:root {
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --border: #e5e7eb;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    /* Dark banner palette */
    --banner-bg-from: #0b1220;
    --banner-bg-to: #020617;
    --banner-border: rgba(56, 189, 248, 0.30);
    --banner-text: #e5e7eb;
    --banner-label: #93c5fd;
    --banner-muted: #9ca3af;
    --tile-bg: rgba(15, 23, 42, 0.85);
    --tile-border: rgba(148, 163, 184, 0.35);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Mission split layout: banner full-width on top, panels below (matches Lun_mvp disposition) */
.mission-split-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.col-left {
    width: 100%;
    min-width: 0;
}

/* Analysis panels column: stacked vertically on all screens */
.col-right {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    min-width: 0;
}

header {
    margin-bottom: 2rem;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.file-drop-area {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 2px dashed var(--border);
    border-radius: 6px;
    background-color: #f9fafb;
    margin-bottom: 1rem;
    transition: 0.2s;
}

.file-drop-area:hover {
    border-color: var(--primary);
    background-color: #eff6ff;
}

.file-msg {
    color: var(--text-muted);
}

.file-input {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 100%;
    cursor: pointer;
    opacity: 0;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
}

.btn.primary {
    background-color: var(--primary);
    color: white;
    width: 100%;
    font-size: 1rem;
}

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

.btn.secondary {
    background-color: var(--border);
    color: var(--text-main);
}

.btn.small {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.btn.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem 0;
}

/* ── Chip Bar ─────────────────────────────────── */
.chip-bar-section {
    padding-bottom: 1rem;
}

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

.chip-bar-header h2 {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

#chip-bar {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.5rem;
    padding-bottom: 0.25rem;
}

.run-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    border: 2px solid transparent;
    background: var(--card-bg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    white-space: nowrap;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-main);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.run-chip:hover {
    border-color: var(--primary);
}

.run-chip.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

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

.chip-dot-CREATED {
    background: #9ca3af;
}

.chip-dot-QUEUED {
    background: #f59e0b;
}

.chip-dot-RUNNING {
    background: #3b82f6;
    animation: pulse 1.2s infinite;
}

.chip-dot-SUCCEEDED {
    background: #10b981;
}

.chip-dot-FAILED {
    background: #ef4444;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ── Mission Panel ───────────────────────────── */
.mission-header {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

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

.mission-title-row .run-id-short {
    font-size: 1.1rem;
    font-weight: 600;
}

.run-item {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.run-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.run-status {
    padding: 0.2em 0.6em;
    border-radius: 999px;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.status-CREATED {
    background: #e5e7eb;
    color: #374151;
}

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

.status-RUNNING {
    background: #dbeafe;
    color: #1e40af;
}

.status-SUCCEEDED {
    background: #d1fae5;
    color: #065f46;
}

.status-FAILED {
    background: #fee2e2;
    color: #991b1b;
}

.run-details {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    word-break: break-word;
}

.run-error {
    color: var(--error);
    font-size: 0.875rem;
    background: #fef2f2;
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    white-space: pre-wrap;
    font-family: monospace;
}

.run-artifacts {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
}

.artifacts-list {
    list-style: none;
    margin-top: 0.5rem;
}

.artifacts-list li {
    margin-bottom: 0.25rem;
}

.artifacts-list a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.875rem;
}

.artifacts-list a:hover {
    text-decoration: underline;
}

/* Config Editor Styling */
.run-config fieldset {
    border: none;
    margin-bottom: 0.5rem;
    padding-left: 1rem;
    border-left: 2px solid var(--border);
}

.run-config legend {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-main);
    padding: 0 0.25rem;
}

.config-field {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.config-field label {
    flex: 0 0 150px;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.config-field input[type="text"],
.config-field input[type="number"] {
    flex: 1;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.875rem;
    max-width: 200px;
}

.config-field input[type="checkbox"] {
    margin-top: 0.15rem;
}

/* ═══════════════════════════════════════════════════════════════
   Panel Sections
   ═══════════════════════════════════════════════════════════════ */

.panel-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

/* In the col-right grid, each visible panel is a self-contained card */
.col-right > .panel-section {
    margin-top: 0;
    padding-top: 1.25rem;
    border-top: none;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.panel-section-header {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}

.panel-section-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}

.panel-section-note {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.run-components {
    overflow-x: auto;
}

/* ── 3D Viewer section ── */

.run-viewer .viewer-host {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: #0a0f1e;
}

/* ── 3D Viewer section ── */

.run-viewer .viewer-host {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: #0a0f1e;
}

/* ── Component Budget Table ── */

.budget-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    margin-top: 0;
}

.budget-table thead th {
    background: #1e2433;
    color: #93c5fd;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.7rem;
    padding: 7px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.budget-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.budget-table tbody tr:hover {
    background: #eff6ff;
}

.budget-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #f0f0f0;
    color: var(--text-main);
    vertical-align: middle;
}

/* Numeric columns right-aligned */
.budget-table .num-col {
    text-align: right;
}

.budget-table td.highlight-max {
    font-weight: bold !important;
}

.budget-table tfoot td {
    padding: 7px 10px;
    border-top: 2px solid #1e2433;
    background: #f0f6ff;
    font-size: 0.8125rem;
}

/* ── Power Budget Panel ── */

.power-kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.power-kpi-tile {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.power-kpi-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.power-kpi-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

/* Margin tile colour states */
.power-kpi-margin.margin-ok {
    border-color: #22c55e;
    background: #f0fdf4;
}

.power-kpi-margin.margin-warn {
    border-color: #f59e0b;
    background: #fffbeb;
}

.power-kpi-margin.margin-crit {
    border-color: #ef4444;
    background: #fef2f2;
}

.power-kpi-margin.margin-ok .power-kpi-value {
    color: #15803d;
}

.power-kpi-margin.margin-warn .power-kpi-value {
    color: #92400e;
}

.power-kpi-margin.margin-crit .power-kpi-value {
    color: #b91c1c;
}

/* Stacked bar */
.power-bar-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.power-bar-track {
    height: 12px;
    background: #e2e8f0;
    border-radius: 99px;
    position: relative;
    overflow: hidden;
    display: flex;
}

.power-bar-generated {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    height: 100%;
    border-radius: 99px 0 0 99px;
    transition: width 0.4s ease;
}

.power-bar-consumed {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
    height: 100%;
    transition: width 0.4s ease;
}

.power-bar-legend {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    gap: 1rem;
    align-items: center;
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 3px;
}

.legend-generated {
    background: #3b82f6;
}

.legend-consumed {
    background: #f59e0b;
}

/* ── Engineering Insights ── */
.insights-box {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.insight {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    border-left: 4px solid var(--border);
    background: var(--card-bg);
}

.insight-info {
    border-left-color: var(--primary);
    background: #eff6ff;
    color: #1e3a8a;
}

.insight-warning {
    border-left-color: var(--warning);
    background: #fffbeb;
    color: #92400e;
}

.insight-critical {
    border-left-color: var(--error);
    background: #fef2f2;
    color: #991b1b;
}

/* ═══════════════════════════════════════════════════════════════
   Mission Summary Banner
   ═══════════════════════════════════════════════════════════════ */

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ═══════════════════════════════════════════════════════════════
   Live Logs Modern IDE Styling
   ═══════════════════════════════════════════════════════════════ */
.run-logs {
    background: #1e1e1e !important;
    color: #cccccc !important;
    font-family: 'Consolas', 'Fira Code', 'JetBrains Mono', monospace !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
}

.log-info { color: #569cd6; }
.log-warn { color: #d7ba7d; }
.log-error { color: #f44336; font-weight: bold; }
.log-debug { color: #9cdcfe; }
.log-time { color: #888888; }

.mission-banner-data {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mission-summary-banner {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: linear-gradient(135deg, var(--banner-bg-from), var(--banner-bg-to) 70%);
    border-radius: 12px;
    padding: 18px 20px;
    border: 1px solid var(--banner-border);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    margin-bottom: 1.25rem;
    color: var(--banner-text);
}

.mission-banner-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.mission-banner-data {
    flex: 1;
}

/* ── Left column: title + param rows ── */

.mission-header-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mission-summary-banner .mission-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.mission-summary-banner .run-id-short {
    font-size: 1rem;
    font-weight: 600;
    color: #e5f2ff;
    word-break: break-word;
}

.mission-summary-banner .run-status {
    /* override light-mode styles */
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: 999px;
}

/* Dark-mode overrides for status badges */
.mission-summary-banner .status-CREATED {
    background: rgba(156, 163, 175, 0.2);
    color: #d1d5db;
    border: 1px solid rgba(156, 163, 175, 0.4);
}

.mission-summary-banner .status-QUEUED {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.mission-summary-banner .status-RUNNING {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.mission-summary-banner .status-SUCCEEDED {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.mission-summary-banner .status-FAILED {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.mission-param-rows {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 4px;
}

.mission-param-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 0.8125rem;
}

.mission-param-label {
    font-weight: 500;
    color: var(--banner-label);
    min-width: 76px;
    flex-shrink: 0;
}

.mission-param-value {
    color: #cbd5e1;
}

.mission-preview {
    flex: 0 0 240px;
    height: 240px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 0;
}

.mission-preview .orbit-preview-img {
    width: 240px;
    height: 240px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(10, 15, 30, 0.6);
}

.mission-preview .orbit-preview-msg {
    font-size: 0.75rem;
    color: var(--banner-muted);
    text-align: center;
    padding: 1rem 0;
}

/* Grouped Parameters Layout */
.mission-param-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 12px;
}

.param-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.param-group-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--banner-label);
    font-weight: 600;
    margin-bottom: 4px;
}

.param-item {
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    color: #cbd5e1;
}

.param-label {
    color: var(--banner-muted);
    font-weight: 500;
    margin-right: 8px;
}

.param-value {
    text-align: right;
    font-weight: 600;
}

/* ── Right column: metric tiles grid ── */

.mission-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.metric-tile {
    background: var(--tile-bg);
    border: 1px solid var(--tile-border);
    border-radius: 8px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.metric-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--banner-muted);
}

.metric-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: #e5e7eb;
}

/* ── Run details row (file + time) inside banner ── */

.mission-summary-banner .run-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 0.78rem;
    color: var(--banner-muted);
    margin: 0;
}

/* ── Responsive ── */

@media (max-width: 900px) {
    .mission-summary-banner {
        grid-template-columns: 1fr;
    }

    .mission-metrics {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 560px) {
    .mission-metrics {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .mission-banner-content {
        flex-direction: column-reverse;
        align-items: center;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Wizard Dashboard
   ═══════════════════════════════════════════════════════════════ */

.wizard-panels {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.wizard-panel {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fafafa;
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.wizard-panel[open] {
    background: #ffffff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border-color: #cbd5e1;
}

.wizard-panel summary {
    padding: 1rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    list-style: none; /* Hide default arrow */
    display: flex;
    align-items: center;
    background: #f8fafc;
    border-bottom: 1px solid transparent;
}

.wizard-panel[open] summary {
    border-bottom-color: var(--border);
    background: #f1f5f9;
}

/* Custom chevron */
.wizard-panel summary::before {
    content: "►";
    font-size: 0.7rem;
    margin-right: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.wizard-panel[open] summary::before {
    transform: rotate(90deg);
}

.wizard-content {
    padding: 1.25rem 1rem;
}

.wizard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.wizard-grid label {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    gap: 0.4rem;
}

.wizard-grid input[type="number"], .wizard-grid input[type="text"], .wizard-grid select {
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
    background-color: var(--card-bg);
    box-sizing: border-box;
    height: 34px;
}

.wizard-grid input:focus, .wizard-grid select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.wizard-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.wizard-checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
}

/* ── Grouped Parameter Tiles inside Summary Banner ── */
.banner-param-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.param-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.tile-wide {
    grid-column: span 2;
}

/* Override mission-banner-data to use 3 columns on desktop */
.mission-banner-data {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    flex: 1;
}

@media (max-width: 1024px) {
    .mission-banner-data {
        grid-template-columns: 1fr;
    }
}

/* Spinner for status areas */
.spinner {
    display: inline-block;
    width: 0.95rem;
    height: 0.95rem;
    border: 2px solid rgba(0, 0, 0, 0.15);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
    margin-right: 0.4rem;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
