/* ============================================================
   AFIS Panel — Tema claro
   Barra de ícones, títulos em azul-marinho, ação em laranja,
   cartões brancos com sombra suave. Tipografia Nunito Sans.
   ============================================================ */

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

:root {
  /* Superfícies */
  --bg-0:      #f4f6fb;   /* fundo da aplicação */
  --bg-1:      #f7f9fd;   /* campos, zonas recuadas, cabeçalhos de tabela */
  --bg-2:      #ffffff;   /* cartões */
  --bg-3:      #eceff7;   /* trilhos, chips neutros */
  --bg-hover:  #f1f4fb;
  --border:    #e5e9f2;
  --border-hi: #d3d9e6;
  --surface-1: var(--bg-1);   /* alias usado no enroll */

  /* Texto */
  --ink:       #1b2559;   /* títulos e números */
  --text-1:    #2b3456;
  --text-2:    #5a6382;
  --text-3:    #8d95b0;

  /* aliases — usados pelos views */
  --text-secondary: var(--text-2);
  --text-muted:     var(--text-3);
  --text-success:   var(--green);
  --text-warning:   var(--yellow);

  /* Dados / ligações / seleção: azul */
  --accent:    #2563eb;
  --accent-d:  #1d4fc4;
  --accent-g:  rgba(37,99,235,.09);

  /* Ação principal: laranja */
  --cta:       #f5a118;
  --cta-2:     #f2b33d;
  --cta-d:     #e08e0b;
  --cta-g:     rgba(245,161,24,.14);

  /* Estados */
  --green:     #16a34a;
  --green-d:   #11823b;
  --green-g:   rgba(22,163,74,.10);

  --red:       #dc2626;
  --red-d:     #b91c1c;
  --red-g:     rgba(220,38,38,.09);

  --yellow:    #b86e00;
  --yellow-g:  rgba(245,161,24,.14);

  --cyan:      #0891b2;
  --cyan-g:    rgba(8,145,178,.10);

  --violet:    #7c4ddb;   /* SourceAFIS */
  --violet-g:  rgba(124,77,219,.10);
  --orange:    #ea7a12;
  --lime:      #4d9a1a;

  --rail-w:    72px;
  --sidebar-w: var(--rail-w);
  --radius:    9px;
  --radius-lg: 14px;
  --shadow:    0 1px 2px rgba(27,37,89,.04), 0 6px 20px rgba(27,37,89,.045);
  --shadow-cta:0 4px 12px rgba(245,161,24,.30);

  --font-ui:   'Nunito Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', 'Cascadia Mono', Consolas, monospace;
}

html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg-0);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-d); }

code, kbd, pre { font-family: var(--font-mono); font-size: .88em; }
code { background: var(--bg-3); color: var(--ink); padding: 1px 6px; border-radius: 5px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Layout ─────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar: barra de ícones ───────────────────────────── */
.sidebar {
  width: var(--rail-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  padding: 18px 0 16px;
}

.sidebar-logo { display: flex; align-items: center; justify-content: center; margin-bottom: 18px; }
.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2.5px solid var(--cta);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.sidebar-logo .logo-icon svg { width: 22px; height: 22px; }

.sidebar-nav {
  flex: 1;
  width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  overflow: visible;
  padding: 4px 0;
}

.nav-sep { width: 28px; height: 1px; background: var(--border); margin: 8px 0; flex-shrink: 0; }

.nav-item {
  position: relative;
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  color: var(--text-3);
  flex-shrink: 0;
  transition: background .12s, color .12s, box-shadow .12s;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-label { display: none; }

.nav-item:hover { background: var(--bg-hover); color: var(--ink); }

.nav-item.active {
  background: var(--bg-2);
  color: var(--cta);
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(27,37,89,.10);
}

/* Etiqueta ao passar o rato (as etiquetas não cabem na barra) */
.nav-item[data-tip]:hover::after,
.nav-item[data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  background: var(--ink); color: #fff;
  font-size: 12.5px; font-weight: 700; white-space: nowrap;
  padding: 6px 10px; border-radius: 7px;
  box-shadow: 0 6px 18px rgba(27,37,89,.18);
  pointer-events: none; z-index: 200;
}

.nav-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--cta); color: #fff;
  font-size: 10px; font-weight: 800; line-height: 17px; text-align: center;
  border: 2px solid var(--bg-2);
}

.sidebar-footer {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding-top: 12px; border-top: 1px solid var(--border); width: 44px;
}
.nav-logout:hover { color: var(--red); background: var(--red-g); }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: #e8f6ee; color: var(--green-d);
  border: 1px solid rgba(22,163,74,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; cursor: default;
}

/* ── Main ─────────────────────────────────────────────────── */
.main {
  margin-left: var(--rail-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Cabeçalho da página (título grande, sem barra) */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 26px 36px 4px;
}
.topbar > div:first-child { flex: 1; }
.topbar-title { font-size: 28px; font-weight: 800; color: var(--ink); letter-spacing: -.02em; line-height: 1.15; }
.topbar-sub   { font-size: 14px; color: var(--text-2); margin-top: 4px; }

.content { padding: 22px 36px 36px; flex: 1; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 22px;
}

/* Cabeçalho do cartão com divisória a toda a largura */
.card > .card-header:first-child {
  margin: -22px -24px 18px;
  padding: 18px 24px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 16px; font-weight: 800; color: var(--ink); letter-spacing: -.005em; }

/* ── Stats: uma faixa única com divisórias ───────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(4,1fr);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  overflow: hidden;
}
.stat-card {
  padding: 24px 28px;
  display: flex; flex-direction: column; gap: 4px;
  border-left: 1px solid var(--border);
}
.stat-card:first-child { border-left: none; }
.stat-icon  { display: none; }   /* ícones emoji não combinam com o tema */
.stat-value { order: -1; font-size: 34px; font-weight: 800; color: var(--ink); line-height: 1.1; letter-spacing: -.02em; }
.stat-label { font-size: 14px; font-weight: 700; color: var(--text-1); }
.stat-sub   { font-size: 12.5px; color: var(--text-3); }
/* cartões de estatística soltos (fora de .stats-grid) */
:not(.stats-grid) > .stat-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}

/* ── Table ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  padding: 11px 14px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-3);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-1);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-1); }
.td-muted { color: var(--text-3); font-size: 12.5px; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 700; line-height: 1.6;
  white-space: nowrap;
}

.badge-green  { background: var(--green-g);  color: var(--green-d); }
.badge-red    { background: var(--red-g);    color: var(--red-d); }
.badge-yellow { background: var(--yellow-g); color: var(--yellow); }
.badge-blue   { background: var(--accent-g); color: var(--accent); }
.badge-gray   { background: var(--bg-3);     color: var(--text-2); }

.nfiq-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1.6; }
.nfiq-1 { background: var(--green-g);  color: var(--green-d); }
.nfiq-2 { background: rgba(77,154,26,.10); color: var(--lime); }
.nfiq-3 { background: var(--yellow-g); color: var(--yellow); }
.nfiq-4 { background: rgba(234,122,18,.12); color: var(--orange); }
.nfiq-5 { background: var(--red-g);    color: var(--red-d); }
.nfiq-na{ background: var(--bg-3);     color: var(--text-3); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px; font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s, filter .12s;
  text-decoration: none;
  line-height: 1.3;
}

/* Ação principal: laranja */
.btn-primary {
  background: linear-gradient(180deg, var(--cta-2), var(--cta));
  color: #fff; border-color: var(--cta);
  box-shadow: var(--shadow-cta);
}
.btn-primary:hover { background: var(--cta-d); border-color: var(--cta-d); color: #fff; }
.btn-success  { background: var(--green);   color: #fff; border-color: var(--green); }
.btn-success:hover  { background: var(--green-d); color: #fff; }
.btn-danger   { background: var(--red);     color: #fff; border-color: var(--red); }
.btn-danger:hover   { background: var(--red-d); color: #fff; }
.btn-ghost    { background: var(--bg-2); color: var(--ink); border-color: var(--border-hi); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--ink); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

/* ── Forms ───────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-full { grid-column: 1/-1; }

.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-label { font-size: 13.5px; font-weight: 700; color: var(--ink); }

.form-control {
  background: var(--bg-2);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  color: var(--text-1);
  padding: 10px 13px;
  font-family: inherit;
  font-size: 14px;
  transition: border-color .12s, box-shadow .12s, background .12s;
  width: 100%;
}

.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.14); }
.form-control::placeholder { color: var(--text-3); }
select.form-control option { background: var(--bg-2); color: var(--text-1); }

input[type=file] { font-family: inherit; font-size: 13.5px; color: var(--text-2); }
input[type=file]::file-selector-button {
  font-family: inherit; font-size: 13.5px; font-weight: 700;
  margin-right: 12px; padding: 7px 13px;
  border: 1px solid var(--border-hi); border-radius: var(--radius);
  background: var(--bg-2); color: var(--ink); cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--bg-hover); }

/* ── Upload zone ─────────────────────────────────────────── */
.upload-zone {
  border: 1.5px dashed var(--border-hi);
  border-radius: var(--radius-lg);
  padding: 34px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: var(--bg-1);
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--accent); background: var(--accent-g); }
.upload-zone input[type=file] { display: none; }
.upload-icon { font-size: 32px; margin-bottom: 8px; color: var(--text-3); }
.upload-text { color: var(--ink); font-size: 14.5px; font-weight: 700; }
.upload-sub  { color: var(--text-3); font-size: 12.5px; margin-top: 4px; }

.upload-preview { margin-top: 12px; display: none; }
.upload-preview img { max-height: 120px; border-radius: var(--radius); border: 1px solid var(--border); background: #fff; }
.upload-preview .file-name { font-size: 12.5px; color: var(--text-2); margin-top: 6px; }

/* ── Score meter ─────────────────────────────────────────── */
.score-meter { display: flex; align-items: center; gap: 10px; }
.score-bar-wrap { flex: 1; height: 7px; background: var(--bg-3); border-radius: 4px; overflow: hidden; }
.score-bar { height: 100%; border-radius: 4px; transition: width .5s; }
.score-val { font-size: 14px; font-weight: 800; min-width: 36px; text-align: right; }

/* ── Fingerprint display ─────────────────────────────────── */
.finger-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 10px; }

.finger-slot {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  font-size: 12px; font-weight: 600;
  color: var(--text-3);
  background: var(--bg-1);
  cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
  padding: 8px;
  text-align: center;
}
.finger-slot.enrolled { border-color: var(--green); background: var(--green-g); color: var(--green-d); }
.finger-slot:hover { border-color: var(--accent); background: var(--accent-g); color: var(--accent); }
.finger-icon { font-size: 20px; }

/* ── Alert / Flash ───────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  margin-bottom: 22px;
  font-size: 14px;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid transparent;
}
.alert-success { background: #eefaf2; border-color: #c6ebd3; color: var(--green-d); }
.alert-error   { background: #fdf1f1; border-color: #f5cccc; color: var(--red-d); }
.alert-info    { background: #eef3fe; border-color: #cddbfa; color: var(--accent-d); }
.alert-warning { background: #fff8e8; border-color: #f6dca2; color: #94590a; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; margin-top: 16px; }
.page-btn {
  padding: 6px 11px; border-radius: 8px; font-size: 13px; font-weight: 700;
  border: 1px solid var(--border-hi); color: var(--text-2);
  background: var(--bg-2); cursor: pointer;
}
.page-btn:hover { background: var(--bg-hover); color: var(--ink); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Search bar ──────────────────────────────────────────── */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar .form-control { flex: 1; }

/* ── Result panel (verify/identify) ─────────────────────── */
.result-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-top: 22px;
  display: none;
  background: var(--bg-2);
}
.result-header { padding: 15px 22px; display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 15.5px; }
.result-match    { background: #eefaf2; border-bottom: 1px solid #c6ebd3; color: var(--green-d); }
.result-nomatch  { background: #fdf1f1; border-bottom: 1px solid #f5cccc; color: var(--red-d); }
.result-identify { background: #eef3fe; border-bottom: 1px solid #cddbfa; color: var(--accent-d); }
.result-body { padding: 22px; background: var(--bg-2); }

/* ── Log timeline ────────────────────────────────────────── */
.log-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.log-row:last-child { border-bottom: none; }
.log-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; }
.log-dot-match   { background: var(--green); }
.log-dot-nomatch { background: var(--red); }
.log-dot-id      { background: var(--accent); }
.log-info { flex: 1; }
.log-time { font-size: 12.5px; color: var(--text-3); }

/* ── Login: ecrã dividido ────────────────────────────────── */
.login-split { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; background: var(--bg-2); }

.login-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, #f6f8fd 0%, #eef3fc 100%);
  border-right: 1px solid var(--border);
  padding: 44px 64px;
  display: flex; flex-direction: column;
}
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand .logo-icon {
  width: 38px; height: 38px; border-radius: 50%; border: 2.5px solid var(--cta);
  color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.login-brand .logo-icon svg { width: 21px; height: 21px; }
.login-brand strong { display: block; font-size: 16px; font-weight: 800; color: var(--ink); line-height: 1.2; }
.login-brand span   { display: block; font-size: 12.5px; color: var(--text-3); }

.login-hero-body { flex: 1; display: flex; flex-direction: column; justify-content: center; max-width: 560px; position: relative; z-index: 1; }
.login-hero h2 {
  font-size: clamp(40px, 4.6vw, 64px); font-weight: 800; color: var(--ink);
  letter-spacing: -.035em; line-height: 1.02; margin-bottom: 18px;
}
.login-hero h2 .muted { color: var(--cta); }
.login-hero p { font-size: 16px; color: var(--text-2); max-width: 460px; }

.login-features { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; position: relative; z-index: 1; }
.login-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 14px; font-size: 13px; font-weight: 700; color: var(--ink);
}
.login-chip svg { width: 15px; height: 15px; color: var(--green); }

.login-print {
  position: absolute; right: -120px; bottom: -120px;
  width: 520px; height: 520px; color: #c9d6f2; opacity: .9; pointer-events: none;
}

.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-form { width: 420px; max-width: 100%; }
.login-form h1 { font-size: 30px; font-weight: 800; color: var(--ink); letter-spacing: -.02em; margin-bottom: 8px; }
.login-form .lead { font-size: 15px; color: var(--text-2); margin-bottom: 28px; }
.login-form .form-group { margin-bottom: 18px; }

.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-3); pointer-events: none; }
.input-icon .form-control { padding-left: 42px; height: 48px; background: var(--bg-1); border-radius: 11px; }
.input-icon .form-control:focus { background: var(--bg-2); }

.login-form .btn-primary { width: 100%; height: 48px; font-size: 15px; border-radius: 11px; margin-top: 6px; }
.login-foot { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border); text-align: center; font-size: 12.5px; color: var(--text-3); }

/* ── Misc ────────────────────────────────────────────────── */
.text-muted  { color: var(--text-3); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-blue   { color: var(--accent); }
.text-mono   { font-family: var(--font-mono); font-size: 12.5px; }
.fw-600      { font-weight: 700; }
.mt-4        { margin-top: 4px; }
.mt-8        { margin-top: 8px; }
.mt-16       { margin-top: 16px; }
.mb-16       { margin-bottom: 16px; }
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; gap: 8px; }
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.empty-state { text-align: center; padding: 40px; color: var(--text-3); }
.empty-icon  { font-size: 36px; margin-bottom: 8px; }
.divider     { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.45);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

* { scrollbar-width: thin; scrollbar-color: var(--border-hi) transparent; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .stat-card:nth-child(3) { border-left: none; }
  .stat-card:nth-child(n+3) { border-top: 1px solid var(--border); }
}
@media (max-width: 900px) {
  .login-split { grid-template-columns: 1fr; }
  .login-hero { display: none; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .content { padding: 18px; }
  .topbar { padding: 20px 18px 0; }
  .topbar-title { font-size: 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .finger-grid { grid-template-columns: repeat(5,1fr); }
}
