/* admin.css - Instructor console. Deliberately independent of the simulator's
   stylesheet so the two applications can be deployed and changed separately. */

:root {
    --bg: #0b1220;
    --panel: #111a2e;
    --panel-2: #14203a;
    --line: #24324d;
    --text: #e6edf7;
    --text-2: #a3b1c9;
    --text-3: #6b7c99;
    --blue: #60a5fa;
    --green: #34d399;
    --amber: #fbbf24;
    --red: #f87171;
    --mono: "JetBrains Mono", "SF Mono", Consolas, monospace;
    --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root[data-theme="light"] {
    --bg: #eef1f6;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --line: #dbe1ea;
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #94a3b8;
    --blue: #2563eb;
    --green: #059669;
    --amber: #b45309;
    --red: #dc2626;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    line-height: 1.45;
    min-height: 100vh;
}
code { font-family: var(--mono); }
[hidden] { display: none !important; }

.btn {
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 7px 13px;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); color: #fff; }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 9px; font-size: 0.72rem; }

select, input[type="text"], input[type="password"] {
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 7px 9px;
    font-size: 0.78rem;
    font-family: inherit;
}
select:focus, input:focus { outline: 2px solid var(--blue); outline-offset: -1px; }

/* ---------------- Gate ---------------- */
.gate {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center; padding: 1.5rem;
    background: linear-gradient(160deg, #0b1220, #16233c);
    overflow-y: auto;
}
.gate-panel {
    width: 100%; max-width: 440px;
    background: #111a2e; border: 1px solid #35486e;
    padding: 1.7rem; box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.gate-brand { font-size: 0.68rem; font-weight: 800; letter-spacing: 2px; color: #60a5fa; }
.gate-panel h1 { font-size: 1.3rem; margin: 0.35rem 0 0.5rem; color: #e6edf7; }
.gate-sub { font-size: 0.78rem; color: #a3b1c9; margin-bottom: 1.2rem; }
.gate-field span {
    display: block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.6px; color: #a3b1c9; margin-bottom: 0.3rem;
}
.gate-field input {
    width: 100%; font-family: var(--mono); font-size: 1rem; letter-spacing: 1px;
    background: #0e1729; border: 1px solid #35486e; color: #e6edf7; padding: 0.6rem 0.75rem;
}
.gate-error { min-height: 1.2rem; font-size: 0.74rem; color: #f87171; margin: 0.4rem 0; }
.gate-panel .btn { width: 100%; justify-content: center; padding: 10px; }
.gate-note { margin-top: 1rem; font-size: 0.68rem; line-height: 1.5; color: #6b7c99; }
.gate-note code { color: #93c5fd; }

/* ---------------- Shell ---------------- */
.top {
    display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
    padding: 0.85rem 1.5rem;
    background: var(--panel); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
}
.brand b { font-size: 0.95rem; letter-spacing: 1px; }
.brand span { display: block; font-size: 0.66rem; color: var(--text-3); letter-spacing: 1px; }
.top-stats { display: flex; gap: 1.6rem; margin-left: auto; flex-wrap: wrap; }
.stat span { display: block; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-3); }
.stat b { font-family: var(--mono); font-size: 1.05rem; }
.top-right { display: flex; align-items: center; gap: 0.75rem; }
.link-state { font-size: 0.72rem; font-weight: 700; padding: 4px 9px; border: 1px solid var(--line); }
.link-state.is-up { color: var(--green); border-color: var(--green); }
.link-state.is-down { color: var(--red); border-color: var(--red); }
.link-state.is-wait { color: var(--amber); border-color: var(--amber); }

.tabs { display: flex; gap: 2px; padding: 0 1.5rem; background: var(--panel); border-bottom: 1px solid var(--line); }
.tab {
    background: transparent; border: none; border-bottom: 3px solid transparent;
    color: var(--text-2); padding: 11px 16px; font-size: 0.78rem; font-weight: 600;
    font-family: inherit; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.view { padding: 1.25rem 1.5rem 3rem; }
.empty { color: var(--text-3); font-size: 0.82rem; padding: 1.5rem 0; text-align: center; }

.bulk { background: var(--panel); border: 1px solid var(--line); padding: 1rem 1.1rem; margin-bottom: 1.25rem; }
.bulk h2 {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-2); margin-bottom: 0.75rem;
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.bulk-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* ---------------- Station cards ---------------- */
.stations { display: grid; grid-template-columns: repeat(auto-fill, minmax(430px, 1fr)); gap: 1rem; }
.station {
    background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--green);
    padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 0.7rem;
}
.station.is-alarm { border-left-color: var(--red); }
.station.is-stale { opacity: 0.55; border-left-color: var(--text-3); }

.st-head { display: flex; justify-content: space-between; gap: 0.75rem; align-items: flex-start; }
.st-who b { display: block; font-size: 0.9rem; }
.st-who span { display: block; font-size: 0.7rem; color: var(--text-3); }
.st-who code { font-size: 0.68rem; color: var(--blue); }
.st-flags { display: flex; flex-direction: column; gap: 0.25rem; align-items: flex-end; }
.chip {
    font-size: 0.64rem; font-weight: 700; padding: 3px 8px;
    background: var(--panel-2); border: 1px solid var(--line); color: var(--text-2); white-space: nowrap;
}
.chip.is-active { color: var(--blue); border-color: var(--blue); }
.chip.is-ok { color: var(--green); border-color: var(--green); }
.chip.is-warn { color: var(--amber); border-color: var(--amber); }
.chip.is-bad { color: var(--red); border-color: var(--red); }

.st-incidents { display: flex; flex-direction: column; gap: 0.3rem; }
.inc {
    display: flex; justify-content: space-between; gap: 0.75rem; align-items: baseline;
    font-size: 0.74rem; padding: 0.35rem 0.5rem; background: var(--panel-2);
    border-left: 3px solid var(--text-3);
}
.inc.is-live { border-left-color: var(--red); }
.inc.is-done { border-left-color: var(--green); }
.inc.inc-none { color: var(--text-3); justify-content: flex-start; }
.inc span { font-family: var(--mono); font-size: 0.7rem; color: var(--text-2); white-space: nowrap; }

.st-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 0.35rem; }
.cell {
    background: var(--panel-2); border: 1px solid var(--line);
    padding: 0.3rem 0.4rem; display: flex; flex-direction: column; line-height: 1.2;
}
.cell span { font-size: 0.56rem; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-3); }
.cell b { font-family: var(--mono); font-size: 0.86rem; }
.cell b.is-ok { color: var(--text); }
.cell b.is-bad { color: var(--red); }
.cell i { font-style: normal; font-size: 0.55rem; color: var(--text-3); }

.st-econ { display: flex; align-items: baseline; gap: 0.5rem; font-size: 0.74rem; color: var(--text-2); }
.st-econ b { font-family: var(--mono); font-size: 0.95rem; color: var(--text); }
.st-rate { color: var(--red); font-family: var(--mono); font-size: 0.72rem; }

.st-tools, .st-msg { display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }
.st-tools select { flex: 1 1 130px; min-width: 0; }
.st-msg-input { flex: 1 1 200px; min-width: 0; }

/* ---------------- Progress ---------------- */
.summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0.75rem; }
.sum { background: var(--panel-2); border: 1px solid var(--line); padding: 0.75rem 0.85rem; }
.sum-head { display: flex; justify-content: space-between; gap: 0.5rem; align-items: baseline; }
.sum-head b { font-size: 0.85rem; }
.sum-head code { font-size: 0.66rem; color: var(--blue); }
.sum-post { font-size: 0.68rem; color: var(--text-3); margin-bottom: 0.5rem; }
.sum-bar { height: 5px; background: var(--line); margin-bottom: 0.6rem; }
.sum-bar i { display: block; height: 100%; background: var(--green); }
.sum-row { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--text-2); padding: 1px 0; }
.sum-row b { font-family: var(--mono); color: var(--text); }

.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.75rem; min-width: 800px; }
.tbl th {
    text-align: left; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.6px;
    color: var(--text-3); padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); color: var(--text-2); }
.tbl tr.is-fail td { background: rgba(248, 113, 113, 0.06); }
.tbl code { font-size: 0.7rem; color: var(--blue); }
.verdict { font-size: 0.64rem; font-weight: 800; padding: 2px 7px; }
.verdict.is-pass { color: var(--green); background: rgba(52, 211, 153, 0.14); }
.verdict.is-fail { color: var(--red); background: rgba(248, 113, 113, 0.14); }

/* ---------------- Journal ---------------- */
.journal { list-style: none; display: flex; flex-direction: column; gap: 1px; }
.jr {
    display: grid; grid-template-columns: 78px 190px 1fr; gap: 0.75rem;
    font-size: 0.74rem; padding: 0.4rem 0.5rem; background: var(--panel-2);
    border-left: 3px solid var(--text-3);
}
.jr time { font-family: var(--mono); font-size: 0.7rem; color: var(--text-3); }
.jr b { font-weight: 600; color: var(--text); }
.jr span { color: var(--text-2); overflow-wrap: anywhere; min-width: 0; }
.jr.is-connect { border-left-color: var(--green); }
.jr.is-disconnect { border-left-color: var(--text-3); }
.jr.is-command { border-left-color: var(--blue); }
.jr.is-pass { border-left-color: var(--green); }
.jr.is-fail { border-left-color: var(--red); }

@media (max-width: 720px) {
    .top { gap: 0.75rem; }
    .top-stats { gap: 1rem; width: 100%; margin-left: 0; }
    .stations { grid-template-columns: 1fr; }
    .jr { grid-template-columns: 62px 1fr; }
    .jr span { grid-column: 1 / -1; }
}

/* ---------------- AI status ---------------- */
.ai-status { display: flex; flex-direction: column; gap: 0.25rem; max-width: 520px; }
.ai-line {
    display: flex; justify-content: space-between; gap: 1rem;
    font-size: 0.76rem; color: var(--text-2);
    padding-bottom: 0.25rem; border-bottom: 1px dashed var(--line);
}
.ai-line b { font-family: var(--mono); color: var(--text); }
.ai-line b.ai-on  { color: var(--green); }
.ai-line b.ai-off { color: var(--text-3); }
.ai-line b.ai-bad { color: var(--amber); }
.ai-path { font-family: var(--mono); font-size: 0.68rem; color: var(--text-3); margin-top: 0.4rem; }
.ai-err  { font-size: 0.72rem; color: var(--red); margin-top: 0.3rem; }
.ai-note { font-size: 0.72rem; color: var(--text-3); margin-top: 0.7rem; max-width: 620px; line-height: 1.5; }
.ai-note code { color: var(--blue); }
.chip.chip-theory { font-size: 0.6rem; }
