/* ═══════════════════════════════════════════════════════════════
   NVR Pro — Dark Theme (ispirato a Bankco Admin Dashboard)
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* ── Tema chiaro (ispirato al mockup "Drive.") ── */
  --bg-body:        #e9ebfa;
  --bg-sidebar:     #171b34;   /* sidebar scura, come nel mockup */
  --bg-card:        #ffffff;
  --bg-card-hover:  #f5f6fd;
  --bg-secondary:   #ffffff;
  --bg-tertiary:    #f1f3fc;
  --bg-input:       #f4f6fd;
  --bg-table-even:  #f8f9fe;
  --accent:         #5a67f6;
  --accent-hover:   #4855e8;
  --accent-light:   #5a67f6;
  --accent-glow:    rgba(90,103,246,0.12);
  --text-primary:   #20264a;
  --text-secondary: #6b7391;
  --text-muted:     #a2abc7;
  --border:         #e6e9f5;
  --border-light:   #eef0fb;
  --success:        #10b981;
  --success-bg:     rgba(16,185,129,0.12);
  --warn:           #f59e0b;
  --warn-bg:        rgba(245,158,11,0.12);
  --danger:         #ef4444;
  --danger-bg:      rgba(239,68,68,0.10);
  --info:           #06b6d4;
  --info-bg:        rgba(6,182,212,0.12);
  --sidebar-width:  250px;
  --sidebar-collapsed: 70px;
  --topbar-height:  60px;
  --radius:         14px;
  --radius-sm:      8px;
  --shadow:         0 12px 32px rgba(70,80,140,0.14);
  --shadow-sm:      0 2px 10px rgba(70,80,140,0.08);
  --transition:     0.2s ease;
}

/* ── Sidebar: mantiene lo schema scuro sovrascrivendo le variabili ── */
.sidebar {
  --text-primary:   #f0f2fb;
  --text-secondary: #9aa3c7;
  --text-muted:     #5c6489;
  --border:         rgba(255,255,255,0.08);
  --border-light:   rgba(255,255,255,0.12);
  --accent-light:   #8b93ff;
  --accent-glow:    rgba(129,140,248,0.20);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-light); text-decoration: none; }
a:hover { color: var(--accent); }

/* ══════════════════════════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════════════════════════ */

.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: width var(--transition);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-separator span,
.sidebar.collapsed .user-details,
.sidebar.collapsed .user-actions,
.sidebar.collapsed .sidebar-powered { display: none; }

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

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

.sidebar-logo-img {
  height: 36px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  display: block;
}

/* Espansa: logo-02 · Ridotta: logo-01 */
.sidebar-logo-collapsed { display: none; }
.sidebar.collapsed .sidebar-logo-expanded { display: none; }
.sidebar.collapsed .sidebar-logo-collapsed {
  display: block;
  height: 32px;
  width: 32px;
  max-width: 40px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  line-height: 1;
  transition: color var(--transition);
}
.sidebar-toggle:hover { color: var(--text-primary); }

/* Nav links */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav ul { list-style: none; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text-secondary);
  border-radius: 0;
  transition: all var(--transition);
  position: relative;
  white-space: nowrap;
}
.nav-link i { font-size: 18px; flex-shrink: 0; }
.nav-link:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.nav-link.active {
  color: var(--accent-light);
  background: var(--accent-glow);
  border-right: 3px solid var(--accent);
}
.nav-link.active i { color: var(--accent); }

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.4;
}
.nav-badge-on {
  background: rgba(34, 197, 94, 0.18);
  color: #22c55e;
}
.nav-badge-off {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
}
.nav-badge-idle {
  background: rgba(245, 158, 11, 0.18);
  color: #f59e0b;
}
.nav-badge-err {
  background: rgba(239, 68, 68, 0.18);
  color: #ef4444;
}
.sidebar.collapsed .nav-badge { display: none; }

.nav-separator {
  padding: 12px 16px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Sidebar footer */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-footer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-powered {
  display: block;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  transition: color var(--transition);
}
.sidebar-powered:hover {
  color: var(--accent-light);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}

.user-details { overflow: hidden; }
.user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; }

.user-actions { display: flex; gap: 4px; flex-shrink: 0; }

.btn-icon {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 16px;
  transition: all var(--transition);
}
.btn-icon:hover { background: rgba(255,255,255,0.12); color: var(--text-primary); }

/* ── Main wrapper ── */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}
.sidebar.collapsed ~ .main-wrapper { margin-left: var(--sidebar-collapsed); }

/* ── Topbar ── */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.sidebar-toggle-mobile {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 22px;
  cursor: pointer;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.04);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ── Content ── */
.content {
  flex: 1;
  padding: 24px;
  overflow-x: hidden;
}

/* ══════════════════════════════════════════════════════════════
   COMPONENTS
══════════════════════════════════════════════════════════════ */

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-title i { color: var(--accent-light); }
.page-actions { display: flex; gap: 10px; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}
.card-title i { color: var(--accent-light); }
.card-action {
  font-size: 12px;
  color: var(--accent-light);
  display: flex;
  align-items: center;
  gap: 4px;
}
.card-action:hover { color: var(--accent); }
.card-subtitle { font-size: 12px; color: var(--text-secondary); }
.card-body { padding: 20px; }
.card-body.p0 { padding: 0; }

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.stat-card:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-glow); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon-blue   { background: rgba(90,103,246,0.15); color: var(--accent-light); }
.stat-icon-green  { background: var(--success-bg);     color: var(--success); }
.stat-icon-red    { background: var(--danger-bg);      color: var(--danger); }
.stat-icon-purple { background: rgba(168,85,247,0.15); color: #c084fc; }
.stat-icon-cyan   { background: var(--info-bg);        color: var(--info); }

.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ── Two column layout ── */
.row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) { .row-2col { grid-template-columns: 1fr; } }

/* ── Data table ── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead tr {
  border-bottom: 1px solid var(--border);
}
.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.filename-cell { font-family: monospace; font-size: 12px; color: var(--text-secondary); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
  line-height: 1;
}
.btn i { font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary  { background: var(--accent);  color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost    { background: rgba(255,255,255,0.06); color: var(--text-primary); border-color: var(--border-light); }
.btn-ghost:hover { background: rgba(255,255,255,0.10); }
.btn-danger   { background: var(--danger-bg); color: var(--danger); border-color: rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-green    { background: var(--success-bg); color: var(--success); border-color: rgba(16,185,129,0.3); }
.btn-green:hover { background: rgba(16,185,129,0.25); }
.btn-red      { background: var(--danger-bg); color: var(--danger); border-color: rgba(239,68,68,0.3); }
.btn-red:hover { background: rgba(239,68,68,0.25); }
.btn-block    { width: 100%; justify-content: center; }
.btn-sm       { padding: 5px 10px; font-size: 12px; }
.btn-icon-only { padding: 5px 8px; }

.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-admin    { background: rgba(168,85,247,0.15); color: #c084fc; }
.badge-operator { background: var(--info-bg); color: var(--info); }
.badge-blue     { background: var(--accent-glow); color: var(--accent-light); }
.badge-green    { background: var(--success-bg); color: var(--success); }
.badge-red      { background: var(--danger-bg); color: var(--danger); }
.badge-warn     { background: var(--warn-bg); color: var(--warn); }
.badge-off      { background: rgba(255,255,255,0.06); color: var(--text-secondary); }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.badge-pulse { animation: pulse 1.5s ease-in-out infinite; }

/* ── Dot indicators ── */
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
}
.dot-green  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.dot-red    { background: var(--danger);  box-shadow: 0 0 6px var(--danger); }
.dot-gray   { background: var(--text-muted); }
.dot-yellow { background: var(--warn); }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group.mb0 { margin-bottom: 0; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-hint {
  display: block;
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-secondary);
  margin-top: 2px;
}
.form-input, .form-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color var(--transition);
  appearance: none;
}
.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-input::placeholder { color: var(--text-muted); }
.form-select { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%236c7a9c'%3E%3Cpath d='M7 10l5 5 5-5H7z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

.form-row { display: flex; gap: 20px; flex-wrap: wrap; }
.form-switch-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text-primary); font-weight: 400; text-transform: none; letter-spacing: 0; margin-top: 4px; }
.form-switch { width: 36px; height: 20px; appearance: none; background: var(--text-muted); border-radius: 10px; cursor: pointer; position: relative; transition: background var(--transition); flex-shrink: 0; }
.form-switch:checked { background: var(--accent); }
.form-switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform var(--transition); }
.form-switch:checked::after { transform: translateX(16px); }
.form-switch:disabled { opacity: 0.45; cursor: not-allowed; }
.form-switch-label.is-disabled { cursor: not-allowed; opacity: 0.75; }
.smtp-hint { margin: 0.5rem 0 0; font-size: 0.8rem; color: var(--danger); }

.input-with-icon { position: relative; }
.input-with-icon .form-input { padding-right: 40px; }
.input-icon-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 16px; padding: 2px; }
.input-icon-btn:hover { color: var(--text-primary); }

.input-suffix { display: flex; align-items: center; gap: 0; }
.input-suffix .form-input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.suffix-label { background: var(--border); border: 1px solid var(--border); border-left: none; padding: 9px 12px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-secondary); font-size: 13px; white-space: nowrap; }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ── Alerts ── */
.alert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.25); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,0.25); }
.alert-warn    { background: var(--warn-bg);    color: var(--warn);    border: 1px solid rgba(245,158,11,0.25); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid rgba(6,182,212,0.25); }

/* ── Toast ── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { opacity:0; transform: translateX(100%); } to { opacity:1; transform: translateX(0); } }
@keyframes fadeOut { from { opacity:1; } to { opacity:0; transform: translateX(100%); } }
.toast.hiding { animation: fadeOut 0.3s ease forwards; }
.toast-success { background: #0f2a1e; color: var(--success); border: 1px solid rgba(16,185,129,0.35); }
.toast-danger  { background: #2a0f0f; color: var(--danger);  border: 1px solid rgba(239,68,68,0.35); }
.toast-info    { background: #0f1e2a; color: var(--info);    border: 1px solid rgba(6,182,212,0.35); }

/* ── Modals ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
  animation: modalIn 0.25s ease;
}
.modal-lg { max-width: 640px; }
.modal-xl { max-width: 860px; }

.roi-wrap {
  background: #111;
  border-radius: 8px;
  overflow: hidden;
  min-height: 180px;
  max-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.roi-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
}
.roi-stage img, .roi-stage canvas {
  display: block;
  max-width: 100%;
  max-height: 360px;
}
.roi-stage canvas {
  position: absolute;
  left: 0;
  top: 0;
  cursor: crosshair;
}
.roi-status { font-size: 0.8rem; color: var(--text-secondary); margin: 0.4rem 0 0; }
@keyframes modalIn { from { opacity:0; transform: scale(0.95) translateY(-10px); } to { opacity:1; transform: scale(1) translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-secondary); font-size: 20px; cursor: pointer; border-radius: var(--radius-sm); padding: 2px; transition: color var(--transition); }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); }

/* ── Camera grid ── */
.camera-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.camera-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition);
}
.camera-card:hover { border-color: var(--border-light); }

.camera-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.camera-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
}
.camera-badges { display: flex; gap: 6px; }

.camera-player {
  background: #000;
  height: 220px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  height: 100%;
}
.player-placeholder i { font-size: 40px; }
.player-placeholder span { font-size: 13px; }

.camera-controls {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ── Disk bar ── */
.disk-info { margin-bottom: 12px; }
.disk-percent { font-size: 36px; font-weight: 700; margin-bottom: 10px; }
.disk-bar-wrap { display: flex; flex-direction: column; gap: 6px; }
.disk-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.disk-bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.5s ease; }
.disk-bar-fill.disk-bar-warn { background: var(--warn); }
.disk-bar-fill.disk-bar-danger { background: var(--danger); }
.disk-labels { display: flex; gap: 16px; font-size: 12px; color: var(--text-secondary); flex-wrap: wrap; }
.disk-labels span { display: inline-flex; align-items: center; gap: 6px; }
.disk-note { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }

/* ── Gestione disco (scheda cliente) ── */
.disk-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.disk-stat {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.disk-stat-label { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .03em; }
.disk-stat-val { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.disk-stat-val.accent { color: var(--accent-light); }

.alloc-bar {
  display: flex;
  height: 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  margin-bottom: 8px;
}
.alloc-bar.split-bar { height: 12px; }
.alloc-seg { height: 100%; width: 0; transition: width .4s ease; }
.alloc-others { background: var(--text-muted); }
.alloc-this   { background: var(--accent); }
.alloc-rec    { background: var(--info); }
.alloc-saved  { background: #c084fc; }
.alloc-seg.alloc-danger { background: var(--danger); }

.lg-others { background: var(--text-muted); }
.lg-this   { background: var(--accent); }
.lg-rec    { background: var(--info); }
.lg-saved  { background: #c084fc; }

.split-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 4px 0 8px; flex-wrap: wrap; }
.split-sum { font-size: 12px; color: var(--text-secondary); }

.usage-bar {
  height: 6px; background: var(--bg-tertiary); border-radius: 3px;
  overflow: hidden; margin: 8px 0 4px;
}
.usage-fill { height: 100%; width: 0; background: var(--success); border-radius: 3px; transition: width .4s ease; }
.usage-fill.usage-warn { background: var(--warn); }
.usage-fill.usage-danger { background: var(--danger); }

.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 20px;
  color: var(--text-secondary);
}
.empty-state i { font-size: 48px; color: var(--text-muted); }
.empty-state p { font-size: 14px; }

/* ── Filter bar ── */
.filter-bar { margin-bottom: 20px; }
.filter-row { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.filter-actions { display: flex; gap: 8px; padding-top: 1px; }

/* ── Recordings ── */
.rec-group { border-bottom: 1px solid var(--border); }
.rec-group:last-child { border-bottom: none; }
.rec-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
}

/* ── Schedule rows ── */
.schedule-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.schedule-row:last-child { border-bottom: none; }
.sched-sep { color: var(--text-secondary); flex-shrink: 0; }
.sched-day, .sched-start, .sched-end { flex: 1; min-width: 80px; }

/* ── User list ── */
.user-row { display: flex; align-items: center; gap: 8px; }
.user-avatar-sm {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

/* ── Permission list ── */
.permission-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.permission-list li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.text-green { color: var(--success); }
.text-red { color: var(--danger); }

/* ── Info list ── */
.info-list { display: flex; flex-direction: column; gap: 12px; }
.info-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: none; }
.info-label { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.info-value { font-size: 13px; font-weight: 500; }

/* ── Video meta ── */
.video-meta { display: flex; gap: 16px; margin-top: 8px; font-size: 12px; color: var(--text-secondary); }

/* ── Loading ── */
.loading-spinner { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--text-secondary); font-size: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 1s linear infinite; }

/* ── Error page ── */
.error-page { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 80px 20px; text-align: center; }
.error-code { font-size: 96px; font-weight: 900; color: var(--accent); opacity: 0.6; line-height: 1; }
.error-message { font-size: 20px; color: var(--text-secondary); }

/* ── Utilities ── */
.text-muted { color: var(--text-secondary); }
.mt-md { margin-top: 20px; }
.mb0 { margin-bottom: 0 !important; }

/* ── Sidebar overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
}

/* ══════════════════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════════════════ */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-body);
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.login-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: 0.3;
}

.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 8px 24px rgba(90,103,246,0.4);
  overflow: hidden;
  padding: 10px;
}

.login-logo-img { display: block; width: 100%; max-width: 220px; height: auto; margin: 0 auto 16px; }
.login-logo h1 { font-size: 28px; font-weight: 800; margin-bottom: 4px; }
.login-logo h1 span { color: var(--accent-light); }
.login-logo p { font-size: 13px; color: var(--text-secondary); }

.login-form { display: flex; flex-direction: column; gap: 0; }

.login-footer { text-align: center; margin-top: 20px; font-size: 11px; color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform var(--transition); }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .main-wrapper { margin-left: 0 !important; }
  .sidebar-toggle { display: none; }
  .sidebar-toggle-mobile { display: block; }
  .camera-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 12px; }
  .filter-row { flex-direction: column; align-items: stretch; }
  .row-2col { grid-template-columns: 1fr; }

  /* Topbar più compatta */
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-left { gap: 8px; min-width: 0; }
  .topbar-right { gap: 6px; flex-shrink: 0; }
  .breadcrumb { font-size: 12px; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .status-indicator { padding: 3px 8px; font-size: 11px; }
  .status-indicator .status-text { display: none; }
  #spaceRemaining .status-text { display: inline; max-width: 7.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #statusDot { padding: 3px 6px; }

  /* Pagina Registrazioni: stili mobile dedicati in recordings-mobile.css */
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 28px 20px; }
  .content { padding: 10px; }
  .card-body { padding: 14px; }
  .page-header { margin-bottom: 12px; }
}

/* code tags */
code { background: var(--bg-input); border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px; font-family: monospace; font-size: 12px; color: var(--accent-light); }

/* ── Stream error box ── */
.stream-error-box {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-family: monospace;
  font-size: 11px;
  padding: 8px 10px;
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  text-align: left;
  max-height: 80px;
  overflow-y: auto;
}

/* ── Settings tabs ── */
.settings-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  flex-wrap: wrap;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
}
.tab-btn i { font-size: 15px; }
.tab-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.tab-btn.active { background: var(--accent-glow); color: var(--accent-light); }
.tab-btn .badge { margin-left: 2px; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Filtri Registrazioni ───────────────────────────────────────────────── */

.rec-filters {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  gap: 12px 16px;
  align-items: end;
}
.rec-filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rec-btn-load { min-width: 110px; justify-content: center; }

.rec-save-range {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px 16px;
  align-items: end;
}
.rec-save-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rec-save-input-row .form-input { flex: 1; min-width: 0; }
.rec-btn-save { white-space: nowrap; }

/* ── Timeline Registrazioni ─────────────────────────────────────────────── */

.tl-card-body { padding-bottom: 1.25rem; }
.tl-card-header {
  flex-wrap: wrap;
  gap: 8px;
}
.tl-card-header .card-title {
  font-size: 13px;
  min-width: 0;
}
.tl-card-header .card-subtitle {
  width: 100%;
  word-break: break-word;
}

.tl-scroll-hint {
  display: none;
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 8px;
  align-items: center;
  gap: 6px;
}
.tl-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.tl-scroll-inner {
  min-width: 100%;
}

.tl-nav-wrap {
  margin: 0.85rem 0 0.35rem;
}
.tl-nav-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.tl-nav-label span:last-child {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600;
  color: var(--text-secondary);
}
.tl-nav {
  width: 100%;
  user-select: none;
  touch-action: none;
}
.tl-nav-track {
  position: relative;
  height: 36px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}
.tl-nav-segs { position: absolute; inset: 0; }
.tl-nav-seg {
  position: absolute;
  top: 8px;
  bottom: 8px;
  background: rgba(34, 197, 94, 0.55);
  border-radius: 2px;
}
.tl-nav-seg.live {
  background: rgba(239, 68, 68, 0.55);
}
.tl-nav-window {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(59, 130, 246, 0.22);
  border: 2px solid rgba(59, 130, 246, 0.85);
  border-radius: 6px;
  cursor: grab;
  box-sizing: border-box;
  min-width: 18px;
}
.tl-nav-window:active { cursor: grabbing; }
.tl-nav-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  background: rgba(59, 130, 246, 0.55);
  cursor: ew-resize;
}
.tl-nav-handle-l { left: 0; border-radius: 4px 0 0 4px; }
.tl-nav-handle-r { right: 0; border-radius: 0 4px 4px 0; }

.tl-zoom-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.55rem 0 0.15rem;
  flex-wrap: wrap;
}
.tl-zoom-range {
  flex: 1;
  min-width: 140px;
  max-width: 420px;
  accent-color: var(--accent, #3b82f6);
  height: 1.25rem;
  cursor: pointer;
}
.tl-zoom-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 2.75rem;
}

/* Righello ore */
.tl-ruler {
  position: relative;
  height: 22px;
  margin-bottom: 6px;
  user-select: none;
}
.tl-mark {
  position: absolute;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  line-height: 1;
}
.tl-mark::before {
  content: '';
  display: block;
  width: 1px;
  height: 6px;
  background: var(--border);
  margin: 0 auto 2px;
}
.tl-mark-tick::before { height: 4px; opacity: .55; }
.tl-mark-tick { font-size: 0; }
.tl-mark-label { font-variant-numeric: tabular-nums; }

/* Barra principale */
.tl-bar-wrap { padding: 2px 0 6px; }
.tl-bar {
  position: relative;
  height: 52px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: crosshair;
  overflow: visible;
  touch-action: pan-x;
}

/* Zona rossa (gap) */
.tl-gap-seg {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(239, 68, 68, 0.28);
  border-radius: 4px;
  pointer-events: none;
}

/* Segmenti verdi (registrazioni) */
.tl-seg {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(34, 197, 94, 0.55);
  border-left: 1px solid rgba(34, 197, 94, 0.8);
  border-right: 1px solid rgba(34, 197, 94, 0.8);
  border-radius: 3px;
  transition: background 0.15s;
  z-index: 2;
  min-width: 2px;
}
.tl-seg:hover { background: rgba(34, 197, 94, 0.8); }

/* Segmento in corso (animato) */
.tl-seg-live {
  background: rgba(34, 197, 94, 0.45);
  animation: tlPulse 2s ease-in-out infinite;
}
@keyframes tlPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

/* Cursore verticale */
.tl-cursor {
  position: absolute;
  top: -6px;
  bottom: -6px;
  width: 2px;
  background: #fff;
  border-radius: 2px;
  transform: translateX(-1px);
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(255,255,255,0.7);
}
.tl-cursor::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #fff;
}

/* Tooltip hover */
.tl-tooltip-box {
  position: absolute;
  top: -30px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 12px;
  font-family: monospace;
  color: var(--text-primary);
  pointer-events: none;
  white-space: nowrap;
  z-index: 30;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Legenda */
.tl-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.tl-leg-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.tl-leg-dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}
.tl-leg-green { background: rgba(34, 197, 94, 0.65); }
.tl-leg-red   { background: rgba(239, 68, 68, 0.4); }
.tl-leg-pulse {
  background: rgba(34, 197, 94, 0.4);
  animation: tlPulse 2s ease-in-out infinite;
}

/* Pannello selezione */
.tl-selection {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  flex-wrap: wrap;
}
.tl-sel-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  min-width: 0;
  flex-wrap: wrap;
}
.tl-sel-actions { display: flex; gap: 8px; flex-shrink: 0; }
.tl-sep { color: var(--text-muted); }

/* Empty / Loading */
.tl-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}
.tl-empty i {
  font-size: 2.5rem;
  display: block;
  margin-bottom: .5rem;
}

/* Badge "REC in corso" nella summary */
.tl-live-badge {
  color: #ef4444;
  font-weight: 600;
  animation: tlPulse 1.5s ease-in-out infinite;
}

/* Toggle switch */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.toggle-switch input[type="checkbox"] { display: none; }
.toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle-switch input:checked + .toggle-slider::after {
  transform: translateX(20px);
  background: #fff;
}
.toggle-label { font-size: 14px; font-weight: 500; color: var(--text-primary); }

.mb-3 { margin-bottom: 1.25rem; }

/* ── Upload Log Viewer ─────────────────────────────────────────────── */
.upload-log-box {
  background: #0d0d0d;
  border-top: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
  height: 320px;
  overflow-y: auto;
  font-family: 'Consolas', 'Fira Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  padding: 6px 0;
}
.log-line {
  display: flex;
  gap: .5rem;
  padding: 2px 12px;
  border-bottom: 1px solid rgba(255,255,255,.03);
  word-break: break-all;
}
.log-line:hover { background: rgba(255,255,255,.04); }
.log-ts  { color: #6b7280; flex-shrink: 0; }
.log-lv  { flex-shrink: 0; width: 46px; font-weight: 600; }
.log-msg { color: #d1d5db; flex: 1; }
.log-info  .log-lv { color: #60a5fa; }
.log-warn  .log-lv { color: #fbbf24; }
.log-warn  .log-msg { color: #fef3c7; }
.log-err   .log-lv { color: #f87171; }
.log-err   .log-msg { color: #fca5a5; }

/* Badges */
.badge { display:inline-block; padding:3px 10px; border-radius:20px; font-size:12px; font-weight:600; }
.badge-green { background:rgba(34,197,94,.15); color:#4ade80; border:1px solid rgba(34,197,94,.3); }
.badge-off   { background:rgba(107,114,128,.15); color:#9ca3af; border:1px solid rgba(107,114,128,.3); }

/* Spin animation */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display:inline-block; animation: spin .8s linear infinite; }

/* ══════════════════════════════════════════════════════════════
   DASHBOARD — layout moderno
══════════════════════════════════════════════════════════════ */

.dash { display: flex; flex-direction: column; gap: 22px; }

/* Anteprima live in dashboard */
.dash-live { display: flex; flex-direction: column; gap: 14px; }
.dash-live-grid { margin-bottom: 0; }
.dash-live .camera-player { height: 200px; }
.dash-live-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.dash-live-stop {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: background var(--transition);
}
.dash-live-stop:hover { background: rgba(220, 38, 38, 0.9); }

/* ── Monitor Excubia (schermo intero) ── */
.monitor-page {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #000;
  cursor: none;
}
.monitor-page.controls-visible { cursor: default; }
.monitor-grid {
  display: grid;
  width: 100vw;
  height: 100vh;
  grid-template-columns: repeat(var(--cols, 2), 1fr);
  grid-template-rows: repeat(var(--rows, 1), 1fr);
  gap: 2px;
  background: #000;
}
.monitor-cell {
  position: relative;
  background: #0a0a0a;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}
.monitor-cell video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: none;
}
.monitor-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #444;
  font-size: 36px;
  background: #0a0a0a;
}
.monitor-placeholder .ri-error-warning-line { color: #7f1d1d; }
.monitor-empty {
  width: 100vw;
  height: 100vh;
  background: #000;
}
.monitor-exit {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.monitor-exit.visible {
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
}
.monitor-exit:hover { background: rgba(220, 38, 38, 0.85); }
.monitor-page .spin { display: inline-block; animation: spin .8s linear infinite; }

/* Intestazione sezione */
.dash-section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 2px;
}
.dash-section-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }

/* Card accesso rapido colorate */
.dash-quick {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.quick-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border-radius: 16px;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 130px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.quick-card:hover { transform: translateY(-4px); color: #fff; }
.quick-top { display: flex; align-items: center; justify-content: space-between; }
.quick-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.22); font-size: 22px;
}
.quick-arrow { font-size: 20px; opacity: .7; }
.quick-value { font-size: 30px; font-weight: 700; line-height: 1.1; margin-top: 8px; }
.quick-label { font-size: 13px; opacity: .9; }
.quick-blue  { background: linear-gradient(135deg, #3b82f6, #2563eb); box-shadow: 0 10px 24px rgba(37,99,235,.30); }
.quick-green { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 10px 24px rgba(16,185,129,.30); }
.quick-red   { background: linear-gradient(135deg, #f43f5e, #e11d48); box-shadow: 0 10px 24px rgba(225,29,72,.30); }
.quick-amber { background: linear-gradient(135deg, #f59e0b, #d97706); box-shadow: 0 10px 24px rgba(217,119,6,.30); }

/* Griglia a due colonne */
.dash-grid {
  display: grid;
  grid-template-columns: 1.9fr 1fr;
  gap: 20px;
  align-items: start;
}
.dash-main, .dash-aside { display: flex; flex-direction: column; gap: 20px; }

/* Pannelli */
.dash-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.dash-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.dash-panel-title {
  font-size: 14px; font-weight: 600; color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
}
.dash-panel-title i { color: var(--accent-light); }
.dash-panel-body { padding: 20px; }
.dash-panel-body.p0 { padding: 0; }
.dash-link {
  font-size: 12px; color: var(--accent-light);
  display: flex; align-items: center; gap: 2px;
}
.dash-link:hover { color: var(--accent); }

/* Lista registrazioni recenti */
.rec-list { list-style: none; }
.rec-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.rec-item:last-child { border-bottom: none; }
.rec-item:hover { background: var(--bg-card-hover); }
.rec-badge {
  flex-shrink: 0;
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-glow); color: var(--accent-light); font-size: 18px;
}
.rec-info { flex: 1; min-width: 0; }
.rec-name {
  font-size: 13px; font-weight: 500; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rec-meta { font-size: 12px; color: var(--text-secondary); }
.rec-date { font-size: 12px; color: var(--text-secondary); flex-shrink: 0; }
.rec-size {
  font-size: 12px; color: var(--text-primary); font-weight: 600;
  flex-shrink: 0; min-width: 64px; text-align: right;
}
.rec-action {
  flex-shrink: 0; font-size: 20px; color: var(--accent-light);
  display: flex; align-items: center;
}
.rec-action:hover { color: var(--accent); }

/* Anello disco */
.disk-ring-wrap { display: flex; justify-content: center; padding: 6px 0 16px; }
.disk-ring {
  --val: 0;
  --ring: var(--accent);
  width: 150px; height: 150px; border-radius: 50%;
  background: conic-gradient(var(--ring) calc(var(--val) * 1%), var(--border) 0);
  display: flex; align-items: center; justify-content: center;
  transition: background .4s ease;
}
.disk-ring.ring-warn   { --ring: var(--warn); }
.disk-ring.ring-danger { --ring: var(--danger); }
.disk-ring-center {
  width: 112px; height: 112px; border-radius: 50%;
  background: var(--bg-card);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.disk-ring-val { font-size: 26px; font-weight: 700; color: var(--text-primary); }
.disk-ring-cap { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.disk-legend { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.disk-legend li {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-secondary);
}
.disk-legend li b { margin-left: auto; color: var(--text-primary); font-weight: 600; }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.lg-used  { background: var(--accent); }
.lg-free  { background: var(--success); }
.lg-total { background: var(--text-muted); }

/* Lista attività */
.activity-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.activity-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.activity-list li:last-child { border-bottom: none; }
.act-icon {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.act-green { background: var(--success-bg); color: var(--success); }
.act-red   { background: var(--danger-bg);  color: var(--danger); }
.act-blue  { background: var(--info-bg);    color: var(--info); }
.act-amber { background: var(--warn-bg);    color: var(--warn); }
.act-text { flex: 1; font-size: 13px; color: var(--text-secondary); }
.act-num  { font-size: 16px; font-weight: 700; color: var(--text-primary); }

/* Raggruppamento per cliente (vista admin) */
.client-group { margin-bottom: 26px; }
.client-group-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.client-group-title {
  font-size: 15px; font-weight: 600; color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
}
.client-group-title i { color: var(--accent-light); }
.client-group-count {
  font-size: 12px; color: var(--text-secondary);
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 2px 10px; border-radius: 20px;
}

/* Accordion sezioni cliente */
.accordion-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.accordion-item .client-group-head,
.accordion-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 0;
  padding: 16px 20px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background var(--transition);
}
.accordion-toggle:hover { background: var(--bg-card-hover); }
.accordion-right { display: flex; align-items: center; gap: 12px; }
.accordion-chevron {
  font-size: 20px; color: var(--text-secondary);
  transition: transform var(--transition);
}
.accordion-body { padding: 18px 20px; }
.accordion-body .camera-grid { margin-bottom: 0; }

/* Stato collassato */
.accordion-item.collapsed .client-group-head { border-bottom: none; }
.accordion-item.collapsed .accordion-body { display: none; }
.accordion-item.collapsed .accordion-chevron { transform: rotate(-90deg); }

/* Responsive */
@media (max-width: 1050px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-quick { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .dash-quick { grid-template-columns: 1fr; }
  .rec-date { display: none; }
}

/* ══════════════════════════════════════════════════════════════
   TEMA CHIARO — aggiustamenti componenti
   (correzioni dove il vecchio tema scuro usava colori non adatti)
══════════════════════════════════════════════════════════════ */

/* Topbar chiara */
.topbar {
  background: var(--bg-card);
  box-shadow: 0 1px 0 var(--border);
}
.status-indicator { background: var(--bg-tertiary); }

/* Card e pannelli: ombra morbida al posto del solo bordo */
.card, .stat-card, .camera-card, .dash-panel, .settings-tabs {
  box-shadow: var(--shadow-sm);
}
.camera-card:hover { border-color: var(--accent); }

/* Bottoni ghost: sfondo chiaro visibile */
.btn-ghost { background: var(--bg-tertiary); color: var(--text-primary); border-color: var(--border); }
.btn-ghost:hover { background: #e4e8f6; }

/* Hover righe/tabelle su sfondo bianco */
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.rec-group-header { background: var(--bg-card-hover); }

/* Badge "spento" leggibile su bianco */
.badge-off { background: #eceef6; color: var(--text-secondary); }

/* Tab impostazioni */
.tab-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }

/* Toast in versione chiara */
.toast-success { background: #e7f8f0; color: #0b7a53; border: 1px solid rgba(16,185,129,0.35); }
.toast-danger  { background: #fdeaea; color: #c0392b; border: 1px solid rgba(239,68,68,0.35); }
.toast-info    { background: #e8f6fb; color: #0b7285; border: 1px solid rgba(6,182,212,0.35); }

/* Cursore timeline scuro su barra chiara */
.tl-cursor { background: var(--text-primary); box-shadow: 0 0 6px rgba(32,38,74,0.4); }
.tl-cursor::before { border-top-color: var(--text-primary); }

/* Ombra tooltip timeline coerente col chiaro */
.tl-tooltip-box { box-shadow: 0 2px 10px rgba(70,80,140,0.18); }

/* Il visualizzatore log resta scuro (stile terminale): testo chiaro garantito */
.upload-log-box { color: #d1d5db; }

/* ── Sala mixer ── */
.mixer-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
.mixer-program {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.mixer-program-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.mixer-program-player {
  background: #000;
  min-height: 280px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mixer-program-player video {
  width: 100%;
  max-height: 420px;
  background: #000;
  display: none;
}
.mixer-program-meta {
  padding: 12px 16px;
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mixer-program-meta code {
  word-break: break-all;
  font-size: 0.75rem;
}
.mixer-cam-select {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.mixer-cam-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  cursor: pointer;
  user-select: none;
  transition: border-color var(--transition), background var(--transition);
}
.mixer-cam-option:hover { border-color: var(--border-light); }
.mixer-cam-option.selected {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
}
.mixer-cam-option input { margin: 0; }
.mixer-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.mixer-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.mixer-card:hover { border-color: var(--border-light); }
.mixer-card.active {
  border-color: #16a34a;
  box-shadow: 0 0 0 1px rgba(22, 163, 74, 0.35);
}
.mixer-card .camera-player { height: 180px; }
.mixer-card .camera-header { pointer-events: none; }
.mixer-active-badge {
  background: rgba(22, 163, 74, 0.15);
  color: #16a34a;
  border: 1px solid rgba(22, 163, 74, 0.35);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  display: none;
}
.mixer-card.active .mixer-active-badge { display: inline-flex; }
.mixer-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
}
.mixer-status-dot.on { background: #16a34a; box-shadow: 0 0 6px rgba(22, 163, 74, 0.6); }
.mixer-status-dot.rec { background: #ef4444; box-shadow: 0 0 6px rgba(239, 68, 68, 0.6); }
.mixer-session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.mixer-session-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  font-weight: 600;
}
.mixer-tx-persist {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.8rem;
  color: #16a34a;
}
.mixer-audio-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}
.mixer-audio-toggle:hover { background: var(--bg-secondary); }
.mixer-audio-chevron {
  font-size: 1.25rem;
  transition: transform 0.2s ease;
}
#mixerAudioCard.collapsed .mixer-audio-chevron { transform: rotate(-90deg); }
#mixerAudioCard.collapsed #mixerAudioBody { display: none; }
.mixer-audio-modes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.mixer-audio-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.mixer-audio-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
}
.mixer-audio-option input { margin-top: 3px; }
.mixer-audio-option span { display: flex; flex-direction: column; gap: 2px; }
.mixer-audio-option strong { font-size: 0.85rem; }
.mixer-audio-option small { font-size: 0.75rem; color: var(--text-muted); }
.mixer-playlist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mixer-playlist li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--bg-secondary);
}
.mixer-card.audio-active {
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.35);
}
.mixer-card.audio-active:not(.active) {
  border-color: #2563eb;
}
.mixer-audio-badge {
  background: rgba(37, 99, 235, 0.12);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.35);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  display: none;
}
.mixer-card.audio-active .mixer-audio-badge { display: inline-flex; align-items: center; gap: 4px; }
.mixer-card .camera-header { pointer-events: auto; }
.mixer-btn-audio {
  pointer-events: auto;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.mixer-btn-audio:hover,
.mixer-card.audio-active .mixer-btn-audio {
  color: #2563eb;
  border-color: rgba(37, 99, 235, 0.45);
}
