/*
 * URF dashboard: a radio front panel.
 * One amber LCD shows who is on the air, the modules are a keypad,
 * everything else is plain tables on an aluminium-grey panel.
 * Red means "transmitting" and nothing else; amber means "nodes linked".
 */

@font-face {
  font-family: "Saira";
  font-style: normal;
  font-weight: 300 800;
  font-stretch: 50% 125%;
  font-display: swap;
  src: url(../fonts/saira-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Saira";
  font-style: normal;
  font-weight: 300 800;
  font-stretch: 50% 125%;
  font-display: swap;
  src: url(../fonts/saira-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --panel: #D5D9DA;
  --panel-raised: #E4E7E7;
  --panel-sunk: #C7CCCD;
  --ink: #1D2427;
  --graphite: #4F575B;
  --rule: #B1B8BA;
  --lcd: #E3A23F;
  --lcd-press: #D99A3A;
  --lcd-ink: #2A1905;
  --lcd-dim: #7A4E12;
  --bezel: #2B3236;
  --tx: #C8352B;
  --ok: #2F7A45;
  --warn: #9A6200;

  --font: "Saira", "Bahnschrift", "DIN Alternate", "Arial Narrow", system-ui, sans-serif;
  --fs-xs: 0.8125rem;
  --fs-s: 0.9375rem;
  --fs-m: 1.0625rem;
  --fs-l: 1.375rem;
  --fs-xl: 1.75rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --panel: #252B2E; --panel-raised: #2F363A; --panel-sunk: #1C2124;
    --ink: #E2E5E3; --graphite: #A2AAAD; --rule: #3C454A;
    --bezel: #121618; --tx: #E5493E; --ok: #6DBA82; --warn: #E0A84A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --panel: #252B2E; --panel-raised: #2F363A; --panel-sunk: #1C2124;
  --ink: #E2E5E3; --graphite: #A2AAAD; --rule: #3C454A;
  --bezel: #121618; --tx: #E5493E; --ok: #6DBA82; --warn: #E0A84A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-m);
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; }
a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--graphite); }

.wrap { max-width: 76rem; margin: 0 auto; padding-inline: 16px; }

/* Top bar */
.bar { border-bottom: 1px solid var(--rule); background: var(--panel-raised); }
.bar .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.75rem; padding-block: 0.75rem; }
.brand { display: flex; align-items: baseline; gap: 0.6rem; text-decoration: none; }
.brand b { font-size: var(--fs-l); font-weight: 700; font-stretch: 75%; }
.brand span { font-size: var(--fs-xs); color: var(--graphite); }
.nav { display: flex; flex-wrap: wrap; gap: 0.25rem; flex: 1 1 auto; min-width: 0; }
.nav a { text-decoration: none; font-size: var(--fs-s); padding: 0.3rem 0.65rem; border-radius: 3px; color: var(--graphite); }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--panel-sunk); font-weight: 600; }
.nav a small { font-size: var(--fs-xs); margin-left: 0.25rem; color: var(--graphite); font-weight: 400; }
.status { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; align-items: center; font-size: var(--fs-xs); color: var(--graphite); margin-left: auto; }
.theme-btn {
  font: inherit; font-size: var(--fs-xs); color: var(--graphite); background: none; border: 1px solid var(--rule);
  border-radius: 3px; padding: 0.2rem 0.55rem; cursor: pointer; min-width: 4.6rem; text-align: center;
}
.theme-btn:hover { color: var(--ink); border-color: var(--graphite); }

.motd { background: var(--lcd); color: var(--lcd-ink); }
.motd .wrap { padding-block: 0.5rem; font-size: var(--fs-s); font-weight: 600; }

main > .wrap { padding-block: 1.75rem 3rem; }
.page { display: grid; gap: 2.25rem; }
.page > * { min-width: 0; }
h1, h2, h3 { font-weight: 650; font-stretch: 82%; margin: 0; text-wrap: balance; line-height: 1.2; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-l); }
h3 { font-size: var(--fs-m); }
.lede { margin: 0.35rem 0 0; color: var(--graphite); font-size: var(--fs-s); max-width: 62ch; }
.hint { font-size: var(--fs-xs); color: var(--graphite); margin: 0; }

/* LCD */
.deck { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1.75rem; align-items: start; }
.bezel { background: var(--bezel); border-radius: 12px; padding: 9px; }
.lcd {
  border-radius: 5px;
  background: var(--lcd);
  color: var(--lcd-ink);
  box-shadow: inset 0 3px 0 #00000024;
  padding: 0.7rem 1rem 0.8rem;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "top top" "call ch" "fields ch";
  gap: 0.25rem 1.1rem;
  min-height: 11rem;
}
.lcd-top { grid-area: top; display: flex; flex-wrap: wrap; align-items: center; row-gap: 0.3rem; gap: 0.6rem; font-size: var(--fs-s); font-weight: 600; min-height: 1.6rem; }
.ann { background: var(--lcd-ink); color: var(--lcd); font-weight: 750; font-size: var(--fs-s); line-height: 1; padding: 0.22rem 0.4rem 0.18rem; border-radius: 2px; }
.lcd-also { margin-left: auto; white-space: nowrap; font-size: var(--fs-xs); font-weight: 600; border: 1px solid var(--lcd-ink); border-radius: 2px; padding: 0.05rem 0.35rem; }
.lcd-also + .lcd-timer { margin-left: 0.6rem; }
.lcd-timer { margin-left: auto; font-weight: 600; font-stretch: 80%; font-size: var(--fs-l); line-height: 1; }
.lcd-call {
  grid-area: call; align-self: end; margin: 0;
  font-size: clamp(2.6rem, 7vw, 4.75rem); font-weight: 650; font-stretch: 58%;
  line-height: 0.92; overflow-wrap: anywhere;
}
.lcd-call small { font-size: 0.42em; font-weight: 500; margin-left: 0.1em; }
.lcd-name { display: block; font-size: max(0.32em, 1.125rem); font-weight: 550; font-stretch: 85%; line-height: 1.15; margin-top: 0.15rem; }
.lcd-ch { grid-area: ch; align-self: stretch; display: grid; align-content: center; justify-items: center;
          border-left: 2px solid #2a190533; padding-left: 1.1rem; }
.lcd-ch span { font-size: var(--fs-xs); color: var(--lcd-dim); }
.lcd-ch b { font-size: clamp(3rem, 8vw, 5.25rem); font-weight: 700; font-stretch: 62%; line-height: 0.85; }
.lcd-fields { grid-area: fields; display: flex; flex-wrap: wrap; gap: 0.2rem 2rem; margin: 0.3rem 0 0; }
.lcd-fields dt { font-size: var(--fs-xs); color: var(--lcd-dim); }
.lcd-fields dd { margin: 0; font-size: var(--fs-m); font-weight: 600; font-stretch: 78%; line-height: 1.1; overflow-wrap: anywhere; }
.lcd.idle .lcd-call, .lcd.idle .lcd-ch b, .lcd.idle .lcd-fields dd { color: var(--lcd-dim); }
.lcd.empty .lcd-call { font-size: clamp(1.75rem, 4vw, 2.5rem); font-stretch: 70%; }
.lcd.flick .lcd-call, .lcd.flick .lcd-ch b, .lcd.flick .lcd-fields dd { animation: flick 240ms steps(3, end); }
@keyframes flick { 0% { opacity: 0.1; } 60% { opacity: 0.55; } 100% { opacity: 1; } }

/* slim LCD line on the other pages */
.strip { background: var(--bezel); border-radius: 8px; padding: 5px; margin-bottom: 1.75rem; }
.strip-in { background: var(--lcd); color: var(--lcd-ink); border-radius: 4px; box-shadow: inset 0 2px 0 #00000024;
            padding: 0.4rem 0.8rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 0.9rem; font-size: var(--fs-s); }
.strip-in b { font-size: var(--fs-l); font-stretch: 62%; font-weight: 650; line-height: 1.1; }
.strip-in .t { margin-left: auto; font-weight: 600; }
.strip-in .lcd-also + .t { margin-left: 0; }
.strip.idle .strip-in { color: var(--lcd-dim); }

/* Module keypad */
.keys-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 0.7rem; }
.keys {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px;
  background: var(--rule); border: 1px solid var(--rule); border-radius: 5px; overflow: hidden;
}
.key {
  font: inherit; color: var(--ink); text-align: left; position: relative;
  background: var(--panel-raised); border: 0; border-radius: 0;
  padding: 0.55rem 0.65rem 0.5rem; min-height: 4.75rem; min-width: 0;
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; gap: 0 0.4rem;
}
button.key { cursor: pointer; }
button.key:hover { background: var(--panel); }
.key:focus-visible { outline-offset: -3px; }
.key .l { font-size: var(--fs-xl); font-weight: 700; font-stretch: 70%; line-height: 1; }
.key .n { font-size: var(--fs-xs); color: var(--graphite); padding-top: 0.15rem; }
.key .d { grid-column: 1 / -1; font-size: var(--fs-xs); color: var(--graphite); line-height: 1.25; align-self: end;
          white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.key.busy { background: var(--lcd); color: var(--lcd-ink); }
button.key.busy:hover { background: var(--lcd-press); }
.key.busy .n, .key.busy .d { color: var(--lcd-dim); }
.key .led { position: absolute; left: 0.65rem; top: 0; width: 1.1rem; height: 4px; border-radius: 0 0 2px 2px; }
.key.tx .led { background: var(--tx); }
.key[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--ink); }
.key.blank { background: var(--panel-sunk); }
.keys.many .key { min-height: 3.6rem; padding: 0.4rem 0.5rem 0.35rem; }
.keys.many .key .l { font-size: var(--fs-l); }
.keys.many .key .led { left: 0.5rem; width: 0.9rem; }

/* Tables */
.tbl-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 0.75rem 1.5rem; margin-bottom: 0.75rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.filters label { font-size: var(--fs-xs); color: var(--graphite); }
.field {
  font: inherit; font-size: var(--fs-s); color: var(--ink); background: var(--panel-raised);
  border: 1px solid var(--rule); border-radius: 3px; padding: 0.3rem 0.6rem; max-width: 100%;
}
.field::placeholder { color: var(--graphite); }
.filters .field { width: 12rem; }
.chip { font: inherit; font-size: var(--fs-xs); background: var(--panel-sunk); color: var(--ink);
        border: 0; border-radius: 3px; padding: 0.3rem 0.6rem; cursor: pointer; }
.chip:hover { background: var(--rule); }
.scroll { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: var(--fs-s); }
.t th { text-align: left; font-weight: 500; font-size: var(--fs-xs); color: var(--graphite); padding: 0 0.75rem 0.4rem; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.t td { padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
.t tbody tr:hover td { background: var(--panel-raised); }
.t .r { text-align: right; white-space: nowrap; }
.t .nw { white-space: nowrap; }
.t.narrow { max-width: 44rem; }
.cs a, .cs > b { font-weight: 650; font-stretch: 80%; font-size: var(--fs-m); text-decoration: none; }
.cs a:hover { text-decoration: underline; }
.cs .sfx { color: var(--graphite); font-stretch: 80%; margin-left: 0.1rem; }
.cs .op { font-size: var(--fs-s); margin-left: 0.45rem; }
.cs .cc { color: var(--graphite); font-size: var(--fs-xs); margin-left: 0.45rem; }
.mod { display: inline-block; min-width: 1.6rem; text-align: center; font-weight: 700; font-stretch: 75%;
       background: var(--panel-sunk); border-radius: 2px; padding: 0 0.3rem; }
.mod.on { background: var(--lcd); color: var(--lcd-ink); }
.txtag { display: inline-block; background: var(--tx); color: #fff; font-size: var(--fs-xs); font-weight: 700; line-height: 1; padding: 0.2rem 0.3rem 0.15rem; border-radius: 2px; }
.state { width: 2.6rem; padding-right: 0 !important; }
tr.live td { background: color-mix(in srgb, var(--lcd) 18%, transparent); }
.empty td { text-align: center; color: var(--graphite); padding-block: 2rem; }
.ip { font-stretch: 85%; color: var(--graphite); }
#log td.meta { display: none; }
.tag { display: inline-block; font-size: var(--fs-xs); border: 1px solid var(--rule); border-radius: 2px; padding: 0 0.35rem; margin: 0.1rem 0.25rem 0.1rem 0; white-space: nowrap; }
.tag.dyn { border-style: dashed; }
.pager { display: flex; flex-wrap: wrap; gap: 0.25rem; justify-content: center; margin-top: 1rem; }
.pager button { min-width: 2.2rem; }
.pager button[aria-current="page"] { background: var(--ink); color: var(--panel); }
.pager button:disabled { opacity: 0.4; cursor: default; }

/* Module list */
details.nodes summary { cursor: pointer; color: var(--graphite); font-size: var(--fs-xs); }
details.nodes summary:hover { color: var(--ink); }
details.nodes ul { list-style: none; margin: 0.35rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.15rem 1rem; font-size: var(--fs-s); }
details.nodes li span { color: var(--graphite); font-size: var(--fs-xs); margin-left: 0.25rem; }

/* Notices */
.note { background: var(--panel-raised); border: 1px solid var(--rule); border-radius: 4px; padding: 1rem 1.15rem; max-width: 46rem; }
.note p { margin: 0 0 0.6rem; }
.note p:last-child { margin: 0; }

/* Footer */
.foot { border-top: 1px solid var(--rule); }
.foot .wrap { padding-block: 1.25rem; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.75rem 2rem; font-size: var(--fs-xs); color: var(--graphite); }
.foot .pi { text-decoration: none; opacity: 0.35; font-size: var(--fs-s); }
.foot .pi:hover { opacity: 1; }

/* Controls (admin) */
.btn {
  font: inherit; font-size: var(--fs-s); font-weight: 600; line-height: 1.2;
  color: var(--ink); background: var(--panel-raised);
  border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 3px;
  padding: 0.35rem 0.8rem; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--graphite); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.btn.danger { color: var(--tx); }
.btn.danger:hover { background: var(--tx); color: #fff; border-color: var(--tx); }
.btn.small { font-size: var(--fs-xs); padding: 0.2rem 0.55rem; }
.btn.quiet { background: none; border-color: transparent; color: var(--graphite); }
.btn.quiet:hover { color: var(--ink); border-color: var(--rule); }

.form-row { display: flex; flex-wrap: wrap; align-items: end; gap: 0.6rem 0.8rem; }
.form-row label { display: grid; gap: 0.2rem; font-size: var(--fs-xs); color: var(--graphite); }
.form-row .field { min-width: 0; }
.form-row .w-xs { width: 5rem; }
.form-row .w-s { width: 7.5rem; }
.form-row .w-m { width: 11rem; }
.form-row .w-l { width: 15rem; }

.state-ok { color: var(--ok); font-weight: 600; }
.state-bad { color: var(--tx); font-weight: 600; }
.state-dyn { color: var(--warn); font-weight: 600; }

.alert { display: flex; justify-content: space-between; align-items: start; gap: 1rem; border-radius: 3px;
         padding: 0.55rem 0.8rem; font-size: var(--fs-s); border: 1px solid var(--rule); border-left-width: 4px; background: var(--panel-raised); }
.alert.ok { border-left-color: var(--ok); }
.alert.bad { border-left-color: var(--tx); }
.alert .close { font: inherit; background: none; border: 0; color: var(--graphite); cursor: pointer; font-size: var(--fs-m); line-height: 1; padding: 0; }

.admin { display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: 2rem; align-items: start; }
.admin-index { position: sticky; top: 1rem; display: grid; gap: 0.1rem; font-size: var(--fs-s); }
.admin-index a { text-decoration: none; color: var(--graphite); padding: 0.25rem 0.5rem; border-left: 2px solid transparent; }
.admin-index a:hover { color: var(--ink); border-left-color: var(--rule); }
.admin-index hr { border: 0; border-top: 1px solid var(--rule); margin: 0.5rem 0; }
.admin-body { display: grid; gap: 2.5rem; min-width: 0; }
/* the plugins' sections are items of that grid too, with its gap between them */
#plugin-sections { display: contents; }
.admin-sec { display: grid; gap: 0.9rem; scroll-margin-top: 1rem; }
.admin-sec > header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.5rem 1rem;
                      border-bottom: 1px solid var(--rule); padding-bottom: 0.4rem; }
.admin-sec .form-row { background: var(--panel-raised); border: 1px solid var(--rule); border-radius: 4px; padding: 0.75rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1.5rem; margin: 0; font-size: var(--fs-s); }
.kv dt { color: var(--graphite); }
.kv dd { margin: 0; }
.log-out { margin: 0; max-height: 22rem; overflow: auto; background: var(--bezel); color: #D8DCDA; border-radius: 4px;
           padding: 0.75rem; font-size: 0.75rem; line-height: 1.5; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.blocks { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.login { max-width: 24rem; margin: 3rem auto; display: grid; gap: 0.9rem; }
.login .field { width: 100%; }

@media (max-width: 860px) {
  .deck { grid-template-columns: minmax(0, 1fr); }
  .status .up, .status .ver { display: none; }
  .admin { grid-template-columns: minmax(0, 1fr); }
  .admin-index { position: static; display: flex; flex-wrap: wrap; gap: 0.25rem; }
  .admin-index a { border: 1px solid var(--rule); border-radius: 3px; padding: 0.2rem 0.5rem; font-size: var(--fs-xs); }
  .admin-index hr { display: none; }
}
@media (max-width: 640px) {
  .lcd { min-height: 0; padding: 0.75rem 0.9rem 0.85rem; gap: 0.3rem 0.9rem; }
  .lcd-ch { padding-left: 0.8rem; }
  .lcd-fields { gap: 0.2rem 1.25rem; }
  .lcd-fields dd { font-size: var(--fs-m); }
  .key { min-height: 3.5rem; padding: 0.45rem 0.5rem; }
  .key .d { display: none; }
  .opt { display: none; }
  #log thead { display: none; }
  #log, #log tbody { display: block; }
  #log tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "cs mod" "meta when";
    gap: 0.1rem 0.6rem; padding: 0.6rem 0.25rem; border-bottom: 1px solid var(--rule);
  }
  #log td { display: block; padding: 0; border: 0; background: none !important; }
  #log tr.live { background: color-mix(in srgb, var(--lcd) 18%, transparent); }
  #log td.state, #log td.opt { display: none; }
  #log td.cs { grid-area: cs; }
  #log td.m { grid-area: mod; text-align: right; }
  #log td.p, #log td.v { display: none; }
  #log td.meta { display: block; grid-area: meta; font-size: var(--fs-xs); color: var(--graphite); min-width: 0; overflow-wrap: anywhere; }
  #log td.when { grid-area: when; font-size: var(--fs-xs); }
  #log .empty td { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  .lcd.flick .lcd-call, .lcd.flick .lcd-ch b, .lcd.flick .lcd-fields dd { animation: none; }
  .btn:active { transform: none; }
}
