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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    overflow: hidden;
}

/* Header */
header {
    padding: 8px 16px;
    background: #16213e;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 50px;
    border-bottom: 1px solid #2a3555;
}

h1 {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
}

.controls {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: auto;
}

/* Search */
.search-group {
    position: relative;
}

#search {
    width: 180px;
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #0f1629;
    color: #e0e0e0;
    outline: none;
    transition: border-color 0.15s;
}

#search:focus { border-color: #2d7d46; }
#search::placeholder { color: #666; }

.search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 340px;
    max-height: 300px;
    overflow-y: auto;
    background: #16213e;
    border: 1px solid #444;
    border-radius: 6px;
    margin-top: 4px;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.search-result-item {
    padding: 7px 10px;
    cursor: pointer;
    border-bottom: 1px solid #1a2744;
    transition: background 0.1s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: #1e3054; }
.sr-title { display: block; font-size: 12px; color: #e0e0e0; }
.sr-meta { font-size: 10px; color: #888; }

/* Filters */
.filter-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.filter-label {
    font-size: 11px;
    color: #999;
    margin-right: 2px;
    white-space: nowrap;
}

.filter-btn {
    padding: 3px 8px;
    font-size: 11px;
    border: 1px solid #444;
    border-radius: 4px;
    background: transparent;
    color: #999;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.filter-btn:hover { border-color: #666; color: #ccc; }
.filter-btn.active { background: #2d7d46; border-color: #2d7d46; color: #fff; }

/* Legend */
.legend {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    color: #999;
}

.legend-gradient {
    width: 80px;
    height: 8px;
    border-radius: 3px;
    background: linear-gradient(to right, #2d7d46, #7ab648, #c4d84a, #f0c93a, #e8842a, #d9381e, #b91c1c, #991b1b);
}
.legend-label { white-space: nowrap; }

/* Main layout */
.main-layout {
    display: flex;
    height: calc(100vh - 50px);
}

/* Sidebar */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: #16213e;
    border-right: 1px solid #2a3555;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
}

.sidebar-section {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #1e2d4d;
}
.sidebar-section:last-of-type { border-bottom: none; margin-bottom: 0; }

.insights-link {
    display: block;
    text-align: center;
    padding: 10px 14px;
    margin-bottom: 14px;
    background: linear-gradient(135deg, #d9381e, #e8842a);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(217, 56, 30, 0.3);
    letter-spacing: 0.02em;
}
.insights-link:hover {
    background: linear-gradient(135deg, #e8842a, #f0c93a);
    box-shadow: 0 4px 16px rgba(217, 56, 30, 0.5);
    transform: translateY(-1px);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #1e2d4d;
}

.footer-sources {
    font-size: 9px;
    color: #777;
    line-height: 1.4;
    margin-bottom: 8px;
}

.footer-author {
    font-size: 11px;
    color: #999;
    margin-bottom: 4px;
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 8px;
}

.footer-links a {
    color: #7ab648;
    text-decoration: none;
    font-size: 11px;
}

.footer-links a:hover {
    text-decoration: underline;
    color: #a0d468;
}

.stat-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 3px;
    line-height: 1.3;
}

.stat-big {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.1;
    color: #e0e0e0;
}

.stat-red { color: #d9381e; }

.stat-sub {
    font-size: 10px;
    color: #666;
    margin-top: 2px;
    line-height: 1.3;
}

.stat-highlight {
    color: #fff;
    font-weight: 600;
}

/* Breakdown rows */
.breakdown-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    font-size: 11px;
}

.bd-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

.bd-label {
    flex: 1;
    color: #ccc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bd-value {
    font-weight: 600;
    color: #e0e0e0;
    width: 42px;
    text-align: right;
    flex-shrink: 0;
}

.bd-pct {
    color: #888;
    width: 30px;
    text-align: right;
    flex-shrink: 0;
}

/* Bar chart rows */
.bar-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    font-size: 10px;
}

.bar-label {
    width: 70px;
    text-align: right;
    color: #aaa;
    flex-shrink: 0;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-track {
    flex: 1;
    height: 12px;
    background: #0f1629;
    border-radius: 3px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.bar-value {
    width: 26px;
    text-align: right;
    font-weight: 600;
    color: #e0e0e0;
    flex-shrink: 0;
}

/* Treemap */
#treemap {
    flex: 1;
    overflow: hidden;
    min-width: 0;
    min-height: 400px;
}

.empty-msg {
    text-align: center;
    padding: 60px;
    color: #666;
    font-size: 16px;
}

.group-label {
    font-size: 11px;
    font-weight: 600;
    fill: #fff;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.tile-label {
    font-size: 10px;
    fill: #fff;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

/* Tooltip */
.tooltip {
    display: none;
    position: absolute;
    background: rgba(22, 33, 62, 0.95);
    border: 1px solid #444;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.4;
    max-width: 420px;
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.tt-dim {
    color: #888;
    font-size: 11px;
}
