:root {
  --ink: #10231d;
  --muted: #63736d;
  --paper: #f4f7f3;
  --panel: #ffffff;
  --line: #dbe4de;
  --green: #0e6b4f;
  --green-2: #1f9d70;
  --lime: #b7db79;
  --night: #e8efe9;
  --amber: #d98d1b;
  --red: #b94a48;
  --navy: #12302a;
  --shadow: 0 12px 32px rgba(20, 56, 45, .08);
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); font-family: "Segoe UI", Inter, system-ui, sans-serif; }
body { margin: 0; min-width: 320px; }
button, select, input { font: inherit; }
button { cursor: pointer; }

#app { width: min(1500px, calc(100% - 48px)); margin: 0 auto; padding: 42px 0 30px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 11px; line-height: 1.2; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1 { max-width: 900px; margin: 0; color: var(--navy); font-size: clamp(32px, 4vw, 58px); line-height: .98; letter-spacing: -.045em; }
.subtitle { max-width: 850px; margin: 16px 0 0; color: var(--muted); font-size: 16px; line-height: 1.55; }
.header-actions { display: flex; flex-shrink: 0; gap: 10px; }
button.primary, button.ghost { min-height: 44px; padding: 0 17px; border-radius: 8px; font-weight: 700; }
button.primary { border: 1px solid var(--navy); background: var(--navy); color: white; }
button.ghost { border: 1px solid #b9c9bf; background: transparent; color: var(--navy); }
button:hover { transform: translateY(-1px); }

.controls { display: grid; grid-template-columns: 1.15fr 1.35fr .62fr .62fr 1.35fr; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.72); box-shadow: var(--shadow); }
.controls label { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 8px; min-width: 0; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.controls select, .controls input[type="number"], .controls input[type="text"] { grid-column: 1 / -1; width: 100%; height: 38px; padding: 0 10px; border: 1px solid #cbd8d0; border-radius: 6px; background: white; color: var(--ink); font-size: 13px; font-weight: 600; }
.controls label > span { position: absolute; right: 10px; bottom: 11px; font-size: 12px; }
.controls .threshold { align-items: center; }
.threshold strong { color: var(--green); font-size: 13px; }
.threshold input { grid-column: 1 / -1; accent-color: var(--green); }

.decision-banner { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin: 14px 0; padding: 18px 22px; border-left: 5px solid var(--green); background: #e8f5ed; }
.decision-banner > div { display: flex; align-items: center; gap: 13px; }
.decision-banner small { display: block; margin-bottom: 3px; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.decision-banner strong { font-size: 19px; }
.decision-banner p { margin: 0; color: #3e5b51; font-size: 13px; text-align: right; }
.signal { width: 12px; height: 12px; border-radius: 50%; background: var(--green-2); box-shadow: 0 0 0 6px rgba(31,157,112,.16); }
.decision-banner.warn { border-color: var(--amber); background: #fff4df; }
.decision-banner.bad { border-color: var(--red); background: #fbe9e8; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 14px 0; }
.kpis article { min-height: 128px; padding: 20px; border-top: 3px solid var(--green); background: var(--panel); box-shadow: var(--shadow); }
.kpis span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.kpis strong { display: block; margin: 9px 0 7px; color: var(--navy); font-size: clamp(27px, 3vw, 40px); line-height: 1; letter-spacing: -.04em; }
.kpis small { color: #7a8983; font-size: 11px; }

.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }
.panel { margin: 14px 0; padding: 22px; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
.grid .panel { margin: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 12px; }
.panel h2 { margin: 0; color: var(--navy); font-size: 20px; line-height: 1.2; letter-spacing: -.02em; }
.panel-head p:not(.eyebrow) { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.legend, .meta { flex-shrink: 0; color: var(--muted); font-size: 11px; }
.legend::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 7px; border-radius: 2px; background: var(--night); vertical-align: -1px; }
.legend.line::before { height: 3px; background: var(--green); vertical-align: 3px; }
.chart { display: block; width: 100%; height: auto; min-height: 215px; overflow: visible; }
.chart text { fill: #7a8983; font-size: 10px; }
.chart .grid { stroke: #e5ece7; stroke-width: 1; }
.chart .night-band { fill: var(--night); opacity: .9; }
.chart .series-line { fill: none; stroke: var(--green); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart circle { fill: white; stroke: var(--green); stroke-width: 2; }

.heat-wrap { display: grid; grid-template-columns: 38px 1fr; grid-template-rows: 18px auto; gap: 5px 10px; margin-top: 20px; }
.heat-hours { display: grid; grid-template-columns: repeat(24, 1fr); color: var(--muted); font-size: 9px; text-align: center; }
.heat-days { display: grid; grid-template-rows: repeat(7, 20px); align-items: center; color: var(--muted); font-size: 10px; font-weight: 700; }
.heat-grid { display: grid; grid-template-columns: repeat(24, minmax(9px, 1fr)); grid-template-rows: repeat(7, 20px); gap: 3px; }
.heat-cell { border-radius: 2px; background: color-mix(in srgb, #e5ede7 calc((1 - var(--i)) * 100%), #0e6b4f calc(var(--i) * 100%)); }
.heat-cell.night { outline: 1px solid rgba(16,48,42,.25); outline-offset: -1px; }
.heat-legend { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 9px; }
.heat-legend i { width: 14px; height: 8px; background: #dce8df; }
.heat-legend i:nth-of-type(2) { background: #a9cdb8; }.heat-legend i:nth-of-type(3) { background: #60a883; }.heat-legend i:nth-of-type(4) { background: var(--green); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 10px 12px; border-bottom: 1px solid #bfcfc5; color: var(--muted); font-size: 10px; letter-spacing: .05em; text-align: right; text-transform: uppercase; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
td { padding: 13px 12px; border-bottom: 1px solid #e7ece9; text-align: right; vertical-align: middle; white-space: nowrap; }
tbody tr:hover { background: #f5f8f5; }
.vm-link { padding: 0; border: 0; background: transparent; color: var(--green); font-weight: 800; }
td small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.status { display: inline-block; padding: 5px 8px; border-radius: 99px; background: #edf1ee; color: var(--muted); font-size: 10px; font-weight: 800; }
.status.good { background: #daf1e4; color: #086044; }.status.warn { background: #fff0d1; color: #8a570b; }.status.bad { background: #f9dfdd; color: #8f3330; }

.evidence-grid { display: grid; grid-template-columns: .9fr 1.1fr; gap: 14px; margin-top: 14px; }
.telemetry > p:last-child { margin: 18px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.coverage { display: grid; gap: 12px; margin-top: 20px; }
.coverage span { display: grid; grid-template-columns: 105px 1fr 35px; align-items: center; gap: 10px; font-size: 11px; }
.coverage b { font-size: 11px; }.coverage em { color: var(--muted); font-style: normal; text-align: right; }
.coverage i { position: relative; height: 7px; overflow: hidden; border-radius: 9px; background: #e5ece7; }
.coverage i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--p); background: var(--green); }
.coverage .missing i::after { width: 5%; background: var(--amber); }
.action-plan ol { margin: 18px 0 0; padding-left: 23px; color: #496159; }
.action-plan li { padding: 5px 0 5px 7px; font-size: 12px; line-height: 1.45; }
.action-plan li::marker { color: var(--green); font-weight: 800; }

footer { display: flex; justify-content: space-between; gap: 30px; padding: 15px 2px 0; color: #7c8984; font-size: 10px; line-height: 1.45; }
footer p { max-width: 650px; margin: 0; }
.fatal { margin: 80px auto; padding: 30px; background: #fff0ee; color: #8f3330; }

@media (max-width: 1050px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .controls { grid-template-columns: repeat(3, 1fr); }
  .threshold { grid-column: span 2; }
  .grid.two, .evidence-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  #app { width: min(100% - 24px, 1500px); padding-top: 24px; }
  .controls { grid-template-columns: 1fr 1fr; }
  .controls label:first-child, .controls label:nth-child(2), .threshold { grid-column: 1 / -1; }
  .decision-banner, footer { align-items: flex-start; flex-direction: column; }
  .decision-banner p { text-align: left; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .panel { padding: 16px; }
  .panel-head { flex-direction: column; }
  .heat-grid { gap: 2px; }
}
@media (max-width: 460px) {
  .header-actions { width: 100%; }.header-actions button { flex: 1; }
  .kpis { grid-template-columns: 1fr; }
  h1 { font-size: 36px; }
}

@media print {
  :root { --paper: white; --shadow: none; }
  #app { width: 100%; padding: 0; }
  .controls, .header-actions { display: none; }
  .panel, .kpis article { break-inside: avoid; box-shadow: none; }
  .grid.two, .evidence-grid { grid-template-columns: 1fr 1fr; }
  footer { border-top: 1px solid var(--line); }
}
