/* Revive brand fonts: Outfit (headings), Source Sans 3 (text), IBM Plex Mono (small capital labels) */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Outfit:wght@500;600;700&family=Source+Sans+3:wght@400;600;700&display=swap');

/* Colours follow the Revive design system: navy canvas, green to act, coral to point. Light theme is the
   same family on white and light-grey; dark theme is the brand's navy. Status colours (red / amber) are
   kept apart from the brand's coral so a warning never looks like decoration. */
:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --topbar: #ffffff;
  --ink: #111f2d;
  --ink-2: #3d546a;
  --ink-3: #5c7184;
  --line: #dce3e9;
  --line-strong: #b9c6d1;
  --hover: #eaeff3;
  --accent: #187a4c; /* green, dark enough for text on white */
  --primary: #2bb673;
  --primary-hover: #34c681;
  --on-primary: #ffffff;
  --coral: #f07951;
  --good: #2bb673;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --inactive: #a0adb8;
  --workshop: #4f78a8;
  --workshop-text: #345d8a;
  --workshop-wash: #e8f0f8;
  --sickbay: #8a5fbf;
  --sickbay-text: #6c4699;
  --sickbay-wash: #f3edfa;
  --closed: #6b8296;
  --closed-text: #4d6274;
  --closed-wash: #eef2f5;
  --good-text: #187a4c;
  --warning-text: #8a5a00;
  --critical-text: #b02a2a;
  --critical-wash: #fdecec;
  --warning-wash: #fff5df;
  --radius: 14px;
  --font-head: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
  --ch-card: #2a5bd7; /* sales graph: card / cash (validated pair, see dataviz palette check) */
  --ch-cash: #eb6834;
  color-scheme: light;
}
/* Dark (Revive navy): used when the computer is in dark mode (unless the theme button says Light), or
   whenever the theme button says Dark. The two blocks must stay identical. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18293a;
    --surface: #203549;
    --topbar: #111f2d;
    --ink: #ffffff;
    --ink-2: #a8bccb;
    --ink-3: #8499aa;
    --line: #2a4056;
    --line-strong: #3d546a;
    --hover: #2a4056;
    --accent: #34c681;
    --primary: #2bb673;
    --primary-hover: #34c681;
    --on-primary: #ffffff;
    --coral: #f07951;
    --inactive: #6c8195;
    --workshop: #7da8d6;
    --workshop-text: #9fc2e6;
    --workshop-wash: #1f3a55;
    --sickbay: #a983d8;
    --sickbay-text: #c9aef0;
    --sickbay-wash: #2e2d4c;
    --closed: #a8bccb;
    --closed-text: #c3d2dd;
    --closed-wash: #24384c;
    --good: #2bb673;
    --good-text: #34c681;
    --warning-text: #fbbf3c;
    --critical-text: #ff8a8a;
    --critical-wash: #3d2433;
    --warning-wash: #3b3424;
    --ch-card: #3987e5;
    --ch-cash: #d95926;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #18293a;
  --surface: #203549;
  --topbar: #111f2d;
  --ink: #ffffff;
  --ink-2: #a8bccb;
  --ink-3: #8499aa;
  --line: #2a4056;
  --line-strong: #3d546a;
  --hover: #2a4056;
  --accent: #34c681;
  --primary: #2bb673;
  --primary-hover: #34c681;
  --on-primary: #ffffff;
  --coral: #f07951;
  --inactive: #6c8195;
  --workshop: #7da8d6;
  --workshop-text: #9fc2e6;
  --workshop-wash: #1f3a55;
  --sickbay: #a983d8;
  --sickbay-text: #c9aef0;
  --sickbay-wash: #2e2d4c;
  --closed: #a8bccb;
  --closed-text: #c3d2dd;
  --closed-wash: #24384c;
  --good: #2bb673;
  --good-text: #34c681;
  --warning-text: #fbbf3c;
  --critical-text: #ff8a8a;
  --critical-wash: #3d2433;
  --warning-wash: #3b3424;
  --ch-card: #3987e5;
  --ch-cash: #d95926;
  color-scheme: dark;
}

/* theme button */
.theme-btn { display: inline-flex; align-items: center; gap: 6px; }
.theme-btn svg { width: 16px; height: 16px; }

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--ink-3); }

/* ---- loading states: placeholders while Nayax data comes in ---- */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 50; background: transparent; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s ease; }
.skel, .skel-bar {
  background: linear-gradient(90deg, var(--line) 25%, var(--hover) 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
.skel { display: inline-block; height: .85em; border-radius: 4px; vertical-align: middle; max-width: 100%; }
.mixbar .skel-bar { background-color: var(--line); }
.skel-row { cursor: default; }
.skel-row .mname { color: var(--ink-2); }
.status.loading { color: var(--ink-3); font-weight: 500; }
.skel-more td { color: var(--ink-3); text-align: center; padding: 12px; }
.skel-more svg { vertical-align: -2px; margin-right: 6px; }
.spin { animation: spin 0.9s linear infinite; }
tbody tr.arrive { animation: arrive .45s ease-out; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes arrive { from { opacity: 0; transform: translateY(-3px); background: var(--hover); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .skel, .skel-bar, .spin, tbody tr.arrive { animation: none; }
}
.small { font-size: 12px; }

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.title { display: flex; align-items: center; gap: 10px; }
h1 { font-size: 18px; margin: 0; font-weight: 650; }
.badge { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 99px; background: var(--warning-wash); color: var(--warning-text); }
.badge.live { background: transparent; color: var(--good-text); border: 1px solid var(--line-strong); }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.btn { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.ghost { border-color: transparent; }
a.btn { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; }

/* ---- Settings page ---- */
.settings-main { max-width: 920px; padding-bottom: 96px; }
.settings-main .intro { margin: 0 0 16px; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .92em; background: var(--hover); padding: 1px 5px; border-radius: 4px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 4px; }
.card h2 { font-size: 16px; margin: 0; }
.card > p { margin: 4px 0 12px; }
.small-btn { padding: 3px 10px; font-size: 13px; }
.set-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); gap: 8px 20px; padding: 12px 0; border-top: 1px solid var(--line); }
.set-row:first-of-type { border-top: 0; }
.set-row.pending { background: linear-gradient(90deg, var(--warning-wash), transparent 70%); margin: 0 -18px; padding-left: 18px; padding-right: 18px; }
.set-label { font-weight: 600; }
.set-text p { margin: 2px 0 0; }
.set-input { display: flex; flex-direction: column; gap: 6px; }
.set-input input[type="number"] { width: 110px; }
.set-input input[type="number"], .text-field { padding: 6px 9px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); font-variant-numeric: tabular-nums; }
.text-field { width: 100%; }
.has-error input { border-color: var(--critical); }
.field-error { color: var(--critical-text); font-weight: 600; }
.num-field { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.set-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.src-badge { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line-strong); color: var(--ink-3); }
.src-badge.dashboard { border-color: var(--accent); color: var(--accent); }
.src-badge.env { color: var(--ink-2); }
.src-badge.pending { border-color: var(--warning); color: var(--warning-text); }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 12px; text-decoration: underline; }
.br-row { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin: 12px 0; }
.br-row label.btn { cursor: pointer; }
.rank-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rank-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: grab; user-select: none; }
.rank-list li:hover { border-color: var(--line-strong); }
.rank-list li.dragging { opacity: .5; border-style: dashed; cursor: grabbing; }
.rank-handle { color: var(--ink-3); font-size: 16px; line-height: 1; }
.rank-num { width: 1.6em; text-align: right; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rank-label { flex: 1; min-width: 0; }
.rank-count { white-space: nowrap; }
.rank-move { display: flex; gap: 4px; }
.icon-btn { width: 30px; height: 30px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); cursor: pointer; line-height: 1; }
.icon-btn:hover:not(:disabled) { background: var(--hover); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.sev-pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.sev-pill.critical { background: var(--critical-wash); color: var(--critical-text); }
.sev-pill.warning { background: var(--warning-wash); color: var(--warning-text); }
.sev-pill.unknown { background: var(--hover); color: var(--ink-3); }
.savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: center; align-items: center; gap: 16px; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--line-strong); box-shadow: 0 -4px 16px rgba(0,0,0,.08); }
.savebar[hidden] { display: none; }
/* clickable problem names in the ranking, and the problem settings window */
.rank-open { border: 0; background: none; padding: 2px 0; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.rank-open:hover .rank-edit, .rank-open:focus-visible .rank-edit { color: var(--accent); }
.rank-open:hover { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.rank-edit { color: var(--ink-3); font-weight: 700; margin-left: 2px; }
.modal { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal[open] { display: flex; flex-direction: column; }
.modal::backdrop { background: rgba(0,0,0,.45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 4px 18px 8px; overflow-y: auto; }
.modal-body > p { margin: 10px 0; }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-fields .set-row { grid-template-columns: minmax(0, 1fr) minmax(180px, 240px); }
.modal-fields .set-row.pending { margin: 0 -18px; }
.levels-box { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 8px; background: var(--hover); }
.levels-box p { margin: 0; }
.levels { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.levels-label { width: 110px; }
.levels-arrow { color: var(--ink-3); }
@media (max-width: 760px) {
  .modal-fields .set-row { grid-template-columns: 1fr; }
  .levels-label { width: 100%; }
}
.savebar-actions { display: flex; gap: 8px; }
@media (max-width: 760px) {
  .set-row { grid-template-columns: 1fr; }
  .rank-list li { flex-wrap: wrap; }
  .rank-label { flex-basis: calc(100% - 140px); }
}

main { max-width: 1400px; margin: 0 auto; padding: 20px 24px 40px; }

.banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: var(--warning-wash); color: var(--ink); border: 1px solid var(--line); }
.banner.error { background: var(--critical-wash); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.tile {
  text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; display: flex; flex-direction: column; gap: 4px;
}
.tile:hover { border-color: var(--line-strong); }
.tile.active { outline: 2px solid var(--accent); outline-offset: -1px; }
.tile-label { color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.tile-value { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile-sub { color: var(--ink-3); font-size: 12px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot.critical { background: var(--critical); }
.dot.warning { background: var(--warning); }
.dot.healthy { background: var(--good); }
.dot.inactive, .dot.unknown { background: var(--inactive); }
.dot.workshop { background: var(--workshop); }
.status.workshop { color: var(--workshop-text); }
.ws-cell { color: var(--workshop-text); white-space: nowrap; }
.ws-box { background: var(--workshop-wash); border-radius: 8px; padding: 12px 14px; margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.ws-box p { margin: 0; }
.ws-note { white-space: pre-wrap; }
.ws-box textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); resize: vertical; }
.ws-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.ws-mark { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn.primary:hover { opacity: .9; background: var(--ink); }
.review { display: flex; flex-direction: column; gap: 10px; }
.review label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
.review select, .review textarea { font-size: 14px; color: var(--ink); padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }
.review textarea { resize: vertical; }
.slow-box { background: var(--hover); border-radius: 8px; padding: 12px 14px; margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.slow-box p { margin: 0; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line-strong); color: var(--ink-2); vertical-align: middle; margin-left: 4px; white-space: nowrap; }
.issue-box.muted-box { background: var(--hover); color: var(--ink-2); }

/* sick bay: known long-term problems parked out of the main view */
.dot.sickbay { background: var(--sickbay); }
.status.sickbay { color: var(--sickbay-text); }
.sb-tag { border-color: var(--sickbay); color: var(--sickbay-text); }
.sb-cell { color: var(--sickbay-text); white-space: nowrap; }
.issues.parked li { color: var(--ink-3); }
.sb-box { background: var(--sickbay-wash); border-radius: 8px; padding: 12px 14px; margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.sb-box p { margin: 0; }
.sb-box svg { vertical-align: -2px; }
.sb-note { white-space: pre-wrap; }
.sb-back { color: var(--warning-text); font-weight: 600; }
.sb-box textarea, .sb-box input[type="date"] { width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); }
.sb-box textarea { resize: vertical; }
.sb-codes { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.sb-codes legend { font-size: 12px; color: var(--ink-2); margin-bottom: 4px; padding: 0; }
.sb-codes label { display: flex; gap: 8px; align-items: flex-start; }
.sb-codes input { margin-top: 3px; }

.mix { margin: 16px 0; }
.mixbar { display: flex; gap: 2px; height: 10px; border-radius: 99px; overflow: hidden; background: var(--line); }
.mixbar span { display: block; height: 100%; }
.mixlegend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 8px; color: var(--ink-2); font-size: 12px; }
.mixlegend span { display: inline-flex; align-items: center; gap: 6px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
#search { flex: 1 1 260px; min-width: 0; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }
select { padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-strong); background: transparent; border-radius: 99px; padding: 4px 12px; cursor: pointer; }
.chip:hover { background: var(--hover); }
.chip.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--ink-2); font-size: 12px; white-space: nowrap; cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--ink); }
th.sorted::after { content: " ↓"; }
th.sorted.asc::after { content: " ↑"; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--hover); }
td[data-label]::before { content: none; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mname { font-weight: 600; }
.copy-btn { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; padding: 3px 5px; margin-left: 2px; border: 0; border-radius: 4px; background: transparent; color: var(--ink-3); cursor: pointer; font-size: 13px; }
.serial { white-space: nowrap; }
.copy-btn:hover { background: var(--hover); color: var(--accent); }
.copy-btn.labelled { border: 1px solid var(--line-strong); padding: 5px 10px; border-radius: 8px; color: var(--accent); font-weight: 500; }
.d-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 30;
  max-width: calc(100% - 32px); background: var(--ink); color: var(--surface);
  padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast kbd { font: 12px/1 ui-monospace, Consolas, monospace; padding: 2px 5px; border-radius: 4px; border: 1px solid currentColor; opacity: .9; }
.toast code { word-break: break-all; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.msub { color: var(--ink-3); font-size: 12px; }
.issues { margin: 0; padding: 0; list-style: none; }
/* Issues are plain text, so they wrap and give way; machine and location keep room to be read */
.issues li { white-space: normal; line-height: 1.35; }
.issues li + li { margin-top: 3px; }
@media (min-width: 761px) {
  #grid th:nth-child(2), #grid td:nth-child(2) { min-width: 220px; }
  #grid th:nth-child(3), #grid td:nth-child(3) { min-width: 200px; }
  #grid th:nth-child(7), #grid td:nth-child(7) { width: 30%; min-width: 240px; }
}
.issues li.critical { color: var(--critical-text); }
.issues li.warning { color: var(--warning-text); }
.issues li.unknown, .issues li.inactive { color: var(--ink-3); }
.empty { text-align: center; padding: 30px; color: var(--ink-3); }

.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.status svg { flex: none; }
.status.critical { color: var(--critical-text); }
.status.warning { color: var(--warning-text); }
.status.healthy { color: var(--good-text); }
.status.inactive, .status.unknown { color: var(--ink-3); }

.bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; vertical-align: middle; margin-right: 6px; }
.bars i { width: 4px; background: var(--line-strong); border-radius: 1px; }
.bars i.on { background: var(--ink-2); }
.bars.weak i.on { background: var(--critical); }

/* ---- machine details panel ---- */
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(1320px, 100%, max(1040px, 82vw));
  background: var(--bg); border-left: 1px solid var(--line-strong); z-index: 20; box-shadow: -12px 0 40px rgba(0,0,0,.18);
  transform: translateX(100%); transition: transform .2s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 24px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.d-head-main { min-width: 0; }
.d-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.drawer-head h2 { margin: 0; font-size: 22px; line-height: 1.2; }
.d-title-row .status { font-size: 15px; padding: 3px 10px; border-radius: 99px; background: var(--hover); }
.d-title-row .status.critical { background: var(--critical-wash); }
.d-title-row .status.warning { background: var(--warning-wash); }
.d-title-row .status.sickbay { background: var(--sickbay-wash); }
.d-title-row .status.workshop { background: var(--workshop-wash); }
.drawer-head p { margin: 4px 0 0; }
.d-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.d-tags .tag { margin-left: 0; }
.ws-tag { border-color: var(--workshop); color: var(--workshop-text); }
.drawer-body { padding: 18px 24px 32px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.drawer-body h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin: 0 0 10px; }

/* problems: the first thing you see */
.d-problems { display: flex; flex-direction: column; gap: 8px; }
.problem { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; font-size: 15px; font-weight: 600; border-left: 5px solid transparent; background: var(--surface); }
.problem svg { flex: none; width: 18px; height: 18px; }
.problem.critical { background: var(--critical-wash); border-left-color: var(--critical); color: var(--critical-text); }
.problem.warning { background: var(--warning-wash); border-left-color: var(--warning); color: var(--warning-text); }
.problem.unknown, .problem.muted-box { background: var(--hover); border-left-color: var(--line-strong); color: var(--ink-2); }
.problem.parked { background: var(--sickbay-wash); border-left-color: var(--sickbay); color: var(--sickbay-text); font-weight: 500; font-size: 13px; }
.problem-detail { display: block; margin-top: 2px; font-size: 13px; font-weight: 400; color: var(--ink-2); }
.problem-note { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--ink-3); }
.d-allclear { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; font-weight: 600; background: var(--surface); border-left: 5px solid var(--good); color: var(--good-text); }
.d-allclear.parked { border-left-color: var(--sickbay); color: var(--sickbay-text); font-weight: 500; }

/* key facts strip */
.d-facts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.fact { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.fact-label { font-size: 12px; color: var(--ink-3); }
.fact-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fact-sub { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fact.critical { border-top-color: var(--critical); background: var(--critical-wash); }
.fact.critical .fact-value { color: var(--critical-text); }
.fact.warning { border-top-color: var(--warning); background: var(--warning-wash); }
.fact.warning .fact-value { color: var(--warning-text); }

/* two columns: actions + assessment | details */
.d-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.d-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.d-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.d-card > :last-child { margin-bottom: 0; }
.d-actions-card .ws-box:first-of-type, .d-actions-card .sb-box:first-of-type, .d-actions-card .slow-box:first-of-type { margin-top: 0; }
/* Sales timeline in the details panel */
.sales-chart {
  --ch-bar: var(--ch-card);
  --ch-weekend: color-mix(in srgb, var(--ink) 3.5%, transparent); /* barely-there band */
  /* compared periods: the brand's neutral grey-blue, so they don't read as "good" (green) */
  --ch-ref: color-mix(in srgb, var(--ink-2) 75%, var(--surface));
  --ch-ref-fill: color-mix(in srgb, var(--ink-2) 10%, transparent);
}
.ch-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 6px; }
.ch-head h3 { margin: 0 !important; }
.ch-key { display: flex; gap: 14px; flex-wrap: wrap; }
.ch-key span { display: inline-flex; align-items: center; gap: 6px; }
.ch-key i { display: inline-block; width: 14px; height: 10px; border-radius: 2px; }
.k-bar { background: var(--ch-bar); }
.k-cash { background: var(--ch-cash); }
.k-unknown { background: var(--inactive); }
.k-weekend { background: var(--ch-weekend); }
.k-ref { background: var(--ch-ref-fill); border: 1.5px solid var(--ch-ref); }
.k-quiet { background: var(--critical-wash); border: 1px solid var(--critical); }
.ch-wrap { position: relative; }
.ch-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.ch-weekend { fill: var(--ch-weekend); }
.ch-hatch-line { stroke: var(--line-strong); stroke-width: 1; }
.ch-quiet { fill: var(--critical-wash); }
.ch-fault { fill: url(#ch-fault-hatch); }
.ch-fault-line { stroke: var(--critical); stroke-width: 1; opacity: .45; }
.ch-skip { fill: none; stroke: var(--ink-3); stroke-width: 1.2; stroke-dasharray: 4 3; }
.ch-skip-label { font-size: 12px; font-style: italic; fill: var(--ink-3); }
.k-skip { border: 1.2px dashed var(--ink-3); }
.k-fault { background: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--critical) 45%, transparent) 0 1px, transparent 1px 5px); border: 1px solid color-mix(in srgb, var(--critical) 45%, transparent); }
/* Fault periods list in the machine panel */
.fault-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; }
.fault-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.fp-main { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.fault-list li.ignored .fp-main strong { color: var(--ink-3); text-decoration: line-through; }
.fault-list li.gap .fp-main strong, .fault-list li.short .fp-main strong { color: var(--ink-2); font-weight: 500; }
.ch-week { fill: none; stroke: var(--ink-3); stroke-width: 1; }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-base { stroke: var(--line-strong); stroke-width: 1; }
.ch-bar { fill: var(--ch-bar); }
.ch-bar.cash { fill: var(--ch-cash); }
.ch-bar.unknown { fill: var(--inactive); }
.ch-ref-bg { fill: var(--ch-ref-fill); }
.ch-ref { fill: none; stroke: var(--ch-ref); stroke-width: 1.5; }
.ch-ref-label { font-size: 13px; font-weight: 700; fill: var(--ink); }
.ch-ref-label.now { fill: var(--ink); }
.ch-now { stroke: var(--ink-2); stroke-width: 1.5; }
.ch-axis { font-size: 11px; fill: var(--ink-3); }
.ch-note { font-size: 12px; fill: var(--ink-3); }
.ch-hover { fill: var(--ink); opacity: .08; pointer-events: none; }
.ch-tip { position: absolute; top: 0; transform: translate(-50%, -100%); background: var(--ink); color: var(--surface); padding: 6px 10px; border-radius: 6px; font-size: 12px; line-height: 1.4; white-space: nowrap; pointer-events: none; z-index: 2; }
.ch-summary { margin: 8px 0 0; color: var(--ink-2); }
.ch-empty { margin: 0; min-height: 40px; display: flex; align-items: center; }
/* Alerts / sales sit beside the details and are exactly as tall as the left column; the list scrolls inside.
   The box is taken out of the flow so only the left column sets the row height. */
@media (min-width: 901px) {
  .d-cols { align-items: stretch; }
  .d-feed-col { position: relative; min-height: 420px; }
  .d-feed-col > .d-feed { position: absolute; inset: 0; display: flex; flex-direction: column; }
  #d-alerts, #d-sales { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin-right: -8px; padding-right: 8px; }
}
/* Actions run across the panel: status boxes side by side, then the buttons */
.d-actions-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.d-actions-row > .ws-box, .d-actions-row > .sb-box, .d-actions-row > .slow-box { flex: 1 1 300px; margin-top: 0; }
.d-actions-row > .ws-actions { flex: 1 1 100%; margin-top: 0; }
.d-actions-row > .d-action-note { flex: 1 1 100%; margin: 0; }
.d-actions-card .ws-mark { margin-top: 0; }
.d-kv { margin: 0; display: flex; flex-direction: column; }
.d-kv > div { display: grid; grid-template-columns: minmax(120px, 44%) 1fr; gap: 10px; padding: 7px 8px; margin: 0 -8px; border-radius: 6px; }
.d-kv > div + div { border-top: 1px solid var(--line); }
.d-kv dt { color: var(--ink-3); font-size: 13px; }
.d-kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.d-kv > div.critical { background: var(--critical-wash); border-top-color: transparent; }
.d-kv > div.critical dd { color: var(--critical-text); font-weight: 600; }
.d-kv > div.warning { background: var(--warning-wash); border-top-color: transparent; }
.d-kv > div.warning dd { color: var(--warning-text); font-weight: 600; }
.rel { font-weight: 600; }
.abs { color: var(--ink-3); font-size: 12px; margin-left: 4px; white-space: nowrap; }

/* Alerts / Sales switch */
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--hover); border: 1px solid var(--line); margin-bottom: 10px; }
.seg button { border: 0; background: transparent; padding: 6px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.feed li.critical .feed-dot { background: var(--critical); }
.feed li.warning .feed-dot { background: var(--warning); }
.feed li.good .feed-dot { background: var(--good); }
.feed li.critical .feed-main { color: var(--critical-text); font-weight: 600; }
.feed-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.feed-meta { font-size: 12px; color: var(--ink-3); font-weight: 400; }
.feed-when { flex: none; text-align: right; font-size: 13px; }
.feed-when .abs { display: block; margin-left: 0; }
.feed-summary { margin: 0 0 6px; }
.critical-text { color: var(--critical-text); }
.feed.sales li.muted-row .feed-main { color: var(--ink-3); }
.sale-badge { flex: none; width: 128px; text-align: center; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--hover); color: var(--ink-3); }
.sale-badge.sold { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good-text); }
.sale-badge.failed { background: var(--critical-wash); color: var(--critical-text); }
.sale-amount { flex: none; width: 64px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.sel { font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 4px; background: var(--hover); color: var(--ink-2); margin-left: 4px; }

@media (max-width: 900px) {
  .d-cols { grid-template-columns: 1fr; }
  .d-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .drawer-head { padding: 14px 16px 12px; }
  .drawer-head h2 { font-size: 19px; }
  .drawer-body { padding: 14px 16px 28px; }
  .d-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sale-badge { width: auto; }
  .feed.sales li { flex-wrap: wrap; }
  .feed.sales .feed-main { flex-basis: calc(100% - 140px); }
}
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--ink-3); font-size: 12px; }
.kv dd { margin: 0 0 6px; font-variant-numeric: tabular-nums; }
.issue-box { border-radius: 8px; padding: 8px 12px; margin-bottom: 6px; }
.issue-box.critical { background: var(--critical-wash); }
.issue-box.warning { background: var(--warning-wash); }
.issue-box.unknown, .issue-box.inactive { background: var(--hover); }
.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.alerts .when { color: var(--ink-3); font-size: 12px; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 15; }

@media (max-width: 1000px) { .hide-md { display: none; } }
@media (max-width: 760px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .hide-sm { display: none; }
  main { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .issues li { white-space: normal; }
  .topbar { position: static; }
  .btn { white-space: nowrap; }
  #grid thead { display: none; }
  #grid, #grid tbody, #grid tr, #grid td { display: block; }
  #grid tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  #grid td { border: 0; padding: 2px 0; }
  #grid td.hide-sm, #grid td.hide-md { display: none; }
  #grid td[data-label]::before { content: attr(data-label) " "; color: var(--ink-3); }
}

/* Sign-in page */
.login-page { min-height: 100vh; display: flex; }
.login-wrap { margin: auto; width: 100%; max-width: 400px; padding: 24px 16px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px 26px; display: flex; flex-direction: column; gap: 10px; }
.login-brand img { height: 34px; }
.login-eyebrow { margin: 12px 0 0; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.14em; font-size: 11px; color: var(--accent); }
.login-card h1 { font-size: 28px; margin: 0; }
.login-card > p.muted { margin: 0 0 8px; }
.login-card label[for="password"] { font-weight: 600; font-size: 13px; }
.login-card input[type="password"] { padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); font-size: 16px; }
.login-card input[type="password"]:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.login-remember { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.login-remember input { width: 16px; height: 16px; accent-color: var(--primary); }
.login-btn { margin-top: 6px; padding: 10px 18px; font-size: 15px; }
.signout-btn { white-space: nowrap; }

/* Alert history: "Recently cleared" list and the machine panel's history */
.chip-n { display: inline-block; min-width: 1.4em; margin-left: 4px; padding: 0 6px; border-radius: 99px; background: var(--hover); color: var(--ink-2); font-size: 12px; text-align: center; }
.chip.active .chip-n { background: rgba(255, 255, 255, .25); color: inherit; }
.chip-n:empty { display: none; }
.cleared-table tbody tr { cursor: pointer; }
.cleared-table tbody tr:hover { background: var(--hover); }
.was { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.was.critical { color: var(--critical-text); }
.was.warning { color: var(--warning-text); }
.was.unknown { color: var(--ink-3); }
.why { font-size: 13px; color: var(--ink-2); }
.why.fixed { color: var(--good-text); }
.why.paused, .why.workshop, .why.closed { color: var(--ink-3); }
.why.check { color: var(--warning-text); font-weight: 600; }
.ah-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ah-list li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.ah-list li:first-child { border-top: 0; }
.ah-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: var(--line-strong); }
.ah-dot.critical { background: var(--critical); }
.ah-dot.warning { background: var(--warning); }
.ah-main { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.ah-list li.ongoing .ah-main strong::after { content: " · now"; color: var(--accent); font-weight: 600; }

/* Closed (out of season) */
.status.closed { color: var(--closed-text); }
.dot.closed { background: var(--closed); }
.cl-cell { color: var(--closed-text); white-space: nowrap; }
.cl-tag { border-color: var(--closed); color: var(--closed-text); }
.cl-box { background: var(--closed-wash); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1 1 300px; }
.cl-box label { font-size: 12px; color: var(--ink-2); }
.cl-box textarea, .cl-box input[type="date"] { width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); }
.cl-box.past { background: transparent; border: 1px dashed var(--line-strong); }
.cl-history { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); }
.cl-history li + li { margin-top: 2px; }

/* ===================== Revive brand layer =====================
   Type: Outfit for headings and big numbers, Source Sans 3 for text, IBM Plex Mono caps for small labels.
   Shape: cards 14, controls 10, small 6, pills for the main action and filters. Flat: depth comes from
   stepping surfaces, not shadows. Motion: a short colour fade, no bounce. */
body { font-family: var(--font-body); font-size: 15px; }
h1, h2, h3.card-title, .card h2, .drawer-head h2, .tile-value, .fact-value, .problem, .d-allclear { font-family: var(--font-head); }
h1 { font-weight: 600; letter-spacing: -0.01em; }
.card h2, .drawer-head h2 { font-weight: 600; }
.tile-value, .fact-value { font-weight: 600; }
.btn, .chip, .tile, a.btn, select, #search, .link-btn { transition: background-color .16s ease, border-color .16s ease, color .16s ease; }

/* header: Revive lockup, then the page name */
.topbar { background: var(--topbar); }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand img { height: 30px; width: auto; display: block; }
.brand .logo-on-dark { display: none; }
.brand-sep { width: 1px; height: 26px; background: var(--line-strong); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand .logo-on-light { display: none; }
  :root:not([data-theme="light"]) .brand .logo-on-dark { display: block; }
}
:root[data-theme="dark"] .brand .logo-on-light { display: none; }
:root[data-theme="dark"] .brand .logo-on-dark { display: block; }

/* small capital labels (the brand's "eyebrow") */
.tile-label, .fact-label, .drawer-body h3, th, .d-kv dt, .ch-head h3, .levels-label, .sb-codes legend {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 500;
}
.tile-label { color: var(--ink-3); }
th { color: var(--ink-3); }
th.sorted { color: var(--coral); } /* coral points: the column the list is sorted by */
.drawer-body h3 { color: var(--accent); }

/* buttons: squared outline by default, green pill for the main action */
.btn { border-radius: 10px; font-weight: 600; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); border-radius: 99px; padding-left: 18px; padding-right: 18px; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
#refresh { background: var(--primary); border-color: var(--primary); color: var(--on-primary); border-radius: 99px; padding-left: 16px; padding-right: 16px; }
#refresh:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.link-btn { color: var(--accent); font-weight: 600; }

/* filter chips: pills, green when active */
.chip { font-weight: 600; border-color: var(--line-strong); padding: 5px 14px; }
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
#search, select, .text-field, .set-input input[type="number"] { border-radius: 10px; }

/* cards and tiles */
.tile, .card, .panel, .d-card, .fact { border-radius: 14px; }
.tile.active { outline: 2px solid var(--primary); }
.tag, .sel { border-radius: 6px; }
.badge.live { color: var(--accent); border-color: var(--accent); font-family: var(--font-mono); letter-spacing: 0.1em; }

/* phones: logo and title on one line, the controls wrap underneath */
@media (max-width: 760px) {
  .brand img { height: 24px; }
  .brand-sep { height: 20px; }
  .title h1 { font-size: 16px; }
  .topbar-right { flex-wrap: wrap; width: 100%; gap: 8px; }
  .topbar-right #updated { flex: 1 1 100%; font-size: 12px; }
  .topbar-right #reqs { display: none; }
}
/* Machines / Vans switcher in the header (same in public/styles.css and public/vans/styles.css) */
.app-switch { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line-strong); border-radius: 99px; }
.app-switch a { padding: 5px 14px; border-radius: 99px; font-weight: 600; font-size: 15px; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.app-switch a:hover { background: var(--hover); color: var(--ink); }
.app-switch a { position: relative; isolation: isolate; }
.app-switch a[aria-current="page"] { color: var(--on-primary, #fff); }
.app-switch a[aria-current="page"]:hover { background: transparent; color: var(--on-primary, #fff); }
/* the green pill is its own element under the label, so it can slide between pages (motion.css) */
.app-switch .pill-bg { position: absolute; inset: 0; z-index: -1; border-radius: 99px; background: var(--primary); }
.app-switch .lbl { position: relative; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 760px) { .app-switch a { padding: 4px 10px; font-size: 14px; } }