/* ============================================================
   GuardMe Admin Dashboard — Dark Theme
   ============================================================ */

:root {
  --bg:          #0a0e1a;
  --bg-card:     #0f1629;
  --bg-input:    #0d1526;
  --bg-hover:    #14203a;
  --bg-sidebar:  #080c18;
  --border:      #1e2d45;
  --border-light:#243350;
  --text:        #e2e8f0;
  --text-muted:  #64748b;
  --text-sec:    #94a3b8;
  --accent:      #3b82f6;
  --accent-h:    #2563eb;
  --green:       #22c55e;
  --red:         #ef4444;
  --orange:      #f59e0b;
  --purple:      #8b5cf6;
  --teal:        #14b8a6;
  --sidebar-w:   240px;
  --header-h:    60px;
  --radius:      8px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
ul { list-style: none; }

/* ── Layout ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.25s ease;
}
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Sidebar logo ──────────────────────────────────────────── */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.logo-shield {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.logo-text { font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.logo-sub  { font-size: 10px; color: var(--text-muted); letter-spacing: 1px; text-transform: uppercase; }

/* ── Sidebar nav ───────────────────────────────────────────── */
.sidebar-nav {
  padding: 12px 8px;
  flex: 1;
  overflow-y: auto;
}
.nav-section { font-size: 10px; color: var(--text-muted); text-transform: uppercase;
               letter-spacing: 1px; padding: 12px 12px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-sec);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
  text-decoration: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: rgba(59,130,246,0.15); color: var(--accent); }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Header ────────────────────────────────────────────────── */
.header {
  height: var(--header-h);
  background: var(--bg-card);
  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;
}
.header-left  { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.page-title   { font-size: 17px; font-weight: 600; }
.menu-toggle  { display: none; background: none; border: none; color: var(--text); cursor: pointer; font-size: 20px; }

/* ── Content ───────────────────────────────────────────────── */
.content { padding: 24px; flex: 1; max-width: 1400px; }

/* ── Flash messages ────────────────────────────────────────── */
.alert {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13.5px;
  animation: slideIn 0.2s ease;
}
.alert-success { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.3); color: #4ade80; }
.alert-error   { background: rgba(239,68,68,0.12);  border: 1px solid rgba(239,68,68,0.3);  color: #f87171; }
@keyframes slideIn { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:none; } }
.alert-close { margin-left: auto; background: none; border: none; color: inherit; cursor: pointer; font-size: 16px; opacity: 0.7; }
.alert-close:hover { opacity: 1; }

/* ── Stat cards ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; flex-direction: column; gap: 8px;
}
.stat-card .label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .value { font-size: 32px; font-weight: 700; line-height: 1; }
.stat-card .sub   { font-size: 12px; color: var(--text-sec); }
.stat-card.blue   { border-top: 3px solid var(--accent); }
.stat-card.green  { border-top: 3px solid var(--green); }
.stat-card.orange { border-top: 3px solid var(--orange); }
.stat-card.purple { border-top: 3px solid var(--purple); }
.stat-card.gray   { border-top: 3px solid var(--text-muted); }

/* ── View toggle (Detections / No Detections) ──────────────── */
.view-toggle { display: flex; gap: 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); width: fit-content; }
.view-toggle-btn { padding: 8px 18px; font-size: 13px; font-weight: 500; color: var(--text-sec); background: var(--bg-card); text-decoration: none; transition: background 0.15s, color 0.15s; }
.view-toggle-btn:first-child { border-right: 1px solid var(--border); }
.view-toggle-btn.active { background: var(--accent); color: #fff; }
.view-toggle-btn:not(.active):hover { background: var(--bg-hover); color: var(--text); }

/* ── System status ─────────────────────────────────────────── */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.status-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
}
.status-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.status-dot.ok   { background: var(--green); box-shadow: 0 0 8px rgba(34,197,94,0.5); }
.status-dot.fail { background: var(--red);   box-shadow: 0 0 8px rgba(239,68,68,0.5); }
.status-name { font-size: 13px; font-weight: 500; }
.status-text { font-size: 11px; color: var(--text-muted); }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.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; }
.card-body   { padding: 0; }

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(30,45,69,0.5);
  vertical-align: middle;
  font-size: 13px;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.02); }
.col-actions { width: 1%; white-space: nowrap; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: none;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.98); }
.btn-primary  { background: var(--accent);  color: #fff; }
.btn-success  { background: var(--green);   color: #fff; }
.btn-danger   { background: var(--red);     color: #fff; }
.btn-warning  { background: var(--orange);  color: #fff; }
.btn-ghost    { background: rgba(255,255,255,0.06); color: var(--text-sec); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px;  font-size: 11px; }
.actions { display: flex; gap: 6px; align-items: center; }

/* ── Badges / pills ────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px; font-weight: 500;
  white-space: nowrap;
}
.badge-green  { background: rgba(34,197,94,0.15);  color: #4ade80; }
.badge-red    { background: rgba(239,68,68,0.15);   color: #f87171; }
.badge-blue   { background: rgba(59,130,246,0.15);  color: #93c5fd; }
.badge-orange { background: rgba(245,158,11,0.15);  color: #fbbf24; }
.badge-gray   { background: rgba(100,116,139,0.15); color: var(--text-sec); }

/* ── Forms ─────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-label {
  font-size: 12px; font-weight: 500;
  color: var(--text-sec); text-transform: uppercase; letter-spacing: 0.4px;
}
.form-input, .form-select, .form-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input[readonly]    { opacity: 0.6; cursor: default; }
.form-hint { font-size: 11px; color: var(--text-muted); }
.form-select option { background: var(--bg-card); }

/* ── Toggle switch ─────────────────────────────────────────── */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0;
  background: var(--border-light); border-radius: 22px;
  cursor: pointer; transition: background 0.2s;
}
.slider::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff;
  left: 3px; top: 3px;
  transition: transform 0.2s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ── Camera toggle button (AJAX) ───────────────────────────── */
.cam-toggle {
  background: rgba(239,68,68,0.15); color: #f87171;
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 20px; padding: 3px 10px; font-size: 12px;
  cursor: pointer; transition: all 0.15s;
}
.cam-toggle.active {
  background: rgba(34,197,94,0.15); color: #4ade80;
  border-color: rgba(34,197,94,0.3);
}

/* ── Password field ────────────────────────────────────────── */
.pw-wrap { position: relative; }
.pw-wrap .form-input { padding-right: 36px; }
.pw-eye {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 15px;
}
.pw-copy {
  background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: 6px; padding: 9px 10px; color: var(--text-sec);
  cursor: pointer; font-size: 13px; flex-shrink: 0;
  transition: background 0.15s;
}
.pw-copy:hover { background: var(--border); color: var(--text); }
.pw-row { display: flex; gap: 8px; align-items: stretch; }

/* ── Schedule builder ──────────────────────────────────────── */
.schedule-builder {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.schedule-head {
  display: grid;
  grid-template-columns: 110px 60px 1fr 1fr;
  gap: 12px;
  padding: 8px 16px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
}
.schedule-row {
  display: grid;
  grid-template-columns: 110px 60px 1fr 1fr;
  gap: 12px; align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(30,45,69,0.4);
  transition: background 0.1s;
}
.schedule-row:last-child { border-bottom: none; }
.schedule-row:hover { background: rgba(255,255,255,0.02); }
.schedule-row .day-name { font-size: 13px; font-weight: 500; }
.sched-time {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px;
  color: var(--text); font-size: 13px;
  outline: none; width: 100%;
  transition: border-color 0.15s;
}
.sched-time:focus { border-color: var(--accent); }
.sched-time:disabled { opacity: 0.35; cursor: not-allowed; }
.sched-time::-webkit-calendar-picker-indicator { filter: invert(1) opacity(0.4); cursor: pointer; }

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: 6px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.pagination .page-info { color: var(--text-muted); font-size: 12px; margin-left: auto; }
.page-btn {
  min-width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; font-size: 13px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-sec);
  text-decoration: none; transition: all 0.15s;
}
.page-btn:hover { background: var(--bg-hover); color: var(--text); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn.disabled { opacity: 0.3; pointer-events: none; }

/* ── Thumbnails ────────────────────────────────────────────── */
.thumb {
  width: 140px; height: 105px;
  border-radius: 6px; object-fit: cover;
  background: var(--bg-hover);
  display: block;
}
.thumb-placeholder {
  width: 140px; height: 105px;
  border-radius: 6px;
  background: var(--bg-hover);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: var(--text-muted);
}
.thumb-clickable {
  cursor: zoom-in;
  transition: opacity 0.15s, transform 0.15s;
}
.thumb-clickable:hover { opacity: 0.85; transform: scale(1.03); }

/* ── Thumbnail lightbox ────────────────────────────────────── */
.lightbox-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.88);
  align-items: center; justify-content: center;
  cursor: zoom-out;
}
.lightbox-overlay.open { display: flex; }
.lightbox-img {
  max-width: 92vw; max-height: 88vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
  cursor: default;
  object-fit: contain;
}
.lightbox-close {
  position: fixed; top: 18px; right: 24px;
  font-size: 32px; color: #fff; cursor: pointer;
  line-height: 1; opacity: 0.8; user-select: none;
}
.lightbox-close:hover { opacity: 1; }
.lightbox-caption {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  font-size: 13px; color: rgba(255,255,255,0.75);
  background: rgba(0,0,0,0.5); padding: 6px 14px;
  border-radius: 20px; white-space: nowrap; max-width: 80vw;
  overflow: hidden; text-overflow: ellipsis;
}

/* ── Detection classes ─────────────────────────────────────── */
.det-classes { display: flex; flex-wrap: wrap; gap: 4px; }
.det-class {
  font-size: 11px; padding: 2px 6px; border-radius: 4px;
}
.det-class.person { background: rgba(59,130,246,0.15); color: #93c5fd; }
.det-class.car, .det-class.truck, .det-class.bus, .det-class.motorcycle
  { background: rgba(245,158,11,0.15); color: #fbbf24; }

/* ── Filter bar ────────────────────────────────────────────── */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 160px; flex: 1; }
.filter-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }

/* ── Telegram cards ────────────────────────────────────────── */
.tg-client-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
  margin-bottom: 12px;
}
.tg-client-info { flex: 1; min-width: 200px; }
.tg-client-name { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.tg-client-meta { font-size: 12px; color: var(--text-sec); }
.tg-client-schedule { font-size: 12px; color: var(--text-muted); white-space: pre; margin-top: 6px; }
.tg-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Bot status banner ─────────────────────────────────────── */
.bot-banner {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 24px;
}
.bot-icon { font-size: 28px; }
.bot-info .title { font-size: 15px; font-weight: 600; }
.bot-info .sub   { font-size: 12px; color: var(--text-sec); }
.bot-actions { margin-left: auto; }

/* ── Page header row ───────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h2 { font-size: 20px; font-weight: 700; }

/* ── Section title ─────────────────────────────────────────── */
.section-title { font-size: 13px; font-weight: 600; color: var(--text-sec); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.4px; }

/* ── Two-column layout ─────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── Refresh indicator ─────────────────────────────────────── */
#refresh-badge {
  font-size: 11px; color: var(--text-muted);
  display: flex; align-items: center; gap: 4px;
}
#refresh-badge .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--text-muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .form-grid { grid-template-columns: 1fr; }
  .two-col   { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .schedule-head, .schedule-row { grid-template-columns: 80px 50px 1fr 1fr; }
  .content { padding: 16px; }
  .filter-bar { flex-direction: column; }
  .tg-client-card { flex-direction: column; }
  .bot-banner { flex-wrap: wrap; }
  .bot-actions { margin-left: 0; width: 100%; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .schedule-head { display: none; }
  .schedule-row { grid-template-columns: 80px 44px 1fr 1fr; gap: 6px; }
}

/* ── Scrollbar styling ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── FTP lock status icons ─────────────────────────────────── */
.ftp-lock {
  font-size: .9rem;
  cursor: default;
  margin-left: 4px;
}
.ftp-open   { filter: none; opacity: .9; }
.ftp-closed { filter: grayscale(0) brightness(0.9); opacity: .9; }

/* ── Client shield status badges ───────────────────────────── */
.client-shield {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .78rem;
  font-weight: 700;
}
.client-shield.armed {
  background: rgba(34,197,94,.15);
  color: var(--green);
  border: 1px solid rgba(34,197,94,.3);
}
.client-shield.disarmed {
  background: rgba(100,116,139,.12);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ── Client controls widget (dashboard) ────────────────────── */
.client-controls-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.client-control-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.client-control-name {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.client-control-cameras {
  font-size: .75rem;
  color: var(--text-muted);
}
.client-control-btns {
  flex-shrink: 0;
}

/* ── Arm/Disarm event log badges ────────────────────────────── */
.event-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .78rem;
  font-weight: 700;
}
.event-badge.arm {
  background: rgba(34,197,94,.15);
  color: var(--green);
}
.event-badge.disarm {
  background: rgba(100,116,139,.12);
  color: var(--text-muted);
}
.event-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.event-dot.arm    { background: var(--green); }
.event-dot.disarm { background: var(--text-muted); }

/* ── Camera card grid ──────────────────────────────────────── */
.camera-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.camera-card {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.camera-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.camera-card-name {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
}
.camera-card-path {
  font-size: .7rem;
  color: var(--text-muted);
  font-family: monospace;
}

/* Credentials block */
.cred-block {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}
.cred-item {
  flex: 1;
  padding: 14px 16px;
  border-right: 1px solid var(--border);
}
.cred-item:last-child { border-right: none; }

.cred-label {
  display: block;
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.cred-value-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cred-value {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 2px;
  word-break: break-all;
}
.cred-pass { color: var(--accent); }

/* Copy credential button */
.btn-copy-cred {
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: .7rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.btn-copy-cred:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-copy-cred.copied { background: var(--green); color: #fff; border-color: var(--green); }

/* Setup string */
.setup-string-box {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.setup-string-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.setup-string-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.setup-string {
  font-family: 'Courier New', Courier, monospace;
  font-size: .75rem;
  color: var(--text-sec);
  word-break: break-all;
  flex: 1;
}

/* Camera card actions */
.camera-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card);
}

/* ── Storage widget ────────────────────────────────────────── */
.storage-card { margin-bottom: 24px; }

.storage-disk-label {
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--text-sec);
  margin-bottom: 6px;
}
.storage-disk-pct { font-weight: 600; color: var(--text); }

.storage-bar-track {
  width: 100%;
  height: 10px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 6px;
}
.storage-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .4s ease;
}
.storage-bar-fill.warn   { background: var(--orange); }
.storage-bar-fill.danger { background: var(--red); }

.storage-disk-sub {
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.storage-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 12px;
}
.storage-metric {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  text-align: center;
}
.storage-metric-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.storage-metric-label {
  font-size: .7rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Login page ────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-wrap {
  width: 100%;
  max-width: 400px;
  padding: 1rem;
}

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

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-shield {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: .5rem;
}

.login-brand {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.5px;
}

.login-brand-sub {
  font-size: .8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: .25rem;
}

.login-form .form-group { margin-bottom: 1.25rem; }

.login-remember {
  display: flex;
  align-items: center;
  margin-bottom: 1.5rem;
  font-size: .875rem;
  color: var(--text-sec);
}

.login-remember input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.login-btn {
  width: 100%;
  padding: .75rem;
  font-size: 1rem;
}

.login-footer {
  text-align: center;
  margin-top: 2rem;
  font-size: .75rem;
  color: var(--text-muted);
}

/* ── Logout button ─────────────────────────────────────────── */
.btn-logout {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  padding: .375rem .875rem;
  border-radius: var(--radius);
  font-size: .8rem;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.btn-logout:hover {
  color: var(--red);
  border-color: var(--red);
}

/* ── Chat ID helper ─────────────────────────────────────────── */
.chatid-helper {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.chatid-instructions {
  margin-bottom: 12px;
  font-size: .8rem;
  color: var(--text-sec);
  line-height: 1.6;
}

.chatid-instructions strong {
  display: block;
  color: var(--text);
  margin-bottom: 6px;
  font-size: .825rem;
}

.chatid-instructions ol {
  list-style: decimal;
  padding-left: 18px;
}

.chatid-instructions code {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: .78rem;
  color: var(--accent);
}

/* ── Info alert banner ──────────────────────────────────────── */
.alert-info {
  background: rgba(59,130,246,.08);
  border: 1px solid rgba(59,130,246,.25);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: .82rem;
  color: var(--text-sec);
  line-height: 1.6;
}
.alert-info strong {
  display: block;
  color: var(--text);
  margin-bottom: 4px;
}

/* ── Performance colour-coded cells ────────────────────────── */
.perf-cell {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  padding: 6px 10px;
}
.perf-green  { color: var(--green); }
.perf-orange { color: var(--orange); }
.perf-red    { color: var(--red); }

/* ── Performance log viewer ─────────────────────────────────── */
.perf-log {
  font-family: 'Courier New', Courier, monospace;
  font-size: .72rem;
  color: var(--text-sec);
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.perf-log-line {
  padding: 2px 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.6;
  word-break: break-all;
}
.perf-log-line:last-child { border-bottom: none; }

/* ── Server Performance metric cards ───────────────────────── */
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 20px 16px;
}
.metric-label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.metric-value { font-size: 36px; font-weight: 700; line-height: 1.1; margin-bottom: 8px; transition: color 0.4s; }
.metric-bar-track { height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.metric-bar-fill  { height: 100%; border-radius: 3px; transition: width 0.6s ease, background-color 0.4s ease; }
.metric-sub { font-size: 12px; color: var(--text-sec); }

/* ── Server health widget (dashboard) ──────────────────────── */
.server-health-pct { font-size: 26px; font-weight: 700; }
.pct-green  { color: var(--green); }
.pct-orange { color: var(--orange); }
.pct-red    { color: var(--red); }
.badge-red  { background: rgba(239,68,68,0.15); color: #ef4444; }
