:root {
    --bg: #000000;
    --panel: #111111;
    --panel-2: #171717;
    --border: #2a2a2a;
    --text: #ededed;
    --muted: #a1a1aa;
    --accent: #0070f3;
    --accent-soft: rgba(0, 112, 243, 0.12);
    --good: #10b981;
    --warn: #f59e0b;
    --bad: #f87171;
}

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

body {
    font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 24px;
    line-height: 1.5;
}

[hidden] { display: none !important; }

/* ---------- header ---------- */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin: 0 auto 24px;
    max-width: 1500px;
}
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.page-head p { color: var(--muted); font-size: 14px; margin-top: 2px; }

.badge {
    background: rgba(255, 255, 255, 0.08);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.badge.ok { background: rgba(16, 185, 129, 0.15); color: var(--good); }
.badge.busy { background: rgba(245, 158, 11, 0.15); color: var(--warn); }
.badge.err { background: rgba(248, 113, 113, 0.15); color: var(--bad); }

/* ---------- layout ---------- */
.layout {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 24px;
    max-width: 1500px;
    margin: 0 auto;
    align-items: start;
}
.results { display: flex; flex-direction: column; gap: 24px; min-width: 0; }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    min-width: 0;
}
.inputs { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; }

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 16px;
}
.panel-head h2 { font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 8px; }

/* ---------- form ---------- */
.group { margin-bottom: 28px; }
.group-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; margin-bottom: 12px; min-width: 0; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }

label { font-size: 13px; font-weight: 600; margin-bottom: 6px; }

input[type="number"] {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 9px 11px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 112, 243, 0.25);
}
input.invalid { border-color: var(--bad); }

.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

.chip {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    background: var(--accent-soft);
    color: #6eb0ff;
    vertical-align: 1px;
}
.chip.nasa { background: rgba(16, 185, 129, 0.15); color: var(--good); }
.chip.manual { background: rgba(245, 158, 11, 0.15); color: var(--warn); }
.chip.fallback { background: rgba(248, 113, 113, 0.15); color: var(--bad); }
.chip.busy { background: rgba(255, 255, 255, 0.08); color: var(--muted); }

.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 14px;
}
.seg {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 8px 6px;
    border-radius: 5px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.seg.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }

.advanced { margin-top: 4px; }
.advanced summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-bottom: 12px; }

button { font-family: inherit; }
.btn-primary {
    width: 100%;
    background: var(--text);
    color: var(--bg);
    border: none;
    border-radius: 6px;
    padding: 13px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary:hover { background: #cfcfcf; }
.btn-primary:disabled { opacity: 0.55; cursor: progress; }

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.btn-ghost:hover:not(:disabled) { border-color: #555; background: rgba(255, 255, 255, 0.04); }
.btn-ghost.wide { width: 100%; padding: 10px; margin-top: 4px; font-size: 13px; }
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

.error {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(248, 113, 113, 0.4);
    background: rgba(248, 113, 113, 0.08);
    color: var(--bad);
    border-radius: 6px;
    font-size: 13px;
}

/* ---------- key/value lists ---------- */
.kv {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}
.kv > div { background: var(--panel); padding: 12px 14px; }
.kv dt { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.kv dd { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kv dd small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 4px; }

/* ---------- optimized system (vertical table) ---------- */
.empty { color: var(--muted); font-size: 14px; padding: 28px 8px; text-align: center; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; }
#opt-table { width: 100%; border-collapse: collapse; }
#opt-table th, #opt-table td {
    padding: 11px 18px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
#opt-table thead th { background: var(--panel-2); font-size: 13px; position: sticky; top: 0; }
#opt-table tbody th { text-align: left; font-weight: 500; color: var(--muted); background: var(--panel-2); position: sticky; left: 0; }
#opt-table td { text-align: right; }
#opt-table thead th:not(:first-child) { text-align: right; }
#opt-table tr:last-child th, #opt-table tr:last-child td { border-bottom: none; }
#opt-table tr.key td, #opt-table tr.key th { color: var(--good); font-weight: 700; background: rgba(16, 185, 129, 0.06); }
#opt-table td.miss { color: var(--bad); white-space: normal; min-width: 220px; text-align: left; font-size: 12px; }
#opt-table tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }

/* ---------- charts ---------- */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.chart-grid h3 { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.chart-box { position: relative; height: 320px; }

@media (max-width: 1100px) {
    .layout { grid-template-columns: 1fr; }
    .inputs { position: static; max-height: none; }
}
@media (max-width: 760px) {
    body { padding: 14px; }
    .chart-grid { grid-template-columns: 1fr; }
    .page-head { flex-direction: column; }
}

.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.chart-head h3 { margin: 0; }
.chart-dl { padding: 4px 10px; font-size: 12px; }

.radio { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; font-weight: 400; margin-top: 6px; }
.radio input { margin-top: 3px; }
#solar-file-row { margin-top: 8px; }

.login-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  background: rgba(8, 10, 18, 0.88); }
.login-overlay[hidden] { display: none; }
.login-box { width: min(360px, 90vw); display: flex; flex-direction: column; gap: 8px; padding: 24px;
  border-radius: 14px; background: var(--panel, #14182a); border: 1px solid var(--border, rgba(120,140,200,.25)); }
.login-box h2 { margin: 0; }
.login-box input { padding: 10px; border-radius: 8px; border: 1px solid var(--border, rgba(120,140,200,.25));
  background: transparent; color: inherit; font: inherit; }
.login-error { color: #f87171; font-size: 13px; margin: 0; }
#who { font-size: 13px; color: var(--muted); }
