/* ── Google Fonts already loaded in HTML ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ═══════════════════════════════════════════════════════════
   DESIGN TOKENS
════════════════════════════════════════════════════════════ */
:root {
  --bg-base:        #050a15;
  --bg-surface:     #0c1427;
  --bg-card:        rgba(12, 20, 39, 0.7);
  --bg-card-hover:  rgba(18, 30, 58, 0.85);
  --bg-elevated:    rgba(255, 255, 255, 0.05);
  --border:         rgba(255, 255, 255, 0.1);
  --border-subtle:  rgba(255,255,255,0.06);
  --border-glow:    rgba(0,210,255,0.25);

  --text-primary:   #f0f4ff;
  --text-secondary: #8899bb;
  --text-muted:     #4b5a72;

  --cyan:     #00d2ff;
  --purple:   #7b2ff7;
  --violet:   #a855f7;
  --emerald:  #10b981;
  --amber:    #f59e0b;
  --rose:     #f43f5e;

  --grad-brand: linear-gradient(135deg, #00d2ff 0%, #7b2ff7 100%);
  --grad-glow:  radial-gradient(ellipse at 50% 0%, rgba(0,210,255,0.15) 0%, transparent 70%);

  --sidebar-w:  260px;
  --topbar-h:   64px;
  --radius:     16px;
  --radius-sm:  10px;
  --shadow-card: 0 4px 32px rgba(0,0,0,0.4);

  --font-brand: 'Outfit', sans-serif;
  --font-body:  'Inter', sans-serif;
  --transition: 0.22s ease;
}

/* ═══════════════════════════════════════════════════════════
   BASE
════════════════════════════════════════════════════════════ */
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ═══════════════════════════════════════════════════════════
   ANIMATED BACKGROUND ORBS
════════════════════════════════════════════════════════════ */
.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  animation: orb-float 18s ease-in-out infinite;
}
.orb-1 { width: 500px; height: 500px; background: radial-gradient(circle, #00d2ff44, transparent); top: -150px; left: -100px; animation-delay: 0s; }
.orb-2 { width: 600px; height: 600px; background: radial-gradient(circle, #7b2ff744, transparent); top: 40%; right: -200px; animation-delay: -6s; }
.orb-3 { width: 400px; height: 400px; background: radial-gradient(circle, #10b98133, transparent); bottom: -100px; left: 40%; animation-delay: -12s; }
@keyframes orb-float {
  0%, 100% { transform: translateY(0) scale(1); }
  33%       { transform: translateY(-30px) scale(1.05); }
  66%       { transform: translateY(20px) scale(0.97); }
}

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: rgba(5, 10, 21, 0.9);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--border-subtle);
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.brand-icon svg { width: 38px; height: 38px; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-family: var(--font-brand); font-size: 20px; font-weight: 800; color: var(--text-primary); }
.brand-pro {
  font-family: var(--font-brand); font-size: 10px; font-weight: 700;
  background: var(--grad-brand); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; letter-spacing: 2px;
}

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--text-secondary);
  font-size: 14px; font-weight: 500;
  transition: all var(--transition);
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.nav-item.active {
  background: rgba(0,210,255,0.1);
  color: var(--cyan);
  box-shadow: inset 3px 0 0 var(--cyan);
}
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; min-width: 22px; height: 22px;
  background: rgba(0,210,255,0.15); color: var(--cyan);
  font-size: 11px; font-weight: 700;
  border-radius: 11px; display: flex; align-items: center; justify-content: center;
  padding: 0 6px;
}

.sidebar-status {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition);
  box-shadow: 0 0 0 0 transparent;
}
.status-dot.online { background: var(--emerald); box-shadow: 0 0 8px var(--emerald); animation: pulse-dot 2s infinite; }
.status-dot.offline { background: var(--rose); }
@keyframes pulse-dot {
  0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
}

/* ═══════════════════════════════════════════════════════════
   TOPBAR (mobile)
════════════════════════════════════════════════════════════ */
.topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 90;
  height: var(--topbar-h); padding: 0 16px;
  align-items: center; justify-content: space-between;
  background: rgba(5,10,21,0.95);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
}
.topbar-title { font-family: var(--font-brand); font-weight: 700; font-size: 18px; }
.topbar-sync { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.live-indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--emerald); animation: pulse-dot 2s infinite; }
.hamburger { background: none; border: none; cursor: pointer; padding: 8px; display: flex; flex-direction: column; gap: 5px; }
.hamburger span { display: block; width: 22px; height: 2px; background: var(--text-primary); border-radius: 2px; transition: var(--transition); }

/* ═══════════════════════════════════════════════════════════
   MAIN CONTENT
════════════════════════════════════════════════════════════ */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 32px 36px;
  position: relative; z-index: 1;
}

/* ═══════════════════════════════════════════════════════════
   PAGE TRANSITIONS
════════════════════════════════════════════════════════════ */
.page { display: none; animation: fade-up 0.35s ease; }
.page.active { display: block; }
@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════
   PAGE HEADER
════════════════════════════════════════════════════════════ */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: 16px;
  margin-bottom: 28px;
}
.page-title { font-family: var(--font-brand); font-size: 32px; font-weight: 800; line-height: 1; color: var(--text-primary); }
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }
.header-actions { display: flex; align-items: center; gap: 12px; }

.last-sync-pill {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary); font-size: 12px;
  padding: 8px 14px; border-radius: 20px;
}

/* ═══════════════════════════════════════════════════════════
   GLASS CARD
════════════════════════════════════════════════════════════ */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition);
}
.glass-card:hover { border-color: var(--border-glow); }
.card-title { font-family: var(--font-brand); font-size: 18px; font-weight: 600; margin-bottom: 20px; color: var(--text-primary); }

/* ═══════════════════════════════════════════════════════════
   STATS GRID
════════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 22px;
  display: flex; align-items: center; gap: 16px;
  position: relative; overflow: hidden;
  transition: all var(--transition);
  box-shadow: var(--shadow-card);
  cursor: default;
}
.stat-card::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(var(--accent-raw),0.06) 0%, transparent 60%);
  border-radius: inherit;
}
.stat-card:hover { transform: translateY(-3px); border-color: var(--accent,var(--cyan)); box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 20px color-mix(in srgb, var(--accent, var(--cyan)) 20%, transparent); }
.stat-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: rgba(255,255,255,0.05);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; color: var(--accent, var(--cyan)); }
.stat-info { flex: 1; }
.stat-label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.stat-value { display: block; font-family: var(--font-brand); font-size: 28px; font-weight: 700; color: var(--text-primary); }
.stat-ring { width: 44px; height: 44px; flex-shrink: 0; }
.ring-svg { transform: rotate(-90deg); }
.ring-bg  { fill: none; stroke: rgba(255,255,255,0.06); stroke-width: 3; }
.ring-fill { fill: none; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 94.25; stroke-dashoffset: 94.25; transition: stroke-dashoffset 1s ease; }

/* ═══════════════════════════════════════════════════════════
   DASHBOARD ROW
════════════════════════════════════════════════════════════ */
.dashboard-row {
  display: grid; grid-template-columns: 340px 1fr;
  gap: 20px; margin-bottom: 24px;
}
@media (max-width: 960px) { .dashboard-row { grid-template-columns: 1fr; } }

/* Storage donut */
.storage-visual { display: flex; align-items: center; gap: 24px; }
.storage-donut { position: relative; width: 120px; height: 120px; flex-shrink: 0; }
.storage-donut svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.donut-bg  { fill: none; stroke: rgba(255,255,255,0.06); stroke-width: 12; }
.donut-fill { fill: none; stroke: url(#donut-grad); stroke-width: 12; stroke-linecap: round; stroke-dasharray: 251.2; stroke-dashoffset: 251.2; transition: stroke-dashoffset 1.2s ease; }
.donut-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: var(--font-brand);
}
.donut-label span { font-size: 15px; font-weight: 700; }
.donut-label small { font-size: 11px; color: var(--text-muted); }
.storage-legend { display: flex; flex-direction: column; gap: 10px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }

/* Activity feed */
.activity-feed { display: flex; flex-direction: column; gap: 10px; max-height: 220px; overflow-y: auto; }
.activity-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px; color: var(--text-muted); font-size: 13px; }
.activity-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03); font-size: 13px;
  animation: fade-up 0.3s ease;
}
.activity-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.activity-meta { margin-left: auto; font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ═══════════════════════════════════════════════════════════
   DEVICE CARDS
════════════════════════════════════════════════════════════ */
.devices-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.device-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 12px;
  transition: all var(--transition);
}
.device-card:hover { border-color: var(--border-glow); transform: translateY(-2px); }
.device-header { display: flex; align-items: center; gap: 14px; }
.device-avatar {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--grad-brand); display: flex; align-items: center; justify-content: center;
}
.device-avatar svg { width: 24px; height: 24px; color: #fff; }
.device-name { font-weight: 600; font-size: 15px; }
.device-model { font-size: 12px; color: var(--text-muted); }
.device-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.device-stat { text-align: center; }
.device-stat-val { font-family: var(--font-brand); font-size: 18px; font-weight: 700; }
.device-stat-lbl { font-size: 10px; color: var(--text-muted); }
.device-footer { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--text-muted); }
.online-badge { color: var(--emerald); background: rgba(16,185,129,0.1); padding: 3px 8px; border-radius: 20px; }

/* ═══════════════════════════════════════════════════════════
   TABLE
════════════════════════════════════════════════════════════ */
.table-container { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { padding: 10px 14px; text-align: left; color: var(--text-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.03); color: var(--text-primary); vertical-align: middle; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.data-table tr:last-child td { border-bottom: none; }
.loading-cell { text-align: center; color: var(--text-muted); padding: 40px !important; }
.sms-body-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.call-type-in  { color: var(--emerald); }
.call-type-out { color: var(--cyan); }
.call-type-mis { color: var(--rose); }

/* Pagination */
.table-pagination { display: flex; gap: 8px; justify-content: flex-end; padding-top: 16px; flex-wrap: wrap; }
.page-btn { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border-subtle); background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 13px; transition: all var(--transition); }
.page-btn:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.page-btn.active { background: var(--grad-brand); color: #fff; border-color: transparent; }

/* ═══════════════════════════════════════════════════════════
   MEDIA GRID
════════════════════════════════════════════════════════════ */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.media-thumb {
  aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden;
  cursor: pointer; position: relative;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border-subtle);
  transition: all var(--transition);
}
.media-thumb:hover { border-color: var(--cyan); transform: scale(1.03); }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-thumb .media-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: 10px; opacity: 0; transition: opacity var(--transition);
}
.media-thumb:hover .media-overlay { opacity: 1; }
.media-overlay span { font-size: 11px; color: #fff; text-align: center; word-break: break-all; }
.media-video-icon { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.7); border-radius: 6px; padding: 4px 6px; font-size: 12px; }

/* ═══════════════════════════════════════════════════════════
   SEARCH & FILTERS
════════════════════════════════════════════════════════════ */
.search-input {
  padding: 10px 16px; border-radius: 24px;
  border: 1px solid var(--border-subtle);
  background: rgba(255,255,255,0.04); color: var(--text-primary);
  font-family: var(--font-body); font-size: 14px;
  width: 260px; outline: none; transition: all var(--transition);
}
.search-input:focus { border-color: var(--cyan); background: rgba(0,210,255,0.05); box-shadow: 0 0 0 3px rgba(0,210,255,0.1); }
.search-input::placeholder { color: var(--text-muted); }

.filter-tabs { display: flex; gap: 6px; }
.filter-btn {
  padding: 8px 16px; border-radius: 20px; border: 1px solid var(--border-subtle);
  background: transparent; color: var(--text-secondary); font-size: 13px; cursor: pointer;
  transition: all var(--transition);
}
.filter-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.filter-btn.active { background: rgba(0,210,255,0.15); border-color: var(--cyan); color: var(--cyan); }

/* ═══════════════════════════════════════════════════════════
   SETTINGS
════════════════════════════════════════════════════════════ */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 10px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.input-row { display: flex; gap: 8px; }
.form-input {
  flex: 1; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle); background: rgba(255,255,255,0.04);
  color: var(--text-primary); font-family: var(--font-body); font-size: 14px; outline: none;
  transition: all var(--transition);
}
.form-input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0,210,255,0.1); }
.form-hint { font-size: 12px; color: var(--text-muted); }
.connection-test { display: flex; align-items: center; gap: 10px; padding-top: 12px; }
#test-text { font-size: 13px; color: var(--text-secondary); flex: 1; }
.steps-list { display: flex; flex-direction: column; gap: 14px; }
.step { display: flex; gap: 14px; align-items: flex-start; }
.step-num {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--grad-brand); display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.step p { font-size: 13px; color: var(--text-secondary); padding-top: 4px; }
.step code { background: rgba(255,255,255,0.08); padding: 2px 6px; border-radius: 4px; font-size: 12px; color: var(--cyan); }
.apk-info { display: flex; align-items: center; gap: 16px; }
.apk-name { font-weight: 600; }
.apk-desc { font-size: 12px; color: var(--text-muted); }
.apk-icon { padding: 10px; }
.danger-zone { display: flex; flex-direction: column; gap: 16px; }
.danger-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.danger-title { font-size: 14px; font-weight: 600; color: var(--rose); }
.danger-desc  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ═══════════════════════════════════════════════════════════
   BUTTONS
════════════════════════════════════════════════════════════ */
.btn { padding: 10px 20px; border-radius: var(--radius-sm); border: none; cursor: pointer; font-family: var(--font-body); font-weight: 600; font-size: 13px; transition: all var(--transition); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn-primary { background: var(--grad-brand); color: #fff; }
.btn-primary:hover { opacity: 0.85; transform: translateY(-1px); box-shadow: 0 4px 20px rgba(0,210,255,0.3); }
.btn-ghost { background: rgba(255,255,255,0.06); color: var(--text-secondary); border: 1px solid var(--border-subtle); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }
.btn-danger { background: rgba(244,63,94,0.15); color: var(--rose); border: 1px solid rgba(244,63,94,0.3); }
.btn-danger:hover { background: rgba(244,63,94,0.25); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ═══════════════════════════════════════════════════════════
   EMPTY STATE
════════════════════════════════════════════════════════════ */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); font-size: 14px; }
.empty-state.full-width { grid-column: 1 / -1; }
.empty-state svg { margin: 0 auto 12px; display: block; }

/* ═══════════════════════════════════════════════════════════
   TOAST
════════════════════════════════════════════════════════════ */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 14px 20px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  backdrop-filter: blur(16px); border: 1px solid var(--border-subtle);
  min-width: 250px; max-width: 360px;
  animation: toast-in 0.3s ease;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.toast-success { background: rgba(16,185,129,0.2); border-color: rgba(16,185,129,0.4); color: #6ee7b7; }
.toast-error   { background: rgba(244,63,94,0.2);  border-color: rgba(244,63,94,0.4);  color: #fda4af; }
.toast-info    { background: rgba(0,210,255,0.15); border-color: rgba(0,210,255,0.3);  color: var(--cyan); }
@keyframes toast-in  { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }
@keyframes toast-out { to   { opacity:0; transform: translateX(20px); } }

/* ═══════════════════════════════════════════════════════════
   LIGHTBOX
════════════════════════════════════════════════════════════ */
.lightbox {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.9); backdrop-filter: blur(10px);
  align-items: center; justify-content: center; flex-direction: column; gap: 16px;
  cursor: zoom-out;
}
.lightbox.open { display: flex; animation: fade-up 0.2s ease; }
.lightbox-close { position: absolute; top: 20px; right: 24px; background: rgba(255,255,255,0.1); border: none; color: #fff; font-size: 20px; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background var(--transition); }
.lightbox-close:hover { background: rgba(255,255,255,0.2); }
.lightbox-prev, .lightbox-next {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1);
  color: #fff; font-size: 16px; width: 48px; height: 48px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); z-index: 210;
  backdrop-filter: blur(8px);
}
.lightbox-prev { left: 24px; }
.lightbox-next { right: 24px; }
.lightbox-prev:hover, .lightbox-next:hover {
  background: rgba(255,255,255,0.2);
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
  transform: translateY(-50%) scale(1.08);
}
.lightbox-img { max-width: 90vw; max-height: 80vh; border-radius: var(--radius); object-fit: contain; cursor: default; }
.lightbox-caption { color: var(--text-secondary); font-size: 13px; }

/* ═══════════════════════════════════════════════════════════
   SCROLLBAR
════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,0.8); }
  .topbar { display: flex; }
  .main-content { margin-left: 0; padding: 24px 16px; padding-top: calc(var(--topbar-h) + 20px); }
  .page-title { font-size: 24px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .search-input { width: 100%; }
}

/* ═══════════════════════════════════════════════════
   MODALS
═══════════════════════════════════════════════════ */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(6px);
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; animation: fadeIn 0.2s ease; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; width: 100%; max-width: 500px; margin: 20px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5); animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity:0; } to { transform: translateY(0); opacity:1; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 18px; font-weight: 700; color: var(--text-primary); margin: 0; }
.modal-close {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 18px; padding: 4px 8px; border-radius: 8px; transition: background 0.2s;
}
.modal-close:hover { background: var(--bg-elevated); color: var(--text-primary); }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer {
  display: flex; gap: 12px; justify-content: flex-end;
  padding: 16px 24px; border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════
   UPLOAD ZONE
═══════════════════════════════════════════════════ */
.upload-zone {
  border: 2px dashed var(--border); border-radius: 16px;
  padding: 32px; margin-bottom: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  color: var(--text-secondary); cursor: pointer; transition: all 0.2s;
  background: rgba(0,210,255,0.02);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--cyan); background: rgba(0,210,255,0.06);
  color: var(--cyan);
}
.upload-zone p { margin: 0; font-size: 15px; }
.upload-zone span { font-size: 12px; color: var(--text-muted); }
.upload-bar-bg {
  width: 100%; height: 6px; background: var(--bg-elevated);
  border-radius: 99px; overflow: hidden;
}
.upload-bar-fill {
  height: 100%; width: 0%; background: linear-gradient(90deg,var(--cyan),var(--purple));
  border-radius: 99px; transition: width 0.3s ease;
}

/* ═══════════════════════════════════════════════════
   CALL BUTTON
═══════════════════════════════════════════════════ */
.call-btn {
  background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.3);
  color: #10b981; padding: 5px 12px; border-radius: 8px; cursor: pointer;
  font-size: 12px; font-weight: 600; transition: all 0.2s; white-space: nowrap;
}
.call-btn:hover { background: rgba(16,185,129,0.3); transform: scale(1.05); }

/* ═══════════════════════════════════════════════════
   LOCATION LIST
═══════════════════════════════════════════════════ */
.location-item {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.location-item:last-child { border-bottom: none; }
.location-pin {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg,var(--cyan),var(--purple));
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.location-info { flex: 1; }
.location-device { font-weight: 600; color: var(--text-primary); font-size: 14px; }
.location-coords { font-size: 12px; color: var(--text-secondary); margin-top: 2px; font-family: monospace; }
.location-time { font-size: 11px; color: var(--text-muted); }
.location-open-btn {
  background: rgba(0,210,255,0.1); border: 1px solid rgba(0,210,255,0.3);
  color: var(--cyan); padding: 6px 14px; border-radius: 8px;
  font-size: 12px; cursor: pointer; text-decoration: none; white-space: nowrap;
}

/* ═══════════════════════════════════════════════════
   DEVICE FILTER CHIPS
═══════════════════════════════════════════════════ */
.device-filter-bar {
  display: none; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 12px 0; margin-bottom: 4px;
}
.device-chip {
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-secondary); padding: 5px 14px; border-radius: 99px;
  font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s;
  white-space: nowrap;
}
.device-chip:hover { border-color: var(--cyan); color: var(--cyan); }
.device-chip.active {
  background: linear-gradient(90deg,rgba(0,210,255,0.15),rgba(123,47,247,0.15));
  border-color: var(--cyan); color: var(--cyan);
}

/* ═══════════════════════════════════════════════════
   PAGE TOOLBAR (Export/Import buttons)
═══════════════════════════════════════════════════ */
.page-toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px;
}
.toolbar-btn {
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-secondary); padding: 6px 14px; border-radius: 10px;
  font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; gap: 6px;
}
.toolbar-btn:hover { background: var(--bg-card); color: var(--text-primary); border-color: var(--cyan); }
.toolbar-btn.export { color: #10b981; border-color: rgba(16,185,129,0.3); }
.toolbar-btn.import { color: #a855f7; border-color: rgba(168,85,247,0.3); }

/* ═══════════════════════════════════════════════════
   CLEAR DATA CONTROLS
═══════════════════════════════════════════════════ */
.clear-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.clear-select {
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-primary); padding: 8px 12px; border-radius: 10px;
  font-size: 13px; flex: 1; min-width: 140px;
}
.clear-select:focus { outline: none; border-color: var(--cyan); }

/* ═══════════════════════════════════════════════════
   IMPORT MODAL STATUS
═══════════════════════════════════════════════════ */
#import-status {
  font-size: 13px; color: var(--text-secondary); min-height: 18px;
}

/* ═══════════════════════════════════════════════════════════
   ADMIN LOGIN WALL
   A premium glassmorphic visual style with a subtle glow
════════════════════════════════════════════════════════════ */
.login-container {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 5, 12, 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(12, 20, 39, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37),
              inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), border-color var(--transition);
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--purple), transparent);
}

/* Shake Animation for Invalid Credentials */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.login-card.shake {
  animation: shake 0.4s ease-in-out;
  border-color: rgba(244, 63, 94, 0.4);
  box-shadow: 0 0 20px rgba(244, 63, 94, 0.15), 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* ═══════════════════════════════════════════════════════════
   SELECTIVE MEDIA DOWNLOAD CHECKBOXES & HIGHLIGHTS
   ════════════════════════════════════════════════════════════ */
.media-select-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.media-select-checkbox {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  outline: none;
}

.media-thumb:hover .media-select-checkbox {
  border-color: var(--cyan);
}

.media-select-checkbox:checked {
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  border-color: transparent;
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.6);
}

.media-select-checkbox::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
  opacity: 0;
  transition: opacity 0.15s ease-in-out;
}

.media-select-checkbox:checked::after {
  opacity: 1;
}

.media-thumb.selected {
  border-color: var(--cyan) !important;
  box-shadow: 0 0 14px rgba(0, 210, 255, 0.35);
  transform: scale(0.97);
}
