/* TaskVision: porcelain glaze, lapis ink, turquoise and pomegranate, after Rishtan ceramics.
   One loud element: an unattended kassa's tile (red frame). Everything else stays quiet. */

:root {
  color-scheme: light;
  --page: #edf1f6;
  --surface: #ffffff;
  --surface-sunk: #f4f6fa;
  --ink: #14244b;
  --ink-soft: #55647f;
  --line: #d4dbe6;
  --brand: #1c3988;
  --on-brand: #ffffff;
  --staffed: #087a6e;
  --unattended: #c22f3c;
  --no-video: #95600a;
  --focus: #2e6be6;
  --font-text: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Unbounded", "Onest", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0a1330;
    --surface: #111d42;
    --surface-sunk: #0d1838;
    --ink: #e7ecf8;
    --ink-soft: #a2aecb;
    --line: #223260;
    --brand: #8eadff;
    --on-brand: #0a1330;
    --staffed: #33c7b3;
    --unattended: #ff6c76;
    --no-video: #f2b74b;
    --focus: #8eadff;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font: 400 15px/1.5 var(--font-text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.2; }
code { font-size: 0.9em; padding: 1px 6px; border-radius: 5px; background: var(--surface-sunk); border: 1px solid var(--line); }
.soft { color: var(--ink-soft); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 28px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font: 600 18px/1 var(--font-display); color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 7px 14px; border-radius: 999px; color: var(--ink-soft); font-weight: 500; text-decoration: none; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { background: var(--page); color: var(--ink); }
.account { display: flex; align-items: center; gap: 12px; margin-left: auto; color: var(--ink-soft); font-size: 14px; }
.link-button { padding: 0; border: 0; background: none; color: var(--brand); font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

.page { max-width: 1440px; margin: 0 auto; padding: 32px 24px 72px; }

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: 600 14px/1 var(--font-text);
  text-decoration: none;
  cursor: pointer;
}
.button:hover { border-color: var(--ink-soft); }
.button.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.button.primary:hover { filter: brightness(1.12); }
.button.quiet { border-color: transparent; background: transparent; color: var(--ink-soft); }
.button.danger { color: var(--unattended); }
.button.danger:hover { border-color: var(--unattended); }
.button.danger-solid { background: var(--unattended); border-color: var(--unattended); color: #fff; }
.button[disabled] { opacity: 0.6; cursor: progress; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }

.notices { display: grid; gap: 8px; margin-bottom: 20px; }
.notice { padding: 12px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.notice.success { border-color: color-mix(in srgb, var(--staffed) 45%, var(--line)); }

/* Dashboard: what needs attention */

.overview { margin-bottom: 28px; }
.headline { max-width: 24ch; font: 600 clamp(28px, 4.2vw, 46px)/1.08 var(--font-display); letter-spacing: -0.03em; }
.attention { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; }
.attention:empty { display: none; }
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
.chip span { font-weight: 500; font-variant-numeric: tabular-nums; }
.chip.away { border-color: var(--unattended); color: var(--unattended); }
.chip.unknown { color: var(--no-video); }
.banner {
  margin-top: 16px;
  padding: 12px 16px;
  border: 1px solid color-mix(in srgb, var(--no-video) 40%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--no-video) 10%, var(--surface));
}

/* Dashboard: the wall of kassas */

.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 16px; }
.tile { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); scroll-margin-top: 80px; }
.view {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 0;
  background: #0a1330;
  cursor: zoom-in;
}
.view img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.view::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.no-picture { position: absolute; inset: 0; display: grid; place-items: center; color: #a2aecb; font-size: 14px; }
.view img:not([hidden]) + .no-picture { display: none; }
.tile[data-state="present"] .view::after { box-shadow: inset 0 -4px 0 var(--staffed); }
.tile[data-state="away"] .view::after { box-shadow: inset 0 0 0 4px var(--unattended); }
.tile[data-state="unknown"] .view img { filter: grayscale(1); opacity: 0.45; }
.tile-body { padding: 12px 14px 14px; }
.tile-name { font-size: 16px; font-weight: 600; }
.tile-state { margin-top: 2px; font-weight: 500; font-variant-numeric: tabular-nums; }
.tile[data-state="present"] .tile-state { color: var(--staffed); }
.tile[data-state="away"] .tile-state { color: var(--unattended); }
.tile[data-state="unknown"] .tile-state { color: var(--no-video); }
.tile-tally { margin-top: 6px; color: var(--ink-soft); font-size: 13px; }

.empty-state { display: grid; justify-items: start; gap: 12px; max-width: 560px; padding: 28px; }
.empty-state h2 { font-size: 20px; }
.empty-state p { color: var(--ink-soft); }

/* Dashboard: the absence log */

.log { margin-top: 48px; }
.log-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-bottom: 14px; }
.log-head h2 { margin-right: auto; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; color: var(--ink-soft); font-size: 14px; }
.filters label { display: inline-flex; align-items: center; gap: 8px; }

input, select {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
input:hover, select:hover { border-color: var(--ink-soft); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: var(--ink-soft); font-size: 13px; font-weight: 500; }
tbody tr:last-child td { border-bottom: 0; }
td.empty { padding: 28px 16px; color: var(--ink-soft); white-space: normal; }
.still-away { color: var(--unattended); font-weight: 500; }
.thumbs { display: flex; gap: 8px; }
.thumb { display: grid; justify-items: center; gap: 3px; color: var(--ink-soft); font-size: 12px; text-decoration: none; }
.thumb img { display: block; width: 96px; aspect-ratio: 16 / 9; border-radius: 6px; background: #0a1330; object-fit: cover; }
.thumb:hover img { outline: 2px solid var(--brand); outline-offset: 1px; }

.viewer { width: min(1040px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 14px; background: var(--surface); color: var(--ink); }
.viewer::backdrop { background: rgb(6 12 30 / 0.8); }
.viewer img { display: block; width: 100%; height: auto; min-height: 160px; background: #0a1330; }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; }

/* Cameras */

.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-title { font: 600 clamp(24px, 3vw, 32px)/1.1 var(--font-display); letter-spacing: -0.025em; }
.back { display: inline-block; margin-bottom: 8px; color: var(--ink-soft); font-size: 14px; }
.camera-table td:first-child a { color: var(--ink); font-weight: 600; text-decoration: none; }
.camera-table td:first-child a:hover { text-decoration: underline; }
.camera-table tr.off td { color: var(--ink-soft); }
.camera-table .actions { text-align: right; }
.state.present { color: var(--staffed); }
.state.away { color: var(--unattended); }
.state.unknown { color: var(--no-video); }
.tag { margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: var(--surface-sunk); border: 1px solid var(--line); color: var(--ink-soft); font-size: 12px; font-weight: 500; }
.aside { max-width: 70ch; margin-top: 20px; color: var(--ink-soft); font-size: 14px; }

.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 420px); align-items: start; gap: 24px; }
.camera-form { padding: 28px; }
fieldset { min-width: 0; margin: 0 0 28px; padding: 0; border: 0; }
legend { margin-bottom: 12px; padding: 0; font-size: 17px; font-weight: 600; }
.field { margin-bottom: 16px; }
.field.lead { margin-bottom: 28px; }
.field label { display: block; margin-bottom: 6px; font-weight: 500; }
.field input { width: 100%; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 16px; }
.field-row .narrow { max-width: 140px; }
.field-row:has(.narrow) { grid-template-columns: minmax(0, 1fr) 140px; }
.control { display: flex; align-items: center; gap: 10px; }
.suffix { color: var(--ink-soft); }
.field .control input[type="number"] { max-width: 140px; }
.help { margin-top: 6px; color: var(--ink-soft); font-size: 13px; }
.error { margin-top: 6px; color: var(--unattended); font-size: 13px; font-weight: 500; }
.error:empty { display: none; }
.has-error input { border-color: var(--unattended); }
.form-error { margin-bottom: 20px; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--unattended); color: var(--unattended); }

.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-bottom: 18px; padding: 4px; border-radius: 10px; background: var(--surface-sunk); border: 1px solid var(--line); }
.segment { position: relative; }
.segment input { position: absolute; opacity: 0; inset: 0; }
.segment span { display: block; padding: 8px 14px; border-radius: 7px; color: var(--ink-soft); font-weight: 500; cursor: pointer; }
.segment input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(20 36 75 / 0.12); }
.segment input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
[data-when][hidden] { display: none; }

.choices { display: grid; gap: 8px; }
.choice, .check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.choice input, .check input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--brand); }

.advanced { margin-bottom: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.advanced summary { margin-bottom: 4px; color: var(--ink-soft); font-weight: 500; cursor: pointer; }
.advanced[open] summary { margin-bottom: 16px; }

.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.form-actions .push { margin-left: auto; }

.preview { position: sticky; top: 88px; display: grid; gap: 14px; padding: 20px; }
.preview h2 { font-size: 17px; font-weight: 600; }
.preview-frame { display: grid; place-items: center; overflow: hidden; aspect-ratio: 16 / 9; border-radius: 10px; background: #0a1330; color: #a2aecb; text-align: center; }
.preview-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.preview-empty { max-width: 28ch; padding: 16px; font-size: 14px; }
.preview-result { font-size: 14px; }
.preview-result:empty { display: none; }
.preview-result strong { display: block; margin-bottom: 2px; }
.preview-result.ok strong { color: var(--staffed); }
.preview-result.failed strong { color: var(--unattended); }

.confirm { max-width: 560px; padding: 28px; }
.confirm p { margin: 12px 0 24px; color: var(--ink-soft); }

/* Log in */

.login-page { display: grid; place-items: center; min-height: 100vh; padding-top: 24px; }
.login { width: min(400px, 100%); padding: 32px; }
.login .brand { display: block; }
.login-note { margin: 8px 0 28px; color: var(--ink-soft); }
.login h1 { margin-bottom: 20px; font-size: 22px; font-weight: 600; }
.login .field input { width: 100%; }
.button.wide { width: 100%; margin-top: 8px; }

@media (max-width: 860px) {
  .form-layout { grid-template-columns: 1fr; }
  .preview { position: static; order: -1; }
}

/* On phones the absence log turns into stacked rows: kassa and time away, then the times, then photos. */
@media (max-width: 640px) {
  .log-table thead { display: none; }
  .log-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name away" "left left" "back back" "photos photos";
    gap: 2px 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
  }
  .log-table tbody tr:last-child { border-bottom: 0; }
  .log-table tbody tr:has(td.empty) { display: block; padding: 0; }
  .log-table td { padding: 0; border: 0; white-space: normal; }
  .log-table td:nth-child(1) { grid-area: name; font-weight: 600; }
  .log-table td:nth-child(2) { grid-area: left; }
  .log-table td:nth-child(3) { grid-area: back; }
  .log-table td:nth-child(4) { grid-area: away; font-weight: 600; text-align: right; }
  .log-table td:nth-child(5) { grid-area: photos; margin-top: 8px; }
  .log-table td[data-label]::before { content: attr(data-label) " "; color: var(--ink-soft); }
  .log-table td.empty { padding: 24px 16px; }
}

@media (max-width: 560px) {
  .topbar { padding: 10px 16px; gap: 8px; }
  .brand { font-size: 16px; }
  .nav a { padding: 6px 8px; }
  .account span { display: none; }
  .page { padding: 24px 16px 56px; }
  .camera-form, .preview { padding: 18px; }
  .field-row, .field-row:has(.narrow) { grid-template-columns: 1fr; }
  .field-row .narrow { max-width: none; }
}

/* Small Android phones (360px): keep the top bar on one line. */
@media (max-width: 380px) {
  .brand { font-size: 14px; }
  .nav a, .account { font-size: 14px; }
  .nav a { padding: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
