:root {
  --ground: #f3f1ec; --surface: #fff; --chip: #ece9e2; --ink: #17191e; --muted: #5b5f68; --line: #e6e3dc; --line2: #ddd9d0;
  --red: #b3221b; --red-ink: #8e1a14; --red-tint: #fbe9e7; --green: #1d6e47; --green-tint: #e1efe7;
  --amber: #7a3a04; --amber-tint: #f6ead9; --amber-bar: #c9a15c; --band: #8e1a14;
  --r-card: 22px; --r-inner: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #121316; --surface: #1c1e22; --chip: #272a2f; --ink: #ecebe6; --muted: #a3a6ad; --line: #2e3136; --line2: #3a3d43;
    --red: #c23a31; --red-ink: #f4a7a0; --red-tint: #3a1c1a; --green: #23744c; --green-tint: #17301f;
    --amber: #e8ae6a; --amber-tint: #33261a; --amber-bar: #a47b3e; --band: #6e1712;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--surface); border-radius: var(--r-card); padding: 20px 24px; }
.narrow { width: 100%; max-width: 380px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; }
.brand img { width: 28px; height: 28px; }

/* Shell: a side menu (server switch, sections by role, connection) beside the work area */
.shell { display: flex; min-height: 100vh; }
.side { flex: 0 0 264px; background: var(--surface); border-right: 1px solid var(--line); position: sticky; top: 0;
  align-self: flex-start; height: 100vh; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 16px; }
.switcher { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--r-inner); background: var(--ground); }
.switcher select { appearance: none; border: 0; background: transparent; font-weight: 700; padding: 0; min-height: 0; width: 100%; }
.nav { display: flex; flex-direction: column; gap: 14px; }
.navgroup { display: flex; flex-direction: column; gap: 2px; }
.navgroup .label { padding: 0 10px 6px; }
.navitem { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; padding: 9px 10px;
  border: 0; border-radius: 12px; background: transparent; text-align: left; color: var(--ink); }
.navitem:hover { background: var(--ground); }
.navitem[aria-current="page"] { background: var(--chip); font-weight: 600; }
.navitem.alarm[aria-current="page"] { background: var(--red-tint); color: var(--red-ink); }
.count { border-radius: 999px; font-size: 12px; padding: 1px 8px; font-weight: 600; }
.count:empty { display: none; }
.count.red { background: var(--red); color: #fff; }
.count.amber { background: var(--amber-tint); color: var(--amber); }
.sidefoot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--r-inner); background: var(--ground); }
.sidefoot .btn { align-self: flex-start; }
.conn { display: flex; align-items: center; gap: 6px; color: var(--green); font-size: 14px; }
.conn::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.conn.bad { color: var(--red-ink); font-weight: 600; }
.conn.bad::before { background: var(--red); }
.btn.menu-toggle { display: none; }
.work { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
main { padding: 24px 32px 48px; display: flex; flex-direction: column; gap: 20px; }
.pagehead { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.alarm-slot { padding: 16px 32px 0; }
.alarm-slot:empty { display: none; }
.alarm-banner { background: var(--red); color: #fff; border-radius: 18px; padding: 12px 18px; display: flex; flex-direction: column; gap: 8px; }
.alarm-banner .btn { background: #fff; color: var(--red-ink); border-color: #fff; }

@media (max-width: 860px) {
  .shell { display: block; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .btn.menu-toggle { display: inline-flex; }
  .side:not(.open) .nav, .side:not(.open) .sidefoot { display: none; }
  main { padding: 20px 16px 40px; }
  .alarm-slot { padding: 16px 16px 0; }
}

dialog.modal { border: 0; border-radius: var(--r-card); background: var(--surface); color: var(--ink);
  padding: 22px 24px; width: min(520px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgb(23 25 30 / .45); }
.modal-kind { font-size: 22px; font-weight: 700; color: var(--red-ink); }
.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; }
.row.end { justify-content: flex-end; }
.choice .check { align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; }
.choice .check + .check { margin-top: 6px; }
.choice input { margin-top: 4px; }
.btn.hold { position: relative; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.btn.hold > span { position: relative; }
.btn.hold::before { content: ''; position: absolute; inset: 0; background: rgb(255 255 255 / .3); transform: scaleX(0); transform-origin: left; }
.btn.hold.holding::before { transform: scaleX(1); transition: transform 2s linear; }
@media (prefers-reduced-motion: reduce) { .btn.hold.holding::before { transition-duration: .01s; } }

.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1100px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 18px; margin-bottom: 10px; }
h3 { font-size: 15px; margin-bottom: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line2); border-radius: 12px; background: var(--surface); min-height: 44px; }
textarea { min-height: 80px; resize: vertical; }
label.field { display: block; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
label.check { display: flex; gap: 8px; align-items: center; padding: 4px 0; cursor: pointer; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border-radius: 22px;
  border: 1px solid var(--line2); background: var(--surface); color: var(--ink); font-weight: 500; }
.btn:hover { border-color: var(--muted); }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn.small { min-height: 34px; padding: 0 14px; border-radius: 17px; font-size: 14px; }
.btn.wide { width: 100%; min-height: 52px; border-radius: 26px; font-size: 16px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; border-top: 0; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--ground); }
table.fit td { overflow-wrap: anywhere; }
.org { padding: 10px 0; border-top: 1px solid var(--line); }
/* A wide table scrolls inside its card instead of widening the page on a phone */
.card { overflow-x: auto; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; background: var(--chip); }
.pill.red { background: var(--red-tint); color: var(--red-ink); }
.pill.green { background: var(--green-tint); color: var(--green); }
.pill.amber { background: var(--amber-tint); color: var(--amber); }

.alert-card { border: 1px solid var(--red); }
.alert-card.cleared { border-color: var(--green); }
.pill.strong { font-weight: 700; }
.btn.ghostred { color: var(--red-ink); border-color: var(--red); }
.btn.big { min-height: 52px; border-radius: 26px; padding: 0 28px; font-size: 16px; }
.link { background: none; border: 0; padding: 0; text-decoration: underline; color: inherit; }
.red-ink { color: var(--red-ink); }
.list > * { padding: 10px 0; border-top: 1px solid var(--line); }
.list > *:first-child { border-top: 0; }

/* Incident mode: the page gives way to a red header, the people to check and a pinned all-clear */
main.incident { padding: 0; gap: 0; }
main.incident > :not(.incident) { display: none; }
.incident > div { min-height: 100vh; display: flex; flex-direction: column; }
.band { background: var(--band); color: #fff; padding: 18px 32px 22px; display: flex; flex-direction: column; gap: 14px; }
.band .label { color: #fff; opacity: .85; }
.band h1 { font-size: 38px; }
.band .bottom { align-items: flex-end; }
.band .right { text-align: right; }
.band .atab { background: transparent; color: #fff; border-color: rgb(255 255 255 / .45); }
.band .atab[aria-selected="true"] { background: #fff; color: var(--band); border-color: #fff; }
.band .dot.red { background: #fff; }
.band .atab[aria-selected="true"] .dot.red { background: var(--red); }
.timer { display: block; font-size: 44px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.incident-page { padding: 24px 32px 20px; }
.grid4.big { gap: 14px; }
.grid4.big .card b { display: block; font-size: 40px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.card.alarm { border: 1px solid var(--red); }
.dock { position: sticky; bottom: 0; margin-top: auto; background: var(--surface); border-top: 1px solid var(--line);
  padding: 14px 32px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
@media (max-width: 860px) {
  .band, .incident-page, .dock { padding-left: 16px; padding-right: 16px; }
  .band h1 { font-size: 28px; }
  .timer { font-size: 34px; }
}
.grow { flex: 1 1 auto; }
.faint { opacity: .75; }

details.fold { background: var(--surface); border-radius: var(--r-card); border: 1px solid var(--line); }
details.fold.attn { border-color: var(--ink); }
details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 24px; border-radius: var(--r-card); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary:hover { background: var(--ground); }
details.fold > summary svg { transition: transform .15s; flex: none; }
details.fold[open] > summary svg { transform: rotate(180deg); }
.fold-head { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.foldtitle { font-size: 17px; font-weight: 600; }
.foldbody { padding: 0 24px 22px; overflow-x: auto; }
.row.nowrap { flex-wrap: nowrap; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: space-between; }
.pager .pages { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.pager button { min-width: 36px; min-height: 36px; border-radius: 18px; border: 1px solid var(--line2); background: var(--surface); }
.pager button[aria-current="page"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.pager button:disabled { opacity: .4; cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line2); background: var(--surface); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip.kind[aria-pressed="true"] { background: var(--red-tint); color: var(--red-ink); border: 2px solid var(--red); padding: 6px 13px; }
.chip.all { border-style: dashed; font-weight: 600; }
.chip.busy { opacity: .55; cursor: not-allowed; }
.chip.busy::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-right: 6px; }
.alertswitch { display: flex; flex-wrap: wrap; gap: 6px; }
.atab { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line2);
  background: var(--surface); text-align: left; }
.atab[aria-selected="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.dot.red { background: var(--red); }
.bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--chip); }
.bar span { display: block; height: 100%; }
.bar .b-ok { background: var(--green); } .bar .b-help { background: var(--red); } .bar .b-silent { background: var(--amber-bar); }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 860px) { .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { border-radius: 16px; padding: 12px 14px; background: var(--chip); }
.tile b { display: block; font-size: 26px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile span { font-size: 13px; }
.tile.ok { background: var(--green-tint); color: var(--green); }
.tile.help { background: var(--red-tint); color: var(--red-ink); }
.tile.silent { background: var(--amber-tint); color: var(--amber); }
.stats { display: flex; gap: 10px 18px; flex-wrap: wrap; }
.stats b { display: block; font-size: 26px; line-height: 1.1; }
.ok { color: var(--green); } .help { color: var(--red-ink); } .silent { color: var(--amber); }
.code { font: 600 24px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .1em; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--surface);
  padding: 10px 16px; border-radius: 12px; max-width: 90vw; z-index: 20; font-size: 14px; }
#toast.err { background: var(--red); color: #fff; }
.hidden { display: none !important; }
.notice { background: var(--amber-tint); color: var(--amber); padding: 10px 12px; border-radius: var(--r-inner); }
.form-err { color: var(--red-ink); font-weight: 600; }
.form-err:empty { display: none; }
.pre { white-space: pre-line; }
.notes-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
