:root {
    --bg-page: #f9fafb;
    --bg-card: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-accent: #3b82f6;
    /* Modern Blue */
    --border-color: #e5e7eb;

    --success-bg: #d1fae5;
    --success-text: #059669;
    --warning-bg: #fef3c7;
    --warning-text: #d97706;
    --error-bg: #fee2e2;
    --error-text: #dc2626;
    --neutral-bg: #f3f4f6;
    --neutral-text: #4b5563;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: var(--font-sans);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

#root {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Navigation */
nav {
    display: flex;
    gap: 24px;
}

.nav-btn {
    background: none;
    border: none;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 0;
    position: relative;
    transition: color 0.2s;
}

.nav-btn:hover {
    color: var(--text-primary);
}

.nav-btn.active {
    color: var(--text-accent);
}

.nav-btn.active::after {
    content: '';
    position: absolute;
    bottom: -21px;
    /* Align with header border */
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--text-accent);
}

/* Grid & Cards */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 24px;
}

.col-span-12 {
    grid-column: span 12;
}

.col-span-8 {
    grid-column: span 8;
}

.col-span-6 {
    grid-column: span 6;
}

.col-span-4 {
    grid-column: span 4;
}

.col-span-3 {
    grid-column: span 3;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin: 0 0 16px 0;
    letter-spacing: 0.05em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Metrics & Stats */
.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.stat-row:last-child {
    border-bottom: none;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

.status-online {
    background-color: var(--success-bg);
    color: var(--success-text);
}

.status-standby {
    background-color: var(--neutral-bg);
    color: var(--neutral-text);
}

.status-warning {
    background-color: var(--warning-bg);
    color: var(--warning-text);
}

.status-error {
    background-color: var(--error-bg);
    color: var(--error-text);
}

/* Terminal Logs (Modernized) */
.terminal-window {
    background: #1f2937;
    /* Dark Gray, not black */
    border-radius: 8px;
    padding: 16px;
    height: 300px;
    overflow-y: auto;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.825rem;
    color: #e5e7eb;
}

.log-entry {
    margin-bottom: 6px;
    line-height: 1.4;
    opacity: 0.9;
}

.log-timestamp {
    color: #9ca3af;
    margin-right: 8px;
    font-size: 0.75rem;
}

/* Phase Tracker (Modern) */
.phase-card {
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
    border-color: #bfdbfe;
    text-align: center;
    padding: 40px;
}

.day-display {
    font-size: 4rem;
    font-weight: 800;
    color: #1e3a8a;
    /* Deep Blue */
    line-height: 1;
    margin: 10px 0;
}

.phase-status {
    font-size: 0.875rem;
    font-weight: 600;
    color: #3b82f6;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Agent Grid */
.agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.agent-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    transition: transform 0.1s, box-shadow 0.1s;
}

.agent-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    padding: 12px;
    min-width: 100px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

tr:last-child td {
    border-bottom: none;
}

/* Animations */
@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        opacity: 1;
    }
}

@keyframes radarPing {
    0% {
        transform: scale(0.2);
        opacity: 0.9;
    }

    100% {
        transform: scale(1.9);
        opacity: 0;
    }
}

.loading {
    animation: pulse 1.5s infinite;
    color: var(--text-secondary);
    font-weight: 500;
}

.radar-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid #3b82f6;
    animation: radarPing 2.4s ease-out infinite;
    transform-origin: center;
}

.radar-ring-2 {
    animation-delay: 0.8s;
}

.radar-ring-3 {
    animation-delay: 1.6s;
}

/* Extended status badges */
.status-in-progress {
    background-color: #dbeafe;
    color: #1e40af;
}

.status-waiting {
    background-color: #fef3c7;
    color: #92400e;
}

/* ── Command Center: Glow-Green Pulse (ACTIVE agents) ── */
@keyframes glowGreen {
    0%   { box-shadow: 0 0 4px 1px rgba(16, 185, 129, 0.6); opacity: 1; }
    50%  { box-shadow: 0 0 12px 4px rgba(16, 185, 129, 0.9); opacity: 0.85; }
    100% { box-shadow: 0 0 4px 1px rgba(16, 185, 129, 0.6); opacity: 1; }
}

.glow-green-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #10b981;
    animation: glowGreen 2s ease-in-out infinite;
    flex-shrink: 0;
}

/* ── Command Center: Tiered ROI Header ── */
.roi-header {
    display: flex;
    gap: 12px;
    align-items: stretch;
    padding: 16px 20px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border-radius: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.roi-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    min-width: 120px;
    flex: 1;
}

.roi-metric-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.roi-metric-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
}

.roi-divider {
    width: 1px;
    background: rgba(255,255,255,0.08);
    margin: 4px 0;
}

/* ── Command Center: Tier-Coded Row Styles ── */
.tier-row-gold {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 40%, #fde68a 100%) !important;
    border-left: 4px solid #f59e0b !important;
}

.tier-row-silver {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%) !important;
    border-left: 4px solid #94a3b8 !important;
}

.tier-row-cold {
    background: #f1f5f9 !important;
    border-left: 4px solid #64748b !important;
}

/* ── Header Day Counter Chip ── */
.day-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
    color: white;
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

@keyframes glowRed {
    0%   { box-shadow: 0 0 4px 1px rgba(220, 38, 38, 0.6); opacity: 1; }
    50%  { box-shadow: 0 0 12px 4px rgba(220, 38, 38, 0.9); opacity: 0.85; }
    100% { box-shadow: 0 0 4px 1px rgba(220, 38, 38, 0.6); opacity: 1; }
}

.glow-red-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #dc2626;
    animation: glowRed 1s ease-in-out infinite;
    flex-shrink: 0;
}

/* ── Steady Emerald: SUCCESS state — no animation, solid deep forest green ── */
.glow-emerald-steady {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #059669;
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.15), 0 0 6px 2px rgba(5, 150, 105, 0.35);
    flex-shrink: 0;
}

.action-btn {
    border: none;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.8rem;
    font-weight: 700;
    background: #1d4ed8;
    color: #ffffff;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.action-btn:hover:not(:disabled) {
    background: #1e40af;
}

.action-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.action-btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.action-btn-secondary:hover:not(:disabled) {
    background: #e5e7eb;
}

.universe-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    padding: 2px 0 4px;
}

.universe-hero-actions {
    min-width: 240px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.universe-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
}

.universe-summary-card {
    padding: 14px;
    border-radius: 12px;
    border: 1px solid #dbe4f0;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(248,250,252,0.95) 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

.universe-lane-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.universe-lane-card {
    border-radius: 14px;
    padding: 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #eef6ff 100%);
    border: 1px solid #dbeafe;
}

.universe-lane-title {
    font-size: 0.74rem;
    color: #475569;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.universe-lane-value {
    font-size: 2rem;
    line-height: 1;
    font-weight: 800;
    color: #0f172a;
    margin-top: 10px;
}

.universe-lane-caption {
    font-size: 0.76rem;
    color: #64748b;
    margin-top: 8px;
    line-height: 1.45;
}

@media (max-width: 960px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 18px;
    }

    nav {
        flex-wrap: wrap;
        gap: 14px;
    }

    .universe-hero {
        flex-direction: column;
    }

    .universe-hero-actions {
        min-width: 0;
        width: 100%;
        align-items: flex-start;
    }
}
