:root,
html[data-theme="dark"] {
    --bg: #0b0e14;
    --surface: #131822;
    --surface-2: #1a2230;
    --border: #1f2937;
    --text: #e5e7eb;
    --text-muted: #94a3b8;
    --dl: #f97316;
    --ul: #8b5cf6;
    --lat: #38bdf8;
    --ok: #10b981;
    --warn: #f59e0b;
    --err: #ef4444;
    --grid-line: rgba(255, 255, 255, 0.06);
    --map-land: #1f2937;
}

html[data-theme="light"] {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --border: #e2e8f0;
    --text: #172033;
    --text-muted: #64748b;
    --dl: #ea580c;
    --ul: #7c3aed;
    --lat: #0284c7;
    --ok: #16a36a;
    --warn: #d97706;
    --err: #dc2626;
    --grid-line: rgba(15, 23, 42, 0.08);
    --map-land: #cbd5e1;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.mono {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
}

.st-shell {
    max-width: 1320px;
    margin: 0 auto;
    padding: 20px 24px 36px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Header */
.st-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.st-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.st-logo {
    height: 40px;
    width: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.st-brand-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.st-brand-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.st-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.st-client-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 500;
}

.st-pill-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--dl);
}

.st-pill-sep {
    color: var(--text-muted);
}

.st-sync-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 9999px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.28);
    color: var(--ok);
    font-size: 12px;
    font-weight: 600;
}

.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ok);
    animation: st-pulse 1.5s infinite;
}

@keyframes st-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.45; transform: scale(1.25); }
}

.st-theme-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.st-theme-btn:hover {
    background: var(--surface-2);
}

/* Error Banner */
.st-error-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.st-error-icon { font-size: 22px; }
.st-error-title { font-weight: 700; color: var(--err); font-size: 15px; }
.st-error-msg { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* Quick Context Selector */
.st-context-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 16px;
}

.st-context-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.st-context-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.st-chip-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.st-chip {
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 5px 11px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.st-chip:hover {
    color: var(--text);
    border-color: var(--dl);
}

.st-chip.active {
    background: rgba(249, 115, 22, 0.15);
    color: var(--dl);
    border-color: var(--dl);
    font-weight: 600;
}

/* Main Hero Grid */
.st-hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 2.15fr) minmax(300px, 1fr);
    gap: 16px;
    align-items: stretch;
}

.st-left-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.st-metrics-top {
    display: grid;
    grid-template-columns: 1fr 1fr 0.92fr;
    gap: 14px;
}

.st-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
}

.st-speed-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.st-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.st-card-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dot-dl, .dot-ul {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.dot-dl { background: var(--dl); }
.dot-ul { background: var(--ul); }

.st-p90-tag {
    font-size: 11px;
    color: var(--dl);
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.25);
    padding: 2px 7px;
    border-radius: 5px;
}

.st-p90-ul {
    color: var(--ul);
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.25);
}

.st-big-number {
    font-size: 40px;
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.03em;
    margin-bottom: 10px;
}

.st-unit {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 5px;
}

.st-canvas-wrap {
    width: 100%;
    height: 132px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.st-canvas-wrap canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.st-card-foot {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 10px;
}

.st-card-foot strong {
    color: var(--text);
}

/* Telemetry Stack */
.st-telemetry-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.st-mini-card {
    padding: 12px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.st-mini-pill {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 9999px;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.st-mini-pill.ok { color: var(--ok); background: rgba(16, 185, 129, 0.12); border-color: rgba(16, 185, 129, 0.3); }
.st-mini-pill.warn { color: var(--warn); background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.3); }
.st-mini-pill.err { color: var(--err); background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.3); }

.st-mini-val {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.15;
}

.st-unit-sm {
    font-size: 13px;
    color: var(--text-muted);
    margin-left: 4px;
}

.st-mini-sub {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Progress Bar */
.st-progress-card {
    padding: 14px 16px;
}

.st-progress-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.st-ctrl-btns {
    display: flex;
    align-items: center;
    gap: 8px;
}

.st-circle-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s ease, border-color 0.15s ease;
}

.st-circle-btn:hover {
    border-color: var(--dl);
}

.st-btn-primary {
    background: var(--dl);
    color: #0b0e14;
    border-color: var(--dl);
    font-weight: 700;
}

.st-progress-status {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
}

.st-phase-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--dl);
}

.st-phase-pct {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
}

.st-chevron-bar {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 3px;
    height: 16px;
}

.st-chev {
    background: var(--surface-2);
    clip-path: polygon(0 0, 78% 0, 100% 50%, 78% 100%, 0 100%, 22% 50%);
    transition: background-color 0.2s ease, opacity 0.2s ease;
    opacity: 0.45;
}

.st-chev.done-lat { background: var(--lat); opacity: 1; }
.st-chev.done-dl { background: var(--dl); opacity: 1; }
.st-chev.done-ul { background: var(--ul); opacity: 1; }
.st-chev.done-udp { background: var(--ok); opacity: 1; }
.st-chev.active { animation: chev-blink 0.9s infinite alternate; opacity: 1; }

@keyframes chev-blink {
    from { filter: brightness(0.85); }
    to { filter: brightness(1.3); }
}

/* Map Card */
.st-map-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.st-edge-pill {
    font-size: 11px;
    font-weight: 600;
    color: var(--ok);
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    padding: 2px 8px;
    border-radius: 9999px;
}

.st-map-box {
    position: relative;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    height: 185px;
}

.st-map-svg {
    width: 100%;
    height: 100%;
}

.map-land { fill: var(--map-land); opacity: 0.75; }
.map-grid { stroke: var(--grid-line); stroke-width: 1; }
.map-label { fill: var(--text); font-size: 10px; font-family: 'Inter', sans-serif; font-weight: 600; }

.st-map-rtt {
    position: absolute;
    right: 8px;
    bottom: 8px;
    background: rgba(11, 14, 20, 0.85);
    color: #e5e7eb;
    border: 1px solid #374151;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
}

.st-meta-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

.st-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.st-meta-row:last-child { border-bottom: none; padding-bottom: 0; }
.st-meta-key { color: var(--text-muted); }
.st-meta-val { font-weight: 600; text-align: right; word-break: break-word; }

/* Quality Score Strip */
.st-quality-note {
    font-size: 12px;
    color: var(--text-muted);
}

.st-quality-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-top: 8px;
}

.st-q-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
}

.st-q-icon { font-size: 22px; line-height: 1; margin-top: 2px; }
.st-q-title { font-size: 14px; font-weight: 600; }
.st-stars { color: var(--dl); font-size: 15px; letter-spacing: 2px; margin: 3px 0; }
.st-stars .dim { color: var(--border); }
.st-q-desc { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

/* Confirmation Banner */
.st-confirm-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 16px 20px;
    border-radius: 10px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.st-confirm-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.st-confirm-check {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ok);
    color: #0b0e14;
    font-weight: 800;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.st-confirm-title { font-weight: 700; font-size: 15px; color: var(--ok); }
.st-confirm-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.st-confirm-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.st-btn-orange {
    background: var(--dl);
    color: #0b0e14;
    border: none;
    padding: 9px 16px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
}

.st-btn-ghost {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 9px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}

.st-footer {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
    padding-top: 6px;
}

@media (max-width: 1024px) {
    .st-hero-grid { grid-template-columns: 1fr; }
    .st-metrics-top { grid-template-columns: 1fr 1fr; }
    .st-telemetry-stack { grid-column: 1 / -1; flex-direction: row; }
}

@media (max-width: 720px) {
    .st-shell { padding: 14px; }
    .st-metrics-top { grid-template-columns: 1fr; }
    .st-telemetry-stack { flex-direction: column; }
    .st-quality-grid { grid-template-columns: 1fr; }
    .st-big-number { font-size: 34px; }
}
