/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Design tokens ── */
:root {
  --navy: #0D1B2A;
  --blue: #1D4ED8;
  --blue-light: #DBEAFE;
  --bg: #F4F6FA;
  --surface: #FFFFFF;
  --muted: #64748B;
  --hint: #94A3B8;
  --border: #E2E8F0;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --font-ui: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --radius-card: 14px;
  --radius-btn: 12px;
  --shadow-card: 0 1px 4px rgba(13,27,42,0.07);
}

/* ── Base ── */
html { font-size: 16px; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--navy);
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--font-mono); }
.text-muted { font-size: 13px; color: var(--muted); }

/* ── Screens ── */
.screen { display: none; padding: 0 20px 100px; min-height: 100dvh; }
.screen.active { display: block; }
.screen-marcar { background: var(--surface); }
.screen-marcar.active { display: flex; flex-direction: column; align-items: center; }

/* ── Login ── */
.login-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100dvh;
  padding: 0 8px;
}
.login-brand {
  text-align: center;
  margin-bottom: 40px;
}
.login-logo {
  width: 64px; height: 64px;
  background: var(--navy);
  color: var(--surface);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 16px;
}
.login-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--navy);
}
.login-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}
.denied-icon { font-size: 48px; margin-bottom: 16px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--navy);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--navy);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--blue); }
.form-error {
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 12px;
  padding: 10px 14px;
  background: rgba(239,68,68,0.08);
  border-radius: 8px;
}
.btn-primary {
  display: block;
  width: 100%;
  height: 52px;
  background: var(--navy);
  color: var(--surface);
  border: none;
  border-radius: var(--radius-btn);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.15s;
}
.btn-primary:active { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-outline {
  display: inline-block;
  padding: 12px 32px;
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.header-brand { font-size: 18px; font-weight: 600; letter-spacing: -0.3px; }

/* ── Avatar ── */
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}
.avatar-lg { width: 64px; height: 64px; font-size: 20px; }

/* ── Greeting ── */
.greeting { font-size: 20px; font-weight: 500; margin-bottom: 2px; }
.greeting-date { font-size: 13px; color: var(--muted); margin-bottom: 20px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  padding: 16px;
  margin-bottom: 12px;
}
.section-title { font-size: 18px; font-weight: 600; }

/* ── Stats ── */
.stats-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  padding: 14px 12px;
  text-align: center;
}
.stat-value { font-family: var(--font-mono); font-size: 20px; margin-bottom: 2px; }
.stat-label { font-size: 11px; color: var(--hint); }

/* ── Status card ── */
.status-card { position: relative; padding-left: 19px; }
.status-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 3px;
}
.status-card.ok::before { background: var(--success); }
.status-card.error::before { background: var(--danger); }
.status-line { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-success { background: var(--success); }
.dot-danger { background: var(--danger); }
.dot-warning { background: var(--warning); }

/* ── CTA button ── */
.btn-cta {
  display: block;
  width: 100%;
  height: 52px;
  background: var(--navy);
  color: var(--surface);
  border: none;
  border-radius: var(--radius-btn);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  margin-top: 8px;
}
.btn-cta:active { opacity: 0.85; }

/* ── Marcar screen ── */
.clock-big { font-size: 48px; margin-top: 60px; text-align: center; line-height: 1; }
.clock-date { font-size: 13px; color: var(--muted); margin-top: 6px; text-align: center; }
.status-chips { display: flex; gap: 12px; margin-top: 28px; }
.chip {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
}

/* ── Mark button ── */
.mark-wrapper {
  position: relative;
  margin-top: 40px;
  width: 200px; height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mark-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--blue-light);
  animation: pulse-ring 2.2s ease-out infinite;
}
.mark-ring:nth-child(1) { width: 170px; height: 170px; animation-delay: 0s; }
.mark-ring:nth-child(2) { width: 200px; height: 200px; animation-delay: 1.1s; }
.mark-ring.confirmed { border-color: rgba(16,185,129,0.3); }

@keyframes pulse-ring {
  0% { transform: scale(0.85); opacity: 0.7; }
  70% { transform: scale(1); opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}

.mark-btn {
  width: 140px; height: 140px;
  border-radius: 50%;
  background: var(--blue);
  border: none;
  color: var(--surface);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.2px;
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: transform 0.1s;
  line-height: 1.3;
}
.mark-btn:active { transform: scale(0.95); }
.mark-btn.disabled { opacity: 0.4; pointer-events: none; }
.mark-btn.confirmed { background: var(--success); }
.mark-verifying { font-size: 11px; color: var(--muted); text-align: center; margin-top: 16px; display: none; }
.mark-note { font-size: 11px; color: var(--muted); text-align: center; margin-top: 32px; max-width: 260px; line-height: 1.5; }
.btn-back-home {
  display: none;
  align-items: center; justify-content: center;
  gap: 6px;
  width: calc(100% - 40px);
  max-width: 350px;
  height: 48px;
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 24px;
}
.btn-back-home.visible { display: flex; }

/* ── Camera overlay ── */
.camera-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  flex-direction: column;
  align-items: center;
  max-width: 430px;
  margin: 0 auto;
}
.camera-overlay.active { display: flex; }
.camera-video { width: 100%; flex: 1; object-fit: cover; transform: scaleX(-1); }
.camera-ui {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.camera-top {
  width: 100%; padding: 20px;
  display: flex; justify-content: space-between; align-items: center;
  pointer-events: auto;
}
.camera-top-text { font-size: 14px; font-weight: 500; color: #fff; }
.camera-close {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none; color: #fff; font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.camera-guide {
  width: 260px; height: 340px;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 50%;
  position: absolute;
  top: 45%; left: 50%;
  transform: translate(-50%, -50%);
}
.camera-bottom {
  width: 100%;
  padding: 32px 20px 48px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  pointer-events: auto;
}
.camera-hint { font-size: 13px; color: rgba(255,255,255,0.7); }
.camera-snap {
  width: 68px; height: 68px;
  border-radius: 50%;
  background: var(--surface);
  border: 4px solid rgba(255,255,255,0.3);
  cursor: pointer;
}
.camera-snap:active { transform: scale(0.92); }
.camera-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity 0.1s; }
.camera-flash.flash { opacity: 0.8; }

/* ── History ── */
.history-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 0 12px;
  position: sticky; top: 0;
  background: var(--bg);
  z-index: 10;
}
.history-title { font-size: 18px; font-weight: 600; }
.month-nav { display: flex; align-items: center; gap: 10px; }
.month-nav button {
  background: none; border: none;
  font-size: 16px; color: var(--muted);
  cursor: pointer; padding: 4px;
}
.month-nav span { font-size: 13px; min-width: 80px; text-align: center; }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.mini-stat {
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  padding: 12px 4px;
}
.mini-stat-value { font-family: var(--font-mono); font-size: 18px; }
.mini-stat-label { font-size: 10px; color: var(--hint); margin-top: 2px; }
.day-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.day-left { text-align: center; min-width: 36px; }
.day-abbr { font-size: 11px; color: var(--hint); }
.day-num { font-size: 15px; font-weight: 500; }
.day-mid { flex: 1; }
.day-times { font-family: var(--font-mono); font-size: 13px; }
.day-hours { font-size: 12px; color: var(--muted); margin-top: 2px; }
.badge { font-size: 10px; padding: 3px 8px; border-radius: 20px; font-weight: 500; white-space: nowrap; flex-shrink: 0; }
.badge-presente { background: rgba(16,185,129,0.1); color: var(--success); }
.badge-tarde { background: rgba(245,158,11,0.1); color: var(--warning); }
.badge-ausente { background: rgba(239,68,68,0.1); color: var(--danger); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--hint); font-size: 14px; }

/* ── Profile ── */
.profile-top { display: flex; flex-direction: column; align-items: center; padding: 24px 0 20px; }
.profile-name { font-size: 18px; font-weight: 600; margin-top: 12px; }
.profile-role { font-size: 13px; color: var(--muted); margin-top: 2px; text-align: center; }
.info-card { margin-bottom: 12px; }
.info-label { font-size: 10px; color: var(--hint); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.info-value { font-size: 14px; }
.info-row { display: flex; align-items: center; justify-content: space-between; }
.badge-verified { font-size: 11px; color: var(--blue); background: var(--blue-light); padding: 3px 10px; border-radius: 20px; font-weight: 500; }
.info-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.profile-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; }
.profile-stat { text-align: center; padding: 8px 0; }
.profile-stat:not(:last-child) { border-right: 1px solid var(--border); }
.profile-stat-value { font-family: var(--font-mono); font-size: 18px; }
.profile-stat-label { font-size: 10px; color: var(--hint); margin-top: 2px; }
.btn-logout {
  display: block; width: 100%; height: 48px;
  background: var(--surface);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius-btn);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 24px;
}
.btn-logout:active { opacity: 0.8; }

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed; bottom: 0;
  left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 64px;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none;
  cursor: pointer; padding: 8px 12px;
  font-family: var(--font-ui);
  color: var(--hint);
}
.nav-item.active { color: var(--navy); }
.nav-icon { width: 22px; height: 22px; }
.nav-label { font-size: 10px; font-weight: 500; }

/* ── Loading spinner ── */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
