/* Noga dashboard. Light and dark follow the system setting. Chart colours are the validated pair
   (blue = worked, orange = didn't work); status colours are only ever shown with a word and a mark. */
:root {
  color-scheme: light;
  --page: #f6f5f3;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --line: #e4e2dc;
  --line-strong: #cfcdc6;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #898781;
  --link: #9a4a12;
  --accent: #ffb067;
  --accent-ink: #2a1606;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --wash: rgba(11, 11, 11, 0.05);
  --good: #0ca30c;
  --good-ink: #006300;
  --good-bg: rgba(12, 163, 12, 0.10);
  --warn-ink: #8a5a00;
  --warn-bg: rgba(250, 178, 25, 0.18);
  --bad: #d03b3b;
  --bad-ink: #a82828;
  --bad-bg: rgba(208, 59, 59, 0.10);
  --neutral-bg: rgba(11, 11, 11, 0.06);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #121117;
    --surface: #1c1a23;
    --surface-2: #26232f;
    --line: #2c2a33;
    --line-strong: #3a3743;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --ink-3: #898781;
    --link: #ffc08a;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #2c2a33;
    --axis: #3a3743;
    --wash: rgba(255, 255, 255, 0.06);
    --good-ink: #3ccf3c;
    --good-bg: rgba(12, 163, 12, 0.16);
    --warn-ink: #fab219;
    --warn-bg: rgba(250, 178, 25, 0.14);
    --bad: #e06060;
    --bad-ink: #ff8a8a;
    --bad-bg: rgba(208, 59, 59, 0.18);
    --neutral-bg: rgba(255, 255, 255, 0.08);
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; line-height: 1.2; margin: 0; letter-spacing: -0.015em; }
h2 { font-size: 15px; margin: 0 0 12px; }
p { margin: 0; }
.muted { color: var(--ink-3); }
.ink2 { color: var(--ink-2); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.he { unicode-bidi: plaintext; text-align: start; }

/* --- layout --------------------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }
.nav {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 2px;
  padding: 18px 12px; background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 16px; }
.orb {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 34% 28%, #fff2da 0%, #ffc27a 24%, #ff7a6b 56%, #8b5cf6 100%);
  box-shadow: 0 4px 12px rgba(255, 110, 100, 0.35);
}
.nav a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); }
.nav a:hover { background: var(--wash); text-decoration: none; }
.nav a.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.nav .spacer { flex: 1; }
.nav form { padding: 0 10px; }
main { padding: 28px 36px 64px; max-width: 1320px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.head .sub { color: var(--ink-2); margin-top: 6px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 16px 18px 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card-head.pad { padding: 16px 18px 0; flex-wrap: wrap; }
.card-head .filters { margin: 0; }
.mt { margin-top: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- stat tiles ---------------------------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { color: var(--ink-2); font-size: 13px; }
.tile .value { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; }
.tile .note { color: var(--ink-3); font-size: 12px; }

/* --- controls ------------------------------------------------------------------------------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2); }
.seg a { padding: 5px 12px; border-radius: 8px; color: var(--ink-2); font-size: 13px; }
.seg a:hover { text-decoration: none; background: var(--wash); }
.seg a.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
input[type="text"], input[type="search"], input[type="password"], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 6px 10px; min-height: 32px;
}
textarea { width: 100%; min-height: 70px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--series-1); outline-offset: 2px;
}
.btn {
  font: inherit; font-weight: 500; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 12px; min-height: 32px; cursor: pointer;
}
.btn:hover { background: var(--wash); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 650; }
.btn.danger { color: var(--bad-ink); }
.btn.link { background: none; border: none; color: var(--ink-2); padding: 6px 0; }
.inline { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* --- status marks (always a mark + a word, never colour alone) ---------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; font-size: 12px; font-weight: 600;
        padding: 2px 9px 2px 7px; border-radius: 999px; background: var(--neutral-bg); color: var(--ink-2); }
.pill::before { font-size: 11px; line-height: 1; }
.pill.ok { color: var(--good-ink); background: var(--good-bg); }
.pill.ok::before { content: "✓"; }
.pill.failed { color: var(--bad-ink); background: var(--bad-bg); }
.pill.failed::before { content: "✕"; }
.pill.blocked { color: var(--warn-ink); background: var(--warn-bg); }
.pill.blocked::before { content: "!"; font-weight: 800; }
.pill.stopped::before { content: "■"; font-size: 8px; }
.pill.declined::before { content: "↩"; }
.chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px;
        background: var(--neutral-bg); color: var(--ink-2); white-space: nowrap; }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); margin-right: 6px; vertical-align: 1px; }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }

/* --- tables ------------------------------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr.link:hover { background: var(--wash); cursor: pointer; }
td.name a { color: var(--ink); font-weight: 600; }
.table-wrap { overflow-x: auto; }

/* --- chart -------------------------------------------------------------------------------------- */
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch.s1 { background: var(--series-1); }
.swatch.s2 { background: var(--series-2); }
.chart { display: block; width: 100%; height: auto; margin-top: 8px; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--ink-3); font-size: 11px; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.chart .s1 { fill: var(--series-1); }
.chart .s2 { fill: var(--series-2); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--wash); }
details.table-view { margin-top: 10px; }
details.table-view summary { color: var(--ink-3); font-size: 12px; cursor: pointer; }
#tip { position: fixed; z-index: 10; pointer-events: none; opacity: 0; transition: opacity 0.08s;
       background: var(--ink); color: var(--page); font-size: 12px; padding: 6px 9px; border-radius: 8px; max-width: 280px; }

/* --- requests ------------------------------------------------------------------------------------ */
.reqs { display: flex; flex-direction: column; }
details.req { border-bottom: 1px solid var(--line); }
details.req:last-child { border-bottom: none; }
details.req > summary {
  list-style: none; cursor: pointer; display: grid; gap: 12px; align-items: baseline;
  grid-template-columns: 92px 108px minmax(0, 1.1fr) minmax(0, 1fr) 120px; padding: 11px 16px;
}
details.req.with-pc > summary { grid-template-columns: 92px 130px 108px minmax(0, 1.1fr) minmax(0, 1fr) 120px; }
details.req > summary::-webkit-details-marker { display: none; }
details.req > summary:hover { background: var(--wash); }
details.req[open] > summary { background: var(--surface-2); }
.said { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { color: var(--ink-3); font-size: 12px; text-align: right; white-space: nowrap; }
.req-body { padding: 4px 16px 16px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.req-body h3 { font-size: 12px; color: var(--ink-3); font-weight: 600; margin: 10px 0 6px; text-transform: none; }
.bubble { background: var(--surface-2); border-radius: 12px; padding: 8px 12px; margin-bottom: 6px; }
.bubble.noga { background: var(--wash); }
.actions { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.actions li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 6px; align-items: baseline; }
.mark { font-size: 12px; text-align: center; color: var(--ink-3); }
.mark.ok::before { content: "•"; }
.mark.asked::before, .mark.asked-unknown::before { content: "?"; color: var(--ink-2); font-weight: 700; }
.mark.said-no::before { content: "↩"; }
.mark.blocked::before { content: "!"; color: var(--warn-ink); font-weight: 800; }
.mark.error::before { content: "✕"; color: var(--bad-ink); }
.mark.redo::before { content: "↻"; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--ink-3); font-size: 12px; margin-top: 10px; }
.cause { color: var(--bad-ink); font-size: 13px; margin-top: 4px; }
.cause.declined, .cause.stopped { color: var(--ink-2); }
.cause.blocked { color: var(--warn-ink); }

/* --- conversations on a PC page --------------------------------------------------------------------- */
.conv { border-top: 1px solid var(--line); }
.conv:first-child { border-top: none; }
.conv-head { display: flex; gap: 10px; align-items: center; padding: 12px 16px 2px; color: var(--ink-3); font-size: 12px; }
.conv details.req { border-bottom: none; }
.note-row { padding: 6px 16px 6px 120px; color: var(--ink-3); font-size: 12px; }

/* --- profile ------------------------------------------------------------------------------------------ */
dl.kv { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 7px 12px; margin: 0; }
dl.kv dt { color: var(--ink-3); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checks li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; }
.checks .ok::before { content: "✓"; color: var(--good-ink); font-weight: 700; }
.checks .bad::before { content: "✕"; color: var(--bad-ink); font-weight: 700; }
.checks .na::before { content: "–"; color: var(--ink-3); }
.problem-group { padding: 14px 18px; border-top: 1px solid var(--line); }
.problem-group:first-of-type { border-top: none; }
.problem-group .row { display: flex; gap: 12px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.examples { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bars .bar-row { display: grid; grid-template-columns: 190px minmax(0, 1fr) 40px; gap: 10px; align-items: center; font-size: 13px; }
.meter { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: var(--series-1); }
.meter > i.w0 { width: 0%; }
.meter > i.w5 { width: 5%; }
.meter > i.w10 { width: 10%; }
.meter > i.w15 { width: 15%; }
.meter > i.w20 { width: 20%; }
.meter > i.w25 { width: 25%; }
.meter > i.w30 { width: 30%; }
.meter > i.w35 { width: 35%; }
.meter > i.w40 { width: 40%; }
.meter > i.w45 { width: 45%; }
.meter > i.w50 { width: 50%; }
.meter > i.w55 { width: 55%; }
.meter > i.w60 { width: 60%; }
.meter > i.w65 { width: 65%; }
.meter > i.w70 { width: 70%; }
.meter > i.w75 { width: 75%; }
.meter > i.w80 { width: 80%; }
.meter > i.w85 { width: 85%; }
.meter > i.w90 { width: 90%; }
.meter > i.w95 { width: 95%; }
.meter > i.w100 { width: 100%; }
.token { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--surface-2);
         border-radius: 8px; padding: 10px 12px; overflow-wrap: anywhere; user-select: all; white-space: pre-wrap; }
.callout { border: 1px solid var(--line-strong); border-radius: 14px; padding: 16px 18px; background: var(--surface-2); }
pre.raw { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); border-radius: 10px;
          padding: 12px; overflow: auto; max-height: 520px; margin: 0; }
.empty { color: var(--ink-3); padding: 24px 16px; text-align: center; }

/* --- sign in ---------------------------------------------------------------------------------------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.login .orb { width: 44px; height: 44px; margin-bottom: 8px; }
.login input { min-height: 40px; }
.login .btn { min-height: 40px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.error { color: var(--bad-ink); }

/* --- narrow screens ------------------------------------------------------------------------------------------ */
@media (max-width: 980px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .req-body { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px 12px; border-right: none; border-bottom: 1px solid var(--line); }
  .brand { padding: 4px 10px 4px 4px; }
  .nav .spacer { display: none; }
  main { padding: 20px 16px 48px; }
  details.req > summary, details.req.with-pc > summary { grid-template-columns: 70px minmax(0, 1fr); }
  details.req > summary .reply, details.req > summary .meta, details.req > summary .pc { display: none; }
  .note-row { padding-left: 16px; }
  .bars .bar-row { grid-template-columns: 120px minmax(0, 1fr) 32px; }
}
