/* Radio Desk — night-ops console. Dark by default for use in dim comms rooms. */
:root {
  --bg: #0d0e10;
  --panel: #15171a;
  --panel-2: #1c1f23;
  --line: #2a2e34;
  --line-2: #363b42;
  --text: #e9e6e1;
  --muted: #9a958d;
  --faint: #6c6861;
  --accent: #ff7a2f;
  --accent-ink: #1a0d05;
  --accent-soft: rgba(255, 122, 47, .14);
  --crit: #ff5368;
  --crit-soft: rgba(255, 83, 104, .13);
  --warn: #f2b33d;
  --warn-soft: rgba(242, 179, 61, .13);
  --ok: #47c486;
  --ok-soft: rgba(71, 196, 134, .13);
  --info: #6aa8ff;
  --info-soft: rgba(106, 168, 255, .12);
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  --sans: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  --r: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p { margin: 0 0 .8em; }
code, .mono { font-family: var(--mono); font-size: 13px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.side { background: #0a0b0c; border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 18px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-family: var(--mono); }
.brand b { display: block; font-size: 14px; }
.brand span { display: block; color: var(--muted); font-size: 12px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--muted); font-weight: 520; }
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav .sep { height: 1px; background: var(--line); margin: 10px 4px; }
.nav .badge { margin-left: auto; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.side-foot form { display: inline; }
.main { padding: 26px 32px 60px; min-width: 0; }
.embed .shell { grid-template-columns: 1fr; }
.embed .side { display: none; }
.embed .main { padding: 14px 16px 40px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar .sub { color: var(--muted); margin: 2px 0 0; }
.crumb { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.crumb a { color: var(--muted); }

/* ---- panels & grid ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.panel + .panel { margin-top: 16px; }
.cols > .panel + .panel, .cols > .stat + .stat { margin-top: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.cols { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat b { display: block; font-size: 26px; font-family: var(--mono); font-weight: 600; }
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.stat.crit b { color: var(--crit); }
.stat.warn b { color: var(--warn); }
.stat.ok b { color: var(--ok); }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---- buttons & forms ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); padding: 7px 13px; border-radius: 6px; font: inherit; font-weight: 560; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--faint); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { border-color: rgba(255, 83, 104, .5); color: var(--crit); background: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel-2); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
label { display: block; color: var(--muted); font-size: 12px; font-weight: 560; margin-bottom: 4px; }
input:not([type]), input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; background: #0f1113; border: 1px solid var(--line-2); color: var(--text); border-radius: 6px; padding: 7px 9px; font: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 80px; resize: vertical; }
input.mono { font-family: var(--mono); }
.field { margin-bottom: 14px; }
.field .hint { color: var(--faint); font-size: 12px; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; font-weight: 400; }
.check input { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 14px; }
.inline-form { display: inline; }
.file-drop { border: 2px dashed var(--line-2); border-radius: var(--r); padding: 28px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s; }
.file-drop.over, .file-drop:hover { border-color: var(--accent); color: var(--text); }
.file-drop input { display: none; }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, .015); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.table-wrap table td:first-child, .table-wrap table th:first-child { padding-left: 14px; }
.freq { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.tone { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---- pills & flashes ---- */
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line-2); white-space: nowrap; }
.pill.crit, .pill.critical { background: var(--crit-soft); color: var(--crit); border-color: transparent; }
.pill.warn, .pill.warning { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.ok, .pill.active, .pill.exact { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.info, .pill.reserved, .pill.rx_only { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill.retired { text-decoration: line-through; }
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--crit); color: #fff; font-size: 11px; font-weight: 700; }
.flash { padding: 10px 14px; border-radius: var(--r); margin-bottom: 16px; border: 1px solid transparent; }
.flash.ok { background: var(--ok-soft); border-color: rgba(71, 196, 134, .35); }
.flash.error { background: var(--crit-soft); border-color: rgba(255, 83, 104, .35); }
.flash.warn { background: var(--warn-soft); border-color: rgba(242, 179, 61, .35); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state h2 { color: var(--text); }

/* ---- tabs ---- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 560; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }

/* ---- issues ---- */
.issue { display: grid; grid-template-columns: 88px 1fr; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.issue:last-child { border-bottom: 0; }
.issue .t { font-weight: 600; }
.issue .links { margin-top: 4px; display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; }

/* ---- channel grid editor ---- */
.grid-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r) var(--r) 0 0; position: sticky; top: 0; z-index: 5; }
.grid-toolbar .sel-count { color: var(--muted); font-size: 12px; }
.grid-toolbar input[type=search] { width: 200px; }
.grid-scroll { overflow: auto; max-height: calc(100vh - 250px); border: 1px solid var(--line); border-radius: 0 0 var(--r) var(--r); background: var(--panel); }
table.cgrid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
table.cgrid th { position: sticky; top: 0; background: var(--panel-2); z-index: 2; padding: 7px 6px; }
table.cgrid td { padding: 0; border-bottom: 1px solid var(--line); border-right: 1px solid #1f2226; height: 30px; vertical-align: middle; }
table.cgrid td.loc { position: sticky; left: 0; background: var(--panel); z-index: 1; padding: 0 8px; font-family: var(--mono); color: var(--muted); text-align: right; min-width: 52px; cursor: pointer; user-select: none; }
table.cgrid tr.sel td { background: rgba(255, 122, 47, .08); }
table.cgrid tr.sel td.loc { background: #2a1d14; color: var(--accent); }
table.cgrid tr.empty td:not(.loc) { opacity: .45; }
table.cgrid tr.dirty td.loc { box-shadow: inset 3px 0 0 var(--accent); }
table.cgrid tr.focus td { background: rgba(106, 168, 255, .08); }
table.cgrid input, table.cgrid select { border: 0; border-radius: 0; background: transparent; color: var(--text); height: 30px; padding: 0 6px; font-size: 13px; min-width: 0; display: block; }
table.cgrid input:focus, table.cgrid select:focus { background: #0b0c0e; box-shadow: inset 0 0 0 2px var(--accent); }
table.cgrid input.mono { font-family: var(--mono); }
table.cgrid td.err { box-shadow: inset 0 0 0 2px var(--crit); background: var(--crit-soft); }
table.cgrid td.wrn { box-shadow: inset 0 0 0 2px var(--warn); }
table.cgrid td.chg input, table.cgrid td.chg select { color: var(--accent); }
table.cgrid td.ro { color: var(--faint); padding: 0 8px; font-family: var(--mono); font-size: 12px; white-space: nowrap; }
table.cgrid td.plan { padding: 0 8px; white-space: nowrap; font-size: 12px; }
table.cgrid .w-name { width: 104px; } table.cgrid .w-freq { width: 96px; } table.cgrid .w-sm { width: 78px; } table.cgrid .w-md { width: 104px; } table.cgrid .w-lg { width: 160px; } table.cgrid .w-xs { width: 62px; }
.grid-status { display: flex; gap: 14px; align-items: center; padding: 8px 2px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.msgbox { margin-top: 12px; }
.msgbox li { margin-bottom: 3px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); vertical-align: middle; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.crit { background: var(--crit); } .dot.busy { background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---- settings form ---- */
.sgroup { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 12px; background: var(--panel); }
.sgroup > summary { cursor: pointer; padding: 12px 16px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
.sgroup > summary::-webkit-details-marker { display: none; }
.sgroup[open] > summary { border-bottom: 1px solid var(--line); }
.sgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 20px; padding: 14px 16px; }
.srow { padding: 6px 0; }
.srow.chg label { color: var(--accent); }
.srow .doc { color: var(--faint); font-size: 11.5px; margin-top: 3px; }
.sgroup .sgroup { margin: 8px 16px; }

/* ---- diff ---- */
.diff-before { color: var(--crit); text-decoration: line-through; opacity: .85; }
.diff-after { color: var(--ok); }
.change-added { color: var(--ok); } .change-removed { color: var(--crit); } .change-changed { color: var(--warn); }

/* ---- template builder ---- */
.zone { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); margin-bottom: 12px; }
.zone-head { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); border-radius: var(--r) var(--r) 0 0; }
.zone-head input { max-width: 220px; }
.zone-head .start { width: 90px; }
.slot { display: grid; grid-template-columns: 26px 52px minmax(160px, 1.4fr) 120px 110px 90px 70px 30px; gap: 8px; align-items: center; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.slot:last-child { border-bottom: 0; }
.slot.dragging { opacity: .4; }
.slot.over { box-shadow: inset 0 2px 0 var(--accent); }
.handle { cursor: grab; color: var(--faint); text-align: center; user-select: none; }
.slot-loc { font-family: var(--mono); color: var(--muted); text-align: right; }

/* ---- radio page ---- */
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 34px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: -1px; width: 22px; height: 22px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line-2); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--accent); }
.progress { height: 10px; background: #0f1113; border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.progress.done > i { background: var(--ok); }
.progress.fail > i { background: var(--crit); }
.choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.choice label { display: block; border: 1px solid var(--line-2); border-radius: var(--r); padding: 12px 14px; cursor: pointer; color: var(--text); font-size: 14px; font-weight: 400; margin: 0; }
.choice label b { display: block; margin-bottom: 2px; }
.choice label span { color: var(--muted); font-size: 12.5px; }
.choice input { display: none; }
.choice input:checked + label { border-color: var(--accent); background: var(--accent-soft); }

/* ---- login ---- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at top, #1d1410 0%, var(--bg) 60%); }
.auth .panel { width: 100%; max-width: 380px; padding: 28px; }
.auth .brand { border: 0; padding: 0 0 20px; }

/* ---- modal ---- */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: 10px; padding: 0; width: min(560px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog .dhead { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 650; }
dialog .dbody { padding: 18px; }
dialog .dfoot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; gap: 4px; padding: 10px; }
  .brand { border: 0; padding: 0 8px 0 0; margin: 0; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav .sep, .side-foot { display: none; }
  .main { padding: 18px 14px 40px; }
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr 1fr; }
  .slot { grid-template-columns: 22px 44px 1fr 90px 30px; }
  .slot .opt { display: none; }
}

/* ---- print (channel cards) ---- */
.card-page { background: #fff; color: #111; font: 12px/1.35 var(--sans); padding: 18px; }
.card-page h1 { font-size: 16px; margin: 0 0 2px; }
.card-page .meta { color: #555; margin-bottom: 10px; }
.card-page table th { color: #444; border-bottom: 1.5px solid #111; padding: 4px 6px; }
.card-page table td { border-bottom: 1px solid #ccc; padding: 4px 6px; }
.card-page .group { font-weight: 700; background: #eee; }
.card-page .noprint { margin-bottom: 14px; }
@media print { .noprint { display: none !important; } .card-page { padding: 0; } @page { margin: 10mm; } }
