/* Refero-inspired dashboard shell: sticky header, split workstream, fixed context rail. */
:root {
  color-scheme: dark;
  --bg: #17191d;
  --panel: #202328;
  --panel-soft: #262a31;
  --line: #3a4048;
  --line-soft: #2d3239;
  --ink: #f4f6f8;
  --muted: #a8b0bb;
  --faint: #737d8a;
  --accent: #75b88f;
  --accent-strong: #9ed5b1;
  --danger: #ea6b62;
  --radius: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Noto Sans TC", "Microsoft JhengHei", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgb(117 184 143 / .14), transparent 30rem),
    linear-gradient(180deg, #1b1e23, var(--bg));
  font-variant-numeric: tabular-nums;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .28;
  background-image:
    linear-gradient(rgb(255 255 255 / .035) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / .03) 1px, transparent 1px);
  background-size: 48px 48px;
}

h1, h2, h3, p { margin: 0; }
h1 {
  max-width: 760px;
  font-size: clamp(2rem, 4.8vw, 4.75rem);
  line-height: .96;
  text-wrap: balance;
}
h2 { font-size: 1rem; font-weight: 650; }
h3 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 700;
}

.skipLink {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 100;
  transform: translateY(-160%);
  color: var(--bg);
  background: var(--accent-strong);
  padding: 10px 12px;
  border-radius: 10px;
}
.skipLink:focus { transform: translateY(0); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  min-height: 72px;
  padding: 10px clamp(16px, 3vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgb(23 25 29 / .84);
  backdrop-filter: blur(18px);
}
.crumbs { display: flex; align-items: center; gap: 12px; min-width: 0; }
.crumbs a, .crumbs strong {
  color: var(--ink);
  text-decoration: none;
  font-weight: 650;
}
.crumbs span { color: var(--faint); }

button, .importBtn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 10px 15px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
button:hover, .importBtn:hover { border-color: var(--accent); background: #2c3338; }
button:active, .importBtn:active { transform: translateY(1px) scale(.99); }
button:disabled { cursor: wait; opacity: .58; }
button:focus-visible, .importBtn:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid rgb(117 184 143 / .38);
  outline-offset: 3px;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.importBtn input { display: none; }

.dashboardShell {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(420px, .92fr);
  gap: 0;
  max-width: 1680px;
  margin: 0 auto;
  min-height: calc(100dvh - 72px);
  padding: 0;
}
.workstream {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: clamp(18px, 3vw, 44px);
}
.contextRail {
  display: grid;
  align-content: start;
  gap: 18px;
  min-width: 0;
  padding: clamp(18px, 3vw, 44px);
  border-left: 1px solid var(--line);
  background: rgb(255 255 255 / .025);
}

.heroPanel {
  display: grid;
  gap: 18px;
  padding: clamp(22px, 4vw, 44px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgb(117 184 143 / .12), transparent 48%),
    var(--panel);
}
.heroPanel p:not(.eyebrow) {
  max-width: 62ch;
  color: var(--muted);
  line-height: 1.7;
}
.eyebrow {
  color: var(--accent-strong);
  font-size: .86rem;
  font-weight: 700;
  letter-spacing: .04em;
}

.summary, .fields, .sources, .checks, .topics { display: grid; gap: 12px; }
.summary { grid-template-columns: repeat(5, minmax(120px, 1fr)); }
.summary article, .panel {
  background: rgb(32 35 40 / .92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.summary article {
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 16px;
}
.summary span, .panelHead span, label span { color: var(--muted); font-size: .88rem; }
.summary strong, .bigNumber {
  font-family: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  font-weight: 500;
  letter-spacing: 0;
}
.summary strong { font-size: clamp(1.8rem, 3vw, 2.75rem); }
meter { width: 100%; height: 8px; accent-color: var(--accent); }

.panel { padding: 18px; }
.panelHead {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.fields { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
label { display: grid; gap: 7px; color: var(--ink); font-weight: 650; }
input[type="number"] {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  color: var(--ink);
  background: #171a1f;
  transition: border-color .18s ease, background .18s ease;
}
input[type="number"]:focus { border-color: var(--accent); background: #111419; }

.previewPanel { background: linear-gradient(180deg, #22262c, #1d2025); }
.bigNumber { font-size: clamp(3rem, 8vw, 6rem); line-height: .95; margin-bottom: 20px; }
.donutWrap {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 24px;
  align-items: center;
}
.donut {
  width: 132px;
  aspect-ratio: 1;
  border-radius: 50%;
  position: relative;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .08);
}
.donut::after {
  content: "";
  position: absolute;
  inset: 34px;
  border-radius: 50%;
  background: #1d2025;
}
.legend { display: grid; gap: 14px; }
.legend div { display: flex; gap: 10px; align-items: start; }
.legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 7px;
  background: var(--dot);
  flex: 0 0 auto;
}
.legend span { display: grid; gap: 3px; }
.legend strong { color: var(--ink); }
.lineChart { min-height: 190px; }
.lineChart svg { width: 100%; height: auto; display: block; }
.chartArea { fill: rgb(117 184 143 / .18); }
.chartLine { fill: none; stroke: var(--accent-strong); stroke-width: 2; }
.lineChart circle { fill: #1d2025; stroke: var(--accent-strong); stroke-width: 2; }
.lineChart text { fill: var(--muted); font-size: 12px; text-anchor: middle; }
.lineChart text:first-of-type, .lineChart text:nth-of-type(2) { text-anchor: start; }

.source, .check, .topic {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px;
  background: #181b20;
}
.source strong, .topic strong { display: block; margin-bottom: 5px; color: var(--ink); }
.source small, .topic small { color: var(--muted); line-height: 1.55; }
.check span { color: var(--muted); line-height: 1.45; }
.checks { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
.check { display: flex; gap: 10px; align-items: start; font-weight: 500; }
.check input { margin-top: 4px; accent-color: var(--accent); }
.topics { grid-template-columns: 1fr 1fr; }
.liveStatus {
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 12px;
}
.liveChecks {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}
.liveItem {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #181b20;
}
.liveItem span { color: var(--muted); font-size: .86rem; }
.liveItem strong { color: var(--ink); font-weight: 650; overflow-wrap: anywhere; }
.opsGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.opsList { display: grid; gap: 10px; }
.opsItem {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #181b20;
}
.opsItem::before {
  content: "";
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--danger);
}
.opsItem.isOk::before { background: var(--accent); }
.opsItem strong { display: block; margin-bottom: 4px; color: var(--ink); }
.opsItem span { color: var(--muted); line-height: 1.45; font-size: .9rem; }

.importStatus {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  color: var(--ink);
  background: #111419;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}
.importStatus.isVisible { opacity: 1; transform: translateY(0); }
.importStatus.isError { border-color: var(--danger); }

@media (max-width: 1180px) {
  .dashboardShell { grid-template-columns: 1fr; }
  .contextRail { border-left: 0; border-top: 1px solid var(--line); }
  .summary, .fields, .checks, .opsGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .topbar { align-items: start; flex-direction: column; }
  .actions, button, .importBtn { width: 100%; }
  button, .importBtn { text-align: center; }
  .workstream, .contextRail { padding: 14px; }
  .summary, .fields, .checks, .topics, .liveChecks, .opsGrid { grid-template-columns: 1fr; }
  .donutWrap { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
