:root {
  --bg: #111214;
  --panel: #17191c;
  --panel2: #202328;
  --border: #31343a;
  --text: #eceff3;
  --muted: #aeb3bb;
  --blue: #8fd8ff;
  --green: #7dff7d;
  --yellow: #ffd166;
  --red: #ff6b6b;
  --orange: #ff9f43;
  --map-bg: #071015;
  --map-grid: rgba(143, 216, 255, .22);
  --map-grid-detail: rgba(143, 216, 255, .12);
  --map-label: rgba(200, 235, 255, .58);
}

html[data-theme="light"] {
  --bg: #eef3f7;
  --panel: #ffffff;
  --panel2: #f6f9fb;
  --border: #ccd7df;
  --text: #17212a;
  --muted: #5f6f7a;
  --blue: #0369a1;
  --green: #138a36;
  --yellow: #a55d00;
  --red: #c62828;
  --orange: #bf5b00;
  --map-bg: #dbe9f0;
  --map-grid: rgba(3, 105, 161, .30);
  --map-grid-detail: rgba(3, 105, 161, .17);
  --map-label: rgba(0, 75, 110, .70);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.topbar { position: sticky; top: 0; z-index: 1000; display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 14px 18px; background: var(--panel); border-bottom: 1px solid var(--border); }
.top-title { min-width: 260px; }
.top-clock { display: flex; gap: 12px; align-items: center; justify-content: center; flex: 1; }
.top-clock div { background: var(--panel2); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; min-width: 160px; text-align: center; }
.top-clock span { display:block; color:var(--muted); font-size:10px; text-transform:uppercase; letter-spacing:.08em; }
.top-clock strong { display:block; color:var(--blue); font-size:14px; margin-top:2px; }
.top-actions { display:flex; flex-wrap:wrap; gap:8px; justify-content:flex-end; align-items:center; }
h1,h2,h3 { color:var(--blue); margin:0 0 12px; } h1{font-size:24px} h2{font-size:18px}.subtitle{margin:0;color:var(--muted)}
button { background:#2d6cdf; color:white; border:1px solid transparent; border-radius:8px; padding:9px 12px; font-weight:700; cursor:pointer; }
button:hover{filter:brightness(1.12)} button.danger{background:#9d2d2d} button.secondary{background:var(--panel2);color:var(--text);border-color:var(--border)} button.active-control{background:#175a8a;border-color:var(--blue)}
select { background:var(--panel2); color:var(--text); border:1px solid var(--border); border-radius:7px; padding:6px; }
.dashboard { display:grid; grid-template-columns:repeat(12,minmax(0,1fr)); gap:14px; padding:14px; }
.card { background:var(--panel); border:1px solid var(--border); border-radius:12px; padding:14px; min-width:0; }
.span-3{grid-column:span 3}.span-4{grid-column:span 4}.span-6{grid-column:span 6}.span-12{grid-column:span 12}
.health-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}.health-group h3{font-size:12px;margin:0 0 6px;color:var(--muted)}.compact-health-card{min-height:160px}.compact-health{grid-template-columns:1fr 1fr;gap:8px}.compact-health .chip-grid{gap:5px}.compact-health .chip{font-size:10px;padding:3px 6px}
.status-list{display:grid;grid-template-columns:auto 1fr;gap:7px 12px;margin:0}.status-list dt{color:var(--muted)}.status-list dd{margin:0;font-weight:700}
.chip-grid{display:flex;flex-wrap:wrap;gap:8px}.compact-chips{margin-bottom:10px}.chip{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--border);border-radius:999px;padding:5px 9px;background:var(--panel2);font-size:12px;white-space:nowrap}.chip.ok{color:var(--green)}.chip.bad{color:var(--red)}.chip.warn{color:var(--yellow)}
.pill{display:inline-flex;align-items:center;background:var(--panel2);border:1px solid var(--border);border-radius:999px;padding:6px 10px;color:var(--muted);white-space:nowrap}
.audio-box{margin-top:8px}audio{width:100%;height:38px}.audio-actions{display:flex;flex-wrap:wrap;gap:7px;align-items:center;margin:8px 0 3px}a{color:var(--blue)}.small{color:var(--muted);font-size:12px;margin-top:6px}
.section-title-row{display:flex;justify-content:space-between;gap:12px;align-items:center}.controls{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.alert{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:10px;border-radius:8px;margin:8px 0;background:#3b2d14;color:var(--yellow);border-left:4px solid var(--yellow)}.alert.critical{background:#401616;color:var(--red);border-left-color:var(--red)}.alert.vhf{background:#17324a;color:#bceaff;border-left-color:#8fd8ff}.alert-main{min-width:0}.alert-repeat{font-size:12px}
.table-wrap{overflow-x:auto}table{width:100%;border-collapse:collapse}th,td{border-bottom:1px solid var(--border);padding:8px 10px;text-align:left;white-space:nowrap}th{color:var(--blue);font-size:12px}.empty{color:var(--muted);text-align:center}
.heatmap{overflow-x:auto}.heat-row{display:grid;grid-template-columns:62px repeat(24,minmax(34px,1fr));gap:2px;align-items:center;margin-bottom:3px;min-width:980px}.daily-row{grid-template-columns:62px repeat(21,minmax(42px,1fr));min-width:1500px}.heat-label{color:var(--blue);font-weight:700;font-size:12px}.heat-cell{min-height:24px;border:1px solid var(--border);border-radius:4px;display:flex;align-items:center;justify-content:center;font-size:10px;color:#fff;background:#181a1d}.heat-cell.hour{background:transparent;border-color:transparent;color:var(--muted)}.heat-0{background:#181a1d}.heat-1{background:#183654}.heat-2{background:#1e5f74}.heat-3{background:#2d8a68}.heat-4{background:#8a7a2d}.heat-5{background:#9b512c}.heat-current{outline:2px solid var(--blue)}
.band-buttons{display:flex;flex-wrap:wrap;gap:8px}.band-buttons button{min-width:88px}
.map-controls{justify-content:flex-end}.spots-map{width:100%;height:clamp(420px,68vh,880px);min-height:420px;max-height:880px;position:relative;overflow:hidden;border:1px solid var(--border);border-radius:10px;background:var(--map-bg);cursor:grab;touch-action:none;user-select:none}.spots-map.dragging{cursor:grabbing}.spots-map canvas{width:100%;height:100%;display:block}.map-layout{display:grid;grid-template-columns:120px 1fr;gap:14px;align-items:stretch}.map-legend{background:var(--panel2);border:1px solid var(--border);border-radius:12px;padding:12px;font-size:.85rem}.map-legend h3{margin:0 0 10px;color:var(--blue)}.map-legend div{display:flex;align-items:center;gap:8px;margin:7px 0}.map-legend span{width:13px;height:13px;border-radius:50%;display:inline-block;box-shadow:0 0 8px currentColor}.map-tooltip{position:absolute;z-index:4;max-width:260px;background:var(--panel);border:1px solid var(--border);border-radius:8px;padding:8px 10px;color:var(--text);font-size:12px;box-shadow:0 8px 24px rgba(0,0,0,.35);display:none;pointer-events:none}.map-tooltip strong{color:var(--blue)}.map-tooltip code{display:block;margin-top:5px;white-space:normal;word-break:break-word;color:var(--text);font:11px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
.logs-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.log-panel{border:1px solid var(--border);border-radius:8px;overflow:hidden;background:var(--panel2)}.log-header{display:flex;align-items:center;gap:8px;background:var(--panel2);padding:6px 10px;cursor:pointer}.log-toggle{background:none;border:none;color:var(--blue);font-size:14px;cursor:pointer}.log-output{max-height:320px;overflow-y:auto;padding:10px;margin:0;font-size:12px;line-height:1.3;background:var(--bg);color:var(--text);white-space:pre-wrap;word-break:break-word}.log-panel.collapsed .log-output{display:none}.log-error{color:var(--red);font-weight:bold}.log-warn{color:var(--yellow)}.log-success{color:var(--green)}.log-info{color:var(--blue)}
.waterfall-canvas{width:100%;height:120px;display:block;background:#050b10;border:1px solid var(--border);border-radius:8px}
@media(max-width:1100px){.span-3,.span-4,.span-6{grid-column:span 12}.logs-grid{grid-template-columns:1fr}}
@media(max-width:800px){.map-layout{grid-template-columns:1fr}.map-legend{display:grid;grid-template-columns:repeat(4,1fr)}.map-legend h3{grid-column:1/-1}}
@media(max-width:700px){.top-clock{width:100%;flex-direction:column;align-items:stretch}.top-clock div{min-width:0}.topbar{align-items:flex-start;flex-direction:column}.dashboard{grid-template-columns:1fr;padding:10px}.span-3,.span-4,.span-6,.span-12{grid-column:span 1}.section-title-row{align-items:flex-start;flex-direction:column}.spots-map{height:clamp(360px,60vh,560px);min-height:360px;max-height:560px}}

/* Card cleanup and live-clock UI */
.card-title-row{align-items:flex-start;margin-bottom:8px}.card-title-row h2{margin-bottom:0}
.summary-grid{display:grid;gap:5px}.summary-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;align-items:center;padding:3px 0;border-bottom:1px solid color-mix(in srgb,var(--border) 55%, transparent);font-size:12px}.summary-row:last-child{border-bottom:0}.summary-row span{color:var(--muted)}.summary-row strong{font-size:11px;letter-spacing:.02em}.summary-ok{color:var(--green)!important}.summary-bad{color:var(--red)!important}
.details-box{margin-top:10px;border-top:1px solid var(--border);padding-top:7px}.details-box summary{cursor:pointer;color:var(--blue);font-size:12px;font-weight:700}.details-box[open] summary{margin-bottom:8px}.audio-details{display:grid;gap:3px}.audio-summary{margin-bottom:8px}.audio-footer{display:flex;gap:8px;justify-content:space-between;align-items:center;flex-wrap:wrap}.audio-footer a{font-weight:700}.compact-health-card{min-height:0}.compact-health{margin-top:8px}

/* Mobile usability patch for small phones such as Pixel 3 */
@media (max-width: 700px) {
  html, body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    font-size: 13px;
  }

  .topbar {
    position: static;
    padding: 10px;
    gap: 8px;
  }

  .top-title {
    min-width: 0;
    width: 100%;
  }

  h1 { font-size: 19px; margin-bottom: 4px; }
  h2 { font-size: 16px; }
  .subtitle { font-size: 11px; }

  .top-clock {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .top-clock div {
    min-width: 0;
    border-radius: 10px;
    padding: 5px 7px;
  }

  .top-clock span { font-size: 9px; }
  .top-clock strong { font-size: 12px; }

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .top-actions .pill {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .top-actions button,
  .top-actions .pill {
    width: 100%;
    min-width: 0;
  }

  button {
    padding: 8px 8px;
    font-size: 12px;
  }

  .dashboard {
    padding: 8px;
    gap: 8px;
  }

  .card {
    padding: 10px;
    border-radius: 10px;
  }

  .section-title-row {
    gap: 7px;
  }

  .status-list {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 8px;
    font-size: 12px;
  }

  .summary-row {
    gap: 8px;
    font-size: 12px;
  }

  .audio-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .audio-actions button,
  .audio-actions .pill {
    width: 100%;
    justify-content: center;
  }

  .audio-actions .pill {
    grid-column: 1 / -1;
  }

  .audio-footer {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .waterfall-canvas {
    height: 88px;
  }

  .map-layout {
    gap: 8px;
  }

  .map-legend {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 8px;
    font-size: 11px;
  }

  .map-legend div {
    margin: 3px 0;
  }

  .map-controls {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .map-controls label {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    width: 100%;
  }

  .map-controls select,
  .map-controls button,
  .map-controls .pill {
    width: 100%;
    min-width: 0;
    justify-content: center;
  }

  #mapZoomLevel {
    min-width: 0;
  }

  #mapCount {
    grid-column: 1 / -1;
  }

  .spots-map {
    height: 62vh;
    min-height: 310px;
    max-height: 460px;
    border-radius: 8px;
  }

  .map-tooltip {
    max-width: calc(100vw - 36px);
    font-size: 11px;
  }

  .band-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .band-buttons button {
    min-width: 0;
    width: 100%;
  }

  .table-wrap,
  .heatmap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-left: -2px;
    margin-right: -2px;
  }

  table {
    font-size: 12px;
  }

  th, td {
    padding: 6px 8px;
  }

  .heat-row {
    min-width: 760px;
    grid-template-columns: 50px repeat(24, 28px);
  }

  .daily-row {
    min-width: 940px;
    grid-template-columns: 50px repeat(21, 40px);
  }

  .heat-cell {
    min-height: 22px;
    font-size: 9px;
  }

  .logs-grid {
    gap: 8px;
  }

  .log-output {
    max-height: 250px;
    font-size: 11px;
  }
}

@media (max-width: 400px) {
  .top-actions {
    grid-template-columns: 1fr;
  }

  .audio-actions {
    grid-template-columns: 1fr;
  }

  .map-controls {
    grid-template-columns: 1fr 1fr;
  }

  .map-controls button {
    padding-left: 6px;
    padding-right: 6px;
  }

  .spots-map {
    height: 58vh;
    min-height: 295px;
  }
}


/* Radio Status + Live Waterfall combined card */
.radio-waterfall-card {
  display: grid;
  grid-template-rows: auto auto minmax(48px, 1fr);
  gap: 7px;
  overflow: hidden;
}

.compact-card-title {
  margin-bottom: 0;
}

.compact-card-title h2 {
  margin-bottom: 0;
}

.mini-pill {
  padding: 4px 8px;
  font-size: 11px;
}

.compact-radio-status {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 8px;
  font-size: 12px;
  line-height: 1.2;
}

.compact-radio-status dd {
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-waterfall-canvas {
  height: 58px;
  min-height: 48px;
  margin-top: 2px;
}

.reserved-top-card {
  min-height: 0;
}

.reserved-top-card h2 {
  margin-bottom: 6px;
}

@media (max-width: 700px) {
  .radio-waterfall-card {
    grid-template-rows: auto auto 76px;
  }

  .compact-radio-status {
    font-size: 12px;
    gap: 4px 8px;
  }

  .mini-waterfall-canvas {
    height: 76px;
  }

  .reserved-top-card {
    min-height: 0;
  }
}

@media (max-width: 400px) {
  .compact-card-title {
    align-items: flex-start;
  }

  .mini-pill {
    font-size: 10px;
  }

  .mini-waterfall-canvas {
    height: 68px;
  }
}

/* KB2URI stable clock header patch
   Keeps Local/UTC clock position stable while refreshStatus changes text. */
.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(360px, 1fr);
  align-items: center;
}

.top-title {
  min-width: 0;
}

.top-clock {
  justify-self: center;
  flex: none;
  min-width: 344px;
}

.top-clock div {
  width: 166px;
  min-width: 166px;
}

.top-actions {
  justify-self: end;
  min-width: 360px;
}

#refreshStatus {
  min-width: 132px;
  justify-content: center;
  text-align: center;
}

/* Medium widths: keep the clock from being squeezed by action buttons. */
@media (max-width: 1100px) and (min-width: 701px) {
  .topbar {
    grid-template-columns: minmax(220px, 1fr) auto;
    grid-template-areas:
      "title clock"
      "actions actions";
  }

  .top-title { grid-area: title; }
  .top-clock {
    grid-area: clock;
    justify-self: end;
  }

  .top-actions {
    grid-area: actions;
    width: 100%;
    min-width: 0;
    justify-content: flex-end;
  }
}

/* Mobile: clocks remain in their own row; refresh status changes below them. */
@media (max-width: 700px) {
  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "clock"
      "actions";
  }

  .top-title {
    grid-area: title;
  }

  .top-clock {
    grid-area: clock;
    justify-self: stretch;
    min-width: 0;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
  }

  .top-clock div {
    width: auto;
    min-width: 0;
  }

  .top-actions {
    grid-area: actions;
    min-width: 0;
    width: 100%;
  }

  #refreshStatus {
    min-width: 0;
    min-height: 31px;
  }
}

@media (max-width: 380px) {
  .top-clock strong {
    font-size: 11px;
    letter-spacing: -0.02em;
  }
}

/* KB2URI manual control card patch */
.manual-control-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.manual-scanner-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.manual-control-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(76px, .45fr);
  gap: 6px;
  align-items: end;
}

.manual-control-form label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
}

.manual-control-form input,
.manual-control-form select {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  padding: 6px 8px;
  font-size: 13px;
}

.manual-control-form button {
  grid-column: 1 / -1;
}

.manual-note {
  margin: 0;
  line-height: 1.25;
}

#manualControlStatus {
  white-space: nowrap;
}

@media (max-width: 700px) {
  .manual-scanner-actions,
  .manual-control-form {
    grid-template-columns: 1fr 1fr;
  }

  .manual-control-form button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 380px) {
  .manual-scanner-actions,
  .manual-control-form {
    grid-template-columns: 1fr;
  }

  .manual-control-form button {
    grid-column: 1;
  }
}

/* KB2URI top cards cleanup patch */
.order-health,
.order-radio,
.order-audio,
.manual-control-card {
  min-height: 0;
}

.order-health .summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.order-health .summary-row {
  display: block;
  min-height: 42px;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 9px;
  padding: 7px 9px;
  background: color-mix(in srgb, var(--panel-soft) 72%, transparent);
}

.order-health .summary-row span,
.order-health .summary-row strong {
  display: block;
}

.order-health .summary-row span {
  font-size: 11px;
  line-height: 1.15;
  margin-bottom: 3px;
}

.order-health .summary-row strong {
  font-size: 12px;
  line-height: 1.2;
}

.order-health .details-box {
  margin-top: 10px;
}

.top-card-clean-radio {
  display: grid;
  grid-template-rows: auto auto auto minmax(58px, 1fr);
  gap: 8px;
}

.radio-primary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.bigfreq {
  font-size: clamp(18px, 1.35vw, 23px);
  font-weight: 750;
  letter-spacing: .01em;
  line-height: 1.15;
  color: var(--text);
}

.band-pill {
  align-self: end;
  min-width: 48px;
}

.radio-mini {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 3px 10px;
  font-size: 12px;
  color: var(--muted);
}

.radio-mini strong {
  color: var(--text);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-card-clean-radio .mini-waterfall-canvas {
  height: 86px;
  max-height: 96px;
}

.audio-top-card .card-title-row {
  margin-bottom: 8px;
}

.audio-status-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.audio-status-grid .summary-row {
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 9px;
  padding: 7px 9px;
  background: color-mix(in srgb, var(--panel-soft) 72%, transparent);
}

.compact-audio-box {
  margin-top: 8px;
}

.compact-audio-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.compact-audio-actions button {
  white-space: nowrap;
}

.audio-top-card .audio-footer {
  align-items: center;
}

.audio-top-card .details-box {
  margin-top: 8px;
}

.manual-top-card {
  gap: 8px;
}

.manual-top-card .manual-scanner-actions {
  gap: 7px;
}

.manual-top-card .manual-control-form {
  grid-template-columns: minmax(0, 1fr) 108px;
  gap: 7px;
}

.manual-top-card .manual-control-form input,
.manual-top-card .manual-control-form select {
  min-height: 36px;
}

.manual-top-card #manualApply {
  min-height: 36px;
}

.control-note {
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 9px;
  background: color-mix(in srgb, var(--panel-soft) 72%, transparent);
  padding: 8px 9px;
}

@media (max-width: 700px) {
  .order-health .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-card-clean-radio {
    grid-template-rows: auto auto auto 80px;
  }

  .top-card-clean-radio .mini-waterfall-canvas {
    height: 80px;
  }

  .manual-top-card .manual-control-form {
    grid-template-columns: minmax(0, 1fr) 96px;
  }
}

@media (max-width: 380px) {
  .order-health .summary-grid,
  .audio-status-grid,
  .compact-audio-actions,
  .manual-top-card .manual-scanner-actions,
  .manual-top-card .manual-control-form {
    grid-template-columns: 1fr;
  }

  .bigfreq {
    font-size: 19px;
  }
}

/* KB2URI mode/frequency cleanup patch */
.manual-control-form select,
.manual-control-form select option,
select#manualMode,
select#manualMode option {
  background-color: var(--panel-soft, #15191f);
  color: var(--text, #e8eef7);
}

.manual-control-form select:focus,
select#manualMode:focus {
  outline: 2px solid var(--accent, #69d1ff);
  outline-offset: 1px;
}

body.light .manual-control-form select,
body.light .manual-control-form select option,
body.light select#manualMode,
body.light select#manualMode option {
  background-color: #ffffff;
  color: #111827;
}

.bigfreq {
  white-space: nowrap;
}

/* KB2URI NFM/squelch Manual Control patch */
.manual-control-form {
  grid-template-columns: minmax(0, 1fr) minmax(92px, .45fr);
}

.manual-squelch {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(84px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 9px;
  background: color-mix(in srgb, var(--panel-soft) 72%, transparent);
}

.manual-squelch label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
}

.manual-squelch label span {
  color: var(--muted);
  font-size: 12px;
}

.manual-squelch label strong {
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.manual-squelch input[type="range"] {
  width: 100%;
  min-width: 0;
  accent-color: var(--accent, #69d1ff);
}

.manual-control-form select,
.manual-control-form select option,
select#manualMode,
select#manualMode option {
  background-color: var(--panel-soft, #15191f) !important;
  color: var(--text, #e8eef7) !important;
}

.manual-control-form select:focus,
select#manualMode:focus {
  outline: 2px solid var(--accent, #69d1ff);
  outline-offset: 1px;
}

body.light .manual-control-form select,
body.light .manual-control-form select option,
body.light select#manualMode,
body.light select#manualMode option {
  background-color: #ffffff !important;
  color: #111827 !important;
}

@media (max-width: 380px) {
  .manual-squelch {
    grid-template-columns: 1fr;
  }
}

/* KB2URI Manual Control three-button row patch */
.manual-action-row,
.manual-top-card .manual-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 7px;
}

.manual-action-row button {
  min-width: 0;
  white-space: nowrap;
  padding-left: 8px;
  padding-right: 8px;
}

.manual-action-row #manualApply {
  background: var(--accent, #2f6be6);
  color: var(--button-text, #ffffff);
}

.manual-control-form {
  margin-top: 0;
}

.manual-control-form button#manualApply {
  grid-column: auto;
}

@media (max-width: 700px) {
  .manual-action-row,
  .manual-top-card .manual-action-row {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .manual-action-row button {
    font-size: 12px;
    padding-left: 6px;
    padding-right: 6px;
  }
}

@media (max-width: 380px) {
  .manual-action-row,
  .manual-top-card .manual-action-row {
    grid-template-columns: 1fr;
  }
}

/* KB2URI Manual Tune move + map time filter patch */
.manual-tune-strip,
.moved-manual-tune {
  margin-top: 0;
}

.manual-tune-strip .section-title-row,
.moved-manual-tune .section-title-row {
  margin-bottom: 8px;
}

.manual-tune-strip .controls,
.manual-tune-strip .band-buttons,
.manual-tune-strip .tune-buttons,
.manual-tune-strip .preset-buttons,
.moved-manual-tune .controls,
.moved-manual-tune .band-buttons,
.moved-manual-tune .tune-buttons,
.moved-manual-tune .preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.manual-tune-strip button[data-tune],
.moved-manual-tune button[data-tune] {
  min-width: 74px;
  white-space: nowrap;
}

.map-time-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  justify-content: flex-end;
  margin-left: auto;
}

.map-time-filter button {
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
  background: color-mix(in srgb, var(--panel-soft) 76%, transparent);
  color: var(--text);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.map-time-filter button.active,
.map-time-filter button[aria-pressed="true"] {
  border-color: var(--accent, #69d1ff);
  background: var(--accent, #2f6be6);
  color: var(--button-text, #ffffff);
}

.map-time-filter button:focus-visible {
  outline: 2px solid var(--accent, #69d1ff);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .map-time-filter {
    justify-content: flex-start;
    width: 100%;
    margin-left: 0;
    margin-top: 6px;
  }
}

@media (max-width: 420px) {
  .manual-tune-strip button[data-tune],
  .moved-manual-tune button[data-tune] {
    min-width: 0;
    flex: 1 1 70px;
  }

  .map-time-filter button {
    flex: 1 1 54px;
  }
}

/* KB2URI map summary display v2 patch */
.map-summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  background: color-mix(in srgb, var(--panel-soft) 78%, transparent);
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .map-summary {
    margin-left: 0;
    margin-top: 6px;
    white-space: normal;
  }
}

/* KB2URI Recent Decode Map cleanup + default 1h patch */
.decode-map-clean-card {
  overflow: hidden;
}

.decode-map-clean-card .section-title-row,
.decode-map-clean-card .card-title-row,
.decode-map-clean-card > .section-title-row,
.decode-map-clean-card > .card-title-row {
  align-items: flex-start;
  gap: 10px;
}

.decode-map-clean-card h2,
.decode-map-clean-card h3 {
  margin-right: auto;
}

.decode-map-clean-card #mapTimeFilter {
  flex: 1 1 100%;
  order: 10;
  justify-content: flex-start;
  margin: 8px 0 0 0;
}

.decode-map-clean-card .map-time-filter {
  gap: 4px;
}

.decode-map-clean-card .map-time-filter button {
  min-height: 26px;
  padding: 4px 8px;
  font-size: 12px;
}

.decode-map-clean-card select {
  min-height: 34px;
}

.decode-map-clean-card button {
  white-space: nowrap;
}

.decode-map-clean-card .map-count-pill,
.decode-map-clean-card #mapCount,
.decode-map-clean-card .map-summary,
.decode-map-clean-card .map-summary-compact {
  font-size: 12px;
  line-height: 1.2;
}

.decode-map-clean-card #mapCount,
.decode-map-clean-card .map-count-pill {
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.decode-map-clean-card .map-summary,
.decode-map-clean-card .map-summary-compact {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 5px 10px;
  opacity: 0.95;
}

.decode-map-clean-card p,
.decode-map-clean-card .help,
.decode-map-clean-card .small {
  line-height: 1.35;
}

@media (min-width: 1000px) {
  .decode-map-clean-card #mapTimeFilter {
    flex: 0 1 auto;
    order: 0;
    margin-top: 0;
  }

  .decode-map-clean-card .map-summary,
  .decode-map-clean-card .map-summary-compact {
    max-width: 420px;
  }
}

@media (max-width: 900px) {
  .decode-map-clean-card .section-title-row,
  .decode-map-clean-card .card-title-row {
    flex-direction: column;
    align-items: stretch;
  }

  .decode-map-clean-card #mapTimeFilter,
  .decode-map-clean-card .map-time-filter {
    width: 100%;
  }

  .decode-map-clean-card .map-time-filter button {
    flex: 1 1 48px;
  }

  .decode-map-clean-card .map-summary,
  .decode-map-clean-card .map-summary-compact {
    max-width: none;
    white-space: normal;
    margin-left: 0;
  }
}
/* KB2URI consolidated frontend controls v7 patch */
.kb2uri-utility-container-right,
[data-kb2uri-utility-container="1"] {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.kb2uri-ft8-preset {
  order: 10;
  font-size: 12px;
  min-width: 78px;
}

.kb2uri-utility-preset-row,
.kb2uri-utility-preset-row-right,
#kb2uriUtilityPresetRow {
  order: 999;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  margin-left: auto;
  margin-right: 0;
  padding-left: 10px;
  padding-right: 0;
  border-left: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-right: 0;
}

.kb2uri-utility-preset {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.map-decode-filter-toggle {
  white-space: nowrap;
}

.map-decode-filter-toggle.active {
  font-weight: 700;
}

@media (max-width: 720px) {
  .kb2uri-utility-preset-row,
  .kb2uri-utility-preset-row-right,
  #kb2uriUtilityPresetRow {
    width: 100%;
    margin-left: 0;
    padding-left: 0;
    padding-top: 7px;
    border-left: 0;
    border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  }

  .kb2uri-utility-preset-row button,
  .kb2uri-utility-preset-row-right button,
  #kb2uriUtilityPresetRow button {
    flex: 1 1 78px;
  }
}
