/* ══════════════════════════════════
   Variables
══════════════════════════════════ */
:root {
  --ink:    #151515;
  --muted:  #6b6560;
  --line:   rgba(21,21,21,0.1);
  --paper:  #fffcf5;
  --green:  #246b52;
  --gold:   #b87526;
  --red:    #b94336;
  --blue:   #2e6685;
  --sidebar-w: 210px;
  --bg:
    linear-gradient(90deg,  rgba(21,21,21,0.03) 1px, transparent 1px),
    linear-gradient(         rgba(21,21,21,0.03) 1px, transparent 1px),
    linear-gradient(135deg, #fbf2df 0%, #f1e7d2 55%, #e5eadf 100%);
  --bg-size: 34px 34px, 34px 34px, auto;
}

*  { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Avenir Next", "Hiragino Sans", "PingFang SC", sans-serif;
  color: var(--ink);
  background: var(--bg);
  background-size: var(--bg-size);
  min-height: 100vh;
}

/* ══════════════════════════════════
   Plain fallback when CDN libraries fail
══════════════════════════════════ */
.plain-app {
  display: block;
  min-height: 100vh;
  padding: 32px;
}

.plain-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
  padding: 28px;
  border-radius: 24px;
  background: rgba(21,18,12,0.92);
  color: #f5e8d4;
}

.plain-hero h1 {
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.05em;
  margin-bottom: 10px;
}

.plain-hero p {
  color: rgba(245,232,212,0.72);
}

.plain-hero button {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: #c9822b;
  color: white;
  font-weight: 800;
  cursor: pointer;
}

.plain-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.4fr;
  gap: 18px;
}

.plain-panel {
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,252,242,0.9);
  box-shadow: 0 12px 40px rgba(55,46,25,0.08);
}

.plain-panel h2 {
  margin-bottom: 12px;
  font-size: 20px;
}

.plain-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.plain-toolbar label {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

.plain-toolbar select {
  margin-left: 6px;
  min-width: 130px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

.plain-status,
.plain-muted {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.plain-table-wrap {
  max-height: 650px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.plain-app table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255,255,255,0.55);
}

.plain-app th,
.plain-app td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(21,21,21,0.08);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

.plain-app th {
  position: sticky;
  top: 0;
  background: #f7edd9;
  z-index: 1;
  font-size: 12px;
  color: var(--muted);
}

.plain-empty {
  color: var(--muted);
  text-align: center !important;
}

/* ══════════════════════════════════
   App layout (sidebar + main)
══════════════════════════════════ */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: rgba(21,18,12,0.94);
  backdrop-filter: blur(20px);
  color: #e8dcc8;
  overflow: hidden;
  z-index: 10;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.logo-mark {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #c9822b, #b94336);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 18px; color: #fff; flex: 0 0 36px;
}

.logo-text {
  font-size: 13px; font-weight: 800;
  line-height: 1.3; color: #f0e8d8;
  letter-spacing: 0.01em;
}

.nav-list { list-style: none; padding: 10px 0; flex: 1; }

.nav-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  cursor: pointer;
  border-radius: 0;
  font-size: 14px;
  font-weight: 600;
  color: rgba(232,220,200,0.65);
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.nav-list li:hover { color: #f0e8d8; background: rgba(255,255,255,0.06); }
.nav-list li.active {
  color: #f5dfa0;
  background: rgba(255,255,255,0.09);
  border-left-color: #c9822b;
}

.nav-icon  { font-size: 16px; flex: 0 0 20px; }
.nav-label { flex: 1; }

.sidebar-footer {
  padding: 14px 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-label { font-size: 11px; color: rgba(232,220,200,0.4); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }

.pipeline-dot {
  font-size: 12px;
  color: rgba(232,220,200,0.55);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Main content area ── */
.main {
  padding: 36px 40px 64px;
  min-height: 100vh;
  overflow-y: auto;
}

/* ══════════════════════════════════
   Page common
══════════════════════════════════ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.page-header h2 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
}

.page-sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 15px;
}

.filter-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ══════════════════════════════════
   Panels
══════════════════════════════════ */
.panel {
  background: rgba(255,252,242,0.88);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px 24px;
  box-shadow: 0 12px 40px rgba(55,46,25,0.08);
  backdrop-filter: blur(12px);
}

.mb16 { margin-bottom: 16px; }
.mb20 { margin-bottom: 20px; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.panel-head h3 { font-size: 18px; font-weight: 700; }

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  background: rgba(36,107,82,0.1);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
}

/* ══════════════════════════════════
   Colors
══════════════════════════════════ */
.c-red   { color: var(--red);   }
.c-gold  { color: var(--gold);  }
.c-green { color: var(--green); }
.c-blue  { color: var(--blue);  }
.muted   { color: var(--muted); }
.small   { font-size: 12px; }

/* ══════════════════════════════════
   Progress bar
══════════════════════════════════ */
.prog-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(21,21,21,0.08);
  margin-bottom: 4px;
}
.prog-seg          { height: 100%; transition: width 0.3s; }
.seg-active  { background: #2f6f4e; }
.seg-passive { background: #c9822b; }
.seg-blind   { background: #c94b3c; }

/* ══════════════════════════════════
   Stat cards (country page)
══════════════════════════════════ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-radius: 20px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  background: rgba(255,252,242,0.7);
  box-shadow: 0 8px 24px rgba(55,46,25,0.07);
}
.stat-card:hover { box-shadow: 0 12px 32px rgba(55,46,25,0.12); }
.stat-card.selected { border-color: currentColor; }

.c-red-bg   { box-shadow: 0 4px 20px rgba(185,67,54,0.12); }
.c-gold-bg  { box-shadow: 0 4px 20px rgba(184,117,38,0.12); }
.c-green-bg { box-shadow: 0 4px 20px rgba(36,107,82,0.12); }

.stat-emoji { font-size: 26px; flex: 0 0 auto; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.stat-num   { font-size: 34px; font-weight: 800; line-height: 1.1; letter-spacing: -0.04em; }

/* ══════════════════════════════════
   Tab bar
══════════════════════════════════ */
.tab-bar { display: flex; gap: 6px; flex-wrap: wrap; }

.tab {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}
.tab:hover { border-color: rgba(21,21,21,0.3); color: var(--ink); }
.tab.active              { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab-blind.active        { background: var(--red);   border-color: var(--red);   color: #fff; }
.tab-passive.active      { background: var(--gold);  border-color: var(--gold);  color: #fff; }
.tab-active.active       { background: var(--green); border-color: var(--green); color: #fff; }

.tab-cnt {
  display: inline-block;
  margin-left: 4px;
  background: rgba(255,255,255,0.25);
  border-radius: 999px;
  padding: 0 6px;
  font-size: 11px;
}

/* ══════════════════════════════════
   ✅ / ❌ checkmarks
══════════════════════════════════ */
.chk      { font-size: 17px; }
.chk.no   { filter: grayscale(1) opacity(0.4); }
.chk.yes  { filter: none; }

/* ══════════════════════════════════
   Pagination
══════════════════════════════════ */
.pagination { display: flex; justify-content: flex-end; padding-top: 16px; }

/* ══════════════════════════════════
   Top opp preview in overview table
══════════════════════════════════ */
.opp-preview { font-size: 13px; }

/* ══════════════════════════════════
   Explainer cards
══════════════════════════════════ */
.explain-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.explain-card {
  background: rgba(255,252,242,0.74);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(55,46,25,0.06);
}

.explain-card b {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
}

.explain-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

/* ══════════════════════════════════
   Empty state
══════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--muted);
}
.empty-icon { font-size: 52px; margin-bottom: 16px; }
.empty-state p { font-size: 16px; line-height: 2; }

/* ══════════════════════════════════
   Responsive
══════════════════════════════════ */
.local-ui .sidebar {
  background:
    radial-gradient(circle at 30% 0%, rgba(201,130,43,0.18), transparent 34%),
    linear-gradient(180deg, #201a12 0%, #12100d 100%);
}

.local-input,
.local-select {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(21,21,21,0.14);
  border-radius: 12px;
  background: rgba(255,252,242,0.92);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}

.local-select {
  min-width: 150px;
  cursor: pointer;
}

.sidebar .local-input {
  width: 100%;
  min-height: 32px;
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.12);
  color: #f5e8d4;
}

.local-btn {
  border: 0;
  border-radius: 999px;
  padding: 9px 14px;
  background: linear-gradient(135deg, #c9822b, #b94336);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(185,67,54,0.18);
}

.local-error {
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid rgba(185,67,54,0.25);
  border-radius: 16px;
  background: rgba(185,67,54,0.08);
  color: var(--red);
  font-weight: 700;
}

.local-loading {
  position: fixed;
  right: 24px;
  top: 24px;
  z-index: 50;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(21,18,12,0.9);
  color: #f5e8d4;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  box-shadow: 0 10px 28px rgba(21,18,12,0.22);
}

.local-loading span {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(245,232,212,0.35);
  border-top-color: #f5dfa0;
  border-radius: 50%;
  animation: local-spin 0.8s linear infinite;
}

.local-blocker {
  position: fixed;
  inset: 0;
  z-index: 45;
  cursor: wait;
  background: rgba(255,252,245,0.18);
  backdrop-filter: blur(1px);
}

.is-loading .sidebar,
.is-loading .main {
  pointer-events: none;
}

.is-loading .local-loading,
.is-loading .local-blocker {
  pointer-events: auto;
}

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

.heat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  max-height: 430px;
  overflow: auto;
  padding-right: 4px;
}

.bubble-map {
  display: grid;
  grid-template-columns: 150px repeat(var(--cols), minmax(74px, 1fr));
  gap: 8px;
  overflow: auto;
  padding: 6px 4px 12px;
}

.bubble-corner,
.bubble-x,
.bubble-y {
  position: sticky;
  z-index: 2;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.bubble-corner {
  left: 0;
  background: rgba(255,252,242,0.92);
}

.bubble-x {
  top: 0;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,252,242,0.92);
}

.bubble-y {
  left: 0;
  min-height: 74px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: rgba(255,252,242,0.92);
  border-radius: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bubble-cell {
  min-width: 74px;
  min-height: 74px;
  border: 1px solid rgba(21,21,21,0.06);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.46), rgba(255,252,242,0.18));
  display: flex;
  align-items: center;
  justify-content: center;
}

.bubble-cell.has-bubble {
  cursor: pointer;
}

.bubble-cell.has-bubble:hover {
  background: rgba(255,245,220,0.95);
}

.bubble-cell span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  min-height: 18px;
  border-radius: 999px;
  color: #fff8ec;
  font-size: 10px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(185,67,54,0.24);
}

.heat-cell {
  min-height: 92px;
  border: 1px solid rgba(21,21,21,0.08);
  border-radius: 18px;
  padding: 12px;
  color: #231811;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 8px 20px rgba(55,46,25,0.08);
  transition: transform 0.15s, box-shadow 0.15s;
}

.heat-cell:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(55,46,25,0.15);
}

.heat-cell b,
.heat-cell span,
.heat-cell em {
  display: block;
}

.heat-cell b {
  font-size: 18px;
  letter-spacing: -0.04em;
}

.heat-cell span {
  margin-top: 6px;
  color: rgba(35,24,17,0.68);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heat-cell em {
  margin-top: 8px;
  font-style: normal;
  font-size: 24px;
  font-weight: 900;
}

.local-table-wrap {
  overflow: auto;
  max-height: 660px;
  border: 1px solid rgba(21,21,21,0.08);
  border-radius: 18px;
  background: rgba(255,255,255,0.36);
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  margin: -4px 0 10px;
}

.download-btn {
  border: 1px solid rgba(21,21,21,0.1);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255,252,242,0.88);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(55,46,25,0.08);
}

.download-btn:hover {
  background: #f5dfa0;
}

.ai-panel {
  padding: 22px;
  border: 1px solid rgba(36,107,82,0.16);
  border-radius: 24px;
  background:
    radial-gradient(circle at 8% 0%, rgba(36,107,82,0.14), transparent 34%),
    linear-gradient(135deg, rgba(255,252,242,0.96), rgba(232,239,222,0.8));
  box-shadow: 0 14px 34px rgba(55,46,25,0.09);
}

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

.ai-head span {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.ai-head h3 {
  font-size: 26px;
  letter-spacing: -0.05em;
}

.ai-head b {
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(36,107,82,0.1);
  color: var(--green);
  font-size: 12px;
}

.ai-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.analysis-btn {
  border: 0;
  border-radius: 999px;
  padding: 9px 14px;
  background: linear-gradient(135deg, #246b52, #2e6685);
  color: white;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(36,107,82,0.18);
}

.analysis-btn:hover {
  transform: translateY(-1px);
}

.analysis-btn:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

.ai-empty {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.ai-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.ai-grid h4,
.ai-top h4 {
  margin-bottom: 8px;
  font-size: 13px;
}

.ai-grid ul {
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.ai-grid li + li {
  margin-top: 6px;
}

.ai-top {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(21,21,21,0.08);
}

.ai-top span {
  display: inline-flex;
  margin: 0 8px 8px 0;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.55);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.llm-panel {
  border-color: rgba(46,102,133,0.2);
  background:
    radial-gradient(circle at 90% 0%, rgba(46,102,133,0.16), transparent 32%),
    linear-gradient(135deg, rgba(255,252,242,0.98), rgba(233,239,241,0.84));
}

.llm-meta {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.llm-output {
  margin: 0;
  padding: 18px;
  border: 1px solid rgba(21,21,21,0.08);
  border-radius: 18px;
  background: rgba(255,255,255,0.62);
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.75;
}

.local-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.local-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 14px;
  background: #efe3cc;
  color: #6b5b49;
  text-align: left;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.local-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.local-table th.sortable:hover {
  background: #e8d8bb;
  color: var(--ink);
}

.local-table td {
  padding: 12px 14px;
  border-top: 1px solid rgba(21,21,21,0.06);
  background: rgba(255,252,242,0.62);
  vertical-align: top;
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.local-table tbody tr {
  cursor: default;
  transition: background 0.12s;
}

.local-table tbody tr:hover td {
  background: rgba(255,245,220,0.98);
}

.local-table [data-keyword-id],
.local-table tr[data-country-row],
.local-table tr[data-comp-row] {
  cursor: pointer;
}

.local-ui .tab {
  min-height: 34px;
}

.local-ui .page-header {
  padding: 22px 24px;
  border: 1px solid rgba(21,21,21,0.08);
  border-radius: 26px;
  background:
    radial-gradient(circle at 85% 20%, rgba(36,107,82,0.12), transparent 28%),
    rgba(255,252,242,0.72);
  box-shadow: 0 12px 34px rgba(55,46,25,0.07);
}

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

.local-stat {
  padding: 18px 20px;
  border: 1px solid rgba(21,21,21,0.08);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(255,252,242,0.96), rgba(246,236,215,0.76));
  box-shadow: 0 10px 26px rgba(55,46,25,0.08);
}

.local-stat span,
.local-stat em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.local-stat b {
  display: block;
  margin: 8px 0 4px;
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.06em;
}

.local-stat.danger b { color: var(--red); }
.local-stat.success b { color: var(--green); }

.bar-chart {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 190px) 1fr 80px;
  gap: 12px;
  align-items: center;
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.34);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.bar-row:hover { background: rgba(255,245,220,0.95); }

.bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.bar-track {
  height: 14px;
  border-radius: 999px;
  background: rgba(21,21,21,0.08);
  overflow: hidden;
}

.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #c9822b, #b94336);
}

.bar-row b {
  text-align: right;
  font-size: 13px;
}

.stack-chart {
  display: grid;
  gap: 14px;
}

.stack-row {
  display: grid;
  grid-template-columns: 130px 1fr 80px;
  gap: 14px;
  align-items: center;
}

.stack-label {
  font-weight: 900;
}

.stack-track {
  display: flex;
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(21,21,21,0.08);
}

.stack-track span {
  display: block;
  height: 100%;
}

.stack-track .seg-blind { background: var(--red); }
.stack-track .seg-passive { background: var(--gold); }
.stack-track .seg-active { background: var(--green); }
.stack-track .seg-exclusive { background: var(--blue); }

.stack-legend {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  margin-right: -8px;
}

.dot.blind { background: var(--red); }
.dot.passive { background: var(--gold); }
.dot.active { background: var(--green); }
.dot.exclusive { background: var(--blue); }

@media (max-width: 900px) {
  .layout    { grid-template-columns: 1fr; }
  .sidebar   { position: fixed; bottom: 0; top: auto; width: 100%; height: auto; flex-direction: row; }
  .nav-list  { display: flex; flex-direction: row; padding: 6px; flex: 1; }
  .nav-list li { flex-direction: column; gap: 2px; padding: 8px 12px; font-size: 11px; border-left: none; border-top: 3px solid transparent; }
  .nav-list li.active { border-left: none; border-top-color: #c9822b; }
  .sidebar-logo, .sidebar-footer { display: none; }
  .main { padding: 20px 16px 80px; }
  .stat-grid { grid-template-columns: 1fr; }
  .explain-grid { grid-template-columns: 1fr; }
  .plain-app { padding: 16px; }
  .plain-hero { flex-direction: column; }
  .plain-grid { grid-template-columns: 1fr; }
  .local-stats { grid-template-columns: 1fr 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 60px; }
  .stack-row { grid-template-columns: 100px 1fr 54px; }
  .ai-grid { grid-template-columns: 1fr; }
}
