* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #1a1d23;
  color: #d4d4d8;
  min-height: 100vh;
}

header {
  background: #12151a;
  border-bottom: 1px solid #2a2d35;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

h1 {
  font-size: 18px;
  font-weight: 600;
  color: #e4e4e7;
  letter-spacing: 0.5px;
}

.status-bar {
  display: flex;
  gap: 16px;
  font-size: 13px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #a1a1aa;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #52525b;
  transition: background 0.3s;
  display: inline-block;
}

.dot.connected {
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e80;
}

.dot.disconnected {
  background: #ef4444;
  box-shadow: 0 0 6px #ef444480;
}

main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto 1fr;
  grid-template-areas:
    "audio audio"
    "radio radio"
    "events alarms";
  gap: 12px;
  padding: 12px;
  height: calc(100vh - 56px);
}

.panel {
  background: #12151a;
  border: 1px solid #2a2d35;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;   /* allow the panel to shrink so its .scrollable content can scroll */
}

#panel-radio {
  grid-area: radio;
  overflow: visible;
}

#panel-events { grid-area: events; }
#panel-alarms { grid-area: alarms; }

.panel h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #71717a;
  padding: 10px 14px;
  border-bottom: 1px solid #2a2d35;
  flex-shrink: 0;
}

.panel-content {
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.6;
  flex: 1;
  overflow: hidden;
}

.panel-content.scrollable {
  overflow-y: auto;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.5;
}

/* Debug toggle */
.debug-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.debug-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #60a5fa;
  cursor: pointer;
}

.debug-toggle-label {
  font-size: 11px;
  color: #71717a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.debug-toggle:hover .debug-toggle-label {
  color: #a1a1aa;
}

/* When debug is off, hide technical events */
.event-line.debug-hidden {
  display: none !important;
}

/* ========================================================================
   Radio Cards Grid (LARDIS-DESK style)
   ======================================================================== */

.radio-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

@media (max-width: 1200px) {
  .radio-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .radio-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.radio-card {
  background: #1e2128;
  border: 1px solid #2a2d35;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Colored header bar */
.radio-card .card-header {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.radio-card .card-header .radio-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.radio-card .card-header .conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #52525b;
  flex-shrink: 0;
  transition: background 0.3s;
}

.radio-card .card-header .conn-dot.connected {
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e80;
}

.radio-card .card-header .conn-dot.disconnected {
  background: #ef4444;
  box-shadow: 0 0 6px #ef444480;
}

/* Card header colors are assigned dynamically per radio id in app.js (colorForRadio). */

/* Card body */
.radio-card .card-body {
  padding: 10px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.radio-card .card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.radio-card .card-label {
  color: #71717a;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}

.radio-card .card-value {
  color: #e4e4e7;
  font-size: 13px;
  font-weight: 500;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.radio-card .card-value.muted {
  color: #52525b;
  font-style: italic;
  font-weight: 400;
}

/* Signal bars */
.signal-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
}

.signal-bars .bar {
  width: 4px;
  background: #3f3f46;
  border-radius: 1px;
}

.signal-bars .bar:nth-child(1) { height: 4px; }
.signal-bars .bar:nth-child(2) { height: 7px; }
.signal-bars .bar:nth-child(3) { height: 10px; }
.signal-bars .bar:nth-child(4) { height: 13px; }
.signal-bars .bar:nth-child(5) { height: 16px; }

.signal-bars .bar.active { background: #22c55e; }
.signal-bars .bar.active.weak { background: #ef4444; }
.signal-bars .bar.active.medium { background: #f59e0b; }
.signal-bars .bar.active.strong { background: #22c55e; }

/* Call activity */
.call-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}

.call-indicator.idle { color: #52525b; }
.call-indicator.active {
  color: #22c55e;
}

.call-indicator .pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
  animation: pulse-glow 1.2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px #22c55e80; }
  50% { opacity: 0.4; box-shadow: 0 0 10px #22c55ecc; }
}

.call-indicator .call-caller {
  color: #e4e4e7;
  font-weight: 500;
}

.call-indicator .call-type-label {
  color: #86efac;
  font-size: 10px;
  font-weight: 400;
}

/* State indicator (receiving / transmitting) */
.state-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
}

.state-indicator.receiving {
  color: #60a5fa;
}

.state-indicator.receiving .state-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #60a5fa;
  display: inline-block;
  animation: pulse-glow-blue 1s ease-in-out infinite;
}

@keyframes pulse-glow-blue {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px #60a5fa80; }
  50% { opacity: 0.3; box-shadow: 0 0 10px #60a5facc; }
}

.state-indicator.transmitting {
  color: #f87171;
}

.state-indicator.transmitting .state-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f87171;
  display: inline-block;
  animation: pulse-glow-red 0.8s ease-in-out infinite;
}

@keyframes pulse-glow-red {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px #f8717180; }
  50% { opacity: 0.3; box-shadow: 0 0 10px #f87171cc; }
}

.state-indicator.idle-state {
  color: #52525b;
}

@keyframes call-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Mode badge */
.mode-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

.mode-badge.tmo {
  background: #1e3a5f;
  color: #60a5fa;
}

.mode-badge.dmo {
  background: #3b1f2b;
  color: #f472b6;
}

.mode-badge.analog-mode {
  background: #4a3b1e;
  color: #fbbf24;
}

.mode-badge.none {
  background: #27272a;
  color: #52525b;
}

/* ========================================================================
   Event lines
   ======================================================================== */

.event-line {
  padding: 3px 0;
  border-bottom: 1px solid #1e2128;
  display: flex;
  gap: 10px;
}

.event-line .ts {
  color: #52525b;
  flex-shrink: 0;
  min-width: 80px;
}

.event-line .source-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* source-tag colors are assigned dynamically per source in app.js (colorForRadio). */

.event-line .msg {
  color: #d4d4d8;
  word-break: break-all;
}

/* Alarm feed */
.alarm-line {
  display: flex;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #1e2128;
  align-items: flex-start;
  font-size: 12px;
}

.alarm-line .ts {
  color: #71717a;
  flex-shrink: 0;
  font-size: 11px;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

.alarm-line .msg {
  color: #d4d4d8;
  word-break: break-word;
  flex: 1;
}

.alarm-parsed {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.alarm-type-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.alarm-type-tag.zvei-tag {
  background: #422006;
  color: #facc15;
}

.alarm-type-tag.callout-tag {
  background: #431407;
  color: #fb923c;
}

.alarm-body {
  color: #e4e4e7;
  line-height: 1.5;
}

.alarm-code {
  color: #a1a1aa;
  font-size: 11px;
}

.alarm-line .source-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.alarm-line.hidden {
  display: none;
}

/* Scrollbar */
.scrollable::-webkit-scrollbar {
  width: 6px;
}
.scrollable::-webkit-scrollbar-track {
  background: transparent;
}
.scrollable::-webkit-scrollbar-thumb {
  background: #3f3f46;
  border-radius: 3px;
}
.scrollable::-webkit-scrollbar-thumb:hover {
  background: #52525b;
}

/* ========================================================================
   Filter input
   ======================================================================== */

.panel-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 0;
  border-bottom: 1px solid #2a2d35;
  flex-shrink: 0;
  gap: 10px;
}

.panel-header-bar h2 {
  border-bottom: none;
  flex-shrink: 0;
}

.filter-input {
  background: #1a1d23;
  border: 1px solid #3f3f46;
  border-radius: 4px;
  color: #d4d4d8;
  font-size: 12px;
  padding: 4px 8px;
  width: 180px;
  outline: none;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

.filter-input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 1px #60a5fa40;
}

.filter-input::placeholder {
  color: #52525b;
}

/* ========================================================================
   Event type color coding
   ======================================================================== */

.event-line.evt-call {
  border-left: 3px solid #22c55e;
  padding-left: 8px;
}

.event-line.evt-call .msg {
  color: #86efac;
}

.event-line.evt-state {
  border-left: 3px solid #60a5fa;
  padding-left: 8px;
}

.event-line.evt-state .msg {
  color: #93c5fd;
}

.event-line.evt-error {
  border-left: 3px solid #ef4444;
  padding-left: 8px;
}

.event-line.evt-error .msg {
  color: #fca5a5;
}

.event-line.evt-fms32 {
  border-left: 3px solid #eab308;
  padding-left: 8px;
}

.event-line.evt-fms32 .msg {
  color: #fde68a;
}

.event-line.evt-history {
  border-left: 3px solid #f97316;
  padding-left: 8px;
}

.event-line.evt-history .msg {
  color: #fdba74;
}

/* History alarm card inline */
.history-detail {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 12px;
  line-height: 1.5;
}

.history-detail .alarm-text {
  color: #fbbf24;
  font-weight: 600;
}

.history-detail .alarm-meta {
  color: #a1a1aa;
  font-size: 11px;
}

.history-detail .alarm-tg {
  color: #fdba74;
}

/* Source tags in alarm feed reuse event source colors */
/* alarm-line source-tag colors are assigned dynamically in app.js (colorForRadio). */

.event-line.hidden {
  display: none;
}

.placeholder {
  color: #52525b;
  font-style: italic;
}

/* ========================================================================
   Audio Controls
   ======================================================================== */

.audio-controls {
  grid-area: audio;
  background: #12151a;
  border: 1px solid #2a2d35;
  border-radius: 6px;
  padding: 8px 14px;
}

.audio-controls-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.audio-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.audio-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #52525b;
}

.audio-indicator.active {
  color: #22c55e;
}

.audio-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3f3f46;
  display: inline-block;
  transition: background 0.3s;
}

.audio-indicator.active .audio-icon {
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e80;
  animation: pulse-glow 1.2s ease-in-out infinite;
}

/* Volume controls */
.audio-volume {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.audio-mute-btn {
  background: none;
  border: 1px solid #3f3f46;
  border-radius: 4px;
  color: #a1a1aa;
  cursor: pointer;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.audio-mute-btn:hover {
  background: #27272a;
  border-color: #52525b;
  color: #d4d4d8;
}

.audio-mute-btn.muted {
  background: #451a1a;
  border-color: #7f1d1d;
  color: #ef4444;
}

.audio-mute-btn.muted .audio-wave-1,
.audio-mute-btn.muted .audio-wave-2 {
  display: none;
}

.audio-volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 4px;
  background: #3f3f46;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.audio-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: #60a5fa;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
}

.audio-volume-slider::-webkit-slider-thumb:hover {
  background: #93c5fd;
}

.audio-volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #60a5fa;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.audio-volume-label {
  font-size: 11px;
  color: #71717a;
  min-width: 32px;
  text-align: right;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

/* Audio level meter */
.audio-meter-container {
  flex: 1;
  min-width: 80px;
  max-width: 200px;
}

.audio-meter {
  height: 6px;
  background: #27272a;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid #3f3f46;
}

.audio-meter-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e 0%, #22c55e 60%, #f59e0b 80%, #ef4444 100%);
  border-radius: 3px;
  transition: width 0.05s linear;
}

.audio-radio-label {
  font-size: 11px;
  color: #71717a;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}

/* Per-radio mute toggles in radio cards */
.radio-audio-mute {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 11px;
  color: #a1a1aa;
  background: none;
  border: 1px solid #3f3f46;
  border-radius: 3px;
  padding: 2px 6px;
  transition: all 0.2s;
}

.radio-audio-mute:hover {
  background: #27272a;
  border-color: #52525b;
}

.radio-audio-mute.muted {
  background: #451a1a;
  border-color: #7f1d1d;
  color: #ef4444;
}

/* ========================================================================
   Talkgroup Selector
   ======================================================================== */

/* Clickable talkgroup in radio card */
.tg-clickable {
  cursor: pointer !important;
  transition: color 0.15s;
}

.tg-clickable:hover {
  color: #60a5fa !important;
  text-decoration: underline;
}

.tg-change-icon {
  font-size: 9px;
  color: #52525b;
  margin-left: 4px;
  transition: color 0.15s;
}

.tg-clickable:hover .tg-change-icon {
  color: #60a5fa;
}

/* Modal overlay */
.tg-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.tg-modal-overlay.open {
  display: flex;
}

/* Modal box */
.tg-modal {
  background: #1a1d23;
  border: 1px solid #2a2d35;
  border-radius: 8px;
  width: 420px;
  max-width: 90vw;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  animation: tg-modal-in 0.15s ease-out;
}

@keyframes tg-modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.tg-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #2a2d35;
  flex-shrink: 0;
}

.tg-modal-title {
  font-size: 14px;
  font-weight: 700;
  color: #e4e4e7;
  letter-spacing: 0.3px;
}

.tg-modal-radio-name {
  font-size: 11px;
  font-weight: 600;
  color: #60a5fa;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.tg-modal-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #71717a;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}

.tg-modal-close:hover {
  color: #e4e4e7;
}

/* Search input */
.tg-modal-search {
  padding: 10px 16px 6px;
  flex-shrink: 0;
}

.tg-search-input {
  width: 100%;
  background: #12151a;
  border: 1px solid #3f3f46;
  border-radius: 4px;
  color: #d4d4d8;
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.tg-search-input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 1px #60a5fa40;
}

.tg-search-input::placeholder {
  color: #52525b;
}

/* Current talkgroup display */
.tg-modal-current {
  padding: 8px 16px;
  font-size: 12px;
  color: #a1a1aa;
  border-bottom: 1px solid #2a2d35;
  flex-shrink: 0;
}

.tg-current-label {
  color: #71717a;
}

.tg-modal-current strong {
  color: #e4e4e7;
}

.tg-current-number {
  color: #71717a;
  font-size: 11px;
  margin-left: 6px;
}

/* Talkgroup list */
.tg-modal-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.tg-modal-list::-webkit-scrollbar {
  width: 6px;
}

.tg-modal-list::-webkit-scrollbar-track {
  background: transparent;
}

.tg-modal-list::-webkit-scrollbar-thumb {
  background: #3f3f46;
  border-radius: 3px;
}

.tg-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.1s;
  gap: 10px;
}

.tg-item:hover {
  background: #27272a;
}

.tg-item.active {
  background: #1e3a5f;
  border-left: 3px solid #60a5fa;
  padding-left: 13px;
}

.tg-item-name {
  font-size: 13px;
  font-weight: 500;
  color: #e4e4e7;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tg-item.active .tg-item-name {
  color: #93c5fd;
}

.tg-item-meta {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  align-items: center;
}

.tg-item-number {
  font-size: 11px;
  color: #71717a;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

.tg-item-gssi {
  font-size: 10px;
  color: #52525b;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  min-width: 60px;
  text-align: right;
}

.tg-empty {
  padding: 20px 16px;
  text-align: center;
  color: #52525b;
  font-size: 13px;
  font-style: italic;
}

/* ========================================================================
   Talkgroup Selector — Sections (Favorites + Folders)
   ======================================================================== */

.tg-section {
}

/* Only top-level folder sections get a bottom border */
#tg-modal-list > .tg-section {
  border-bottom: 1px solid #2a2d35;
}

#tg-modal-list > .tg-section:last-child {
  border-bottom: none;
}

/* Section header (shared) */
.tg-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: default;
  user-select: none;
}

.tg-section-count {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  color: #52525b;
  background: #27272a;
  padding: 1px 6px;
  border-radius: 8px;
}

/* Favorites section */
.tg-section-favorites {
  border-left: 3px solid #d4a017;
}

.tg-favorites-header {
  background: #2a2210;
  color: #fbbf24;
}

.tg-star-icon {
  color: #fbbf24;
  font-size: 14px;
}

.tg-item-fav .tg-item-star {
  color: #d4a017;
  font-size: 12px;
  flex-shrink: 0;
  margin-right: 4px;
}

/* Folder section */
.tg-folder-header {
  background: #1e2128;
  color: #a1a1aa;
  cursor: pointer !important;
  transition: background 0.1s;
}

.tg-folder-header:hover {
  background: #27272a;
  color: #d4d4d8;
}

.tg-folder-chevron {
  font-size: 9px;
  color: #71717a;
  width: 12px;
  text-align: center;
  flex-shrink: 0;
}

/* Items use dynamic padding-left via inline style for hierarchy indentation */

/* ========================================================================
   Audio unlock overlay
   ======================================================================== */
.audio-unlock-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.audio-unlock-overlay.hidden {
  display: none;
}

.audio-unlock-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #d4d4d8;
  font-size: 16px;
  font-weight: 600;
  padding: 32px 48px;
  background: #1e2128;
  border: 1px solid #3f3f46;
  border-radius: 12px;
}

.audio-unlock-box svg {
  color: #60a5fa;
}

/* --- Auth / user menu / admin (RBAC) --- */
.user-menu { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.user-name { color: #d4d4d8; font-size: 13px; }
.user-menu-btn { background: #27272a; border: 1px solid #3f3f46; color: #d4d4d8; border-radius: 4px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.user-menu-btn:hover { background: #3f3f46; }

.auth-modal { width: 360px; }
.auth-body { padding: 16px; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-btn { background: #2563eb; border: none; color: #fff; border-radius: 4px; padding: 9px 14px; cursor: pointer; font-size: 14px; font-weight: 600; }
.auth-btn:hover { background: #1d4ed8; }
.auth-error { color: #f87171; font-size: 12px; min-height: 14px; }

.admin-modal { width: 760px; max-width: 95vw; max-height: 85vh; display: flex; flex-direction: column; }
.admin-tabs { display: flex; gap: 4px; padding: 8px 12px 0; border-bottom: 1px solid #27272a; }
.admin-tab { background: transparent; border: none; color: #a1a1aa; padding: 8px 14px; cursor: pointer; border-bottom: 2px solid transparent; }
.admin-tab.active { color: #fff; border-bottom-color: #2563eb; }
.admin-content { padding: 14px; overflow: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #27272a; vertical-align: top; }
.rolechk { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; font-size: 12px; color: #d4d4d8; }
.mini-btn { background: #27272a; border: 1px solid #3f3f46; color: #d4d4d8; border-radius: 3px; padding: 2px 8px; cursor: pointer; font-size: 11px; }
.mini-btn.danger { color: #f87171; border-color: #7f1d1d; }
.admin-form-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.role-edit { border: 1px solid #27272a; border-radius: 6px; padding: 10px; margin-bottom: 12px; }
.role-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.matrix { width: 100%; border-collapse: collapse; font-size: 12px; margin: 8px 0; }
.matrix th, .matrix td { padding: 4px 6px; border-bottom: 1px solid #27272a; text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.admin-loading { color: #a1a1aa; padding: 20px; }
.admin-content h4 { margin: 14px 0 4px; color: #d4d4d8; font-size: 13px; }

/* --- OIDC login button --- */
.oidc-btn { display: block; text-align: center; text-decoration: none; background: #3b3f8f; }
.oidc-btn:hover { background: #323573; }
.auth-sep { text-align: center; color: #71717a; font-size: 12px; margin: 4px 0; position: relative; }

/* --- Kiosk admin --- */
.kiosk-presets { font-size: 12px; color: #a1a1aa; margin: 6px 0; }
.kiosk-features { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 6px 0; }
body.kiosk { background: #000; }

/* OIDC/SSO admin tab */
.oidc-settings { display: flex; flex-direction: column; gap: 10px; max-width: 640px; }
.oidc-status { font-weight: 600; }
.oidc-ok { color: #3ddc84; }
.oidc-off { color: #888; }
.oidc-err-text { color: #ff6b6b; font-weight: 400; font-size: 0.85em; }
.oidc-hint { font-size: 0.82em; color: #9aa0a6; margin: 0; }
.oidc-hint code { background: rgba(255,255,255,0.08); padding: 1px 5px; border-radius: 3px; }
.oidc-field { display: flex; flex-direction: column; gap: 3px; }
.oidc-label { font-size: 0.85em; color: #c7ccd1; display: flex; align-items: center; gap: 6px; }
.oidc-input { width: 100%; }
.oidc-env-badge { background: #5b4a1f; color: #ffd479; font-size: 0.68em; font-weight: 700; padding: 1px 5px; border-radius: 3px; letter-spacing: 0.04em; }
.oidc-map .oidc-map-group, .oidc-map .oidc-map-role { width: 100%; }
.oidc-enable { font-weight: 600; }
.oidc-input.oidc-ro { opacity: 0.7; cursor: not-allowed; background: rgba(255,255,255,0.04); }

/* PWA update toast */
.pwa-toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1e2128;
  color: #e4e4e7;
  border: 1px solid #3f3f46;
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  font-size: 0.9rem;
  max-width: calc(100vw - 32px);
}
.pwa-toast-btn {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 600;
}
.pwa-toast-btn:hover { background: #1d4ed8; }

/* Push notification dialog */
.nf-device { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.nf-radio { border: 1px solid #2a2e37; border-radius: 6px; padding: 8px 10px; margin: 6px 0; }
.nf-radio-name { font-weight: 600; margin-bottom: 4px; }
.nf-radio .rolechk { display: inline-flex; margin-right: 14px; }
.nf-kind { font-size: 0.7em; font-weight: 400; color: #9aa0a6; background: rgba(255,255,255,0.06); padding: 1px 6px; border-radius: 3px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ========================================================================
   Responsive — works across phones, tablets and desktop
   ======================================================================== */

/* Tablets (portrait) & phones: stack everything into one scrolling column so
   the Ereignisse/Alarme panels are always reachable (the desktop grid keeps
   them side-by-side in the filling 1fr row). */
@media (max-width: 860px) {
  main {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 56px);
    gap: 10px;
    padding: 10px;
  }
  /* Bounded, internally-scrolling feeds; the page scrolls between panels. */
  #panel-events .panel-content.scrollable,
  #panel-alarms .panel-content.scrollable {
    max-height: 45vh;
  }
}

/* Phones: tighten the header, single-column radio cards, full-width filters. */
@media (max-width: 560px) {
  header { padding: 10px 12px; }
  h1 { font-size: 16px; }
  .status-bar { gap: 12px; font-size: 12px; flex-wrap: wrap; }
  main { padding: 8px; gap: 8px; }
  .radio-grid { grid-template-columns: 1fr; }
  .panel h2 { padding: 9px 12px; }
  .panel-content { padding: 9px 12px; }

  .panel-header-bar { flex-wrap: wrap; gap: 6px; }
  .filter-input { width: 100%; flex: 1 1 100px; }

  .audio-controls-inner { gap: 10px; }
  .audio-volume-slider { width: 90px; }

  /* Header user menu wraps instead of overflowing. */
  .user-menu { flex-wrap: wrap; gap: 6px; }

  /* Modals use almost the whole screen on phones. */
  .tg-modal, .admin-modal { width: 96vw; max-width: 96vw; max-height: 88vh; }
  .admin-tabs { flex-wrap: wrap; }
  .admin-table { font-size: 12px; }
  .nf-radio .rolechk { display: flex; margin-right: 0; }
}

/* Coarse-pointer (touch) tweaks: comfortable tap targets regardless of width. */
@media (pointer: coarse) {
  .user-menu-btn, .mini-btn, .auth-btn, .pwa-toast-btn { min-height: 36px; }
  .filter-input { min-height: 36px; }
}
