/* TRUST Cockpit – dark theme. Status colours of Part 4 §7. */
:root {
  --ok: #1E9E5A;
  --warn: #E0A800;
  --crit: #D64545;
  --unknown: #8A8F98;
  --maint: #3B7DD8;
  --none: #2a2f38;
  --bg: #12151b;
  --panel: #1b1f27;
  --panel-2: #232833;
  --line: #313744;
  --text: #e6e8ec;
  --muted: #9aa1ad;
  --font: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: var(--font)/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body.kiosk { --font: 17.5px; }
body.kiosk #tabs, body.kiosk #user-menu { display: none; }
h1, h2, h3 { margin: 0 0 8px; font-weight: 600; }
h2 { font-size: 1.15em; }
h3 { font-size: 1em; color: var(--muted); }
a { color: #7fb0ff; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.big { font-size: 1.8em; font-weight: 600; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }

#header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
#header .brand { font-weight: 700; letter-spacing: 0.04em; }
#header .centre, #header .right { display: flex; align-items: center; gap: 14px; }
.pill { padding: 4px 14px; border-radius: 999px; font-weight: 700; color: #fff; }
.pill.green { background: var(--ok); }
.pill.yellow { background: var(--warn); color: #1b1b1b; }
.pill.red { background: var(--crit); }
.pill.grey { background: var(--unknown); }
.pill.blue { background: var(--maint); }

#banners .banner { padding: 8px 18px; font-weight: 600; }
.banner.blue { background: var(--maint); }
.banner.yellow { background: var(--warn); color: #1b1b1b; }
.banner.red { background: var(--crit); }

#tabs { display: flex; gap: 4px; padding: 8px 18px 0; border-bottom: 1px solid var(--line); }
#tabs a {
  padding: 8px 14px; color: var(--muted); text-decoration: none; border-radius: 6px 6px 0 0;
}
#tabs a.active { background: var(--panel-2); color: var(--text); }

main { padding: 18px; }
main.stale { filter: grayscale(1); }
section { margin-bottom: 22px; }

.btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 12px; cursor: pointer; font: inherit;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: #2d5fae; border-color: #2d5fae; }
input, select, textarea {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 8px; font: inherit;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }

/* status badge, strip */
.badge { display: inline-block; padding: 1px 8px; border-radius: 4px; font-weight: 600; font-size: 0.85em; white-space: nowrap; }
.badge.ok { background: var(--ok); color: #fff; }
.badge.warn { background: var(--warn); color: #1b1b1b; }
.badge.crit { background: var(--crit); color: #fff; }
.badge.unknown { background: var(--unknown); color: #fff; }
.badge.maint { background: var(--maint); color: #fff; }
.strip { display: flex; gap: 1px; height: 14px; margin: 6px 0; }
.strip span { flex: 1; border-radius: 1px; background: var(--none); }
.strip .ok, .strip .green { background: var(--ok); }
.strip .warn, .strip .yellow { background: var(--warn); }
.strip .crit, .strip .red { background: var(--crit); }
.strip .unknown, .strip .grey { background: var(--unknown); }
.strip .maint, .strip .blue { background: var(--maint); }

/* overview cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 12px 10px 18px; position: relative; cursor: pointer; overflow: hidden;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--unknown); }
.card.green::before { background: var(--ok); }
.card.yellow::before { background: var(--warn); }
.card.red::before { background: var(--crit); }
.card.grey::before { background: var(--unknown); }
.card.blue::before { background: var(--maint); }
.card .score { font-size: 2em; font-weight: 700; }
.card .line { margin: 2px 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.8em;
  background: var(--panel-2); border: 1px solid var(--line); margin-right: 6px; cursor: pointer;
}
.chip.active { border-color: var(--text); }
.chip.maintenance { background: var(--maint); border-color: var(--maint); }
.chip.P1 { background: var(--crit); border-color: var(--crit); }
.chip.P2 { background: var(--warn); border-color: var(--warn); color: #1b1b1b; }
.chip.P3 { background: var(--unknown); border-color: var(--unknown); }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--panel-2); }

/* solbox tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.tile {
  background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--unknown);
  border-radius: 8px; padding: 10px; cursor: pointer;
}
.tile.ok { border-top-color: var(--ok); }
.tile.warn { border-top-color: var(--warn); }
.tile.crit { border-top-color: var(--crit); }
.tile.maint { border-top-color: var(--maint); }
.tile .name { font-weight: 700; }
.dots { display: flex; gap: 8px; margin: 4px 0; }
.dot { display: inline-flex; align-items: center; gap: 3px; font-size: 0.8em; color: var(--muted); }
.dot::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--unknown); }
.dot.green::before { background: var(--ok); }
.dot.yellow::before { background: var(--warn); }
.dot.red::before { background: var(--crit); }

/* drawer, modal, toast */
#drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); z-index: 10;
  background: var(--panel); border-left: 1px solid var(--line); padding: 16px; overflow-y: auto;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.4);
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
dl.fields { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0 0 12px; }
dl.fields dt { color: var(--muted); }
dl.fields dd { margin: 0; word-break: break-word; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; overflow-x: auto; }
#modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 20;
  display: flex; align-items: center; justify-content: center;
}
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; width: min(560px, 95%); max-height: 90vh; overflow-y: auto; }
#toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 30; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 14px; }
.toast.error { border-color: var(--crit); }

/* chart colour classes */
.f-green, .f-ok { fill: var(--ok); }
.f-yellow, .f-warn { fill: var(--warn); }
.f-red, .f-crit { fill: var(--crit); }
.f-grey, .f-unknown { fill: var(--unknown); }
.f-blue, .f-maint { fill: var(--maint); }
.f-none { fill: var(--none); }
.s-green { stroke: var(--ok); }
.s-yellow { stroke: var(--warn); }
.s-red { stroke: var(--crit); }
.s-grey { stroke: var(--unknown); }
.s-blue { stroke: var(--maint); }
.f-bg-green { background: var(--ok); }
.f-bg-yellow { background: var(--warn); }
.f-bg-red { background: var(--crit); }
.f-bg-grey { background: var(--unknown); }
.f-bg-blue { background: var(--maint); }
.hidden-svg { visibility: hidden; }

/* hero row */
.hero { display: grid; grid-template-columns: 230px 1fr 230px; gap: 12px; }
@media (max-width: 1000px) { .hero { grid-template-columns: 1fr 1fr; } .hero-trend { grid-column: 1 / -1; order: 3; } }
@media (max-width: 640px) { .hero { grid-template-columns: 1fr; } }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.toolbar.tight { margin: 0; gap: 4px; }
.center { text-align: center; }
.warn-text { color: var(--warn); margin: 2px 0 6px; }
.gauge, .donut { display: block; width: 100%; max-width: 170px; margin: 0 auto; }
.gauge-track { fill: none; stroke: var(--panel-2); stroke-width: 12; }
.gauge-arc { fill: none; stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 1.2s cubic-bezier(.2, .8, .2, 1); }
.gauge-arc.s-green { filter: drop-shadow(0 0 6px rgba(30, 158, 90, .55)); }
.gauge-arc.s-red { filter: drop-shadow(0 0 6px rgba(214, 69, 69, .6)); }
.gauge-score { fill: var(--text); font-size: 34px; font-weight: 700; }
.gauge-score.small-score { font-size: 28px; }
.gauge-word { fill: var(--muted); font-size: 11px; letter-spacing: .12em; }
.donut-track { stroke-width: 16; }
.donut-slice { fill: none; stroke-width: 16; cursor: pointer; transition: stroke-width .15s; }
.donut-slice:hover { stroke-width: 20; }
.legend { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.legend.inline { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.legend-row { display: flex; justify-content: space-between; cursor: pointer; padding: 1px 4px; border-radius: 4px; }
.legend-row:hover { background: var(--panel-2); }
.legend-count { font-weight: 600; }
.avail-bars { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.avail-row { display: grid; grid-template-columns: 34px 1fr 64px; align-items: center; gap: 6px; }
.avail-track { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.avail-fill { display: block; height: 100%; background: var(--ok); border-radius: 3px; transition: width 1s; }
.avail-fill.mid { background: var(--warn); }
.avail-fill.low { background: var(--crit); }
.trend { display: block; width: 100%; height: auto; }
.chart-placeholder { height: 190px; display: flex; align-items: center; justify-content: center; }
.band-green { fill: rgba(30, 158, 90, .06); }
.band-yellow { fill: rgba(224, 168, 0, .06); }
.band-red { fill: rgba(214, 69, 69, .07); }
.grid { stroke: var(--line); stroke-dasharray: 3 4; }
.axis { fill: var(--muted); font-size: 10px; }
.trend-area { fill: rgba(127, 176, 255, .16); }
.trend-line { fill: none; stroke-width: 1.4; stroke-linejoin: round; opacity: .85; }
.trend-line.main { stroke: #7fb0ff; stroke-width: 2.2; opacity: 1; }
.trend-line.o0 { stroke: #e07bd1; } .trend-line.o1 { stroke: #f0b35a; } .trend-line.o2 { stroke: #5ad1c4; }
.trend-line.o3 { stroke: #c9e05a; } .trend-line.o4 { stroke: #ff8f7a; } .trend-line.o5 { stroke: #a99cff; }
.trend-line.o6 { stroke: #8fd18a; }
.crosshair { stroke: var(--muted); stroke-dasharray: 2 3; }
.cross-dot { fill: #7fb0ff; stroke: var(--bg); stroke-width: 2; }
.cross-label { fill: var(--text); font-size: 11px; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; }
.overlay { fill: transparent; cursor: crosshair; }
.overlay-chip.active { background: #2d5fae; border-color: #2d5fae; }

/* cards: sparkline */
.card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.card .word { font-size: .8em; letter-spacing: .08em; color: var(--muted); }
.card.red { animation: redglow 2.4s ease-in-out infinite; }
@keyframes redglow { 50% { box-shadow: 0 0 0 1px var(--crit), 0 0 18px rgba(214, 69, 69, .35); } }
.spark { display: block; width: 100%; height: 34px; margin: 4px 0; }
.spark-area { opacity: .18; }
.spark-line { fill: none; stroke-width: 1.6; vector-effect: non-scaling-stroke; }

/* attention list */
.attention-row { display: grid; grid-template-columns: auto minmax(90px, max-content) 1fr auto; gap: 8px; align-items: center; padding: 4px; border-radius: 4px; cursor: pointer; }
.attention-row:hover { background: var(--panel-2); }
.attention-name { font-weight: 600; }
.right-text { text-align: right; }
.calm { color: var(--ok); padding: 18px 0; font-weight: 600; }

/* header pulse */
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); position: relative; }
.pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--ok); animation: pulse 2s ease-out infinite; }
.pulse.alarm, .pulse.alarm::after { background: var(--crit); border-color: var(--crit); }
.pulse.dead, .pulse.dead::after { background: var(--unknown); border-color: var(--unknown); animation: none; }
@keyframes pulse { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.8); opacity: 0; } }

/* solboxes: fleet bar, segmented switch, heatmap */
.fleet { margin-bottom: 12px; }
.fleet-head { margin-bottom: 6px; }
.stackbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--panel-2); gap: 2px; }
.stackbar span { flex-basis: 0; min-width: 4px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin-left: auto; }
.seg { background: transparent; border: 0; color: var(--muted); padding: 5px 12px; cursor: pointer; font: inherit; }
.seg.active { background: var(--panel-2); color: var(--text); }
.timeline { overflow-x: auto; }
.heatmap { display: block; width: 100%; min-width: 760px; height: auto; }
.heat-row { cursor: pointer; }
.heat-row:hover .heat-label { fill: #7fb0ff; }
.heat-label { fill: var(--text); font-size: 11px; }
.heat-cell { transition: opacity .1s; }
.heat-row:hover .heat-cell { opacity: .85; }
.heat-cell:hover { stroke: var(--text); stroke-width: 1; }
@media (prefers-reduced-motion: reduce) {
  .gauge-arc, .avail-fill { transition: none; }
  .card.red, .pulse::after { animation: none; }
}

/* login */
.login { max-width: 340px; margin: 60px auto; display: flex; flex-direction: column; gap: 10px; }
.error-text { color: var(--crit); }
