:root, [data-theme="dark"] {
  --bg-main: #0b1120;
  --bg-card: #1e293b;
  --bg-card-hover: #243247;
  --bg-subtle: #0f172a;
  --border-main: #334155;
  --border-light: #475569;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0b1120;

  --accent-cyan: #38bdf8;
  --accent-cyan-hover: #0ea5e9;
  --accent-emerald: #10b981;
  --accent-emerald-light: #34d399;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-red: #ef4444;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;

  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-subtle: #e2e8f0;
  --border-main: #cbd5e1;
  --border-light: #94a3b8;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --accent-cyan: #0284c7;
  --accent-cyan-hover: #0369a1;
  --accent-emerald: #059669;
  --accent-emerald-light: #10b981;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;
  --accent-red: #dc2626;

  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.05);
}

[data-theme="oled"] {
  --bg-main: #000000;
  --bg-card: #111111;
  --bg-card-hover: #1c1c1c;
  --bg-subtle: #080808;
  --border-main: #262626;
  --border-light: #404040;

  --text-primary: #ffffff;
  --text-secondary: #a3a3a3;
  --text-muted: #737373;
  --text-inverse: #000000;

  --accent-cyan: #38bdf8;
  --accent-cyan-hover: #0ea5e9;
  --accent-emerald: #10b981;
  --accent-emerald-light: #34d399;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-red: #ef4444;
}

[data-theme="teal"] {
  --bg-main: #041b1d;
  --bg-card: #082f32;
  --bg-card-hover: #0e3f43;
  --bg-subtle: #031415;
  --border-main: #134e4a;
  --border-light: #2dd4bf;

  --text-primary: #f0fdfa;
  --text-secondary: #99f6e4;
  --text-muted: #5eead4;
  --text-inverse: #041b1d;

  --accent-cyan: #2dd4bf;
  --accent-cyan-hover: #14b8a6;
  --accent-emerald: #10b981;
  --accent-emerald-light: #34d399;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-red: #ef4444;
}

[data-theme="nord"] {
  --bg-main: #242933;
  --bg-card: #2e3440;
  --bg-card-hover: #3b4252;
  --bg-subtle: #1e222a;
  --border-main: #434c5e;
  --border-light: #4c566a;

  --text-primary: #eceff4;
  --text-secondary: #d8dee9;
  --text-muted: #88c0d0;
  --text-inverse: #242933;

  --accent-cyan: #88c0d0;
  --accent-cyan-hover: #81a1c1;
  --accent-emerald: #a3be8c;
  --accent-emerald-light: #a3be8c;
  --accent-amber: #ebcb8b;
  --accent-rose: #bf616a;
  --accent-red: #bf616a;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* App Shell */
.app-shell {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-main);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.device-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-card);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-main);
}

.device-selector-wrapper select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.device-selector-wrapper select option {
  background-color: var(--bg-card);
  color: var(--text-primary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.status-dot.connected {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.status-dot.error {
  background-color: var(--accent-rose);
  box-shadow: 0 0 8px rgba(244, 63, 94, 0.6);
}

.status-dot.recording {
  background-color: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-selector-wrapper {
  display: flex;
  align-items: center;
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
}

.theme-selector-wrapper select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.theme-selector-wrapper select option {
  background-color: var(--bg-card);
  color: var(--text-primary);
}

.poll-control {
  display: flex;
  align-items: center;
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  display: inline-block;
  margin-right: 6px;
}

.live-dot.pulse {
  animation: pulse-animation 1.5s infinite;
}

.live-dot.paused {
  background-color: var(--text-muted);
  animation: none;
}

@keyframes pulse-animation {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 6px var(--accent-emerald); }
  100% { transform: scale(0.95); opacity: 0.7; }
}

.poll-control select {
  background: transparent;
  border: none;
  border-left: 1px solid var(--border-main);
  color: var(--text-secondary);
  font-size: 0.8rem;
  padding: 6px 8px;
  outline: none;
  cursor: pointer;
}

.poll-control select option {
  background-color: var(--bg-card);
}

/* Nav Tabs */
.nav-tabs {
  display: flex;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-main);
  padding: 0 16px;
  gap: 8px;
  overflow-x: auto;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text-primary);
}

.nav-tab.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
}

.tab-badge {
  font-size: 0.7rem;
  background-color: var(--border-main);
  color: var(--text-primary);
  padding: 1px 6px;
  border-radius: 9999px;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 24px 20px;
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.view-header h2 {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.view-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Alert Banner */
.alert-banner {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.alert-banner.error {
  background-color: rgba(244, 63, 94, 0.15);
  border: 1px solid var(--accent-rose);
  color: #fecdd3;
}

.alert-banner.info {
  background-color: rgba(56, 189, 248, 0.15);
  border: 1px solid var(--accent-cyan);
  color: #bae6fd;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.btn-icon {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
}

.btn-icon:hover {
  color: var(--text-primary);
}

.btn-primary {
  background-color: var(--accent-cyan);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background-color: var(--accent-cyan-hover);
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-main);
}

.btn-secondary:hover {
  background-color: var(--border-main);
}

.btn-install {
  background-color: var(--accent-emerald);
  color: var(--text-inverse);
}

.btn-danger {
  background-color: #ef4444;
  color: #ffffff;
  border: none;
}

.btn-danger:hover {
  background-color: #dc2626;
}

.btn-delete {
  background-color: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
  font-weight: 600;
  cursor: pointer;
  opacity: 1 !important;
}

.btn-delete:hover {
  background-color: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

[data-theme="light"] .btn-delete {
  background-color: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
}

[data-theme="light"] .btn-delete:hover {
  background-color: #dc2626;
  color: #ffffff;
  border-color: #dc2626;
}

.badge {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 9999px;
  background-color: var(--border-main);
  color: var(--text-secondary);
  font-weight: 500;
}

/* Cards */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  padding: 20px;
}

.card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 12px;
}

/* Tuners Grid */
.tuners-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.tuner-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  transition: border-color 0.2s ease;
}

.tuner-card.active {
  border-color: var(--accent-cyan);
  background-color: var(--bg-card-hover);
}

.tuner-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tuner-name {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tuner-status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 9999px;
  text-transform: uppercase;
}

.tuner-status-badge.idle {
  background-color: rgba(148, 163, 184, 0.15);
  color: var(--text-secondary);
}

.tuner-status-badge.streaming {
  background-color: rgba(56, 189, 248, 0.2);
  color: var(--accent-cyan);
}

.tuner-status-badge.recording {
  background-color: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.tuner-status-badge.recording-streaming {
  background-color: rgba(245, 158, 11, 0.2);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.tuner-active-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-color: var(--bg-subtle);
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-main);
}

.tuner-channel-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tuner-channel-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.tuner-channel-badge-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin-left: 4px;
}

.tuner-channel-num-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tuner-channel-number {
  font-size: 0.95rem;
  font-family: monospace;
  color: var(--accent-cyan);
}

.tuner-channel-rf {
  font-size: 0.72rem;
  font-family: monospace;
  color: var(--text-muted);
  line-height: 1.2;
}

.tuner-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.tuner-shared-clients {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shared-clients-label {
  font-size: 0.75rem;
  color: var(--accent-cyan);
  font-weight: 600;
}

.shared-clients-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.client-badge {
  font-size: 0.72rem;
  font-family: monospace;
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-primary);
}

/* Metric Bars */
.metric-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metric-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label-group {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.metric-value {
  font-weight: 600;
  font-family: monospace;
}

.metric-bar-bg {
  height: 6px;
  background-color: var(--bg-subtle);
  border-radius: 9999px;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.3s ease, background-color 0.3s ease;
}

.metric-bar-fill.good {
  background-color: var(--accent-emerald-light);
}

.metric-bar-fill.fair {
  background-color: var(--accent-amber);
}

.metric-bar-fill.poor {
  background-color: var(--accent-rose);
}

.tuner-idle-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

/* Lineup View */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-bar input[type="text"] {
  flex: 1;
  min-width: 240px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 0.9rem;
}

.filter-bar input[type="text"]:focus {
  outline: 2px solid var(--accent-cyan);
  border-color: transparent;
}

.filter-pills {
  display: flex;
  gap: 6px;
}

.pill {
  padding: 6px 12px;
  border-radius: 9999px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill:hover {
  color: var(--text-primary);
}

.pill.active {
  background-color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  color: var(--text-inverse);
  font-weight: 600;
}

/* Filter Dropdown & Active Chips */
.filter-dropdown-container {
  position: relative;
}

.filter-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.filter-toggle-btn.has-filters {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.filter-count-badge {
  background-color: var(--accent-cyan);
  color: var(--text-inverse);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
}

.dropdown-caret {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

.filter-toggle-btn[aria-expanded="true"] .dropdown-caret {
  transform: rotate(180deg);
}

.filter-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 290px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  padding: 14px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.filter-dropdown-menu.hidden {
  display: none !important;
}

.filter-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-main);
}

.filter-menu-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.btn-text-action {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
  font-weight: 500;
}

.btn-text-action:hover {
  text-decoration: underline;
}

.filter-menu-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-menu-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-menu-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-menu-select {
  width: 100%;
  padding: 7px 10px;
  background-color: var(--bg-main);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
}

.filter-menu-select:focus {
  outline: 2px solid var(--accent-cyan);
  border-color: transparent;
}

.filter-menu-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--border-main);
}

.active-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: -6px;
  margin-bottom: 14px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 10px;
  border-radius: 9999px;
  background-color: var(--bg-card);
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  font-size: 0.78rem;
  font-weight: 500;
}

.filter-chip-remove {
  background: none;
  border: none;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  opacity: 0.75;
}

.filter-chip-remove:hover {
  opacity: 1;
}

.filter-chip-clear-all {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
  margin-left: 4px;
}

.filter-chip-clear-all:hover {
  color: var(--accent-cyan);
}

.lineup-table-wrapper {
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.lineup-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.lineup-table th {
  background-color: var(--bg-subtle);
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-main);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lineup-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-main);
  vertical-align: middle;
}

.lineup-table tr:hover td {
  background-color: var(--bg-card-hover);
}

.channel-num-cell {
  font-family: monospace;
  font-weight: 700;
  color: var(--accent-cyan);
  white-space: nowrap;
}

.channel-name-cell {
  font-weight: 600;
}

.badge-hd {
  background-color: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.badge-favorite {
  background-color: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-disabled {
  background-color: rgba(244, 63, 94, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.lineup-row-disabled td {
  opacity: 0.5;
}

.badge-atsc3 {
  background-color: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
  font-weight: 600;
}

.badge-drm {
  background-color: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
  font-weight: 600;
}

.badge-uhf {
  background-color: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.4);
  font-weight: 600;
}

.badge-vhf {
  background-color: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.4);
  font-weight: 600;
}

[data-theme="light"] .badge-uhf {
  background-color: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.3);
}

[data-theme="light"] .badge-vhf {
  background-color: rgba(16, 185, 129, 0.12);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.3);
}

.channel-rf-sub {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
}

.detail-channel-band {
  display: inline-flex;
  align-items: center;
}

.signal-meter-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: help;
}

.signal-mini-val {
  font-size: 0.8rem;
  font-family: monospace;
  color: var(--text-primary);
  font-weight: 500;
}

.signal-mini-bar {
  width: 56px;
  height: 8px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-main);
  border-radius: 9999px;
  overflow: hidden;
  flex-shrink: 0;
}

.signal-mini-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.3s ease;
}

.signal-mini-fill.good {
  background-color: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.signal-mini-fill.fair {
  background-color: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}

.signal-mini-fill.poor {
  background-color: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

.btn-drm-locked {
  opacity: 0.6;
  cursor: not-allowed !important;
  background-color: var(--border-main) !important;
  color: var(--text-muted) !important;
}

.table-actions {
  display: flex;
  gap: 6px;
}

/* Channel Signal Notice Card */
.channel-signal-notice {
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  border-left: 4px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  padding: 14px 18px;
}

.signal-notice-content {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.signal-notice-icon {
  font-size: 1.3rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.signal-notice-body {
  flex: 1;
}

.signal-notice-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.signal-notice-text {
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0;
}

.signal-notice-subtext {
  color: var(--text-muted);
  line-height: 1.4;
  margin: 6px 0 0 0;
}

.live-dot-mini {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 4px #10b981;
  margin-left: 2px;
  flex-shrink: 0;
  display: inline-block;
}

/* Recordings View */
.storage-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge-pill {
  font-size: 0.72rem;
  background-color: rgba(255, 255, 255, 0.12);
  padding: 1px 6px;
  border-radius: 9999px;
  margin-left: 4px;
}

.pill.active .badge-pill {
  background-color: rgba(15, 23, 42, 0.3);
}

.recordings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.recording-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: border-color 0.2s ease;
}

.recording-card:hover {
  border-color: var(--border-light);
}

.recording-top {
  display: flex;
  gap: 14px;
}

.recording-poster {
  width: 72px;
  height: 104px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-main);
  flex-shrink: 0;
}

.recording-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 4px;
}

.recording-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}

.recording-episode {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

.recording-synopsis {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 4px;
  line-height: 1.35;
}

.recording-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.recording-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.channel-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  color: var(--text-secondary);
}

.channel-logo-img {
  height: 14px;
  width: auto;
  vertical-align: middle;
}

.recording-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.btn-delete-series {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
}

/* Scheduled Rules */
.rule-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rule-priority-badge {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}

.empty-card {
  text-align: center;
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon {
  font-size: 2.5rem;
}

/* System & Settings View */
.system-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.info-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-main);
  padding: 8px 0;
}

.info-label {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.info-val {
  font-weight: 600;
  word-break: break-all;
  text-align: right;
}

.info-val-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-xs {
  padding: 2px 8px;
  font-size: 0.75rem;
}

.badge-up-to-date {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald-light);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-update-available {
  background-color: rgba(245, 158, 11, 0.2);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.4);
  font-weight: 600;
}

.card-footer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}



.device-cards-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  max-width: 480px;
}

.device-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  gap: 12px;
}

.device-item.active {
  border-color: var(--accent-cyan);
}

.device-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.device-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.device-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.badge-auto {
  background-color: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.badge-manual {
  background-color: rgba(167, 139, 250, 0.15);
  color: #a78bfa;
  border: 1px solid rgba(167, 139, 250, 0.35);
}

.badge-btn {
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  transition: opacity 0.15s ease, transform 0.1s ease;
  line-height: 1.3;
}

.badge-btn:hover {
  opacity: 0.85;
  transform: scale(1.04);
}

[data-theme="light"] .badge-auto {
  background-color: #e0f2fe;
  color: #0284c7;
  border-color: #bae6fd;
}

[data-theme="light"] .badge-manual {
  background-color: #ede9fe;
  color: #7c3aed;
  border-color: #ddd6fe;
}

.ip-input-row {
  display: flex;
  gap: 8px;
  max-width: 480px;
}

.ip-input-row input {
  flex: 1;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-family: monospace;
}

.font-mono {
  font-family: monospace;
}

.text-muted {
  color: var(--text-muted);
}

.text-sm {
  font-size: 0.82rem;
}

.mt-6 { margin-top: 6px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }

.hidden {
  display: none !important;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .tuners-grid, .recordings-grid {
    grid-template-columns: 1fr;
  }
}

/* Preferences Switch & Controls */
.pref-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  gap: 16px;
  border-bottom: 1px solid var(--border-main);
}

.pref-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.pref-row:first-of-type {
  padding-top: 4px;
}

.pref-info {
  flex: 1;
}

.pref-info strong {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.pref-control {
  flex-shrink: 0;
}

.pref-select {
  background-color: var(--bg-main);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 12px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.pref-select:hover,
.pref-select:focus {
  border-color: var(--accent-cyan);
}

.pref-select option {
  background-color: var(--bg-card);
  color: var(--text-primary);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-main);
  transition: 0.2s ease;
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: 0.2s ease;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent-cyan);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* Modal Overlay & Card */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-main);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.modal-close-icon:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

.modal-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border-main);
  color: var(--text-muted);
  font-size: 0.88rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  background-color: var(--bg-subtle);
  border-top: 1px solid var(--border-main);
}

/* Toast Notifications */
.app-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--accent-cyan);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.app-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* DVR Series Header Bar */
.dvr-series-header-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  grid-column: 1 / -1;
  padding: 10px 16px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

/* Card Header with Action Button */
.card-header-with-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.card-header-with-actions h3 {
  margin-bottom: 0;
}

/* Live System Status Badges & Storage Mini Bar */
.badge-active-client {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald-light);
  border: 1px solid rgba(16, 185, 129, 0.4);
  font-weight: 600;
}

.badge-active-playback {
  background-color: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.4);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

[data-theme="light"] .badge-active-playback {
  background-color: rgba(6, 182, 212, 0.12);
  color: #0891b2;
  border-color: rgba(6, 182, 212, 0.35);
}

.badge-playing {
  background-color: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.5);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  animation: pulse-playing 2s infinite ease-in-out;
}

[data-theme="light"] .badge-playing {
  background-color: rgba(16, 185, 129, 0.15);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.4);
}

@keyframes pulse-playing {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.recording-card.is-playing {
  border-color: rgba(16, 185, 129, 0.55);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.15);
}

.badge-active-record {
  background-color: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
  font-weight: 600;
}

.storage-mini-bar-wrap {
  width: 140px;
  height: 6px;
  background-color: var(--bg-subtle);
  border-radius: 3px;
  overflow: hidden;
}

/* Status Links in Device Details */
.status-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text-primary);
  transition: opacity 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}

.status-link:hover {
  opacity: 0.85;
}

.status-link .status-arrow {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: normal;
  transition: transform 0.2s ease, color 0.2s ease;
}

.status-link:hover .status-arrow {
  transform: translateX(2px);
  color: var(--accent-cyan);
}

/* ==========================================================================
   Clickable Tuner Cards & Per-Tuner Detail View
   ========================================================================== */

.tuner-card.clickable-tuner-card {
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.tuner-card.clickable-tuner-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-cyan);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.tuner-card-action-hint {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--accent-cyan);
  font-weight: 600;
  margin-top: 2px;
  opacity: 0.85;
  transition: opacity 0.2s ease;
}

.tuner-card:hover .tuner-card-action-hint {
  opacity: 1;
  text-decoration: underline;
}

/* Tuner Detail Top Bar */
.tuner-detail-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.tuner-detail-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 600;
}

/* Header Card */
.tuner-detail-header-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.tuner-detail-header-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}

.tuner-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-tuner-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
}

.detail-channel-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.detail-channel-logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.detail-channel-text-wrap {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.detail-channel-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.detail-channel-locality {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.detail-channel-badge-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin-left: 4px;
}

.detail-channel-num-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.detail-channel-number {
  font-size: 0.95rem;
  font-family: monospace;
  color: var(--accent-cyan);
  font-weight: 600;
}

.detail-channel-rf {
  font-size: 0.74rem;
  font-family: monospace;
  color: var(--text-muted);
  line-height: 1.2;
}

.detail-tuner-meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.detail-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.meta-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Controls Bar */
.tuner-controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border-main);
}

.sample-rate-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.playback-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  display: inline-block;
  animation: pulse-dot 1.5s infinite;
}

.live-pulse-dot.paused {
  background-color: var(--text-muted);
  box-shadow: none;
  animation: none;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

/* Idle Notice Card */
.idle-notice-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background-color: rgba(148, 163, 184, 0.08);
  border: 1px dashed var(--border-light);
  margin-bottom: 16px;
  padding: 16px 20px;
}

.idle-notice-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.idle-notice-text h4 {
  margin: 0 0 4px 0;
  font-size: 1rem;
}

.idle-notice-text p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.4;
}

/* Metrics Summary Grid */
.metrics-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.metric-summary-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 4px solid transparent;
}

.metric-summary-card.metric-strength {
  border-left-color: #38bdf8;
}

.metric-summary-card.metric-quality {
  border-left-color: #34d399;
}

.metric-summary-card.metric-symbol {
  border-left-color: #a78bfa;
}

.metric-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.metric-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.metric-title-group h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.metric-dot-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-strength { background-color: #38bdf8; }
.dot-quality  { background-color: #34d399; }
.dot-symbol   { background-color: #a78bfa; }

.metric-big-value {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: monospace;
}

.metric-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.35;
}

.metric-stats-row {
  display: flex;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border-main);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.metric-stats-row strong {
  color: var(--text-primary);
  font-family: monospace;
}

/* Chart Card */
.chart-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.chart-title-group h3 {
  margin: 0;
  font-size: 1.1rem;
}

.chart-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.legend-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border-main);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.legend-item.active {
  color: var(--text-primary);
  border-color: var(--border-light);
}

.legend-item:not(.active) {
  opacity: 0.4;
  text-decoration: line-through;
}

.legend-color-box {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.color-strength { background-color: #38bdf8; }
.color-quality  { background-color: #34d399; }
.color-symbol   { background-color: #a78bfa; }

/* SVG Chart Container */
.chart-svg-container {
  position: relative;
  width: 100%;
  height: 280px;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-main);
  overflow: hidden;
  touch-action: none;
}

#tuner-chart-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-xaxis-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0 8px;
  font-family: monospace;
}

/* Chart Tooltip */
.chart-tooltip {
  position: absolute;
  top: 12px;
  right: 12px;
  background-color: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border-light);
  backdrop-filter: blur(8px);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.chart-tooltip-time {
  font-weight: 700;
  color: var(--text-primary);
  font-family: monospace;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--border-main);
  padding-bottom: 2px;
}

.chart-tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.chart-tooltip-row .label {
  color: var(--text-secondary);
}

.chart-tooltip-row .val {
  font-weight: 700;
  font-family: monospace;
}

/* ==========================================================================
   Diagnostic Logs & Export
   ========================================================================== */
.diag-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.diag-options {
  display: flex;
  align-items: center;
}

.diag-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.diag-warning-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background-color: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  margin-top: 14px;
  font-size: 0.85rem;
  line-height: 1.45;
}

.diag-warning-banner .diag-warning-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 1px;
}

.diag-warning-banner .diag-warning-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.diag-warning-banner .diag-warning-text strong {
  color: #fbbf24;
  font-weight: 600;
}

.diag-warning-banner .diag-warning-text span {
  color: var(--text-secondary);
}

.diag-status-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-main);
  margin-top: 14px;
  font-size: 0.85rem;
}

.diag-status-banner.success {
  border-color: rgba(16, 185, 129, 0.4);
  background-color: rgba(16, 185, 129, 0.08);
  color: var(--accent-emerald-light);
}

.diag-status-banner.error {
  border-color: rgba(239, 68, 68, 0.4);
  background-color: rgba(239, 68, 68, 0.08);
  color: var(--accent-red);
}

.diag-output-container {
  margin-top: 14px;
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  background-color: var(--bg-card);
  overflow: hidden;
}

.diag-output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-main);
}

.diag-code-block {
  margin: 0;
  padding: 12px;
  max-height: 380px;
  overflow-y: auto;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-secondary);
  background-color: var(--bg-main);
  white-space: pre-wrap;
  word-break: break-word;
  user-select: all;
}

/* ==========================================================================
   Affiliate Logos & Station Identity
   ========================================================================== */

.channel-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.channel-logo-wrap {
  width: 32px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.affiliate-logo {
  max-width: 32px;
  max-height: 22px;
  width: auto;
  height: auto;
  object-fit: contain;
  vertical-align: middle;
  border-radius: 3px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}

.generic-tv-logo {
  opacity: 0.5;
  filter: none;
}

.tuner-affiliate-logo {
  max-width: 36px;
  max-height: 26px;
}

.channel-identity-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.channel-guide-name {
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
}

.channel-locality {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.tuner-channel-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.tuner-locality {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: normal;
}

.badge-affiliate {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-main);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 2px 6px;
}



