/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  --s0: #0d0d0f;
  --s1: #18181b;
  --s2: #232329;
  --s3: #2e2e36;
  --border: #3a3a44;
  --accent: #6366f1;
  --accent-dim: rgba(99,102,241,0.14);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --t1: #f4f4f5;
  --t2: #a1a1aa;
  --t3: #52525b;
  --sidebar-w: 224px;
  --topbar-h: 56px;
  --radius: 10px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--s0);
  color: var(--t1);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── Material Symbols ──────────────────────────────────────── */
.icon {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 20;
  vertical-align: middle;
  user-select: none;
}

/* ── App Shell (Admin) ─────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--s1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-logo {
  height: var(--topbar-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-mark {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.logo-mark .icon { font-size: 18px; }

.sidebar-logo span {
  font-size: 15px;
  font-weight: 700;
  color: var(--t1);
  letter-spacing: -0.01em;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--t2);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.12s, color 0.12s;
  font-family: inherit;
  text-decoration: none;
}

.nav-item:hover { background: var(--s3); color: var(--t1); }

.nav-item.active {
  background: var(--accent-dim);
  color: #818cf8;
  box-shadow: inset 2px 0 0 var(--accent);
  padding-left: 8px;
}

.nav-item .icon { font-size: 20px; flex-shrink: 0; }

.sidebar-footer {
  padding: 10px 8px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  padding: 6px 10px 10px;
  font-size: 12px;
  color: var(--t3);
}

/* ── Content Area ──────────────────────────────────────────── */
.content-area {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: var(--s1);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  flex-shrink: 0;
}

/* ── Pages scroll container ────────────────────────────────── */
.pages-scroll {
  flex: 1;
  overflow-y: auto;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--t3);
  background: var(--s2);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  transition: color 0.2s;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--t3);
  transition: background 0.2s;
}

.status-pill.online { color: var(--t1); }
.status-pill.online .status-dot {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

/* ── Pages / Tabs ──────────────────────────────────────────── */
.page {
  padding: 24px;
  display: none;
  flex: 1;
}
.page.active { display: block; }

/* ── Stat Cards ────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon .icon { font-size: 18px; }

.si-indigo { background: rgba(99,102,241,0.12); color: #818cf8; }
.si-green  { background: rgba(34,197,94,0.12);  color: #4ade80; }
.si-amber  { background: rgba(245,158,11,0.12); color: #fbbf24; }
.si-cyan   { background: rgba(6,182,212,0.12);  color: #22d3ee; }
.si-rose   { background: rgba(244,63,94,0.12);  color: #fb7185; }
.si-violet { background: rgba(167,139,250,0.12);color: #a78bfa; }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--t1);
  line-height: 1;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 12px;
  color: var(--t2);
  font-weight: 500;
}

/* ── Section ───────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--t1);
}

/* ── Panel ─────────────────────────────────────────────────── */
.panel {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.panel-body { padding: 20px; }

/* ── Tables ────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 9px 14px;
  color: var(--t3);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  background: var(--s2);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--t1);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--s2); }
.data-table tbody tr.no-row-hover:hover td { background: transparent; }
.device-sub-table tbody tr:hover td { background: var(--s2); cursor: default; }
.data-table tbody tr.src-dragging { opacity: 0.4; }
.data-table tbody tr.src-drag-over td { background: rgba(99,102,241,0.08); box-shadow: inset 0 2px 0 #6366f1; }

.cell-mono {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
  color: var(--t2);
}

.cell-truncate {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--t2);
  font-size: 12px;
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green  { background: rgba(34,197,94,0.12);  color: #4ade80; }
.badge-gray   { background: var(--s3);              color: var(--t2); border: 1px solid var(--border); }
.badge-indigo { background: rgba(99,102,241,0.12);  color: #818cf8; }
.badge-amber  { background: rgba(245,158,11,0.12);  color: #fbbf24; }

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  display: inline-block;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--t2);
  margin-bottom: 5px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  appearance: auto;
  -webkit-appearance: auto;
  accent-color: var(--accent);
  cursor: pointer;
  padding: 0;
  border: none;
  background: none;
}

input:not([type="checkbox"]), textarea, select {
  width: 100%;
  padding: 9px 12px;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--t1);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}

input:not([type="checkbox"]):focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

input::placeholder, textarea::placeholder { color: var(--t3); }
select option { background: var(--s2); color: var(--t1); }
textarea { resize: vertical; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  line-height: 1;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:not(:disabled):hover { opacity: 0.88; }
.btn:not(:disabled):active { opacity: 0.72; transform: translateY(1px); }

.btn .icon { font-size: 18px; }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--s3); color: var(--t1); border: 1px solid var(--border); }
.btn-danger    { background: rgba(239,68,68,0.12); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.btn-ghost     { background: transparent; color: var(--t2); border: 1px solid var(--border); }
.btn-ghost:not(:disabled):hover { color: var(--t1); background: var(--s2); opacity: 1; }
.btn-icon-only { padding: 7px; background: var(--s3); color: var(--t2); border: 1px solid var(--border); }
.btn-icon-only:not(:disabled):hover { color: var(--t1); opacity: 1; }

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-sm .icon { font-size: 15px; }
.btn-full { width: 100%; }

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

/* ── Auth Overlay ──────────────────────────────────────────── */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--s0);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.auth-card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.auth-logo h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.22);
  color: #f87171;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  margin-top: 12px;
  display: none;
}

.auth-error.visible { display: block; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 150;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 500px;
  animation: modal-in 0.18s ease;
  max-height: 90vh;
  overflow-y: auto;
}

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

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

.modal-title { font-size: 15px; font-weight: 600; }

/* ── Toasts ────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--t1);
  min-width: 220px;
  max-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: toast-in 0.18s ease;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }

.toast-icon .icon { font-size: 18px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error   .toast-icon { color: var(--danger); }
.toast.info    .toast-icon { color: #818cf8; }

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

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(6px); }
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--t3); }

/* ── Player Shell ──────────────────────────────────────────── */
.player-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--s0);
}

.player-topbar {
  height: var(--topbar-h);
  background: var(--s1);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}

.player-topbar .logo-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.player-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  gap: 16px;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

/* Video */
.video-wrapper {
  width: 100%;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border);
}

.video-wrapper video {
  width: 100%;
  height: 100%;
  display: block;
}

.video-idle {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--t3);
  background: var(--s1);
}

.video-idle .icon { font-size: 48px; }
.video-idle span { font-size: 13px; }

.video-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--t2);
  background: var(--s1);
  font-size: 13px;
}

.video-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinner-spin 0.75s linear infinite;
}

@keyframes spinner-spin {
  to { transform: rotate(360deg); }
}

/* Source Panel */
.source-panel {
  width: 100%;
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.source-top {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.source-top select { flex: 1; }

.source-meta {
  font-size: 12px;
  color: var(--t2);
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 18px;
  margin-bottom: 14px;
}

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

.source-meta .icon { font-size: 14px; }

.player-controls { display: flex; gap: 8px; }

/* Log */
.log-section { width: 100%; }

.log-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  color: var(--t3);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 0;
  font-family: inherit;
  transition: color 0.12s;
}

.log-toggle:hover { color: var(--t2); }
.log-toggle .icon { font-size: 16px; transition: transform 0.15s; }
.log-toggle.open .icon { transform: rotate(90deg); }

.log-body {
  display: none;
  margin-top: 8px;
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
  font-size: 11.5px;
  color: var(--t2);
  height: 160px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
}

.log-body.open { display: block; }

.log-line-error { color: #f87171; }
.log-line-event { color: #818cf8; }

/* Landing page */
.landing-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 32px;
}

.landing-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.landing-logo .logo-mark {
  width: 56px;
  height: 56px;
  border-radius: 14px;
}

.landing-logo .logo-mark .icon { font-size: 30px; }

.landing-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--t1);
}

.landing-subtitle {
  font-size: 14px;
  color: var(--t2);
  margin-top: -8px;
}

.landing-links {
  display: flex;
  gap: 12px;
}

.landing-card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  min-width: 140px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-decoration: none;
  color: var(--t1);
}

.landing-card:hover {
  border-color: var(--accent);
  background: var(--s2);
}

.landing-card .icon { font-size: 28px; color: #818cf8; }
.landing-card-label { font-size: 14px; font-weight: 600; }
.landing-card-sub { font-size: 12px; color: var(--t2); }

.landing-api {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  font-family: monospace;
  font-size: 12px;
  color: var(--t2);
  max-width: 420px;
  width: 100%;
}

/* ── Responsive ────────────────────────────────────────────── */

/* Tablet: Icon-only sidebar + column hiding (769px – 1100px) */
@media (min-width: 769px) and (max-width: 1100px) {
  :root { --sidebar-w: 60px; }
  .sidebar-logo { justify-content: center; padding: 0; }
  .sidebar-logo > span { display: none; }
  .sidebar-nav { padding: 10px 6px; }
  .nav-item { justify-content: center; padding: 10px; font-size: 0; gap: 0; }
  .nav-item .icon { font-size: 20px; }
  .sidebar-footer { padding: 10px 6px; }
  .sidebar-user { display: none; }

  /* Overview: hide Leader + Last Seen
     Use direct child selectors so viewer sub-rows (nested table) are not affected */
  #statsTable thead th:nth-child(6), #statsTable thead th:nth-child(9) { display: none; }
  #statsTable > tbody > tr > td:nth-child(6),
  #statsTable > tbody > tr > td:nth-child(9) { display: none; }

  /* Sources: hide ID + Manifest URL + URL-Ablauf */
  #sourcesTable thead th:nth-child(2),
  #sourcesTable thead th:nth-child(4),
  #sourcesTable thead th:nth-child(9) { display: none; }
  #sourcesTable > tbody > tr > td:nth-child(2),
  #sourcesTable > tbody > tr > td:nth-child(4),
  #sourcesTable > tbody > tr > td:nth-child(9) { display: none; }

  /* History: hide Benutzer + Genre + Kontext */
  #historyTable thead th:nth-child(2),
  #historyTable thead th:nth-child(6),
  #historyTable thead th:nth-child(7) { display: none; }
  #historyTable tbody tr td:nth-child(2),
  #historyTable tbody tr td:nth-child(6),
  #historyTable tbody tr td:nth-child(7) { display: none; }

  /* Logs: hide Tag + Benutzer + Gerät + Version */
  #logsTable thead th:nth-child(3),
  #logsTable thead th:nth-child(5),
  #logsTable thead th:nth-child(6),
  #logsTable thead th:nth-child(7) { display: none; }
  #logsTable tbody tr td:nth-child(3),
  #logsTable tbody tr td:nth-child(5),
  #logsTable tbody tr td:nth-child(6),
  #logsTable tbody tr td:nth-child(7) { display: none; }

  /* Proxy tables: hide URL column */
  #sysProxiesTable thead th:nth-child(2),
  #sysProxiesTable tbody tr td:nth-child(2),
  #proxiesTable thead th:nth-child(3),
  #proxiesTable tbody tr td:nth-child(3) { display: none; }
}

/* Mobile: Slide-in drawer (≤ 768px) */
@media (max-width: 768px) {
  /* Sidebar becomes a fixed drawer */
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 240px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.24s cubic-bezier(.4,0,.2,1);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0,0,0,0.5);
  }

  /* Backdrop overlay */
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.52);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s;
  }
  .sidebar-overlay.open { opacity: 1; pointer-events: auto; }

  /* Show hamburger button */
  .menu-toggle { display: flex !important; }

  /* Layout */
  .page { padding: 14px; }
  .topbar { padding: 0 14px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }

  /* Section header: wrap action buttons on small screens */
  .section-header { flex-wrap: wrap; gap: 8px; }
  .section-header > div { flex-wrap: wrap; }

  /* Modals: near full-width */
  .modal {
    width: calc(100vw - 24px) !important;
    max-width: none !important;
    max-height: 90vh;
  }

  /* Responsive table panels: transparent so card rows are the visual units */
  .panel-responsive {
    background: transparent;
    border: none;
    overflow: visible !important;
    padding: 0;
  }

  /* Tables become block containers */
  #statsTable, #sourcesTable, #usersTable,
  #statsTable > tbody, #sourcesTable > tbody, #usersTable > tbody { display: block; }
  #statsTable > thead, #sourcesTable > thead, #usersTable > thead { display: none; }

  /* Source/stats rows → cards */
  #statsTable > tbody > tr:not([data-detail]),
  #sourcesTable > tbody > tr {
    display: block;
    background: var(--s1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow: hidden;
  }

  /* Cells → stacked label + value rows */
  #statsTable > tbody > tr:not([data-detail]) > td,
  #sourcesTable > tbody > tr > td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    border-right: none;
    gap: 8px;
    white-space: normal;
  }
  #statsTable > tbody > tr:not([data-detail]) > td:last-child,
  #sourcesTable > tbody > tr > td:last-child { border-bottom: none; }

  /* Label prefix via data-label attribute */
  #statsTable > tbody > tr:not([data-detail]) > td[data-label]:not([data-label=""])::before,
  #sourcesTable > tbody > tr > td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--t3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
    min-width: 84px;
  }

  /* Header cells (data-label="") → card title style */
  #statsTable > tbody > tr:not([data-detail]) > td[data-label=""],
  #sourcesTable > tbody > tr > td[data-label=""] { background: var(--s2); }

  /* Hide specific outer-table columns on mobile.
     :not([data-detail]) prevents hiding the single colspan td of the detail row. */
  #statsTable > tbody > tr:not([data-detail]) > td:nth-child(1),   /* chevron */
  #statsTable > tbody > tr:not([data-detail]) > td:nth-child(6),   /* Leader */
  #statsTable > tbody > tr:not([data-detail]) > td:nth-child(9),   /* Last Seen */
  #sourcesTable > tbody > tr > td:nth-child(1), /* checkbox */
  #sourcesTable > tbody > tr > td:nth-child(2), /* ID */
  #sourcesTable > tbody > tr > td:nth-child(4), /* URL */
  #sourcesTable > tbody > tr > td:nth-child(9)  /* URL-Ablauf */
  { display: none !important; }

  /* Tappable card — make expansion obvious */
  #statsTable > tbody > tr:not([data-detail]) { cursor: pointer; }

  /* Detail / viewer expand row */
  #statsTable > tbody > tr[data-detail] {
    display: block;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    margin-top: -10px;
    margin-bottom: 10px;
    overflow-x: auto;
  }
  #statsTable > tbody > tr[data-detail] > td { display: block; padding: 0; border: none; }

  /* Users table → single-row cards */
  #usersTable > tbody > tr {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--s1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    padding: 10px 12px;
  }
  #usersTable > tbody > tr > td { display: flex; align-items: center; padding: 0; border: none; flex: 1; }
  #usersTable > tbody > tr > td:last-child { flex: 0; }

  /* Viewer sub-table: block layout so the detail row has a real height on mobile.
     display:table inside a display:block <tr> collapses to 0 height in some browsers. */
  .viewer-table { display: block !important; width: 100%; }
  .viewer-table > thead { display: none; }
  .viewer-table > tbody { display: block; }
  .viewer-table .viewer-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
  }
  .viewer-table .viewer-row:last-child { border-bottom: none; }
  .viewer-table .viewer-row > td {
    display: flex;
    align-items: center;
    padding: 0;
    border: none;
    font-size: 12px;
    white-space: nowrap;
  }
  /* Hide "last path" column on mobile (too wide) */
  .viewer-table .viewer-row > td:nth-child(5) { display: none; }
  /* Push kick button to the right */
  .viewer-table .viewer-row > td:last-child { margin-left: auto; }

  /* No max-width clipping inside cards */
  .cell-truncate { max-width: none; }

  /* Toasts: centered at bottom */
  .toast-container { right: 12px; left: 12px; bottom: 12px; }
  .toast { max-width: 100%; min-width: 0; width: 100%; }

  /* Player */
  .player-main { padding: 12px; }
  .player-topbar { padding: 0 16px; }

  /* Landing */
  .landing-links { flex-direction: column; align-items: center; }

  /* Settings grid */
  .settings-grid { grid-template-columns: 1fr !important; }

  /* History table → cards */
  #historyTable, #historyTable > tbody { display: block; }
  #historyTable > thead { display: none; }
  #historyTable > tbody > tr {
    display: block;
    background: var(--s1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow: hidden;
  }
  #historyTable > tbody > tr > td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    border-right: none;
    gap: 8px;
    white-space: normal;
  }
  #historyTable > tbody > tr > td:last-child { border-bottom: none; }
  #historyTable > tbody > tr > td[data-label=""] { background: var(--s2); font-weight: 500; }
  #historyTable > tbody > tr > td[data-label="x"] { background: transparent; justify-content: flex-end; }
  #historyTable > tbody > tr > td[data-label]:not([data-label=""]):not([data-label="x"])::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--t3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
    min-width: 72px;
  }
  #historyTable > tbody > tr > td:nth-child(2), /* Benutzer */
  #historyTable > tbody > tr > td:nth-child(6), /* Genre */
  #historyTable > tbody > tr > td:nth-child(7)  /* Kontext */
  { display: none !important; }

  /* Logs table → cards */
  #logsTable, #logsTable > tbody { display: block; }
  #logsTable > thead { display: none; }
  #logsTable > tbody > tr {
    display: block;
    background: var(--s1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow: hidden;
  }
  #logsTable > tbody > tr > td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    border-right: none;
    gap: 8px;
    white-space: normal;
  }
  #logsTable > tbody > tr > td:last-child { border-bottom: none; }
  #logsTable > tbody > tr > td[data-label=""] { background: var(--s2); font-weight: 500; }
  #logsTable > tbody > tr > td[data-label="x"] { background: transparent; justify-content: flex-end; }
  #logsTable > tbody > tr > td[data-label]:not([data-label=""]):not([data-label="x"])::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--t3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
    min-width: 72px;
  }
  #logsTable > tbody > tr > td:nth-child(3), /* Tag */
  #logsTable > tbody > tr > td:nth-child(5), /* Benutzer */
  #logsTable > tbody > tr > td:nth-child(6), /* Gerät */
  #logsTable > tbody > tr > td:nth-child(7)  /* Version */
  { display: none !important; }

  /* Proxy tables → compact flex rows */
  #sysProxiesTable, #sysProxiesTable > tbody,
  #proxiesTable,    #proxiesTable    > tbody { display: block; }
  #sysProxiesTable > thead,
  #proxiesTable    > thead { display: none; }
  #sysProxiesTable > tbody > tr,
  #proxiesTable    > tbody > tr {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    background: var(--s1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 8px;
  }
  #sysProxiesTable > tbody > tr > td,
  #proxiesTable    > tbody > tr > td { display: flex; align-items: center; padding: 0; border: none; font-size: 12px; }
  /* Name / Label: take remaining space */
  #sysProxiesTable > tbody > tr > td:nth-child(1) { flex: 1; font-weight: 600; font-size: 13px; min-width: 100px; }
  #proxiesTable    > tbody > tr > td:nth-child(2) { flex: 1; font-weight: 600; font-size: 13px; min-width: 100px; }
  /* URL: hidden on mobile */
  #sysProxiesTable > tbody > tr > td:nth-child(2),
  #proxiesTable    > tbody > tr > td:nth-child(3) { display: none; }
  /* Meta cells: dimmed */
  #sysProxiesTable > tbody > tr > td:nth-child(3),
  #sysProxiesTable > tbody > tr > td:nth-child(4),
  #proxiesTable    > tbody > tr > td:nth-child(1),
  #proxiesTable    > tbody > tr > td:nth-child(4) { color: var(--t3); }
  /* Actions: push to end */
  #sysProxiesTable > tbody > tr > td:last-child,
  #proxiesTable    > tbody > tr > td:last-child { margin-left: auto; }

  /* Touch targets */
  .data-table tbody tr { min-height: 44px; }
}

/* ── Settings grid (desktop) ────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}

/* ── Small mobile (≤ 420px) ─────────────────────────────────── */
@media (max-width: 420px) {
  .page { padding: 10px; }
  .topbar { padding: 0 10px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .modal { padding: 16px; }
  .auth-card { padding: 20px 16px; }
  .topbar-title { font-size: 13px; }
  .section-header .btn-sm .icon + * { display: none; } /* icon-only buttons in headers */
}
