/* Sight Watch Reports - v0.0.3 theme: the login nebula carried into the app, in a dark and a light mode.
   The v0.0.1 scheme is kept in palettes/app-v0.0.1.css. No plain black or plain white anywhere.
   Everything that differs between the two modes is a token below; the rules further down only use tokens. */
:root {
  color-scheme: dark;
  --bg: #080b1a;            /* deep-space navy behind everything */
  --bg-dim-top: rgba(8, 11, 26, 0.80);
  --bg-dim-bottom: rgba(8, 11, 26, 0.92);
  --bg-filter: none;
  --text: #e8ebf7;          /* text straight on the space background: headings, crumbs */
  --muted: #9ea6c8;
  --border: #2b3364;
  --card: #141a36;          /* solid on purpose: sticky table cells paint with it */
  --card-2: #1b2249;
  --card-border: rgba(255, 255, 255, 0.08);
  --card-text: #e8ebf7;
  --card-text-2: #c9cfe6;
  --card-muted: #9ea6c8;
  --card-line: #2b3364;
  --card-strong: #3b4480;
  --line-soft: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.4);
  --hover: rgba(255, 255, 255, 0.04);
  --chip: rgba(255, 255, 255, 0.09);
  --empty-bg: rgba(20, 26, 54, 0.8);
  --input: #0f1430;
  --input-text: #e8ebf7;
  --input-border: #343d78;
  --placeholder: #6f78a3;
  --disabled: #5c6590;
  --accent: #e8533a;        /* reddish-orange from the login aura */
  --accent-soft: #ff8a65;
  --accent-glow: rgba(255, 122, 77, 0.45);
  --accent-tint: rgba(255, 138, 101, 0.14);
  --text-on-accent: #fff4f0;
  --red: #ff5a5f;           /* chart line, rising deltas */
  --red-glow: rgba(255, 90, 95, 0.45);
  --green: #5fd68a;
  --ok: #2f9e5b;
  --warn: #d9a520;
  --shell-base: #1a0f28;    /* header and sidebar: dark wine-navy under the crossed red lines */
  --hatch: rgba(232, 83, 58, 0.30);
  --shell-border: #ff8a65;
  --shell-link: #ffd9cc;
  --shell-link-strong: #fff4f0;
  --shell-active: rgba(255, 138, 101, 0.22);
  --chart-grid: rgba(255, 255, 255, 0.10);
  --chart-label: #c3c9e3;
  --chart-sub: #8089ad;
  --chart-avg: #aab2d6;
  --chart-avg-hover: #f3f4fa;
  --heat-grid: rgba(20, 26, 54, 0.55);
  --loading-bg: rgba(8, 11, 26, 0.55);
  --loading-box: rgba(20, 26, 54, 0.85);
  --radius: 18px;
  --topbar-h: 68px;
  --sidebar-w: 220px;
  --sidebar-w-collapsed: 68px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

/* light mode: the same nebula drained to near-black, off-white content, the v0.0.1 crimson accent */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #06070c;
  --bg-dim-top: rgba(6, 7, 12, 0.38);
  --bg-dim-bottom: rgba(6, 7, 12, 0.62);
  --bg-filter: saturate(0.3) brightness(0.9) contrast(1.05);
  --text: #eceef5;
  --muted: #a7acc0;
  --border: #3a3d4d;
  --card: #f1f2f7;
  --card-2: #e5e7ef;
  --card-border: rgba(255, 255, 255, 0.35);
  --card-text: #1b1d2a;
  --card-text-2: #3c4158;
  --card-muted: #5d6275;
  --card-line: #d3d6e2;
  --card-strong: #b9bdcf;
  --line-soft: rgba(27, 29, 42, 0.08);
  --line-strong: rgba(27, 29, 42, 0.4);
  --hover: rgba(27, 29, 42, 0.045);
  --chip: rgba(27, 29, 42, 0.08);
  --empty-bg: rgba(241, 242, 247, 0.92);
  --input: #fafbfe;
  --input-text: #1b1d2a;
  --input-border: #c5c9d9;
  --placeholder: #8a90a8;
  --disabled: #a0a5ba;
  --accent: #c8102e;
  --accent-soft: #ff6b6b;
  --accent-glow: rgba(255, 96, 96, 0.45);
  --accent-tint: rgba(200, 16, 46, 0.10);
  --text-on-accent: #fff4f4;
  --red: #d9263a;
  --red-glow: rgba(217, 38, 58, 0.30);
  --green: #1f8f4d;
  --ok: #2e9e5b;
  --warn: #d9a520;
  --shell-base: #14121a;
  --hatch: rgba(200, 16, 46, 0.34);
  --shell-border: #ff6b6b;
  --shell-link: #ffd5d5;
  --shell-link-strong: #fff2f2;
  --shell-active: rgba(255, 107, 107, 0.22);
  --chart-grid: rgba(27, 29, 42, 0.10);
  --chart-label: #4a5068;
  --chart-sub: #7a8099;
  --chart-avg: #6b7290;
  --chart-avg-hover: #1b1d2a;
  --heat-grid: rgba(241, 242, 247, 0.75);
  --loading-bg: rgba(6, 7, 12, 0.5);
  --loading-box: rgba(241, 242, 247, 0.95);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2 { font-weight: 600; letter-spacing: 0.01em; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 0.6rem; }
.muted { color: var(--card-muted); }

/* --- shell layout: the nebula sits behind (::before), evenly dimmed (::after), the cards in front */
body.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "top top" "side main";
  min-height: 100vh;
  padding: 14px;
  gap: 16px;
  transition: grid-template-columns 0.2s ease;
  position: relative;
}
body.shell::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: var(--bg) url("/static/img/login-bg.jpg") center / cover no-repeat;
  filter: var(--bg-filter);
}
body.shell::after {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(var(--bg-dim-top), var(--bg-dim-bottom));
}
body.shell > * { position: relative; z-index: 1; }
body.shell.sidebar-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* the crossed red lines from layout.png, drawn with gradients on the shell base */
.topbar, .sidebar-box {
  background-color: var(--shell-base);
  background-image:
    repeating-linear-gradient(45deg, var(--hatch) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(-45deg, var(--hatch) 0 1px, transparent 1px 9px);
}

.topbar {
  grid-area: top;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
.brand { display: inline-flex; align-items: center; background: #eef0f6; border-radius: 12px; padding: 6px 14px; }
.brand img { height: 36px; display: block; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.who {
  display: inline-flex; align-items: center; gap: 10px;
  background: rgba(236, 240, 250, 0.92); color: #15182a;
  border-radius: 999px; padding: 6px 14px 6px 10px;
}
.who::before { content: ""; width: 22px; height: 22px; border-radius: 50%; background: #c3c8dc; display: inline-block; }
.badge {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-on-accent); background: var(--accent); border-radius: 999px; padding: 2px 8px;
}

/* dark / light switch: a pill with a sliding knob, moon on the left, sun on the right */
.theme-switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.theme-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: relative; display: inline-flex; align-items: center; justify-content: space-between;
  width: 58px; height: 30px; border-radius: 999px; padding: 0 7px;
  background: rgba(8, 11, 26, 0.6); border: 1px solid rgba(255, 255, 255, 0.28);
  transition: background 0.2s ease;
}
.switch-icon { font-size: 13px; line-height: 1; color: #ffd9cc; }
.switch-knob {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px var(--accent-glow);
  transition: transform 0.2s ease;
}
.theme-switch input:checked + .switch-track { background: rgba(236, 240, 250, 0.92); }
.theme-switch input:checked + .switch-track .switch-icon { color: #4a4e63; }
.theme-switch input:checked + .switch-track .switch-knob { transform: translateX(28px); }
.theme-switch input:focus-visible + .switch-track { outline: 2px solid var(--accent-soft); outline-offset: 2px; }

/* sidebar: an invisible column that fills the viewport below the header; the visible box floats at its middle */
body.shell > .sidebar {  /* more specific than the body.shell > * rule, which would make it relative */
  grid-area: side;
  position: sticky; top: 14px;
  align-self: start;
  height: calc(100vh - var(--topbar-h) - 44px);
  min-height: 420px;
  display: flex; flex-direction: column; justify-content: center;
}
.sidebar-box {
  position: relative;
  border: 1.5px solid var(--shell-border);
  border-radius: 26px;
  box-shadow: 0 0 16px var(--accent-glow), inset 0 0 12px var(--accent-glow);
  padding: 64px 10px 22px;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sidebar a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px;
  color: var(--shell-link); text-decoration: none; font-weight: 500;
  transition: background 0.15s ease;
}
.sidebar a:hover { background: rgba(255, 255, 255, 0.08); }
.sidebar a.active { background: var(--shell-active); color: var(--shell-link-strong); box-shadow: inset 0 0 0 1px var(--shell-border); }
.nav-icon { display: inline-flex; width: 20px; }
.sidebar-toggle {
  position: absolute; top: 10px; right: 10px;
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--shell-border); background: rgba(8, 11, 26, 0.5); color: var(--shell-link);
  cursor: pointer; font-size: 12px; line-height: 1;
}
.sidebar-collapsed .sidebar-box { padding: 54px 8px 18px; }
.sidebar-collapsed .nav-label { display: none; }
.sidebar-collapsed .sidebar a { justify-content: center; padding: 11px 0; }
.sidebar-collapsed .sidebar-toggle { transform: rotate(180deg); right: 20px; }

.content { grid-area: main; min-width: 0; }
.content-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin: 8px 4px 18px;
}
.content-head h1 { text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6); }

/* --- week picker */
.week-picker { display: inline-flex; align-items: center; gap: 6px; }
.week-picker select {
  font: inherit; color: var(--input-text); background: var(--input);
  border: 1px solid var(--input-border); border-radius: 10px; padding: 8px 12px; min-width: 220px;
}
.wp-arrow {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px; text-decoration: none; font-size: 22px; line-height: 1;
  background: var(--input); color: var(--input-text); border: 1px solid var(--input-border);
}
.wp-arrow:hover { border-color: var(--accent-soft); }
.wp-arrow.disabled { opacity: 0.35; }

/* --- cards, notices, tables */
.card {
  background: var(--card); color: var(--card-text);
  border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 22px 26px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.card + .card { margin-top: 18px; }
.placeholder { text-align: center; padding: 60px 26px; }
.empty {
  background: var(--empty-bg); color: var(--card-text); border: 1px dashed var(--card-strong); border-radius: var(--radius);
  padding: 40px 26px; text-align: center;
}
.empty-title { font-size: 1.15rem; font-weight: 600; margin: 0 0 6px; }
.empty-sub { color: var(--card-muted); margin: 0; }
.notice { border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: 0.93rem; }
.notice-info { background: rgba(255, 196, 77, 0.14); border: 1px solid rgba(255, 196, 77, 0.45); color: #ffe3a6; }

.table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.table th, .table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--card-line); vertical-align: top; }
.table th { font-weight: 600; color: var(--card-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.table th[title] { cursor: help; }
.table th[title]:hover { color: var(--card-text); text-decoration: underline dotted var(--line-strong); text-underline-offset: 4px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .wrap { white-space: pre-wrap; max-width: 520px; }
.status {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em;
  border-radius: 999px; padding: 2px 8px; color: #fff4f0; background: var(--card-strong);
}
.status-ok { background: var(--ok); }
.status-failed { background: var(--accent); }
.status-skipped { background: var(--warn); color: #1b1d2a; }

/* --- card headers and toolbars */
.card-head { margin-bottom: 14px; }
.card-head .muted { margin: 4px 0 0; }
.card-title { font-size: 1.05rem; font-weight: 600; margin: 0; }
.card-actions { margin-top: 16px; display: flex; justify-content: center; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.search {
  font: inherit; padding: 6px 12px; border-radius: 10px; min-width: 220px;
  border: 1px solid var(--input-border); background: var(--input); color: var(--input-text);
}
.search::placeholder { color: var(--placeholder); }
.search:focus { outline: 2px solid var(--accent-soft); outline-offset: 1px; }

/* --- pivot table (site > camera) */
.pivot th.rank, .pivot td.rank { width: 2.4em; color: var(--card-muted); text-align: right; font-variant-numeric: tabular-nums; }
.pivot .site-row { cursor: pointer; font-weight: 600; font-size: 1rem; }
.pivot .site-row:hover td { background: var(--hover); }
.pivot .site-row:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: -2px; }
.pivot .site-row td { border-bottom: 1px solid var(--card-strong); padding-top: 11px; padding-bottom: 11px; }
.pivot .site-row.open td { border-bottom-color: var(--accent-soft); }
.pivot .chev {
  display: inline-block; width: 0; height: 0; margin-right: 10px; vertical-align: 2px;
  border-left: 6px solid var(--card-muted); border-top: 5px solid transparent; border-bottom: 5px solid transparent;
  transition: transform 0.15s ease;
}
.pivot .site-row.open .chev { transform: rotate(90deg); border-left-color: var(--accent-soft); }
.pivot .cams { margin-left: 10px; font-size: 0.72rem; font-weight: 500; color: var(--card-muted); background: var(--chip); border-radius: 999px; padding: 1px 7px; vertical-align: 1px; white-space: nowrap; }
.pivot .total { font-size: 1.05rem; }
.pivot .cam-row td { padding-top: 5px; padding-bottom: 5px; border-bottom: 1px solid var(--line-soft); font-size: 0.9rem; }
.pivot .cam-row .cam { padding-left: 32px; color: var(--card-text-2); }
.pivot .cam-row:hover td { background: var(--hover); }
.pivot .share { color: var(--card-muted); }
.pivot .team { font-weight: 500; color: var(--card-text-2); white-space: nowrap; }
.pivot .team-link { text-decoration: none; border-bottom: 1px dotted var(--line-strong); }
.pivot .team-link:hover { color: var(--accent-soft); border-bottom-color: var(--accent-soft); }
.pivot .delta .up { color: var(--red); }
.pivot .delta .down { color: var(--green); }
.pivot .filtered { display: none; }

/* --- teams */
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.head-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.crumb { color: var(--muted); text-decoration: none; font-weight: 500; }
.crumb:hover { color: var(--text); }
.crumb-sep { color: var(--muted); margin: 0 4px; }
.team-select { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--card-muted); }
.team-select select {
  font: inherit; padding: 6px 10px; border-radius: 10px;
  border: 1px solid var(--input-border); background: var(--input); color: var(--input-text); min-width: 170px;
}
.teams-table .act { width: 1%; white-space: nowrap; text-align: right; }
.teams-table .unassigned .site { color: var(--card-muted); font-weight: 500; }
.teams-table .sub-head td { color: var(--card-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--card-line); }
.teams-table .sub-head td[title] { cursor: help; }
.total-row td { font-weight: 700; border-top: 2px solid var(--card-strong); border-bottom: none; }

.segmented { display: inline-flex; border: 1px solid var(--input-border); border-radius: 10px; overflow: hidden; background: var(--input); }
.segmented button {
  font: inherit; font-size: 0.85rem; padding: 6px 12px; border: 0; background: transparent; color: var(--input-text); cursor: pointer;
  border-right: 1px solid var(--input-border);
}
.segmented button:last-child { border-right: 0; }
.segmented button:hover:not(:disabled) { background: var(--accent-tint); }
.segmented button.active { background: var(--accent); color: var(--text-on-accent); }
.segmented button:disabled { color: var(--disabled); cursor: not-allowed; }

/* --- weekly line chart */
.chart { margin-top: 6px; }
.team-line-chart { width: 100%; height: auto; display: block; }
.team-line-chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.team-line-chart .avg { stroke: var(--chart-avg); stroke-width: 1; stroke-dasharray: 5 4; transition: stroke 0.15s ease, stroke-width 0.15s ease; }
.team-line-chart .avg-hit { stroke: transparent; stroke-width: 16; cursor: default; }
.team-line-chart .avglabel { font-size: 11px; fill: var(--chart-avg); }
.team-line-chart .avg-group:hover .avg { stroke: var(--chart-avg-hover); stroke-width: 2; stroke-dasharray: 6 4; }
.team-line-chart .avg-group:hover .avglabel { fill: var(--chart-avg-hover); font-weight: 600; }
.team-line-chart .line { fill: none; stroke: var(--red); stroke-width: 2.5; stroke-linejoin: round; filter: drop-shadow(0 0 4px var(--red-glow)); }
.team-line-chart .ylabel, .team-line-chart .xlabel { font-size: 12px; fill: var(--chart-label); }
.team-line-chart .xsub { font-size: 10px; fill: var(--chart-sub); }
.team-line-chart .pt circle { fill: var(--card); stroke: var(--red); stroke-width: 2.5; cursor: pointer; }
.team-line-chart .pt circle:hover { fill: var(--red); }
.team-line-chart .pt.selected circle { fill: var(--red); }
.team-line-chart .ptlabel { font-size: 12px; font-weight: 700; fill: var(--red); }
.chart-empty { text-align: center; padding: 30px 0; }

/* --- cameras by hour */
.hour-toolbar { display: flex; align-items: center; gap: 8px; margin: 14px 0 8px; }
.hour-title { font-weight: 600; margin-right: auto; }
.hour-scroll { overflow-x: auto; }
.hour-table { font-size: 0.8rem; min-width: 980px; }
.hour-table th, .hour-table td { padding: 4px 3px; text-align: center; }
.hour-table th.label, .hour-table td.label { text-align: left; min-width: 230px; max-width: 320px; position: sticky; left: 0; background: var(--card); z-index: 1; }
.hour-table th.h { width: 28px; font-size: 0.7rem; }
.hour-table td.h { font-variant-numeric: tabular-nums; }
/* collapsed site rows: a faint divider between hour columns so a number is not read against the wrong hour */
.hour-table .site-row td.h, .hour-table th.h, .hour-table .total-row td.h { border-left: 1px solid var(--line-soft); }
.hour-table .site-row td { padding-top: 7px; padding-bottom: 7px; font-size: 0.85rem; }
.hour-table .site-row .site-h { color: var(--card-muted); font-weight: 500; }
.hour-table .site-row:hover td.label { background: var(--card-2); }
.hour-table .cam-row td.label { padding-left: 24px; }
/* expanded camera rows: Excel-style green > yellow > red cells, dark text, thin gridlines in the card colour */
.hour-table td.heat { color: #1b1d2a; font-weight: 500; border-left: 1px solid var(--heat-grid); }
.hour-table .cam-row td { border-bottom: 1px solid var(--card); }
.hour-table .cam-row:hover td { background: inherit; }
.hour-table .total-row td { position: static; }
.hour-table .total-row td.label { position: sticky; }
.hour-table td.tot, .hour-table th.tot { text-align: right; font-weight: 600; padding-right: 8px; }

/* --- about */
.about-brand { display: flex; align-items: center; gap: 18px; }
.about-brand img { height: 56px; background: #eef0f6; border-radius: 12px; padding: 6px 12px; }
.about-title { font-size: 1.3rem; font-weight: 600; margin: 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 22px 0 0; }
.facts dt { color: var(--card-muted); }
.facts dd { margin: 0; }
.copyright { margin: 28px 0 0; color: var(--card-muted); font-size: 0.85rem; }
code { background: var(--chip); border-radius: 6px; padding: 1px 6px; font-size: 0.9em; }

/* --- buttons */
.btn {
  font: inherit; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; padding: 8px 16px;
  border: 1px solid var(--input-border); background: var(--input); color: var(--input-text);
}
.btn:hover { border-color: var(--accent-soft); color: var(--accent-soft); }
.btn-sm { padding: 5px 10px; font-size: 0.85rem; }
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, 0.3); color: #fff4f0; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.1); color: #fff4f0; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.1); color: var(--text-on-accent); }

/* --- loading overlay: shown while the next page is being fetched */
.loading {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: var(--loading-bg);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  color: var(--card-text);
}
.loading[hidden] { display: none; }
.loading-box {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 28px 40px; border-radius: 22px;
  background: var(--loading-box); border: 1px solid var(--card-border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  font-weight: 500; letter-spacing: 0.02em;
}
.spinner {
  width: 58px; height: 58px; border-radius: 50%;
  border: 5px solid var(--accent-tint);
  border-top-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* --- login page (always the dark art, whatever mode the user picked inside) */
body.login {
  min-height: 100vh;
  background: #050611 url("/static/img/login-bg.jpg") center / cover no-repeat fixed;
  display: grid; place-items: center;
  position: relative;
}
body.login::before {
  content: ""; position: fixed; inset: 0;
  background: radial-gradient(ellipse at 30% 40%, rgba(5, 6, 17, 0.15), rgba(5, 6, 17, 0.6) 70%);
  pointer-events: none;
}
.login-wrap {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 48px;
  width: min(1040px, 92vw); padding: 24px;
}
.login-logo { position: relative; display: grid; place-items: center; min-height: 380px; }
.login-logo img { position: relative; width: min(420px, 80%); filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.55)); }
.aura {
  position: absolute; width: 520px; height: 520px; border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 150, 90, 0.55) 0%,
    rgba(230, 70, 60, 0.40) 28%,
    rgba(180, 40, 60, 0.18) 50%,
    rgba(120, 20, 60, 0.0) 70%);
  filter: blur(6px);
  animation: aura-breathe 9s ease-in-out infinite;
}
@keyframes aura-breathe {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.06); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .aura { animation: none; } }

.glass {
  background: rgba(14, 16, 30, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 22px;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.login-box {
  padding: 36px 36px 32px; display: flex; flex-direction: column; gap: 14px;
  max-width: 420px; width: 100%; justify-self: center;
}
.login-box h1 { font-size: 1.6rem; }
.login-sub { margin: -8px 0 6px; color: var(--muted); }
.login-box label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: #d8dbe8; }
.login-box input {
  font: inherit; font-size: 1rem; padding: 11px 14px; border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25); background: #eef0f6; color: #15182a;
}
.login-box input:focus { outline: 2px solid var(--accent-soft); outline-offset: 1px; }
.login-box .btn-primary { margin-top: 8px; padding: 12px; font-size: 1rem; }
.form-error {
  background: rgba(232, 83, 58, 0.25); border: 1px solid rgba(255, 138, 101, 0.6); color: #ffd9cc;
  border-radius: 10px; padding: 10px 12px; font-size: 0.9rem;
}

/* --- header pill: for admins it opens the upload page */
a.who { text-decoration: none; transition: box-shadow 0.15s ease; }
a.who:hover, a.who:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent-soft), 0 0 14px var(--accent-glow); }
a.who.active { box-shadow: 0 0 0 2px var(--accent); }
.who-icon { display: inline-flex; color: var(--accent); margin-left: -2px; }
.who-icon svg { width: 16px; height: 16px; }

/* --- Home: the chart card follows the "no data" box when the week is empty */
.empty + .card { margin-top: 18px; }

/* --- upload page (admins) */
.upload-form { display: flex; flex-direction: column; gap: 16px; }
.drop-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-height: 168px; padding: 22px 20px; text-align: center;
  border: 2px dashed var(--card-strong); border-radius: 14px; background: var(--card-2);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.drop:hover, .drop.has-files { border-color: var(--accent-soft); }
.drop.dragover { border-color: var(--accent-soft); background: var(--accent-tint); }
.drop:focus-within { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
/* the file input covers the whole box: clicking and dropping files both work without any script */
.drop input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop-icon { display: inline-flex; color: var(--accent-soft); }
.drop-icon svg { width: 30px; height: 30px; }
.drop-title { font-weight: 600; font-size: 1.02rem; }
.drop-sub { color: var(--card-muted); font-size: 0.85rem; max-width: 380px; }
.drop-files { list-style: none; margin: 8px 0 0; padding: 0; width: 100%; font-size: 0.85rem; text-align: left; }
.drop-files li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 2px; border-top: 1px solid var(--line-soft); word-break: break-word; }
.drop-files li span:last-child { color: var(--card-muted); white-space: nowrap; }
.drop-files li.bad, .drop-files li.bad span:last-child { color: var(--red); }
.upload-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.upload-actions .muted { font-size: 0.88rem; }
.upload-progress p { margin: 8px 0 0; font-size: 0.9rem; }
.progress { height: 10px; border-radius: 999px; background: var(--chip); overflow: hidden; }
.progress-bar { height: 100%; width: 0; border-radius: inherit; background: var(--accent); box-shadow: 0 0 10px var(--accent-glow); transition: width 0.2s ease; }
.notice-error { background: rgba(255, 90, 95, 0.12); border: 1px solid rgba(255, 90, 95, 0.5); color: var(--red); }
.notice-wait { background: var(--accent-tint); border: 1px solid var(--accent-soft); color: var(--card-text); }
.job-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.job-head .card-title { margin-right: auto; }
.job-files { margin: 8px 0 0; font-size: 0.88rem; word-break: break-word; }
.job-result { margin: 14px 0 6px; font-weight: 500; }
.job-weeks { margin: 0; padding-left: 20px; }
.job-weeks a { color: var(--card-text); text-decoration-color: var(--accent-soft); text-underline-offset: 3px; }
.job-weeks a:hover { color: var(--accent-soft); }
.job-log, .cmd {
  font-family: "Cascadia Mono", Consolas, "Courier New", monospace; font-size: 0.8rem; line-height: 1.55;
  background: var(--input); color: var(--card-text-2); border: 1px solid var(--input-border); border-radius: 10px;
  padding: 10px 14px; margin: 14px 0 0; white-space: pre-wrap; overflow: auto;
}
.job-log { max-height: 240px; }
.cmd { margin: 0; white-space: pre; }
.spinner.spinner-sm { width: 20px; height: 20px; border-width: 3px; box-shadow: none; }
.status-running, .status-waiting, .status-queued { background: #3f6fd1; }

/* --- changes by hand (admins): the outcome note, the site row buttons and their dialogs */
.flash { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.flash-ok { background: rgba(95, 214, 138, 0.14); border: 1px solid rgba(95, 214, 138, 0.5); color: #d2f7de; }
.flash-error { background: rgba(255, 90, 95, 0.16); border: 1px solid rgba(255, 90, 95, 0.55); color: #ffd6d7; }
.flash a { color: inherit; font-weight: 600; text-underline-offset: 3px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.row-acts { float: right; display: inline-flex; gap: 4px; margin: -3px 2px -3px 10px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--input-border); background: var(--input); color: var(--card-muted);
  opacity: 0.6; transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.icon-btn svg { width: 15px; height: 15px; }
.site-row:hover .icon-btn, .site-row:focus-within .icon-btn { opacity: 1; }
.icon-btn:hover, .icon-btn:focus-visible { opacity: 1; color: var(--accent-soft); border-color: var(--accent-soft); outline: none; }
.dialog {
  width: min(460px, calc(100vw - 32px)); padding: 0;
  border-radius: var(--radius); border: 1px solid var(--card-border);
  background: var(--card); color: var(--card-text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.dialog::backdrop { background: var(--loading-bg); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.dialog form { display: flex; flex-direction: column; gap: 12px; padding: 22px 24px; }
.dialog-title { font-size: 1.1rem; font-weight: 600; margin: 0; }
.dialog-site { margin: -6px 0 2px; color: var(--card-text-2); font-weight: 500; word-break: break-word; }
.dialog-note { margin: 0; font-size: 0.86rem; color: var(--card-muted); }
.dialog .notice { margin: 0; }
.notice-merge { background: rgba(255, 196, 77, 0.16); border: 1px solid rgba(255, 196, 77, 0.55); color: var(--card-text); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; color: var(--card-muted); }
.field select, .field input {
  font: inherit; font-size: 0.95rem; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--input-border); background: var(--input); color: var(--input-text);
}
.field select:focus, .field input:focus { outline: 2px solid var(--accent-soft); outline-offset: 1px; }

/* --- Stats (v0.0.6): six cards of one size, three to a row; two rows fill a full-screen window,
   and a list longer than its card scrolls inside it */
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.stats-grid .card + .card { margin-top: 0; }
.stat-card {
  display: flex; flex-direction: column; min-width: 0;
  height: max(340px, calc((100vh - var(--topbar-h) - 130px) / 2));
  padding: 18px 20px 12px;
}
.stat-head { margin-bottom: 10px; }
.stat-head .card-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.stat-head .muted { margin: 4px 0 0; font-size: 0.85rem; }
.count {
  font-size: 0.75rem; font-weight: 600; line-height: 1.6; padding: 0 9px; border-radius: 999px;
  color: var(--card-text-2); background: var(--chip); font-variant-numeric: tabular-nums;
}
.count-warn { color: #1b1d2a; background: var(--warn); }
.count-alert { color: var(--text-on-accent); background: var(--red); }
.stat-body {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  margin: 0 -10px; padding: 0 10px;
  scrollbar-width: thin; scrollbar-color: var(--card-strong) transparent;
}
.stat-body::-webkit-scrollbar { width: 8px; }
.stat-body::-webkit-scrollbar-track { background: transparent; }
.stat-body::-webkit-scrollbar-thumb { background: var(--card-strong); border-radius: 8px; }
.stat-body::-webkit-scrollbar-thumb:hover { background: var(--accent-soft); }
.stat-list { list-style: none; margin: 0; padding: 0; }
.stat-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--line-soft); }
.stat-row:last-child { border-bottom: 0; }
.stat-main { flex: 1; min-width: 0; }
.stat-name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.stat-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 10px; margin-top: 3px; font-size: 0.8rem; color: var(--card-muted); }
.stat-side { flex: none; display: flex; align-items: center; gap: 8px; }
.stat-num { font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-row .icon-btn { opacity: 0.45; }
.stat-row:hover .icon-btn, .stat-row:focus-within .icon-btn { opacity: 1; }
.stat-cols {
  position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; gap: 10px;
  padding: 2px 2px 6px; background: var(--card); border-bottom: 1px solid var(--card-line);
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--card-muted);
}
.stat-empty { margin: 26px 0; text-align: center; color: var(--card-muted); font-size: 0.92rem; }
.stat-subhead {
  margin: 14px 0 0; padding-bottom: 6px; border-bottom: 1px solid var(--card-line);
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--green);
}
.team-chip {
  display: inline-flex; align-items: center; font: inherit; font-size: 0.76rem; font-weight: 500; line-height: 1.6;
  padding: 0 8px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap;
  background: var(--chip); color: var(--card-text-2);
}
.team-chip.none { color: var(--card-muted); }
button.team-chip { cursor: pointer; border-color: var(--input-border); }
button.team-chip:hover, button.team-chip:focus-visible { border-color: var(--accent-soft); color: var(--accent-soft); outline: none; }
.reason-form { margin: 0; }
.reason-select {
  font: inherit; font-size: 0.82rem; padding: 4px 6px; border-radius: 8px; cursor: pointer; max-width: 9.5em;
  border: 1px solid var(--input-border); background: var(--input); color: var(--input-text);
}
.reason-select:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 1px; }
.reason-select.reason-not_reviewed { border-color: var(--warn); }
.reason-select.reason-down { border-color: var(--red); color: var(--red); }
.reason-select.reason-removed { color: var(--card-muted); }
.reason { font-size: 0.76rem; font-weight: 600; line-height: 1.6; padding: 0 9px; border-radius: 999px; white-space: nowrap; background: var(--chip); color: var(--card-text-2); }
.reason.reason-not_reviewed { box-shadow: inset 0 0 0 1px var(--warn); }
.reason.reason-down { color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.reason.reason-removed { color: var(--card-muted); }
.stat-help { margin-top: 8px; font-size: 0.8rem; color: var(--card-muted); }
.stat-help summary { cursor: pointer; width: max-content; }
.stat-help summary:hover { color: var(--card-text); }
.stat-help dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 8px 0 2px; }
.stat-help dt { font-weight: 600; color: var(--card-text-2); }
.stat-help dd { margin: 0; }
.stat-table { font-size: 0.88rem; }
.stat-table th, .stat-table td { padding: 7px 6px; vertical-align: middle; }
.stat-table th { position: sticky; top: 0; z-index: 1; background: var(--card); white-space: nowrap; }
.stat-table td.wk { white-space: nowrap; }
.stat-table td.wk a { text-decoration: none; border-bottom: 1px dotted var(--line-strong); }
.stat-table td.wk a:hover { color: var(--accent-soft); border-bottom-color: var(--accent-soft); }
.stat-table .bar-col { width: 40%; }
.stat-table .bar { display: block; height: 8px; min-width: 3px; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-soft)); opacity: 0.8; }
.stat-table tr.selected td { background: var(--accent-tint); font-weight: 600; }
.stat-table tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.stat-table tr.selected .bar { opacity: 1; box-shadow: 0 0 8px var(--accent-glow); }
.stat-table .delta { white-space: nowrap; }
.stat-table .up { color: var(--red); }
.stat-table .down { color: var(--green); }
@media (max-width: 1400px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* --- responsive */
@media (max-width: 900px) {
  body.shell { grid-template-columns: var(--sidebar-w-collapsed) 1fr; padding: 10px; gap: 10px; }
  .nav-label { display: none; }
  .sidebar a { justify-content: center; padding: 10px 0; }
  .sidebar-box { padding: 18px 8px; }
  .sidebar-toggle { display: none; }
  .drop-grid { grid-template-columns: 1fr; }
  .who-name { display: none; }
  .login-wrap { grid-template-columns: 1fr; gap: 12px; }
  .login-logo { min-height: 240px; }
  .aura { width: 320px; height: 320px; }
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { height: 420px; }
}
