:root {
  --bg: #eef3f6;
  --ink: #172026;
  --muted: #5f6f7a;
  --panel: #ffffff;
  --line: #d7e0e6;
  --blue: #2563eb;
  --cyan: #0891b2;
  --green: #16a34a;
  --amber: #d97706;
  --orange: #ea580c;
  --red: #dc2626;
  --navy: #23313c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

body.intro-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(15, 24, 32, 0.94);
}

.intro-overlay.is-hidden {
  display: none;
}

.intro-content {
  width: min(1120px, 100%);
  max-height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
  border: 1px solid rgba(196, 224, 235, 0.22);
  border-radius: 8px;
  background: #f8fbfc;
  padding: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
}

.intro-copy {
  display: grid;
  gap: 6px;
}

.intro-kicker {
  margin: 0;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.intro-copy h2 {
  margin: 0;
  color: #14212a;
  font-size: 28px;
  line-height: 1.24;
  letter-spacing: 0;
}

.intro-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.intro-video-frame {
  min-height: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #0c141b;
}

.intro-video-frame video {
  width: 100%;
  height: 100%;
  max-height: min(63vh, 640px);
  display: block;
  object-fit: contain;
  background: #0c141b;
}

.intro-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.intro-primary,
.intro-secondary,
.demo-button {
  min-height: 38px;
  padding: 0 14px;
}

.intro-primary {
  color: #ffffff;
  background: var(--cyan);
}

.intro-secondary,
.demo-button,
.visit-chip {
  border: 1px solid var(--line);
  color: #21313b;
  background: #ffffff;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.side-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 22px;
  background: var(--navy);
  color: #f7fbff;
  overflow-y: auto;
}

.brand {
  display: flex;
  gap: 13px;
  align-items: center;
  margin-bottom: 30px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border: 2px solid #8bd5e4;
  border-radius: 8px;
  position: relative;
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  background: #facc15;
}

.brand-mark::before {
  top: 12px;
  transform: rotate(34deg);
}

.brand-mark::after {
  bottom: 12px;
  transform: rotate(-34deg);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

.brand p {
  margin: 4px 0 0;
  color: #c7d7e1;
  font-size: 13px;
}

.control-group {
  display: grid;
  gap: 8px;
  margin-bottom: 19px;
}

.control-group label,
.switch-line {
  color: #dae8ef;
  font-size: 13px;
}

input[type="file"],
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
  padding: 9px 10px;
}

select option {
  color: #172026;
}

input[type="range"] {
  accent-color: #22d3ee;
}

.data-status {
  color: #a9bdc9;
  font-size: 12px;
  word-break: break-word;
}

.switch-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 2px 0 20px;
}

.switch-line input {
  width: 17px;
  height: 17px;
  accent-color: #22c55e;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

button.primary {
  color: white;
  background: var(--cyan);
}

button.secondary {
  color: white;
  background: rgba(255, 255, 255, 0.15);
}

.dataset-button {
  width: 100%;
  color: #10232c;
  background: #bfeaf2;
}

.dataset-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.dataset-control {
  margin-bottom: 24px;
}

.dataset-meta {
  min-height: 34px;
  color: #a9bdc9;
  font-size: 12px;
  line-height: 1.45;
}

.regional-card {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  margin-bottom: 22px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.regional-title {
  margin-bottom: 7px;
  color: #eaf7fb;
  font-size: 13px;
  font-weight: 700;
}

.regional-context {
  color: #b9ced9;
  font-size: 12px;
  line-height: 1.55;
}

.innovation-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.innovation-list span {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: #e5f2f7;
  padding: 5px 9px;
  font-size: 12px;
}

.main-panel {
  padding: 28px;
  min-width: 0;
}

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

.topbar-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: 0;
}

.time-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  padding: 9px 12px;
  font-size: 13px;
}

.visit-chip {
  flex: 0 0 auto;
  border-radius: 8px;
  color: #12606d;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
}

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

.metric-tile,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric-tile {
  padding: 16px;
}

.metric-tile span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-tile strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.16fr) minmax(320px, 0.84fr);
  gap: 16px;
}

.network-panel {
  grid-row: span 2;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.panel h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.subtle-label {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

canvas {
  width: 100%;
  display: block;
}

#networkCanvas {
  aspect-ratio: 780 / 470;
}

#lineCanvas,
#barCanvas {
  aspect-ratio: 780 / 310;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.state-free {
  background: var(--green);
}

.state-light {
  background: var(--amber);
}

.state-moderate {
  background: var(--orange);
}

.state-severe {
  background: var(--red);
}

.bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 16px;
  margin-top: 16px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid #edf1f4;
  padding: 10px 8px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-width: 74px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 8px;
  color: white;
  font-size: 12px;
}

.status-pill.free {
  background: var(--green);
}

.status-pill.light {
  background: var(--amber);
}

.status-pill.moderate {
  background: var(--orange);
}

.status-pill.severe {
  background: var(--red);
}

.report-panel p {
  min-height: 116px;
  margin: 0;
  color: #33414b;
  font-size: 14px;
  line-height: 1.7;
}

.report-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 12px;
}

.report-stats span {
  border-radius: 999px;
  background: #eef7f8;
  color: #12606d;
  padding: 6px 10px;
  font-size: 12px;
}

.experiment-note {
  border-left: 3px solid var(--cyan);
  margin-top: 14px;
  padding-left: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.assistant-panel {
  margin-top: 16px;
}

.assistant-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.assistant-actions button {
  border: 1px solid var(--line);
  background: #f4f8fa;
  color: #24323b;
  min-height: 34px;
  padding: 0 12px;
}

.assistant-actions button.active {
  border-color: var(--cyan);
  background: #e8f8fb;
  color: #075866;
}

.assistant-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  gap: 10px;
  align-items: stretch;
}

.assistant-input-row textarea {
  width: 100%;
  resize: vertical;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fbfdfe;
  line-height: 1.55;
}

.assistant-output {
  min-height: 128px;
  margin-top: 13px;
  border: 1px solid #dce7ec;
  border-radius: 8px;
  background: #f8fbfc;
  padding: 14px;
  color: #26343d;
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: relative;
    height: auto;
  }

  .dashboard-grid,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .network-panel {
    grid-row: auto;
  }
}

@media (max-width: 720px) {
  .intro-overlay {
    padding: 12px;
  }

  .intro-content {
    max-height: calc(100vh - 24px);
    padding: 14px;
  }

  .intro-copy h2 {
    font-size: 21px;
  }

  .intro-video-frame video {
    max-height: 52vh;
  }

  .intro-actions,
  .topbar-actions {
    width: 100%;
  }

  .intro-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .main-panel {
    padding: 18px;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar h2 {
    font-size: 21px;
  }

  .topbar-actions {
    justify-content: space-between;
  }

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

  .metric-tile strong {
    font-size: 25px;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .assistant-input-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .button-row {
    grid-template-columns: 1fr;
  }
}
