/* ── Managed Risk Console — Design System ───────────────────────── */

:root {
    --bg-base: #0b0e14;
    --bg-surface: #111520;
    --bg-card: #141923;
    --bg-card-hover: #1a2030;
    --border: rgba(255,255,255,0.06);
    --border-light: rgba(255,255,255,0.1);

    --cyan: #00d4ff;
    --purple: #a855f7;
    --orange: #f97316;
    --red: #ef4444;
    --green: #10b981;
    --yellow: #eab308;
    --blue: #3b82f6;

    --text-primary: #f0f2f5;
    --text-secondary: #7a8599;
    --text-muted: #4a5568;

    --sidebar-w: 220px;
    --topbar-h: 54px;
    --radius: 10px;
    --radius-sm: 6px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────────────────────────────── */

.app-container {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon { flex-shrink: 0; }

.logo-text {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
    background: rgba(255,255,255,0.04);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(0,212,255,0.08);
    color: var(--cyan);
}

.nav-item.active svg { stroke: var(--cyan); }

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
}

.sidebar-brand {
    font-size: 0.6rem;
    color: var(--text-muted);
    letter-spacing: 0.03em;
}

/* ── Main Content ───────────────────────────────────────────────── */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Top Bar ────────────────────────────────────────────────────── */

.topbar {
    height: var(--topbar-h);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-date {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 4px;
    transition: color 0.15s;
}
.icon-btn:hover { color: var(--text-primary); }

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
}

/* ── Dashboard Grid ─────────────────────────────────────────────── */

.dashboard-grid {
    padding: 1rem 1.25rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 1rem;
    flex: 1;
}

/* ── Cards ───────────────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    overflow: hidden;
}

.card-title {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0.75rem;
}

/* ── Risk Score Card ─────────────────────────────────────────────── */

.card-risk-score { grid-column: 1; }

.risk-score-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.gauge-container {
    position: relative;
    width: 180px;
    height: 180px;
    flex-shrink: 0;
}

.gauge-svg { width: 100%; height: 100%; }

.gauge-seg {
    stroke-linecap: round;
    transition: stroke-dasharray 0.6s ease;
}

.gauge-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.gauge-value {
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(180deg, #fff 30%, var(--cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gauge-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

.risk-score-meta { flex: 1; min-width: 0; }

.score-legend {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.legend-item strong {
    color: var(--text-primary);
    margin-left: auto;
    font-size: 0.75rem;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.key-events h4 {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.35rem;
}

.key-events ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.key-events li {
    font-size: 0.68rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.dot-sm {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dot-sm.red { background: var(--red); }
.dot-sm.yellow { background: var(--yellow); }
.dot-sm.green { background: var(--green); }

/* ── Agent Confidence Card ───────────────────────────────────────── */

.card-agent-confidence { grid-column: 2; }

.agent-layout {
    display: flex;
    gap: 1rem;
}

.agent-network {
    width: 180px;
    flex-shrink: 0;
}

.network-svg { width: 100%; height: auto; }

.agent-table-wrap { flex: 1; min-width: 0; }

.agent-table-wrap h4 {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}

.agent-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.72rem;
}

.agent-table th {
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.agent-table td {
    padding: 0.4rem 0.5rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.conf-high { color: var(--green) !important; font-weight: 600; }
.conf-med { color: var(--orange) !important; font-weight: 600; }
.conf-low { color: var(--red) !important; font-weight: 600; }

/* ── Row 2 Wrapper (3 cards side-by-side) ───────────────────────── */

.row-2-wrap {
    grid-column: 1 / -1;
    display: flex;
    gap: 1rem;
}

.row-2-wrap .card { flex: 1; min-width: 0; }

/* ── Trend Card ──────────────────────────────────────────────────── */

.trend-chart {
    width: 100%;
    height: auto;
    display: block;
}

/* ── Metrics Card ────────────────────────────────────────────────── */

.metrics-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.metric-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.metric-label {
    width: 75px;
    font-size: 0.62rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    text-align: right;
}

.metric-blocks {
    display: flex;
    gap: 3px;
}

.mb {
    display: block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

/* ── Efficiency Donut ────────────────────────────────────────────── */

.donut-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto;
}

.donut-svg { width: 100%; height: 100%; }

.donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.donut-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--green);
}

.donut-label {
    font-size: 0.6rem;
    color: var(--text-muted);
}

.donut-legend {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 0.75rem;
    font-size: 0.62rem;
    color: var(--text-secondary);
}

.donut-legend i {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.3rem;
    vertical-align: middle;
}

/* ── Alerts Table ────────────────────────────────────────────────── */

.card-alerts { grid-column: 1; }

.badge-crit {
    display: inline-block;
    background: rgba(239,68,68,0.15);
    color: var(--red);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

.badge-warn {
    display: inline-block;
    background: rgba(234,179,8,0.12);
    color: var(--yellow);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

.alerts-table-wrap { overflow-x: auto; }

.alerts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.7rem;
}

.alerts-table th {
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.alerts-table td {
    padding: 0.45rem 0.6rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
}

.alerts-table td:first-child { color: var(--text-muted); }

.row-crit { border-left: 2px solid var(--red); }
.row-warn { border-left: 2px solid var(--yellow); }

.row-crit td:last-child { color: var(--red); font-weight: 600; }
.row-warn td:last-child { color: var(--yellow); font-weight: 600; }

/* ── Heatmap Card ────────────────────────────────────────────────── */

.card-heatmap { grid-column: 2; }

.heatmap-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    padding: 0.5rem 0;
}

.world-map { width: 100%; height: auto; max-height: 220px; }

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .card-risk-score,
    .card-agent-confidence,
    .card-alerts,
    .card-heatmap {
        grid-column: 1;
    }
    .row-2-wrap {
        grid-column: 1;
        flex-direction: column;
    }
    .risk-score-layout { flex-direction: column; align-items: center; }
    .agent-layout { flex-direction: column; }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
}
