:root {
  --bg: #0d1014;
  --panel: #151a20;
  --panel-2: #1c222a;
  --border: #262d37;
  --text: #dce2ea;
  --muted: #7f8b9a;
  --accent: #3d9cf0;
  --live: #2fbf71;
  --queued: #e0a030;
  --priority: #e5484d;
  --grid: rgba(255, 255, 255, 0.06);
  --label-w: 180px;
  --row-h: 28px;
  --axis-h: 26px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

button, select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font: inherit;
  cursor: pointer;
}
button:hover, select:hover { border-color: var(--accent); }
button.link { background: none; border: none; color: var(--accent); padding: 0 4px; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* Header */
.topbar {
  position: sticky;
  top: 0;
  /* Above page content and the home listen iframe (iframes steal clicks otherwise). */
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(13, 16, 20, .92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 156, 240, .25);
}
.conn-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--queued); }
.conn-dot.ok { background: var(--live); }
.conn-dot.bad { background: var(--priority); }
/* Personal / Curator mode switch (staff): pill in the top bar on wide
   screens, segmented control inside the menu on narrow ones. */
.mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.mode-switch a {
  padding: 5px 12px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}
.mode-switch a:hover { color: var(--text); }
/* Active side is the same accent in both modes: green/amber/red are
   reserved for the connection dot and other status lights. */
.mode-switch a.active { background: var(--accent); color: #fff; }
.menu-mode-switch { display: none; }
@media (max-width: 720px) {
  .top-mode-switch { display: none !important; }
  .menu-mode-switch { display: flex; margin: 4px 2px 6px; }
  .menu-mode-switch a { flex: 1; text-align: center; }
}
.icon-btn { display: flex; flex-direction: column; gap: 4px; padding: 8px; background: none; border: none; }
.icon-btn span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 1px; }

/* Hamburger dropdown */
.app-menu-wrap { position: relative; }
.app-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .45);
  z-index: 40;
}
.app-menu-group { display: flex; flex-direction: column; gap: 2px; }
.app-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
.app-menu-item:hover { background: var(--panel-2); border-color: transparent; }
a.app-menu-item { color: var(--text); }
.app-menu-badge {
  align-self: flex-start;
  margin: 4px 12px 2px;
}
.app-menu-meta {
  padding: 6px 12px 2px;
  color: var(--muted);
  font-size: 12px;
}

/* Page */
.page {
  max-width: 1500px;
  margin: 0 auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
/* Logged-out home: same listen card as the WordPress embed */
.home-page {
  align-items: center;
  padding-top: 28px;
}
.home-listen {
  border: 0;
  width: 100%;
  max-width: 640px;
  height: 140px;
  background: transparent;
}
.home-activity { width: 100%; max-width: 640px; }
.home-tease {
  width: 100%;
  max-width: 640px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.home-tease-lead {
  margin: 0;
  font-size: 16px;
  line-height: 1.45;
  max-width: 36em;
}
.home-tease-cta {
  display: inline-block;
  min-width: 200px;
  text-align: center;
  text-decoration: none;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  font-weight: 600;
  border-radius: 6px;
  padding: 10px 18px;
}
.home-tease-cta:hover { filter: brightness(1.05); }
.home-tease-note { margin: 0; }
.home-tease-note a { color: var(--accent); }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; }
.card-head h2 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.card-body { padding: 0 14px 14px; }

/* Timeline card */
.collapse-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 4px 0;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.chev {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
  transition: transform .15s;
}
.timeline-card.collapsed .chev { transform: rotate(-90deg); }
.timeline-card.collapsed .card-body { display: none; }

.timeline { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.tl-scroll {
  overflow: auto;
  max-height: calc(var(--max-rows, 8) * var(--row-h) + var(--axis-h) + 2px);
  overscroll-behavior-x: contain;
}
.tl-inner { min-width: 100%; }
.axis-row, .row { display: grid; grid-template-columns: var(--label-w) 1fr; }
.axis-row {
  position: sticky;
  top: 0;
  z-index: 3;
  height: var(--axis-h);
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.label-head {
  position: sticky;
  left: 0;
  z-index: 4;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--muted);
  background: var(--panel-2);
  border-right: 1px solid var(--border);
}
.axis { position: relative; overflow: hidden; }
.tick {
  position: absolute;
  top: 5px;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.rows { position: relative; }
.row { height: var(--row-h); }
.row:nth-child(even) .track { background-color: rgba(255, 255, 255, .015); }
.label {
  position: sticky;
  left: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  background: var(--panel);
  border-right: 1px solid var(--border);
  cursor: pointer;
}
.label .name { overflow: hidden; text-overflow: ellipsis; }
.label input { margin: 0; accent-color: var(--priority); }
.swatch { flex: none; width: 10px; height: 10px; border-radius: 2px; background: var(--c); }
.row.priority .name { color: var(--priority); font-weight: 600; }
.track {
  position: relative;
  overflow: hidden;
  background-image: linear-gradient(to right, var(--grid) 1px, transparent 1px);
  background-size: var(--grid-size, 100px) 100%;
  background-position: var(--grid-offset, 0) 0;
  background-repeat: repeat-x;
}
.block {
  position: absolute;
  top: 5px;
  bottom: 5px;
  min-width: 4px;
  border-radius: 3px;
  background: var(--c);
  cursor: pointer;
}
.block:hover { filter: brightness(1.25); }
.block.pending { background-image: repeating-linear-gradient(45deg, transparent 0 4px, rgba(0, 0, 0, .3) 4px 8px); }
.block.played { opacity: .45; }
.block.queued { box-shadow: 0 0 0 2px var(--queued); }
.block.playing { box-shadow: 0 0 0 2px #fff; z-index: 1; }
.now-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 2px dashed var(--priority);
  opacity: .8;
  pointer-events: none;
  z-index: 1;
}
.empty { padding: 24px; text-align: center; color: var(--muted); position: sticky; left: 0; width: min(100%, 100vw); }

.block.on-stream { box-shadow: 0 0 0 2px var(--priority); }
.block.playing.on-stream { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--priority); }

/* Stream status */
.stream-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
}
.stream-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.stream-card[data-status="live"] .stream-dot { background: var(--priority); animation: pulse 1.6s infinite; }
.stream-card[data-status="idle"] .stream-dot { background: var(--live); }
.stream-card[data-status="off"] .stream-dot { background: var(--queued); }
.stream-label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.stream-now { font-weight: 600; }
.stream-card[data-status="offline"] .stream-now,
.stream-card[data-status="off"] .stream-now { color: var(--muted); font-weight: 400; }
.overlay-link { color: var(--accent); font-size: 13px; text-decoration: none; }
.overlay-link:hover { text-decoration: underline; }
button:disabled { opacity: .45; cursor: default; border-color: var(--border); }
.stream-toggle { font-weight: 600; color: var(--queued); border-color: var(--queued); }
.stream-toggle.on { color: #fff; background: var(--priority); border-color: var(--priority); }

/* Lower area */
.lower { display: flex; flex-direction: column; gap: 14px; }
/* Player + activity rail: contents on narrow screens (activity hidden,
   members use menu > Stats), sticky rail under the player on wide ones. */
.side-rail { display: contents; }
.card.side-activity { display: none; }
.side-activity h2 { font-size: 15px; }
.side-activity .activity-updated { margin: 0; }
/* Fixed-height activity card: the table body scrolls (wheel / touch /
   keyboard) under a sticky header row; the scrollbar itself is hidden. */
.activity-scroll {
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}
.activity-scroll::-webkit-scrollbar { display: none; width: 0; height: 0; }
.activity-tg-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  cursor: pointer;
  border-radius: 999px;
}
.activity-tg-link:hover .tg-badge { filter: brightness(1.3); text-decoration: underline; }
.activity-tg-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.side-activity thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}
@media (min-width: 1000px) {
  /* Pin the whole rail as one unit: player on top, fixed-height activity
     card filling the rest of the screen height below it. */
  .side-rail {
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: sticky;
    top: 64px;
    max-height: calc(100vh - 78px);
  }
  .side-rail .player-card { position: static; }
  .card.side-activity { display: flex; flex: 1; min-height: 0; }
  .side-activity .activity-scroll { flex: 1; }
}

/* Player */
.player-card { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
audio { width: 100%; height: 40px; }
.player-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill { border-radius: 999px; padding: 6px 12px; color: var(--muted); }
.pill.has-items { color: var(--text); border-color: var(--queued); }
.live-btn { display: flex; align-items: center; gap: 8px; margin-left: auto; font-weight: 600; }
.live-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--priority); }
.live-btn.on { background: rgba(47, 191, 113, .15); border-color: var(--live); color: var(--live); }
.live-btn.on .live-dot { background: var(--live); animation: pulse 1.6s infinite; }
.live-btn.resume { border-color: var(--queued); color: var(--queued); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.queue-list:empty::before { content: "Queue is empty"; display: block; padding: 10px 12px; color: var(--muted); }
.queue-list li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.queue-list li:last-child { border-bottom: none; }
.queue-list li:hover { background: var(--panel-2); }
.queue-list li.waiting { opacity: .55; }
.queue-list li.priority .q-title { color: var(--priority); font-weight: 600; }
.q-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-meta { color: var(--muted); font-size: 12px; }

.now-playing { font-size: 14px; }
.transcript {
  min-height: 4.5em;
  max-height: 40vh;
  overflow-y: auto;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 17px;
  line-height: 1.6;
  color: var(--muted);
}
.word { cursor: pointer; border-radius: 3px; transition: color .1s, background .1s; }
.word.spoken { color: var(--text); }
.word.active { color: #fff; background: var(--accent); }
.word.low { text-decoration: underline dotted rgba(224, 160, 48, .7); text-underline-offset: 4px; opacity: .7; }
.word.low.active { opacity: 1; }
.priority-row { font-size: 13px; color: var(--muted); }
#priorityName { color: var(--priority); font-weight: 600; }

/* Recent calls */
.recent-card { display: flex; flex-direction: column; }
.recent-row {
  display: grid;
  grid-template-columns: minmax(120px, 190px) 92px 64px 1fr;
  gap: 12px;
  align-items: start;
  padding: 9px 14px;
  border-left: 3px solid transparent;
}
.recent-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.recent-list .recent-row { border-bottom: 1px solid var(--border); cursor: pointer; }
.recent-list .recent-row:hover { background: var(--panel-2); }
.recent-row.playing { background: rgba(61, 156, 240, .12); border-left-color: var(--accent); }
.recent-row.queued { border-left-color: var(--queued); }
.recent-row.played .r-text { color: var(--muted); }
.recent-row.duplicate { opacity: .55; }
.tg-badge {
  justify-self: start;
  max-width: 100%;
  padding: 2px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 22%, transparent);
  border: 1px solid var(--c);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.r-time, .r-len { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.r-text.pending { font-style: italic; color: var(--muted); }

/* Full-page settings sheet (same document → audio keeps playing) */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 110; }
.settings {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}
.settings-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: none;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.settings h2 { margin: 0; font-size: 18px; }
.settings h3 { margin: 6px 0 0; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.settings-tabs {
  display: flex;
  flex: none;
  gap: 0;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  overflow-x: auto;
}
.settings-tabs [data-tab] {
  flex: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.settings-tabs [data-tab]:hover { color: var(--text); }
.settings-tabs [data-tab].active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.settings-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.settings-panel { display: none; flex-direction: column; gap: 12px; min-height: 0; }
.settings-panel.active { display: flex; flex: 1; }
.settings-panel[data-panel="talkgroups"] .tg-list { flex: 1; }
body.settings-sheet-open { overflow: hidden; }
.settings code {
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.keyword-add { display: flex; gap: 6px; }
.keyword-add input { flex: 1; min-width: 0; }
.keyword-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
}
.keyword-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 13px;
}
.keyword-chip button {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 2px 6px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.keyword-chip button:hover { color: var(--priority); }
.keyword-pill.open {
  background: rgba(47, 191, 113, .15);
  border-color: var(--live);
  color: var(--live);
}
.keyword-pill.quiet {
  border-color: var(--queued);
  color: var(--queued);
}
.opt { display: flex; gap: 8px; align-items: flex-start; }
.opt-number { align-items: center; justify-content: space-between; }
.opt-number input, .tg-tools input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
}
.opt-number input { width: 70px; }
.tg-tools { display: flex; gap: 6px; }
.tg-tools input { flex: 1; min-width: 0; }
.tg-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.tg-list li { display: flex; flex-direction: column; gap: 0; }
.tg-row { display: flex; gap: 6px; align-items: center; }
.tg-list label { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: center; padding: 6px 2px; cursor: pointer; }
.tg-list .tg-id { margin-left: auto; color: var(--muted); font-size: 12px; }
.tg-delay { flex: none; font-size: 12px; padding: 2px 4px; color: var(--muted); }
.tg-delay.on { color: var(--queued); border-color: var(--queued); font-weight: 600; }
.tg-more { flex: none; font-size: 12px; padding: 2px 8px; color: var(--muted); }
.tg-more::before { content: '▸'; display: inline-block; margin-right: 3px; transition: transform .12s ease; }
.tg-more.open::before { transform: rotate(90deg); }
.tg-more.active { color: var(--live); border-color: var(--live); font-weight: 600; }
.tg-extras {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 0 2px 8px 28px;
}
.tg-tone, .tg-trim { flex: none; font-size: 12px; padding: 2px 8px; color: var(--muted); }
.tg-tone.on, .tg-trim.on { color: var(--live); border-color: var(--live); font-weight: 600; }
.tg-gain { flex: none; font-size: 12px; padding: 2px 4px; color: var(--muted); }
.tg-gain.on { color: var(--live); border-color: var(--live); font-weight: 600; }
.tg-delay-note { flex: none; font-size: 11px; color: var(--queued); border: 1px solid var(--queued); border-radius: 4px; padding: 0 5px; }
.settings-note { margin: 0; color: var(--muted); font-size: 13px; }

/* Admin header */
.brand-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--queued); border: 1px solid var(--queued); border-radius: 4px; padding: 0 5px; }
.user-menu { display: flex; align-items: center; gap: 6px; }
.user-link { color: var(--text); text-decoration: none; font-weight: 600; }
.user-link:hover { color: var(--accent); }

/* Login & account pages */
input:not([type=checkbox]):not([type=radio]) {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
  font: inherit;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: var(--priority); }
button.danger:hover { border-color: var(--priority); }
button:disabled { opacity: .5; cursor: default; }
.small { font-size: 12px; }
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: 100%; max-width: 340px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.login-door { display: flex; flex-direction: column; gap: 10px; }
.login-split { text-align: center; text-transform: uppercase; letter-spacing: .08em; font-size: 11px; }
.login-toggle { align-self: flex-start; }
a.login-membership, a.button.primary {
  display: block;
  text-align: center;
  text-decoration: none;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  font-weight: 600;
  border-radius: 6px;
  padding: 9px 12px;
}
a.login-membership:hover { filter: brightness(1.05); }
.auth-card label, .stack-form label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; }
.auth-card input, .stack-form input { color: var(--text); font-size: 15px; }
.form-error, .form-msg { margin: 0; color: var(--priority); font-size: 13px; }
.form-msg.ok { color: var(--live); }
.form-note { margin: 0; padding: 8px 10px; border-radius: 6px; background: rgba(224, 160, 48, .12); color: var(--queued); font-size: 13px; }
.form-note code { color: var(--text); font-size: 14px; user-select: all; }
.account-page { max-width: 900px; }
.help-page { max-width: 860px; }
.help-page .account-card p { margin: 0; }
.faq-item { border-top: 1px solid var(--border); padding: 10px 0 2px; }
.faq-item:first-of-type { border-top: none; }
.faq-item summary { cursor: pointer; font-weight: 600; padding: 2px 0 8px; }
.faq-item summary:hover { color: var(--accent); }
.faq-item p { margin: 0 0 10px; color: var(--text); }
.account-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.account-card h2 { margin: 0; font-size: 16px; }
.stack-form { display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.inline-form, .copy-row { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 140px; }
.copy-row input { flex: 1; min-width: 200px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.plain-list li:last-child { border-bottom: none; }
.pill-tag { font-size: 11px; color: var(--live); border: 1px solid var(--live); border-radius: 4px; padding: 0 5px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.data-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr.warn td { color: var(--queued); }
.row-actions { text-align: right; }
.row-actions button { margin: 2px 0 2px 6px; }
.row-actions button, .data-table select { padding: 3px 8px; font-size: 12px; }
.nav-link { font-weight: 500; }
.inline-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.inline-form .inline-label input { flex: none; min-width: 0; }
span.viewer-fields { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form .notes-input { flex: 2 1 220px; }
.user-notes { margin-top: 2px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.users-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.users-toolbar input[type=search] {
  flex: 1;
  min-width: 160px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font: inherit;
}
.users-pager {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.user-more { font-size: 12px; padding: 3px 8px; color: var(--muted); }
.user-more::before { content: '▸'; display: inline-block; margin-right: 3px; transition: transform .12s ease; }
.user-more.open::before { transform: rotate(90deg); }
.user-extras-row td {
  background: var(--panel-2, rgba(255, 255, 255, .03));
  padding: 10px 12px 12px;
}
.user-extras {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  max-width: 280px;
}
.user-field select, .user-field input, .user-details-form .notes-input {
  color: var(--text);
  font-size: 13px;
}
.user-details-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}
.user-expiry-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.user-extras-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}
.secure-tg-field { max-width: none; }
.secure-tg-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 4px;
}
.secure-tg-list .opt { font-size: 13px; color: var(--text); }
.data-table input.profile-name { min-width: 120px; padding: 3px 8px; font-size: 13px; }
.data-table input.num-input { width: 64px; padding: 3px 6px; font-size: 13px; }
.access-badge { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; border-radius: 4px; padding: 1px 6px; border: 1px solid var(--muted); color: var(--muted); white-space: nowrap; }
.access-badge.live { color: var(--live); border-color: var(--live); }

/* Call history */
.history-page { max-width: 860px; }
.history-controls {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 12px;
  align-items: end;
}
.history-controls input[type=date] {
  color: var(--text);
  width: 100%;
}
.history-player audio { width: 100%; margin-top: 6px; }
.history-now { margin-bottom: 2px; }
.history-list-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.history-list-head .summary-meta { margin: 0; flex: 1; min-width: 140px; }
.history-search-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.history-search {
  width: min(100%, 220px);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
  font: inherit;
}
.history-item.filtered-out { display: none; }
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(70vh, 900px);
  overflow-y: auto;
}
.history-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}
.history-item:hover { border-color: var(--accent); }
.history-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.history-item.no-audio { cursor: default; opacity: .85; }
.history-item.no-audio:hover { border-color: var(--border); }
.history-item-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 4px;
  font-size: 13px;
}
.history-time { font-weight: 600; font-variant-numeric: tabular-nums; }
.history-dur { font-variant-numeric: tabular-nums; }
.history-src { margin-left: auto; }
.history-flags { display: flex; gap: 4px; }
.history-text { font-size: 14px; line-height: 1.45; white-space: pre-wrap; }
.history-empty { padding: 12px; }
@media (max-width: 640px) {
  .history-controls { grid-template-columns: 1fr; }
}

/* Talkgroup summary */
.summary-page { max-width: 920px; }
.summary-controls {
  display: grid;
  grid-template-columns: 1fr 140px auto;
  gap: 12px;
  align-items: end;
}
.summary-field { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; }
.summary-field select { color: var(--text); width: 100%; }
.summary-meta { margin-bottom: 4px; }
.summary-body { font-size: 15px; line-height: 1.55; }
.summary-body h3 { margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.summary-body h3:first-child { margin-top: 0; }
.summary-body p { margin: 0 0 10px; }
.summary-body ul { margin: 0 0 10px; padding-left: 1.2em; }
.summary-body li { margin: 4px 0; }
.summary-bars { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; }
.summary-bar-row {
  display: grid;
  grid-template-columns: minmax(110px, 160px) 1fr 2.5rem;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}
.summary-bar-label { color: var(--text); }
.summary-bar-track {
  height: 10px;
  border-radius: 4px;
  background: var(--panel-2, rgba(255, 255, 255, .06));
  overflow: hidden;
}
.summary-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent, #3b82f6);
  min-width: 2px;
}
.summary-bar-count { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.summary-table { width: 100%; margin: 0 0 12px; font-size: 13px; }
.summary-table td.num, .summary-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.summary-stats { margin: 0 0 12px; }
.summary-footnote { margin: 16px 0 0; }
@media (max-width: 640px) {
  .summary-controls { grid-template-columns: 1fr; }
  .summary-bar-row { grid-template-columns: 1fr 2.5rem; }
  .summary-bar-label { grid-column: 1 / -1; }
}

/* Stats page */
.stats-page { max-width: 1100px; }
.tg-stats-page { max-width: 760px; }
.tg-stats-page .stats-head h1 { font-size: 18px; }
.stats-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.stats-head h1 { margin: 0; font-size: 20px; flex: 1; }
.stats-page > p { margin: -6px 0 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: none; border-radius: 0; background: transparent; padding: 6px 14px; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: var(--accent); color: #fff; font-weight: 600; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { padding: 12px 14px; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 2px; }
.stat-value.live-num { color: var(--live); }
.stat-sub { color: var(--muted); font-size: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.hbars { display: flex; flex-direction: column; gap: 7px; }
.hbar { display: grid; grid-template-columns: 90px 1fr 70px; gap: 8px; align-items: center; font-size: 13px; }
.hbar-track { height: 12px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.hbar-value { text-align: right; color: var(--muted); font-size: 12px; }
.chart-title { color: var(--muted); font-size: 12px; margin-top: 4px; }
.vbars { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; height: 90px; align-items: end; }
.vbar { height: 100%; display: flex; align-items: flex-end; background: var(--bg); border-radius: 3px; }
.vbar.empty { opacity: .35; }
.vbar-fill { width: 100%; background: var(--live); border-radius: 3px; }
.vbars.calls .vbar-fill { background: var(--queued); }
.vbars-axis { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; font-size: 10px; color: var(--muted); }
.vbars-axis span { white-space: nowrap; overflow: visible; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table.sortable th[data-sort] { cursor: pointer; user-select: none; }
.data-table.sortable th[data-sort]:hover { color: var(--text); }
.data-table.sortable th.sorted { color: var(--accent); }
.share-col { width: 22%; white-space: nowrap; }
.share-bar { display: inline-block; height: 8px; border-radius: 4px; vertical-align: middle; min-width: 2px; max-width: 75%; }
.tg-num { white-space: nowrap; }

@media (max-width: 640px) {
  .account-page .audit-table th:nth-child(4), .account-page .audit-table td:nth-child(4) { display: none; }
  .share-col { display: none; }
  .users-table th:nth-child(2), .users-table tr:not(.user-extras-row) td:nth-child(2) {
    max-width: 7.5rem;
    font-size: 12px;
  }
  .user-field { max-width: none; }
}

/* Wide screens: player beside the call list */
@media (min-width: 1000px) {
  .lower {
    display: grid;
    grid-template-columns: minmax(360px, 480px) 1fr;
    align-items: start;
  }
  .player-card { position: sticky; top: 64px; }
}

/* Phones */
@media (max-width: 640px) {
  :root { --label-w: 120px; --row-h: 32px; }
  .page { padding: 8px; gap: 10px; }
  .card-head { padding: 8px 10px; }
  .card-body { padding: 0 8px 8px; }
  .card-head select { padding: 5px 8px; }
  .label { padding: 0 7px; font-size: 12px; }
  .player-card { padding: 10px; }
  .live-btn { margin-left: 0; }
  .recent-row { grid-template-columns: 96px 74px 1fr; gap: 8px; padding: 9px 10px; font-size: 13px; }
  .col-len, .r-len { display: none; }
  .tg-badge { font-size: 11px; padding: 2px 7px; }
}
