/* China Auto City Atlas — theme tokens + components (committed Tailwind companion). */

:root {
  --bg-base: #f6f8fb;
  --bg-shell: rgba(255, 255, 255, 0.92);
  --bg-surface: #ffffff;
  --bg-elev: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #64748b;
  --accent: #0d9488;
  --accent-strong: #0f766e;
  --accent-soft: rgba(13, 148, 136, 0.12);

  --chart-1: #0f766e; --chart-2: #0891b2; --chart-3: #6366f1; --chart-4: #f59e0b;
  --chart-5: #ec4899; --chart-6: #22c55e; --chart-7: #8b5cf6; --chart-8: #ef4444;

  --map-land: #e8edf4;
  --map-border: #cbd5e1;
}

html.dark {
  --bg-base: #0b1220;
  --bg-shell: rgba(15, 23, 42, 0.88);
  --bg-surface: #131d30;
  --bg-elev: #1e293b;
  --border: #273449;
  --border-strong: #3b4d66;
  --text: #f1f5f9;
  --text-muted: #b4c0d3;
  --text-faint: #7c8aa3;
  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --accent-soft: rgba(45, 212, 191, 0.14);

  --map-land: #1c2740;
  --map-border: #34415c;
}

html, body { background: var(--bg-base); }
body { color: var(--text); font-family: Inter, system-ui, sans-serif; }

.bg-base { background: var(--bg-base); }
.bg-shell { background: var(--bg-shell); }
.text-base { color: var(--text); }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.border-base { border-color: var(--border); }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  padding: 0.5rem 1rem; background: var(--accent-strong); color: #fff;
  border-radius: 0 0 0.5rem 0.5rem; font-size: 0.85rem; text-decoration: none;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.nav-link {
  padding: 0.35rem 0.6rem; border-radius: 0.5rem; color: var(--text-muted);
  white-space: nowrap; transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--bg-elev); color: var(--text); }
.auto-nav {
  min-height: 3.5rem; display: grid; align-items: center; gap: 0.5rem 0.75rem;
  grid-template-columns: auto minmax(16rem, 1fr) minmax(10rem, 18rem) auto;
  grid-template-areas: "brand links search controls";
}
.auto-nav-brand { grid-area: brand; display: flex; align-items: center; gap: 0.75rem; white-space: nowrap; }
.auto-nav-links {
  grid-area: links; display: flex; align-items: center; gap: 0.25rem;
  min-width: 0; overflow-x: auto;
}
.auto-nav-search { grid-area: search; min-width: 0; }
.auto-nav-controls { grid-area: controls; display: flex; align-items: center; gap: 0.5rem; }
#lang-toggle, #theme-toggle {
  width: 2.25rem; height: 2.25rem; display: flex; align-items: center; justify-content: center;
  flex: none; border: 1px solid var(--border); border-radius: 0.5rem;
  background: var(--bg-surface); color: var(--text-muted); cursor: pointer;
}
.nav-scroll {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent 100%);
  mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent 100%);
}

.btn-ghost {
  padding: 0.35rem 0.7rem; border-radius: 0.5rem; font-size: 0.8rem;
  border: 1px solid var(--border); color: var(--text-muted); background: transparent;
  transition: all .15s; cursor: pointer;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost:disabled { opacity: 0.45; cursor: not-allowed; }

.section-title { font-size: 1.4rem; font-weight: 600; letter-spacing: -0.01em; }
.panel {
  border: 1px solid var(--border); border-radius: 0.85rem; background: var(--bg-surface);
  overflow: hidden;
}
.panel-head {
  padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--border);
  font-size: 0.85rem; font-weight: 500; color: var(--text-muted);
}
.chart-h-md { width: 100%; height: 320px; }
.chart-h-lg { width: 100%; height: 520px; }
.chart-h-graph { width: 100%; height: 560px; }

.kpi-card {
  border: 1px solid var(--border); border-radius: 0.85rem; background: var(--bg-surface);
  padding: 0.9rem 1rem;
}
.kpi-num { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; color: var(--accent-strong); }
.kpi-label { margin-top: 0.15rem; font-size: 0.72rem; color: var(--text-faint); }

.select {
  padding: 0.35rem 0.6rem; border-radius: 0.5rem; font-size: 0.8rem;
  border: 1px solid var(--border); background: var(--bg-surface); color: var(--text);
}
.select:focus { outline: none; border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 0.5rem; overflow: hidden; }
.seg button {
  padding: 0.35rem 0.7rem; font-size: 0.78rem; background: transparent; color: var(--text-muted);
  border: none; border-right: 1px solid var(--border); cursor: pointer; white-space: nowrap;
}
.seg button:last-child { border-right: none; }
.seg button.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.list-scroll {
  max-height: min(72vh, 44rem);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 1024px) {
  .list-scroll { max-height: min(80vh, 52rem); }
}
.data-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; min-width: 640px; }
.list-scroll .data-table { min-width: 52rem; }
.data-table th, .data-table td { padding: 0.5rem 0.7rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.list-scroll .data-table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-surface);
  box-shadow: 0 1px 0 var(--border);
}
.data-table th { color: var(--text-faint); font-weight: 500; cursor: pointer; user-select: none; }
.data-table th:hover { color: var(--accent); }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: var(--accent-soft); }
.data-table tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.field-status { color: var(--text-faint); font-size: 0.74rem; }
.field-status-not_applicable { opacity: 0.82; }
.field-status-not_separately_listed { color: var(--text-muted); }
.scope-note { font-size: 0.7rem; }
.field-context { display: block; max-width: 20rem; margin-top: 0.12rem; color: var(--text-faint); font-size: 0.68rem; line-height: 1.3; white-space: normal; }
.evidence-link { display: inline-flex; min-width: 1.35rem; min-height: 1.35rem; align-items: center; justify-content: center; border-radius: 999px; }
.evidence-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.data-table td.source-scope-cell { min-width: 18rem; max-width: 30rem; white-space: normal; line-height: 1.45; }
.data-table th[role="button"]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.type-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.type-chip {
  padding: 0.22rem 0.65rem; border-radius: 999px; font-size: 0.74rem;
  border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-muted);
  cursor: pointer; transition: border-color .12s, background .12s, color .12s;
}
.type-chip:hover { border-color: var(--accent); color: var(--text); }
.type-chip.active {
  border-color: var(--accent); background: var(--accent-soft);
  color: var(--accent-strong); font-weight: 600;
}

.map-legend { display: flex; flex-wrap: wrap; gap: 0.75rem; padding: 0.6rem 0.9rem; border-top: 1px solid var(--border); font-size: 0.72rem; color: var(--text-muted); }
.map-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.map-legend .legend-sep { display: inline-block; width: 1px; height: 0.9rem; background: var(--border); margin: 0 0.15rem; vertical-align: middle; }
.map-legend .size-legend-title, .map-legend .size-legend-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.map-legend .size-legend-dot { display: inline-block; flex: none; border-radius: 50%; background: var(--chart-1); border: 1px solid var(--text-muted); box-sizing: border-box; }
.map-legend .size-legend-dot.is-unknown { width: 10px; height: 10px; background: transparent; border-width: 1.5px; }
.map-legend .size-legend-note, .map-legend .size-legend-categories { flex-basis: 100%; }
.map-legend .size-legend-categories { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.seg button:disabled { opacity: 0.45; cursor: not-allowed; }

.badge { display: inline-block; padding: 0.08rem 0.45rem; border-radius: 0.4rem; font-size: 0.66rem; font-weight: 500; line-height: 1.5; }
.badge-tier-core { background: rgba(15,118,110,.15); color: #0f766e; }
.badge-tier-specialist { background: rgba(99,102,241,.15); color: #6366f1; }
html.dark .badge-tier-core { color: #2dd4bf; }
html.dark .badge-tier-specialist { color: #a5b4fc; }

.badge-rt-oem_manufacturing { background: rgba(15,118,110,.15); color: #0f766e; }
.badge-rt-headquarters { background: rgba(99,102,241,.15); color: #6366f1; }
.badge-rt-rd_design { background: rgba(8,145,178,.15); color: #0891b2; }
.badge-rt-autonomous_driving { background: rgba(139,92,246,.15); color: #7c3aed; }
.badge-rt-auto_software { background: rgba(56,189,248,.15); color: #0284c7; }
.badge-rt-chips { background: rgba(245,158,11,.15); color: #b45309; }
.badge-rt-battery { background: rgba(34,197,94,.15); color: #16a34a; }
.badge-rt-auto_electronics { background: rgba(236,72,153,.15); color: #db2777; }
.badge-rt-parts { background: rgba(100,116,139,.16); color: #475569; }
.badge-rt-testing { background: rgba(168,85,247,.15); color: #9333ea; }
.badge-rt-higher_education { background: rgba(14,165,233,.15); color: #0369a1; }
.badge-rt-auto_media { background: rgba(244,63,94,.13); color: #be123c; }
.badge-rt-expo_culture { background: rgba(234,179,8,.15); color: #a16207; }
.badge-rt-export_logistics { background: rgba(20,184,166,.15); color: #0d9488; }
.badge-rt-auto_history { background: rgba(120,113,108,.15); color: #57534e; }
html.dark .badge-rt-parts { color: #cbd5e1; }
html.dark .badge-rt-auto_history { color: #d6d3d1; }

.badge-grade-A { background: rgba(34,197,94,.16); color: #16a34a; }
.badge-grade-B { background: rgba(56,189,248,.16); color: #0284c7; }
.badge-grade-C { background: rgba(245,158,11,.16); color: #b45309; }
.badge-grade-D { background: rgba(239,68,68,.15); color: #dc2626; }
html.dark .badge-grade-A { color: #4ade80; }
html.dark .badge-grade-B { color: #38bdf8; }
html.dark .badge-grade-C { color: #fbbf24; }
html.dark .badge-grade-D { color: #f87171; }

.cluster-card {
  border: 1px solid var(--border); border-radius: 0.85rem; background: var(--bg-surface);
  padding: 0.9rem 1rem; cursor: pointer; transition: border-color .15s;
}
.cluster-card:hover { border-color: var(--accent); }
.cluster-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  background: var(--accent-soft);
}
.cluster-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cluster-card-hint { margin-top: 0.45rem; font-size: 0.72rem; color: var(--accent); }
.map-legend .legend-cluster {
  border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0; font: inherit;
}
.map-legend .legend-cluster:hover, .map-legend .legend-cluster.is-on { color: var(--accent-strong); }
.map-legend .legend-cluster:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cluster-card h3 { font-size: 0.95rem; font-weight: 600; }
.cluster-card p { margin-top: 0.35rem; font-size: 0.8rem; color: var(--text-muted); line-height: 1.45; }

.list-card {
  border: 1px solid var(--border); border-radius: 0.7rem; background: var(--bg-surface);
  padding: 0.75rem 0.9rem; font-size: 0.82rem; cursor: pointer; transition: border-color .15s;
}
.list-card:hover { border-color: var(--accent); }
.list-card + .list-card { margin-top: 0.5rem; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center;
  padding: 4vh 1rem; overflow-y: auto;
}
body.modal-open { overflow: hidden; }
.modal-panel {
  position: relative; width: 100%; max-width: 880px; background: var(--bg-surface);
  border: 1px solid var(--border); border-radius: 1rem; padding: 1.25rem 1.4rem 1.6rem;
}
.modal-close {
  position: absolute; top: 0.6rem; right: 0.9rem; font-size: 1.5rem; line-height: 1;
  color: var(--text-faint); background: none; border: none; cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal-tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.9rem; border-bottom: 1px solid var(--border); }
.modal-tab-btn {
  padding: 0.4rem 0.7rem; font-size: 0.8rem; color: var(--text-muted);
  border: none; background: none; border-bottom: 2px solid transparent; cursor: pointer;
}
.modal-tab-btn.active { color: var(--accent-strong); border-bottom-color: var(--accent); font-weight: 600; }
.modal-body { margin-top: 0.9rem; font-size: 0.85rem; line-height: 1.55; }
.modal-body h4 { font-size: 0.78rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; margin: 0.9rem 0 0.35rem; }
.modal-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 0.9rem; }
.kv dt { color: var(--text-faint); }
.chip { display: inline-block; padding: 0.1rem 0.5rem; margin: 0.1rem; border-radius: 0.4rem; background: var(--bg-elev); font-size: 0.72rem; }
.chip-link { border: 1px solid var(--border); color: var(--accent); cursor: pointer; transition: background .12s, border-color .12s; }
.chip-link:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.warn-box {
  border: 1px solid rgba(245,158,11,.35); background: rgba(245,158,11,.08);
  border-radius: 0.7rem; padding: 0.75rem 0.9rem; font-size: 0.82rem; color: var(--text-muted);
}
.runtime-warning-shell {
  max-width: 80rem; margin: 1rem auto 0; padding: 0.8rem 1rem;
  border: 1px solid rgba(245,158,11,.55); border-radius: 0.7rem;
  background: #fffbeb; color: #78350f; font-size: 0.82rem; line-height: 1.45;
}
html.dark .runtime-warning-shell { background: #2c210b; color: #fde68a; }
.runtime-warning-shell strong { display: block; color: inherit; }
.runtime-warning-shell p { margin: 0.2rem 0 0; }
.runtime-chart-fallback {
  box-sizing: border-box; min-height: 100%; margin: 0; padding: 2rem 1rem;
  display: flex; align-items: center; justify-content: center; text-align: center;
  color: var(--text-muted); background: var(--bg-elev); font-size: 0.85rem;
}
.loading { color: var(--text-faint); font-size: 0.85rem; padding: 1.5rem; text-align: center; }
.hidden { display: none !important; }
.chip-link {
  display: inline-block; padding: 0.1rem 0.5rem; margin: 0.1rem; border-radius: 0.4rem;
  background: var(--bg-elev); font-size: 0.72rem;
}

.search-wrap { position: relative; width: 100%; }
.search-input {
  width: 100%; height: 2.15rem; padding: 0 0.7rem; font-size: 0.8rem;
  border: 1px solid var(--border); border-radius: 0.55rem;
  background: var(--bg-surface); color: var(--text);
}
.search-input:focus { outline: none; border-color: var(--accent); }
.search-pop {
  position: absolute; top: calc(100% + 0.35rem); right: 0; left: 0; z-index: 50;
  min-width: 16rem; max-height: 22rem; overflow-y: auto;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: 0.7rem;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
}
html.dark .search-pop { box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35); }
.search-pop-group {
  padding: 0.35rem 0.7rem 0.15rem; font-size: 0.68rem; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.search-pop-item {
  display: block; width: 100%; text-align: left; padding: 0.45rem 0.75rem;
  font-size: 0.82rem; color: var(--text); background: none; border: none; cursor: pointer;
}
.search-pop-item:hover, .search-pop-item[aria-selected="true"] { background: var(--accent-soft); }
.search-pop-empty { padding: 0.7rem 0.8rem; font-size: 0.8rem; color: var(--text-faint); }
@media (max-width: 900px) {
  .auto-nav {
    padding-top: 0.4rem; padding-bottom: 0.4rem;
    grid-template-columns: minmax(0, 1fr) minmax(10rem, 16rem) auto;
    grid-template-areas: "brand search controls" "links links links";
  }
  .auto-nav-links { padding-bottom: 0.1rem; }
  .nav-scroll {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent 100%);
    mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent 100%);
  }
  section { scroll-margin-top: 7.5rem; }
}
@media (max-width: 520px) {
  .auto-nav {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand controls" "links links" "search search";
  }
  .auto-nav-brand { gap: 0.45rem; }
  .auto-nav-brand-name { display: none; }
  .auto-nav-search, .search-input { width: 100%; }
  .search-pop { min-width: 0; width: 100%; right: auto; }
  .runtime-warning-shell { margin: 0.75rem 1rem 0; }
  .modal-backdrop { padding: 0.5rem; }
  .modal-panel { padding: 1rem 1rem 1.25rem; border-radius: 0.75rem; }
}

.qrost-touch-toggle {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  margin: 0.5rem 0 0;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--accent);
  border-radius: 0.65rem;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
}
.qrost-touch-toggle[hidden] { display: none !important; }
.qrost-touch-toggle[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}
.is-touch-locked { touch-action: pan-y; }
.is-touch-unlocked { touch-action: none; }
.table-wrap, .list-scroll, .auto-nav-links, .nav-scroll {
  overscroll-behavior-x: contain;
}
.auto-nav-links, .nav-scroll {
  overflow-x: auto;
  overflow-y: hidden;
}
@media (max-width: 900px), (pointer: coarse), (any-pointer: coarse) {
  .list-scroll {
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
  }
  .chart-h-lg { height: min(52dvh, 22rem); }
  .chart-h-graph { height: min(56dvh, 24rem); }
}
