/* Suniylash Business — brand interface.
   One structure, two looks: MIRAGE (the brand: brand red #890103 glowing out
   of near-black) and PAPER (the same red as ink on white, for daylight and
   printing). Only the tokens below change between them; every component reads
   tokens, never raw colours. Fonts are ones Windows already has, so nothing is
   downloaded and the strict content policy stays intact. */

:root,
:root[data-theme="mirage"] {
  color-scheme: dark;

  /* The brand, as measured from the logo: red on black. */
  --brand: #890103;
  --brand-lit: #c11226;      /* fills that need to be seen */
  --brand-text: #ff6b76;     /* the red as text or an icon, readable on black */

  --bg: #07080c;
  --grid: rgb(255 255 255 / 2.6%);
  --surface: rgb(20 14 18 / 72%);
  --surface-2: rgb(38 24 29 / 60%);
  --text: #f4eef0;
  --muted: #a1919a;
  --line: rgb(255 255 255 / 16%);
  --line-soft: rgb(255 255 255 / 8%);
  --accent: var(--brand);
  --accent-hover: var(--brand-lit);
  --accent-text: #fff3f4;
  --accent-2: var(--brand-text);
  --ok: #3ddc9a;
  --ok-bg: rgb(61 220 154 / 10%);
  --warn: #ffb44d;
  --warn-bg: rgb(255 180 77 / 10%);
  --bad: #ff5f6d;
  --bad-bg: rgb(255 95 109 / 12%);
  --attention: rgb(137 1 3 / 14%);
  --glow: 0 0 40px rgb(137 1 3 / 18%);
  --radius: 4px;
  --font-display: "Bahnschrift", "DIN Alternate", "Arial Narrow", "Segoe UI", sans-serif;
  --display-weight: 600;
  --display-case: uppercase;
  --display-spacing: 0.005em;
}

:root[data-theme="paper"] {
  color-scheme: light;
  --brand: #890103;
  --brand-lit: #a8121c;
  --brand-text: #890103;
  --bg: #f4f1f1;
  --grid: rgb(137 1 3 / 4%);
  --surface: #ffffff;
  --surface-2: #f6f1f1;
  --text: #140e10;
  --muted: #6a5c60;
  --line: rgb(20 14 16 / 22%);
  --line-soft: rgb(20 14 16 / 11%);
  --accent: var(--brand);
  --accent-hover: var(--brand-lit);
  --accent-text: #ffffff;
  --accent-2: #140e10;
  --ok: #14724a;
  --ok-bg: #e3f2ea;
  --warn: #8a5600;
  --warn-bg: #fbeed3;
  --bad: #b41f2a;
  --bad-bg: #fbe5e7;
  --attention: #fdf1f1;
  --glow: none;
  --radius: 4px;
  --font-display: "Bahnschrift", "DIN Alternate", "Arial Narrow", "Segoe UI", sans-serif;
  --display-weight: 600;
  --display-case: uppercase;
  --display-spacing: 0.005em;
}

/* One spacing scale for the whole interface, so panels, headings, tables and
   buttons line up instead of each choosing their own margin. */
:root {
  --s1: 6px;
  --s2: 10px;
  --s3: 14px;
  --s4: 20px;
  --s5: 28px;
  --s6: 40px;
}

:root {
  --font-mono: "Cascadia Mono", "Cascadia Code", Consolas, "SF Mono", ui-monospace, monospace;
  --font-body: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  --tick: 10px;
  font-family: var(--font-body);
}

* { box-sizing: border-box; }

/* The hidden attribute must win over any class that sets display: .field is
   flex, so the consent dialog's "face will be deleted" tick box showed even
   for a permanent consent. */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  background-color: var(--bg);
  /* Fine drafting grid, kept faint so it sits under the glow, not over it. */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px, 32px 32px;
  background-attachment: fixed;
}

/* The brand light: red bleeding out of the black, the way the logo does. The
   glows are layers of the page's own background, fixed to the window, so
   scrolling moves the interface across the light instead of dragging the
   light with it. */
:root[data-theme="mirage"] body,
:root:not([data-theme]) body {
  background-image:
    radial-gradient(58vw 46vh at 82% -8%, rgb(193 18 38 / 30%), transparent 60%),
    radial-gradient(44vw 52vh at 4% 12%, rgb(137 1 3 / 26%), transparent 62%),
    radial-gradient(64vw 44vh at 50% 112%, rgb(137 1 3 / 22%), transparent 58%),
    radial-gradient(34vw 30vh at 68% 46%, rgb(98 28 26 / 16%), transparent 66%),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: auto, auto, auto, auto, 32px 32px, 32px 32px;
}

h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 {
  font-family: var(--font-display); font-weight: var(--display-weight);
  text-transform: var(--display-case); letter-spacing: var(--display-spacing);
  font-size: clamp(24px, 2.6vw, 32px);
}
/* A panel's name. The red tick does the work the old [ brackets ] did, without
   the noise, and lines every panel title up on the same vertical. */
h2 {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
}
h2::before {
  content: ""; flex: none; width: 3px; height: 13px; border-radius: 2px;
  background: var(--accent);
}
h3 { font-size: 14px; font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.mono { font-family: var(--font-mono); }
.boot { padding: 48px 24px; color: var(--muted); font-family: var(--font-mono); text-transform: uppercase; }

.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;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent); color: var(--accent-text); }

/* ---- HUD frame: thin rule plus accent corner brackets ---------------------- */

.hud, .panel, .stat, .camera-card, .incident-card, .login-card, .empty, .dialog {
  position: relative;
  background-color: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--glow);
}
:root[data-theme="mirage"] .hud, :root[data-theme="mirage"] .panel,
:root[data-theme="mirage"] .stat, :root[data-theme="mirage"] .camera-card,
:root[data-theme="mirage"] .incident-card, :root[data-theme="mirage"] .login-card,
:root[data-theme="mirage"] .dialog {
  /* Frosted, so the light behind the interface shows through the panels. */
  backdrop-filter: blur(14px);
}
/* Corner ticks only on the figures at the top of a page, where they read as
   instrument marks. On every panel at once they were just noise. */
.stat::before, .stat::after {
  content: ""; position: absolute; width: var(--tick); height: var(--tick);
  pointer-events: none; border-color: var(--accent);
}
.stat::before { top: -1px; left: -1px; border-top: 2px solid; border-left: 2px solid; }
.stat::after { right: -1px; bottom: -1px; border-right: 2px solid; border-bottom: 2px solid; }

/* ---- Top bar ----------------------------------------------------------------- */

.topbar {
  display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap;
  padding: var(--s2) var(--s4); position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-weight: 700; font-size: 13px;
  letter-spacing: 0.12em; text-transform: uppercase;
}
.brand.large { font-size: 16px; margin-bottom: 18px; }
.logo { width: 26px; height: 26px; border-radius: 4px; flex: none; object-fit: cover; }
.brand-logo { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; }
.org {
  font-weight: 500; color: var(--muted); padding-left: 10px; letter-spacing: 0.04em;
  border-left: 1px solid var(--line-soft);
}
.nav { display: flex; gap: 2px; }
.nav a {
  color: var(--muted); text-decoration: none; padding: 6px 10px;
  font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
  border: 1px solid transparent; border-radius: var(--radius);
}
.nav a:hover { color: var(--text); border-color: var(--line-soft); }
.nav a.active { color: var(--text); border-color: var(--line-soft); background: var(--attention); }
.nav a.active::before { content: "▸ "; color: var(--brand-text); }
.account {
  display: flex; align-items: center; gap: var(--s2); margin-left: auto; flex-wrap: wrap;
}
/* Clock · site | look · language | who · buttons */
.account > .site-name, .account > select, .account > .who {
  padding-left: var(--s2); border-left: 1px solid var(--line-soft);
}
.who { color: var(--muted); white-space: nowrap; font-size: 12.5px; }
.site-name { font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.clock {
  font-family: var(--font-mono); font-size: 11px; line-height: 1.15; text-align: right;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); white-space: nowrap;
}
.clock strong { display: block; color: var(--text); font-size: 13px; }
.theme-btn::before { content: "◐ "; color: var(--brand-text); }

/* ---- Layout -------------------------------------------------------------------- */

.view { max-width: 1280px; margin: 0 auto; padding: var(--s5) var(--s4) var(--s6); }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); padding-bottom: var(--s3);
  border-bottom: 1px solid var(--line-soft);
  position: relative;
}
.page-head::after {
  /* One red thread under the title, lit from the left. */
  content: ""; position: absolute; left: 0; bottom: -1px; width: 72px; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
}
/* The explanation under a title is a sentence, so it is set as one: body font,
   sentence case, a readable measure. */
.page-head p {
  margin: var(--s1) 0 0; font-size: 13px; color: var(--muted); max-width: 68ch;
}

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s3);
  margin-bottom: var(--s4); counter-reset: stat;
}
.stat { padding: var(--s3) var(--s3) var(--s4); counter-increment: stat; overflow: hidden; }
.stat-value {
  font-family: var(--font-display); font-weight: var(--display-weight);
  font-size: 34px; line-height: 1.05; font-variant-numeric: tabular-nums; margin-top: var(--s4);
}
.stat-label {
  color: var(--muted); font-family: var(--font-mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.07em; margin-top: 6px;
}
.stat-value::before {
  content: "0" counter(stat); position: absolute; top: 10px; left: 14px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 400; color: var(--muted);
  letter-spacing: 0.06em;
}
.stat-label::after {
  content: ""; display: block; height: 4px; margin-top: 10px;
  background: repeating-linear-gradient(90deg, var(--line-soft) 0 2px, transparent 2px 5px);
}

/* ---- Tables -------------------------------------------------------------------- */

/* A table standing on its own page needs its own frame; one inside a panel
   borrows the panel's, so it is not a second box inside the first. */
.table-wrap {
  overflow-x: auto; background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius); box-shadow: var(--glow);
}
:root[data-theme="mirage"] .table-wrap { backdrop-filter: blur(14px); }
.panel > .table-wrap {
  background: none; border: 0; border-radius: 0; box-shadow: none; backdrop-filter: none;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: var(--s2) var(--s3); text-align: left; vertical-align: middle; }
/* First and last columns line up with the panel's own padding. */
.panel th:first-child, .panel td:first-child { padding-left: var(--s4); }
.panel th:last-child, .panel td:last-child { padding-right: var(--s4); }
th {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); white-space: nowrap;
  background: var(--surface-2); border-bottom: 1px solid var(--line-soft);
}
td { border-bottom: 1px solid var(--line-soft); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
tr.attention td { background: var(--attention); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; font-family: var(--font-mono); font-size: 13px; }

.dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  vertical-align: middle; margin-right: 8px;
}
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.dot.off { background: var(--line-soft); }

/* ---- Chips and badges ---------------------------------------------------------- */

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip, .badge {
  display: inline-block; padding: 2px 7px; border-radius: var(--radius);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
  color: var(--muted); border: 1px solid var(--line-soft); background: transparent;
}
.chip.warn, .badge.warn { color: var(--warn); border-color: currentColor; background: var(--warn-bg); }
.badge.ok { color: var(--ok); border-color: currentColor; background: var(--ok-bg); }
.badge.bad { color: var(--bad); border-color: currentColor; background: var(--bad-bg); }

/* A line across the top of every page while the subscription is running out. */
.notice {
  display: flex; gap: var(--s3); align-items: center; justify-content: space-between;
  flex-wrap: wrap; width: min(1280px, 100% - 2 * var(--s4)); margin: var(--s3) auto 0;
  padding: var(--s2) var(--s3);
  border: 1px solid currentColor; border-left-width: 3px; border-radius: var(--radius);
  font-size: 13px;
}
.notice.warn { color: var(--warn); background: var(--warn-bg); }
.notice.bad { color: var(--bad); background: var(--bad-bg); }
.notice .btn { color: var(--text); border-color: currentColor; }
/* The banner sits between the top bar and the page, inside the same column. */
.notice + .view { padding-top: var(--s4); }

/* ---- Buttons and forms ---------------------------------------------------------- */

.btn {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  border-radius: var(--radius); padding: 8px 14px; line-height: 1.2;
  border: 1px solid var(--line); background: transparent; color: var(--text);
  cursor: pointer; white-space: nowrap; transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}
.btn:hover { border-color: var(--accent); color: var(--brand-text); background: var(--attention); }
.btn:disabled { opacity: 0.5; cursor: progress; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); box-shadow: var(--glow); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { border-color: var(--line-soft); background: var(--attention); color: var(--brand-text); }
.btn.small { padding: 5px 9px; font-size: 11px; }
.btn.big { padding: 12px 20px; font-size: 13px; }
.danger-text { color: var(--bad); }
.btn.ghost.danger-text:hover { color: var(--bad); border-color: var(--bad); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 8px 10px; width: 100%;
}
input:focus, select:focus { border-color: var(--line); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
.hint { font-size: 12px; color: var(--muted); }
.form-error { color: var(--bad); margin: 0; font-size: 13px; }
.form-error:not([hidden])::before { content: "✕ "; font-family: var(--font-mono); }
.filters {
  display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px;
}
.filters .field { min-width: 160px; }
.account select, .login-top select { width: auto; padding: 5px 8px; font-size: 12.5px; }
input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.login-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.login-top .brand.large { margin-bottom: 0; }

/* A panel is a header and a body. Everything inside gets the panel's own
   padding, except tables, which run to the edges: a bordered table inside a
   bordered panel was the box-inside-a-box that made pages look cluttered. */
.panel { padding: 0; margin-bottom: var(--s4); }
.panel > * { padding-inline: var(--s4); }
.panel > *:last-child { padding-bottom: var(--s4); }
.panel > .table-wrap { padding-inline: 0; }
.panel > p, .panel > .callout, .panel > .week, .panel > .chips { margin: var(--s2) 0 0; }

.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s3); flex-wrap: wrap;
  padding-block: var(--s3);
  border-bottom: 1px solid var(--line-soft);
}
.panel-head p { margin: var(--s1) 0 0; }
.panel-head + * { margin-top: var(--s3); }

/* A named group inside a panel: staff, then cameras, then keys. */
.panel h3 {
  margin: var(--s4) 0 var(--s2); color: var(--muted); font-family: var(--font-mono);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
}
.panel .panel-head + h3 { margin-top: var(--s3); }
.id-cell { display: inline-flex; align-items: center; gap: 6px; }
.id-cell code { font-size: 11.5px; color: var(--muted); font-family: var(--font-mono); }
.code-row { display: flex; align-items: flex-start; gap: 8px; }
.code {
  flex: 1; margin: 0; padding: 10px 12px; background: var(--surface-2);
  border: 1px solid var(--line-soft); border-radius: var(--radius); overflow-x: auto; white-space: pre;
  font-family: var(--font-mono); font-size: 12px;
}

.callout { border-radius: var(--radius); padding: 10px 12px; margin: 0; border: 1px solid transparent; }
.callout.warn { background: var(--warn-bg); color: var(--warn); border-color: currentColor; }
.callout.info { background: var(--surface-2); color: var(--muted); margin-bottom: 14px; border-color: var(--line-soft); }
.callout.info::before { content: "i // "; font-family: var(--font-mono); color: var(--brand-text); }

/* Facts about a thing, as label and value rather than a stack of sentences.
   Panels used to list "Key holder: Frutty" one paragraph at a time, which read
   as a wall of grey text with nothing to scan down. */
.facts {
  display: grid; grid-template-columns: minmax(120px, max-content) 1fr;
  gap: 0; margin: var(--s3) 0 0; font-size: 13px;
}
.facts dt {
  color: var(--muted); font-family: var(--font-mono); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: var(--s2) var(--s3) var(--s2) 0; border-top: 1px solid var(--line-soft);
  align-self: stretch; display: flex; align-items: center;
}
.facts dd {
  margin: 0; padding: var(--s2) 0; border-top: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
}
.facts dt:first-of-type, .facts dt:first-of-type + dd { border-top: 0; }

/* A badge followed by a sentence: the panel's headline state. */
.status { display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap; }

/* Something kept out of the way until it is asked for. */
.folded { border-top: 1px solid var(--line-soft); }
.folded > summary {
  padding: var(--s2) var(--s4); cursor: pointer; color: var(--muted);
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
}
.folded > summary:hover { color: var(--brand-text); }
.folded[open] > summary { border-bottom: 1px solid var(--line-soft); }

/* ---- Customers chart ------------------------------------------------------------- */

.presets { align-self: flex-end; }
.bars {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(30px, 1fr);
  gap: 6px; align-items: end; overflow-x: auto; padding: 14px 0 4px;
  background: repeating-linear-gradient(0deg, var(--line-soft) 0 1px, transparent 1px 40px);
  background-position: 0 -4px;
}
.bar { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.bar-track { height: 170px; width: 100%; max-width: 40px; display: flex; align-items: flex-end; }
.bar-stack { width: 100%; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.bar-new { background: var(--accent); }
.bar-returning { background: var(--accent-2); opacity: 0.85; }
:root[data-theme="mirage"] .bar-returning { background: rgb(255 107 118 / 45%); opacity: 1; }
.bar-value { font-family: var(--font-mono); font-size: 11px; font-weight: 600; min-height: 16px; }
.bar-label { font-family: var(--font-mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.bar-detail { font-family: var(--font-mono); font-size: 10.5px; white-space: nowrap; }
.legend { display: flex; gap: 14px; align-items: center; font-family: var(--font-mono); text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.06em; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; display: inline-block; }
.swatch.new { background: var(--accent); }
.swatch.returning { background: var(--accent-2); }
:root[data-theme="mirage"] .swatch.returning { background: rgb(255 107 118 / 45%); }

/* ---- Security --------------------------------------------------------------------- */

.security-state { border-left: 3px solid var(--line-soft); }
.security-state.ok { border-left-color: var(--ok); }
.security-state.warn { border-left-color: var(--warn); }
.security-state h2 { margin: 0; font-size: 14px; }
.section-title { margin: 26px 0 12px; }
.incidents { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.incident-card { overflow: hidden; display: flex; flex-direction: column; }
.incident-card.open { border-color: var(--bad); }
.incident-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.incident-body p { margin: 0; }
.photo-button { display: block; padding: 0; border: 0; background: #000; cursor: zoom-in; position: relative; }
.photo-button img, .photo-strip img { display: block; width: 100%; height: auto; }
.photo-button img { aspect-ratio: 16 / 9; object-fit: cover; }
.photo-missing {
  aspect-ratio: 16 / 9; display: grid; place-items: center; background: var(--surface-2);
  font-family: var(--font-mono); text-transform: uppercase; font-size: 11px;
}
.photo-strip { display: flex; flex-direction: column; gap: 8px; max-height: 65vh; overflow-y: auto; }

/* ---- Work schedule ------------------------------------------------------------------ */

.week { display: flex; flex-direction: column; gap: 6px; }
.week-row {
  display: grid; grid-template-columns: minmax(110px, 1fr) minmax(0, 116px) auto minmax(0, 116px);
  align-items: center; gap: 8px;
}
.week-row input[type="time"] { font-family: var(--font-mono); }
.week-row input[type="time"]:disabled { opacity: 0.4; }
.dialog-form h3 {
  margin: 4px 0 0; font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}
table.compact td { padding: 4px 6px; }

/* ---- Cameras ------------------------------------------------------------------------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.camera-card { display: flex; flex-direction: column; overflow: visible; }
.camera-card.warn { border-color: color-mix(in srgb, var(--warn) 50%, var(--line-soft)); }
/* Switched off on purpose: quiet, not alarming. */
.camera-card.off { opacity: 0.72; }
.badge.off { color: var(--muted); }
.camera-card.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--line-soft)); }
.camera-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.camera-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.camera-card p { margin: 0; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.meta dt { color: var(--muted); font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; align-self: center; }
.meta dd { margin: 0; }

.shot {
  position: relative; aspect-ratio: 16 / 9; background: #050605; overflow: hidden;
  border-bottom: 1px solid var(--line-soft);
}
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot .shot-empty {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 12px;
  color: #8fa39c; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  background:
    linear-gradient(rgb(255 255 255 / 5%) 1px, transparent 1px) 0 0 / 100% 12px,
    #070908;
}
.shot-hud {
  position: absolute; left: 8px; right: 8px; top: 8px; display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 10.5px; color: #eafff7; text-transform: uppercase;
  letter-spacing: 0.08em; text-shadow: 0 1px 2px rgb(0 0 0 / 80%); pointer-events: none;
}
.shot-hud .rec::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #ff3b30; margin-right: 6px; vertical-align: 0; animation: blink 1.4s steps(2) infinite;
}
.shot::after {
  /* Viewfinder corners. */
  content: ""; position: absolute; inset: 10px; pointer-events: none;
  background:
    linear-gradient(#fff, #fff) left top / 14px 1px no-repeat,
    linear-gradient(#fff, #fff) left top / 1px 14px no-repeat,
    linear-gradient(#fff, #fff) right top / 14px 1px no-repeat,
    linear-gradient(#fff, #fff) right top / 1px 14px no-repeat,
    linear-gradient(#fff, #fff) left bottom / 14px 1px no-repeat,
    linear-gradient(#fff, #fff) left bottom / 1px 14px no-repeat,
    linear-gradient(#fff, #fff) right bottom / 14px 1px no-repeat,
    linear-gradient(#fff, #fff) right bottom / 1px 14px no-repeat;
  opacity: 0.55;
}

.agent-strip {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
  padding: 10px 14px; border: 1px solid var(--line-soft); background: var(--surface);
  font-family: var(--font-mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em;
}
.agent-strip .pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none;
}
.agent-strip.running .pulse { background: var(--ok); animation: pulse 2s infinite; }
.agent-strip.restarting .pulse { background: var(--warn); }
.agent-log { width: 100%; margin: 4px 0 0; white-space: pre-wrap; text-transform: none; color: var(--muted); font-size: 11px; }

/* ---- Connect-camera wizard ------------------------------------------------------------ */

.dialog.wide { width: min(640px, calc(100vw - 24px)); }
.steps {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: -2px 0 4px;
  font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em;
}
.steps span {
  padding: 8px 6px; border-bottom: 2px solid var(--line-soft); color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.steps span.active { color: var(--text); border-bottom-color: var(--accent); }
.steps span.done { color: var(--ok); border-bottom-color: var(--ok); }
.found-list { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.found {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; text-align: left;
  padding: 10px 12px; border: 1px solid var(--line-soft); background: var(--surface);
  color: var(--text); font: inherit; cursor: pointer; border-radius: var(--radius);
}
.found:hover { border-color: var(--line); }
.found[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.found:disabled { cursor: default; opacity: 0.6; }
.found .ip { font-family: var(--font-mono); font-weight: 600; }
.found .icon {
  width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line-soft);
  font-family: var(--font-mono); font-size: 16px; color: var(--brand-text);
}
.scan {
  display: flex; align-items: center; gap: 14px; padding: 18px 4px;
  font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
}
.radar {
  width: 46px; height: 46px; border-radius: 50%; flex: none; position: relative;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle, transparent 38%, var(--line-soft) 39% 40%, transparent 41%),
    conic-gradient(from 0deg, color-mix(in srgb, var(--accent) 55%, transparent), transparent 30%);
  animation: spin 1.6s linear infinite;
}
.preview {
  border: 1px solid var(--line); background: #000; position: relative;
}
.preview img { width: 100%; display: block; }
.preview figcaption {
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 7px 10px; background: var(--surface); color: var(--text); border-top: 1px solid var(--line);
}
.result { padding: 10px 12px; border: 1px solid currentColor; font-size: 13px; }
.result.ok { color: var(--ok); background: var(--ok-bg); }
.result.bad { color: var(--bad); background: var(--bad-bg); }
details.advanced summary {
  cursor: pointer; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--muted);
}
.advanced-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.success-mark {
  font-family: var(--font-display); font-weight: var(--display-weight); font-size: 30px;
  text-transform: var(--display-case); color: var(--ok);
}

/* ---- Getting started, faces, Telegram -------------------------------------------------- */

.onboarding .meter { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin: 4px 0 14px; }
.onboarding .meter span { height: 4px; background: var(--line-soft); }
.onboarding .meter span.on { background: var(--accent); }
.onboarding-steps {
  list-style: none; margin: 0; padding: 0; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  grid-auto-rows: 1fr; gap: var(--s2);
}
.onboarding-steps li {
  display: grid; grid-template-columns: auto 1fr auto; gap: var(--s2); align-items: start;
  padding: var(--s2) var(--s3); border: 1px solid var(--line-soft); border-radius: var(--radius);
  background: var(--surface-2);
}
.onboarding-steps a.btn { align-self: center; }
.onboarding-steps li.done { opacity: 0.6; }
.onboarding-steps .step-no {
  font-family: var(--font-mono); font-size: 12px; font-weight: 700; width: 28px; height: 28px;
  display: grid; place-items: center; border: 1px solid var(--line);
}
.onboarding-steps li.done .step-no { color: var(--ok); border-color: var(--ok); }
.onboarding-steps .step-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.onboarding-steps a.btn { text-decoration: none; }
.face-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.panel-lite { border: 1px dashed var(--line-soft); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.steps-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
label.found { cursor: pointer; }

/* ---- Empty states ------------------------------------------------------------------------ */

.empty { border-style: dashed; padding: 40px 24px; text-align: center; }
.empty h2::before, .empty h2::after { content: none; }
.empty h2 { font-size: 13px; justify-content: center; }
.empty p { margin: 8px auto 0; max-width: 60ch; }

/* ---- Dialogs -------------------------------------------------------------------------------- */

.dialog {
  padding: 0; width: min(480px, calc(100vw - 24px)); color: var(--text);
  border-color: var(--line); background: var(--surface);
}
:root[data-theme="mirage"] .dialog { background: #0d0a0f; }
/* A dialog scrolls, so its corner marks sit inside it rather than 1px over the edge. */
.dialog { overflow-x: hidden; }
.dialog-form::before { top: 0; left: 0; }
.dialog-form::after { right: 0; bottom: 0; }
.dialog::backdrop { background: rgb(4 6 6 / 55%); backdrop-filter: blur(2px); }
.dialog-form { display: flex; flex-direction: column; gap: 14px; padding: 0 20px 20px; position: relative; }
.dialog-form > h2:first-child {
  margin: 0 -20px 2px; padding: 10px 20px; background: var(--text); color: var(--bg);
  font-size: 12px; display: flex; justify-content: space-between; gap: 8px;
}
.dialog-form > h2:first-child::before { content: "▣ "; color: inherit; opacity: 0.7; }
.dialog-form > h2:first-child::after { content: "//"; color: inherit; opacity: 0.45; }
.dialog-form p { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; flex-wrap: wrap; }

/* ---- Toasts ------------------------------------------------------------------------------------ */

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: 400px;
  background: var(--text); color: var(--bg); padding: 11px 14px 11px 16px;
  border-left: 3px solid var(--accent); font-size: 13px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 25%);
  animation: slide-in 0.18s ease-out;
}
.toast.error { background: var(--bad); color: #fff; border-left-color: #fff; }

/* ---- Sign-in and first-run --------------------------------------------------------------------- */

.login-page {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, 440px);
  align-items: center; gap: 32px; padding: 32px clamp(16px, 4vw, 56px); max-width: 1320px; margin: 0 auto;
}
.login-card { width: 100%; padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 30px; }
.login-card.wide { max-width: 480px; }

.hero { position: relative; min-height: 520px; display: flex; flex-direction: column; justify-content: space-between; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.hero-title {
  font-family: var(--font-display); font-weight: var(--display-weight); text-transform: var(--display-case);
  letter-spacing: var(--display-spacing); font-size: clamp(40px, 6.4vw, 88px); line-height: 0.92; margin: 0;
}
.hero-title span { display: block; }
.hero-title .accent { color: var(--brand-text); }
.hero-tag {
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  border: 1px solid var(--line); padding: 3px 7px; white-space: nowrap;
}
.hero-art { position: relative; width: 100%; max-width: 560px; margin: 8px auto 0; aspect-ratio: 1 / 0.82; }
.hero-art svg { width: 100%; height: 100%; overflow: visible; color: var(--text); }
.hero-art .ring { transform-origin: 280px 230px; animation: spin 60s linear infinite; }
.hero-art .ring.reverse { animation-direction: reverse; animation-duration: 90s; }
.hero-art .scanline { animation: scan 4s ease-in-out infinite alternate; }
.hero-threads { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.thread {
  border-top: 1px solid var(--line); padding-top: 8px;
  font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em;
}
.thread b { display: block; font-size: 12px; margin-top: 2px; color: var(--text); }
.thread i { font-style: normal; color: var(--muted); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } 60% { box-shadow: 0 0 0 7px transparent; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes scan { from { transform: translateY(-120px); } to { transform: translateY(120px); } }
@keyframes slide-in { from { transform: translateY(10px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Narrow screens ------------------------------------------------------------------------------ */

@media (max-width: 980px) {
  .login-page { grid-template-columns: 1fr; }
  .hero { min-height: 0; gap: 18px; }
  .hero-art { max-width: 420px; }
}

@media (max-width: 760px) {
  .topbar { gap: 10px; padding: 10px 16px; }
  .account { margin-left: 0; width: 100%; justify-content: space-between; }
  .who, .clock { display: none; }
  .view { padding: 18px 16px 40px; }
  .notice { width: calc(100% - 32px); }
  /* Seven tabs do not fit a phone: scroll the tab bar, not the whole page. */
  .nav { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .nav a { white-space: nowrap; }
  .row-actions { justify-content: flex-start; }
  .week-row { grid-template-columns: 104px minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; }
  .week-row input[type="time"] { min-width: 0; padding: 7px 4px; font-size: 14px; }
  .hero-threads { grid-template-columns: 1fr; }
  .hero-art { display: none; }
  .advanced-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 26px; margin-top: 12px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 10px 12px 12px; }
  .stat-label { font-size: 10px; }
  /* The organisation name is already in the brand line. */
  .account .site-name { display: none; }
  .page-head .btn.big { width: 100%; }
}

.file-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; cursor: pointer; }
.file-row .muted { overflow-wrap: anywhere; }
.file-row:focus-within .btn { outline: 2px solid var(--accent); outline-offset: 2px; }

.fingerprint { display: inline-block; overflow-wrap: anywhere; font-size: 11px; letter-spacing: 0.02em; }

/* A camera card's shelves: waiting alerts, Telegram switch, answer-all */
.zone-rows { list-style: none; margin: 4px 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.zone-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* Drawing shelves on a camera picture */
.zone-editor { position: relative; border: 1px solid var(--line); background: #000; }
.zone-editor img { display: block; width: 100%; height: auto; user-select: none; }
.zone-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.zone-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.zone-list li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.webcam-frame { background: #000; min-height: 120px; display: grid; place-items: center; }
.webcam-picture { display: block; width: 100%; height: auto; }

/* The picture runs the full width of its panel, like a camera card's shot. */
.ai-frame {
  background: #000; border-block: 1px solid var(--line-soft); min-height: 160px;
  display: grid; place-items: center;
}
.panel > .ai-frame { padding-inline: 0; margin-top: var(--s3); }
.ai-frame img { display: block; width: 100%; height: auto; }
