:root {
  color-scheme: light;
  --bg: #f6f8f9;
  --panel: #ffffff;
  --ink: #13202a;
  --muted: #60717d;
  --line: #dce3e7;
  --line-strong: #c8d2d8;
  --blue: #1677a6;
  --teal: #0a8a75;
  --gold: #b87912;
  --coral: #c55b49;
  --pink: #b74f78;
  --green-soft: #eaf7f3;
  --amber-soft: #fff5df;
  --red-soft: #fff0ed;
  --shadow: 0 8px 24px rgba(18, 41, 56, 0.07);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 0;
}

button, select, input { font: inherit; letter-spacing: 0; }
button, a, select, input { -webkit-tap-highlight-color: transparent; }

.app-header {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px max(20px, calc((100vw - 1480px) / 2));
  background: #102934;
  color: #fff;
  border-bottom: 1px solid #28434d;
}

.brand-block, .header-actions, .section-heading, .legend, .read-only, .compact-toggle {
  display: flex;
  align-items: center;
}

.brand-block { gap: 12px; min-width: 0; }
.header-actions { gap: 8px; }

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid #4c6973;
  border-radius: 6px;
  color: #8ed7e6;
}

.brand-mark svg, .icon-button svg { width: 19px; height: 19px; }
.brand-block h1 { margin: 0; font-size: 18px; line-height: 1.25; font-weight: 680; }
.brand-block p { margin: 3px 0 0; color: #a9bdc5; font-size: 12px; }

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid #4b6872;
  border-radius: 6px;
  background: transparent;
  color: #e7f1f4;
  cursor: pointer;
  text-decoration: none;
}
.icon-button:hover { background: #1d3b46; border-color: #6e8b95; }
.icon-button:focus-visible, select:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid rgba(22, 119, 166, 0.24); outline-offset: 2px; }

.section-nav {
  display: flex;
  gap: 4px;
  padding: 0 max(20px, calc((100vw - 1480px) / 2));
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.section-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  font-weight: 620;
}
.section-nav a:hover { color: var(--ink); }
.section-nav a.active { color: var(--blue); border-bottom-color: var(--blue); }

main {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 20px 0 48px;
}

.filter-band {
  display: grid;
  grid-template-columns: minmax(130px, 0.7fr) minmax(220px, 1.5fr) minmax(140px, 0.8fr) 1fr;
  gap: 12px;
  align-items: end;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

label { min-width: 0; }
label > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 620; }
select {
  width: 100%;
  height: 38px;
  padding: 0 34px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
}
.period-stamp { justify-self: end; align-self: center; color: var(--muted); font-size: 12px; text-align: right; }

.data-alert {
  margin-top: 12px;
  padding: 11px 13px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--amber-soft);
  border: 1px solid #efd59e;
  border-radius: 5px;
  color: #6f4a0a;
  line-height: 1.55;
}
.data-alert svg { width: 18px; height: 18px; flex: 0 0 auto; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.kpi-card {
  min-height: 108px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent, var(--blue));
  border-radius: 6px;
}
.kpi-card span { color: var(--muted); font-size: 12px; }
.kpi-card b { display: block; margin-top: 8px; font-size: 25px; line-height: 1; font-weight: 700; }
.kpi-card small { display: block; margin-top: 9px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.kpi-card.accent-blue { --accent: var(--blue); }
.kpi-card.accent-teal { --accent: var(--teal); }
.kpi-card.accent-gold { --accent: var(--gold); }
.kpi-card.accent-coral { --accent: var(--coral); }
.kpi-card.accent-pink { --accent: var(--pink); }
.kpi-card.accent-ink { --accent: #294651; }

.analysis-band, .panel {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}
.analysis-band, .panel { padding: 16px; }
.section-heading { justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.section-heading h2 { margin: 2px 0 0; font-size: 16px; line-height: 1.3; }
.eyebrow { margin: 0; color: var(--blue); font-size: 11px; font-weight: 730; text-transform: uppercase; }
.read-only { gap: 6px; color: var(--teal); font-size: 12px; }
.read-only svg { width: 16px; height: 16px; }

.analysis-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.analysis-item { padding: 12px 13px; border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 5px; background: #fbfcfc; }
.analysis-item.high { border-left-color: var(--coral); background: var(--red-soft); }
.analysis-item.medium { border-left-color: var(--gold); background: var(--amber-soft); }
.analysis-item h3 { margin: 0 0 7px; font-size: 13px; line-height: 1.35; }
.analysis-item p { margin: 0; color: #52646f; font-size: 12px; line-height: 1.55; }

.chart-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 14px; }
.chart-panel { min-width: 0; }
.legend { gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.legend span { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; }
.legend i { width: 9px; height: 3px; display: inline-block; background: var(--color); }
.legend .swatch-0 { background: var(--blue); }
.legend .swatch-1 { background: var(--gold); }
.legend .swatch-2 { background: var(--coral); }
.legend .swatch-3 { background: var(--teal); }
.legend .swatch-4 { background: var(--pink); }
.chart-wrap { position: relative; width: 100%; aspect-ratio: 16 / 7; min-height: 280px; }
.chart-wrap svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-empty { height: 100%; display: grid; place-items: center; color: var(--muted); }

.segmented { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line-strong); border-radius: 5px; overflow: hidden; }
.segmented button { min-height: 34px; padding: 0 10px; border: 0; border-right: 1px solid var(--line-strong); background: #fff; color: var(--muted); cursor: pointer; white-space: nowrap; }
.segmented button:last-child { border-right: 0; }
.segmented button.active { background: #173f50; color: #fff; }

.table-shell { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 5px; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 10px 11px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
th { position: sticky; top: 0; z-index: 1; background: #f2f5f6; color: #53646e; font-size: 11px; font-weight: 700; }
th:first-child, td:first-child { text-align: left; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f7fafb; }
td { font-size: 12px; }
.selected-row td { background: #eef7fa; }
.room-link { padding: 0; border: 0; background: transparent; color: var(--blue); font-weight: 650; cursor: pointer; }
.detail-table th, .detail-table td { padding: 9px 10px; }
.source-stamp { color: var(--muted); font-size: 11px; }
.metric-positive { color: var(--teal); font-weight: 650; }
.metric-warning { color: var(--gold); font-weight: 650; }
.metric-risk { color: var(--coral); font-weight: 650; }
.metric-muted { color: #88959d; }
.status-chip { display: inline-flex; min-height: 24px; align-items: center; padding: 0 7px; border-radius: 4px; background: #eef2f4; color: #52636d; font-size: 10px; }
.status-chip.verified { background: var(--green-soft); color: #08715f; }
.pressure-row td { background: #fff9ed; }
.compact-toggle { gap: 7px; color: var(--muted); font-size: 12px; }
.compact-toggle input { width: 16px; height: 16px; accent-color: var(--blue); }

.method-band { margin-top: 14px; padding: 13px 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.65; }
.method-band p { margin: 3px 0; }
.method-band b { color: var(--ink); }

.chart-tooltip {
  position: fixed;
  z-index: 20;
  max-width: 260px;
  padding: 9px 10px;
  border-radius: 5px;
  background: #102934;
  color: #fff;
  box-shadow: 0 8px 20px rgba(16, 41, 52, 0.2);
  pointer-events: none;
  font-size: 11px;
  line-height: 1.55;
}
.chart-tooltip b { display: block; margin-bottom: 3px; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(360px, calc(100vw - 36px));
  padding: 11px 13px;
  border-radius: 5px;
  background: #102934;
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.loading svg { animation: spin 0.9s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .analysis-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app-header { min-height: 62px; padding: 10px 14px; }
  .brand-mark { display: none; }
  .brand-block h1 { font-size: 15px; }
  .header-actions { gap: 5px; }
  .icon-button { width: 34px; height: 34px; }
  .section-nav { padding: 0 10px; overflow-x: auto; }
  main { width: min(100% - 20px, 1480px); padding-top: 12px; }
  .filter-band { grid-template-columns: 1fr 1fr; gap: 10px; }
  .room-filter { grid-column: 1 / -1; grid-row: auto; }
  .period-stamp { grid-column: 1 / -1; justify-self: start; text-align: left; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-card { min-height: 96px; padding: 12px; }
  .kpi-card b { font-size: 21px; }
  .analysis-grid { grid-template-columns: 1fr; }
  .analysis-band, .panel { padding: 12px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 9px; }
  .section-heading .legend { justify-content: flex-start; }
  .chart-wrap { min-height: 250px; aspect-ratio: 4 / 3; }
  .segmented { width: 100%; }
  .segmented button { padding: 0 6px; font-size: 11px; }
  .data-alert { align-items: flex-start; }
}

@media (max-width: 420px) {
  .brand-block p { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-card b { font-size: 19px; }
  .filter-band { grid-template-columns: 1fr; }
  .room-filter, .period-stamp { grid-column: 1; }
}
