/* =============================================================================
   MACH Secure Workspace — dashboard
   =============================================================================

   Desktop-first and dense. This is a console somebody keeps open all day beside
   other work, not a marketing page: the density target is "a fleet of 200 fits
   on one screen without scrolling past the summary".

   THE COLOUR SYSTEM CARRIES ONE ARGUMENT.

   There are five tones, not three. `unknown` is a first-class state with its
   own colour — a hatched violet that reads as "something is missing here" and
   cannot be mistaken for either the green or the grey. Most dashboards have
   only ok/warn/bad, so an absent measurement falls through to whichever is the
   default, and on this product's pilot that default was green for four days
   while nothing was being collected at all.

   `neutral` is separate again: it means "a fact with no health meaning"
   (a locked screen, an archived policy) and must never be confused with
   "healthy" either.
   ============================================================================= */

:root {
  color-scheme: light dark;

  /* --- Surfaces --- */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --surface-sunken: #eef0f4;
  --border: #dfe3ea;
  --border-strong: #c6ccd8;

  /* --- Text --- */
  --text: #14171f;
  --text-muted: #5c6472;
  --text-faint: #858d9c;
  --text-inverse: #ffffff;

  /* --- Brand --- */
  --accent: #2b5cd9;
  --accent-hover: #1e47b3;
  --accent-soft: #e8eefc;

  /* --- Tones --- */
  --ok: #157a4a;
  --ok-soft: #e3f4ea;
  --warn: #9a6108;
  --warn-soft: #fdf1dc;
  --bad: #b3261e;
  --bad-soft: #fbe6e4;
  --unknown: #6b46c1;
  --unknown-soft: #efe9fb;
  --neutral: #5c6472;
  --neutral-soft: #eceef2;

  /* --- Geometry --- */
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 1px 2px rgba(20, 23, 31, 0.06), 0 1px 3px rgba(20, 23, 31, 0.04);
  --shadow-lg: 0 4px 16px rgba(20, 23, 31, 0.1);

  /* --- Rhythm: one 4px scale, used everywhere --- */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --sidebar-w: 216px;
  --header-h: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1117;
    --surface: #161b23;
    --surface-2: #1b212b;
    --surface-sunken: #10141b;
    --border: #262d38;
    --border-strong: #38414f;

    --text: #e6e9ef;
    --text-muted: #9aa3b2;
    --text-faint: #6b7484;

    --accent: #5b87f0;
    --accent-hover: #789ef5;
    --accent-soft: #1b2740;

    --ok: #4ade80;
    --ok-soft: #10261a;
    --warn: #fbbf4a;
    --warn-soft: #2a2110;
    --bad: #f87171;
    --bad-soft: #2c1517;
    --unknown: #a78bfa;
    --unknown-soft: #1f1a33;
    --neutral: #9aa3b2;
    --neutral-soft: #1e242e;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Focus is never removed, only restyled. An operator navigating a dense table
   by keyboard needs to know where they are. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* =============================================================================
   Shell
   ============================================================================= */

#app { min-height: 100%; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas: "brand header" "nav main";
  min-height: 100vh;
}

.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0 var(--s4);
  background: var(--surface);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-weight: 650;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 22px; height: 22px;
  border-radius: 5px;
  background: linear-gradient(135deg, var(--accent), #7b3fe4);
  flex: none;
}
.brand-sub { color: var(--text-faint); font-weight: 500; font-size: 11px; }

.topbar {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: 0 var(--s5);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 600; font-size: 14px; }
.topbar-right { display: flex; align-items: center; gap: var(--s3); }
.topbar-user { text-align: right; line-height: 1.25; }
.topbar-user .name { font-weight: 550; }
.topbar-user .roles { color: var(--text-faint); font-size: 11px; }

.sidenav {
  grid-area: nav;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--s3) var(--s2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidenav a {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 7px var(--s3);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 520;
  text-decoration: none;
}
.sidenav a:hover { background: var(--surface-sunken); color: var(--text); text-decoration: none; }
.sidenav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidenav .nav-count {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--text-faint);
}
.sidenav-group {
  margin-top: var(--s4);
  padding: 0 var(--s3) var(--s1);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 650;
}

main {
  grid-area: main;
  padding: var(--s5);
  min-width: 0;
  max-width: 1560px;
}

/* =============================================================================
   Page furniture
   ============================================================================= */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s4);
  flex-wrap: wrap;
}
.page-title { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -0.015em; }
.page-sub { margin: 2px 0 0; color: var(--text-muted); max-width: 74ch; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: var(--s4); }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
}
.card-title { font-weight: 620; font-size: 13.5px; }
.card-body { padding: var(--s4); }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: var(--s4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }

/* =============================================================================
   Tiles
   ============================================================================= */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: var(--s3);
  margin-bottom: var(--s4);
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s3) var(--s4);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
/* The tone stripe is the fastest read on the page. */
.tile::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--tone-color, transparent);
}
.tile-label { color: var(--text-muted); font-size: 11.5px; font-weight: 560; text-transform: uppercase; letter-spacing: 0.04em; }
.tile-value {
  font-size: 26px;
  font-weight: 660;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-top: 2px;
}
.tile-hint { color: var(--text-faint); font-size: 11.5px; margin-top: var(--s1); line-height: 1.35; }

/* =============================================================================
   Tone system
   ============================================================================= */

.tone-ok      { --tone-color: var(--ok);      --tone-soft: var(--ok-soft); }
.tone-warn    { --tone-color: var(--warn);    --tone-soft: var(--warn-soft); }
.tone-bad     { --tone-color: var(--bad);     --tone-soft: var(--bad-soft); }
.tone-unknown { --tone-color: var(--unknown); --tone-soft: var(--unknown-soft); }
.tone-neutral { --tone-color: var(--neutral); --tone-soft: var(--neutral-soft); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 580;
  white-space: nowrap;
  background: var(--tone-soft, var(--neutral-soft));
  color: var(--tone-color, var(--neutral));
  border: 1px solid transparent;
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
/* Unknown is the one badge that is also texturally different, so it survives
   a monochrome screenshot and a colour-blind reader. */
.badge.tone-unknown { border-color: color-mix(in srgb, var(--unknown) 35%, transparent); border-style: dashed; }
.badge.tone-unknown::before { border-radius: 1px; transform: rotate(45deg); }

.banner {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  padding: var(--s3) var(--s4);
  border-radius: var(--radius);
  background: var(--tone-soft, var(--neutral-soft));
  border-left: 3px solid var(--tone-color, var(--neutral));
  color: var(--text);
  margin-bottom: var(--s4);
}
.banner .banner-title { font-weight: 620; }
.banner .banner-body { color: var(--text-muted); }

/* =============================================================================
   Tables
   ============================================================================= */

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th {
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
table.data td {
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.clickable { cursor: pointer; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.mono, .mono { font-family: var(--mono); font-size: 12px; }
.cell-primary { font-weight: 570; }
.cell-sub { color: var(--text-faint); font-size: 11.5px; }

/* =============================================================================
   Controls
   ============================================================================= */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
}
.toolbar .spacer { flex: 1 1 auto; }

input[type="text"], input[type="search"], input[type="password"], input[type="email"],
input[type="number"], input[type="date"], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 5px var(--s2);
  min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="search"] { min-width: 220px; }
label.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-muted); }
label.field > span.label-text { font-weight: 560; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }

button {
  font: inherit;
  font-weight: 560;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 5px var(--s3);
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--surface-sunken); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
button.subtle { border-color: transparent; background: transparent; color: var(--text-muted); }
button.subtle:hover:not(:disabled) { background: var(--surface-sunken); color: var(--text); }
button.sm { padding: 2px var(--s2); font-size: 12px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 var(--s4); }
.tabs button {
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: var(--s2) var(--s3);
  color: var(--text-muted);
}
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 620; }
.tabs .tab-count { color: var(--text-faint); font-variant-numeric: tabular-nums; margin-left: 5px; }

/* =============================================================================
   States: loading, empty, error, permission
   =============================================================================
   Four distinct treatments, deliberately. A spinner where an error belongs
   makes a broken screen look merely slow, and a reader waits instead of acting.
   ============================================================================= */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  padding: var(--s7) var(--s5);
  text-align: center;
  color: var(--text-muted);
}
.state .state-title { font-weight: 620; color: var(--text); font-size: 14px; }
.state .state-body { max-width: 60ch; }
.state .state-icon { font-size: 22px; line-height: 1; }

/* unavailableState(): quieter than the other three states on purpose - "this
   does not exist in this build" must not compete visually with a genuine
   error or an empty-but-real feature. */
.state-unavailable { padding: var(--s5) var(--s4); color: var(--text-faint); }
.state-unavailable .state-title { color: var(--text-muted); font-weight: 560; }
.state-unavailable .state-icon { color: var(--text-faint); }

/* desiredActual(): the product owner's DESIRED-vs-ACTUAL rule, as one
   reusable two-column layout every policy/web/wifi screen shares. */
.desired-actual {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--s4);
  align-items: start;
}
@media (max-width: 720px) {
  .desired-actual { grid-template-columns: 1fr; }
  .desired-actual-match { justify-self: center; }
}
.desired-actual-col {
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-sunken);
}
.desired-actual-title {
  font-weight: 620;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-bottom: var(--s2);
}
.desired-actual-match {
  align-self: center;
  font-size: 18px;
  font-weight: 700;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.desired-actual-match.tone-ok { color: var(--ok); background: var(--ok-soft); }
.desired-actual-match.tone-bad { color: var(--bad); background: var(--bad-soft); }
.desired-actual-match.tone-warn { color: var(--warn); background: var(--warn-soft); }

.skeleton {
  background: linear-gradient(90deg, var(--surface-sunken) 25%, var(--surface-2) 37%, var(--surface-sunken) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius);
  height: 12px;
}
.skeleton.row { height: 34px; margin: var(--s2) var(--s4); }
.skeleton.tile { height: 78px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

/* A stale panel keeps showing the last good data rather than blanking: an
   operator mid-investigation must not lose the screen because one poll failed. */
.stale { position: relative; }
.stale::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg);
  opacity: 0.4;
  pointer-events: none;
  border-radius: inherit;
}
.stale-note {
  display: flex; align-items: center; gap: 6px;
  padding: var(--s2) var(--s4);
  font-size: 12px;
  color: var(--warn);
  background: var(--warn-soft);
  border-bottom: 1px solid var(--border);
}

/* =============================================================================
   Detail layouts
   ============================================================================= */

dl.facts { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: var(--s2) var(--s4); margin: 0; }
dl.facts dt { color: var(--text-faint); font-size: 12px; }
dl.facts dd { margin: 0; }

.kv-list { display: flex; flex-direction: column; gap: var(--s1); }
.kv { display: flex; justify-content: space-between; gap: var(--s3); padding: 3px 0; border-bottom: 1px dashed var(--border); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-muted); }
.kv .v { font-variant-numeric: tabular-nums; font-weight: 560; }

/* --- Timeline --- */
.timeline { display: flex; flex-direction: column; }
.timeline-day {
  position: sticky; top: 0;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: var(--s1) var(--s4);
  font-size: 11.5px; font-weight: 620; color: var(--text-muted);
  z-index: 1;
}
.tl-entry {
  display: grid;
  grid-template-columns: 76px 118px 1fr;
  gap: var(--s3);
  padding: 6px var(--s4);
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.tl-entry:hover { background: var(--surface-2); }
.tl-time { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); }
.tl-lane { font-size: 11px; font-weight: 620; letter-spacing: 0.03em; color: var(--text-muted); text-transform: uppercase; }
.tl-label { min-width: 0; }
.tl-repeat { color: var(--text-faint); font-size: 11.5px; }
/* A baseline is visually a different kind of thing: it describes the state the
   window opened in, and its timestamp is the edge, not an event. */
.tl-entry.is-baseline { background: repeating-linear-gradient(135deg, transparent, transparent 6px, var(--surface-sunken) 6px, var(--surface-sunken) 12px); }
.tl-entry.is-baseline .tl-time::after { content: " (edge)"; }

/* --- Capture strip --- */
.capture-strip { display: flex; gap: 2px; flex-wrap: wrap; }
.capture-cell {
  width: 22px; height: 26px;
  border-radius: 3px;
  background: var(--tone-soft, var(--neutral-soft));
  border-top: 3px solid var(--tone-color, var(--neutral));
  cursor: help;
}
.capture-cell.tone-unknown {
  background-image: repeating-linear-gradient(45deg, transparent, transparent 3px, color-mix(in srgb, var(--unknown) 22%, transparent) 3px, color-mix(in srgb, var(--unknown) 22%, transparent) 6px);
}
.capture-legend { display: flex; gap: var(--s4); flex-wrap: wrap; margin-top: var(--s3); font-size: 11.5px; color: var(--text-muted); }
.capture-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--tone-color); margin-right: 5px; vertical-align: -1px; }

/* --- Provenance --- */
.prov-row { display: grid; grid-template-columns: minmax(180px, 1fr) 110px minmax(160px, 1fr); gap: var(--s3); padding: 5px 0; border-bottom: 1px dashed var(--border); align-items: baseline; }
.prov-source { font-size: 11.5px; color: var(--text-muted); }
.prov-source.is-default { color: var(--text-faint); font-style: italic; }

/* =============================================================================
   Login
   ============================================================================= */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--s5); }
.login-card { width: min(400px, 100%); }
.login-card .card-body { display: flex; flex-direction: column; gap: var(--s3); }
.login-head { text-align: center; margin-bottom: var(--s2); }
.login-head .brand-mark { margin: 0 auto var(--s2); width: 32px; height: 32px; }
.login-error { color: var(--bad); background: var(--bad-soft); padding: var(--s2) var(--s3); border-radius: var(--radius); font-size: 12.5px; }

/* =============================================================================
   Utilities
   ============================================================================= */

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: var(--s2); }
.row-wrap { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: var(--s2); }
.stack-sm > * + * { margin-top: var(--s2); }
.right { margin-left: auto; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
/* Spacing utilities exist because this origin's CSP is style-src 'self' with no
   'unsafe-inline': a style="" attribute is blocked outright. That is a
   constraint worth keeping — it means an injected node cannot carry its own
   presentation either — so layout adjustments live here, never on the element. */
.noscript-note { padding: var(--s5); font-family: var(--font); }
.section-head { margin: 0 0 var(--s2); }
.section-gap { margin: var(--s5) 0 var(--s2); }
.contents { display: contents; }
.w-num { width: 88px; }

.note {
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.45;
  border-left: 2px solid var(--border-strong);
  padding-left: var(--s2);
}

/* =============================================================================
   Responsive
   =============================================================================
   Desktop-first, as an operations console should be. Below 1100px the sidebar
   collapses to icons-plus-labels in a top strip; below 720px tables scroll
   horizontally rather than reflowing into cards, because a dense comparison
   across many rows is the reason the table exists and stacked cards destroy it.
   ============================================================================= */

@media (max-width: 1100px) {
  .grid-main, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) auto 1fr;
    grid-template-areas: "brand" "header" "main";
  }
  .brand { border-right: none; }
  .sidenav {
    grid-area: header;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: var(--s2);
  }
  .sidenav-group { display: none; }
  .sidenav .nav-count { display: none; }
  .topbar { display: none; }
  main { padding: var(--s4) var(--s3); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media print {
  .sidenav, .topbar, .toolbar { display: none; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* =============================================================================
   Phase 1 control centre — Armenian operator console
   =============================================================================

   Added rather than rewritten. The token layer at the top of this file — five
   tones with `unknown` as a first-class colour, one 4px rhythm, one radius
   scale — is the design system, and everything below is built from it. Not one
   literal colour or pixel value appears here that is not a var().

   Sidebar navigation is now five items plus a secondary group, and the Armenian
   labels run longer than the English ones they replace, so --sidebar-w is
   adjusted once, here, rather than per rule.
   ============================================================================= */

:root { --sidebar-w: 244px; }

.brand-name { font-size: 15px; line-height: 1.1; }

.sidenav-icon {
  width: 16px;
  text-align: center;
  opacity: 0.75;
  flex: none;
  font-size: 12px;
}

/* --- Page furniture ---------------------------------------------------------- */

.page-actions { display: flex; gap: var(--s2); align-items: center; flex: none; }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s3);
}
.card-sub { color: var(--text-faint); font-size: 11.5px; margin-top: 1px; }
.card-actions { display: flex; gap: var(--s2); align-items: center; flex: none; }
.card-body.flush { padding: 0; }
.card-body.flush > .filter-bar { padding: var(--s3) var(--s4); }
.card-body.flush > .tabs { padding: 0 var(--s4); }

/* --- "Ուշադրություն է պահանջում" ---------------------------------------------
   The first thing on the overview, and the only element on it with a coloured
   left rail. Colour is never the only signal: the heading names the state in
   Armenian and the icon repeats it, so the screen reads identically in
   greyscale, in a pasted screenshot, and to a colour-blind reader. */

.attention {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--tone-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: var(--s4);
  overflow: hidden;
}
.attention-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4);
  background: color-mix(in srgb, var(--tone-soft) 55%, var(--surface));
}
.attention-icon {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--tone-color);
  color: var(--text-inverse);
  font-weight: 700;
  flex: none;
}
.attention-title { margin: 0; font-size: 15px; font-weight: 650; }
.attention-sub { color: var(--text-muted); font-size: 12px; }

.attention-list { list-style: none; margin: 0; padding: 0; }
.attention-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--border);
}
.attention-item::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--tone-color);
  flex: none;
}
.attention-item.tone-unknown::before { border-radius: 1px; transform: rotate(45deg); }
.attention-item-text { min-width: 0; flex: 1 1 auto; }
.attention-item-title { font-weight: 580; }
.attention-item-body { color: var(--text-muted); font-size: 12px; }

/* --- Stat tiles --------------------------------------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: var(--s3);
}
.stat {
  position: relative;
  padding: var(--s3) var(--s3) var(--s3) var(--s4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
}
.stat::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--tone-color);
  border-radius: var(--radius) 0 0 var(--radius);
}
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { background: var(--surface); box-shadow: var(--shadow); }
.stat-label {
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 560;
}
.stat-value {
  font-size: 26px;
  font-weight: 640;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat-hint { color: var(--text-faint); font-size: 11.5px; margin-top: var(--s1); line-height: 1.35; }

/* --- Key/value grids ---------------------------------------------------------- */

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s2) var(--s4);
  margin-top: var(--s3);
}
.kv { display: flex; flex-direction: column; gap: 1px; padding: var(--s1) 0; border-bottom: none; }
.kv.wide { grid-column: 1 / -1; }
.kv-label { color: var(--text-muted); font-size: 11.5px; }
.kv-value { font-weight: 550; }

/* --- Present-state tiles on the device page ----------------------------------- */

.now-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--s3);
}
.now-tile {
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.now-label { color: var(--text-muted); font-size: 11.5px; font-weight: 560; }
.now-value { margin: var(--s2) 0 var(--s1); font-size: 15px; font-weight: 600; }
.now-sub { color: var(--text-faint); font-size: 11.5px; line-height: 1.35; }

.app-name { font-weight: 570; }
.app-name.big { font-size: 16px; }

.freshness { display: inline-flex; align-items: center; gap: 5px; }
.freshness::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--tone-color);
}

/* --- People-first table -------------------------------------------------------- */

table.data.people td { vertical-align: middle; }
.person { min-width: 0; }
.person-name { font-weight: 570; }
.person-sub { color: var(--text-faint); font-size: 11.5px; }
.stack { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }

.table-meta {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s4);
  color: var(--text-muted);
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.table-meta .note { margin: 0; }

/* --- Filters ------------------------------------------------------------------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}
.control {
  font: inherit;
  padding: 5px var(--s2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  min-height: 30px;
}
.control.search { min-width: 240px; flex: 1 1 240px; max-width: 380px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: var(--s2) var(--s3);
  color: var(--text-muted);
  font-weight: 560;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 640; }

button.small { padding: 3px var(--s2); font-size: 12px; min-height: 24px; }

/* --- Alert / incident lists ---------------------------------------------------- */

.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.alert-row:last-child { border-bottom: none; }
.alert-row:hover { background: var(--surface-2); }
.alert-row.urgent { box-shadow: inset 3px 0 0 var(--bad); padding-left: var(--s2); }
.alert-text { flex: 1 1 auto; min-width: 0; }
.alert-title { font-weight: 570; }
.alert-sub { color: var(--text-faint); font-size: 11.5px; }

.reason-list { margin: var(--s2) 0 0; padding-left: var(--s5); color: var(--text-muted); font-size: 12px; }
.health-head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.health-summary { color: var(--text-muted); }

.service-strip { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s3); }
.service-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px var(--s2);
  border-radius: 999px;
  background: var(--tone-soft);
  color: var(--tone-color);
  font-size: 11.5px;
  font-weight: 560;
  font-family: var(--mono);
}
.service-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--tone-color); }

/* --- "Ինչ դեռ չի աշխատում" ------------------------------------------------------ */

.reaches {
  margin-top: var(--s3);
  padding: var(--s2) var(--s3);
  border-radius: var(--radius);
  background: var(--tone-soft);
  color: var(--tone-color);
  font-weight: 580;
}

.truth-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.truth {
  padding: var(--s2) var(--s3);
  border-left: 3px solid var(--tone-color);
  background: var(--surface-2);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.truth-title { font-weight: 570; }
.truth-body { color: var(--text-muted); font-size: 12px; }

/* --- Timeline ------------------------------------------------------------------ */

.timeline-day + .timeline-day { margin-top: var(--s4); }
.timeline-day-head {
  position: sticky;
  top: 0;
  background: var(--surface);
  padding: var(--s2) 0;
  font-weight: 640;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  z-index: 1;
}
.timeline-list { list-style: none; margin: 0; padding: 0; }
.timeline-entry {
  display: grid;
  grid-template-columns: 74px 104px minmax(0, 1fr);
  gap: var(--s3);
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
}
.timeline-time { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); }
.timeline-lane {
  font-size: 11px;
  font-weight: 620;
  color: var(--text-muted);
}
.timeline-text { min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2); }
.timeline-value { font-weight: 550; }
.timeline-note {
  flex-basis: 100%;
  color: var(--tone-color);
  font-size: 11.5px;
}

/* --- Screenshot gallery --------------------------------------------------------- */

.gallery-filter { padding: var(--s3) var(--s4) 0; }
.gallery-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s2) var(--s4);
  color: var(--text-muted);
  font-size: 12px;
}
.budget-line { display: flex; align-items: center; gap: var(--s2); }
.gallery-more { display: flex; justify-content: center; padding: var(--s4); }

.shot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--s3);
  padding: 0 var(--s4) var(--s4);
}
.shot-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
  cursor: pointer;
}
.shot-card:hover { box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.shot-surface {
  aspect-ratio: 16 / 10;
  background: var(--surface-sunken);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.shot-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot-loading { color: var(--text-faint); font-size: 12px; }
.shot-placeholder { display: grid; place-items: center; gap: var(--s2); }
.shot-placeholder-icon { font-size: 26px; color: var(--text-faint); }
.shot-fail {
  padding: var(--s3);
  text-align: center;
  color: var(--tone-color);
}
.shot-fail-title { font-weight: 600; font-size: 12.5px; }
.shot-fail-body { color: var(--text-muted); font-size: 11.5px; margin-top: 3px; }
.shot-meta { padding: var(--s2) var(--s3); display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.shot-who { font-weight: 570; }
.shot-sub { color: var(--text-faint); font-size: 11.5px; }
.badge.tiny { font-size: 10.5px; padding: 0 5px; }

/* --- Full-size viewer ------------------------------------------------------------ */

.viewer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.82);
  display: grid;
  place-items: center;
  padding: var(--s4);
  z-index: 50;
}
.viewer {
  width: min(1280px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.viewer-head, .viewer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
}
.viewer-head { border-bottom: 1px solid var(--border); }
.viewer-foot { border-top: 1px solid var(--border); flex-wrap: wrap; }
.viewer-head-right { display: flex; align-items: center; gap: var(--s3); }
.viewer-who { font-weight: 620; }
.viewer-sub { color: var(--text-faint); font-size: 11.5px; }
.viewer-counter { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 12px; }
.viewer-surface {
  flex: 1 1 auto;
  min-height: 240px;
  background: var(--surface-sunken);
  display: grid;
  place-items: center;
  overflow: auto;
}
.viewer-surface .shot-img { width: auto; max-width: 100%; max-height: 72vh; object-fit: contain; }
.viewer-details { display: flex; gap: var(--s4); flex-wrap: wrap; }
.viewer-detail { display: flex; flex-direction: column; }
.viewer-detail-label { color: var(--text-faint); font-size: 11px; }
.viewer-detail-value { font-size: 12px; font-weight: 550; }

/* --- Modal and toast -------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.55);
  display: grid;
  place-items: center;
  padding: var(--s4);
  z-index: 60;
}
.modal {
  width: min(520px, 100%);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-head { padding: var(--s4) var(--s4) 0; }
.modal-title { margin: 0; font-size: 15px; font-weight: 640; }
.modal-body { padding: var(--s3) var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--border);
}
.field { display: flex; flex-direction: column; gap: 3px; }
.label-text { color: var(--text-muted); font-size: 12px; }

.toast-host {
  position: fixed;
  bottom: var(--s5);
  right: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  z-index: 70;
}
.toast {
  padding: var(--s2) var(--s4);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--tone-color);
  box-shadow: var(--shadow-lg);
  font-weight: 550;
}

/* --- Technical disclosure ---------------------------------------------------------
   Every UUID, hash and raw payload in this console lives inside one of these.
   Collapsed by default; never removed. */

.technical {
  margin-top: var(--s4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.technical > summary {
  padding: var(--s2) var(--s3);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 560;
}
.technical-body { padding: 0 var(--s3) var(--s3); }
pre.json {
  margin: 0;
  padding: var(--s3);
  background: var(--surface-sunken);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.45;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
}

.mono { font-family: var(--mono); }
.loading { padding: var(--s3) 0; }
.banner { display: flex; align-items: flex-start; gap: var(--s3); }
.banner-text { flex: 1 1 auto; min-width: 0; }

/* --- Responsive -------------------------------------------------------------------
   Desktop-first, with a real tablet layout rather than a broken one: below
   1080px the sidebar collapses to a strip of icons; below 760px it becomes a
   horizontal bar above the content. Nothing is hidden at any width — a console
   that drops its navigation on a tablet is a console somebody cannot use in a
   meeting. */

@media (max-width: 1080px) {
  :root { --sidebar-w: 60px; }
  .sidenav a > span:not(.sidenav-icon) { display: none; }
  .sidenav a { justify-content: center; }
  /* The group heading has no room to be readable in a 60px rail, and a
     truncated Armenian word is worse than none: the divider above the
     secondary links already says what it said. */
  .sidenav-group { height: 1px; padding: 0; margin: var(--s3) var(--s2); overflow: hidden; text-indent: -999em; background: var(--border); }
  .brand > div:not(.brand-mark) { display: none; }
  main { padding: var(--s4); }
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) auto 1fr;
    grid-template-areas: "header" "nav" "main";
  }
  .brand { display: none; }
  .sidenav { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .sidenav-group { display: none; }
  .sidenav a > span:not(.sidenav-icon) { display: inline; }
  .stat-grid, .now-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .shot-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .timeline-entry { grid-template-columns: 64px minmax(0, 1fr); }
  .timeline-lane { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Two-factor setup: the QR, the key under it, and the one-time recovery list.
   The QR keeps a white quiet zone of its own regardless of theme - a dark
   surface behind a dark-on-transparent code is a code no camera reads. */
.qr-wrap {
  display: flex;
  justify-content: center;
  padding: 12px 0;
}
.qr {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  image-rendering: pixelated;
  max-width: 100%;
  height: auto;
}
code.hash {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95em;
  letter-spacing: 0.04em;
  word-break: break-all;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
}
ul.recovery-codes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 6px;
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}
