:root {
  color-scheme: light;
  --bg: #f4f3f0;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e4e2dc;
  --grid: #e9e7e1;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #85837d;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --band: rgba(27, 175, 122, 0.10);
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --accent: #2a78d6;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121211;
    --surface-1: #1a1a19;
    --surface-2: #242422;
    --border: #30302d;
    --grid: #2a2a27;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e86;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --band: rgba(25, 158, 112, 0.16);
    --accent: #3987e5;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, system-ui, sans-serif; background: var(--bg); color: var(--text-primary); }
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface-1); border-right: 1px solid var(--border); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 20px; }
.brand small { display: block; color: var(--text-muted); font-size: 12px; }
.logo { width: 34px; height: 34px; border-radius: 9px; }
nav a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 9px; color: var(--text-secondary); cursor: pointer; user-select: none; }
nav a span { width: 18px; text-align: center; opacity: .8; }
nav a:hover { background: var(--surface-2); }
nav a.active { background: var(--surface-2); color: var(--text-primary); font-weight: 600; }
.side-foot { margin-top: auto; font-size: 12px; color: var(--text-muted); display: grid; gap: 6px; padding: 8px; }
.src-line { display: flex; gap: 8px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
main { padding: 28px 36px 60px; max-width: 1280px; min-width: 0; }
h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
.sub { color: var(--text-secondary); margin: 0 0 22px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 40; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border); flex-direction: row; }
  .side .brand, .side .side-foot { display: none; }
  nav { display: flex; width: 100%; justify-content: space-around; }
  nav a { flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 4px; flex: 1; text-align: center; }
  nav a span { font-size: 17px; width: auto; }
  nav a.active { background: transparent; color: var(--accent); }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  main { padding: calc(16px + env(safe-area-inset-top)) 16px 96px; }
  h1 { font-size: 24px; }
  .tile-value { font-size: 28px; }
  .src { grid-template-columns: 40px 1fr; }
  .src > :last-child { grid-column: 1 / -1; }
  table { font-size: 12px; }
}
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card.click { cursor: pointer; transition: border-color .15s; }
.card.click:hover { border-color: var(--text-muted); }
.section { margin-top: 28px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--text-muted); }
.sec { color: var(--text-secondary); }
.small { font-size: 12px; }

/* stat tile */
.tile-label { color: var(--text-secondary); font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }
.tile-value { font-size: 32px; font-weight: 650; letter-spacing: -0.02em; margin: 6px 0 0; font-variant-numeric: tabular-nums; }
.tile-value small { font-size: 13px; font-weight: 500; color: var(--text-muted); margin-left: 4px; }
.tile-meta { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.delta { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* status pill */
.pill { display: inline-flex; gap: 5px; align-items: center; font-size: 11.5px; font-weight: 600; padding: 2px 8px 2px 6px; border-radius: 999px; background: var(--surface-2); color: var(--text-primary); white-space: nowrap; }
.pill i { font-style: normal; font-size: 10px; }

/* status strip */
.strip { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; margin: 10px 0 8px; }
.strip > div { height: 100%; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); }
.legend span { display: inline-flex; gap: 6px; align-items: center; }

/* signals */
.signal { display: grid; grid-template-columns: 34px 1fr; gap: 12px; }
.signal .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); font-size: 15px; }
.signal b { display: block; margin-bottom: 2px; }
.signal p { margin: 0; color: var(--text-secondary); font-size: 13px; }

/* chips / buttons / forms */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); padding: 6px 12px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 13px; }
.chip.on { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }
.btn { border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); padding: 8px 14px; border-radius: 9px; cursor: pointer; font: inherit; font-weight: 550; }
.btn:hover { border-color: var(--text-muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-secondary); padding: 4px 8px; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; align-items: end; }
.form label { display: grid; gap: 4px; font-size: 12px; color: var(--text-secondary); }
input, select, textarea { font: inherit; color: var(--text-primary); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { resize: vertical; min-height: 38px; }

/* progress */
.bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; background: var(--series-1); border-radius: 4px; }

/* table */
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 550; font-size: 12px; }
td.num, th.num { text-align: right; }
details summary { cursor: pointer; color: var(--text-secondary); font-size: 13px; margin-top: 10px; }

/* charts */
.chart { width: 100%; display: block; }
.chart text { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gl { stroke: var(--grid); stroke-width: 1; }
.chart .band { fill: var(--band); }
.chart .bandline { stroke: var(--series-3); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.chart .goal { stroke: var(--text-secondary); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .cross { stroke: var(--text-muted); stroke-width: 1; }
.tip { position: fixed; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border); box-shadow: 0 6px 24px rgba(0,0,0,.12); border-radius: 10px; padding: 8px 10px; font-size: 12px; z-index: 50; min-width: 120px; }
.tip b { font-size: 14px; }

/* timeline */
.tl { position: relative; padding-left: 26px; }
.tl::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 18px; }
.tl-item::before { content: ""; position: absolute; left: -23px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface-1); border: 2px solid var(--series-1); }
.tl-item.done::before { background: var(--series-1); }
.tl-item.done .tl-title { text-decoration: line-through; color: var(--text-muted); }
.tl-date { font-size: 12px; color: var(--text-muted); }
.ring { display: block; }
.empty { border: 1px dashed var(--border); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--text-muted); }
.src { display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center; }
.src .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; font-size: 20px; }
.note { font-size: 12px; color: var(--text-muted); margin-top: 24px; }

/* ask */
.chat { display: grid; gap: 12px; min-height: 160px; }
.msg-user { justify-self: end; max-width: 85%; background: var(--accent); color: #fff; padding: 9px 13px; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; }
.msg-assistant { max-width: 92%; background: var(--surface-2); padding: 10px 14px; border-radius: 16px 16px 16px 4px; }
.msg-assistant p { margin: 0 0 8px; } .msg-assistant p:last-child { margin: 0; }
.msg-assistant ul { margin: 4px 0 8px; padding-left: 18px; }
.chip { text-align: left; }
.medrow { padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
code { font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; word-break: break-all; }
@media (max-width: 760px) {
  nav { overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  nav a { flex: 0 0 auto; min-width: 62px; }
}
