/* Command-center theme: light warm canvas, charcoal instrument panels.
   Two colour contexts share the same variable names: the canvas (:root) and the dark panels (.panel-ctx list below),
   so every component reads var(--ink), var(--border)… and looks right wherever it is placed. */
:root {
  --page: #E7E3D8; --ink: #1A1B18; --ink-2: #3F413A; --muted: #5C5F54; --border: #CBC6B7; --border-strong: #8F8A7B;
  --surface: #1B1D19; --surface-2: rgba(26, 27, 24, .08); --field-bg: #F6F4EE; --field-border: #A9A392;
  --primary-bg: #1A1B18; --primary-ink: #F3F1EA; --critical-text: #B3261E; --good-text: #1B6E3C;
  --critical: #FF6B57; --serious: #F59A4A; --warning: #F5C244; --good: #5FD38D; --info: #6FB2FF;
  --grid: #2A2D26; --axis: #4A4F43; --series: #E9E6DC; --radius: 12px; --rail: 64px;
  --sans: "Onest", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.card, .rail, .topbar, .banner, .msg, .menu, .sheet, .tile, .toast, .tooltip {
  --ink: #F3F1EA; --ink-2: #D5D3C9; --muted: #A7AA9D; --border: #34382F; --border-strong: #4A4F43;
  --surface-2: #262922; --field-bg: #262922; --field-border: #4A4F43; --primary-bg: #F3F1EA; --primary-ink: #0F100E;
  --critical-text: #FF6B57; --good-text: #5FD38D; color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--page); color: var(--ink); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 12.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
h3 { font-size: 13px; margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0 0 18px; max-width: 860px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---- shell: icon rail + command bar */
.rail { position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: var(--rail); background: var(--surface); border-right: 1px solid var(--border);
  padding: 10px; display: flex; flex-direction: column; gap: 4px; overflow: hidden; transition: width .14s ease; }
.rail:hover, .rail.open { width: 236px; box-shadow: 8px 0 28px rgba(0, 0, 0, .22); }
.rail a, .rail button.rail-btn { height: 44px; min-width: 44px; padding: 0 12px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 10px; background: transparent;
  color: var(--muted); text-decoration: none; white-space: nowrap; font: inherit; cursor: pointer; position: relative; }
.rail a:hover, .rail button.rail-btn:hover { background: var(--surface-2); color: var(--ink); }
.rail a.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.rail .lbl { opacity: 0; transition: opacity .1s; } .rail:hover .lbl, .rail.open .lbl { opacity: 1; }
.rail .pip { position: absolute; left: 30px; top: 8px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--critical); color: #0F100E; font-size: 10.5px; font-weight: 700; line-height: 16px; text-align: center; }
.rail .grow { flex: 1; }
.scrim { display: none; position: fixed; inset: 0; z-index: 35; background: rgba(26, 27, 24, .45); }
.topbar { position: sticky; top: 0; z-index: 30; margin-left: var(--rail); height: 60px; padding: 0 20px; display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .ws { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; white-space: nowrap; }
.topbar .ws i { width: 24px; height: 24px; border-radius: 6px; background: #F3F1EA; color: #0F100E; display: inline-flex; align-items: center; justify-content: center; font-style: normal; font-size: 12px; font-weight: 700; }
.topbar .crumb { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .grow { flex: 1; }
.cmd { position: relative; width: min(440px, 36vw); }
.cmd form { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; background: var(--field-bg); border: 1px solid var(--border); border-radius: 8px; color: var(--muted); }
.cmd input { border: 0; background: transparent; padding: 0; outline: 0; height: 38px; }
.cmd kbd { font: 11px var(--mono); padding: 2px 6px; border: 1px solid var(--border-strong); border-radius: 5px; white-space: nowrap; }
.menu { position: absolute; z-index: 50; top: 46px; right: 0; min-width: 300px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; padding: 6px; box-shadow: 0 14px 40px rgba(0, 0, 0, .35); }
.cmd .menu { left: 0; right: 0; }
.menu a, .menu button { width: 100%; min-height: 42px; white-space: nowrap; padding: 0 12px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); text-decoration: none; text-align: left; font: inherit; cursor: pointer; }
.menu a:hover, .menu button:hover, .menu .first { background: var(--surface-2); }
.menu .kind { margin-left: auto; font: 11px var(--mono); color: var(--muted); }
.menu .who { padding: 8px 12px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; color: var(--muted); font-size: 12.5px; } .menu .who b { color: var(--ink); font-size: 14px; }
.pop { position: relative; } .pop > button { white-space: nowrap; }
.chip-date { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; white-space: nowrap; color: var(--ink-2); }
.iconbtn { text-decoration: none; position: relative; width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.iconbtn .dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--critical); }
.avatar { width: 38px; height: 38px; padding: 0; border-radius: 50%; font-weight: 600; background: var(--surface-2); }
.burger { display: none; }
main { margin-left: var(--rail); padding: 20px 24px 72px; min-width: 0; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.modtabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 16px; }
.modtabs a { height: 36px; padding: 0 14px; display: inline-flex; align-items: center; gap: 8px; border-radius: 8px; text-decoration: none; color: var(--muted); }
.modtabs a:hover { background: var(--surface-2); color: var(--ink); }
.modtabs a.active { background: var(--surface); color: #F3F1EA; font-weight: 600; }
.modtabs .n { font: 11px var(--mono); padding: 1px 6px; border-radius: 8px; background: var(--critical); color: #0F100E; font-weight: 700; }

/* ---- building blocks */
.grid { display: grid; gap: 12px; } .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.section { margin-top: 12px; }
.kpi .label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 8px; }
.kpi .label::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--good); flex: none; }
.kpi.is-bad .label::before { background: var(--critical); }
.kpi .value { font: 500 21px/1.3 var(--mono); letter-spacing: -.02em; margin: 6px 0 2px; word-break: break-word; }
.kpi .delta { font-size: 12.5px; color: var(--muted); } .kpi .delta.bad { color: var(--critical-text); } .kpi .delta.good { color: var(--good-text); }
.banner { border-radius: var(--radius); padding: 14px 18px; margin-bottom: 12px; border: 1px solid var(--border); background: var(--surface); display: flex; gap: 12px; align-items: center; }
.banner::before { content: ""; width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--good); }
.banner.critical::before { background: var(--critical); } .banner.attention::before { background: var(--warning); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.badge.critical, .badge.failed, .badge.blocked, .badge.rejected, .badge.down, .badge.revoked, .badge.denied, .badge.error { background: #3A1815; color: #FF6B57; }
.badge.high, .badge.degraded, .badge.expired { background: #3A2412; color: #F59A4A; }
.badge.medium, .badge.pending, .badge.pending_approval, .badge.acked, .badge.partial { background: #3A2E10; color: #F5C244; }
.badge.low, .badge.info, .badge.unknown { background: #13283D; color: #6FB2FF; }
.badge.ok, .badge.executed, .badge.approved, .badge.resolved, .badge.done { background: #123222; color: #5FD38D; }
.badge.critical::before, .badge.failed::before, .badge.blocked::before, .badge.rejected::before, .badge.down::before, .badge.revoked::before, .badge.denied::before, .badge.error::before,
.badge.high::before, .badge.degraded::before, .badge.expired::before, .badge.medium::before, .badge.pending::before, .badge.pending_approval::before, .badge.acked::before, .badge.partial::before,
.badge.low::before, .badge.info::before, .badge.unknown::before, .badge.ok::before, .badge.executed::before, .badge.approved::before, .badge.resolved::before, .badge.done::before { background: currentColor; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; } tr:last-child td { border-bottom: 0; }
td.right { font-family: var(--mono); font-size: 13px; }
.table-wrap { overflow-x: auto; }

button, .btn { font: 500 14px var(--sans); min-height: 38px; border: 1px solid var(--border-strong); background: transparent; color: var(--ink); padding: 0 14px; border-radius: 8px; cursor: pointer; }
button:hover { background: var(--surface-2); } button:disabled { opacity: .5; cursor: default; }
button.primary, button.approve { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-ink); font-weight: 600; }
button.primary:hover, button.approve:hover { opacity: .9; background: var(--primary-bg); }
button.danger { color: var(--critical-text); }
button.small { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
button.big { min-height: 46px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--field-bg); border: 1px solid var(--field-border); border-radius: 8px; padding: 8px 11px; width: 100%; min-height: 38px; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; accent-color: #F3F1EA; }
label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }
.tabs { display: flex; gap: 4px; margin: 0 0 12px; flex-wrap: wrap; }
.tabs button { border-color: transparent; color: var(--muted); min-height: 36px; }
.tabs button.active { background: var(--surface); color: #F3F1EA; font-weight: 600; }

.chart { position: relative; } .chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.chart-title b { font-size: 13.5px; } .chart-title span { color: var(--muted); font: 12.5px var(--mono); }
.tooltip { position: fixed; z-index: 70; pointer-events: none; background: #0F100E; padding: 5px 9px; border-radius: 6px; font-size: 12px; white-space: nowrap; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 80; background: #0F100E; border: 1px solid #4A4F43; padding: 12px 16px; border-radius: 10px; max-width: 420px; }

.conf { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } .conf-bar { flex: none; width: 90px; height: 6px; background: var(--grid); border-radius: 3px; overflow: hidden; }
.conf-bar i { display: block; height: 100%; background: var(--good); border-radius: 3px; }
.chain { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; } .chain span { background: var(--surface-2); border-radius: 6px; padding: 2px 8px; font-size: 12.5px; } .chain em { color: var(--muted); font-style: normal; }
ul.ev { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); } ul.ev li { margin: 2px 0; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; font-size: 13.5px; margin: 0; } .kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
pre.params { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font: 12px var(--mono); overflow-x: auto; margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; }

.chat { display: flex; flex-direction: column; gap: 10px; min-height: 300px; }
.msg { max-width: 820px; padding: 12px 16px; border-radius: 12px 12px 12px 4px; border: 1px solid var(--border); background: var(--surface); }
.msg.user { align-self: flex-end; border-radius: 12px 12px 4px 12px; background: #F3F1EA; border-color: #CBC6B7; --ink: #0F100E; color: #0F100E; }
.msg p { margin: 0 0 6px; } .msg p:last-child { margin: 0; }
.chatbar { display: flex; gap: 8px; margin-top: 12px; position: sticky; bottom: 12px; } .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chips button { font-size: 13px; border-radius: 999px; min-height: 34px; }
.md h1 { font-size: 18px; margin: 0 0 8px; } .md h2 { margin: 16px 0 6px; padding-top: 12px; border-top: 1px solid var(--border); } .md ul, .md ol { margin: 4px 0; padding-left: 20px; } .md p { margin: 4px 0; }
.login { max-width: 380px; margin: 12vh auto; padding: 28px; } .login h1 { font-size: 20px; } .error { color: var(--critical-text); margin-top: 10px; font-size: 13px; }

/* ---- command center (home) */
.cc { display: grid; grid-template-columns: minmax(0, 1fr) 368px; grid-template-rows: auto 1fr; gap: 12px; align-items: start; }
.cc-head { grid-column: 1; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.cc-head h1 { font-size: 30px; margin: 6px 0 0; } .cc-head .meta { color: var(--muted); font-size: 13px; }
.cc-head .counts { display: flex; gap: 18px; color: var(--muted); font-size: 13px; } .cc-head .counts b { font: 600 13px var(--mono); color: var(--ink); }
.cc-main { grid-column: 1; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.cc-right { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 72px; }
.state { display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px; border-radius: 6px; font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.state.critical { background: #FBE3DF; color: #B3261E; } .state.attention { background: #FAEAC0; color: #8A5A00; } .state.ok { background: #DCF0E2; color: #1B6E3C; }
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tile .l { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.tile .l i, .dotc { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--muted); }
.tile .v { font: 500 23px/1.2 var(--mono); letter-spacing: -.02em; word-break: break-word; } .tile .n { font-size: 12.5px; font-weight: 500; }
.t-bad { --tone: var(--critical); } .t-warn { --tone: var(--warning); } .t-good { --tone: var(--good); } .t-info { --tone: var(--info); }
.tile .l i, .tile .n, .dotc { background-color: var(--tone, var(--muted)); } .tile .n { background: none; color: var(--tone, var(--muted)); }
.insights { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.insight { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.insight .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; } .insight .dom { font: 12px var(--mono); color: var(--muted); text-transform: uppercase; }
.insight h3 { font-size: 18px; line-height: 1.25; letter-spacing: -.01em; margin: 0; }
.wwd { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 8px 10px; font-size: 13.5px; margin: 0; } .wwd dt { color: var(--muted); } .wwd dd { margin: 0; } .wwd dd.do { font-weight: 600; }
.insight .acts { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.panel { padding: 0; display: flex; flex-direction: column; }
.panel > header { height: 46px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--border); }
.panel > header h2 { margin: 0; } .panel > header a { font-size: 12.5px; font-weight: 600; }
.rec { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.rec dl { margin: 0; display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; } .rec dt { font-size: 12px; color: var(--muted); } .rec dd { margin: 0; } .rec dd.b { font-weight: 600; }
.meter { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); } .meter div:first-child { display: flex; justify-content: space-between; } .meter b { font: 500 12px var(--mono); color: var(--ink); }
.meter .bar { height: 6px; border-radius: 3px; background: var(--grid); } .meter .bar i { display: block; height: 6px; border-radius: 3px; background: var(--good); }
.two { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
.arow { display: flex; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--border); text-decoration: none; } .arow:last-child { border-bottom: 0; } .arow:hover { background: var(--surface-2); }
.arow .dotc { margin-top: 6px; } .arow .t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; } .arow .t b { font-size: 13.5px; line-height: 1.35; } .arow .t span, .arow .d { font-size: 12.5px; color: var(--muted); }
.tl { display: flex; } .tl > div { flex: 1 1 0; min-width: 0; padding: 12px 14px; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 5px; } .tl > div:last-child { border-right: 0; }
.tl .when { display: flex; align-items: center; gap: 8px; font: 12px var(--mono); color: var(--muted); } .tl b { font-size: 13px; line-height: 1.35; } .tl span.d { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

/* ---- phone: drawer navigation, alerts first, assistant as a bottom sheet */
.fab, .sheet { display: none; }
@media (max-width: 1240px) { .insights { grid-template-columns: 1fr; } .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .rail { width: 272px; transform: translateX(-100%); transition: transform .16s ease; } .rail:hover { width: 272px; box-shadow: none; }
  .rail.open { transform: none; width: 272px; } .rail .lbl { opacity: 1; } .rail.open + .scrim { display: block; }
  .topbar { margin-left: 0; padding: 0 8px; gap: 4px; height: 56px; } .burger { display: inline-flex; border: 0; }
  .topbar .ws, .cmd, .chip-date, .quick { display: none; } .topbar .crumb { color: var(--ink); font-weight: 700; font-size: 15px; } .iconbtn { border: 0; width: 44px; height: 44px; }
  main { margin-left: 0; padding: 14px 14px 96px; } h1 { font-size: 22px; } .cc-head h1 { font-size: 22px; }
  .g2, .g3, .kv { grid-template-columns: 1fr; }
  .cc { display: flex; flex-direction: column; } .cc-right { position: static; order: 1; } .cc-main { order: 2; } .cc-right .panel.alerts { order: -1; }
  .tiles { grid-template-columns: 1fr; gap: 8px; } .tile { flex-direction: row; align-items: center; gap: 12px; padding: 12px 14px; } .tile .l { flex: 1; } .tile .v { font-size: 20px; order: 3; } .tile .n { order: 2; }
  .tl { flex-direction: column; } .tl > div { border-right: 0; border-bottom: 1px solid var(--border); }
  button { min-height: 44px; } button.small { min-height: 36px; } .two button { min-height: 52px; }
  .fab { display: inline-flex; align-items: center; gap: 10px; position: fixed; right: 16px; bottom: 18px; z-index: 28; height: 56px; padding: 0 20px; border-radius: 999px; border: 0;
    background: #1A1B18; color: #F3F1EA; font-weight: 600; font-size: 15px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); }
  .sheet.open { display: flex; flex-direction: column; gap: 12px; position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; max-height: 86vh; overflow-y: auto; padding: 10px 16px 20px;
    background: var(--surface); border-top: 1px solid var(--border-strong); border-radius: 18px 18px 0 0; }
  .sheet .grab { align-self: center; width: 44px; height: 5px; border-radius: 3px; background: var(--border-strong); border: 0; min-height: 5px; padding: 0; }
  .sheet.open ~ .scrim2 { display: block; } .sheet .rec { padding: 0; }
}
.scrim2 { display: none; position: fixed; inset: 0; z-index: 55; background: rgba(26, 27, 24, .5); }
