:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2332;
    --bg-card-hover: #1f2b3d;
    --border: #2d3748;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --green: #10b981;
    --green-dim: #064e3b;
    --yellow: #f59e0b;
    --yellow-dim: #78350f;
    --orange: #f97316;
    --orange-dim: #7c2d12;
    --red: #ef4444;
    --red-dim: #7f1d1d;
    --blue: #3b82f6;
    --blue-dim: #1e3a5f;
    --purple: #8b5cf6;
    --cyan: #06b6d4;

    --s0-color: var(--green);
    --s1-color: var(--yellow);
    --s2-color: var(--orange);
    --s3-color: var(--red);
    --s4-color: #dc2626;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.state-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.state-badge.s0 { background: var(--green-dim); color: var(--green); border: 1px solid var(--green); }
.state-badge.s1 { background: var(--yellow-dim); color: var(--yellow); border: 1px solid var(--yellow); }
.state-badge.s2 { background: var(--orange-dim); color: var(--orange); border: 1px solid var(--orange); }
.state-badge.s3 { background: var(--red-dim); color: var(--red); border: 2px solid var(--red); animation: pulse-glow 1s infinite; }

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 20px rgba(239, 68, 68, 0.6); }
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
}

.connection-dot.disconnected { background: var(--red); }

/* Main Layout */
.main {
    padding: 16px 24px;
    max-width: 1600px;
    margin: 0 auto;
}

/* Crisis Overview Grid */
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.overview-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    transition: border-color 0.2s;
}

.overview-card:hover { border-color: var(--blue); }

.overview-card .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.overview-card .value {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.overview-card .change {
    font-size: 13px;
    font-weight: 500;
    margin-top: 2px;
}

.change.positive { color: var(--green); }
.change.negative { color: var(--red); }
.change.neutral { color: var(--text-muted); }

.overview-card .state-indicator {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
}

/* Charts Section */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

.chart-card h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chart-container {
    height: 220px;
    position: relative;
}

/* Contagion Matrix */
.contagion-section {
    margin-bottom: 16px;
}

.contagion-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 12px;
}

.matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.matrix-table th,
.matrix-table td {
    padding: 8px;
    text-align: center;
    border: 1px solid var(--border);
}

.matrix-table th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
}

.matrix-cell {
    font-weight: 600;
}

.transmission-path {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    margin-bottom: 6px;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 13px;
}

.path-arrow { color: var(--text-muted); }
.path-strong { color: var(--red); font-weight: 600; }
.path-moderate { color: var(--orange); font-weight: 500; }

/* Bloomberg TV Section */
.bloomberg-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
}

.bloomberg-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.bloomberg-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bloomberg-external {
    font-size: 11px;
    color: var(--blue);
    text-decoration: none;
}

.bloomberg-external:hover { text-decoration: underline; }

.bloomberg-iframe-container {
    position: relative;
    width: 100%;
    padding-bottom: 42%;
    background: #000;
}

.bloomberg-iframe-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* News Item Styles */
.news-item {
    display: block;
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 6px;
    background: var(--bg-secondary);
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
    cursor: pointer;
}

.news-item:hover { background: var(--bg-card-hover); }

.news-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.news-source {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.news-title {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text-primary);
}

.news-item:hover .news-title { color: var(--blue); }

.news-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
}

.news-time {
    font-size: 10px;
    color: var(--text-muted);
}

/* Sentiment Badges */
.sentiment-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sentiment-very_negative { background: var(--red-dim); color: var(--red); }
.sentiment-negative { background: var(--orange-dim); color: var(--orange); }
.sentiment-neutral { background: rgba(100,116,139,0.2); color: var(--text-muted); }
.sentiment-positive { background: var(--green-dim); color: var(--green); }

/* News Panel (top section) */
.news-panel {
    margin-bottom: 16px;
    max-height: 300px;
}

.news-panel .news-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 6px;
}

/* Bottom Section: Alerts + Events */
.bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    max-height: 500px;
    overflow-y: auto;
}

.panel h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    padding-bottom: 8px;
}

.alert-item {
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 6px;
    border-left: 3px solid;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: background 0.2s;
}

.alert-item:hover { background: var(--bg-card-hover); }

.alert-item.severity-info { border-left-color: var(--blue); }
.alert-item.severity-watch { border-left-color: var(--yellow); }
.alert-item.severity-warning { border-left-color: var(--orange); }
.alert-item.severity-critical { border-left-color: var(--red); }
.alert-item.severity-emergency { border-left-color: #dc2626; background: var(--red-dim); }

.alert-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.alert-severity {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

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

.alert-title {
    font-size: 13px;
    font-weight: 500;
}

.alert-body {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.4;
}

.alert-actions {
    margin-top: 6px;
}

.btn-ack {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-ack:hover {
    border-color: var(--green);
    color: var(--green);
}

.event-item {
    padding: 8px 10px;
    margin-bottom: 4px;
    border-radius: 4px;
    font-size: 12px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

a.event-item {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

a.event-item:hover {
    background: var(--bg-card-hover);
}

a.event-item:hover .event-text {
    color: var(--blue);
}

.event-category {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.cat-market { background: var(--blue-dim); color: var(--blue); }
.cat-credit { background: var(--purple); color: #fff; opacity: 0.8; }
.cat-maritime { background: var(--cyan); color: #000; opacity: 0.9; }
.cat-official { background: var(--yellow-dim); color: var(--yellow); }
.cat-satellite { background: var(--orange-dim); color: var(--orange); }

.event-text {
    color: var(--text-secondary);
    line-height: 1.3;
}

.event-time {
    color: var(--text-muted);
    font-size: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Zone Section */
.zone-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.zone-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.zone-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

/* SVG Zone Map */
.zone-map-container {
    background: #0d1520;
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.zone-map-container svg {
    width: 100%;
    height: auto;
    display: block;
}

.zone-rect {
    transition: opacity 0.3s;
    cursor: pointer;
}

.zone-rect:hover {
    opacity: 0.5 !important;
}

.zone-label {
    font-size: 9px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.zone-count {
    font-size: 22px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
}

.zone-detail-text {
    font-size: 9px;
    font-family: 'Inter', sans-serif;
}

/* Chokepoint pulse animation */
.zone-rect-chokepoint.zone-closed-pulse {
    animation: zone-pulse-red 1.5s ease-in-out infinite;
}

@keyframes zone-pulse-red {
    0%, 100% { opacity: 0.2; filter: drop-shadow(0 0 2px rgba(239,68,68,0.3)); }
    50% { opacity: 0.45; filter: drop-shadow(0 0 12px rgba(239,68,68,0.7)); }
}

/* Zone Detail Cards */
.zone-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.zone-detail-card {
    background: var(--bg-secondary);
    border-radius: 6px;
    border-left: 3px solid;
    padding: 10px 12px;
}

.zone-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.zone-card-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.zone-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 10px;
}

.zone-badge-closed {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid var(--red);
}

.zone-badge-active {
    background: var(--green-dim);
    color: var(--green);
    border: 1px solid var(--green);
}

.zone-card-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    text-align: center;
}

.zone-card-stats div {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.zone-stat-val {
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.zone-stat-lbl {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Zone Chart Tabs */
.zone-chart-section {
    margin-bottom: 12px;
}

.zone-chart-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.zone-tab {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.zone-tab:hover {
    border-color: var(--blue);
    color: var(--text-primary);
}

.zone-tab.active {
    background: var(--blue-dim);
    border-color: var(--blue);
    color: var(--blue);
    font-weight: 600;
}

/* Maritime AIS Panel (backward compat totals) */
.ais-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.ais-stat {
    background: var(--bg-secondary);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
}

.ais-stat .stat-value {
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.ais-stat .stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Responsive */
@media (max-width: 1200px) {
    .charts-grid { grid-template-columns: 1fr; }
    .contagion-grid { grid-template-columns: 1fr; }
    .bottom-grid { grid-template-columns: 1fr; }
    .zone-grid { grid-template-columns: 1fr; }
    .zone-chart-tabs { flex-wrap: wrap; }
}

@media (max-width: 768px) {
    .overview-grid { grid-template-columns: repeat(2, 1fr); }
    .header { flex-direction: column; gap: 8px; }
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

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

/* Empty state */
.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 13px;
}
