/* ============================================================
   cctv-demo dashboard — design tokens
   A calm, legible operations tool, not a marketing page.
   Color is reserved for meaning: amber = awaiting human review
   (the core safety feature of this system), green = resolved
   safely, muted red = reserved only for active wanted-suspect
   matches. Category color-coding is used consistently across
   badges and list rows so the eye learns it once.
   ============================================================ */

:root {
  --bg: #EEF1F6;
  --surface: #FFFFFF;
  --text: #1A2233;
  --text-muted: #677084;
  --border: #E6E9EF;

  --brand: #1E2A4A;
  --brand-light: #2C3B63;
  --brand-contrast: #EDEFF4;

  --pending: #E08A2E;
  --pending-bg: #FDF1E1;
  --confirmed: #2E9B6B;
  --confirmed-bg: #E6F6EE;
  --dismissed: #6B7280;
  --dismissed-bg: #EEF0F3;

  --cat-wanted: #D6453F;
  --cat-wanted-bg: #FCEAEA;
  --cat-missing: #2E7DD1;
  --cat-missing-bg: #E9F1FC;
  --cat-banned: #C68A1F;
  --cat-banned-bg: #FCF1DD;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Roboto Mono", Consolas, "Liberation Mono", monospace;

  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(20,25,40,0.04), 0 1px 1px rgba(20,25,40,0.03);
  --shadow-md: 0 4px 14px rgba(20,25,40,0.07);
  --shadow-lg: 0 10px 28px rgba(20,25,40,0.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: inherit; }

.shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidenav {
  width: 230px;
  flex-shrink: 0;
  background: linear-gradient(165deg, var(--brand) 0%, #16203A 100%);
  color: var(--brand-contrast);
  display: flex;
  flex-direction: column;
  padding: 22px 0;
  height: 100vh;
  position: sticky;
  top: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px 18px 22px;
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}
.brand-mark {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--pending);
  box-shadow: 0 0 0 4px rgba(224,138,46,0.22);
}
.sidenav-search { padding: 0 16px 14px 16px; flex-shrink: 0; }
.sidenav-search input {
  width: 100%; box-sizing: border-box; padding: 9px 12px; border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.14); background: rgba(255,255,255,0.06);
  color: #fff; font-size: 13px;
}
.sidenav-search input::placeholder { color: #8B94AC; }
.sidenav-search input:focus { outline: none; border-color: var(--pending); background: rgba(255,255,255,0.1); }
/* Only this links area scrolls — brand, search, and footer stay put */
.sidenav-links { flex: 1 1 auto; overflow-y: auto; min-height: 0; padding: 4px 10px; }
.sidenav a {
  display: block;
  padding: 11px 14px;
  margin-bottom: 2px;
  text-decoration: none;
  color: #B7BFD3;
  font-size: 14px;
  font-weight: 500;
  border-radius: 9px;
  border-left: 3px solid transparent;
}
.sidenav a:hover { color: #fff; background: rgba(255,255,255,0.06); }
.sidenav a.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(224,138,46,0.22) 0%, rgba(255,255,255,0.05) 100%);
  border-left: 3px solid var(--pending);
  font-weight: 700;
}
.sidenav a.sidenav-sublink {
  padding-left: 30px;
  font-size: 12.5px;
  color: #9AA3B8;
}
.sidenav a.sidenav-sublink:before { content: "› "; }

/* ---------- Collapsible Settings dropdown group ---------- */
.sidenav-group-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 11px 14px; margin-bottom: 2px;
  background: none; border: none; border-radius: 9px; border-left: 3px solid transparent;
  color: #B7BFD3; font-size: 14px; font-weight: 500; font-family: inherit;
  cursor: pointer; text-align: left;
}
.sidenav-group-toggle:hover { color: #fff; background: rgba(255,255,255,0.06); }
.sidenav-group-toggle.active-parent {
  color: #fff;
  font-weight: 700;
  background: linear-gradient(90deg, rgba(224,138,46,0.22) 0%, rgba(255,255,255,0.05) 100%);
  border-left: 3px solid var(--pending);
}
.sidenav-chevron { font-size: 10px; transition: transform 0.15s ease; }
.sidenav-group-toggle.open .sidenav-chevron { transform: rotate(90deg); }
.sidenav-subgroup {
  max-height: 0; overflow: hidden;
  transition: max-height 0.18s ease;
}
.sidenav-subgroup.open { max-height: 220px; }
.sidenav-footer {
  flex-shrink: 0;
  margin-top: 0;
  padding: 18px 22px 0 22px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.user-chip { margin-bottom: 8px; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-role {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: #9aa3b5;
}
.sidenav-footer-link {
  display: inline-block; margin-top: 10px; font-size: 12.5px;
  color: #B7BFD3; text-decoration: none;
}
.sidenav-footer-link:hover { color: #fff; text-decoration: underline; }
.logout-link { font-size: 13px; color: #C7CCDA; text-decoration: underline; }

/* ---------- Content ---------- */
.content { flex: 1; padding: 22px 32px; max-width: 1400px; }

/* ---------- Top bar (Dashboard / Back / Forward / Sign out) ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin: -22px -32px 18px -32px; padding: 11px 32px;
  box-shadow: var(--shadow-sm); background: var(--surface);
}
.topbar-nav { display: flex; align-items: center; gap: 8px; }
.topbar-title { font-weight: 700; font-size: 15px; margin-left: 8px; color: var(--text); }
.topbar-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer;
  font-size: 16px; line-height: 1; font-family: inherit;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.topbar-btn:hover { background: var(--bg); border-color: #D5DAE3; }
.btn-signout {
  display: inline-flex; align-items: center; padding: 8px 18px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  text-decoration: none; font-size: 13px; font-weight: 700;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn-signout:hover { background: var(--cat-wanted-bg); border-color: var(--cat-wanted); color: var(--cat-wanted); }
.content--bare {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; width: 100%; padding: 24px;
}

.eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--text-muted); font-weight: 700; margin-bottom: 6px;
}
h1 { font-size: 22px; font-weight: 800; margin: 0 0 3px 0; letter-spacing: -0.01em; }
h2 { font-size: 15.5px; font-weight: 700; margin: 0 0 10px 0; }
.page-sub { color: var(--text-muted); margin: 0 0 16px 0; font-size: 13.5px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}

/* ---------- Stat tiles ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat-tile {
  display: flex; align-items: flex-start; gap: 12px;
  text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius); padding: 14px 16px;
  transition: box-shadow 0.15s ease, transform 0.12s ease;
}
.stat-tile:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: #fff;
}
.stat-tile-body { min-width: 0; }
.stat-tile .num { font-family: var(--font-mono); font-size: 23px; font-weight: 800; line-height: 1.1; color: var(--text); }
.stat-tile .label { font-size: 12px; color: var(--text-muted); margin-top: 2px; font-weight: 500; }
.stat-tile.is-pending .stat-icon { background: var(--pending); }
.stat-tile.is-pending .num { color: var(--pending); }
.stat-tile.is-wanted .stat-icon { background: var(--cat-wanted); }
.stat-tile.is-wanted .num { color: var(--cat-wanted); }
.stat-tile.is-missing .stat-icon { background: var(--cat-missing); }
.stat-tile.is-missing .num { color: var(--cat-missing); }
.stat-tile.is-banned .stat-icon { background: var(--cat-banned); }
.stat-tile.is-banned .num { color: var(--cat-banned); }

/* ---------- Badges (category / status) — color-coded consistently ---------- */
.badge {
  display: inline-block; font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em;
  padding: 4px 10px; border-radius: 100px; text-transform: uppercase;
}
.badge-wanted   { background: var(--cat-wanted-bg);   color: var(--cat-wanted); }
.badge-missing  { background: var(--cat-missing-bg);  color: var(--cat-missing); }
.badge-banned   { background: var(--cat-banned-bg);   color: var(--cat-banned); }
.badge-pending     { background: var(--pending-bg);   color: var(--pending); }
.badge-confirmed   { background: var(--confirmed-bg); color: var(--confirmed); }
.badge-false_positive { background: var(--dismissed-bg); color: var(--dismissed); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em;
     color: var(--text-muted); padding: 10px 10px; border-bottom: 1px solid var(--border); }
td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.mono { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); }

/* ---------- Forms ---------- */
label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.field { margin-bottom: 11px; }
.hint { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=file], input[type=number],
select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--font-ui); font-size: 13.5px; background: #fff; color: var(--text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-light); box-shadow: 0 0 0 3px rgba(44,59,99,0.12);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .field--full { grid-column: 1 / -1; }

.btn {
  display: inline-block; padding: 10px 18px; border-radius: 9px; border: 1px solid transparent;
  font-size: 14px; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: transform 0.08s ease, box-shadow 0.12s ease;
}
.btn:hover { box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-light); }
.btn-confirm { background: var(--confirmed); color: #fff; }
.btn-dismiss { background: #fff; color: var(--text-muted); border-color: var(--border); }
.btn-dismiss:hover { background: var(--dismissed-bg); }

.alert { padding: 13px 16px; border-radius: 9px; font-size: 13.5px; margin-bottom: 18px; }
.alert-error { background: var(--cat-wanted-bg); color: var(--cat-wanted); }
.alert-success { background: var(--confirmed-bg); color: var(--confirmed); }

/* ---------- Match review cards (signature element) ----------
   The confidence meter + PENDING state is the one thing this
   page should be remembered by: a visible, deliberate pause
   before any action happens. */
.match-card {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--pending);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px;
}
.match-card.is-resolved { border-left-color: var(--border); opacity: 0.75; }
.match-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.match-meta { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.confidence-row { margin: 12px 0; }
.confidence-label { font-size: 11.5px; color: var(--text-muted); margin-bottom: 4px; }
.confidence-track { background: var(--bg); border-radius: 100px; height: 8px; overflow: hidden; }
.confidence-fill { background: var(--pending); height: 100%; }
.match-actions { display: flex; gap: 10px; margin-top: 12px; }

/* ---------- Login page ---------- */
.login-card {
  width: 380px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius); padding: 36px 32px;
}
.login-brand { text-align: center; margin-bottom: 24px; font-weight: 800; font-size: 19px; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidenav { width: 100%; flex-direction: row; flex-wrap: wrap; padding: 12px; }
  .sidenav-footer { display: none; }
  .content { padding: 20px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Overview page two-column layout ---------- */
.dash-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
@media (max-width: 980px) { .dash-grid { grid-template-columns: 1fr; } }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } }

.insights-panel {
  background: linear-gradient(165deg, var(--brand) 0%, #16203A 100%);
  color: #fff; border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 20px 20px 22px 20px;
}
.insights-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.insights-panel-head h2 { font-size: 14.5px; margin: 0; color: #fff; }
.insights-badge {
  background: var(--cat-wanted); color: #fff; font-size: 11.5px; font-weight: 700;
  border-radius: 999px; padding: 2px 8px; min-width: 18px; text-align: center;
}
.insights-empty { color: #C7CCDA; font-size: 13px; margin: 10px 0 0; }
.insight-item {
  border-top: 1px solid rgba(255,255,255,0.1); padding: 12px 0;
}
.insight-item:first-of-type { border-top: none; padding-top: 14px; }
.insight-item-title { font-size: 13.5px; font-weight: 600; color: #fff; }
.insight-item-sub { font-size: 12px; color: #AEB6CB; margin-top: 2px; }
.insight-item-action {
  display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 600;
  color: #FBCB8C; text-decoration: none;
}
.insight-item-action:hover { text-decoration: underline; }

/* ---------- Reports ---------- */
.report h1 { font-size: 19px; margin-bottom: 4px; }
.report h2 { font-size: 15px; margin: 22px 0 10px; }
.report .report-meta { color: var(--text-muted); font-size: 13px; margin-bottom: 18px; }
.report table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 6px; }
.report table th, .report table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }

@media print {
  .sidenav, .page-sub a, button { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
}
