:root {
  color-scheme: light;
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f0f2ee;
  --text: #1e2520;
  --muted: #6e756f;
  --border: #dfe3de;
  --accent: #b8322a;
  --accent-soft: #f7e7e4;
  --positive: #237a57;
  --negative: #c23a32;
  --amber: #ba7a1b;
  --teal: #247c7a;
  --shadow: 0 8px 24px rgba(28, 38, 30, .06);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171a18;
  --surface: #202421;
  --surface-2: #282d29;
  --text: #edf0ec;
  --muted: #aab2ab;
  --border: #363c37;
  --accent: #e0695e;
  --accent-soft: #3b2927;
  --positive: #66bd98;
  --negative: #ed7d73;
  --amber: #d9a64c;
  --teal: #63b8b4;
  --shadow: 0 8px 24px rgba(0, 0, 0, .2);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif; letter-spacing: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; }
.topbar { min-height: 68px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: var(--accent); color: white; border-radius: 7px; font-weight: 700; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; font-weight: 600; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.industry-switch { display: inline-flex; flex: 0 0 auto; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; }
.industry-option { min-height: 34px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 5px; color: var(--muted); font-size: 12px; text-decoration: none; white-space: nowrap; }
.industry-option:hover { color: var(--text); }
.industry-option.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.industry-option svg { width: 15px; height: 15px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.sync-state { display: inline-flex; align-items: center; gap: 7px; margin-right: 6px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--positive); box-shadow: 0 0 0 3px color-mix(in srgb, var(--positive) 15%, transparent); }
.icon-button, .primary-button, .ghost-button { border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; border-radius: 6px; background: var(--surface); }
.icon-button { width: 36px; padding: 0; }
.primary-button { padding: 0 14px; background: var(--text); border-color: var(--text); color: var(--surface); }
.ghost-button { padding: 0 12px; }
.icon-button:hover, .ghost-button:hover { background: var(--surface-2); }
.primary-button:hover { opacity: .88; }
.icon-button svg, .primary-button svg, .ghost-button svg, .tab svg { width: 16px; height: 16px; }
main { max-width: 1540px; margin: 0 auto; padding: 26px 28px 44px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 7px; color: var(--accent); font-size: 11px; font-weight: 600; }
h1 { margin: 0; font-size: clamp(28px, 4vw, 42px); line-height: 1.15; font-weight: 600; }
.page-head p:not(.eyebrow) { margin: 8px 0 0; color: var(--muted); }
.headline-number { min-width: 190px; text-align: right; }
.headline-number span, .headline-number em { display: block; color: var(--muted); font-size: 12px; font-style: normal; }
.headline-number strong { display: block; margin: 4px 0; font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }
.section-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; padding: 12px 16px; border: 0; background: transparent; color: var(--muted); }
.tab::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px; background: transparent; }
.tab.active { color: var(--text); font-weight: 600; }
.tab.active::after { background: var(--accent); }
.filter-band { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; padding: 16px 0 14px; }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 7px; }
.segmented button { border: 0; padding: 7px 11px; border-radius: 5px; background: transparent; color: var(--muted); font-size: 12px; white-space: nowrap; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.field { display: grid; gap: 4px; color: var(--muted); font-size: 11px; }
.field input, .field select, .compact-select select { min-height: 36px; padding: 0 32px 0 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.selector-field select { min-width: 150px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 4px 0 14px; }
.metric { min-width: 0; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; box-shadow: var(--shadow); }
.metric span, .metric small { display: block; color: var(--muted); }
.metric span { font-size: 12px; }
.metric strong { display: block; margin: 9px 0 7px; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric small { min-height: 16px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.positive { color: var(--positive) !important; }
.negative { color: var(--negative) !important; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 14px; }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; box-shadow: var(--shadow); overflow: hidden; }
.panel-head { min-height: 70px; padding: 16px 18px 10px; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.unit { color: var(--muted); font-size: 11px; white-space: nowrap; }
.panel-wide, .panel-table { grid-column: 1 / -1; }
.chart { width: 100%; }
.chart-main { height: 390px; }
.chart-side { height: 390px; }
.chart-heatmap { height: 300px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 12px 18px; border-top: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; background: var(--surface-2); }
td.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.compact-select { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.compact-select select { min-height: 32px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 14px; padding: 14px; border-top: 1px solid var(--border); }
.pagination span { color: var(--muted); font-size: 12px; }
.chart-modal { position: fixed; z-index: 20; inset: 0; padding: 50px 4vw 4vw; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(8px); }
.modal-close { position: absolute; top: 12px; right: 18px; }
.modal-chart { width: 100%; height: calc(100vh - 80px); background: var(--surface); border: 1px solid var(--border); border-radius: 7px; }
[hidden] { display: none !important; }

@media (max-width: 960px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .panel-wide, .panel-table { grid-column: auto; }
  .panel-main, .panel-side { grid-column: auto; }
}

@media (max-width: 640px) {
  .topbar { min-height: 60px; padding: 0 14px; gap: 8px; }
  .brand-copy { display: none; }
  .brand { gap: 0; }
  .brand-mark { width: 34px; height: 34px; }
  .brand small, .sync-state, .primary-button span { display: none; }
  .industry-option { min-height: 32px; padding: 0 8px; gap: 5px; font-size: 11px; }
  .industry-option span { font-size: 0; }
  .industry-option span::after { content: attr(data-short); font-size: 11px; }
  .industry-option svg { width: 14px; height: 14px; }
  .top-actions { gap: 6px; }
  .primary-button { width: 36px; padding: 0; }
  main { padding: 20px 14px 32px; }
  .page-head { align-items: flex-start; }
  .page-head p:not(.eyebrow), .headline-number span { display: none; }
  .headline-number { min-width: auto; }
  .headline-number strong { font-size: 22px; }
  .headline-number em { max-width: 110px; }
  .section-tabs { margin-left: -14px; margin-right: -14px; padding: 0 10px; }
  .tab { padding: 11px 10px; font-size: 12px; }
  .filter-band { display: grid; grid-template-columns: 1fr 1fr; }
  .segmented { grid-column: 1 / -1; overflow-x: auto; }
  .field input, .field select { width: 100%; min-width: 0; }
  .selector-field { grid-column: 1 / -1; }
  #resetZoom { grid-column: 1 / -1; }
  .metrics { gap: 8px; }
  .metric { padding: 13px; }
  .metric strong { font-size: 19px; }
  .chart-main, .chart-side { height: 320px; }
  .chart-heatmap { height: 340px; }
  .panel-head { min-height: 64px; padding: 14px 14px 8px; }
  th, td { padding: 11px 14px; }
  .compact-select span { display: none; }
}
