/* ── Variables: bridge to design_tokens.css ──────────── */
/* design_tokens.css is loaded before this file and defines
   --paper, --card, --line, --ink-*, --accent-*, --risk-*,
   --leaf-*, --teal-*, --wheat-*, --terracotta-*, --earth-*,
   --font-serif, --font-sans, --font-mono, --shadow-card, etc. */
:root {
    --bg: var(--paper);
    --card-bg: var(--card);
    --border: var(--line);
    --text: var(--ink-1);
    --text-muted: var(--ink-3);
    --blue: var(--accent);
    --blue-dark: var(--accent-600);
    --blue-light: var(--accent-wash);
    --red: var(--risk);
    --red-light: var(--risk-wash);
    --green: var(--leaf);
    --green-light: var(--leaf-wash);
    --orange: var(--terracotta);
    --orange-light: var(--terracotta-wash);
    --purple: #553c9a;
    --purple-light: #faf5ff;
    /* --teal and --teal-wash come from design_tokens.css */
    --teal-light: var(--teal-wash);
    --yellow: var(--wheat);
    --yellow-light: var(--wheat-wash);
    --shadow: var(--shadow-card);
}

/* ── Reset & base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* ── Site header ───────────────────────────────────────── */
.site-header {
    background: var(--ink-1);
    color: var(--on-color);
    padding: 1.1rem 2rem;
}
.header-inner h1 {
    font-family: var(--font-serif);
    font-size: 1.45rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.header-sub { font-size: 0.8rem; opacity: 0.72; margin-top: 0.2rem; font-family: var(--font-sans); }

/* ── Tab nav ───────────────────────────────────────────── */
.tab-nav {
    display: flex;
    background: #fff;
    border-bottom: 2px solid var(--border);
    padding: 0 2rem;
}
.tab-btn {
    padding: 0.65rem 1.3rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s;
}
.tab-btn:hover  { color: var(--blue); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ── Tab panels ────────────────────────────────────────── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.main-content { padding: 1.5rem 2rem; max-width: 1200px; margin: 0 auto; }

/* ── Controls bar ──────────────────────────────────────── */
.controls-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.control-label { font-weight: 600; font-size: 0.88rem; }
.select-input {
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.88rem;
    background: #fff;
    min-width: 260px;
    cursor: pointer;
}
.select-input:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

/* ── Cards ─────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.2rem;
    box-shadow: var(--shadow);
}

/* ── Graph header ──────────────────────────────────────── */
.graph-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}
.graph-header h2 { font-size: 1.25rem; font-weight: 700; }
.archetype-badge {
    background: var(--blue);
    color: #fff;
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.summary-text { color: var(--text-muted); max-width: 74ch; }

/* ── Section headers ───────────────────────────────────── */
.section { margin-top: 1.4rem; }
.section-title {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.65rem;
    color: var(--text);
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.35rem;
}

/* ── Node grid (grouped by type) ───────────────────────── */
.node-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: flex-start;
}
.node-group {
    border-radius: 8px;
    padding: 0.7rem 0.8rem;
    min-width: 135px;
    flex: 0 1 auto;
}
.node-group-title {
    font-size: 0.67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.45rem;
    opacity: 0.65;
}
.node-card {
    background: rgba(255,255,255,0.65);
    border-radius: 5px;
    padding: 0.3rem 0.55rem;
    margin-bottom: 0.28rem;
    font-size: 0.78rem;
}
.node-card:last-child { margin-bottom: 0; }
.node-label { font-weight: 500; }
.node-meta { font-size: 0.7rem; opacity: 0.6; }

/* Node type colour bands */
.node-type-product          { background: var(--blue-light);   border: 1px solid #bee3f8; }
.node-type-retailer         { background: var(--teal-light);   border: 1px solid #b2f5ea; }
.node-type-business_activity{ background: var(--teal-light);   border: 1px solid #b2f5ea; }
.node-type-asset            { background: var(--blue-light);   border: 1px solid #bee3f8; }
.node-type-production_input { background: var(--yellow-light); border: 1px solid #f6e05e; }
.node-type-ingredient       { background: var(--orange-light); border: 1px solid #fbd38d; }
.node-type-commodity        { background: var(--orange-light); border: 1px solid #fbd38d; }
.node-type-origin_country   { background: var(--teal-wash); border: 1px solid var(--teal); }
.node-type-cost_factor      { background: var(--purple-light); border: 1px solid #d6bcfa; }
.node-type-risk_event       { background: var(--red-light);    border: 1px solid #fed7d7; }
.node-type-market_price     { background: var(--green-light);  border: 1px solid #c6f6d5; }
.node-type-transport_mode   { background: #f7fafc; border: 1px solid var(--border); }
.node-type-distribution_stage { background: #f7fafc; border: 1px solid var(--border); }

/* ── Risk exposure cards ───────────────────────────────── */
.risk-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}
.risk-card {
    background: var(--red-light);
    border: 1px solid #fed7d7;
    border-radius: 8px;
    padding: 0.85rem;
    flex: 1 1 200px;
    max-width: 320px;
}
.risk-card-title { font-weight: 700; font-size: 0.88rem; color: var(--red); margin-bottom: 0.4rem; }
.risk-bar { height: 5px; background: #fed7d7; border-radius: 3px; margin: 0.35rem 0; overflow: hidden; }
.risk-fill { height: 100%; background: var(--red); border-radius: 3px; transition: width 0.4s; }
.risk-severity { font-size: 0.73rem; color: var(--red); font-weight: 600; }
.risk-explanation { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.35rem; }

/* ── Dependency table ──────────────────────────────────── */
.edge-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.edge-table th {
    text-align: left;
    padding: 0.45rem 0.7rem;
    background: #f7fafc;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.edge-table td {
    padding: 0.4rem 0.7rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.edge-table tr:last-child td { border-bottom: none; }
.edge-table tr:hover td { background: #f7fafc; }
.rel-badge {
    background: #edf2f7;
    color: var(--text-muted);
    padding: 0.12rem 0.45rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
}

/* ── Origin summary panel (TASK UI 010) ────────────────── */
.origin-summary-panel {
    background: var(--teal-light);
    border: 1px solid #b2f5ea;
    border-radius: 8px;
    padding: 1rem 1.2rem;
    margin-bottom: 1.25rem;
}
.origin-summary-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--teal);
    margin-bottom: 0.25rem;
}
.origin-summary-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-style: italic;
}
.origin-commodity-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}
.origin-commodity-item {
    background: rgba(255,255,255,0.65);
    border-radius: 6px;
    padding: 0.55rem 0.75rem;
    min-width: 140px;
    flex: 0 1 auto;
}
.origin-commodity-name {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--teal);
    margin-bottom: 0.35rem;
}
.origin-country-rows { display: flex; flex-direction: column; gap: 0.18rem; }
.origin-country-row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.79rem;
}
.origin-country-name { color: var(--text); }
.origin-country-pct  { font-weight: 600; color: var(--teal); white-space: nowrap; }
.origin-unavailable-msg {
    font-size: 0.82rem;
    color: var(--red);
    font-weight: 600;
}
.origin-unavailable-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 0.2rem;
}
.origin-no-data-msg  { font-size: 0.82rem; color: var(--text-muted); }
.origin-missing-note {
    font-size: 0.73rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.35rem;
}
.origin-limitation-note {
    font-size: 0.71rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.5rem;
    border-top: 1px solid #b2f5ea;
    padding-top: 0.45rem;
}

/* ── Methodology block ─────────────────────────────────── */
.methodology-block {
    margin-top: 1.4rem;
    background: #f7fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}
.methodology-block h3 { font-size: 0.88rem; font-weight: 700; margin-bottom: 0.4rem; }
.methodology-block h3 + h3 { margin-top: 0.75rem; }
.methodology-block p  { font-size: 0.8rem; color: var(--text-muted); }
.methodology-block ul { padding-left: 1.2rem; margin-top: 0.3rem; }
.methodology-block li { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.18rem; }

/* ── Shock simulation ──────────────────────────────────── */
.shock-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.1rem;
}
.shock-title { font-size: 1.25rem; font-weight: 700; }
.basket-score-badge {
    background: var(--blue);
    color: #fff;
    padding: 0.3rem 0.85rem;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
}
.affected-grid { display: flex; flex-direction: column; gap: 0.55rem; }
.affected-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    border-left: 4px solid var(--border);
    box-shadow: var(--shadow);
}
.affected-card.score-high { border-left-color: var(--red); }
.affected-card.score-mid  { border-left-color: #ed8936; }
.affected-card.score-low  { border-left-color: #48bb78; }
.affected-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}
.affected-product-name { font-weight: 700; font-size: 0.98rem; }
.affected-score-pct    { font-weight: 700; font-size: 0.98rem; }
.score-bar { height: 5px; background: var(--border); border-radius: 3px; margin: 0.25rem 0; overflow: hidden; }
.score-fill { height: 100%; border-radius: 3px; transition: width 0.4s; }
.score-high .score-fill { background: var(--red); }
.score-mid  .score-fill { background: #ed8936; }
.score-low  .score-fill { background: #48bb78; }
.affected-archetype {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.3rem;
}
.affected-explanation { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.top-paths strong { font-size: 0.76rem; color: var(--text); }
.top-paths ul { padding-left: 1.1rem; margin-top: 0.15rem; }
.top-paths li  { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.12rem; }

/* ── Basket exposure ───────────────────────────────────── */
.exposure-intro {
    color: var(--text-muted);
    max-width: 74ch;
    margin-bottom: 1.1rem;
    font-size: 0.88rem;
}
.exposure-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}
.exposure-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    flex: 1 1 200px;
    max-width: 320px;
    box-shadow: var(--shadow);
}
/* Top-border accent per type */
.exposure-type-commodity        { border-top: 3px solid #ed8936; }
.exposure-type-production_input { border-top: 3px solid #ecc94b; }
.exposure-type-cost_factor      { border-top: 3px solid var(--purple); }
.exposure-type-risk_event       { border-top: 3px solid var(--red); }
.exposure-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}
.exposure-label-text  { font-weight: 700; font-size: 0.9rem; }
.exposure-count-badge {
    background: #edf2f7;
    color: var(--text-muted);
    padding: 0.12rem 0.5rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}
.exposure-type-text {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.45rem;
}
.product-tags { display: flex; flex-wrap: wrap; gap: 0.28rem; }
.product-tag {
    background: var(--blue);
    color: #fff;
    padding: 0.12rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
}

/* ── Checkbox controls ─────────────────────────────────── */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ── Price signal block ────────────────────────────────── */
.signal-block {
    margin-top: 0.55rem;
    background: var(--teal-light);
    border: 1px solid #b2f5ea;
    border-radius: 6px;
    padding: 0.45rem 0.65rem;
    font-size: 0.76rem;
}
.signal-block-title {
    font-weight: 600;
    color: var(--teal);
    margin-bottom: 0.28rem;
    font-size: 0.76rem;
}
.signal-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.85rem;
}
.signal-item { color: var(--text-muted); }
.signal-item strong { color: var(--text); }
.direction-up   { color: var(--green); font-weight: 600; }
.direction-down { color: var(--red);   font-weight: 600; }
.direction-flat { color: var(--text-muted); font-weight: 600; }
.no-signal-note {
    font-size: 0.73rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.45rem;
}

/* ── SVG graph panel (TASK UI 005) ────────────────────── */
.graph-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.65rem;
    font-style: italic;
}
.graph-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    box-shadow: var(--shadow);
}
.graph-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.85rem;
    margin-bottom: 0.7rem;
    font-size: 0.74rem;
    color: var(--text-muted);
}
.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    white-space: nowrap;
}
.legend-swatch {
    width: 13px;
    height: 13px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}
.graph-svg-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fafcff;
    min-height: 80px;
}
.graph-svg { display: block; }
.graph-node-group { transition: opacity 0.15s; }
.graph-node-selected rect { filter: drop-shadow(0 0 4px rgba(43,108,176,0.5)); }
.graph-edge { transition: stroke 0.12s, stroke-width 0.12s; }
.graph-edge-highlighted { stroke: #2b6cb0 !important; }
.graph-clear-btn {
    display: inline-flex;
    align-items: center;
    margin-top: 0.55rem;
    padding: 0.28rem 0.7rem;
    font-size: 0.77rem;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #fff;
    color: var(--text-muted);
    cursor: pointer;
}
.graph-clear-btn:hover { background: var(--blue-light); color: var(--blue); }
.graph-details {
    margin-top: 0.7rem;
    background: #f7fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.7rem 0.85rem;
    font-size: 0.8rem;
}
.gd-title {
    font-weight: 700;
    font-size: 0.88rem;
    margin-bottom: 0.4rem;
    color: var(--text);
    word-break: break-all;
}
.gd-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    margin-bottom: 0.35rem;
}
.gd-table td { padding: 0.18rem 0.5rem 0.18rem 0; vertical-align: top; }
.gd-key {
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
    padding-right: 0.7rem;
    width: 26%;
}
.gd-section {
    font-size: 0.73rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0.45rem 0 0.2rem;
}
.gd-list { padding-left: 1rem; margin: 0; font-size: 0.77rem; }
.gd-list li { margin-bottom: 0.15rem; color: var(--text-muted); }

/* ── Shock comparison charts (TASK UI 006) ─────────────── */
.shock-charts-section {
    margin-bottom: 1.5rem;
}
.chart-section-header,
.chart-header {
    margin-bottom: 0.75rem;
}
.chart-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.18rem;
}
.chart-header p {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    margin: 0;
}
.chart-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.18rem;
}
.chart-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}
.chart-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    box-shadow: var(--shadow);
    margin-bottom: 0.65rem;
    overflow-x: auto;
}
.chart-svg { display: block; }
.chart-legend-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.85rem;
    margin-bottom: 0.75rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    min-height: 1rem;
}
.chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    white-space: nowrap;
}
.chart-legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}
/* Bar chart classes (used in SVG via inline styles; these cover any HTML fallback) */
.bar-row    { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; }
.bar-track  { flex: 1; height: 20px; background: #f0f4f8; border-radius: 4px; overflow: hidden; }
.bar-fill   { height: 100%; border-radius: 4px; transition: width 0.3s; }
.bar-segment { display: inline-block; height: 100%; }
.bar-label  { min-width: 120px; text-align: right; font-size: 0.82rem; color: var(--text); }
.bar-value  { min-width: 36px; text-align: left; font-size: 0.82rem; font-weight: 600; color: var(--text); }
.signal-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: var(--teal-light);
    color: var(--teal);
    white-space: nowrap;
}
.empty-chart-note {
    background: #fffbf0;
    border: 1px solid #f6e05e;
    border-radius: 6px;
    padding: 0.65rem 0.9rem;
    font-size: 0.82rem;
    color: #744210;
    margin-bottom: 0.65rem;
    line-height: 1.5;
}

/* ── Historical Replay (TASK UI 007) ───────────────────── */
.history-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-bottom: 0.75rem;
}
.history-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    box-shadow: var(--shadow);
    margin-bottom: 0.65rem;
    font-size: 0.88rem;
    color: var(--text);
}
.history-chart {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    box-shadow: var(--shadow);
    margin-bottom: 0.65rem;
    overflow-x: auto;
}
.history-line {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.history-axis-label {
    font-size: 0.75rem;
    fill: var(--text-muted);
}
.history-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.85rem;
    margin-top: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.history-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}
.driver-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--border);
    color: var(--text-muted);
    margin: 0.1rem;
}
.driver-chip.available { background: #d1fae5; color: #065f46; }
.driver-chip.missing   { background: #fee2e2; color: #991b1b; }
.missing-data-note {
    background: #fffbf0;
    border: 1px solid #f6e05e;
    border-radius: 6px;
    padding: 0.65rem 0.9rem;
    font-size: 0.82rem;
    color: #744210;
    margin-bottom: 0.65rem;
    line-height: 1.5;
}

/* ── Data Sources panel (TASK UI 009) ──────────────────── */
.ds-section {
    margin-bottom: 1.5rem;
}
.ds-section-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.55rem;
    padding-bottom: 0.28rem;
    border-bottom: 2px solid var(--border);
}
.ds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.65rem;
}
.ds-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 0.9rem;
    box-shadow: var(--shadow);
    font-size: 0.82rem;
    line-height: 1.5;
}
.ds-card-title {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text);
    margin-bottom: 0.3rem;
    word-break: break-word;
}
.ds-badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}
.ds-badge-integrated { background: #d1fae5; color: #065f46; }
.ds-badge-partial     { background: #fef3c7; color: #92400e; }
.ds-badge-planned     { background: #dbeafe; color: #1e40af; }
.ds-badge-blocked     { background: #fee2e2; color: #991b1b; }
.ds-badge-manual      { background: #f3f4f6; color: #374151; }
.ds-meta {
    color: var(--text-muted);
    margin-bottom: 0.15rem;
    line-height: 1.4;
}
.ds-used-for {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin-top: 0.35rem;
}
.ds-chip {
    display: inline-block;
    padding: 0.08rem 0.4rem;
    background: var(--blue-light);
    color: var(--blue);
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 500;
}

/* ── Utility ───────────────────────────────────────────── */
.hint    { color: var(--text-muted); font-size: 0.88rem; }
.loading { color: var(--text-muted); font-style: italic; font-size: 0.88rem; }
.no-affected { color: var(--text-muted); font-size: 0.88rem; padding: 0.5rem 0; }

/* ── Food Basket Overview (TASK UI 012) ────────────────── */
.overview-intro {
    font-family: var(--font-sans);
    font-size: 0.92rem;
    color: var(--ink-2);
    max-width: 70ch;
    margin-bottom: 1.25rem;
    line-height: 1.6;
}
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}
.overview-tile {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-card);
    padding: 1.1rem 1.2rem;
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s, transform 0.12s;
}
.overview-tile:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent-300);
    transform: translateY(-1px);
}
.overview-tile-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--r-sm);
    background: var(--sunken);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.6rem;
}
.overview-tile-body { flex: 1; min-width: 0; }
.overview-tile-name {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ink-1);
    margin-bottom: 0.2rem;
}
.overview-tile-archetype {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ink-3);
    margin-bottom: 0.4rem;
}
.overview-tile-summary {
    font-size: 0.8rem;
    color: var(--ink-2);
    line-height: 1.5;
    margin-bottom: 0.5rem;
}
.overview-tile-footer {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.overview-tile-cta {
    font-size: 0.73rem;
    color: var(--accent);
    font-weight: 600;
    margin-top: 0.25rem;
}

/* ── Supply Chain Story Strip (TASK UI 013) ────────────── */
.story-strip {
    display: flex;
    align-items: stretch;
    gap: 0;
    margin-bottom: 1.2rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    padding: 0.6rem 0.75rem;
}
.story-step {
    flex: 1;
    min-width: 80px;
    padding: 0.4rem 0.5rem;
    text-align: center;
}
.story-step-empty .story-step-content {
    color: var(--ink-4);
    font-style: italic;
}
.story-step-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-3);
    margin-bottom: 0.3rem;
}
.story-step-content {
    font-size: 0.75rem;
    color: var(--ink-2);
    line-height: 1.4;
    word-break: break-word;
}
.story-step-icon {
    font-size: 1.1rem;
    margin-bottom: 0.2rem;
    display: block;
}
.story-chevron {
    display: flex;
    align-items: center;
    color: var(--ink-4);
    font-size: 1.1rem;
    padding: 0 0.1rem;
    flex-shrink: 0;
    align-self: center;
}

/* ── Global Origin Map (TASK UI 016 / TASK UI 017) ───────── */
.global-map-header { margin-bottom: 1rem; }
.global-map-title {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--ink-1);
    margin-bottom: 0.2rem;
}
.global-map-subtitle {
    font-size: 0.85rem;
    color: var(--ink-3);
    font-style: italic;
}
.global-map-status {
    background: #fffbf0;
    border: 1px solid #f6e05e;
    border-radius: 6px;
    padding: 0.55rem 0.85rem;
    font-size: 0.82rem;
    color: #744210;
    margin-bottom: 0.75rem;
}
.global-map-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-card);
    padding: 1rem 1.2rem;
}
.global-map-trust-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem 0.75rem;
    margin-bottom: 0.85rem;
}
.global-map-limitation {
    font-size: 0.73rem;
    color: var(--ink-3);
    font-style: italic;
}

/* Two-column layout */
.global-map-columns {
    display: flex;
    gap: 1.1rem;
    align-items: flex-start;
}
.global-map-left-col {
    flex: 1 1 62%;
    min-width: 0;
}
.global-map-right-col {
    flex: 0 1 260px;
    min-width: 210px;
}
@media (max-width: 680px) {
    .global-map-columns { flex-direction: column; }
    .global-map-right-col { flex: 1 1 100%; min-width: 0; }
}

.global-map-svg-container {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #EAF0F1; /* parchment sea, matches design kit */
    min-height: 80px;
    margin-bottom: 0.55rem;
    overflow-x: auto;
    position: relative; /* needed for tooltip absolute positioning */
}
.global-map-svg { display: block; }
.omap-country-node, .omap-uk-node { cursor: default; }

.global-map-schematic-note {
    font-size: 0.71rem;
    color: var(--ink-4);
    font-style: italic;
    margin: 0 0 0.5rem;
}

/* UK destination card */
.global-map-dest-card { margin-bottom: 0.6rem; }
.origin-dest-card {
    background: var(--card);
    border: 1px solid var(--teal);
    border-radius: 6px;
    padding: 0.55rem 0.8rem;
}
.origin-dest-title {
    font-family: var(--font-serif);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--ink-1);
    margin-bottom: 0.38rem;
    padding-bottom: 0.28rem;
    border-bottom: 1px solid var(--line);
}
.origin-dest-rows {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
    margin-bottom: 0.38rem;
}
.origin-dest-row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.77rem;
}
.origin-dest-label { color: var(--ink-3); flex-shrink: 0; }
.origin-dest-val { font-weight: 500; color: var(--ink-1); text-align: right; }
.origin-dest-top { color: var(--teal); }
.origin-dest-source { font-size: 0.67rem; color: var(--ink-4); font-style: italic; }

/* Ranking panel */
.global-map-ranking { }
.origin-rank-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
}
.origin-rank-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.48rem 0.72rem;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
}
.origin-rank-title {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 0.87rem;
    color: var(--ink-1);
}
.origin-rank-meta {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--ink-3);
}
.origin-rank-rows { padding: 0.2rem 0; }
.origin-rank-row {
    display: grid;
    grid-template-columns: 2rem 1fr 68px 2.4rem 3rem;
    align-items: center;
    gap: 0 0.3rem;
    padding: 0.26rem 0.68rem;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    font-size: 0.77rem;
}
.origin-rank-row:last-child { border-bottom: none; }
.origin-rank-other {
    opacity: 0.72;
    background: rgba(0,0,0,0.018);
}
.origin-rank-num {
    font-family: var(--font-mono);
    font-size: 0.67rem;
    font-weight: 600;
    color: var(--ink-3);
}
.origin-rank-name {
    font-weight: 500;
    color: var(--ink-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.origin-rank-bar-track {
    height: 5px;
    background: rgba(0,0,0,0.07);
    border-radius: 3px;
    overflow: hidden;
}
.origin-rank-bar-fill {
    height: 100%;
    background: var(--teal);
    border-radius: 3px;
    transition: width 0.25s ease;
}
.origin-rank-pct {
    font-family: var(--font-mono);
    font-size: 0.77rem;
    font-weight: 700;
    color: var(--teal);
    text-align: right;
}
.origin-rank-val {
    font-size: 0.67rem;
    color: var(--ink-3);
    text-align: right;
    white-space: nowrap;
}

/* ── Origin map interactions (TASK UI 018) ─────────────── */

/* Hover tooltip */
.omap-tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.45rem 0.65rem;
    box-shadow: 0 6px 20px rgba(30,45,59,0.14);
    max-width: 160px;
    z-index: 10;
    font-size: 0.78rem;
    line-height: 1.4;
}
.omap-tt-name {
    font-weight: 600;
    color: var(--ink-1);
    margin-bottom: 0.15rem;
}
.omap-tt-meta { color: var(--teal); font-weight: 600; }
.omap-tt-src  { font-size: 0.67rem; color: var(--ink-4); margin-top: 0.15rem; font-style: italic; }

/* Selected / dimmed states on SVG arcs and nodes */
.omap-arc.omap-selected    { opacity: 1 !important; }
.omap-arc.omap-dimmed      { opacity: 0.15 !important; }
.omap-origin-node.omap-selected circle { stroke: #1E2D3B !important; stroke-width: 2.5 !important; }
.omap-origin-node.omap-dimmed          { opacity: 0.18 !important; }

/* Ranking row selected state */
.origin-rank-row.origin-rank-selected {
    background: var(--teal-wash);
    border-left: 2px solid var(--teal);
}

/* Selected origin detail card */
.global-map-detail-col { margin-top: 0.55rem; }
.origin-detail-card {
    background: var(--card);
    border: 1px solid var(--teal);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    margin-top: 0.55rem;
}
.origin-detail-header {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.4rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--line);
}
.origin-detail-rank {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--ink-3);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.1rem 0.32rem;
    flex-shrink: 0;
}
.origin-detail-country {
    font-family: var(--font-serif);
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--ink-1);
}
.origin-detail-rows {
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
    margin-bottom: 0.38rem;
}
.origin-detail-row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.77rem;
}
.origin-detail-label { color: var(--ink-3); flex-shrink: 0; }
.origin-detail-val   { font-weight: 500; color: var(--ink-1); text-align: right; }
.origin-detail-share { font-weight: 700; color: var(--teal); }
.origin-detail-caveat {
    font-size: 0.66rem;
    color: var(--ink-4);
    font-style: italic;
    border-top: 1px solid var(--line);
    padding-top: 0.3rem;
}

/* Arc legend */
.omap-arc-legend text { dominant-baseline: middle; }

/* Legacy card classes (kept for existing CSS tests) */
.global-map-card {
    background: var(--teal-wash);
    border: 1px solid var(--teal);
    border-radius: 6px;
    padding: 0.45rem 0.7rem;
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 0 0.5rem;
    min-width: 200px;
    flex: 0 1 auto;
}
.global-map-card-rank { font-family: var(--font-mono); font-size: 0.68rem; font-weight: 600; color: var(--ink-3); }
.global-map-card-name { font-weight: 600; font-size: 0.82rem; color: var(--ink-1); }
.global-map-card-share { font-family: var(--font-mono); font-size: 0.88rem; font-weight: 700; color: var(--teal); }
.global-map-card-value { font-size: 0.72rem; color: var(--ink-3); }

.global-map-unavailable {
    background: #fffbf0;
    border: 1px solid #f6e05e;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: #744210;
    margin: 0.5rem;
}
.global-map-unavailable code {
    background: rgba(0,0,0,0.07);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.82em;
}
