@font-face { font-family: "Plex Sans"; src: url("/static/fonts/plex-sans-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("/static/fonts/plex-sans-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("/static/fonts/plex-sans-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  color-scheme: light;
  --page: #eef1f2;
  --surface: #ffffff;
  --surface-2: #f5f7f7;
  --line: #e0e4e7;
  --line-2: #c9cfd4;
  --ink: #13181c;
  --ink-2: #454e58;
  --muted: #5b6470;
  --shell: #173f35;
  --shell-2: #1f4d41;
  --shell-ink: #ffffff;
  --shell-ink-2: #bcd3ca;
  --accent: #1d5e4e;
  --accent-hover: #164a3e;
  --accent-wash: #e3eeea;
  --accent-wash-2: #d3e5de;
  --focus: #1d5e4e;
  --good: #0d6b34;
  --bad: #b02a21;
  --good-mark: #2e8b57;
  --bad-mark: #c4453b;
  --compare: #a3abb4;
  --grid: #e7eaec;
  --axis: #c9cfd4;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #898781;
  --r: 10px;
  --r-sm: 6px;
  --font: "Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-wash-2); color: var(--ink); }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.shell { background: var(--shell); color: var(--shell-ink); }
.shell-in {
  max-width: 1360px; margin: 0 auto; padding: 0 24px; min-height: 56px;
  display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--shell-ink); text-decoration: none; }
.brand:hover { color: var(--shell-ink); }
.brand svg { flex: none; }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -0.005em; }
.shell-sep { width: 1px; height: 20px; background: rgba(255, 255, 255, 0.22); }
.shell-title { color: var(--shell-ink-2); }
.shell-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.source { color: var(--shell-ink-2); font-size: 13px; margin-right: 8px; white-space: nowrap; }
.source b { color: var(--shell-ink); font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: var(--r-sm); border: 1px solid transparent; background: none; cursor: pointer;
  font-weight: 500; white-space: nowrap; transition: background-color 150ms ease-out, border-color 150ms ease-out;
}
.btn svg { flex: none; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-shell { color: var(--shell-ink); border-color: rgba(255, 255, 255, 0.28); }
.btn-shell:hover, .btn-shell[aria-expanded="true"] { background: var(--shell-2); border-color: rgba(255, 255, 255, 0.4); }
.btn-shell:focus-visible { outline-color: #ffffff; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-quiet { border-color: var(--line-2); background: var(--surface); color: var(--ink); }
.btn-quiet:hover { background: var(--surface-2); }

.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 220px; padding: 6px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 8px 24px rgba(19, 24, 28, 0.12), 0 1px 2px rgba(19, 24, 28, 0.06);
}
.menu-list a {
  display: flex; flex-direction: column; padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--ink); text-decoration: none; cursor: pointer;
}
.menu-list a span { color: var(--muted); font-size: 12.5px; }
.menu-list a:hover, .menu-list a:focus-visible { background: var(--surface-2); outline-offset: -2px; }

/* ---------- connect panel ---------- */
.connect { background: var(--surface); border-bottom: 1px solid var(--line); }
.connect-in { max-width: 1360px; margin: 0 auto; padding: 24px 24px 28px; }
.connect h2 { margin: 0 0 4px; font-size: 17px; font-weight: 600; }
.connect-lead { margin: 0 0 18px; color: var(--ink-2); max-width: 72ch; }
.connect-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.connect-box { border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.connect-box h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.drop {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 14px;
  border: 1px dashed var(--line-2); border-radius: var(--r-sm); background: var(--surface-2); cursor: pointer;
  transition: border-color 150ms ease-out, background-color 150ms ease-out;
}
.drop:hover, .drop.is-over { border-color: var(--accent); background: var(--accent-wash); }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.drop b { font-weight: 500; color: var(--accent); }
.drop small { display: block; color: var(--muted); font-size: 12.5px; }
.field-row { display: flex; gap: 8px; }
.input {
  flex: 1; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface);
}
.input::placeholder { color: #7d858f; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-wash-2); }
.hint { margin: 8px 0 0; color: var(--muted); font-size: 12.5px; }
.connect-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-top: 14px; font-size: 13px; color: var(--ink-2); }
.status { margin: 12px 0 0; font-size: 13px; min-height: 20px; }
.status.is-error { color: var(--bad); }
.status.is-ok { color: var(--good); }

/* ---------- page ---------- */
.wrap { max-width: 1360px; margin: 0 auto; padding: 20px 24px 40px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; margin-bottom: 28px; }
.field { display: flex; flex-direction: column; gap: 4px; position: relative; }
.field-label { font-size: 12.5px; color: var(--muted); }
.select, .select-btn, .date {
  height: 36px; padding: 0 32px 0 12px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%23454e58' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 11px center;
  appearance: none; cursor: pointer; min-width: 150px; text-align: left;
}
.date { padding-right: 10px; background-image: none; min-width: 0; }
.select:hover, .select-btn:hover, .date:hover { border-color: #aeb6be; }
.custom { flex-direction: row; align-items: center; gap: 8px; padding-bottom: 0; }
.custom span { color: var(--muted); font-size: 13px; }

.seg { display: inline-flex; height: 36px; padding: 3px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); }
.seg button {
  border: 0; background: none; padding: 0 12px; border-radius: 4px; cursor: pointer; color: var(--ink-2);
  transition: background-color 150ms ease-out, color 150ms ease-out;
}
.seg button:hover { color: var(--ink); background: var(--surface-2); }
.seg button[aria-checked="true"] { background: var(--accent-wash); color: var(--accent); font-weight: 500; }
.seg button:disabled { color: #a6adb4; cursor: default; background: none; }

.popover {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: 260px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 8px 24px rgba(19, 24, 28, 0.12), 0 1px 2px rgba(19, 24, 28, 0.06);
}
.check { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r-sm); cursor: pointer; }
.check:hover { background: var(--surface-2); }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.check .dot { margin-left: auto; }
.pop-foot { display: flex; justify-content: space-between; border-top: 1px solid var(--line); margin-top: 6px; padding: 6px 2px 0; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 6px; font-weight: 500; border-radius: 4px; }
.link-btn:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--c, var(--s8)); }

.heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 14px; }
.heading h1 { margin: 0; font-size: 24px; line-height: 1.2; font-weight: 600; letter-spacing: -0.012em; }
.heading p { margin: 0; color: var(--ink-2); }
.banner { margin: -4px 0 16px; padding: 10px 14px; border-radius: var(--r-sm); background: #fff6e0; color: #6b4b00; font-size: 13px; }

/* ---------- KPI strip ---------- */
.kpis {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
  margin-bottom: 16px;
}
.kpi {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 18px 16px; text-align: left;
  border: 0; border-right: 1px solid var(--line); background: none; cursor: pointer; min-width: 0;
  transition: background-color 150ms ease-out;
}
.kpi:last-child { border-right: 0; }
.kpi:hover { background: var(--surface-2); }
.kpi { position: relative; }
.kpi[aria-selected="true"] { background: var(--accent-wash); }
.kpi[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--accent); }
.kpi:focus-visible { outline-offset: -3px; }
.kpi-label { color: var(--ink-2); font-size: 13px; }
.kpi[aria-selected="true"] .kpi-label { color: var(--accent); font-weight: 500; }
.kpi-value { font-size: 28px; line-height: 1.25; font-weight: 600; letter-spacing: -0.015em; margin-top: 2px; }
.kpi-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-size: 13px; color: var(--muted); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 500; white-space: nowrap; }
.delta svg { flex: none; }
.delta.is-good { color: var(--good); }
.delta.is-bad { color: var(--bad); }
.delta.is-flat, .delta.is-neutral { color: var(--ink-2); }
.kpi.is-linked, tr.is-linked td { background: #fff1c7 !important; transition: background-color 120ms ease-out; }
.kpi.is-dim { opacity: 0.55; }

/* ---------- panels ---------- */
.main-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(320px, 1fr); gap: 16px; margin-bottom: 16px; align-items: stretch; }
#chart-panel { display: flex; flex-direction: column; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px 20px; }
.panel + .panel { margin-top: 16px; }
.main-grid > .panel + .panel { margin-top: 0; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 10px; }
.panel h2 { margin: 0; font-size: 16px; line-height: 1.3; font-weight: 600; }
.panel-sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.is-loading { opacity: 0.55; transition: opacity 150ms ease-out; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 6px; font-size: 13px; color: var(--ink-2); min-height: 20px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.key-line { width: 16px; height: 2px; border-radius: 1px; background: var(--c); }
.key-box { width: 10px; height: 10px; border-radius: 2px; background: var(--c); }

.chart { position: relative; flex: 1 1 300px; min-height: 300px; }
.chart svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: visible; }
.chart .tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .cross { stroke: var(--ink-2); stroke-width: 1; shape-rendering: crispEdges; }
.chart .note-line { stroke: var(--line-2); stroke-width: 1; shape-rendering: crispEdges; }
.chart .note-flag circle { fill: var(--surface); stroke: var(--ink-2); stroke-width: 1.25; }
.chart .note-flag text { fill: var(--ink); font-size: 11px; font-weight: 600; text-anchor: middle; }
.chart .note-flag.is-linked circle { fill: #ffe08a; stroke: var(--ink); }
.chart .empty { fill: var(--muted); font-size: 14px; text-anchor: middle; }

.notes { list-style: none; margin: 14px 0 0; padding: 12px 0 0; border-top: 1px solid var(--line); display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }
.notes li { display: flex; align-items: baseline; gap: 10px; }
.notes .n {
  display: inline-grid; place-items: center; width: 18px; height: 18px; flex: none; border-radius: 50%;
  border: 1.25px solid var(--ink-2); font-size: 11px; font-weight: 600; color: var(--ink); line-height: 1;
}
.notes time { color: var(--ink); font-weight: 500; white-space: nowrap; }
.notes li.is-linked { background: #fff1c7; border-radius: 4px; }

.tip {
  position: fixed; z-index: 50; pointer-events: none; min-width: 180px; max-width: 280px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
  box-shadow: 0 6px 20px rgba(19, 24, 28, 0.14);
}
.tip-title { color: var(--muted); margin-bottom: 6px; }
.tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.6; }
.tip-row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-row .lbl { color: var(--ink-2); margin-left: auto; padding-left: 12px; text-align: right; }
.tip-row .key-line { flex: none; }
.tip-sep { border-top: 1px solid var(--line); margin: 6px 0; }

/* ---------- summary ---------- */
.summary h2 { margin-bottom: 2px; }
.sum-body { margin-top: 14px; }
.sum-lead { margin: 0 0 12px; font-size: 15.5px; line-height: 1.5; font-weight: 500; }
.sum-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.sum-points li { display: grid; grid-template-columns: 8px 1fr; gap: 10px; align-items: baseline; color: var(--ink); }
.sum-points .dot { transform: translateY(-1px); }
.sum-watch {
  display: grid; grid-template-columns: 16px 1fr; gap: 8px; align-items: start;
  margin: 14px 0 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink);
}
.sum-watch svg { margin-top: 3px; color: var(--ink-2); }
.fig {
  font: inherit; color: inherit; background: none; border: 0; padding: 0 1px; margin: 0 -1px; cursor: help;
  text-decoration: underline dotted var(--line-2); text-decoration-thickness: 1.5px; text-underline-offset: 4px;
  border-radius: 3px; font-variant-numeric: tabular-nums;
}
.fig:hover, .fig:focus-visible { background: #fff1c7; text-decoration-color: var(--ink-2); }
.nowrap { white-space: nowrap; }
.bridge-row.is-linked { background: #fff1c7; border-radius: 4px; }
.skel { display: grid; gap: 10px; margin-top: 14px; }
.skel i { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, #eef1f2, #f6f7f8, #eef1f2); background-size: 200% 100%; animation: skel 1.4s ease-in-out infinite; }
.skel i:nth-child(1) { width: 92%; height: 16px; }
.skel i:nth-child(2) { width: 80%; }
.skel i:nth-child(3) { width: 86%; }
.skel i:nth-child(4) { width: 64%; }
@keyframes skel { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.bridge { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.bridge h3 { margin: 0 0 2px; font-size: 14px; font-weight: 600; }
.bridge p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.bridge-row { display: grid; grid-template-columns: minmax(96px, 128px) 1fr 64px; align-items: center; gap: 10px; height: 28px; font-size: 13px; }
.bridge-name { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink-2); }
.bridge-name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bridge-track { position: relative; height: 12px; }
.bridge-track::before { content: ""; position: absolute; left: 50%; top: -6px; bottom: -6px; width: 1px; background: var(--axis); }
.bridge-bar { position: absolute; top: 0; height: 12px; }
.bridge-bar.up { left: 50%; background: var(--good-mark); border-radius: 0 3px 3px 0; }
.bridge-bar.down { right: 50%; background: var(--bad-mark); border-radius: 3px 0 0 3px; }
.bridge-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 500; }
.sum-foot { margin: 16px 0 0; color: var(--muted); font-size: 12.5px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
td { font-variant-numeric: tabular-nums; }
th { font-weight: 500; color: var(--muted); font-size: 12.5px; border-bottom-color: var(--line-2); }
th button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
th button svg { flex: none; }
th:not(:first-child) button { flex-direction: row-reverse; }
th button:hover { color: var(--ink); }
th[aria-sort] button { color: var(--ink); }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 600; border-top: 1px solid var(--line-2); border-bottom: 0; }
.ch-name { display: inline-flex; align-items: center; gap: 9px; font-variant-numeric: normal; }
.share { display: inline-flex; align-items: center; gap: 8px; }
.share-bar { width: 56px; height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.share-bar i { display: block; height: 100%; border-radius: 3px; background: var(--c); }
.muted { color: var(--muted); }
details > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
details > summary::-webkit-details-marker { display: none; }
details > summary .chev { transition: transform 150ms ease-out; color: var(--ink-2); }
details[open] > summary .chev { transform: rotate(180deg); }
details[open] > summary { margin-bottom: 8px; }

.foot { max-width: 1360px; margin: 0 auto; padding: 0 24px 32px; color: var(--muted); font-size: 12.5px; }

/* ---------- small screens ---------- */
@media (max-width: 1100px) {
  .main-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 880px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { border-bottom: 1px solid var(--line); }
  .kpi:nth-child(2n) { border-right: 0; }
  .kpi:last-child { grid-column: 1 / -1; border-bottom: 0; }
  .connect-grid { grid-template-columns: 1fr; }
  .source { display: none; }
}
@media (max-width: 640px) {
  .shell-in { padding: 0 16px; gap: 8px; min-height: 52px; }
  .shell-sep, .shell-title { display: none; }
  .shell-right { gap: 6px; }
  .btn { height: 32px; padding: 0 10px; font-size: 13px; }
  .btn-shell svg { display: none; }
  .brand-name { font-size: 14px; }
  .wrap { padding: 16px 16px 32px; }
  .connect-in { padding: 20px 16px 24px; }
  .foot { padding: 0 16px 28px; }
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 22px; }
  .toolbar .field { min-width: 0; }
  .select, .select-btn { min-width: 0; width: 100%; }
  .custom { grid-column: 1 / -1; }
  .custom .date { flex: 1; }
  .seg { width: 100%; }
  .seg button { flex: 1; }
  .heading h1 { font-size: 21px; }
  .kpi { padding: 12px 14px 14px; }
  .kpi-value { font-size: 23px; }
  .panel { padding: 16px 16px 18px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .chart { flex-basis: 240px; min-height: 240px; }
  .bridge-row { grid-template-columns: 124px 1fr 58px; gap: 8px; }
  #ch-table th:first-child, #ch-table td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line); padding-right: 10px; }
  .menu-list { right: auto; left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
  .shell-right, .toolbar, .connect, .summary .sum-foot { display: none !important; }
  body { background: #fff; }
  .panel, .kpis { break-inside: avoid; }
}
