:root {
  color-scheme: light;
  --page: #f4f6f5;
  --surface: #ffffff;
  --surface-muted: #e9eeec;
  --ink: #17201e;
  --muted: #68736f;
  --line: #d6dedb;
  --teal: #087f7a;
  --green: #27835b;
  --coral: #cf5b4c;
  --yellow: #d8a237;
  --radius: 6px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body { margin: 0; min-width: 320px; background: var(--page); color: var(--ink); font-size: 14px; letter-spacing: 0; }
button { color: inherit; font: inherit; letter-spacing: 0; }

.app-header { min-height: 68px; padding: 10px 24px; display: flex; align-items: center; justify-content: space-between; gap: 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand, .header-actions, .system-status { display: flex; align-items: center; }
.brand { gap: 11px; }
.brand h1 { margin: 0; font-size: 19px; line-height: 1.2; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.brand-mark { width: 34px; height: 34px; padding: 7px; display: grid; align-content: center; gap: 4px; background: var(--ink); border-radius: 4px; }
.brand-mark span { display: block; height: 2px; background: #fff; }
.brand-mark span:nth-child(1) { width: 17px; transform: rotate(8deg); }
.brand-mark span:nth-child(2) { width: 12px; transform: rotate(-10deg); }
.brand-mark span:nth-child(3) { width: 18px; transform: rotate(5deg); }
.header-actions { gap: 10px; }
.language-link { min-width: 30px; height: 28px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; text-decoration: none; font-size: 10px; font-weight: 750; }
.language-link:hover { color: var(--teal); border-color: var(--teal); }
.system-status { gap: 9px; text-align: right; }
.system-status i { width: 8px; height: 8px; border-radius: 50%; background: #a8b1ae; }
.system-status i.ok { background: var(--green); }
.system-status i.attention { background: var(--coral); }
.system-status div { display: grid; gap: 2px; }
.system-status strong { font-size: 12px; }
.system-status span { color: var(--muted); font-size: 10px; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); cursor: pointer; font-size: 19px; }
.icon-button:hover { color: var(--teal); border-color: var(--teal); }
.icon-button.loading { animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { height: 42px; padding: 0 24px; display: flex; gap: 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.tab { position: relative; padding: 0 2px; border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 650; cursor: pointer; }
.tab-link { display: inline-flex; align-items: center; text-decoration: none; }
.tab-link:hover { color: var(--ink); }
.tab.active { color: var(--ink); }
.tab.active::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--teal); }

main { max-width: 1480px; margin: 0 auto; padding: 18px 24px 34px; }
.view { display: none; }
.view.active { display: block; }
.run-notice { min-height: 74px; margin-bottom: 12px; padding: 12px 15px; display: flex; align-items: center; justify-content: space-between; gap: 24px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--teal); border-radius: var(--radius); }
.run-notice.settling { border-left-color: var(--yellow); }
.run-notice.complete { border-left-color: var(--green); background: #f2f8f4; }
.notice-copy { min-width: 0; display: grid; gap: 3px; }
.notice-copy span { color: var(--teal); font-size: 9px; font-weight: 750; }
.run-notice.settling .notice-copy span { color: #8a6519; }
.run-notice.complete .notice-copy span { color: var(--green); }
.notice-copy strong { font-size: 14px; }
.notice-copy small { color: var(--muted); font-size: 10px; }
.notice-progress { width: min(230px, 32%); flex: 0 0 auto; display: grid; gap: 7px; }
.notice-progress > strong { text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; }
.progress-track { height: 5px; overflow: hidden; background: var(--surface-muted); border-radius: 2px; }
.progress-track i { width: 0; height: 100%; display: block; background: var(--teal); transition: width 250ms ease; }
.run-notice.settling .progress-track i { background: var(--yellow); }
.run-notice.complete .progress-track i { background: var(--green); }
.metric-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.metric { min-height: 92px; padding: 13px 15px; display: grid; align-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.metric.accent { border-top: 3px solid var(--teal); }
.metric span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.metric strong { font-size: 27px; line-height: 1; font-variant-numeric: tabular-nums; }
.metric small { color: var(--muted); font-size: 10px; }

.toolbar { min-height: 52px; margin-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.segmented { padding: 2px; display: inline-flex; gap: 2px; background: #e4eae7; border-radius: 5px; }
.segment { height: 29px; min-width: 76px; padding: 0 10px; border: 0; border-radius: 3px; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 650; }
.segment.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(23 32 30 / 10%); }
.legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.legend span { width: 9px; height: 9px; display: inline-block; margin-left: 8px; border-radius: 2px; }
.legend-ch008 { background: var(--teal); }
.legend-etas { background: var(--coral); }

.overview-grid { margin-top: 16px; display: grid; grid-template-columns: minmax(0, 3fr) minmax(240px, 0.8fr); gap: 18px; }
.chart-panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.section-heading { min-height: 56px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin: 0; font-size: 14px; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.section-heading > strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.chart-stage { position: relative; width: 100%; aspect-ratio: 2.65; min-height: 260px; background: #fbfcfb; overflow: hidden; }
#score-chart { display: block; width: 100%; height: 100%; }
.empty-state { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.empty-state.hidden { display: none; }
.chart-tooltip { position: absolute; z-index: 2; min-width: 132px; padding: 7px 9px; display: none; color: #fff; background: rgb(23 32 30 / 94%); border-radius: 4px; pointer-events: none; font-size: 10px; line-height: 1.5; }
.chart-tooltip.visible { display: block; }
.score-summary { display: grid; align-content: start; border-top: 1px solid var(--line); }
.summary-block { min-height: 92px; padding: 13px 0; display: grid; align-content: space-between; border-bottom: 1px solid var(--line); }
.summary-block span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.summary-block strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.summary-block small { color: var(--muted); font-size: 10px; }

.data-section { margin-top: 22px; }
.data-section > .section-heading { padding-right: 0; padding-left: 0; }
.table-wrap { width: 100%; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--line); }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
th { height: 37px; padding: 0 12px; color: var(--muted); background: #eef2f0; border-bottom: 1px solid var(--line); text-align: left; font-size: 9px; text-transform: uppercase; }
td { height: 57px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 11px; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
.primary-cell { display: grid; gap: 3px; }
.primary-cell strong { font-size: 12px; }
.primary-cell small, .muted { color: var(--muted); font-size: 9px; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 650; }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.status-pill.waiting::before { background: var(--yellow); }
.gain-positive { color: var(--green); font-weight: 700; }
.gain-negative { color: var(--coral); font-weight: 700; }
.gain-neutral { color: var(--muted); }

.view-heading { padding: 8px 0 19px; border-bottom: 1px solid var(--line); }
.view-heading span { color: var(--teal); font-size: 10px; font-weight: 750; }
.view-heading h2 { margin: 6px 0 0; font-size: 21px; }
.view-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.score-table-wrap { margin-top: 14px; }
.table-empty { min-height: 150px; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.table-empty.hidden { display: none; }

.protocol-grid { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 34px; padding-top: 20px; }
.protocol-grid section { min-width: 0; }
.protocol-grid h3 { margin: 0 0 10px; font-size: 12px; }
dl { margin: 0; border-top: 1px solid var(--line); }
dl div { min-height: 42px; padding: 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
dt { color: var(--muted); font-size: 10px; }
dd { margin: 0; text-align: right; font-size: 11px; font-weight: 650; }
.protocol-regions { border-top: 1px solid var(--line); }
.protocol-region { min-height: 63px; padding: 9px 0; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.protocol-region strong, .protocol-region small { display: block; }
.protocol-region strong { font-size: 11px; }
.protocol-region small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.protocol-region span { font-size: 11px; font-variant-numeric: tabular-nums; }

.error-banner { position: fixed; left: 50%; bottom: 18px; z-index: 10; width: min(520px, calc(100% - 32px)); padding: 11px 14px; display: none; transform: translateX(-50%); color: #fff; background: #8d3028; border-radius: 4px; box-shadow: 0 8px 24px rgb(23 32 30 / 18%); }
.error-banner.visible { display: block; }
.site-footer { min-height: 54px; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--muted); background: var(--surface); border-top: 1px solid var(--line); font-size: 10px; }
.site-footer a { color: var(--ink); text-decoration: none; }
.site-footer a:hover { color: var(--teal); }

@media (max-width: 980px) {
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .overview-grid { grid-template-columns: 1fr; }
  .score-summary { grid-template-columns: repeat(3, 1fr); }
  .summary-block { padding: 12px; border-right: 1px solid var(--line); }
  .protocol-grid { grid-template-columns: 1fr 1fr; }
  .protocol-grid section:last-child { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .app-header { min-height: 62px; padding: 9px 14px; }
  .brand h1 { font-size: 16px; }
  .brand p, .system-status div { display: none; }
  .tabs { padding: 0 14px; gap: 18px; }
  main { padding: 12px 14px 28px; }
  .run-notice { align-items: stretch; flex-direction: column; gap: 10px; }
  .notice-progress { width: 100%; }
  .metric-strip { gap: 7px; }
  .metric { min-height: 82px; padding: 10px; }
  .metric strong { font-size: 22px; }
  .toolbar { align-items: flex-start; flex-direction: column; padding: 9px 0; }
  .segmented { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .segment { min-width: 0; padding: 0 4px; }
  .legend { align-self: flex-end; }
  .chart-stage { min-height: 310px; aspect-ratio: 1.1; }
  .score-summary { grid-template-columns: 1fr; }
  .summary-block { min-height: 78px; padding: 11px 0; border-right: 0; }
  .protocol-grid { grid-template-columns: 1fr; gap: 26px; }
  .protocol-grid section:last-child { grid-column: auto; }
  .view-heading h2 { font-size: 18px; }
}
