﻿:root {
    --idle: #94a3b8;
    --active: #2563eb;
    --success: #16a34a;
    --warning: #d97706;
    --error: #dc2626;
    --stuck: #b91c1c;
    --llm: #7c3aed;
    --bg-deep: #f5f3ef;
    --bg-primary: #ffffff;
    --bg-card: #ffffff;
    --bg-elevated: #fafaf8;
    --bg-hover: #f0eeea;
    --border: #e2e0db;
    --border-subtle: #eceae5;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #8a8a8a;
    --accent: #c2410c;
    --accent-dim: rgba(194, 65, 12, 0.06);
    --accent-hover: rgba(194, 65, 12, 0.1);
    --font-mono: 'IBM Plex Mono', monospace;
    --font-sans: 'Plus Jakarta Sans', sans-serif;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    /* Extended palette for charts */
    --chart-1: #c2410c;
    --chart-2: #2563eb;
    --chart-3: #7c3aed;
    --chart-4: #16a34a;
    --chart-5: #d97706;
    --chart-6: #0891b2;
    --chart-7: #db2777;
    --chart-8: #4f46e5;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-deep);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════
   TOP BAR (identical to insights)
   ═══════════════════════════════════════════ */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-sans);
    font-weight: 800;
    font-size: 17px;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    text-decoration: none;
}

    .logo span {
        color: var(--accent);
    }

.logo-hex {
    width: 28px;
    height: 28px;
    background: var(--accent);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-hex-inner {
    width: 18px;
    height: 18px;
    background: var(--bg-primary);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.workspace-badge {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-deep);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.view-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-deep);
    padding: 4px;
    border-radius: var(--radius-md);
}

.view-tab {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

    .view-tab:hover {
        color: var(--text-secondary);
        background: var(--bg-hover);
    }

    .view-tab.active {
        background: var(--bg-primary);
        color: var(--accent);
        box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-deep);
    padding: 5px 14px;
    border-radius: 20px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse-dot 2.5s ease infinite;
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.3);
    }

    50% {
        opacity: 0.7;
        box-shadow: 0 0 0 5px rgba(22, 163, 74, 0);
    }
}

.env-selector {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    outline: none;
}

/* ═══════════════════════════════════════════
   ANALYTICS LAYOUT
   ═══════════════════════════════════════════ */

.analytics-container {
    height: calc(100vh - 56px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 32px 48px;
    scroll-behavior: smooth;
}

    .analytics-container::-webkit-scrollbar {
        width: 5px;
    }

    .analytics-container::-webkit-scrollbar-track {
        background: transparent;
    }

    .analytics-container::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 3px;
    }

/* Toolbar */
.analytics-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

    .analytics-toolbar label {
        font-size: 12px;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .analytics-toolbar select {
        font-family: var(--font-sans);
        font-size: 13px;
        font-weight: 500;
        background: var(--bg-elevated);
        border: 1px solid var(--border);
        color: var(--text-secondary);
        padding: 6px 12px;
        border-radius: var(--radius-sm);
        cursor: pointer;
        outline: none;
    }

.toolbar-spacer {
    flex: 1;
}

.toolbar-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

    .toolbar-title svg {
        color: var(--accent);
    }

/* Sections (reused from insights) */
.a-section {
    margin-bottom: 20px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.a-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
    border-bottom: 1px solid transparent;
}

    .a-section-header:hover {
        background: var(--bg-hover);
    }

    .a-section-header.expanded {
        border-bottom-color: var(--border-subtle);
    }

.section-chevron {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}

    .section-chevron.expanded {
        transform: rotate(90deg);
    }

.section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.section-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 4px;
}

.section-tag {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-dim);
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.3px;
    margin-left: auto;
}

.a-section-body {
    padding: 20px;
    display: none;
}

    .a-section-body.expanded {
        display: block;
    }

/* Grids */
.a-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.a-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.a-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.a-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* Cards */
.a-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: border-color 0.15s;
}

    .a-card:hover {
        border-color: var(--border);
    }

.a-card--full {
    grid-column: 1 / -1;
}

.a-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.a-card-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.a-card-body {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Big Numbers */
.a-big-number {
    font-family: var(--font-sans);
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

    .a-big-number.small {
        font-size: 22px;
    }

.a-metric-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

/* Badges */
.a-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
}

.a-badge--green {
    background: rgba(22,163,74,0.1);
    color: #16a34a;
}

.a-badge--amber {
    background: rgba(217,119,6,0.1);
    color: #d97706;
}

.a-badge--red {
    background: rgba(220,38,38,0.1);
    color: #dc2626;
}

.a-badge--blue {
    background: rgba(37,99,235,0.1);
    color: #2563eb;
}

.a-badge--purple {
    background: rgba(124,58,237,0.1);
    color: #7c3aed;
}

.a-badge--gray {
    background: rgba(148,163,184,0.1);
    color: #64748b;
}

/* Horizontal Bars */
.a-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.a-bar-label {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    width: 130px;
    text-align: right;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.a-bar-track {
    flex: 1;
    height: 20px;
    background: var(--bg-hover);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.a-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    padding-left: 6px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: white;
    font-weight: 600;
}

.a-bar-value {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    width: 70px;
    flex-shrink: 0;
}

/* Tables */
.a-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

    .a-table th {
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        font-size: 10px;
        padding: 8px 10px;
        text-align: left;
        border-bottom: 1px solid var(--border);
    }

    .a-table td {
        padding: 8px 10px;
        border-bottom: 1px solid var(--border-subtle);
        font-family: var(--font-mono);
        font-size: 12px;
        color: var(--text-secondary);
    }

    .a-table tr:last-child td {
        border-bottom: none;
    }

    .a-table tr:hover td {
        background: var(--bg-hover);
    }

/* Commentary boxes */
.commentary-box {
    background: var(--accent-dim);
    border: 1px solid rgba(194,65,12,0.12);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
}

    .commentary-box strong {
        color: var(--accent);
        font-weight: 700;
    }

    .commentary-box .highlight {
        font-family: var(--font-mono);
        font-weight: 700;
        color: var(--text-primary);
    }

/* Subsection divider */
.subsection-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 20px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
}

/* Heatmap */
.heatmap-grid {
    display: grid;
    gap: 2px;
    margin-top: 8px;
}

.heatmap-cell {
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    min-height: 28px;
    transition: transform 0.1s;
    cursor: default;
    position: relative;
}

    .heatmap-cell:hover {
        transform: scale(1.05);
        z-index: 1;
    }

    .heatmap-cell.empty {
        background: var(--bg-hover);
        color: var(--text-muted);
    }

.heatmap-label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    padding: 4px 0;
}

.heatmap-row-label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
}

/* Distribution strip */
.distribution-strip {
    display: flex;
    height: 32px;
    border-radius: 6px;
    overflow: hidden;
    margin: 8px 0;
}

    .distribution-strip .segment {
        display: flex;
        align-items: center;
        justify-content: center;
        font-family: var(--font-mono);
        font-size: 10px;
        font-weight: 600;
        color: white;
        transition: width 0.4s ease;
        min-width: 24px;
        cursor: default;
        position: relative;
    }

        .distribution-strip .segment:hover {
            filter: brightness(1.1);
        }

/* Rank indicator */
.rank-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.rank-1 {
    background: rgba(220,38,38,0.12);
    color: var(--error);
}

.rank-2 {
    background: rgba(217,119,6,0.12);
    color: var(--warning);
}

.rank-3 {
    background: rgba(37,99,235,0.12);
    color: var(--active);
}

.rank-low {
    background: rgba(22,163,74,0.12);
    color: var(--success);
}

/* Drilldown toggle */
.drilldown-toggle {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    background: transparent;
    border: 1px solid var(--accent);
    padding: 3px 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

    .drilldown-toggle:hover {
        background: var(--accent-dim);
    }

    .drilldown-toggle.active {
        background: var(--accent);
        color: white;
    }

.drilldown-content {
    display: none;
    margin-top: 12px;
}

    .drilldown-content.visible {
        display: block;
    }

/* Skill/Tool pills */
.usage-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    font-size: 12px;
    margin: 3px;
}

    .usage-pill .count {
        font-family: var(--font-mono);
        font-weight: 700;
        font-size: 14px;
        color: var(--text-primary);
    }

    .usage-pill .label {
        color: var(--text-secondary);
        font-weight: 500;
    }

    .usage-pill .sub {
        font-family: var(--font-mono);
        font-size: 10px;
        color: var(--text-muted);
    }

/* Verdict banners */
.verdict-banner {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.verdict-banner--green {
    background: rgba(22,163,74,0.08);
    color: var(--success);
}

.verdict-banner--amber {
    background: rgba(217,119,6,0.08);
    color: var(--warning);
}

.verdict-banner--red {
    background: rgba(220,38,38,0.08);
    color: var(--error);
}

/* Misc utilities */
.muted {
    color: var(--text-muted);
}

/* Fleet Status Strip */
.fleet-status-strip {
    display: flex;
    height: 32px;
    border-radius: 6px;
    overflow: hidden;
}

.fleet-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: white;
    transition: width 0.4s ease;
    min-width: 60px;
}

.fleet-seg--running {
    background: var(--success);
}

.fleet-seg--idle {
    background: var(--warning);
}

.fleet-seg--stopped {
    background: var(--error);
}

/* Status Grid (agent rows) */
.status-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.status-row {
    display: grid;
    grid-template-columns: 32px 140px 100px 120px 1fr 90px 90px;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    transition: border-color 0.15s, background 0.15s;
}

    .status-row:hover {
        border-color: var(--border);
        background: var(--bg-hover);
    }

.status-row--running {
    border-left: 3px solid var(--success);
}

.status-row--idle {
    border-left: 3px solid var(--warning);
}

.status-row--stopped {
    border-left: 3px solid var(--error);
    opacity: 0.8;
}

.status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
}

.heartbeat-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.heartbeat-dot--running {
    background: var(--success);
    animation: pulse-hb 2s ease infinite;
}

.heartbeat-dot--idle {
    background: var(--warning);
    animation: pulse-hb-slow 4s ease infinite;
}

.heartbeat-dot--stopped {
    background: var(--error);
    opacity: 0.5;
}

@keyframes pulse-hb {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(22,163,74,0.4);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(22,163,74,0);
    }
}

@keyframes pulse-hb-slow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(217,119,6,0.3);
        opacity: 1;
    }

    50% {
        box-shadow: 0 0 0 4px rgba(217,119,6,0);
        opacity: 0.6;
    }
}

.status-name {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-state {
    white-space: nowrap;
}

.status-heartbeat {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.status-last-event {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    white-space: nowrap;
}

.status-cost {
    text-align: right;
    white-space: nowrap;
}

.status-cpt {
    text-align: right;
    white-space: nowrap;
}

@media (max-width: 1100px) {
    .status-row {
        grid-template-columns: 32px 120px 90px 100px 1fr 80px;
    }

    .status-cpt {
        display: none;
    }
}

@media (max-width: 800px) {
    .status-row {
        grid-template-columns: 28px 1fr 90px 90px;
    }

    .status-heartbeat, .status-last-event, .status-cpt {
        display: none;
    }
}

.mono {
    font-family: var(--font-mono);
}

.mt-4 {
    margin-top: 4px;
}

.mt-8 {
    margin-top: 8px;
}

.mt-12 {
    margin-top: 12px;
}

.mt-16 {
    margin-top: 16px;
}

.mb-4 {
    margin-bottom: 4px;
}

.mb-8 {
    margin-bottom: 8px;
}

.mb-16 {
    margin-bottom: 16px;
}

.gap-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-sm {
    font-size: 12px;
}

.text-xs {
    font-size: 11px;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Responsive */
@media (max-width: 900px) {
    .a-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .a-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .a-grid-2 {
        grid-template-columns: 1fr;
    }

    .heatmap-grid {
        font-size: 8px;
    }
}

@media (max-width: 600px) {
    .a-grid-4, .a-grid-3, .a-grid-2 {
        grid-template-columns: 1fr;
    }

    .analytics-container {
        padding: 16px 12px 32px;
    }
}