:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #fcfcfb;
  --surface-2: #f0efeb;
  --border: #e2e0da;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #77756f;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --brand: #d9622b;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --idle: #9a988f;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #33322f;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #9a988f;
    --accent: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #33322f;
  --text: #ffffff; --text-2: #c3c2b7; --muted: #9a988f; --accent: #3987e5;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 8px; }
h1 { font-size: 22px; }
h2 { font-size: 17px; margin-top: 28px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.flame {
  width: 16px; height: 18px; background: var(--brand);
  clip-path: path("M8 0c1 3 5 5 5 10a5 5 0 0 1-10 0c0-2 1-3 2-5 .5 2 1 2.5 2.5 2.5C7 5 7 2.5 8 0z");
}
.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
#who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; font-size: 13px; }

main { max-width: 1100px; margin: 0 auto; padding: 16px 16px 64px; }

button, .btn {
  font: inherit; font-size: 14px; border-radius: 8px; padding: 6px 12px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
}
button.ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
button.danger { background: transparent; color: var(--critical); border-color: var(--critical); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input, textarea, select {
  font: inherit; width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
}
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }

.lead { border-left: 4px solid var(--brand); }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.dept { display: block; color: inherit; }
.dept:hover { text-decoration: none; border-color: var(--accent); }
.dept .headline { margin: 6px 0; color: var(--text-2); }
.dept .facts { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.sub { margin-left: 18px; border-left: 2px solid var(--border); padding-left: 12px; }
.inactive { opacity: .7; }

.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; }
.status.green .dot { background: var(--good); }
.status.amber .dot { background: var(--warning); }
.status.red .dot { background: var(--critical); }
.status.idle .dot { background: var(--idle); }
.badge { font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); }

.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md table { border-collapse: collapse; font-size: 14px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
.md pre, .md code { background: var(--surface-2); border-radius: 6px; font-size: 13px; }
.md pre { padding: 8px; overflow-x: auto; }
.md h2, .md h3 { font-size: 15px; margin-top: 14px; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; }
table.data th, table.data td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }

.thread { display: flex; flex-direction: column; gap: 8px; max-height: 480px; overflow-y: auto; padding: 4px; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); }
.msg.ceo { align-self: flex-end; background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }

details > summary { cursor: pointer; color: var(--text-2); }
.decision { border-left: 4px solid var(--warning); }
.decision.done { border-left-color: var(--border); }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }
.error { color: var(--critical); }

.login { max-width: 380px; margin: 12vh auto 0; }

@media (max-width: 600px) {
  main { padding: 12px 16px 48px; }
  .msg { max-width: 95%; }
  .sub { margin-left: 6px; }
}
.mt { margin-top: 10px; }
