:root {
  --bg: #0f1420;
  --card: #1b2537;
  --card2: #212d43;
  --line: #2a3550;
  --txt: #e7ecf5;
  --muted: #93a1bd;
  --accent: #4f8cff;
  --good: #2fbf71;
  --warn: #f2a53a;
  --bad: #e5544b;
  --chip: #24304a;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--txt); font-size: 14px; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* Gate */
.gate { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1c2740, var(--bg)); }
.gate-card { width: 320px; max-width: 90vw; padding: 32px 26px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.45); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.gate-logo { font-size: 20px; font-weight: 700; }
.gate-sub { color: var(--muted); margin: 0 0 6px; font-size: 13px; }
.gate-input { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  color: var(--txt); font-size: 18px; text-align: center; letter-spacing: 4px; }
.gate-input:focus { outline: none; border-color: var(--accent); }
.gate-btn { padding: 12px 14px; border: 0; border-radius: 10px; cursor: pointer; background: var(--accent); color: #fff; font-weight: 600; font-size: 15px; }
.gate-btn:hover { filter: brightness(1.08); }
.gate-err { color: var(--bad); font-size: 13px; min-height: 16px; }

/* Shell */
.app { max-width: 860px; margin: 0 auto; padding: 20px 18px 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.topbar h1 { margin: 0; font-size: 22px; font-weight: 700; }
.topbar-sub { color: var(--muted); font-size: 13px; }
.topbar-r { display: flex; align-items: center; gap: 8px; }
.updated { color: var(--muted); font-size: 12px; margin-right: 4px; }
.btn-ghost { width: 34px; height: 34px; border-radius: 9px; cursor: pointer; background: var(--chip); border: 1px solid var(--line); color: var(--txt); font-size: 15px; }
.btn-ghost:hover { border-color: var(--accent); }

/* Hero */
.hero { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 12px; margin-bottom: 22px; }
.hero-main { grid-column: 1 / 2; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.hero-main .h-lbl { color: var(--muted); font-size: 12px; margin: 0 0 4px; }
.hero-main .h-big { font-size: 46px; font-weight: 700; line-height: 1.05; letter-spacing: .5px; font-variant-numeric: tabular-nums; }
.hero-main .h-delta { font-size: 14px; margin-left: 8px; }
.hero-main .h-cap { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.hero-main .spark { margin-top: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; justify-content: center; }
.kpi .k-lbl { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.kpi .k-val { font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .k-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.pos { color: var(--good); } .neg { color: var(--bad); } .amb { color: var(--warn); }

/* Blocks */
.block { margin-bottom: 22px; }
.block-h { font-size: 15px; font-weight: 650; margin-bottom: 12px; }
.block-note { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 6px; }
.mini-note { color: var(--muted); font-size: 12px; margin-top: 10px; line-height: 1.5; }

/* Action cards */
.act { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-left: 3px solid var(--muted); border-radius: 0 10px 10px 0; padding: 12px 14px; margin-bottom: 8px; }
.act .a-ic { font-size: 18px; width: 22px; text-align: center; }
.act .a-body { min-width: 0; }
.act .a-title { font-weight: 600; }
.act .a-why { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.act .a-big { margin-left: auto; font-size: 18px; font-weight: 700; white-space: nowrap; text-align: right; padding-left: 8px; font-variant-numeric: tabular-nums; }
.act.bad { border-left-color: var(--bad); } .act.warn { border-left-color: var(--warn); }
.act.good { border-left-color: var(--good); } .act.accent { border-left-color: var(--accent); }
.a-prog { height: 6px; border-radius: 4px; background: var(--chip); margin-top: 7px; overflow: hidden; }
.a-prog > span { display: block; height: 100%; background: var(--bad); border-radius: 4px; }

/* Aging heatmap */
.aging { display: grid; grid-template-columns: 74px repeat(3, 1fr); gap: 5px; }
.aging .hc { border-radius: 7px; padding: 12px 4px; text-align: center; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.aging .hlab { color: var(--muted); font-size: 12px; display: flex; align-items: center; }
.aging .hlab.col { justify-content: center; padding-bottom: 2px; }

/* Recovery */
.recovery { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rec-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.rec-h { font-size: 13px; font-weight: 600; margin: 0 0 10px; }
.rec-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 13.5px; }
.rec-row .r-name { width: 96px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-row .r-track { flex: 1; height: 7px; border-radius: 4px; background: var(--chip); }
.rec-row .r-fill { height: 7px; border-radius: 4px; }
.rec-row .r-val { width: 36px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.rec-note { color: var(--muted); font-size: 12px; margin: 8px 0 0; line-height: 1.4; }

/* Details / truck table */
.details summary { cursor: pointer; font-weight: 650; font-size: 15px; padding: 6px 0; list-style: none; }
.details summary::-webkit-details-marker { display: none; }
.details summary::before { content: "▸  "; color: var(--muted); }
.details[open] summary::before { content: "▾  "; }
.table-wrap { overflow-x: auto; margin-top: 10px; }
.tabla { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tabla th, .tabla td { padding: 7px 9px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.tabla th { color: var(--muted); font-weight: 600; font-size: 12px; cursor: pointer; }
.tabla th:first-child, .tabla td:first-child { text-align: left; }
.tabla tr.total-row td { font-weight: 700; border-top: 2px solid var(--line); background: var(--card); }

.foot { color: var(--muted); font-size: 12px; margin-top: 8px; line-height: 1.5; }
.loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); color: var(--muted); z-index: 40; }

@media (max-width: 680px) {
  .hero { grid-template-columns: 1fr 1fr; }
  .hero-main { grid-column: 1 / 3; }
  .recovery { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 19px; }
}
