/* --- SELF-HOSTED FONTS -----------------------------------------
   Bundled locally (frontend/fonts/) instead of calling Google Fonts
   on every page load. Exo 2 is a variable font -- Google serves one
   file per subset covering the whole weight axis, so a single
   @font-face with a weight range covers every weight this app uses.
   IosevkaTerm ships as static per-weight files, so each weight this
   app actually uses (400/600/700) gets its own @font-face pinned to
   that exact weight. Latin + Latin Extended subsets only (no
   cyrillic/greek/vietnamese -- this app's text is English/ASCII). */
@font-face {
  font-family: 'Exo 2'; font-style: normal; font-weight: 300 900; font-display: swap;
  src: url('../fonts/exo2-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Exo 2'; font-style: normal; font-weight: 300 900; font-display: swap;
  src: url('../fonts/exo2-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IosevkaTerm'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/iosevka-term-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IosevkaTerm'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/iosevka-term-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IosevkaTerm'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/iosevka-term-semibold-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IosevkaTerm'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/iosevka-term-semibold-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IosevkaTerm'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/iosevka-term-bold-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IosevkaTerm'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/iosevka-term-bold-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Share Tech Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/share-tech-mono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* --- DARK THEME (default) ------------------------------------ */
:root {
  --bg:        #0a0c0f;
  --bg1:       #0f1218;
  --bg2:       #151a22;
  --bg3:       #1c232e;
  --bg4:       #232c3a;
  --border:    #2a3547;
  --border2:   #3a4d66;
  --text:      #c8d8f0;
  --text2:     #7a9cc0;
  --text3:     #4a6a90;
  --accent:    #00b4ff;
  --accent2:   #0080cc;
  --green:     #00e676;
  --amber:     #ffab00;
  --red:       #ff3d00;
  --purple:    #b26cff;
  --font-mono: 'IosevkaTerm', 'Share Tech Mono', monospace;
  --font-ui:   'Exo 2', sans-serif;
  --radius:    4px;
  --shadow:    0 4px 24px rgba(0,0,0,0.6);
}

/* --- LIGHT THEME --------------------------------------------- */
html.light {
  --bg:        #f0f4f8;
  --bg1:       #e4eaf2;
  --bg2:       #d8e2ee;
  --bg3:       #ccd6e6;
  --bg4:       #bfcbdc;
  --border:    #a8bad0;
  --border2:   #8aa4c0;
  --text:      #1a2a3a;
  --text2:     #2e4a68;
  --text3:     #5a7a9a;
  --accent:    #0070cc;
  --accent2:   #005aaa;
  --green:     #008844;
  --amber:     #cc7700;
  --red:       #cc2200;
  --purple:    #7733cc;
  --shadow:    0 4px 24px rgba(0,0,0,0.15);
}

html.light body::before { display: none; }

*, *::before, *::after {
  box-sizing: border-box; margin: 0; padding: 0;
  transition: background-color 0.18s, border-color 0.18s, color 0.12s;
}

html {
  font-size: 16px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: inherit;
  line-height: 1.5;
  overflow: hidden;
}
/* body carries the font-size zoom (see setFontSize() in app.js) -- a
   descendant sizing itself off `vh` resolves against the *true* viewport,
   not body's zoomed rendering, so it renders zoom% too tall/short and
   silently pushes content out past the outer overflow:hidden with no way
   to scroll back to it. #app uses flex:1 against this column instead of
   `calc(100vh - Npx)` so its size stays consistent within body's own
   zoomed coordinate system. */
body { display: flex; flex-direction: column; }

body::before {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.08) 2px, rgba(0,0,0,0.08) 4px);
  pointer-events: none;
  z-index: 9999;
}

/* --- HEADER -------------------------------------------------- */
#header {
  display: flex; align-items: center; gap: 6px;
  padding: 0 12px; height: 52px;
  background: var(--bg1); border-bottom: 1px solid var(--border);
  flex-shrink: 0; position: relative; overflow: visible; flex-wrap: nowrap;
}
#header::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: 0.5;
}
.logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo-icon { display: flex; align-items: center; justify-content: center; color: var(--accent); flex-shrink: 0; }
.logo-text { font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; }
.logo-sub  { font-family: var(--font-mono); font-size: 10px; color: var(--accent); letter-spacing: 0.15em; text-transform: uppercase; }
.header-sep { flex: 1; min-width: 0; }

/* header toolbar grouping: a small caption before each cluster of controls,
   and a hairline divider between clusters (File / Radio / Appearance) so the
   groups read as distinct steps instead of one long row of buttons. */
.h-glabel {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--text3);
  flex-shrink: 0; user-select: none;
}
.h-divider { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; margin: 0 2px; }

.h-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 0 10px; height: 30px;
  border: 1px solid var(--border); background: var(--bg2);
  color: var(--text2); font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  cursor: pointer; border-radius: var(--radius); white-space: nowrap; flex-shrink: 0;
  text-decoration: none;
}
.h-btn:hover         { border-color: var(--accent); color: var(--accent); background: rgba(0,180,255,0.05); }
.h-btn.primary       { background: var(--accent2); border-color: var(--accent); color: #fff; }
.h-btn.primary:hover { background: var(--accent); }
.h-btn:disabled      { opacity: 0.35; cursor: not-allowed; }
.h-btn:disabled:hover{ border-color: var(--border); color: var(--text2); background: var(--bg2); }
.h-btn.left          { justify-content: flex-start; }
.h-btn.icon-only     { padding: 0; width: 30px; justify-content: center; font-size: 15px; }

/* Custom hover tooltip (replaces the native `title` attribute popup, which is
   slow, plain, and un-themeable) -- attach text via data-tip="..." on any
   element. Shown after a short delay so it doesn't flash on every mouse
   pass; hides immediately. */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  background: var(--bg4); color: var(--text); border: 1px solid var(--border);
  font-family: var(--font-ui); font-size: 12px; font-weight: 500; letter-spacing: normal;
  text-transform: none; white-space: nowrap; padding: 5px 9px; border-radius: var(--radius);
  box-shadow: var(--shadow); pointer-events: none; opacity: 0; z-index: 10000;
  transition: opacity 0.12s ease;
}
[data-tip]::before {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-bottom-color: var(--bg4);
  pointer-events: none; opacity: 0; z-index: 10000; transition: opacity 0.12s ease;
}
[data-tip]:hover::after, [data-tip]:hover::before { opacity: 1; transition-delay: 0.35s; }
/* For elements near the right edge of the viewport, centering the tooltip
   would push it off-screen -- this opens it leftward from the trigger's
   right edge instead. */
[data-tip].tip-edge::after  { left: auto; right: 0; transform: none; }
[data-tip].tip-edge::before { left: auto; right: 10px; transform: none; }

/* header select (radio type) */
.h-select {
  padding: 0 8px; height: 30px; width: 176px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-family: var(--font-mono); font-size: 12px;
  flex-shrink: 0; text-overflow: ellipsis;
}

/* font size picker */
.fs-picker {
  display: flex; align-items: center; height: 30px;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; flex-shrink: 0;
}
.fs-lbl {
  padding: 0 8px; font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.1em; color: var(--text3); border-right: 1px solid var(--border);
  height: 100%; display: flex; align-items: center; background: var(--bg2); user-select: none;
}
.fs-btn {
  padding: 0 10px; height: 100%; background: var(--bg2);
  border: none; border-right: 1px solid var(--border);
  color: var(--text3); cursor: pointer; font-size: 12px; font-family: var(--font-ui); font-weight: 400;
}
.fs-btn:last-child { border-right: none; }
.fs-btn:hover      { background: var(--bg3); color: var(--text); }
.fs-btn.active     { background: var(--accent2) !important; color: #fff !important; font-weight: 700; }

/* "Look & Feel" popover (font size + theme), tucked behind one header
   button instead of cluttering the toolbar with both controls directly. */
.lf-menu {
  position: fixed; top: 56px; right: 12px; z-index: 500;
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px; min-width: 190px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transform: translateY(-8px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}
.lf-menu.open { opacity: 1; visibility: visible; transform: translateY(0); }
.lf-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lf-row .lf-lbl {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text3); white-space: nowrap;
}

/* theme toggle */
.theme-tog {
  width: 30px; height: 30px; flex-shrink: 0;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text2); cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.theme-tog:hover { border-color: var(--accent); }

#radio-status {
  display: flex; align-items: center; gap: 7px;
  padding: 0 10px; height: 30px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg2); font-family: var(--font-mono); font-size: 12px; color: var(--text3);
  white-space: nowrap; flex-shrink: 0;
}
.sdot { width: 7px; height: 7px; border-radius: 50%; background: var(--text3); flex-shrink: 0; }
.sdot.connected { background: var(--green); box-shadow: 0 0 5px var(--green); animation: blink 2s infinite; }
.sdot.reading   { background: var(--amber); box-shadow: 0 0 5px var(--amber); animation: blink .5s infinite; }
.sdot.error     { background: var(--red);   box-shadow: 0 0 5px var(--red); }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* --- LAYOUT -------------------------------------------------- */
#app { display: flex; flex: 1; min-height: 0; }

#sidebar {
  width: 218px; flex-shrink: 0; min-height: 0;
  background: var(--bg1); border-right: 1px solid var(--border);
  overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.ss { padding: 6px 0 2px; }
.sl {
  padding: 6px 14px 4px; font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.2em; color: var(--text3); text-transform: uppercase;
  border-top: 1px solid var(--border);
}
.ss:first-child .sl { border-top: none; }

.ni {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; cursor: pointer; font-size: 14px; color: var(--text2);
  border-left: 2px solid transparent; user-select: none;
}
.ni:hover  { background: var(--bg2); color: var(--text); }
.ni.active { background: rgba(0,180,255,0.08); color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.ni-icon   { width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nb {
  margin-left: auto; padding: 1px 6px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; font-family: var(--font-mono); font-size: 11px; color: var(--text3);
}

#main { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }

/* Without min-height:0, a flex item's default min-height:auto refuses to
   shrink below its content's natural size -- so a long table (or any panel
   with a lot of rows) silently inflated #main, then #app, taller than the
   viewport instead of staying clipped, pushing content past where the
   outer overflow:hidden clips it with no scrollbar left to reach it. That
   was the real cause behind pagination controls / trailing rows appearing
   to vanish -- .pb's own internal scrolling was working fine the whole
   time, it just wasn't the thing that had grown too tall. */
.panel { display: none; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; }
.panel.active { display: flex; }

.ph {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  background: var(--bg1); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.pt  { font-size: 16px; font-weight: 700; color: var(--text); }
.ps  { font-family: var(--font-mono); font-size: 12px; color: var(--text3); }
.pa  { margin-left: auto; display: flex; gap: 7px; flex-wrap: wrap; }

/* overflow-x explicit (not left to default `visible`) -- otherwise the UA
   force-computes it to `auto` alongside overflow-y:auto (per spec), and any
   off-screen layout box that extends past the right edge -- even an
   invisible-until-hover [data-tip] tooltip pseudo-element -- silently opens
   a horizontal scrollbar here. Tables that legitimately need horizontal
   scroll wrap themselves in their own .scroll-x div instead. */
.pb { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 18px; }

.pb::-webkit-scrollbar { width: 6px; }
.pb::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* toolbar row (search / filter bar under a panel header) */
.tbar {
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--bg1);
  display: flex; gap: 8px; flex-shrink: 0;
}
.tbar-field {
  padding: 7px 9px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-family: var(--font-mono); font-size: 13px;
}
.tbar-field.grow { flex: 1; min-width: 100px; }
.tbar-field.lg   { font-size: 14px; }

.scroll-y-flex { overflow-y: auto; flex: 1; }
.scroll-x { overflow-x: auto; }

/* --- PAGER (truncated page numbers + symbol prev/next/first/last) -------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.pg-nav { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.pg-nums { display: flex; align-items: center; gap: 3px; margin: 0 2px; }
.pg-btn {
  min-width: 26px; height: 26px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--bg2); color: var(--text2);
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  border-radius: var(--radius); cursor: pointer;
}
.pg-btn:hover:not(:disabled):not(.active) { border-color: var(--accent); color: var(--accent); background: rgba(0,180,255,0.05); }
.pg-btn.active { background: var(--accent2); border-color: var(--accent); color: #fff; cursor: default; }
.pg-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.pg-gap { padding: 0 4px; color: var(--text3); font-size: 13px; }

/* --- TABLE --------------------------------------------------- */
.dt { width: 100%; border-collapse: collapse; font-size: 14px; }
.dt th {
  text-align: left; padding: 7px 10px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--text3);
  border-bottom: 1px solid var(--border); background: var(--bg1);
  position: sticky; top: 0; z-index: 1;
}
.dt td { padding: 6px 10px; border-bottom: 1px solid rgba(42,53,71,0.4); color: var(--text2); font-family: var(--font-mono); font-size: 13px; }
.dt tr:hover td { background: rgba(255,255,255,0.02); color: var(--text); }
.dt tr.sel td   { background: rgba(0,180,255,0.06); }
.dt tr.row-click { cursor: pointer; }
.tn { color: var(--text) !important; font-weight: 600; font-family: var(--font-ui) !important; font-size: 14px !important; }
/* DMR Contacts table: both columns (DMR ID, Callsign) monospace -- higher
   specificity than .tn's own !important so it wins just for this table. */
/* Callsigns are always monospace, wherever they're shown -- .tn's own
   !important normally forces the UI font, so these need the extra selector
   specificity to win just for the columns/cells that hold a callsign. */
#dl-body .tn, #rep-body .tn, #dmrdb-read-body .tn { font-family: var(--font-mono) !important; }
code { font-family: var(--font-mono); }
/* Truncate a cell to its column's inline max-width instead of letting one
   long value (RadioID's CITY field sometimes holds a whole street address)
   blow out the whole table's width and force horizontal scroll -- full text
   is still available via the native title tooltip on hover. */
.tc { max-width: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tf { color: var(--accent) !important; }
.col-check { width: 26px; }

/* --- EMPTY STATE --------------------------------------------- */
.es { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 60px 20px; color: var(--text3); text-align: center; }
.es .ei { width: 44px; height: 44px; opacity: 0.55; }
.es .ei .icon { width: 100%; height: 100%; stroke-width: 1.4; }
.es .et { font-size: 15px; font-weight: 600; color: var(--text2); }
.es .ed { font-size: 14px; max-width: 300px; line-height: 1.6; }

/* --- FORM ---------------------------------------------------- */
.fg  { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 16px; }
.fg2 { grid-template-columns: 1fr 1fr; }
.fg3 { grid-template-columns: 1fr 1fr 1fr; }
.fld { display: flex; flex-direction: column; gap: 5px; }
.fld label { font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text3); }
.req { color: var(--red); }
.fld input, .fld select, .fld textarea {
  padding: 7px 9px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-family: var(--font-mono); font-size: 14px;
}
.fld select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234a6a90' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; padding-right: 26px;
  appearance: none; -webkit-appearance: none;
}
.fld input:focus, .fld select:focus { outline: none; border-color: var(--accent2); box-shadow: 0 0 0 2px rgba(0,128,204,0.2); }
.hint { font-size: 12px; color: var(--text3); }

/* generic grid layouts reused by a couple of panels */
.qa-grid  { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.two-col  { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tog-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
}

/* Each row is its own bordered box -- with a shared full-width underline and
   no visual boundary between cells, a toggle sitting at the right edge of a
   narrow grid cell reads as closer to the *next* label than its own, so the
   label/toggle pairing gets misread at a glance. */
.tog-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
}
.tog-lbl { font-size: 14px; color: var(--text2); }
.tog { position: relative; width: 36px; height: 19px; }
.tog input { opacity: 0; width: 0; height: 0; }
.tog .sl2 { position: absolute; inset: 0; background: var(--bg3); border: 1px solid var(--border); border-radius: 19px; cursor: pointer; }
.tog .sl2::before { content: ''; position: absolute; width: 13px; height: 13px; left: 2px; top: 2px; background: var(--text3); border-radius: 50%; transition: all 0.18s; }
.tog input:checked + .sl2 { background: rgba(0,180,255,0.15); border-color: var(--accent); }
.tog input:checked + .sl2::before { background: var(--accent); transform: translateX(17px); }

/* --- CARD ---------------------------------------------------- */
.card { background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.ct { font-size: 11px; font-family: var(--font-mono); font-weight: 600; letter-spacing: 0.15em; text-transform: uppercase; color: var(--text3); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.ct.inline { margin: 0; border: none; padding: 0; text-transform: none; font-size: inherit; letter-spacing: normal; }

/* card-style list rows (Zones / TG Lists / Scan Lists panels) */
.list-card-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.list-card-count { color: var(--text3); font-weight: 400; }
.list-card-actions { display: flex; gap: 5px; }

/* collapsible section (e.g. Satellites' advanced orbital-element fields) */
.acc { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.acc > summary { padding: 9px 12px; cursor: pointer; font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text3); list-style: none; }
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary::before { content: '▸ '; }
.acc[open] > summary::before { content: '▾ '; }
.acc-body { padding: 2px 12px 14px; }
.ab-sm { height: 24px; padding: 0 7px; font-size: 12px; }

/* --- STAT BOX ------------------------------------------------ */
.sgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-bottom: 20px; }
.sbox {
  background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 12px; text-align: center; cursor: pointer; user-select: none;
  transition: border-color 0.12s ease, transform 0.12s ease, background 0.12s ease;
}
.sbox:hover, .sbox:focus-visible {
  border-color: var(--accent); background: var(--bg2); transform: translateY(-2px);
  outline: none;
}
.sbox:active { transform: translateY(0); }
.snum { font-family: var(--font-mono); font-size: 30px; font-weight: 600; color: var(--accent); line-height: 1; }
.slbl { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 4px; }

/* --- ACTION BTN ---------------------------------------------- */
.ab {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0 9px; height: 28px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text2);
  font-size: 13px; font-family: var(--font-ui); font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.ab:hover      { border-color: var(--accent); color: var(--accent); background: rgba(0,180,255,0.05); }
.ab.ok:hover   { border-color: var(--green);  color: var(--green);  background: rgba(0,230,118,0.05); }
.ab.del:hover  { border-color: var(--red);    color: var(--red);    background: rgba(255,61,0,0.05); }

/* --- MODAL --------------------------------------------------- */
.mo { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 1000; align-items: center; justify-content: center; backdrop-filter: blur(3px); }
.mo.open { display: flex; }
.mbox {
  background: var(--bg1); border: 1px solid var(--border2);
  border-radius: 6px; width: min(680px,95vw); max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow); animation: pIn .15s ease;
}
.mbox::-webkit-scrollbar { width: 5px; }
.mbox::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
@keyframes pIn { from{transform:translateY(14px);opacity:0} to{transform:translateY(0);opacity:1} }
.mh { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 15px; background: var(--bg2); position: sticky; top: 0; z-index: 2; }
.mc { cursor: pointer; font-size: 20px; color: var(--text3); line-height: 1; }
.mc:hover { color: var(--red); }
.mb   { padding: 18px; }
.mf   { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--bg2); position: sticky; bottom: 0; }

.mtabs { display: flex; margin-bottom: 14px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.mtab  { flex: 1; padding: 7px; text-align: center; background: var(--bg2); cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text3); border: none; }
.mtab.active { background: rgba(0,180,255,0.12); color: var(--accent); }

.dmrf, .fmf { display: none; }
.dmrf.show, .fmf.show { display: block; }

/* --- BADGE --------------------------------------------------- */
.bdg { display: inline-block; padding: 1px 6px; border-radius: 3px; font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; }
.bdg.fm  { background: rgba(0,230,118,0.12); color: var(--green); border: 1px solid rgba(0,230,118,0.25); }
.bdg.dmr { background: rgba(178,108,255,0.12); color: var(--purple); border: 1px solid rgba(178,108,255,0.25); }

/* status pill (repeater online/offline, etc) -- rounded, colored, with a
   small live-indicator dot so "Active" reads as a state, not just a label. */
.bdg.pill { border-radius: 999px; padding: 2px 9px 2px 7px; }
.bdg.active  { background: rgba(0,230,118,0.12); color: var(--green); border: 1px solid rgba(0,230,118,0.3); }
.bdg.offline { background: rgba(122,156,192,0.10); color: var(--text3); border: 1px solid var(--border); }
.bdg.warn    { background: rgba(255,171,0,0.12); color: var(--amber); border: 1px solid rgba(255,171,0,0.3); }
.bdg.stale   { background: rgba(255,61,0,0.12); color: var(--red); border: 1px solid rgba(255,61,0,0.3); }
.bdg-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; background: currentColor; vertical-align: middle; }
.bdg.active .bdg-dot { box-shadow: 0 0 4px var(--green); animation: blink 2s infinite; }

/* chip (used for zone/TG-list member tags) */
.chip { display: inline-block; margin: 2px 3px 2px 0; padding: 2px 7px; background: var(--bg2); border: 1px solid var(--border); border-radius: 3px; font-size: 12px; color: var(--text2); }
.chip.purple { color: var(--purple); }
.chip-empty { font-size: 12px; color: var(--text3); font-style: italic; }

/* tag picker (searchable multi-select for Zone channels / TG List contacts /
   Scan List channels -- replaces free-typed "one per line" textareas) */
.tagpick { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg2); padding: 8px; }
.tagpick-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.tagpick-chips:not(:empty) { margin-bottom: 7px; }
.tagpick-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg3); border: 1px solid var(--border2); border-radius: 3px;
  padding: 3px 4px 3px 8px; font-size: 12px; color: var(--text);
}
.tagpick-chip .x { cursor: pointer; color: var(--text3); font-weight: 700; padding: 0 4px; border-radius: 2px; line-height: 1.4; }
.tagpick-chip .x:hover { color: var(--red); background: rgba(255,61,0,0.12); }
.tagpick-inputwrap { position: relative; }
.tagpick-input {
  width: 100%; background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 9px; font-family: var(--font-ui); font-size: 13px; color: var(--text);
}
.tagpick-input:focus { border-color: var(--accent); outline: none; }
.tagpick-dd {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; max-height: 220px; overflow-y: auto;
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 50; display: none;
}
.tagpick-dd.open { display: block; }
.tagpick-opt { padding: 7px 10px; font-size: 13px; color: var(--text2); cursor: pointer; }
.tagpick-opt:hover, .tagpick-opt.hl { background: var(--bg4); color: var(--text); }
.tagpick-opt.none { color: var(--text3); font-style: italic; cursor: default; }
.tagpick-opt.none:hover { background: none; }
.tagpick-empty-hint { font-size: 12px; color: var(--text3); padding: 6px 2px 0; }

/* code / CSV example block */
.code-block {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px; font-family: var(--font-mono); font-size: 12px; color: var(--text2); overflow-x: auto;
}
.code-block.wrap { white-space: pre-wrap; overflow-x: hidden; }

/* --- MISC ---------------------------------------------------- */
.uwarn { background: rgba(255,171,0,0.08); border: 1px solid rgba(255,171,0,0.3); border-radius: var(--radius); padding: 9px 13px; font-size: 14px; color: var(--amber); display: flex; gap: 9px; align-items: flex-start; margin-bottom: 14px; }
.ic { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; }
.ii { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ii .icon { width: 22px; height: 22px; stroke-width: 1.6; }
.in { flex: 1; }
.it { font-weight: 600; font-size: 14px; color: var(--text); }
.id { font-size: 12px; color: var(--text3); margin-top: 2px; }
.about-banner { background: linear-gradient(135deg,rgba(0,128,204,.1),rgba(0,60,120,.05)); border: 1px solid rgba(0,128,204,.2); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; text-align: center; }
.at { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 20px; font-weight: 900; color: var(--text); margin-bottom: 4px; }
.at-icon { color: var(--accent); flex-shrink: 0; }
.as { font-family: var(--font-mono); font-size: 12px; color: var(--accent); letter-spacing: .1em; margin-bottom: 10px; }
.ad { font-size: 14px; color: var(--text2); line-height: 1.7; max-width: 560px; margin: 0 auto 14px; }
.tag { display: inline-block; padding: 3px 9px; margin: 2px 3px; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; font-size: 13px; color: var(--text2); }

#ns { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 7px; z-index: 9000; pointer-events: none; }
.nf { padding: 9px 14px; background: var(--bg2); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius); font-size: 14px; color: var(--text); box-shadow: var(--shadow); max-width: 300px; pointer-events: all; animation: nIn .18s ease, nOut .25s ease 3s forwards; }
.nf.success { border-left-color: var(--green); }
.nf.error   { border-left-color: var(--red); }
.nf.warn    { border-left-color: var(--amber); }
@keyframes nIn  { from{opacity:0;transform:translateX(24px)} to{opacity:1;transform:translateX(0)} }
@keyframes nOut { from{opacity:1} to{opacity:0;transform:translateX(24px)} }

/* --- UTILITIES ------------------------------------------------
   Small, composable atoms for the one-off layout/spacing/color
   tweaks that used to be inline styles. Prefer a named component
   class above for anything that's actually a repeated component. */
.hidden { display: none !important; }

.flex          { display: flex; }
.flex-wrap     { flex-wrap: wrap; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.grow          { flex: 1; min-width: 0; }

.gap-3  { gap: 3px; }
.gap-5  { gap: 5px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }

.w-130 { width: 130px; }

.mt-8  { margin-top: 8px; }
.mt-14 { margin-top: 14px; }
.mb-6  { margin-bottom: 6px; }
.mb-8  { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }
.mb-14 { margin-bottom: 14px; }

.mono    { font-family: var(--font-mono); }
.text-11 { font-size: 12px; }
.text-12 { font-size: 13px; }
.text-13 { font-size: 14px; }

.text-dim    { color: var(--text3); }
.text-dim2   { color: var(--text2); }
.text-accent { color: var(--accent); }
.text-purple { color: var(--purple); }
.text-error  { color: var(--red); }
.status-ok   { color: var(--green); }

.link-accent { color: var(--accent); }

/* --- ICONS ----------------------------------------------------
   Vendored Lucide SVG sprite (see <symbol> defs near the top of
   index.html) referenced via <svg class="icon"><use href="#i-x"/></svg>.
   No color class needed inside an already-colored context (buttons that
   turn cyan/green/red on hover, .text-error, .uwarn) -- currentColor picks
   that up for free. The ic-* utilities below are only for standalone icons
   (sidebar nav, empty states) that carry their own fixed identity color. */
.icon {
  width: 16px; height: 16px; flex-shrink: 0; vertical-align: -3px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.ic-cyan   { color: var(--accent); }
.ic-blue   { color: var(--accent2); }
.ic-green  { color: var(--green); }
.ic-purple { color: var(--purple); }
.ic-amber  { color: var(--amber); }
.ic-red    { color: var(--red); }
.ic-muted  { color: var(--text3); }

@keyframes icon-spin { to { transform: rotate(360deg); } }
.icon-spin { animation: icon-spin 0.9s linear infinite; }
@media (prefers-reduced-motion: reduce) { .icon-spin { animation: none; } }
