/* cerberus-ops — one stylesheet, no build step, no external fonts.
   Light is the base; the dark values are a selected second palette, declared
   under both the OS media query and an explicit [data-theme] stamp so the
   in-app toggle wins in either direction. */

:root {
  color-scheme: light;
  --plane:        #f4f4f1;
  --surface:      #fcfcfb;
  --surface-2:    #f0efec;
  --ink:          #0b0b0b;
  --ink-2:        #52514e;
  --muted:        #898781;
  --grid:         #e1e0d9;
  --axis:         #c3c2b7;
  --hairline:     rgba(11, 11, 11, 0.10);
  --shadow:       0 1px 2px rgba(11,11,11,.05), 0 8px 24px -12px rgba(11,11,11,.16);

  --series-1:     #2a78d6;
  --series-2:     #eb6834;
  --series-3:     #1baf7a;
  --seq-100:      #cde2fb;
  --seq-250:      #86b6ef;
  --seq-400:      #3987e5;
  --seq-550:      #1c5cab;
  --seq-700:      #0d366b;

  --good:         #0ca30c;
  --good-text:    #006300;
  --warning:      #fab219;
  --serious:      #ec835a;
  --critical:     #d03b3b;

  --wash:         rgba(42,120,214,.10);
  --wash-good:    rgba(12,163,12,.10);
  --wash-bad:     rgba(208,59,59,.10);
  --wash-warn:    rgba(250,178,25,.14);

  --r-sm: 8px; --r: 14px; --r-lg: 22px;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane: #0d0d0d; --surface: #1a1a19; --surface-2: #232322;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --hairline: rgba(255,255,255,.10);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -16px rgba(0,0,0,.7);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
    --seq-100: #184f95; --seq-250: #1c5cab; --seq-400: #3987e5;
    --seq-550: #86b6ef; --seq-700: #cde2fb;
    --good-text: #0ca30c;
    --wash: rgba(57,135,229,.16); --wash-good: rgba(12,163,12,.16);
    --wash-bad: rgba(208,59,59,.18); --wash-warn: rgba(250,178,25,.16);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d; --surface: #1a1a19; --surface-2: #232322;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --hairline: rgba(255,255,255,.10);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -16px rgba(0,0,0,.7);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  --seq-100: #184f95; --seq-250: #1c5cab; --seq-400: #3987e5;
  --seq-550: #86b6ef; --seq-700: #cde2fb;
  --good-text: #0ca30c;
  --wash: rgba(57,135,229,.16); --wash-good: rgba(12,163,12,.16);
  --wash-bad: rgba(208,59,59,.18); --wash-warn: rgba(250,178,25,.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* Several containers here set display:flex/grid, which outranks the UA's
   [hidden] rule. Without this, hiding a tab does nothing. */
[hidden] { display: none !important; }
body {
  font-family: var(--sans);
  background: var(--plane);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.45;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.011em; }
a { color: var(--series-1); }
button { font: inherit; }

/* ------------------------------------------------------------------ shell */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--hairline);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.02em; }
.brand .mark {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--series-1), color-mix(in srgb, var(--series-1) 60%, #000));
  color: #fff; font-size: 13px; font-weight: 700;
}
.brand small { color: var(--muted); font-weight: 500; letter-spacing: 0; }
.spacer { flex: 1; }

.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: none; color: var(--ink-2);
  padding: 7px 13px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  font-size: 14px; font-weight: 500;
}
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab[aria-selected="true"] { background: var(--ink); color: var(--surface); }

main { padding: 22px 20px 72px; max-width: 1360px; margin: 0 auto; }

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 18px;
}
.card > header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.card > header h3 { font-size: 15px; }
.card > header .sub { color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .cols-3, .cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 640px)  { .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; } }

/* -------------------------------------------------------------- stat tile */
.tile { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r); padding: 15px 16px; }
.tile .label { color: var(--ink-2); font-size: 12.5px; font-weight: 500; }
.tile .value { font-size: 30px; font-weight: 640; letter-spacing: -.025em; margin-top: 3px; line-height: 1.1; }
.tile .value.sm { font-size: 24px; }
.tile .delta { font-size: 12.5px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 5px; }
.delta .up { color: var(--good-text); } .delta .down { color: var(--critical); }

.hero { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 18px; }
.hero .figure { font-size: 60px; font-weight: 640; letter-spacing: -.035em; line-height: 1; }
.hero .caption { color: var(--ink-2); max-width: 40ch; font-size: 13.5px; }

/* ------------------------------------------------------------------ chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 550;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--hairline);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.good { background: var(--wash-good); color: var(--good-text); border-color: transparent; }
.chip.bad  { background: var(--wash-bad);  color: var(--critical); border-color: transparent; }
.chip.warn { background: var(--wash-warn); color: var(--ink); border-color: transparent; }
.chip.info { background: var(--wash); color: var(--series-1); border-color: transparent; }

/* --------------------------------------------------------------- controls */
.btn {
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 550;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--ink); color: var(--surface); border-color: transparent; }
.btn.primary:hover { opacity: .9; }
.btn.danger { color: var(--critical); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: 13px; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: none; color: var(--ink-2); padding: 5px 11px;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 550;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--hairline); border-radius: 10px; padding: 8px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--series-1); outline-offset: 1px; }
label.field { display: block; font-size: 12.5px; color: var(--ink-2); font-weight: 550; margin-bottom: 4px; }

/* --------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
.row-link { cursor: pointer; }

details.table-twin > summary {
  cursor: pointer; color: var(--muted); font-size: 12.5px; margin-top: 10px; list-style: none;
}
details.table-twin > summary::before { content: "▸ "; }
details.table-twin[open] > summary::before { content: "▾ "; }

/* ---------------------------------------------------------------- charts */
.chart { width: 100%; overflow: visible; }
.chart text { font-family: var(--sans); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.tooltip {
  position: fixed; pointer-events: none; z-index: 100; opacity: 0;
  transition: opacity .09s ease;
  background: var(--surface); color: var(--ink); border: 1px solid var(--hairline);
  border-radius: 10px; box-shadow: var(--shadow); padding: 8px 11px; font-size: 12.5px;
  max-width: 260px;
}
.tooltip b { font-weight: 600; }
.tooltip .k { color: var(--muted); }

/* ------------------------------------------------------------- LO portal */
.lo-page { max-width: 560px; margin: 0 auto; padding: 18px 16px 90px; }
.switch-card {
  border-radius: var(--r-lg); padding: 26px 22px 22px; text-align: center;
  background: var(--surface); border: 1px solid var(--hairline); box-shadow: var(--shadow);
  transition: background .25s ease, border-color .25s ease;
}
.switch-card.on { background: linear-gradient(180deg, var(--wash-good), var(--surface) 62%); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.switch-card.break { background: linear-gradient(180deg, var(--wash-warn), var(--surface) 62%); }
.state-word { font-size: 13px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
.state-timer { font-size: 54px; font-weight: 640; letter-spacing: -.03em; line-height: 1.05; margin: 2px 0 2px; font-variant-numeric: tabular-nums; }
.state-note { color: var(--ink-2); font-size: 13.5px; min-height: 20px; }

.big-switch {
  margin: 20px auto 10px; width: 100%; max-width: 340px; height: 92px;
  border-radius: 999px; border: 0; cursor: pointer; position: relative;
  background: var(--ink); color: var(--surface);
  font-size: 19px; font-weight: 640; letter-spacing: -.01em;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  transition: transform .12s ease, background .25s ease, box-shadow .2s ease;
  box-shadow: 0 10px 26px -14px rgba(0,0,0,.6);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.big-switch:active { transform: scale(.975); }
/* A step down from the status green so white label text clears contrast on the
   fill; the status hue still reads as "on". */
.big-switch.on { background: color-mix(in srgb, var(--good) 82%, #000); color: #fff; }
.big-switch[disabled] { opacity: .6; }
.big-switch .knob {
  width: 26px; height: 26px; border-radius: 50%; background: currentColor;
  box-shadow: 0 0 0 6px color-mix(in srgb, currentColor 22%, transparent);
}
.pulse { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .45 } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none } .big-switch { transition: none } }

.mini-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.mini { background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px; padding: 10px 8px; text-align: center; }
.mini .v { font-size: 19px; font-weight: 640; letter-spacing: -.02em; }
.mini .l { font-size: 11px; color: var(--muted); margin-top: 1px; }
@media (max-width: 420px) { .mini-grid { grid-template-columns: repeat(2, 1fr); } }

.queue-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  border-bottom: 1px solid var(--grid);
}
.queue-item:last-child { border-bottom: 0; }
.queue-item .who { flex: 1; min-width: 0; }
.queue-item .who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-item .who span { color: var(--muted); font-size: 12.5px; }
.call-btn {
  background: var(--series-1); color: #fff; border: 0; border-radius: 10px;
  padding: 8px 14px; font-weight: 600; text-decoration: none; font-size: 13.5px;
}

/* -------------------------------------------------------------- ops misc */
.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.person {
  display: flex; align-items: center; gap: 11px; padding: 11px 12px;
  border: 1px solid var(--hairline); border-radius: 12px; background: var(--surface);
}
.person .status-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--axis); }
.person.on .status-dot { background: var(--good); box-shadow: 0 0 0 4px var(--wash-good); }
.person.break .status-dot { background: var(--warning); box-shadow: 0 0 0 4px var(--wash-warn); }
.person .n { font-weight: 600; font-size: 14px; }
.person .s { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.alert { border-radius: var(--r); padding: 13px 15px; display: flex; gap: 11px; align-items: flex-start; }
.alert.bad  { background: var(--wash-bad); }
.alert.warn { background: var(--wash-warn); }
.alert .ico { font-size: 15px; line-height: 1.3; }
.alert b { display: block; margin-bottom: 2px; }
.alert ul { margin: 6px 0 0; padding-left: 18px; font-size: 13.5px; }

.drawer {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 60;
  display: flex; justify-content: flex-end;
}
.drawer[hidden] { display: none; }
.drawer > .panel {
  width: min(680px, 100%); background: var(--plane); height: 100%; overflow-y: auto;
  padding: 20px; border-left: 1px solid var(--hairline);
}
.timeline { position: relative; margin: 8px 0 0; padding: 0 0 0 22px; list-style: none; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--grid); }
.timeline li { position: relative; padding: 8px 0; }
.timeline li::before {
  content: ""; position: absolute; left: -21px; top: 14px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px var(--plane);
}
.timeline li.answered::before { background: var(--good); }
.timeline li.missed::before, .timeline li.voicemail::before { background: var(--critical); }
.timeline li.lead::before { background: var(--series-1); }
.timeline .when { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.empty { color: var(--muted); font-size: 13.5px; padding: 18px 4px; text-align: center; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 200;
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 999px;
  font-size: 13.5px; font-weight: 550; box-shadow: var(--shadow); opacity: 0;
  transition: opacity .18s ease, transform .18s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

.sched-grid { display: grid; grid-template-columns: 120px repeat(7, 1fr); gap: 6px; font-size: 13px; }
.sched-grid .hd { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; padding: 4px; }
.sched-cell {
  border: 1px solid var(--hairline); border-radius: 9px; padding: 6px; min-height: 46px;
  background: var(--surface); cursor: pointer; font-variant-numeric: tabular-nums;
}
.sched-cell:hover { border-color: var(--series-1); }
.sched-cell.set { background: var(--wash); border-color: transparent; }
.sched-cell .t { font-size: 11.5px; color: var(--ink-2); }

.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 22px; }
.login-card { width: min(420px, 100%); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 14px; }
.pin-pad button {
  padding: 17px 0; font-size: 21px; font-weight: 600; border-radius: 13px;
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink); cursor: pointer;
}
.pin-pad button:active { background: var(--surface-2); }
.pin-dots { display: flex; gap: 11px; justify-content: center; margin: 16px 0 2px; }
.pin-dots i { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--axis); }
.pin-dots i.filled { background: var(--ink); border-color: var(--ink); }
.who-list { display: grid; gap: 7px; max-height: 46vh; overflow-y: auto; }
.who-list button {
  text-align: left; padding: 13px 15px; border-radius: 12px; font-size: 16px; font-weight: 550;
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink); cursor: pointer;
}
.who-list button:hover { border-color: var(--series-1); background: var(--surface-2); }
.err { color: var(--critical); font-size: 13px; min-height: 18px; margin-top: 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------- availability grid */
/* Two rows of seven: this week, then next. Sized for a thumb, because this gets
   used on a phone in a car park more often than at a desk. */
.avail-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 10px;
}
.avail-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 74px;
  padding: 8px 4px;
  border: 1px solid var(--grid);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  text-align: center;
}
.avail-day:hover:not(:disabled) { border-color: var(--series-1); }
.avail-day .d { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.avail-day .n { font-size: 18px; font-weight: 650; line-height: 1.1; }
.avail-day .h { font-size: 10px; color: var(--ink-2); line-height: 1.25; }

.avail-day.is-today { border-color: var(--series-1); box-shadow: inset 0 0 0 1px var(--series-1); }
/* A declared day off is a state, not a series — hence the status colour. */
.avail-day.is-off { background: var(--wash-bad); border-color: var(--critical); }
.avail-day.is-off .h { color: var(--critical); font-weight: 600; }
.avail-day.is-partial { background: var(--wash-warn); border-color: var(--warning); }
.avail-day.is-locked { opacity: .45; cursor: default; }

@media (max-width: 560px) {
  .avail-week { grid-template-columns: repeat(4, 1fr); }
  .avail-day { min-height: 66px; }
}
