:root {
  --bg-main: #0a0a0c;
  --bg-sidebar: #0e0e11;
  --bg-card: rgba(22, 22, 26, 0.75);
  --bg-card-hover: rgba(30, 30, 36, 0.85);
  --bg-elevated: #16161a;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(255, 255, 255, 0.28);
  --primary: #ffffff;
  --primary-glow: rgba(255, 255, 255, 0.15);
  --accent-blue: #94a3b8;
  --accent-green: #22c55e;
  --accent-amber: #eab308;
  --accent-rose: #ef4444;
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  -webkit-tap-highlight-color: transparent;
}

html {
  overflow-x: hidden;
  overflow-y: auto;
  scroll-behavior: smooth;
}

body {
  background: radial-gradient(circle at 50% 0%, #17171c 0%, #0c0c0e 60%, #060607 100%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Ambient glow */
.ambient {
  position: fixed;
  width: 550px;
  height: 550px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  filter: blur(100px);
  opacity: 0.04;
}
.ambient-1 { top: -150px; right: -150px; background: #ffffff; }
.ambient-2 { bottom: -200px; left: -200px; background: #52525b; }

/* Top Header */
header {
  height: 64px;
  background: rgba(14, 14, 17, 0.92);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 50;
  flex-shrink: 0;
  position: sticky;
  top: 0;
}

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

.brand-logo-container {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.2));
}

.brand-text h1 {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-text span {
  color: var(--primary);
  font-weight: 800;
}

.brand-sub {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.btn-lock-session {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-lock-session:hover {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.4);
  color: var(--accent-rose);
}

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

.broker-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.3s ease;
}
.dot.online { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }
.dot.offline { background: var(--accent-rose); box-shadow: 0 0 8px var(--accent-rose); }
.dot.connecting { background: var(--accent-amber); animation: pulse 1.5s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* App Container */
.app-container {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 64px);
  position: relative;
  z-index: 10;
}

/* Sidebar */
aside {
  width: 320px;
  background: rgba(9, 13, 21, 0.75);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
}

.sidebar-header {
  padding: 1.25rem 1rem 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 700;
}

.btn-add {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-add:hover {
  background: var(--primary);
  color: #000;
  box-shadow: 0 0 12px var(--primary-glow);
}

.device-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.device-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.device-item:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.device-item.active {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
}

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

.device-name {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.device-type-icon {
  font-size: 1.1rem;
}

.device-id {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.device-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.device-actions {
  display: flex;
  gap: 4px;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s;
}

.btn-icon:hover { color: var(--accent-rose); }

/* Main Content Area */
main {
  flex: 1;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

/* Device Banner */
.device-banner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(12px);
}

.banner-left h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.banner-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.banner-meta span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.banner-stats {
  display: flex;
  gap: 20px;
}

.stat-pill {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  text-align: center;
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
}

.stat-val {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
}

/* Tabs Navigation */
.tabs-nav {
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  background: var(--bg-card);
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--text-main);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Tab Panels */
.tab-panel {
  display: none;
  animation: fadeIn 0.25s ease forwards;
}

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

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

/* Grid Layouts */
.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(12px);
}

.card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.btn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.cmd-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 14px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.cmd-btn:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.cmd-btn:active {
  transform: translateY(0);
}

.cmd-btn.btn-primary {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.cmd-btn.btn-primary:hover {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

.cmd-btn.btn-danger {
  border-color: rgba(244, 63, 94, 0.3);
  color: #ff758f;
}
.cmd-btn.btn-danger:hover {
  background: var(--accent-rose);
  color: #fff;
  border-color: var(--accent-rose);
  box-shadow: 0 0 16px rgba(244, 63, 94, 0.3);
}

/* Surveillance Viewer */
.surveillance-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.viewport-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.viewport-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.viewport-body {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}

.viewport-body img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.viewport-placeholder {
  color: var(--text-dim);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.viewport-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
}

/* File Explorer */
.file-explorer {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.explorer-toolbar {
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drives-shelf {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.drive-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.2s;
}

.drive-chip:hover, .drive-chip.active {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.breadcrumb-bar {
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.btn-up {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}

.file-list {
  max-height: 480px;
  overflow-y: auto;
}

.file-row {
  display: grid;
  grid-template-columns: 28px 1fr 140px 180px 120px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}

.file-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.file-icon {
  font-size: 1.1rem;
}

.file-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size, .file-date {
  color: var(--text-dim);
  font-size: 0.78rem;
  font-family: var(--font-mono);
}

.file-ops {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.btn-file-op {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-file-op:hover {
  color: var(--primary);
  border-color: var(--primary);
}

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

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

.modal-box {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  width: 90%;
  max-width: 440px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-box h3 {
  font-size: 1.2rem;
  margin-bottom: 1.25rem;
  font-weight: 700;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.form-control {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--primary);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.btn-sec {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  border: none;
  color: #000;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 0 16px var(--primary-glow);
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  animation: slideIn 0.3s ease forwards;
}

@keyframes slideIn {
  from { transform: translateX(50px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Volume Slider */
.volume-control {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
}

.volume-slider {
  flex: 1;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
}
.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

/* Security Passcode Gate Overlay */
.auth-gate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 9, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.auth-gate-overlay.unlocked {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: rgba(18, 18, 22, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8), 0 20px 40px rgba(0, 0, 0, 0.6);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  animation: cardFadeIn 0.4s ease-out;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
}

@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-logo-wrapper {
  width: 72px;
  height: 72px;
  margin: 0 auto 1.25rem auto;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
}

.auth-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
}

.auth-card h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.auth-card h2 span {
  color: var(--primary);
}

.auth-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.auth-input-group {
  position: relative;
  margin-bottom: 1rem;
}

.auth-input-group input {
  width: 100%;
  padding: 14px 44px 14px 16px;
  background: rgba(8, 12, 20, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 1rem;
  letter-spacing: 0.05em;
  outline: none;
  transition: all 0.2s;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

.auth-input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 16px var(--primary-glow), inset 0 2px 4px rgba(0,0,0,0.5);
}

.btn-toggle-eye {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.btn-toggle-eye:hover {
  opacity: 1;
}

.auth-error {
  color: var(--accent-rose);
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 1rem;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.btn-auth-unlock {
  width: 100%;
  padding: 13px 20px;
  background: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  color: #000000;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(255, 255, 255, 0.15);
  transition: all 0.2s;
}

.btn-auth-unlock:hover {
  transform: translateY(-1px);
  background: #e4e4e7;
  box-shadow: 0 6px 25px rgba(255, 255, 255, 0.25);
}

.auth-footer-tag {
  margin-top: 1.75rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-mono);
}

/* Responsive */
@media (max-width: 900px) {
  .app-container {
    flex-direction: column;
    min-height: auto;
  }
  aside {
    width: 100%;
    height: auto;
    max-height: 280px;
    position: relative;
    top: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  main {
    padding: 1rem;
  }
  .surveillance-container { grid-template-columns: 1fr; }
  .file-row { grid-template-columns: 28px 1fr 100px; }
  .file-date { display: none; }
  .banner-stats { flex-wrap: wrap; }
}

