/* ============================================
   Claude Telemetry Command Center
   A dark, dramatic mission-control aesthetic
   ============================================ */

:root {
    /* Base colors */
    --bg-deep: #06090f;
    --bg-primary: #0a0f1a;
    --bg-secondary: #111827;
    --bg-elevated: #1a2234;
    --bg-hover: #243049;

    /* Text colors */
    --text-primary: #f0f4f8;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Accent colors */
    --accent-cyan: #00d4ff;
    --accent-cyan-dim: rgba(0, 212, 255, 0.15);
    --accent-cyan-glow: rgba(0, 212, 255, 0.4);

    /* Stage colors - heat gradient */
    --stage-analysis: #3b82f6;
    --stage-compute-read: #22c55e;
    --stage-compute-write: #ef4444;
    --stage-data-read: #f59e0b;
    --stage-data-copy: #a855f7;
    --stage-cleanup: #6b7280;

    /* Domain colors */
    --domain-aws: #ff9900;
    --domain-gcp: #4285f4;
    --domain-azure: #0078d4;

    /* Status colors */
    --status-success: #22c55e;
    --status-warning: #f59e0b;
    --status-error: #ef4444;
    --status-terminated: #6b7280;

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.1);

    /* Spacing */
    --sidebar-width: 280px;
    --top-bar-height: 60px;

    /* Typography */
    --font-display: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-medium: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--font-display);
    background: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
}

/* ============================================
   Background Effects
   ============================================ */

.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
}

.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    pointer-events: none;
    z-index: 0;
}

.bg-glow-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-cyan-glow) 0%, transparent 70%);
    top: -200px;
    left: -200px;
    opacity: 0.3;
}

.bg-glow-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.3) 0%, transparent 70%);
    bottom: -150px;
    right: -150px;
    opacity: 0.2;
}

/* ============================================
   App Container
   ============================================ */

.app-container {
    display: flex;
    height: 100vh;
    position: relative;
    z-index: 1;
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--stage-data-copy) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.logo-icon svg {
    width: 22px;
    height: 22px;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.logo-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.sidebar-section {
    padding: 1.25rem;
    flex: 1;
    overflow-y: auto;
}

.sidebar-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

/* Campaign List */
.campaign-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 0.5rem;
    border: 1px solid transparent;
}

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

.campaign-item.active {
    background: var(--accent-cyan-dim);
    border-color: var(--accent-cyan);
}

.campaign-indicator {
    width: 4px;
    height: 100%;
    min-height: 32px;
    border-radius: 2px;
    flex-shrink: 0;
}

.campaign-info {
    flex: 1;
    min-width: 0;
}

.campaign-name {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.campaign-stats {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Sidebar Stats */
.sidebar-stats {
    border-top: 1px solid var(--border-subtle);
    flex: 0;
    padding: 1.25rem;
}

#sidebar-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.sidebar-stat {
    background: var(--bg-secondary);
    padding: 0.75rem;
    border-radius: 8px;
    text-align: center;
}

.sidebar-stat-value {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1rem;
    color: var(--accent-cyan);
    display: block;
}

.sidebar-stat-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: block;
}

/* ============================================
   Main Content
   ============================================ */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-secondary);
}

/* Top Bar */
.top-bar {
    height: var(--top-bar-height);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-primary);
    flex-shrink: 0;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.25rem;
}

.tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.tab svg {
    width: 16px;
    height: 16px;
}

.tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tab.active {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
}

/* Live Indicator */
.live-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 20px;
}

.live-dot {
    width: 8px;
    height: 8px;
    background: var(--status-success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.9); }
}

.live-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--status-success);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Flame Graph Section
   ============================================ */

.flame-header {
    margin-bottom: 1.5rem;
}

.flame-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.campaign-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.campaign-meta .meta-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.campaign-meta .meta-item strong {
    color: var(--text-primary);
    font-weight: 600;
    font-family: var(--font-mono);
}

.campaign-meta .meta-divider {
    color: var(--text-muted);
    opacity: 0.5;
}

.flame-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    padding: 1.5rem;
    min-height: 500px;
    position: relative;
    overflow: hidden;
}

.flame-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, var(--accent-cyan-dim) 0%, transparent 30%);
    pointer-events: none;
    opacity: 0.3;
}

#flame-graph {
    width: 100%;
    overflow-x: auto;
    position: relative;
    z-index: 1;
}

#flame-graph svg {
    display: block;
}

/* D3 Time Axis */
.time-axis path,
.time-axis line {
    stroke: var(--border-medium);
}

.time-axis text {
    fill: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10px;
}

.flame-rect {
    cursor: pointer;
    transition: all var(--transition-fast);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.flame-rect:hover {
    filter: brightness(1.2) drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

.flame-label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    fill: white;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Tooltip */
.tooltip {
    position: fixed;
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 1000;
    max-width: 320px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
}

.tooltip.hidden {
    display: none;
}

.tooltip-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
}

.tooltip-label {
    color: var(--text-muted);
}

.tooltip-value {
    font-family: var(--font-mono);
    font-weight: 500;
}

/* Tooltip status colors */
.tooltip .status-success {
    color: var(--status-success);
}

.tooltip .status-error {
    color: var(--status-error);
}

.tooltip .status-partial {
    color: var(--status-warning);
}

.tooltip .status-terminated {
    color: var(--status-terminated);
}

/* ============================================
   Grid Section
   ============================================ */

.grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.grid-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.summary-stats {
    display: flex;
    gap: 2rem;
}

.summary-stat {
    text-align: center;
}

.summary-stat-value {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent-cyan);
}

.summary-stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.sessions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

/* Stage Card */
.stage-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 1.25rem;
    cursor: pointer;
    transition: all var(--transition-medium);
    position: relative;
    overflow: hidden;
}

.stage-card:hover {
    border-color: var(--border-medium);
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}

.stage-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.stage-card-indicator {
    width: 4px;
    height: 24px;
    border-radius: 2px;
    flex-shrink: 0;
}

.stage-card-title {
    font-weight: 600;
    font-size: 0.95rem;
    text-transform: capitalize;
    color: var(--text-primary);
}

.stage-card-instance {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.instance-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: white;
}

.instance-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stage-card-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.stage-metric {
    background: var(--bg-secondary);
    padding: 0.5rem;
    border-radius: 6px;
    text-align: center;
}

.stage-metric-value {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    display: block;
}

.stage-metric-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-top: 0.125rem;
    display: block;
}

.stage-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-subtle);
}

.stage-status {
    padding: 0.25rem 0.625rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.stage-status.status-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--status-success);
}

.stage-status.status-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-error);
}

.stage-status.status-partial {
    background: rgba(245, 158, 11, 0.15);
    color: var(--status-warning);
}

.stage-status.status-terminated {
    background: rgba(107, 114, 128, 0.15);
    color: var(--status-terminated);
}

.stage-campaign {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   Flyout Panel
   ============================================ */

.flyout {
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
}

.flyout.hidden {
    display: none;
}

.flyout:not(.hidden) {
    pointer-events: auto;
}

.flyout-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.flyout-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 50vw;
    min-width: 400px;
    max-width: 80vw;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-medium);
    padding: 2rem;
    overflow-y: auto;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.flyout-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
    background: transparent;
    transition: background 0.2s;
    z-index: 10;
}

.flyout-resize-handle:hover,
.flyout-resize-handle:active {
    background: var(--accent-cyan-dim);
}

.flyout-resize-handle::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 40px;
    background: var(--border-medium);
    border-radius: 1px;
    opacity: 0;
    transition: opacity 0.2s;
}

.flyout-resize-handle:hover::before {
    opacity: 1;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.flyout-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-hover);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.flyout-close:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.flyout-close svg {
    width: 18px;
    height: 18px;
}

/* Flyout Content */
.flyout-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-right: 3rem;
}

.flyout-title {
    font-size: 1.5rem;
    font-weight: 600;
    text-transform: capitalize;
}

.flyout-status {
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.flyout-status.status-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--status-success);
}

.flyout-status.status-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-error);
}

.flyout-status.status-partial {
    background: rgba(245, 158, 11, 0.15);
    color: var(--status-warning);
}

.flyout-status.status-terminated {
    background: rgba(107, 114, 128, 0.15);
    color: var(--status-terminated);
}

.flyout-meta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 10px;
}

.flyout-meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.flyout-meta-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.flyout-meta-value {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.flyout-section {
    margin-bottom: 2rem;
}

.flyout-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.logs-container,
.tools-container {
    background: var(--bg-deep);
    border-radius: 8px;
    padding: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

.empty-state {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 1.5rem;
}

/* Log Entries */
.log-container {
    background: var(--bg-deep);
    border-radius: 8px;
    padding: 1rem;
    max-height: 300px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.log-entry {
    display: flex;
    gap: 0.75rem;
    padding: 0.375rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-time {
    color: var(--text-muted);
    min-width: 55px;
}

.log-type {
    min-width: 60px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 3px;
    text-align: center;
}

.log-info .log-type {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.log-success .log-type {
    background: rgba(34, 197, 94, 0.2);
    color: var(--status-success);
}

.log-warning .log-type {
    background: rgba(245, 158, 11, 0.2);
    color: var(--status-warning);
}

.log-error .log-type {
    background: rgba(239, 68, 68, 0.2);
    color: var(--status-error);
}

.log-message {
    color: var(--text-secondary);
    flex: 1;
}

/* Tool Calls */
.tool-call {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
    border-left: 3px solid var(--accent-cyan);
    margin-bottom: 0.75rem;
}

.tool-call:last-child {
    margin-bottom: 0;
}

.tool-header {
    margin-bottom: 0.5rem;
}

.tool-name {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--accent-cyan);
}

.tool-input,
.tool-output {
    background: var(--bg-deep);
    padding: 0.75rem;
    border-radius: 6px;
    margin-top: 0.5rem;
    overflow-x: auto;
}

.tool-input code,
.tool-output code {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
}

.tool-output {
    border-left: 2px solid var(--status-success);
}

/* ============================================
   Scrollbar Styling
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 1200px) {
    .sidebar {
        width: 240px;
    }
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 50;
        transition: transform var(--transition-medium);
    }

    .sidebar.open {
        transform: translateX(280px);
    }

    .main-content {
        margin-left: 0;
    }
}

/* ============================================
   View Header (shared)
   ============================================ */

.view-header {
    margin-bottom: 1.5rem;
}

.view-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.view-description {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ============================================
   Timeline View
   ============================================ */

.timeline-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    padding: 1.5rem;
    min-height: 400px;
    overflow-x: auto;
}

.timeline-svg .instance-name {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 500;
    fill: var(--text-primary);
}

.timeline-svg .instance-resource-id {
    font-family: var(--font-mono);
    font-size: 9px;
    fill: var(--text-muted);
}

.timeline-svg .stage-label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    fill: white;
    pointer-events: none;
}

.timeline-svg .instance-label {
    transition: opacity 0.2s ease;
}

.timeline-svg .instance-label:hover {
    opacity: 0.8;
}

/* ============================================
   Lineage View
   ============================================ */

.lineage-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    padding: 1.5rem;
    min-height: 500px;
    overflow: auto;
}

.lineage-svg .lineage-link {
    fill: none;
    stroke-opacity: 0.8;
}

.lineage-svg .node-label {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 500;
    fill: var(--text-primary);
}

.lineage-svg .node-sublabel {
    font-family: var(--font-mono);
    font-size: 10px;
    fill: var(--text-secondary);
}

.lineage-svg .node-icon {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    fill: var(--text-primary);
}

.lineage-svg .env-label {
    font-size: 11px;
    font-weight: 600;
    fill: white;
}

.lineage-svg .campaign-label {
    fill: var(--text-primary);
}

.lineage-svg .spawn-icon {
    font-size: 8px;
    fill: white;
}

/* ============================================
   Flame Graph View (updated)
   ============================================ */

.flame-svg .flame-label {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 500;
    fill: white;
}

.flame-svg .flame-stats {
    font-family: var(--font-mono);
    font-size: 10px;
    fill: rgba(255, 255, 255, 0.7);
}

.flame-svg .instance-label {
    font-size: 11px;
}

.flame-svg .stage-label {
    font-size: 10px;
}

.flame-row {
    transition: opacity 0.15s ease;
}

.flame-row:hover {
    opacity: 0.9;
}

/* ============================================
   Graph View
   ============================================ */

.graph-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    padding: 1.5rem;
    min-height: 500px;
    position: relative;
    overflow: hidden;
}

.graph-controls {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 10;
}

.control-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.control-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.control-toggle input[type="checkbox"] {
    accent-color: var(--accent-cyan);
    width: 14px;
    height: 14px;
}

.graph-svg .node-label {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 500;
    fill: var(--text-primary);
}

.graph-svg .node-sublabel {
    font-family: var(--font-mono);
    font-size: 9px;
    fill: var(--text-secondary);
}

.graph-svg .node-icon {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 600;
    fill: var(--text-primary);
}

.graph-svg .env-label {
    font-size: 10px;
    font-weight: 600;
    fill: white;
}

.graph-svg .link-label {
    font-family: var(--font-mono);
    font-size: 8px;
    fill: var(--text-muted);
    text-anchor: middle;
}

.graph-svg .graph-link {
    stroke-opacity: 0.8;
}

.graph-svg .graph-node {
    transition: opacity 0.15s ease;
}

.graph-svg .graph-node:hover {
    opacity: 0.85;
}

/* ============================================
   Tooltip Enhancements
   ============================================ */

.tooltip-header {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    gap: 1rem;
}

.tooltip-row span:first-child {
    color: var(--text-muted);
}

.tooltip-findings {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-subtle);
}

.tooltip-findings .finding {
    font-size: 0.8rem;
    padding: 0.25rem 0;
}

.tooltip-findings .severity-info { color: #60a5fa; }
.tooltip-findings .severity-warning { color: var(--status-warning); }
.tooltip-findings .severity-error { color: var(--status-error); }
.tooltip-findings .severity-critical { color: #a855f7; }

.spawn-info {
    color: var(--stage-compute-write);
}

/* ============================================
   Updated Flyout Styles
   ============================================ */

.flyout-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.flyout-title-row .flyout-title {
    flex: 1;
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
}

.flyout-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.flyout-badges {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.flyout-resource-id {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    word-break: break-all;
}

.stage-badge,
.instance-type-badge,
.provider-badge {
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    font-family: var(--font-mono);
    text-transform: uppercase;
    color: white;
}

.status-badge {
    padding: 0.25rem 0.625rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.status-success,
.status-badge.status-completed {
    background: rgba(34, 197, 94, 0.15);
    color: var(--status-success);
}

.status-badge.status-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-error);
}

.status-badge.status-terminated {
    background: rgba(107, 114, 128, 0.15);
    color: var(--status-terminated);
}

.status-badge.status-running {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.flyout-header {
    margin-bottom: 1.5rem;
    padding-right: 3rem;
}

.flyout-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-top: 1rem;
}

.flyout-meta .meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.flyout-meta .meta-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.flyout-meta .meta-value {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.flyout-meta .meta-value.monospace {
    font-size: 0.75rem;
    word-break: break-all;
}

.flyout-body {
    padding-right: 0.5rem;
}

.flyout-section {
    margin-bottom: 1.5rem;
}

.flyout-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

/* Findings List */
.findings-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.finding-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    border-left: 3px solid;
}

.finding-item.severity-info {
    border-color: #60a5fa;
}

.finding-item.severity-warning {
    border-color: var(--status-warning);
}

.finding-item.severity-error {
    border-color: var(--status-error);
}

.finding-item.severity-critical {
    border-color: #a855f7;
}

.finding-type {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    min-width: 60px;
}

.finding-value {
    font-size: 0.85rem;
    color: var(--text-primary);
}

/* Model Usage */
.model-usage-list {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 0.75rem;
}

.model-usage-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

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

.model-name {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-cyan);
}

.model-tokens {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.model-cost {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Events List (Tool Calls) */
.events-list {
    max-height: 400px;
    overflow-y: auto;
}

.tool-call {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 0.875rem;
    margin-bottom: 0.75rem;
    border-left: 3px solid var(--accent-cyan);
}

.tool-call.has-error {
    border-left-color: var(--status-error);
}

.tool-call-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.tool-name {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--accent-cyan);
}

.tool-duration {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
}

.tool-error-badge {
    padding: 0.125rem 0.375rem;
    background: rgba(239, 68, 68, 0.2);
    color: var(--status-error);
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 3px;
}

.tool-input {
    background: var(--bg-deep);
    padding: 0.625rem;
    border-radius: 4px;
    margin-top: 0.5rem;
}

.tool-input code {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
}

.tool-output {
    margin-top: 0.5rem;
}

.tool-output.stdout {
    background: rgba(34, 197, 94, 0.1);
    border-left: 2px solid var(--status-success);
    padding: 0.625rem;
    border-radius: 4px;
}

.tool-output.stderr {
    background: rgba(239, 68, 68, 0.1);
    border-left: 2px solid var(--status-error);
    padding: 0.625rem;
    border-radius: 4px;
}

.tool-output pre {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
}

/* Identity Section */
.identity-list,
.sysinfo-list,
.details-list {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 0.75rem;
}

.identity-row,
.sysinfo-row,
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.identity-row:last-child,
.sysinfo-row:last-child,
.detail-row:last-child {
    border-bottom: none;
}

.identity-key,
.sysinfo-key,
.detail-key {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.identity-value,
.sysinfo-value,
.detail-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-primary);
    text-align: right;
    max-width: 60%;
    word-break: break-all;
}

/* Spawn Section */
.spawn-section {
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    padding: 1rem;
}

.spawn-info .spawn-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.spawn-info .spawn-row:last-child {
    margin-bottom: 0;
}

.spawn-key {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.spawn-value {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.spawn-command {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-deep);
    padding: 0.5rem;
    border-radius: 4px;
    display: block;
    word-break: break-all;
}

/* Lineage Info */
.lineage-info {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 0.75rem;
}

.lineage-row {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.lineage-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 80px;
}

.lineage-value {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.lineage-value.seed {
    color: var(--accent-cyan);
    font-weight: 500;
}

/* Stages Summary */
.stages-summary-list {
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
}

.stage-summary-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid var(--border-subtle);
}

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

.stage-summary-row:hover {
    background: var(--bg-hover);
}

.stage-color {
    width: 4px;
    height: 20px;
    border-radius: 2px;
    flex-shrink: 0;
}

.stage-summary-row .stage-name {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.stage-summary-row .stage-duration {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stage-summary-row .stage-status {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* Instances Summary */
.instances-summary-list {
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
}

.instance-summary-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid var(--border-subtle);
}

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

.instance-summary-row:hover {
    background: var(--bg-hover);
}

.instance-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.instance-status-dot.status-success,
.instance-status-dot.status-completed {
    background: var(--status-success);
}

.instance-status-dot.status-terminated {
    background: var(--status-terminated);
}

.instance-status-dot.status-error {
    background: var(--status-error);
}

.instance-summary-row .instance-name {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
}

.instance-summary-row .instance-type {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.instance-summary-row .instance-stages {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Status text colors */
.status-success, .status-completed { color: var(--status-success); }
.status-error { color: var(--status-error); }
.status-terminated { color: var(--status-terminated); }
.status-warning, .status-partial { color: var(--status-warning); }
.status-running, .status-pending { color: #60a5fa; }

/* ============================================
   Overview View
   ============================================ */

.overview-container {
    padding: 0;
}

.overview-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

@media (max-width: 1200px) {
    .overview-grid {
        grid-template-columns: 1fr;
    }
}

.overview-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    padding: 1.5rem;
}

.overview-card h3 {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}

/* Summary Card */
.overview-summary {
    grid-column: 1 / -1;
}

.overview-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 600px) {
    .overview-stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.overview-stat {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.overview-stat-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent-cyan);
    display: block;
    margin-bottom: 0.25rem;
}

.overview-stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.overview-timeline {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
}

.timeline-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

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

.timeline-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.timeline-value {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
}

/* Environment List */
.env-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.env-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.env-row:hover {
    background: var(--bg-hover);
}

.env-indicator {
    width: 4px;
    height: 36px;
    border-radius: 2px;
    flex-shrink: 0;
}

.env-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.env-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.env-provider {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
}

.env-stats {
    display: flex;
    gap: 0.75rem;
}

.env-stat {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    background: var(--bg-deep);
    border-radius: 4px;
}

/* Stage Breakdown */
.stage-breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stage-breakdown-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.stage-breakdown-indicator {
    width: 4px;
    height: 20px;
    border-radius: 2px;
    flex-shrink: 0;
}

.stage-breakdown-name {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.stage-breakdown-count {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 30px;
}

.stage-breakdown-duration {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: right;
}

.stage-breakdown-cost {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent-cyan);
    min-width: 50px;
    text-align: right;
}

/* Findings Overview */
.overview-findings {
    max-height: 450px;
    overflow-y: auto;
}

.findings-groups {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.findings-group {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 0.75rem;
}

.findings-group.severity-critical {
    border-left: 3px solid #a855f7;
}

.findings-group.severity-error {
    border-left: 3px solid var(--status-error);
}

.findings-group.severity-warning {
    border-left: 3px solid var(--status-warning);
}

.findings-group.severity-info {
    border-left: 3px solid #60a5fa;
}

.findings-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.findings-group-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}

.findings-group-count {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.125rem 0.375rem;
    background: var(--bg-deep);
    border-radius: 3px;
}

.finding-overview-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.375rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.finding-overview-item:last-child {
    border-bottom: none;
}

.finding-overview-type {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    min-width: 60px;
}

.finding-overview-value {
    font-size: 0.8rem;
    color: var(--text-primary);
    flex: 1;
}

.findings-more {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    padding-top: 0.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border-subtle);
}
