/* ============================================================================
   FAHO — Tactical Command theme
   Dark olive command-post aesthetic: Oswald display, JetBrains Mono readouts,
   HUD panels with corner brackets, signal-amber accents, status LEDs.
   ========================================================================== */

/* Colours live in themes.css (the single source); only theme-agnostic tokens
   — geometry and fonts — are defined here. */
:root {
  --radius: 4px;
  --radius-sm: 2px;

  --font-display: "Manrope", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --font-body: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* Repaint smoothly when the theme switches (disabled under reduced-motion). */
:root { --theme-transition: background-color .2s ease, border-color .2s ease, color .2s ease; }
@media (prefers-reduced-motion: reduce) { :root { --theme-transition: none; } }
body, .sidebar, .panel, .stat, .btn, input, select, textarea, .badge, th, .topbar {
  transition: var(--theme-transition);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  background-color: var(--bg);
  /* Layered atmosphere: tactical grid + olive corner glow + top vignette. */
  background-image:
    radial-gradient(900px 500px at 100% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, color-mix(in srgb, var(--signal) 6%, transparent), transparent 55%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 38px 38px, 38px 38px;
  /* No `background-attachment: fixed` — it forces a full-viewport repaint of
     all four gradient layers on every scroll frame, pinning a CPU core. The
     background scrolls with the document instead, which is painted once. */
  -webkit-font-smoothing: antialiased;
}

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

/* `.btn` etc. set display, which would otherwise win over the `hidden` attribute. */
[hidden] { display: none !important; }

::selection { background: color-mix(in srgb, var(--signal) 30%, transparent); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-bright) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 10px; }

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

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar {
  width: 244px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--signal) 5%, transparent), transparent 140px),
    var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  position: relative;
  padding: 20px 22px 18px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 1px;
  font-size: 22px;
  border-bottom: 1px solid var(--border);
}
.brand::before {  /* command ribbon */
  content: ""; position: absolute; left: 0; top: 20px; bottom: 18px;
  width: 4px; background: linear-gradient(180deg, var(--signal), var(--accent));
}
.brand small {
  display: block; font-family: var(--font-mono); font-weight: 400;
  color: var(--muted); font-size: 9.5px; letter-spacing: 2px; margin-top: 3px;
}

.nav { padding: 14px 0; flex: 1; }
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 22px;
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: .2px;
  border-left: 3px solid transparent;
  transition: color .12s, background .12s;
}
.nav a::before {  /* monospace bullet that lights up when active */
  content: "›"; font-family: var(--font-mono); color: var(--muted-2);
  font-size: 13px; transition: color .12s, transform .12s;
}
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a:hover::before { color: var(--signal); }
.nav a.active {
  color: var(--text); background: var(--panel);
  border-left-color: var(--signal);
}
.nav a.active::before { content: "▸"; color: var(--signal); transform: translateX(1px); }

.sidebar .user {
  padding: 14px 16px 16px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
}
.user-id { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
/* Shared avatar — photo or initials placeholder. Rendered via {% avatar %}.
   Sizes: sm (sidebar), md (list rows), lg (detail hero). */
.avatar {
  flex: none; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; letter-spacing: .5px;
  color: var(--ok-glow);
  background: radial-gradient(circle at 30% 25%, var(--panel-3), var(--panel-2));
  border: 1px solid var(--border-bright);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.avatar.sm { width: 38px; height: 38px; border-radius: 50%; font-size: 14px; }
.avatar.md { width: 42px; height: 42px; border-radius: 50%; font-size: 14px; }
.avatar.lg { width: 150px; height: 200px; border-radius: var(--radius); font-size: 44px; letter-spacing: 1px; }
.user-meta { min-width: 0; flex: 1; }
.user-meta b {
  display: block; color: var(--text); font-size: 13px;
  font-family: var(--font-display); letter-spacing: .3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-sub {
  display: block; font-family: var(--font-mono); font-size: 10.5px; color: var(--muted-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px;
}
.user-role {
  color: var(--accent-2); font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
}

/* ── Main column ──────────────────────────────────────────────────────── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 30px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--topbar-veil), transparent);
}
.topbar h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: 22px; margin: 0; letter-spacing: -.2px;
}
.content { padding: 26px 30px 48px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-divider {
  flex: none; width: 1px; align-self: stretch; margin: 4px 0;
  background: var(--border);
}
.topbar-divider:first-child { display: none; }
.sys-status {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 1.5px;
  color: var(--muted); text-transform: uppercase;
  padding: 6px 12px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel);
}
.icon-btn, .theme-toggle {
  flex: none; width: 34px; height: 34px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1; color: var(--muted);
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); transition: color .12s, border-color .12s, background .12s;
}
.icon-btn:hover, .theme-toggle:hover { color: var(--signal); border-color: var(--border-bright); background: var(--panel-2); }
.icon-btn svg { display: block; }

/* ── Eyebrow / section labels ─────────────────────────────────────────── */
.eyebrow {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--muted-2); display: flex; gap: 8px;
  align-items: center; margin: 0 0 14px;
}
.eyebrow::before { content: "//"; color: var(--signal); }

/* ── Panels (HUD frame) ───────────────────────────────────────────────── */
.panel {
  position: relative;
  background:
    linear-gradient(180deg, var(--panel-sheen), transparent 60px),
    var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.panel > h3:first-child, .panel > .eyebrow:first-child { margin-top: 0; }
.panel h3 {
  font-family: var(--font-display); font-weight: 700; font-size: 16px;
  letter-spacing: -.1px; margin: 0 0 16px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.panel h3::before {  /* signal tick before headings */
  content: ""; width: 8px; height: 8px; margin-right: 9px; flex: none;
  background: var(--signal); transform: rotate(45deg);
  box-shadow: 0 0 8px color-mix(in srgb, var(--signal) 50%, transparent);
}
.panel h3 .count {
  font-family: var(--font-mono); font-size: 12px; color: var(--muted);
  letter-spacing: 1px; margin-left: auto;
}
.panel h3 .count::before, .panel h3 .count::after { display: none; }

/* HUD corner brackets — opt-in via .hud */
.hud::before, .hud::after {
  content: ""; position: absolute; width: 12px; height: 12px; pointer-events: none;
}
.hud::before { top: 6px; left: 6px; border-top: 1px solid var(--signal); border-left: 1px solid var(--signal); }
.hud::after { bottom: 6px; right: 6px; border-bottom: 1px solid var(--signal); border-right: 1px solid var(--signal); }

/* ── Grids ────────────────────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.dash-split { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; }
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .dash-split { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
}

/* ── Stat / KPI cards ─────────────────────────────────────────────────── */
.stat {
  position: relative; overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 17px;
}
.stat::after {  /* accent edge */
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--border-bright);
}
.stat .num {
  font-family: var(--font-mono); font-size: 34px; font-weight: 700;
  line-height: 1.05; letter-spacing: -1px;
}
.stat .label {
  color: var(--muted); font-family: var(--font-mono); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 1.5px; margin-top: 4px;
}
.stat .sub { color: var(--muted-2); font-size: 11.5px; margin-top: 8px; }
.stat.primary::after { background: var(--accent-2); }
.stat.primary .num { color: var(--ok-glow); text-shadow: 0 0 18px color-mix(in srgb, var(--ok-glow) 35%, transparent); }
.stat.alert::after { background: var(--danger); }
.stat.alert .num { color: var(--danger); }
.stat.signal::after { background: var(--signal); }
.stat.signal .num { color: var(--signal-2); }

/* Readiness gauge card */
.gauge-card { display: flex; gap: 18px; align-items: center; }
.gauge { flex: none; }
.gauge .track { fill: none; stroke: var(--panel-3); stroke-width: 9; }
.gauge .val { fill: none; stroke: var(--ok); stroke-width: 9; stroke-linecap: round;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--ok) 50%, transparent)); transition: stroke-dashoffset 1s ease; }
.gauge-card .meta .label {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted);
}

/* ── Status LED ───────────────────────────────────────────────────────── */
.led {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: currentColor; box-shadow: 0 0 7px currentColor; flex: none;
}
.led.pulse { animation: ledpulse 1.8s ease-in-out infinite; }
@keyframes ledpulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ── Donut chart + legend ─────────────────────────────────────────────── */
.donut-wrap { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.donut { position: relative; flex: none; }
.donut svg { transform: rotate(-90deg); display: block; }
.donut .seg { transition: stroke-dashoffset .8s ease; }
.donut .hole {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
}
.donut .hole .n { font-family: var(--font-mono); font-size: 30px; font-weight: 700; line-height: 1; }
.donut .hole .t { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--muted); margin-top: 4px; }

.legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 190px; }
.legend li {
  display: flex; align-items: center; gap: 10px; padding: 6px 0;
  border-bottom: 1px dashed var(--border); font-size: 13px;
}
.legend li:last-child { border-bottom: none; }
.legend .name { flex: 1; color: var(--text); }
.legend .pct { font-family: var(--font-mono); color: var(--muted); font-size: 11.5px; min-width: 44px; text-align: right; }
.legend .cnt { font-family: var(--font-mono); font-weight: 700; min-width: 30px; text-align: right; }

/* ── Vertical bar chart (movements) ───────────────────────────────────── */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 8px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; }
.bars .col .stack { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bars .bar {
  width: 100%; min-height: 2px; border-radius: 2px 2px 0 0;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  position: relative; transition: height .6s ease;
}
.bars .bar[data-n="0"] { background: var(--panel-3); }
.bars .col.weekend .bar { background: linear-gradient(180deg,
  color-mix(in srgb, var(--accent) 65%, var(--muted-2)),
  color-mix(in srgb, var(--accent) 40%, var(--muted-2))); opacity: .8; }
.bars .bar .v {
  position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: 10px; color: var(--muted);
}
.bars .col .d { font-family: var(--font-mono); font-size: 9px; color: var(--muted-2); letter-spacing: .3px; }

/* ── Horizontal bars (by subdivision) ─────────────────────────────────── */
.hbars { list-style: none; margin: 0; padding: 0; }
.hbars li { padding: 9px 0; border-bottom: 1px solid var(--border); }
.hbars li:last-child { border-bottom: none; }
.hbars .row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.hbars .code { font-family: var(--font-mono); font-weight: 600; font-size: 13px; }
.hbars .code small { color: var(--muted-2); font-weight: 400; margin-left: 8px; font-family: var(--font-body); }
.hbars .n { font-family: var(--font-mono); font-weight: 700; color: var(--ok-glow); }
.hbars .track { height: 6px; background: var(--panel-3); border-radius: 3px; overflow: hidden; }
.hbars .fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 3px; transition: width .7s ease; }

/* ── Tables ───────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th {
  background: var(--panel-2); color: var(--muted); font-family: var(--font-mono);
  font-weight: 500; font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px;
}
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: none; }
td .mono, .mono { font-family: var(--font-mono); }
.tracking { font-family: var(--font-mono); color: var(--signal-2); font-size: 12.5px; }
.feed .tracking { flex: none; padding-top: 1px; }

/* Compact list rows for dashboard feeds */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
  display: flex; gap: 16px; align-items: flex-start; padding: 12px 0;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.feed li:last-child { border-bottom: none; }
.feed .when {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--muted-2);
  flex: none; min-width: 84px; padding-top: 2px;
}
/* Two-line body: name on top, route (from → to) beneath — keeps the subject
   from running into the locations. */
.feed .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.feed .who { font-weight: 500; }
.feed .route {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 7px;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--muted-2);
}
.feed .route .arrow { color: var(--muted-2); }
.feed .to { color: var(--accent-2); }
/* Status pill rendered as a link at the end of an active-movement row. */
.feed > li > .badge { flex: none; align-self: center; text-decoration: none; }

/* ── Attention panel (СЗЧ roster) ─────────────────────────────────────── */
.panel.attention {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--danger) 8%, transparent), transparent 80px),
    var(--panel);
}
.eyebrow.danger, .eyebrow.danger::before { color: var(--danger); }
.chip-roster { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip-roster a {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 11px;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
  border-radius: var(--radius-sm); background: color-mix(in srgb, var(--danger) 9%, transparent);
  color: var(--text); font-size: 12.5px; text-decoration: none; transition: background .15s ease;
}
.chip-roster a:hover { background: color-mix(in srgb, var(--danger) 16%, transparent); }
.chip-roster .led {
  width: 7px; height: 7px; border-radius: 50%; background: var(--danger); flex: none;
  box-shadow: 0 0 8px color-mix(in srgb, var(--danger) 70%, transparent);
}
.chip-roster small { color: var(--muted-2); font-family: var(--font-mono); font-size: 11px; }

/* ── Badges ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px;
  border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 11px;
  font-weight: 500; letter-spacing: .4px; border: 1px solid transparent;
}
/* Tinted badges derive from a single base colour: a translucent fill, a
   translucent border, and a foreground mixed toward --text so it stays vivid
   on dark and legible on light without per-theme overrides. */
.badge.in_unit, .badge.in_service, .badge.arrived {
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: color-mix(in srgb, var(--ok) 70%, var(--text));
  border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge.hospital, .badge.cancelled {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: color-mix(in srgb, var(--danger) 78%, var(--text));
  border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.badge.leave, .badge.planned {
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  color: color-mix(in srgb, var(--warn) 78%, var(--text));
  border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.badge.mission, .badge.in_transit {
  background: color-mix(in srgb, var(--info) 16%, transparent);
  color: color-mix(in srgb, var(--info) 60%, var(--text));
  border-color: color-mix(in srgb, var(--info) 45%, transparent); }
.badge.training {
  background: color-mix(in srgb, var(--violet) 16%, transparent);
  color: color-mix(in srgb, var(--violet) 60%, var(--text));
  border-color: color-mix(in srgb, var(--violet) 45%, transparent); }
.badge.discharged {
  background: color-mix(in srgb, var(--muted) 12%, transparent);
  color: var(--muted); border-color: var(--border); }
/* СЗЧ — найтривожніший стан: суцільний червоний, щоб виділявся серед усіх інших. */
.badge.szch { background: var(--danger); color: var(--on-accent); border-color: var(--danger); font-weight: 700;
  box-shadow: 0 0 12px color-mix(in srgb, var(--danger) 40%, transparent); }
.badge.role { background: var(--panel-2); color: var(--accent-2); border-color: var(--border); text-transform: uppercase; }

/* Банер-попередження вгорі картки військовослужбовця у стані СЗЧ. */
.alert-szch { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; padding: 12px 16px;
  border: 1px solid var(--danger); border-left-width: 4px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); font-weight: 600; }
.alert-szch .alert-icon { font-size: 18px; line-height: 1.2; }
.alert-szch small { display: block; font-weight: 400; opacity: .85; margin-top: 2px; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius); border: 1px solid var(--border-bright);
  background: var(--panel-2); color: var(--text); cursor: pointer;
  font-family: var(--font-display); font-size: 13px; font-weight: 500;
  letter-spacing: .8px; text-transform: uppercase; transition: all .12s;
}
.btn:hover { border-color: var(--accent-2); color: var(--text-strong); text-decoration: none; background: var(--panel-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--on-accent); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.btn.sm { padding: 5px 11px; font-size: 11.5px; }

/* ── Forms ────────────────────────────────────────────────────────────── */
form .field { margin-bottom: 14px; }
form label { display: block; margin-bottom: 5px; color: var(--muted); font-family: var(--font-mono);
  font-size: 11px; font-weight: 500; letter-spacing: .6px; text-transform: uppercase; }
input, select, textarea {
  width: 100%; padding: 9px 11px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border-bright); border-radius: var(--radius); font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 15%, transparent); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.help, .errorlist { font-size: 12px; }
.errorlist { color: var(--danger); list-style: none; padding: 0; margin: 4px 0 0; }
.actions { margin-top: 18px; display: flex; gap: 10px; }
.linklike {
  background: none; border: 0; padding: 0; width: auto; cursor: pointer;
  color: var(--accent-2); font: inherit; text-decoration: underline;
}
.linklike:hover { color: var(--text-strong); }

/* ── Tabbed form (Person modal) ───────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 2px; flex-wrap: wrap;
  margin: 0 0 18px; border-bottom: 1px solid var(--border);
}
.tab-bar .tab {
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); cursor: pointer; width: auto;
  padding: 9px 14px; margin-bottom: -1px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  letter-spacing: .6px; text-transform: uppercase; transition: color .12s, border-color .12s;
}
.tab-bar .tab:hover { color: var(--text); }
.tab-bar .tab.is-active { color: var(--accent-2); border-bottom-color: var(--accent-2); }
/* A tab whose panel holds an unfilled required field gets a warning dot. */
.tab-bar .tab.has-error { color: var(--danger); }
.tab-bar .tab.has-error::after {
  content: ""; display: inline-block; margin-left: 6px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--danger);
  vertical-align: middle;
}
.tab-bar .tab.has-error.is-active { border-bottom-color: var(--danger); }

/* "What's missing to save" summary, injected above the tabs on a failed save. */
.form-missing {
  margin: 0 0 16px; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}
.form-missing-title { margin: 0 0 6px; font-weight: 600; color: var(--danger); }
.form-missing ul { margin: 0; padding-left: 18px; }
.form-missing li { margin: 2px 0; }
.form-missing .linklike { color: var(--danger); }
.form-missing .linklike:hover { color: var(--text-strong); }

.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: tab-fade .14s ease-out; }
@keyframes tab-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Photo uploader ───────────────────────────────────────────────────── */
.photo-uploader {
  display: flex; gap: 16px; align-items: stretch;
  padding: 14px; border: 1px dashed var(--border-bright);
  border-radius: var(--radius); background: var(--bg); transition: border-color .12s, background .12s;
}
.photo-uploader.is-dragover { border-color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 6%, transparent); }
.photo-preview {
  flex: none; width: 120px; height: 120px; border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden; background: var(--panel-2);
  display: flex; align-items: center; justify-content: center;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-ph {
  color: var(--muted); font-family: var(--font-mono); font-size: 11px;
  letter-spacing: .6px; text-transform: uppercase;
}
.photo-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.photo-hint { margin: 0; font-size: 13px; color: var(--text); line-height: 1.5; }
.photo-body .help { margin: 0; }
.photo-clear { align-self: flex-start; margin-top: 4px; }
/* Native file input is driven via the "оберіть файл" / drop zone, not shown raw. */
.photo-uploader input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
@media (max-width: 520px) {
  .photo-uploader { flex-direction: column; align-items: center; text-align: center; }
}

/* ── Misc ─────────────────────────────────────────────────────────────── */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.muted { color: var(--muted); }
.messages { list-style: none; padding: 0; margin: 0 0 18px; }
.messages li { padding: 11px 16px; border-radius: var(--radius); margin-bottom: 8px; border: 1px solid var(--border);
  background: var(--panel); border-left: 3px solid var(--border-bright); }
.messages li.success { border-left-color: var(--ok); }
.messages li.error { border-left-color: var(--danger); }
.dl { display: grid; grid-template-columns: 200px 1fr; gap: 0; }
.dl dt { color: var(--muted); padding: 9px 0; border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: 12px; }
.dl dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--border); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 12px 0 12px 22px; border-left: 2px solid var(--border); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 16px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 60%, transparent); }

/* ── Movement tracking timeline ───────────────────────────────────────── */
.track-list li { padding-bottom: 16px; }
.track-when {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
  font-family: var(--font-mono); font-size: 11px;
}
.track-date { color: var(--text); font-weight: 600; letter-spacing: .5px; }
.track-time { color: var(--muted); }
.track-route {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  font-size: 14px; margin-bottom: 4px;
}
.track-arrow { color: var(--muted-2); }
.loc-link {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; cursor: pointer;
  color: var(--text); background: var(--panel-2); border: 1px solid var(--border);
  text-decoration: none; transition: border-color .12s, background .12s;
}
.loc-link::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--muted-2);
}
.loc-link:hover { border-color: var(--border-bright); background: var(--panel-3); }
.loc-link.to { color: var(--ok-glow); }
.loc-link.to::before { background: var(--accent); }
.track-meta {
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  font-size: 12.5px; color: var(--muted); margin-bottom: 4px;
}
.track-record {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .5px;
  color: var(--muted-2); text-decoration: none;
}
.track-record:hover { color: var(--accent-2); }

/* ── Location modal (read-only card) ──────────────────────────────────── */
.loc-modal-sub {
  margin: 16px 0 8px; font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 1px; text-transform: uppercase; color: var(--muted-2);
}
.loc-modal-people { list-style: none; padding: 0; margin: 0;
  max-height: 220px; overflow-y: auto; }
.loc-modal-people li { padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.loc-modal-people li:last-child { border-bottom: none; }
.loc-modal-people a { color: var(--text); text-decoration: none; }
.loc-modal-people a:hover { color: var(--accent-2); }

/* ── Person hero (detail header card) ─────────────────────────────────── */
.person-hero {
  display: flex; gap: 24px; align-items: flex-start;
  margin-bottom: 16px;
}
.person-hero-main { min-width: 0; flex: 1; }
.person-hero-rank {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--signal); margin-bottom: 4px;
}
.person-hero-name {
  margin: 0 0 10px; font-family: var(--font-display); font-weight: 700;
  font-size: 26px; line-height: 1.15; letter-spacing: -.2px;
}
.person-hero-callsign { color: var(--accent-2); font-weight: 600; }
.person-hero-status { margin-bottom: 14px; }
.person-hero-facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 24px; margin: 0;
}
.person-hero-facts > div { min-width: 0; }
.person-hero-facts dt {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted-2); margin-bottom: 3px;
}
.person-hero-facts dd { margin: 0; color: var(--text); font-size: 13.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-hero-tags { margin-top: 16px; }
.person-description { margin: 8px 0 0; color: var(--text); }

@media (max-width: 560px) {
  .person-hero { flex-direction: column; align-items: center; text-align: center; }
  .person-hero-facts { text-align: left; }
}

/* ── Ward list (підопічні) ────────────────────────────────────────────── */
.ward-list { list-style: none; padding: 0; margin: 8px 0 0; }
.ward-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.ward-item:last-child { border-bottom: none; }
.ward-main { min-width: 0; flex: 1; }
.ward-name {
  display: block; color: var(--text); font-family: var(--font-display);
  font-weight: 700; font-size: 14px; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ward-name:hover { color: var(--text-strong); }
.ward-rank { color: var(--signal); font-weight: 600; }
.ward-callsign { color: var(--accent-2); font-weight: 600; }
.ward-meta {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted-2);
  margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ward-status { flex: none; }

@media (max-width: 560px) {
  .ward-item { flex-wrap: wrap; }
  .ward-status { margin-left: 56px; }
}

/* ── Login ────────────────────────────────────────────────────────────── */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-card { width: 380px; position: relative; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 36px 34px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 4px; font-family: var(--font-display); font-size: 28px;
  letter-spacing: 3px; text-transform: uppercase; }
.login-card p { margin: 0 0 22px; color: var(--muted); font-size: 13px; font-family: var(--font-mono); letter-spacing: 1px; }
.login-logo { display: block; height: 168px; width: auto; margin: 0 auto 24px; }
.login-error {
  margin-top: 18px; padding: 12px 14px;
  border: 1px solid var(--danger); border-left-width: 4px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}
.login-error p { margin: 0; color: var(--danger); font-size: 13px; font-weight: 600; }
.login-error p + p { margin-top: 6px; }

/* ── Brand logo (sidebar) ─────────────────────────────────────────────── */
.brand { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.brand-logo { height: 64px; width: auto; }

/* The logo is a white monochrome mark; --logo-invert flips it to dark on light
   themes (0 = leave as-is, 1 = invert). New themes just set the token. */
.brand-logo, .login-logo, .splash-logo {
  filter: invert(var(--logo-invert)); transition: filter .2s ease;
}

/* ── Splash / no-access screen ────────────────────────────────────────── */
.splash {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 28px; padding: 24px;
}
.splash-logo { height: 168px; width: auto; max-width: 80vw; }
.splash-logout { opacity: .6; transition: opacity .15s; }
.splash-logout:hover { opacity: 1; }

/* ── Panel width helpers ──────────────────────────────────────────────── */
.panel-md { max-width: 760px; }
.panel-lg { max-width: 900px; }

/* ── Modal (HTMX-loaded create/edit forms) ────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px 24px;
  background: var(--backdrop);
  /* No `backdrop-filter: blur()` — blurring the whole viewport is GPU-heavy on
     weak machines. The semi-transparent `--backdrop` colour dims fine on its own. */
  animation: modal-fade .12s ease-out;
}
.modal {
  width: 100%; max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modal-rise .14s ease-out;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 0 0 18px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 {
  margin: 0; border: 0; padding: 0;
  font-family: var(--font-display); font-weight: 700; font-size: 17px;
}
.modal-x {
  flex: none; cursor: pointer; line-height: 1;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); border-radius: var(--radius-sm);
  width: 30px; height: 30px; font-size: 14px;
}
.modal-x:hover { color: var(--text); border-color: var(--border-bright); }
.modal-intro { margin-top: 0; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Transient confirmation after a successful modal save. */
.toast-stack {
  position: fixed; right: 16px; bottom: 16px; z-index: 120;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--panel-2); border: 1px solid var(--border-bright);
  border-left: 3px solid var(--ok); color: var(--text);
  padding: 10px 14px; border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: 13px;
  animation: modal-rise .14s ease-out;
}

/* ── Utilities ────────────────────────────────────────────────────────── */
.mt-sm { margin-top: 16px; }
.mt-md { margin-top: 20px; }
.mb-md { margin-bottom: 20px; }
.text-right { text-align: right; }
.bold { font-weight: 600; }
.fz-sm { font-size: 12px; }
.center { justify-content: center; }
.clickable { cursor: pointer; }
.w-search { max-width: 320px; }
.w-filter { max-width: 200px; }
.w-filter-lg { max-width: 260px; }
.btn-block { width: 100%; justify-content: center; }
.field-full { grid-column: 1 / -1; }

/* ── Person detail ────────────────────────────────────────────────────── */
.unit-photo { width: 140px; height: 140px; object-fit: cover; border-radius: var(--radius);
  border: 1px solid var(--border); margin-bottom: 14px; }
ul.plain { list-style: none; padding: 0; margin: 8px 0 0; }
ul.plain li { padding: 5px 0; border-bottom: 1px solid var(--border); }
ul.plain li:last-child { border-bottom: none; }
td .badge { margin-bottom: 2px; }

/* Staggered entrance for dashboard cards */
@media (prefers-reduced-motion: no-preference) {
  .reveal { animation: rise .5s cubic-bezier(.2, .7, .2, 1) backwards; }
  .reveal:nth-child(1) { animation-delay: .02s; }
  .reveal:nth-child(2) { animation-delay: .07s; }
  .reveal:nth-child(3) { animation-delay: .12s; }
  .reveal:nth-child(4) { animation-delay: .17s; }
  @keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
}

/* ── Tags: chips, autocomplete, catalogue ─────────────────────────────────
   Every tag carries its own colour via an inline `--tag` custom property, so a
   chip derives a translucent fill / coloured text / coloured border from it the
   same way status badges do — staying legible on both themes. */
.tag-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; vertical-align: middle;
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .3px; line-height: 1.6;
  background: color-mix(in srgb, var(--tag, var(--accent)) 14%, transparent);
  color: color-mix(in srgb, var(--tag, var(--accent)) 72%, var(--text-strong));
  border: 1px solid color-mix(in srgb, var(--tag, var(--accent)) 38%, transparent);
}
.tag-chip .dot { width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--tag, var(--accent)); box-shadow: 0 0 6px color-mix(in srgb, var(--tag, var(--accent)) 60%, transparent); }
.tag-chip.is-new { border-style: dashed; }
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* Input control: a bordered box that behaves like a text field but holds chips
   and a borderless entry. The real value lives in a hidden input (tags.js). */
.tag-input { position: relative; }
.tag-input .control {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  min-height: 40px; padding: 6px 8px; background: var(--bg);
  border: 1px solid var(--border-bright); border-radius: var(--radius); cursor: text;
}
.tag-input.is-focused .control {
  border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 15%, transparent);
}
.tag-input .chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px;
  border-radius: 999px; font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .3px;
  background: color-mix(in srgb, var(--tag, var(--accent)) 14%, transparent);
  color: color-mix(in srgb, var(--tag, var(--accent)) 72%, var(--text-strong));
  border: 1px solid color-mix(in srgb, var(--tag, var(--accent)) 38%, transparent);
}
.tag-input .chip.is-new { border-style: dashed; }
.tag-input .chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--tag, var(--accent)); flex: none; }
.tag-input .chip .x {
  width: auto; padding: 0 2px; margin: 0; background: none; border: 0; cursor: pointer;
  color: inherit; opacity: .65; font-size: 14px; line-height: 1;
}
.tag-input .chip .x:hover { opacity: 1; }
.tag-input .entry {
  flex: 1; min-width: 120px; width: auto; border: 0; background: transparent; box-shadow: none;
  padding: 4px 2px; font-size: 14px;
}
.tag-input .entry:focus { outline: none; box-shadow: none; }

/* Suggestions dropdown. */
.tag-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
  max-height: 260px; overflow-y: auto; padding: 4px;
  background: var(--panel); border: 1px solid var(--border-bright); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.tag-menu[hidden] { display: none; }
.tag-menu .opt {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 7px; cursor: pointer;
}
.tag-menu .opt .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tag, var(--accent)); flex: none; }
.tag-menu .opt .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-menu .opt .usage { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.tag-menu .opt.is-active, .tag-menu .opt:hover { background: var(--panel-3); }
.tag-menu .opt.create .label { color: var(--accent-2); }
.tag-menu .opt.create b { color: var(--text-strong); }
.tag-menu .empty { padding: 9px; color: var(--muted); font-size: 13px; }

/* Person detail: tags with provenance (who attached, when) on hover. */
.tag-prov { margin-left: 6px; color: var(--muted); font-size: 11px; font-family: var(--font-mono); }

/* ── Tag catalogue (management page) ──────────────────────────────────────── */
.tag-cat-group { margin-bottom: 22px; }
.tag-cat-head {
  display: flex; align-items: center; gap: 10px; margin: 0 0 12px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted);
}
.tag-cat-head .dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--tag, var(--accent));
  box-shadow: 0 0 8px color-mix(in srgb, var(--tag, var(--accent)) 55%, transparent);
}
.tag-cat-head .cat-name { color: color-mix(in srgb, var(--tag, var(--muted)) 55%, var(--text)); font-weight: 600; }
.tag-cat-head .rule { flex: 1; height: 1px; background: var(--border); }
.tag-cat-head .cat-ops { display: flex; gap: 4px; }
.tag-cat-head .cat-ops .btn { padding: 3px 8px; font-size: 10.5px; }
.tag-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.tag-card {
  display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; padding: 11px 13px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius);
  border-left: 3px solid var(--tag, var(--accent));
}
.tag-card .name { font-weight: 600; color: var(--text-strong); overflow-wrap: anywhere; }
.tag-card .meta { font-family: var(--font-mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.tag-card .grow { flex: 1 1 110px; min-width: 0; }
.tag-card .ops { display: flex; gap: 4px; flex: none; }
.tag-card .ops .btn { padding: 4px 9px; font-size: 11px; }
.color-input { width: 56px; height: 40px; padding: 3px; cursor: pointer; }

/* ── Advanced search modal ────────────────────────────────────────────────
   A personnel-query console: filter form on the left, live dossier cards on
   the right, saved-query presets in a bar above both. The modal is a fixed-
   height flex column — header + presets stay pinned, only the two panes scroll
   internally, so the body never drifts and leaves dead space. */
.search-modal {
  max-width: 1280px; max-height: 88vh; overflow: hidden;
  display: flex; flex-direction: column; padding: 20px 22px 18px;
}
.search-modal > .modal-head, .search-modal > .search-presets { flex: none; }
.search-modal > .search-body { flex: 1; min-height: 0; }

.search-head-titles { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.search-head-titles .eyebrow { margin: 0; }
.search-modal .modal-head { align-items: flex-start; margin-bottom: 14px; }

/* Presets bar */
.search-presets {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px 14px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--border);
}
.search-presets-list { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.search-presets-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted-2);
}
.search-presets-label::before { content: "★"; color: var(--signal); font-size: 10px; }
.preset-chip {
  display: inline-flex; align-items: stretch; overflow: hidden;
  border: 1px solid var(--border-bright); border-radius: var(--radius-sm); background: var(--panel-2);
  transition: border-color .12s;
}
.preset-chip:hover { border-color: var(--accent-2); }
.preset-load {
  background: none; border: 0; cursor: pointer; width: auto;
  padding: 4px 8px 4px 11px; color: var(--text);
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .2px;
}
.preset-load:hover { color: var(--accent-2); }
.preset-del {
  background: none; border: 0; border-left: 1px solid var(--border); cursor: pointer;
  width: auto; padding: 0 8px; color: var(--muted-2); font-size: 11px; transition: color .12s, background .12s;
}
.preset-del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.search-save { display: flex; gap: 6px; align-items: center; margin: 0; }
.search-save input { width: auto; min-width: 150px; padding: 6px 10px; font-size: 13px; }
.search-save .btn { white-space: nowrap; }

/* Two-pane body: panes own the scroll, with a hairline rule between them. */
.search-body { display: grid; grid-template-columns: 364px 1fr; gap: 0; align-items: stretch; }
.search-filters {
  min-height: 0; overflow-y: auto; padding-right: 18px; margin-right: 18px;
  border-right: 1px solid var(--border);
}
.search-results-pane { min-height: 0; overflow-y: auto; padding-left: 2px; }
@media (max-width: 860px) {
  .search-modal { overflow-y: auto; }
  .search-body { grid-template-columns: 1fr; min-height: 0; }
  .search-filters {
    min-height: 0; overflow: visible; border-right: 0; padding-right: 0;
    margin-right: 0; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--border);
  }
  .search-results-pane { overflow: visible; }
}

.search-section { margin-bottom: 18px; }
.search-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 520px) { .search-grid { grid-template-columns: 1fr; } }

/* Multi-select chips (status + tags): the real checkbox is hidden, the chip dims
   when unchecked and gains a ring when checked. */
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check { cursor: pointer; display: inline-flex; position: relative; }
/* Visually hidden but focusable. The label above is position:relative so this
   stays inside it — focusing it on click never scrolls the modal to a stray box. */
.chip-check input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.chip-check .badge, .chip-check .tag-chip {
  cursor: pointer; opacity: .42; filter: saturate(.7); transition: opacity .12s, box-shadow .12s, filter .12s;
}
.chip-check:hover .badge, .chip-check:hover .tag-chip { opacity: .75; }
.chip-check input:checked + .badge, .chip-check input:checked + .tag-chip {
  opacity: 1; filter: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-2) 55%, transparent);
}
.chip-check input:focus-visible + .badge, .chip-check input:focus-visible + .tag-chip {
  box-shadow: 0 0 0 2px var(--signal);
}

.filter-taglist {
  max-height: 168px; overflow-y: auto; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
}
.filter-tag-cat {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .8px;
  text-transform: uppercase; color: var(--muted-2); margin: 12px 0 7px;
}
.filter-tag-cat:first-child { margin-top: 0; }

.filter-range { margin-bottom: 12px; }
.filter-range > label {
  display: block; margin-bottom: 5px; color: var(--muted); font-family: var(--font-mono);
  font-size: 11px; font-weight: 500; letter-spacing: .6px; text-transform: uppercase;
}
.range-inputs { display: flex; align-items: center; gap: 8px; }
.range-inputs input { flex: 1; min-width: 0; }
.range-sep { flex: none; color: var(--muted-2); }

/* Opaque sticky footer: filter content scrolls cleanly beneath it, so the
   border-top reads as the footer's top edge — not a line floating over the
   fields above it. */
.search-filters-actions {
  display: flex; gap: 10px; position: sticky; bottom: 0; z-index: 1;
  padding: 14px 0 2px; margin-top: 4px;
  background: var(--panel);
  border-top: 1px solid var(--border);
}

/* Results pane */
.search-results-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  position: sticky; top: 0; z-index: 1; padding-bottom: 12px; margin-bottom: 4px;
  background: linear-gradient(180deg, var(--panel) 65%, transparent);
}
.search-count {
  display: inline-flex; align-items: baseline; gap: 8px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted);
}
.search-count::before { content: "▸"; color: var(--signal); }
.search-count b { color: var(--ok-glow); font-size: 15px; letter-spacing: 0; }

.search-cards { display: flex; flex-direction: column; gap: 8px; padding-bottom: 4px; }

/* Personnel-file card: a full-height portrait on the left, identity + a
   command-readout of facts on the right. The photo column stretches to the
   card's height; the status-coloured rule between photo and data flags state. */
.search-card {
  display: flex; align-items: stretch; min-height: 124px; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-2);
  transition: border-color .12s, background .12s;
}
.search-card:hover {
  border-color: var(--accent-2); background: var(--panel-3); text-decoration: none;
}
/* The photo column carries the status rule and a subtle panel fill, so any space
   below a top-aligned portrait reads as part of the photo panel, never as a gap. */
.search-card-photo {
  flex: none; align-self: stretch; display: flex; align-items: flex-start;
  padding: 14px; border-right: 3px solid var(--spine, var(--border-bright));
  background: var(--panel-3);
  transition: border-color .12s;
}
/* A fixed-width 3:4 document portrait, kept shorter than the typical readout so
   the data column drives the card height — the photo never forces a dead gap. */
.search-card-frame {
  position: relative; width: 120px; aspect-ratio: 3 / 4; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel);
}
.search-card-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.search-card-initials {
  font-family: var(--font-display); font-weight: 700; font-size: 30px;
  letter-spacing: 1px; color: var(--muted-2);
}
.search-card-main { flex: 1; min-width: 0; padding: 14px 16px; display: flex; flex-direction: column; }

.search-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.search-card-id { min-width: 0; }
.search-card-name {
  font-family: var(--font-display); font-weight: 700; font-size: 17px;
  color: var(--text-strong); letter-spacing: .2px; line-height: 1.2;
}
.search-card-cs { color: var(--accent-2); font-weight: 600; font-size: 14px; margin-left: 8px; white-space: nowrap; }
.search-card-rank {
  margin-top: 4px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--signal);
}
.search-card-status { flex: none; }

/* Command readout: each fact is a label stacked over its value, laid out as a
   wrapping row with generous spacing — a spec sheet, not a cramped grid. */
.search-card-readout {
  display: flex; flex-wrap: wrap; gap: 11px 26px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
}
.search-card-readout .ro { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.search-card-readout .ro-wide { flex-basis: 100%; }
.ro-l {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted-2);
}
.ro-v {
  font-size: 13.5px; color: var(--text); max-width: 240px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ro-v a { color: var(--accent-2); }
.ro-v a:hover { color: var(--text-strong); text-decoration: underline; }
.search-card-tags { margin-top: auto; padding-top: 12px; }

@media (max-width: 520px) {
  .ro-v { max-width: 150px; }
}

/* Spine colour keyed to status — readiness at a glance, СЗЧ flagged in red. */
.search-card[data-status="in_service"] { --spine: var(--ok); }
.search-card[data-status="hospital"]   { --spine: var(--danger); }
.search-card[data-status="leave"]      { --spine: var(--warn); }
.search-card[data-status="mission"]    { --spine: var(--info); }
.search-card[data-status="training"]   { --spine: var(--violet); }
.search-card[data-status="szch"]       { --spine: var(--danger); }
.search-card[data-status="discharged"] { --spine: var(--muted-2); }

.search-empty {
  padding: 40px 16px; text-align: center; color: var(--muted);
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .5px;
}
.search-empty::before {
  content: "⌖"; display: block; font-size: 30px; color: var(--muted-2);
  margin-bottom: 10px; opacity: .7;
}
