:root {
  color-scheme: light;
  --bg: #f4f6f2;
  --paper: #ffffff;
  --ink: #17201b;
  --muted: #667268;
  --line: #dfe5de;
  --green: #1f7a55;
  --teal: #126f78;
  --amber: #b2781d;
  --red: #b74b45;
  --soft: #f8faf7;
  --shadow: 0 18px 45px rgba(26, 39, 31, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

h1, h2, h3, p { margin: 0; }

h1 {
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(20px, 2vw, 26px);
  line-height: 1.25;
}

h3 {
  font-size: 18px;
  line-height: 1.25;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding: 30px clamp(18px, 4vw, 56px);
  background: #10241d;
  color: #fff;
}

.eyebrow {
  margin-bottom: 8px;
  color: #6d8b7a;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar .eyebrow { color: #a8cdb8; }

.report-meta {
  display: grid;
  gap: 7px;
  justify-items: end;
  color: #dcebe3;
  font-size: 14px;
}

.report-meta strong { color: #fff; }

.shell {
  width: min(1520px, calc(100% - 36px));
  margin: 24px auto 42px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.hero-grid,
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 18px;
  margin-bottom: 18px;
}

.shell > .panel { margin-bottom: 18px; }

.thesis-panel p {
  max-width: 960px;
  color: var(--muted);
  line-height: 1.75;
  margin-top: 12px;
}

.thesis-tags,
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.thesis-tags span,
.legend span,
.section-note,
.formula-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.formula-panel,
.formula-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.formula-strip {
  grid-column: 1 / -1;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.formula-chip {
  max-width: 100%;
  border-style: dashed;
  background: #fff;
  color: #435149;
  line-height: 1.4;
}

.formula-chip strong {
  margin-right: 5px;
  color: var(--ink);
}

.feature-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ml-tab-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ml-tab-controls button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 900;
  cursor: pointer;
}

.ml-tab-controls button.active {
  border-color: var(--teal);
  background: #e8f4f6;
  color: var(--teal);
}

.ml-tab-pane.is-hidden {
  display: none;
}

.feature-tab-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.feature-controls button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 900;
  cursor: pointer;
}

.feature-controls button.active {
  border-color: var(--green);
  background: #eaf4ef;
  color: var(--green);
}

.feature-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.feature-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
}

.line-key {
  position: relative;
  padding-left: 26px !important;
}

.line-key::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  width: 10px;
  height: 3px;
  border-radius: 999px;
  transform: translateY(-50%);
  background: currentColor;
}

.line-key.previous {
  color: #7a8790;
}

.line-key.current {
  color: #256a5a;
}

.line-key.forecast {
  color: #b15f25;
}

.feature-chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.feature-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 14px;
}

.feature-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.feature-card-head strong {
  display: block;
  font-size: 18px;
}

.feature-card-head span,
.feature-stats {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.feature-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.feature-svg {
  display: block;
  width: 100%;
  min-height: 260px;
}

.chart-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-line.previous {
  stroke: #7a8790;
  opacity: 0.65;
}

.chart-line.current {
  stroke: #256a5a;
}

.chart-line.forecast {
  stroke: #b15f25;
  stroke-dasharray: 7 5;
}

.current-point {
  fill: #256a5a;
}

.forecast-point {
  fill: #b15f25;
  stroke: #fff;
  stroke-width: 1.5;
}

.axis-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.tick-label {
  fill: var(--muted);
  font-size: 10px;
}

.feature-thumb-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.feature-thumb {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.feature-thumb:hover {
  border-color: var(--green);
}

.feature-thumb strong,
.feature-thumb span {
  display: block;
}

.feature-thumb strong {
  color: var(--ink);
  font-size: 14px;
}

.feature-thumb span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  background: #eaf4ef;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.warning {
  background: #fff3df;
  color: var(--amber);
}

.quality-list,
.risk-map,
.checklist {
  display: grid;
  gap: 10px;
}

.commander-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.commander-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 14px;
}

.commander-card span {
  display: inline-flex;
  margin-bottom: 10px;
  border-radius: 999px;
  background: #e8f4f6;
  color: var(--teal);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 900;
}

.commander-card strong {
  display: block;
  margin-bottom: 7px;
  font-size: 18px;
}

.commander-card p {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.quality-row {
  display: grid;
  grid-template-columns: 1fr 86px;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
}

.quality-row.failed { border-left-color: var(--amber); }

.quality-row strong,
.source-card strong,
.risk-item strong {
  display: block;
  margin-bottom: 5px;
}

.quality-row span,
.quality-row small,
.risk-item span,
.source-card p,
.watch-row p,
.focus-card p,
.checklist li {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.quality-row b {
  display: block;
  text-align: right;
  font-size: 13px;
}

.quality-row small {
  display: block;
  text-align: right;
}

.agent-roster-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.agent-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--green);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.agent-card span {
  width: fit-content;
  border-radius: 999px;
  background: #edf5f2;
  color: #26634b;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 900;
}

.agent-card h3 {
  margin: 0;
  font-size: 18px;
}

.agent-card strong {
  color: var(--teal);
}

.agent-card code {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  border-radius: 6px;
  background: var(--soft);
  padding: 7px 8px;
  color: var(--muted);
  font-size: 11px;
}

.agent-card p {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.coordination-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.agent-flow {
  display: grid;
  gap: 10px;
}

.flow-step {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.flow-step > span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #e8f4f6;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.flow-step strong {
  display: block;
  margin-bottom: 4px;
}

.flow-step p,
.shared-bus p {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.shared-bus {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--teal);
  border-radius: 8px;
  background: var(--soft);
  padding: 16px;
}

.bus-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bus-chip-grid span {
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
}

.dot.high { background: var(--green); }
.dot.mid { background: var(--teal); }
.dot.watch { background: var(--amber); }

.watchlist-table {
  display: grid;
  gap: 10px;
}

.watch-row {
  display: grid;
  grid-template-columns: 110px 1.05fr 1.4fr 1.25fr 1.1fr 72px;
  gap: 12px;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 12px;
}

.watch-id strong {
  display: block;
  font-size: 21px;
}

.watch-id span,
.industry,
.watch-row small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.industry {
  display: inline-flex;
  margin-bottom: 6px;
  border-radius: 999px;
  background: #edf5f2;
  color: #26634b;
  padding: 5px 8px;
}

.confidence {
  display: grid;
  place-items: center;
  min-height: 64px;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
}

.confidence.high { background: var(--green); }
.confidence.mid { background: var(--teal); }
.confidence.watch { background: var(--amber); }

.focus-grid,
.source-grid,
.ml-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.focus-card,
.source-card,
.risk-item,
.ml-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 16px;
}

.ml-panel .section-note {
  background: #e8f4f6;
  color: var(--teal);
}

.handoff-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.handoff-card {
  display: grid;
  gap: 10px;
  align-content: start;
  border: 1px solid var(--line);
  border-top: 5px solid var(--amber);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 16px;
}

.handoff-card.wide {
  grid-column: 1 / -1;
  border-top-color: var(--teal);
}

.handoff-card p,
.handoff-card li,
.handoff-card span {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.handoff-card ul {
  margin: 0;
  padding-left: 18px;
}

.handoff-card > span {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  background: #fff3df;
  color: var(--amber);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 900;
}

.handoff-flow {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.handoff-flow div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px;
}

.handoff-flow strong,
.handoff-flow span {
  display: block;
}

.handoff-flow strong {
  margin-bottom: 4px;
}

.ml-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ml-card {
  display: grid;
  gap: 10px;
  align-content: start;
}

.ml-card.wide {
  grid-column: span 2;
}

.ml-card h3 {
  margin-bottom: 2px;
}

.ml-card p,
.ml-card li {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.ml-card ul {
  margin: 0;
  padding-left: 18px;
}

.ml-score {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
  font-size: 13px;
}

.ml-score strong {
  font-size: 18px;
}

.ml-badge {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  background: #edf5f2;
  color: #26634b;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 900;
}

.accuracy-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.accuracy-metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 14px;
}

.accuracy-metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}

.accuracy-metric strong {
  font-size: 22px;
}

.accuracy-week-grid {
  display: grid;
  gap: 14px;
}

.accuracy-week {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 16px;
}

.accuracy-week-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.accuracy-week-head h3 {
  margin-bottom: 6px;
}

.accuracy-week-head p,
.accuracy-note {
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.accuracy-table {
  display: grid;
  gap: 8px;
}

.accuracy-row {
  display: grid;
  grid-template-columns: 92px repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
  font-size: 13px;
}

.accuracy-row strong {
  font-size: 16px;
}

.accuracy-row span {
  color: var(--muted);
}

.accuracy-chart {
  display: block;
  width: 100%;
  min-height: 280px;
  margin-top: 12px;
}

.accuracy-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-top: 8px;
}

.focus-card {
  border-top: 5px solid var(--green);
}

.focus-card.watch { border-top-color: var(--amber); }
.focus-card.neutral { border-top-color: var(--teal); }

.focus-card span {
  display: inline-flex;
  margin-bottom: 12px;
  border-radius: 999px;
  background: #edf5f2;
  color: #26634b;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 900;
}

.focus-card.watch span {
  background: #fff3df;
  color: var(--amber);
}

.focus-card.neutral span {
  background: #e8f4f6;
  color: var(--teal);
}

.focus-card h3 { margin-bottom: 8px; }

.risk-item {
  border-left: 4px solid var(--red);
}

.checklist {
  margin: 0;
  padding-left: 22px;
}

.checklist li {
  padding: 4px 0;
}

.source-card,
.backfill-card {
  background: var(--soft);
}

.backfill-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.backfill-card {
  border: 1px solid var(--line);
  border-top: 5px solid var(--teal);
  border-radius: 8px;
  padding: 16px;
}

.backfill-card span {
  display: inline-flex;
  margin-bottom: 12px;
  border-radius: 999px;
  background: #e8f4f6;
  color: var(--teal);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 900;
}

.backfill-card h3 {
  margin-bottom: 8px;
}

.backfill-card p {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.historical-panel {
  display: grid;
  gap: 18px;
}

.historical-controls {
  display: grid;
  grid-template-columns: 160px 280px minmax(260px, 1fr);
  gap: 12px;
  align-items: end;
}

.historical-controls label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.historical-controls select,
.historical-controls input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  font: inherit;
  font-size: 14px;
}

.historical-layout {
  display: grid;
  grid-template-columns: minmax(240px, 330px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.history-list {
  display: grid;
  gap: 8px;
  max-height: 720px;
  overflow: auto;
  padding-right: 6px;
}

.history-list button {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 74px;
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.history-list button.active,
.history-list button:hover {
  border-left-color: var(--teal);
  background: #eef7f7;
}

.history-list strong {
  font-size: 14px;
}

.history-list span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.history-detail {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

.history-detail-head,
.history-meta,
.history-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.history-detail-head h3 {
  margin-top: 4px;
  font-size: 24px;
}

.history-meta {
  justify-content: flex-start;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.history-meta span,
.history-chip-grid span {
  border-radius: 999px;
  background: var(--soft);
  padding: 7px 10px;
}

.history-detail section {
  display: grid;
  gap: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 14px;
}

.history-detail h4 {
  margin: 0;
  font-size: 15px;
}

.history-detail p,
.history-detail li {
  color: var(--muted);
  line-height: 1.65;
  font-size: 14px;
}

.history-detail ol {
  margin: 0;
  padding-left: 22px;
}

.empty-note {
  color: var(--muted);
}

footer {
  width: min(1520px, calc(100% - 36px));
  margin: 0 auto 32px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

@media (max-width: 1180px) {
  .hero-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .watch-row {
    grid-template-columns: 92px 1fr 1fr;
  }

  .confidence {
    min-height: 42px;
  }

  .focus-grid,
  .source-grid,
  .backfill-grid,
  .handoff-grid,
  .agent-roster-grid,
  .coordination-grid,
  .commander-grid,
  .ml-grid,
  .feature-chart-grid,
  .accuracy-summary,
  .historical-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .feature-thumb-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .report-meta {
    justify-items: start;
  }

  .shell,
  footer {
    width: min(100% - 24px, 1520px);
  }

  .panel {
    padding: 18px;
  }

  .watch-row,
  .quality-row,
  .focus-grid,
  .source-grid,
  .backfill-grid,
  .handoff-grid,
  .handoff-flow,
  .agent-roster-grid,
  .coordination-grid,
  .commander-grid,
  .historical-controls,
  .historical-layout,
  .ml-grid,
  .feature-chart-grid,
  .accuracy-summary,
  .accuracy-row,
  .handoff-card.wide,
  .ml-card.wide {
    grid-template-columns: 1fr;
    grid-column: auto;
  }

  .feature-thumb-strip {
    grid-template-columns: 1fr;
  }

  .feature-controls {
    justify-content: flex-start;
  }

  .ml-tab-controls,
  .feature-tab-head {
    justify-content: flex-start;
    flex-direction: column;
  }

  .quality-row b,
  .quality-row small {
    text-align: left;
  }
}
