/* ============================================================
   Stonewall Security — Admin Portal design system (dark only)
   Brand-derived gold accent on a near-black canvas.
   ============================================================ */
:root {
  /* Surfaces */
  --bg: #08090b;
  --sidebar: #0c0d10;
  --surface: #131418;
  --surface-2: #171922;
  --surface-3: #1d1f27;
  --border: #24262d;
  --border-strong: #33353e;

  /* Text */
  --text: #e9eaee;
  --text-2: #9a9da7;
  --text-3: #6a6d77;

  /* Accents */
  --accent: #cdad6e;          /* Stonewall gold */
  --accent-2: #b89a5f;
  --accent-soft: rgba(205, 173, 110, 0.14);
  --accent-line: rgba(205, 173, 110, 0.9);
  --blue: #6f8dff;            /* secondary chart hue */
  --blue-soft: rgba(111, 141, 255, 0.16);
  --positive: #52b981;
  --warning: #d9a441;
  --negative: #d4526b;
  --focus: #cdad6e;

  /* Shadows / radius / spacing */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-3: 0 24px 60px rgba(0, 0, 0, 0.5);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;

  --sidebar-w: 236px;
  --header-h: 68px;
  --grid: rgba(255, 255, 255, 0.06);
  --dur: 0.18s;

  --font: 'Inter', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Buttons / controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font-size: 13px; font-weight: 500; cursor: pointer; transition: background var(--dur), border-color var(--dur);
}
.btn:hover { background: var(--surface-3); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #17130a; font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.field {
  width: 100%; height: 44px; padding: 0 14px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
  font-size: 14px; transition: border-color var(--dur), box-shadow var(--dur);
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field::placeholder { color: var(--text-3); }
select.field { appearance: none; cursor: pointer; }
label.lbl { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; letter-spacing: 0.02em; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(205,173,110,0.06), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(111,141,255,0.05), transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3); padding: 36px 32px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-brand img { width: 40px; height: 40px; }
.login-brand .bn { font-weight: 700; letter-spacing: 0.14em; font-size: 15px; text-transform: uppercase; }
.login-brand .bs { color: var(--text-3); font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase; }
.login-title { font-size: 20px; margin-bottom: 4px; }
.login-sub { color: var(--text-2); font-size: 13px; margin: 0 0 24px; }
.form-row { margin-bottom: 16px; }
.pw-wrap { position: relative; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  height: 32px; width: 34px; display: grid; place-items: center;
  background: transparent; border: 0; color: var(--text-3); cursor: pointer; border-radius: 6px;
}
.pw-toggle:hover { color: var(--text); }
.field-error { color: var(--negative); font-size: 12px; margin-top: 6px; min-height: 16px; }
.form-alert {
  background: rgba(212,82,107,0.1); border: 1px solid rgba(212,82,107,0.3); color: #f0a9b6;
  border-radius: var(--r-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 16px; display: none;
}
.form-alert.show { display: block; }
.login-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; }
.login-foot a { color: var(--text-2); font-size: 12.5px; }
.login-foot a:hover { color: var(--accent); }
.login-reassure {
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border);
  color: var(--text-3); font-size: 11.5px; display: flex; align-items: center; gap: 8px;
}
.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(23,19,10,0.35);
  border-top-color: #17130a; border-radius: 50%; animation: spin 0.7s linear infinite;
}
.btn-ghost .spinner, .spinner-light { border-color: rgba(255,255,255,0.3); border-top-color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }
.otp-inputs { display: flex; gap: 8px; justify-content: space-between; margin: 8px 0 4px; }
.otp-inputs input {
  width: 46px; height: 54px; text-align: center; font-size: 22px; font-family: var(--mono);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-sm); color: var(--text);
}
.otp-inputs input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.qr-box { display: grid; place-items: center; background: #fff; border-radius: var(--r-sm); padding: 14px; margin: 12px 0; }
.qr-box svg { width: 180px; height: 180px; }
.secret-code { font-family: var(--mono); font-size: 12px; color: var(--text-2); word-break: break-all; text-align: center; }
.view { display: none; }
.view.active { display: block; }

/* ============================================================
   SHELL
   ============================================================ */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; background: var(--sidebar);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 20px 14px;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.side-brand img { width: 34px; height: 34px; }
.side-brand .bn { font-weight: 700; letter-spacing: 0.12em; font-size: 13px; text-transform: uppercase; }
.side-brand .bs { color: var(--text-3); font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: 13.5px; font-weight: 500; transition: background var(--dur), color var(--dur);
}
.nav a svg { width: 18px; height: 18px; flex: 0 0 auto; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--text); }
.nav a.active svg { color: var(--accent); }
.side-spacer { flex: 1; }
.side-user {
  border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px;
}
.side-user .who { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.side-user .avatar {
  width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.side-user .meta { min-width: 0; }
.side-user .nm { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .rl { font-size: 11px; color: var(--text-3); text-transform: capitalize; }
.logout-btn {
  width: 100%; margin-top: 8px; height: 36px; background: transparent; border: 1px solid var(--border);
  color: var(--text-2); border-radius: var(--r-sm); cursor: pointer; font-size: 12.5px; display: flex;
  align-items: center; justify-content: center; gap: 8px; transition: color var(--dur), border-color var(--dur);
}
.logout-btn:hover { color: var(--text); border-color: var(--border-strong); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--header-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: rgba(8,9,11,0.85); backdrop-filter: blur(10px); z-index: 20;
}
.topbar h1 { font-size: 18px; }
.topbar .sub { color: var(--text-2); font-size: 12.5px; margin-top: 1px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.content { padding: 24px 28px 48px; }

/* Date range / freshness */
.range-picker { display: flex; align-items: center; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface-2);
  color: var(--text-2); font-size: 12.5px;
}
.freshness { color: var(--text-3); font-size: 11.5px; display: flex; align-items: center; gap: 7px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--positive); }
.dot.stale { background: var(--warning); } .dot.err { background: var(--negative); }

/* ============================================================
   CARDS / PANELS / GRID
   ============================================================ */
.grid { display: grid; gap: 16px; }
.metric-row { grid-template-columns: repeat(6, 1fr); }
.viz-row { grid-template-columns: 2fr 1fr; }
.tri-row { grid-template-columns: 1fr 1fr 1fr; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 18px; box-shadow: var(--shadow-1); min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-title { font-size: 14px; }
.panel-title .hint { color: var(--text-3); cursor: help; margin-left: 6px; font-size: 12px; }

.metric-card { position: relative; }
.metric-card .mlabel { color: var(--text-2); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.metric-card .mval { font-size: 26px; font-weight: 600; margin: 8px 0 6px; letter-spacing: -0.02em; }
.metric-card .mtrend { font-size: 12px; display: inline-flex; align-items: center; gap: 5px; }
.mtrend.up { color: var(--positive); } .mtrend.down { color: var(--negative); }
.mtrend.flat, .mtrend.new { color: var(--text-3); }
.metric-card .mcompare { color: var(--text-3); font-size: 11px; margin-top: 4px; }
.metric-card .micon {
  position: absolute; top: 16px; right: 16px; width: 30px; height: 30px; border-radius: 8px;
  background: var(--surface-2); display: grid; place-items: center; color: var(--text-2);
}
.metric-card .micon svg { width: 16px; height: 16px; }

/* Tables */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--text-3); font-weight: 500; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 0 8px 10px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.bar-cell { position: relative; }
.bar-cell .bar { position: absolute; left: 8px; bottom: 4px; height: 3px; background: var(--accent); border-radius: 2px; opacity: 0.6; }

/* Legend */
.legend { display: flex; flex-direction: column; gap: 10px; }
.legend .li { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; }
.legend .lk { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.legend .sw { width: 9px; height: 9px; border-radius: 3px; }
.legend .lv { color: var(--text); font-variant-numeric: tabular-nums; }

/* Vitals */
.vital { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.vital:last-child { border-bottom: 0; }
.vital .vn { font-weight: 600; }
.vital .vd { color: var(--text-3); font-size: 11.5px; }
.rating { font-size: 11px; padding: 3px 9px; border-radius: 999px; text-transform: capitalize; }
.rating.good { background: rgba(82,185,129,0.14); color: var(--positive); }
.rating\.needs-improvement, .rating.needs-improvement { background: rgba(217,164,65,0.14); color: var(--warning); }
.rating.poor { background: rgba(212,82,107,0.14); color: var(--negative); }
.rating.unknown { background: var(--surface-2); color: var(--text-3); }

/* States */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 6px; }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.state { text-align: center; color: var(--text-2); padding: 40px 20px; }
.state .ico { width: 40px; height: 40px; margin: 0 auto 12px; color: var(--text-3); }
.state .t { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.state .d { font-size: 13px; }
.state.error .t { color: var(--negative); }
.annot { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.annot .a { font-size: 12.5px; padding: 8px 12px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); display: flex; align-items: center; gap: 8px; }
.annot .a.attention { border-color: rgba(217,164,65,0.35); }
.annot .a.positive { border-color: rgba(82,185,129,0.3); }

/* Tooltip */
.tt { position: fixed; z-index: 100; pointer-events: none; background: var(--surface-3); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow-2); max-width: 260px; display: none; }
.tt.show { display: block; }
.tt .k { color: var(--text-3); } .tt .v { color: var(--text); font-variant-numeric: tabular-nums; }

/* Charts */
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--text-3); font-size: 10px; font-family: var(--mono); }
.spark { width: 90px; height: 28px; }

/* Section title */
.section-h { display: flex; align-items: center; gap: 10px; margin: 28px 0 14px; }
.section-h h2 { font-size: 15px; }
.section-h .rule { flex: 1; height: 1px; background: var(--border); }
.source-tag { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }

/* ============================================================
   PAGE FLOW GRAPH
   ============================================================ */
/* ============================================================
   Page Flow — live force-directed map
   ============================================================ */
.flow-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .flow-layout { grid-template-columns: 1fr; } }

/* --- control bar --- */
.flow-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.flow-bar .field { height: 34px; width: auto; min-width: 118px; }
.flow-sep { width: 1px; height: 22px; background: var(--border); margin: 0 2px; }

.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; }
.seg button { appearance: none; border: 0; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 550;
  color: var(--text-2); background: transparent; padding: 6px 13px; border-radius: 7px;
  display: inline-flex; align-items: center; gap: 6px; transition: color var(--dur), background var(--dur); }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(205,173,110,0.28); }
.seg button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.seg .pulse { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.seg button.on .pulse { background: var(--positive); animation: livePulse 2s ease-in-out infinite; }
@keyframes livePulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.45; transform: scale(0.78); } }

.freshness.is-live .dot { background: var(--positive); box-shadow: 0 0 0 3px rgba(82,185,129,0.16);
  animation: livePulse 2s ease-in-out infinite; }

/* --- canvas --- */
.flow-canvas-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  height: 660px;
  /* Layered gradient ground: a warm brass bloom top-left, a cool signal blue
     bottom-right, over a deep slate base with a soft vignette to hold the
     edges. No grid — the graph supplies the structure. */
  background:
    radial-gradient(120% 90% at 8% 4%, rgba(205,173,110,0.16) 0%, rgba(205,173,110,0.05) 34%, transparent 62%),
    radial-gradient(95% 85% at 96% 100%, rgba(111,141,255,0.15) 0%, rgba(111,141,255,0.04) 38%, transparent 66%),
    radial-gradient(70% 60% at 50% 46%, rgba(148,163,196,0.055) 0%, transparent 72%),
    radial-gradient(140% 120% at 50% 50%, transparent 52%, rgba(0,0,0,0.42) 100%),
    linear-gradient(168deg, #14161d 0%, #0e1015 46%, #090a0e 100%);
}
.flow-canvas { width: 100%; height: 100%; cursor: grab; display: block; touch-action: none; }
.flow-canvas.panning { cursor: grabbing; }
.flow-canvas:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

/* --- strings --- */
.flow-edge {
  fill: none;
  stroke: url(#edgeGrad);
  stroke-linecap: round;
  transition: opacity var(--dur), stroke-width var(--dur);
  opacity: 0.72;
}
.flow-edge.hot, .flow-edge.sel { opacity: 1; stroke: url(#edgeGradSel); }
.flow-edge.dim { opacity: 0.09; }

/* --- nodes --- */
.flow-node { cursor: grab; transition: opacity var(--dur); }
.flow-node.dragging { cursor: grabbing; }
.flow-node .n-halo { fill: transparent; transition: fill var(--dur); }
.flow-node .n-body {
  fill: url(#nodeGrad);
  stroke: var(--border-strong);
  stroke-width: 1;
  transition: stroke var(--dur), filter var(--dur);
}
.flow-node .n-accent { fill: var(--border-strong); transition: fill var(--dur); }
.flow-node.entry .n-accent { fill: var(--blue); }
.flow-node.keyevent .n-accent { fill: var(--positive); }
.flow-node:hover .n-body { stroke: var(--accent); }
.flow-node:focus-visible .n-body { stroke: var(--accent); stroke-width: 2; }
.flow-node:focus-visible { outline: none; }
.flow-node.sel .n-body { stroke: var(--accent); stroke-width: 1.8; }
.flow-node.sel .n-halo { fill: rgba(205,173,110,0.10); }
.flow-node.dragging .n-halo { fill: rgba(205,173,110,0.16); }
.flow-node.pinned .n-body { stroke-dasharray: 4 3; stroke: var(--accent-2); }
.flow-node.dim { opacity: 0.2; }
.flow-node.search-miss { opacity: 0.12; }

.flow-node .n-title { fill: var(--text); font-size: 12.5px; font-weight: 650; }
.flow-node .n-path { fill: var(--text-3); font-size: 9.5px; font-family: var(--mono); }
.flow-node .n-val { fill: var(--text); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.flow-node .n-metric { fill: var(--text-3); font-size: 9.5px; }
.flow-node .n-bar-bg { fill: rgba(255,255,255,0.07); }
.flow-node .n-bar { fill: var(--accent); opacity: 0.85; }
.flow-node text { pointer-events: none; user-select: none; }

/* --- floating controls --- */
.flow-controls { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 5px;
  padding: 5px; background: rgba(12,13,16,0.72); backdrop-filter: blur(10px);
  border: 1px solid var(--border); border-radius: 11px; box-shadow: var(--shadow-2); }
.flow-controls button { width: 32px; height: 32px; border-radius: 7px; background: transparent; border: 0;
  color: var(--text-2); cursor: pointer; font-size: 15px; line-height: 1; display: grid; place-content: center;
  transition: background var(--dur), color var(--dur); }
.flow-controls button:hover { background: var(--surface-3); color: var(--text); }
.flow-controls button:active { background: var(--accent-soft); color: var(--accent); }
.flow-controls button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.flow-legend { position: absolute; left: 12px; top: 12px; display: grid; gap: 7px;
  background: rgba(12,13,16,0.72); backdrop-filter: blur(10px); border: 1px solid var(--border);
  border-radius: 11px; padding: 11px 13px; font-size: 11.5px; color: var(--text-2); box-shadow: var(--shadow-2); }
.flow-legend .li { display: flex; align-items: center; gap: 8px; }
.flow-legend .swl { width: 15px; height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--blue)); }
.flow-legend .swn { width: 10px; height: 10px; border-radius: 3px; border: 1.5px solid; }
.flow-hint { position: absolute; left: 12px; bottom: 12px; font-size: 11px; color: var(--text-3);
  background: rgba(12,13,16,0.6); backdrop-filter: blur(8px); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; }

/* --- detail panel --- */
.flow-detail { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 18px; min-height: 200px; }
.flow-detail.empty { display: grid; place-content: center; text-align: center; gap: 6px;
  color: var(--text-3); min-height: 300px; }
.fd-empty-icon { font-size: 26px; color: var(--border-strong); }
.fd-empty-t { color: var(--text-2); font-weight: 600; font-size: 14px; }
.fd-empty-d { font-size: 12.5px; line-height: 1.55; max-width: 240px; margin: 0 auto; }

.fd-head { border-bottom: 1px solid var(--border); padding-bottom: 13px; margin-bottom: 14px; }
.fd-title { font-size: 16px; font-weight: 650; color: var(--text); }
.fd-path { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); margin-top: 3px;
  overflow-wrap: anywhere; }
.fd-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 18px; }
.fd-stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; }
.fd-stat-v { font-size: 17px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.fd-stat-k { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.07em; margin-top: 2px; }
.fd-stat.blue .fd-stat-v { color: var(--blue); }
.fd-stat.green .fd-stat-v { color: var(--positive); }

.fd-sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent);
  font-family: var(--mono); margin: 16px 0 9px; }
.fd-rows { display: grid; gap: 9px; }
.fd-row-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; font-size: 12.5px; }
.fd-row-label { color: var(--text); overflow-wrap: anywhere; }
.fd-row-val { color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 11.5px; }
.fd-row-track { height: 4px; background: rgba(255,255,255,0.06); border-radius: 2px; margin-top: 5px; overflow: hidden; }
.fd-row-fill { height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.fd-none { font-size: 12px; color: var(--text-3); font-style: italic; }

@media (prefers-reduced-motion: reduce) {
  .seg button.on .pulse, .freshness.is-live .dot { animation: none; }
}

.kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.kv:last-child { border-bottom: 0; } .kv .k { color: var(--text-2); } .kv .v { font-variant-numeric: tabular-nums; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
  .metric-row { grid-template-columns: repeat(3, 1fr); }
  .viz-row, .tri-row { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%);
    transition: transform 0.25s ease; width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: grid !important; }
  .backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 55; display: none; }
  .backdrop.show { display: block; }
}
@media (max-width: 600px) {
  .metric-row { grid-template-columns: 1fr 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}
.menu-btn { display: none; width: 38px; height: 38px; border-radius: 8px; background: var(--surface-2);
  border: 1px solid var(--border-strong); color: var(--text); cursor: pointer; place-items: center; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ============================================================
   SUBMISSIONS CRM — contact requests + job applications
   ============================================================ */

/* Status tab strip. Counts come from the API's `counts` object; the strip
   scrolls horizontally rather than wrapping so its height stays fixed. */
.status-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 3px; margin-bottom: 14px; }
.stab {
  display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; height: 38px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); color: var(--text-2);
  font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background var(--dur), border-color var(--dur), color var(--dur);
}
.stab:hover { background: var(--surface-2); color: var(--text); }
.stab[aria-pressed="true"] { background: var(--accent-soft); border-color: rgba(205,173,110,0.45); color: var(--text); }
.stab .n { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.stab[aria-pressed="true"] .n { color: var(--accent); }
.sdot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: 0 0 auto; }

/* Filter bar. Field height drops to 38px so inputs line up with .btn / .chip. */
.filter-bar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.filter-bar .fb { display: flex; flex-direction: column; min-width: 0; }
.filter-bar .fb.grow { flex: 1 1 220px; }
.filter-bar .field { height: 38px; width: auto; min-width: 140px; font-size: 13px; }
.filter-bar .fb.grow .field { width: 100%; }
.filter-bar .lbl { margin-bottom: 4px; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.7); cursor: pointer; }

/* Table. .panel carries 18px padding; the negative margin lets the horizontal
   scroll edge sit flush with the panel edge instead of inside it. */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text-2); }
.tbl th .sarrow { margin-left: 5px; color: var(--accent); }
.tbl th.nowrap, .tbl td.nowrap { white-space: nowrap; }
.tbl td.trunc { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl tbody tr.row { cursor: pointer; transition: background var(--dur); }
.tbl tbody tr.row:hover { background: var(--surface-2); }
.tbl tbody tr.row:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.tbl tbody tr.row.sel { background: var(--accent-soft); }
.tbl .t2 { color: var(--text-3); font-size: 11.5px; }
.mono { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.unset { color: var(--text-3); }

/* Status pills — one per contact_status / application_status enum value. */
.pill {
  display: inline-flex; align-items: center; font-size: 11px; padding: 3px 9px;
  border-radius: 999px; text-transform: capitalize; white-space: nowrap;
}
.pill.new { background: var(--blue-soft); color: var(--blue); }
.pill.reviewed, .pill.reviewing { background: var(--accent-soft); color: var(--accent); }
.pill.contacted, .pill.interview, .pill.offer { background: rgba(217,164,65,0.14); color: var(--warning); }
.pill.hired { background: rgba(82,185,129,0.14); color: var(--positive); }
.pill.closed { background: var(--surface-2); color: var(--text-2); }
.pill.rejected, .pill.spam { background: rgba(212,82,107,0.14); color: var(--negative); }
.pill.flag { background: rgba(212,82,107,0.14); color: var(--negative); text-transform: none; }
.sdot.new { background: var(--blue); }
.sdot.reviewed, .sdot.reviewing { background: var(--accent); }
.sdot.contacted, .sdot.interview, .sdot.offer { background: var(--warning); }
.sdot.hired { background: var(--positive); }
.sdot.rejected, .sdot.spam { background: var(--negative); }

/* Pagination */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.pager .info { color: var(--text-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.pager .pbtns { display: flex; align-items: center; gap: 8px; }
.pager .field { height: 34px; width: auto; min-width: 0; font-size: 12.5px; padding: 0 10px; }

/* ---------- Detail drawer ---------- */
/* Sits above the mobile sidebar (60) and below the tooltip (100). */
/* visibility flips instantly on open (so the close button is focusable in the
   same task) and is held back until the slide-out finishes on close. */
.scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 65;
  opacity: 0; visibility: hidden; transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}
.scrim.show { opacity: 1; visibility: visible; transition: opacity 0.2s ease, visibility 0s linear 0s; }
.drawer {
  position: fixed; top: 0; right: 0; z-index: 70; height: 100vh; width: min(560px, 100%);
  display: flex; flex-direction: column; background: var(--surface);
  border-left: 1px solid var(--border); box-shadow: var(--shadow-3);
  transform: translateX(100%); visibility: hidden; transition: transform 0.25s ease, visibility 0s linear 0.25s;
}
.drawer.open { transform: translateX(0); visibility: visible; transition: transform 0.25s ease, visibility 0s linear 0s; }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
}
.drawer-head h2 { font-size: 16px; }
.drawer-head .dsub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text-2); font-size: 12.5px; margin-top: 5px; }
.drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 16px 20px 24px; }
.drawer-foot {
  border-top: 1px solid var(--border); padding: 14px 20px; background: var(--surface);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.icon-btn {
  width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 8px;
  background: transparent; border: 1px solid var(--border); color: var(--text-2); cursor: pointer;
  transition: color var(--dur), border-color var(--dur);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.dsec { margin-top: 20px; }
.dsec:first-child { margin-top: 0; }
.dsec .dtitle {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-3); margin-bottom: 6px;
}
.kv .v.wrap { text-align: right; overflow-wrap: anywhere; font-variant-numeric: normal; }
.kv .v a { color: var(--accent); }
.kv .v a:hover { text-decoration: underline; }
.msg-box {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 12px 14px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere;
}
textarea.field { height: auto; min-height: 96px; padding: 10px 14px; line-height: 1.5; resize: vertical; font-family: inherit; }

/* Attached applicant documents */
.file-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.file-row:last-child { border-bottom: 0; }
.file-row .fname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.file-row .fmeta { color: var(--text-3); font-size: 11px; }
.file-row .btn { height: 30px; padding: 0 12px; font-size: 12px; }

/* Inline save / update feedback */
.notice { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
.notice.ok { color: var(--positive); }
.notice.err { color: var(--negative); }

body.drawer-open { overflow: hidden; }

@media (max-width: 900px) {
  .drawer { width: 100%; }
  .tbl .opt { display: none; }
}
@media (max-width: 600px) {
  .filter-bar .fb, .filter-bar .fb .field { flex: 1 1 100%; width: 100%; }
  .drawer-head { padding: 14px 16px 12px; }
  .drawer-body { padding: 14px 16px 20px; }
  .drawer-foot { padding: 12px 16px; }
}


/* ============================================================
   Errors tab
   ============================================================ */
.nav-badge {
  margin-left: auto;
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--negative);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.err-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.err-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 15px 17px; }
.err-stat.bad  { border-color: rgba(212,82,107,0.42); background: rgba(212,82,107,0.07); }
.err-stat.good { border-color: rgba(82,185,129,0.34); background: rgba(82,185,129,0.06); }
.es-v { font-size: 21px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.err-stat.bad .es-v  { color: var(--negative); }
.err-stat.good .es-v { color: var(--positive); }
.es-k { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); margin-top: 3px; }

.err-list { display: grid; gap: 1px; background: var(--border); border: 1px solid var(--border);
  border-radius: var(--r-md); overflow: hidden; }
.err-item { background: var(--surface); }
.err-item.is-resolved { opacity: 0.62; }

.err-head { cursor: pointer; list-style: none; display: grid;
  grid-template-columns: 68px 1fr auto auto; gap: 12px; align-items: center; padding: 13px 16px; }
.err-head::-webkit-details-marker { display: none; }
.err-head:hover { background: var(--surface-2); }
.err-head:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

.err-src { font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.09em;
  text-align: center; padding: 3px 0; border-radius: 5px; border: 1px solid var(--border-strong); color: var(--text-3); }
.err-src.server { color: var(--warning); border-color: rgba(217,164,65,0.4); background: rgba(217,164,65,0.1); }
.err-src.client { color: var(--blue);    border-color: rgba(111,141,255,0.4); background: rgba(111,141,255,0.1); }
.err-src.cron   { color: var(--accent);  border-color: rgba(205,173,110,0.4); background: var(--accent-soft); }

.err-msg { color: var(--text); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err-count { font-family: var(--mono); font-size: 11.5px; color: var(--negative); font-variant-numeric: tabular-nums; }
.err-item.is-resolved .err-count { color: var(--text-3); }
.err-when { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }

.err-body { padding: 4px 16px 18px; border-top: 1px solid var(--border); }
.err-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 2px 20px; margin: 12px 0; }
.err-stack { font-family: var(--mono); font-size: 11.5px; line-height: 1.65; color: var(--text-2);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 12px 14px; overflow-x: auto; white-space: pre; margin: 0 0 14px; }
.err-actions { display: flex; gap: 8px; }

@media (max-width: 720px) {
  .err-head { grid-template-columns: 56px 1fr auto; }
  .err-when { display: none; }
}

/* ============================================================
   CRM activity timeline + follow-ups (drawer)
   ============================================================ */
.tl-compose { display: flex; gap: 8px; margin: 10px 0 14px; flex-wrap: wrap; }
.tl-compose .field { flex: 1 1 160px; min-width: 0; height: 34px; }
.tl-compose input[type="date"] { flex: 0 0 140px; }

.tl-tasks { display: grid; gap: 6px; }
.tl-task { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 9px 11px; }
.tl-task.is-overdue { border-color: rgba(212,82,107,0.45); background: rgba(212,82,107,0.07); }
.tl-check { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-strong);
  background: transparent; color: var(--text-3); cursor: pointer; line-height: 1; font-size: 12px;
  transition: color var(--dur), border-color var(--dur), background var(--dur); }
.tl-check:hover { color: var(--positive); border-color: var(--positive); background: rgba(82,185,129,0.12); }
.tl-check:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.tl-task-title { font-size: 13.5px; color: var(--text); overflow-wrap: anywhere; }
.tl-task-due { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.tl-task.is-overdue .tl-task-due { color: var(--negative); }

.tl-list { position: relative; display: grid; gap: 0; margin-top: 10px; }
/* The spine sits under the dots rather than being drawn per item. */
.tl-list::before { content: ''; position: absolute; left: 4px; top: 8px; bottom: 8px;
  width: 1px; background: var(--border); }
.tl-item { position: relative; display: grid; grid-template-columns: 9px 1fr; gap: 14px;
  padding: 9px 0 9px 0; }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong);
  margin-top: 5px; z-index: 1; box-shadow: 0 0 0 3px var(--surface); }
.tl-status_changed .tl-dot { background: var(--accent); }
.tl-created .tl-dot { background: var(--blue); }
.tl-task .tl-dot, .tl-item.tl-task .tl-dot { background: var(--warning); }
.tl-contacted .tl-dot { background: var(--positive); }
.tl-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.tl-kind { font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--accent); }
.tl-time { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.tl-body { font-size: 13.5px; color: var(--text); line-height: 1.6; margin-top: 3px; overflow-wrap: anywhere; }
.tl-actor { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.tl-empty { font-size: 12.5px; color: var(--text-3); font-style: italic; padding: 6px 0; }
.tl-error { font-size: 12.5px; color: var(--negative); padding: 6px 0; }
