/* ===== Data Page Styles ===== */

.data-page {
    padding: 0;
}


/* ===== Sidebar Layout ===== */

.data-layout {
    display: flex;
    min-height: calc(100vh - 60px);
}

.data-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 12px 0;
    overflow-y: auto;
}

/* Sidebar Search Box */
.sidebar-search-box {
    padding: 8px 16px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.sidebar-search {
    width: 100%;
    padding: 7px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    cursor: pointer;
}
.sidebar-search:focus {
    border-color: var(--accent);
}
.sidebar-search::placeholder {
    color: var(--text-muted);
}

/* Category Headings */
.sidebar-category-heading {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 12px 20px 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.sidebar-category-heading:first-child {
    padding-top: 4px;
}
.sidebar-category-heading svg {
    flex-shrink: 0;
}

.sidebar-item {
    display: block;
    width: 100%;
    padding: 8px 20px 8px 28px;
    font-size: 13px;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-left: 3px solid transparent;
    text-align: left;
    cursor: pointer;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.sidebar-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.sidebar-item.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: rgba(59, 130, 246, 0.08);
}


/* ===== Breadcrumb ===== */

.data-breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 0 12px;
    font-size: 12px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.bc-segment {
    cursor: default;
    color: var(--text-muted);
    transition: color 0.2s;
}

.bc-segment:not(.bc-active) {
    cursor: pointer;
}
.bc-segment:not(.bc-active):hover {
    color: var(--accent);
}

.bc-active {
    color: var(--text-primary);
    font-weight: 500;
}

.bc-sep {
    color: var(--text-muted);
    font-size: 11px;
}


/* ===== Tab Strip (Phase 2: subviews as pills) ===== */

.dataset-tab-strip {
    display: flex;
    gap: 6px;
    padding: 0 0 16px;
    overflow-x: auto;
    scrollbar-width: none;
}
.dataset-tab-strip::-webkit-scrollbar {
    display: none;
}

.dataset-tab {
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 12px;
    white-space: nowrap;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.dataset-tab:hover {
    color: var(--text-secondary);
    border-color: var(--text-muted);
}
.dataset-tab.active {
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent);
    border-color: var(--accent);
}


.data-content {
    flex: 1;
    padding: 24px 24px 80px;
    min-width: 0;
    max-width: 1100px;
}


/* ===== Section ===== */

.data-section {
    margin-bottom: 48px;
}

.data-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 16px;
}

.data-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin-bottom: 4px;
}

.data-source {
    font-size: 12px;
    color: var(--text-muted);
}

.data-controls {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.data-select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.data-select:focus {
    outline: none;
    border-color: var(--accent);
}

.export-btn-data {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}
.export-btn-data:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.share-btn-data {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    background: transparent;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.share-btn-data:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}
.share-btn-data.copied {
    color: #10b981;
    border-color: #10b981;
}

.share-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #111827;
    color: #f3f4f6;
    border: 1px solid #374151;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 13px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    opacity: 0;
    transition: opacity 0.18s, transform 0.18s;
    pointer-events: none;
    z-index: 9999;
}
.share-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


/* ===== CPI Summary Cards ===== */

.cpi-summary-cards {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.cpi-summary-card {
    flex: 1;
    min-width: 120px;
    max-width: 200px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
}

.cpi-summary-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cpi-summary-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.cpi-summary-value.summary-up {
    color: var(--green, #10b981);
}

.cpi-summary-value.summary-down {
    color: var(--red, #ef4444);
}

.cpi-summary-arrow {
    font-size: 12px;
}

.cpi-summary-arrow.summary-up {
    color: var(--green, #10b981);
}

.cpi-summary-arrow.summary-down {
    color: var(--red, #ef4444);
}

.cpi-summary-date {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}


/* ===== Chart ===== */

.chart-container {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    height: 360px;
}

.chart-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}


/* ===== Data Table ===== */

.data-table-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.data-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 10px;
    padding: 10px 12px;
    text-align: right;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.data-table th:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    background: var(--bg-tertiary);
    z-index: 3;
}

.data-table td {
    padding: 8px 12px;
    text-align: right;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(31, 41, 55, 0.5);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.data-table td:first-child {
    text-align: left;
    color: var(--text-primary);
    font-weight: 500;
    position: sticky;
    left: 0;
    background: var(--bg-secondary);
}

.data-table tbody tr:hover td {
    background: var(--bg-tertiary);
}
.data-table tbody tr:hover td:first-child {
    background: var(--bg-tertiary);
}


/* ===== Meta ===== */

.data-meta {
    margin-top: 12px;
    font-size: 11px;
    color: var(--text-muted);
}


/* ===== Search Overlay (Phase 3) ===== */

.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 300;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}

.search-modal {
    width: 520px;
    max-width: 90vw;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.search-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 15px;
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    outline: none;
}
.search-input::placeholder {
    color: var(--text-muted);
}

.search-results {
    max-height: 360px;
    overflow-y: auto;
}

.search-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.15s;
}
.search-result:hover,
.search-result.selected {
    background: rgba(59, 130, 246, 0.1);
}

.search-result-label {
    font-size: 14px;
    color: var(--text-primary);
}

.search-result-category {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}


/* ===== Bottom Sheet (Phase 4: mobile navigation) ===== */

.bottom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.bottom-sheet-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 70vh;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 200;
    overflow-y: auto;
    padding: 8px 0 24px;
}
.bottom-sheet.open {
    transform: translateY(0);
}

.bottom-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--text-muted);
    border-radius: 2px;
    margin: 4px auto 8px;
    opacity: 0.4;
}

.bottom-sheet-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
}
.bottom-sheet-close:hover {
    color: var(--text-primary);
}

.bottom-sheet-content {
    padding: 4px 0;
}

.bs-heading {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 12px 20px 4px;
}

.bs-item {
    display: block;
    width: 100%;
    padding: 12px 24px;
    font-size: 14px;
    color: var(--text-secondary);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}
.bs-item:hover {
    background: rgba(255, 255, 255, 0.03);
}
.bs-item.active {
    color: var(--accent);
    background: rgba(59, 130, 246, 0.08);
}


/* ===== Forecast Column Styling ===== */

.col-actual {
    background: rgba(148, 163, 184, 0.06);
}

.col-current {
    background: rgba(245, 158, 11, 0.08);
    border-left: 2px solid rgba(245, 158, 11, 0.25);
}

.col-forecast {
    font-style: italic;
    color: var(--text-muted);
}

th.col-current {
    color: #f59e0b;
    font-style: normal;
}

th.col-forecast {
    font-style: normal;
    color: var(--text-muted);
}

th.col-actual {
    color: #9ca3af;
}


/* ===== Bottom Sheet Search ===== */

.bottom-sheet-search {
    padding: 8px 16px 4px;
}

.bottom-sheet-search input {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
}
.bottom-sheet-search input:focus {
    border-color: var(--accent);
}
.bottom-sheet-search input::placeholder {
    color: var(--text-muted);
}


/* ===== Mobile Nav Bar ===== */

.mobile-nav-bar {
    display: none;
}

@media (max-width: 768px) {
    .mobile-nav-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border);
        z-index: 150;
        align-items: center;
        justify-content: space-around;
        padding: 0 16px;
    }
}

.mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.mobile-nav-btn:active,
.mobile-nav-btn:hover {
    color: var(--accent);
}
.mobile-nav-btn span {
    font-size: 10px;
    font-weight: 500;
}


/* ===== Responsive ===== */

@media (max-width: 768px) {
    .data-layout {
        flex-direction: column;
    }
    .data-sidebar {
        display: none;
    }

    /* Breadcrumb: tappable look on mobile */
    .data-breadcrumb {
        padding: 8px 0 12px;
        font-size: 13px;
        cursor: pointer;
    }
    .bc-segment {
        cursor: pointer;
        padding: 4px 8px;
        border-radius: 6px;
        background: var(--bg-tertiary);
        transition: background 0.15s, color 0.15s;
    }
    .bc-segment:active {
        background: rgba(59, 130, 246, 0.15);
        color: var(--accent);
    }
    .bc-active {
        background: rgba(59, 130, 246, 0.1);
        color: var(--text-primary);
    }
    .bc-sep {
        color: var(--text-muted);
        padding: 0 2px;
    }

    .data-content {
        padding: 16px 16px 72px;
    }
    .data-section-header {
        flex-direction: column;
    }
    .data-title {
        font-size: 18px;
    }
    .chart-container {
        height: 280px;
        padding: 12px;
    }
    .data-table-container {
        overflow-x: auto;
        max-height: 360px;
    }
    .data-table th,
    .data-table td {
        padding: 8px 10px;
        font-size: 11px;
    }
    .data-table th {
        font-size: 9px;
    }
    .dataset-tab-strip {
        padding: 0 0 12px;
    }
    .dataset-tab {
        font-size: 11px;
        padding: 5px 12px;
    }
}

@media (max-width: 480px) {
    .data-content {
        padding: 12px 12px 64px;
    }
    .data-title {
        font-size: 16px;
    }
    .data-source {
        font-size: 11px;
    }
    .chart-container {
        height: 240px;
        padding: 8px;
    }
    .data-table th,
    .data-table td {
        padding: 6px 8px;
        font-size: 10px;
    }
    .data-meta {
        font-size: 10px;
    }
}


/* ══════════════════════════════════════════════════════
   SOVEREIGN DEBT INDICATOR
   ══════════════════════════════════════════════════════ */

.sd-header {
    margin-bottom: 20px;
}

.sd-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.sd-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.sd-export-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
}
.sd-export-btn:hover {
    color: var(--text-primary);
    background: var(--accent-dim);
    text-decoration: none;
}

.sd-summary {
    display: flex;
    gap: 16px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.sd-stat {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    border: 1px solid var(--border);
}

.sd-tier-row {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.sd-tier-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 4px;
    letter-spacing: 0.3px;
}

.sd-controls {
    display: flex;
    gap: 8px;
}

.sd-select {
    padding: 5px 10px;
    border-radius: 5px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
}
.sd-select:focus {
    outline: 1px solid var(--accent);
}

/* Map */
.sd-map-wrap {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #0a0e1a;
    margin-bottom: 24px;
}

#sd-map-svg svg {
    width: 100%;
    cursor: grab;
}
#sd-map-svg svg:active {
    cursor: grabbing;
}

.sd-country {
    transition: opacity 0.2s;
}
.sd-country:hover {
    opacity: 0.8;
    stroke: #fff !important;
    stroke-width: 1.5px !important;
}

.sd-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.92);
    color: #fff;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 100;
    max-width: 220px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.sd-tooltip.hidden { display: none; }

.sd-tip-tier {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 3px;
    margin: 4px 0;
}

.sd-tip-grid {
    display: grid;
    grid-template-columns: auto auto;
    gap: 2px 12px;
    margin-top: 6px;
    font-size: 11px;
}
.sd-tip-grid span:nth-child(odd) {
    color: #6b7280;
}
.sd-tip-grid span:nth-child(even) {
    text-align: right;
    font-weight: 600;
}

.sd-map-legend {
    position: absolute;
    bottom: 12px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.75);
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 10px;
    color: #9ca3af;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.sd-legend-bar {
    width: 150px;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #059669, #eab308, #ea580c, #dc2626);
}

/* Download map button (absolute, overlay on map) */
.sd-download-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #9ca3af;
    font-size: 11px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    z-index: 50;
    transition: all 0.15s;
}
.sd-download-btn:hover {
    color: #e5e7eb;
    background: rgba(0, 0, 0, 0.85);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Download button (inline, for charts) */
.sd-download-btn-inline {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 5px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: #9ca3af;
    font-size: 11px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.sd-download-btn-inline:hover {
    color: #e5e7eb;
    background: var(--accent-dim);
}

/* Bar chart below map */
.sd-map-below {
    margin-bottom: 16px;
}
.sd-map-below h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

#sd-top-chart-wrap {
    height: 500px;
}

/* Ranking view */
.sd-ranking {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.sd-rank-header {
    display: grid;
    grid-template-columns: 36px 1fr 72px 2fr 60px 65px 55px;
    gap: 8px;
    padding: 6px 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.sd-rank-row {
    display: grid;
    grid-template-columns: 36px 1fr 72px 2fr 60px 65px 55px;
    gap: 8px;
    padding: 8px 10px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
.sd-rank-row:hover {
    background: var(--bg-tertiary);
}

.sd-rank-num {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
}

.sd-rank-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sd-rank-tier {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 2px 8px;
    border-radius: 3px;
    text-align: center;
}

.sd-rank-bar-wrap {
    display: flex;
    height: 14px;
    border-radius: 3px;
    overflow: hidden;
    background: var(--bg-primary);
}
.sd-rank-bar-official {
    background: #2563eb;
    height: 100%;
}
.sd-rank-bar-gap {
    background: #dc2626;
    height: 100%;
}

.sd-rank-val {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: right;
}

.sd-rank-gap {
    font-size: 12px;
    font-weight: 700;
    color: #f59e0b;
    text-align: right;
}

.sd-rank-svc {
    font-size: 11px;
    font-weight: 600;
    text-align: right;
}

/* Table view */
.sd-table-wrap {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.sd-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.sd-table thead th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 10px 8px;
    text-align: center;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
}

.sd-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
.sd-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.sd-table td {
    padding: 7px 8px;
    text-align: center;
    color: var(--text-secondary);
    white-space: nowrap;
}
.sd-table td:first-child {
    text-align: left;
    color: var(--text-primary);
    font-weight: 500;
}

.sd-cell-est {
    font-weight: 600;
    color: var(--text-primary) !important;
}

.sd-tier-cell {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 3px;
}

/* Responsive */
@media (max-width: 768px) {
    .sd-summary { gap: 8px; }
    .sd-stat { font-size: 10px; padding: 3px 8px; }
    .sd-tier-badge { font-size: 10px; padding: 2px 8px; }
    .sd-rank-header, .sd-rank-row {
        grid-template-columns: 30px 1fr 55px 1.5fr 45px 50px 45px;
        gap: 4px;
    }
    .sd-rank-name { font-size: 11px; }
    #sd-top-chart-wrap { height: 400px; }
}


/* ===== EM External Vulnerability — Bubble Chart ===== */

.em-vuln-chart-container {
    height: 520px;
}

.em-vuln-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 14px;
    margin-bottom: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}
.em-vuln-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
}
.em-vuln-legend-label {
    color: var(--text-secondary);
    margin-right: 8px;
}
.em-vuln-legend-note {
    margin-left: auto;
    color: var(--text-muted);
    font-style: italic;
}

.em-vuln-picker {
    margin-bottom: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}
.em-vuln-picker-head {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
}
.em-vuln-btn {
    padding: 5px 10px;
    font-size: 11px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
}
.em-vuln-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}
.em-vuln-search {
    flex: 1;
    min-width: 140px;
    padding: 5px 10px;
    font-size: 12px;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 5px;
    outline: none;
}
.em-vuln-search:focus {
    border-color: var(--accent);
}
.em-vuln-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 4px 12px;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 4px;
}
.em-vuln-opt {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 0;
}
.em-vuln-opt input {
    cursor: pointer;
}
.em-vuln-opt-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.em-vuln-em-tag {
    font-size: 9px;
    font-weight: 700;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    padding: 1px 5px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

.em-vuln-empty-banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 18px 24px;
    text-align: center;
    max-width: 520px;
    font-size: 13px;
    line-height: 1.5;
}
.em-vuln-empty-banner strong {
    color: var(--text-primary);
}

/* ===== Methodology modal (per-commodity white paper) ===== */
.methodology-btn {
    background: transparent;
    color: var(--text-secondary, #94a3b8);
    border: 1px solid var(--border, #334155);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.methodology-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--text-primary, #e2e8f0);
    border-color: #3b82f6;
}
.methodology-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 6vh 16px;
    overflow-y: auto;
}
.methodology-modal {
    width: 760px;
    max-width: 100%;
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border, #334155);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    max-height: 88vh;
}
.methodology-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border, #334155);
    background: var(--bg-secondary, #1e293b);
}
.methodology-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
}
.methodology-close {
    background: transparent;
    border: none;
    color: var(--text-muted, #94a3b8);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 8px;
}
.methodology-close:hover {
    color: var(--text-primary, #e2e8f0);
}
.methodology-body {
    overflow-y: auto;
    padding: 22px 28px;
    color: var(--text-secondary, #cbd5e1);
    font-size: 14px;
    line-height: 1.6;
}
.methodology-loading {
    color: var(--text-muted, #94a3b8);
    font-style: italic;
}
.methodology-body h1 { font-size: 20px; margin: 0 0 12px; color: var(--text-primary, #e2e8f0); }
.methodology-body h2 { font-size: 16px; margin: 22px 0 8px; color: var(--text-primary, #e2e8f0); }
.methodology-body h3 { font-size: 14px; margin: 18px 0 6px; color: var(--text-primary, #e2e8f0); text-transform: uppercase; letter-spacing: 0.5px; }
.methodology-body p { margin: 0 0 12px; }
.methodology-body ul { padding-left: 22px; margin: 0 0 12px; }
.methodology-body li { margin-bottom: 6px; }
.methodology-body code {
    background: rgba(148, 163, 184, 0.12);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    font-size: 12px;
}
.methodology-body blockquote {
    margin: 10px 0;
    padding: 8px 14px;
    border-left: 3px solid #3b82f6;
    background: rgba(59, 130, 246, 0.06);
    color: var(--text-secondary, #cbd5e1);
    font-style: italic;
}
.methodology-body hr {
    border: 0;
    border-top: 1px solid var(--border, #334155);
    margin: 18px 0;
}
.methodology-body strong { color: var(--text-primary, #e2e8f0); }
.methodology-body a { color: #3b82f6; text-decoration: none; }
.methodology-body a:hover { text-decoration: underline; }

/* ===== Scenario builder (Phase 9) ===== */
.forecast-cta-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.scenario-btn {
    background: transparent;
    color: var(--text-secondary, #94a3b8);
    border: 1px solid var(--border, #334155);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.scenario-btn:hover {
    background: rgba(167, 139, 250, 0.12);
    color: var(--text-primary, #e2e8f0);
    border-color: #a78bfa;
}
#panel-scenario-container {
    margin-top: 14px;
}
.scenario-loading,
.scenario-empty {
    padding: 14px;
    color: var(--text-muted, #94a3b8);
    font-style: italic;
    border: 1px dashed var(--border, #334155);
    border-radius: 8px;
}
.scenario-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border, #334155);
    border-radius: 8px 8px 0 0;
    border-bottom: none;
}
.scenario-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
.scenario-actions {
    display: flex;
    gap: 6px;
}
.scenario-btn-ghost {
    background: transparent;
    color: var(--text-secondary, #94a3b8);
    border: 1px solid var(--border, #334155);
    border-radius: 5px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.scenario-btn-ghost:hover:not(:disabled) {
    background: rgba(167, 139, 250, 0.12);
    color: var(--text-primary, #e2e8f0);
    border-color: #a78bfa;
}
.scenario-btn-ghost:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.scenario-status {
    padding: 8px 14px;
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    background: rgba(167, 139, 250, 0.06);
    border-left: 1px solid var(--border, #334155);
    border-right: 1px solid var(--border, #334155);
}
.scenario-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
    padding: 14px;
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border, #334155);
    border-top: none;
}
.scenario-row {
    background: rgba(148, 163, 184, 0.04);
    border: 1px solid var(--border, #334155);
    border-radius: 6px;
    padding: 10px 12px;
}
.scenario-row-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}
.scenario-row-head label {
    font-size: 13px;
    color: var(--text-primary, #e2e8f0);
}
.scenario-row-head label strong {
    font-weight: 600;
    margin-right: 6px;
}
.scenario-unit {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.scenario-value {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: #a78bfa;
    font-size: 13px;
    min-width: 60px;
    text-align: right;
}
.scenario-row input[type="range"] {
    width: 100%;
    height: 4px;
    background: var(--border, #334155);
    border-radius: 3px;
    appearance: none;
    cursor: pointer;
    margin: 6px 0;
}
.scenario-row input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #a78bfa;
    border: 2px solid #1e293b;
    cursor: pointer;
    transition: background 0.1s;
}
.scenario-row input[type="range"]::-webkit-slider-thumb:hover {
    background: #c4b5fd;
}
.scenario-row input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #a78bfa;
    border: 2px solid #1e293b;
    cursor: pointer;
}
.scenario-note {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    line-height: 1.4;
    margin-top: 4px;
}
.scenario-footer {
    padding: 8px 14px;
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    line-height: 1.5;
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border, #334155);
    border-top: none;
    border-radius: 0 0 8px 8px;
}


/* ===== Yale Tariff Summary Tiles ===== */

.yale-tariff-tiles {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
    width: 100%;
}
.yale-tariff-tile {
    background: #1e293b;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    min-width: 0;
    overflow: hidden;
}
.yale-tariff-tile-val {
    font-size: 28px;
    font-weight: 700;
    margin-top: 4px;
}

@media (max-width: 768px) {
    .yale-tariff-tiles {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .yale-tariff-tile-val {
        font-size: 22px;
    }
}
@media (max-width: 400px) {
    .yale-tariff-tiles {
        grid-template-columns: 1fr;
    }
}
