/* ============================================================
   HeyStar Control Panel — CSS
   Theme: Clean Light · Indigo Accent · Modern Enterprise
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg-base:       #f0f4f8;
  --bg-surface:    #ffffff;
  --bg-raised:     #f7f9fc;
  --bg-overlay:    #eef2f7;
  --bg-deep:       #e4eaf2;
  --border:        #dde3ec;
  --border-bright: #bfcad8;
  --border-focus:  #6366f1;

  --indigo:        #6366f1;
  --indigo-dark:   #4f46e5;
  --indigo-light:  #818cf8;
  --indigo-glow:   rgba(99, 102, 241, 0.10);
  --indigo-subtle: rgba(99, 102, 241, 0.06);

  --emerald:       #10b981;
  --emerald-dim:   #059669;
  --emerald-glow:  rgba(16, 185, 129, 0.10);
  --amber:         #f59e0b;
  --amber-dim:     #d97706;
  --amber-glow:    rgba(245, 158, 11, 0.10);
  --rose:          #f43f5e;
  --rose-dim:      #e11d48;
  --rose-glow:     rgba(244, 63, 94, 0.10);
  --sky:           #0ea5e9;
  --sky-glow:      rgba(14, 165, 233, 0.10);

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-dim:       #cbd5e1;

  --shadow-sm:  0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md:  0 4px 12px rgba(15,23,42,0.08), 0 2px 4px rgba(15,23,42,0.04);
  --shadow-lg:  0 12px 32px rgba(15,23,42,0.10), 0 4px 8px rgba(15,23,42,0.06);
  --shadow-xl:  0 24px 64px rgba(15,23,42,0.14), 0 8px 16px rgba(15,23,42,0.06);

  --sidebar-w:  248px;
  --header-h:   60px;
  --radius:     6px;
  --radius-lg:  10px;
  --radius-xl:  14px;

  --font-display: 'Plus Jakarta Sans', sans-serif;
  --font-ui:      'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;
  --transition:   0.15s cubic-bezier(0.4, 0, 0.2, 1);

  /* ── Chrome theme variables (header + sidebar) ─────────── */
  --chrome-header-bg:      linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  --chrome-header-shadow:  0 2px 16px rgba(30,27,75,0.45);
  --chrome-sidebar-bg:     #1e1b4b;
  --chrome-sidebar-shadow: 2px 0 16px rgba(30,27,75,0.25);
  --chrome-nav-text:       #a5b4fc;
  --chrome-nav-active-bg:  rgba(99,102,241,0.35);
  --chrome-nav-active-border: rgba(99,102,241,0.5);
  --chrome-nav-active-bar: #818cf8;
  --chrome-nav-section:    #4338ca;
  --chrome-nav-hover-bg:   rgba(255,255,255,0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  min-height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

/* ── Page visibility ─────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ── Header ─────────────────────────────────────────────────── */
.header {
  grid-column: 1 / -1;
  background: var(--chrome-header-bg);
  border-bottom: none;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--chrome-header-shadow);
}
.header-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.header-logo-mark {
  width: 34px; height: 34px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.header-logo-mark svg { width: 16px; height: 16px; color: #fff; }
.header-logo-text {
  font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 800;
  letter-spacing: -0.3px; color: #ffffff;
}
.header-logo-sub {
  font-family: var(--font-mono); font-size: 0.58rem; color: #a5b4fc;
  letter-spacing: 1.5px; text-transform: uppercase; display: block;
  margin-top: -3px; font-weight: 500;
}
.header-divider { width: 1px; height: 24px; background: rgba(255,255,255,0.15); }
.header-device-selector {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius); padding: 7px 12px;
  font-family: var(--font-mono); font-size: 0.72rem;
  color: #c7d2fe; cursor: pointer;
  transition: all var(--transition); min-width: 210px; font-weight: 500;
}
.header-device-selector:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.35);
  color: #ffffff;
}
.device-status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 2px rgba(16,185,129,0.3);
  flex-shrink: 0;
  animation: pulse-dot 2.5s ease-in-out infinite;
}
.device-status-dot.offline { background: #fb7185; box-shadow: 0 0 0 2px rgba(251,113,133,0.3); animation: none; }
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 2px rgba(16,185,129,0.3); }
  50%       { box-shadow: 0 0 0 5px rgba(16,185,129,0.1); }
}
.header-spacer { flex: 1; }
.header-stat { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.header-stat-value { font-family: var(--font-mono); font-size: 0.9rem; font-weight: 600; color: #e0e7ff; }
.header-stat-label { font-size: 0.58rem; text-transform: uppercase; letter-spacing: 1px; color: #818cf8; font-weight: 500; }
.header-btn {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: #c7d2fe; cursor: pointer; transition: all var(--transition);
}
.header-btn:hover {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.35);
  color: #ffffff;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  background: var(--chrome-sidebar-bg);
  border-right: none;
  padding: 20px 0;
  overflow-y: auto;
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  box-shadow: var(--chrome-sidebar-shadow);
}
.nav-section { padding: 0 14px; margin-bottom: 2px; }
.nav-section-label {
  font-size: 0.62rem; font-weight: 600; letter-spacing: 1.5px;
  text-transform: uppercase; color: #4338ca; padding: 14px 8px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius);
  text-decoration: none; color: #a5b4fc;
  font-size: 0.875rem; font-weight: 500; cursor: pointer;
  transition: all var(--transition); border: 1px solid transparent; position: relative;
}
.nav-item:hover {
  color: #ffffff;
  background: var(--chrome-nav-hover-bg);
  border-color: rgba(255,255,255,0.08);
}
.nav-item.active {
  color: #ffffff;
  background: var(--chrome-nav-active-bg);
  border-color: var(--chrome-nav-active-border);
  font-weight: 600;
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; background: var(--chrome-nav-active-bar); border-radius: 0 3px 3px 0;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.6; }
.nav-item:hover svg { opacity: 0.9; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto; background: #f59e0b; color: #fff;
  font-family: var(--font-mono); font-size: 0.6rem; font-weight: 700;
  padding: 2px 6px; border-radius: 20px; min-width: 18px; text-align: center;
}

/* ── Main ────────────────────────────────────────────────────── */
.main {
  padding: 28px;
  overflow-y: auto;
  background: var(--bg-base);
  height: calc(100vh - var(--header-h));
  min-width: 0;
}

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-title { font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; letter-spacing: -0.5px; color: var(--text-primary); line-height: 1.1; }
.page-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 15px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; background: var(--bg-surface);
}
.card-title { font-family: var(--font-display); font-size: 0.9rem; font-weight: 700; letter-spacing: -0.1px; color: var(--text-primary); }
.card-title-icon {
  width: 30px; height: 30px; background: var(--indigo-subtle);
  border: 1px solid rgba(99,102,241,0.2); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; color: var(--indigo);
}
.card-title-icon svg { width: 14px; height: 14px; }
.card-header-action { margin-left: auto; }
.card-body { padding: 20px; }

/* ── Stat cards ─────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  position: relative; overflow: hidden;
  transition: all var(--transition); box-shadow: var(--shadow-sm);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--border-bright); }
.stat-card::after {
  content: ''; position: absolute; top: 0; right: 0; width: 80px; height: 80px;
  background: radial-gradient(circle at top right, var(--indigo-glow), transparent 70%);
}
.stat-card.amber::after { background: radial-gradient(circle at top right, var(--amber-glow), transparent 70%); }
.stat-card.red::after   { background: radial-gradient(circle at top right, var(--rose-glow), transparent 70%); }
.stat-card.green::after { background: radial-gradient(circle at top right, var(--emerald-glow), transparent 70%); }
.stat-icon {
  width: 36px; height: 36px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
  background: var(--indigo-subtle); color: var(--indigo); border: 1px solid rgba(99,102,241,0.15);
}
.stat-card.amber .stat-icon { background: var(--amber-glow);   color: var(--amber);   border-color: rgba(245,158,11,0.2); }
.stat-card.red   .stat-icon { background: var(--rose-glow);    color: var(--rose);    border-color: rgba(244,63,94,0.2); }
.stat-card.green .stat-icon { background: var(--emerald-glow); color: var(--emerald); border-color: rgba(16,185,129,0.2); }
.stat-icon svg { width: 17px; height: 17px; }
.stat-value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 800; color: var(--text-primary); line-height: 1; letter-spacing: -1px; }
.stat-label { font-size: 0.75rem; font-weight: 500; text-transform: uppercase; color: var(--text-muted); margin-top: 5px; letter-spacing: 0.3px; }
.stat-trend { font-size: 0.7rem; color: var(--emerald); margin-top: 8px; font-weight: 500; }
.stat-trend.down { color: var(--rose); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 2px solid var(--border); }
thead th {
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--text-muted); padding: 11px 16px;
  text-align: left; white-space: nowrap; background: var(--bg-raised);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:hover { background: #f8f9fd; }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 13px 16px; font-size: 0.875rem; color: var(--text-secondary); vertical-align: middle; }
tbody td:first-child { color: var(--text-primary); font-weight: 500; }
.td-mono { font-family: var(--font-mono); font-size: 0.78rem; color: var(--indigo); font-weight: 500; }
.td-time { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.3px;
}
.badge-teal  { background: rgba(99,102,241,0.1);  color: var(--indigo);      border: 1px solid rgba(99,102,241,0.2); }
.badge-amber { background: var(--amber-glow);      color: var(--amber-dim);   border: 1px solid rgba(245,158,11,0.25); }
.badge-red   { background: var(--rose-glow);       color: var(--rose-dim);    border: 1px solid rgba(244,63,94,0.25); }
.badge-green { background: var(--emerald-glow);    color: var(--emerald-dim); border: 1px solid rgba(16,185,129,0.25); }
.badge-blue  { background: var(--sky-glow);        color: var(--sky);         border: 1px solid rgba(14,165,233,0.25); }
.badge-muted { background: var(--bg-overlay);      color: var(--text-muted);  border: 1px solid var(--border); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: var(--radius); border: 1px solid transparent;
  font-family: var(--font-ui); font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
  white-space: nowrap; text-decoration: none; line-height: 1; letter-spacing: -0.1px;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-primary { background: var(--indigo); color: #fff; border-color: var(--indigo); box-shadow: 0 1px 3px rgba(99,102,241,0.3); }
.btn-primary:hover { background: var(--indigo-dark); border-color: var(--indigo-dark); box-shadow: 0 4px 12px rgba(99,102,241,0.4); transform: translateY(-1px); }
.btn-secondary { background: #fff; color: var(--indigo); border-color: var(--indigo); }
.btn-secondary:hover { background: var(--indigo-subtle); box-shadow: 0 2px 8px rgba(99,102,241,0.15); }
.btn-danger { background: #fff; color: var(--rose); border-color: var(--rose); }
.btn-danger:hover { background: var(--rose-glow); box-shadow: 0 2px 8px rgba(244,63,94,0.15); }
.btn-amber { background: var(--amber); color: #fff; border-color: var(--amber); box-shadow: 0 1px 3px rgba(245,158,11,0.3); }
.btn-amber:hover { background: var(--amber-dim); box-shadow: 0 4px 12px rgba(245,158,11,0.3); transform: translateY(-1px); }
.btn-ghost { background: var(--bg-raised); color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-bright); background: var(--bg-overlay); }
.btn-sm { padding: 5px 11px; font-size: 0.78rem; }
.btn-lg { padding: 11px 24px; font-size: 0.95rem; }
.btn-icon { padding: 8px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); letter-spacing: -0.1px; }
.form-label .required { color: var(--rose); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 12px; color: var(--text-primary); font-family: var(--font-ui);
  font-size: 0.875rem; transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%; outline: none;
}
.form-input::placeholder { color: var(--text-dim); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.form-select {
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.72rem; color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── Toggles ─────────────────────────────────────────────────── */
.toggle-group { display: flex; align-items: center; gap: 12px; }
.toggle { position: relative; width: 40px; height: 22px; cursor: pointer; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--bg-deep);
  border: 1px solid var(--border); border-radius: 11px; transition: all var(--transition);
}
.toggle-slider::before {
  content: ''; position: absolute; width: 14px; height: 14px;
  left: 3px; top: 50%; transform: translateY(-50%);
  background: var(--text-dim); border-radius: 50%;
  transition: all var(--transition); box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle input:checked + .toggle-slider { background: var(--indigo); border-color: var(--indigo); }
.toggle input:checked + .toggle-slider::before { background: #fff; left: 22px; box-shadow: 0 1px 4px rgba(99,102,241,0.4); }
.toggle-label { font-size: 0.875rem; color: var(--text-secondary); }

/* ── Range ───────────────────────────────────────────────────── */
.range-group { display: flex; flex-direction: column; gap: 6px; }
.range-header { display: flex; justify-content: space-between; align-items: center; }
.range-value { font-family: var(--font-mono); font-size: 0.85rem; color: var(--indigo); font-weight: 600; background: var(--indigo-subtle); padding: 1px 8px; border-radius: 20px; }
input[type=range] { -webkit-appearance: none; width: 100%; height: 5px; background: var(--bg-deep); border-radius: 3px; outline: none; cursor: pointer; border: 1px solid var(--border); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--indigo); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(99,102,241,0.4), 0 0 0 1px rgba(99,102,241,0.2); cursor: pointer; }

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--border); gap: 2px; margin-bottom: 20px; }
.tab { padding: 9px 16px; font-size: 0.85rem; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; cursor: pointer; transition: all var(--transition); margin-bottom: -2px; }
.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--indigo); border-bottom-color: var(--indigo); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45); backdrop-filter: blur(6px);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-xl);
  width: 90%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  transform: translateY(12px) scale(0.99);
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: var(--shadow-xl);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-lg { max-width: 760px; }
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; background: var(--bg-raised); }
.modal-title { font-family: var(--font-display); font-size: 1rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.2px; flex: 1; }
.modal-close { width: 28px; height: 28px; background: var(--bg-overlay); border: 1px solid var(--border); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: var(--text-muted); cursor: pointer; transition: all var(--transition); flex-shrink: 0; }
.modal-close:hover { color: var(--rose); border-color: var(--rose); background: var(--rose-glow); }
.modal-close svg { width: 12px; height: 12px; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--bg-raised); }

/* ── Toast ───────────────────────────────────────────────────── */
#toast-container { position: fixed; top: calc(var(--header-h) + 12px); right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: flex-start; gap: 10px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 16px; min-width: 290px; max-width: 370px; box-shadow: var(--shadow-lg); animation: toast-in 0.3s cubic-bezier(0.34,1.56,0.64,1); border-left: 3px solid var(--indigo); }
.toast.error   { border-left-color: var(--rose); }
.toast.warning { border-left-color: var(--amber); }
.toast.success { border-left-color: var(--emerald); }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px) scale(0.96); } to { opacity: 1; transform: translateX(0) scale(1); } }
.toast-icon { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; color: var(--indigo); }
.toast.error   .toast-icon { color: var(--rose); }
.toast.warning .toast-icon { color: var(--amber); }
.toast.success .toast-icon { color: var(--emerald); }
.toast-body { flex: 1; }
.toast-title { font-weight: 600; font-size: 0.875rem; color: var(--text-primary); }
.toast-msg   { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; font-family: var(--font-mono); }

/* ── Activity feed ───────────────────────────────────────────── */
.activity-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--indigo-subtle); border: 2px solid rgba(99,102,241,0.2); display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700; color: var(--indigo); flex-shrink: 0; }
.activity-avatar.stranger { color: var(--rose); background: var(--rose-glow); border-color: rgba(244,63,94,0.2); }
.activity-content { flex: 1; min-width: 0; }
.activity-name { font-weight: 600; font-size: 0.875rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.activity-time { font-family: var(--font-mono); font-size: 0.62rem; color: var(--text-dim); flex-shrink: 0; padding-top: 4px; }

/* ── Misc components ─────────────────────────────────────────── */
.conn-bar { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 16px; display: flex; align-items: center; gap: 16px; margin-bottom: 20px; font-size: 0.78rem; box-shadow: var(--shadow-sm); }
.conn-bar-item { display: flex; align-items: center; gap: 6px; color: var(--text-muted); }
.conn-bar-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--emerald); box-shadow: 0 0 0 2px rgba(16,185,129,0.2); }
.conn-bar-item .dot.off { background: var(--text-dim); box-shadow: none; }
.conn-bar-item strong { color: var(--text-primary); font-weight: 600; }
.conn-bar-divider { width: 1px; height: 14px; background: var(--border); }

.progress-bar { height: 5px; background: var(--bg-deep); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--indigo), var(--indigo-light)); border-radius: 3px; transition: width 0.5s ease; }

.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--indigo); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay { position: absolute; inset: 0; background: rgba(255,255,255,0.75); display: flex; align-items: center; justify-content: center; border-radius: inherit; z-index: 10; backdrop-filter: blur(2px); }

.empty-state { padding: 48px 20px; text-align: center; color: var(--text-muted); }
.empty-state-icon { width: 52px; height: 52px; margin: 0 auto 16px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-dim); }
.empty-state-icon svg { width: 22px; height: 22px; }
.empty-state-text { font-size: 0.875rem; color: var(--text-muted); }

.pagination { display: flex; align-items: center; gap: 6px; padding: 14px 20px; border-top: 1px solid var(--border); justify-content: flex-end; background: var(--bg-raised); }
.page-btn { width: 32px; height: 32px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); cursor: pointer; font-family: var(--font-mono); font-size: 0.78rem; transition: all var(--transition); }
.page-btn:hover { border-color: var(--indigo); color: var(--indigo); background: var(--indigo-subtle); }
.page-btn.active { background: var(--indigo); color: #fff; border-color: var(--indigo); }
.page-btn svg { width: 12px; height: 12px; }

.terminal { background: #1e293b; border: 1px solid #334155; border-radius: var(--radius); padding: 16px; font-family: var(--font-mono); font-size: 0.75rem; color: #94a3b8; max-height: 220px; overflow-y: auto; line-height: 1.7; }
.terminal .t-dim   { color: #475569; }
.terminal .t-ok    { color: #34d399; }
.terminal .t-error { color: #fb7185; }
.terminal .t-warn  { color: #fbbf24; }
.terminal .t-info  { color: #60a5fa; }

/* ── Utilities ───────────────────────────────────────────────── */
.text-teal   { color: var(--indigo); }
.text-amber  { color: var(--amber); }
.text-red    { color: var(--rose); }
.text-green  { color: var(--emerald); }
.text-muted  { color: var(--text-muted); }
.text-mono   { font-family: var(--font-mono); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

/* ── Responsive ──────────────────────────────────────────────── */
/* ════════════════════════════════════════════════════════════
   CHROME THEMES — applied via data-theme on <body>
   ════════════════════════════════════════════════════════════ */

/* Indigo (default) */
[data-theme="indigo"],
html[data-theme="indigo"] body,
:root {
  --chrome-header-bg:         linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  --chrome-header-shadow:     0 2px 16px rgba(30,27,75,0.45);
  --chrome-sidebar-bg:        #1e1b4b;
  --chrome-sidebar-shadow:    2px 0 16px rgba(30,27,75,0.25);
  --chrome-nav-text:          #a5b4fc;
  --chrome-nav-active-bg:     rgba(99,102,241,0.35);
  --chrome-nav-active-border: rgba(99,102,241,0.5);
  --chrome-nav-active-bar:    #818cf8;
  --chrome-nav-section:       #4338ca;
  --chrome-nav-hover-bg:      rgba(255,255,255,0.08);
}

/* Slate */
[data-theme="slate"], html[data-theme="slate"] body {
  --chrome-header-bg:         linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  --chrome-header-shadow:     0 2px 16px rgba(15,23,42,0.5);
  --chrome-sidebar-bg:        #0f172a;
  --chrome-sidebar-shadow:    2px 0 16px rgba(15,23,42,0.3);
  --chrome-nav-text:          #94a3b8;
  --chrome-nav-active-bg:     rgba(148,163,184,0.15);
  --chrome-nav-active-border: rgba(148,163,184,0.3);
  --chrome-nav-active-bar:    #38bdf8;
  --chrome-nav-section:       #334155;
  --chrome-nav-hover-bg:      rgba(255,255,255,0.06);
}

/* Emerald */
[data-theme="emerald"], html[data-theme="emerald"] body {
  --chrome-header-bg:         linear-gradient(135deg, #064e3b 0%, #065f46 100%);
  --chrome-header-shadow:     0 2px 16px rgba(6,78,59,0.5);
  --chrome-sidebar-bg:        #064e3b;
  --chrome-sidebar-shadow:    2px 0 16px rgba(6,78,59,0.3);
  --chrome-nav-text:          #6ee7b7;
  --chrome-nav-active-bg:     rgba(16,185,129,0.25);
  --chrome-nav-active-border: rgba(16,185,129,0.45);
  --chrome-nav-active-bar:    #34d399;
  --chrome-nav-section:       #065f46;
  --chrome-nav-hover-bg:      rgba(255,255,255,0.08);
}

/* Rose */
[data-theme="rose"], html[data-theme="rose"] body {
  --chrome-header-bg:         linear-gradient(135deg, #4c0519 0%, #881337 100%);
  --chrome-header-shadow:     0 2px 16px rgba(76,5,25,0.5);
  --chrome-sidebar-bg:        #4c0519;
  --chrome-sidebar-shadow:    2px 0 16px rgba(76,5,25,0.3);
  --chrome-nav-text:          #fda4af;
  --chrome-nav-active-bg:     rgba(244,63,94,0.25);
  --chrome-nav-active-border: rgba(244,63,94,0.45);
  --chrome-nav-active-bar:    #fb7185;
  --chrome-nav-section:       #881337;
  --chrome-nav-hover-bg:      rgba(255,255,255,0.08);
}

/* Amber */
[data-theme="amber"], html[data-theme="amber"] body {
  --chrome-header-bg:         linear-gradient(135deg, #451a03 0%, #78350f 100%);
  --chrome-header-shadow:     0 2px 16px rgba(69,26,3,0.5);
  --chrome-sidebar-bg:        #451a03;
  --chrome-sidebar-shadow:    2px 0 16px rgba(69,26,3,0.3);
  --chrome-nav-text:          #fcd34d;
  --chrome-nav-active-bg:     rgba(245,158,11,0.25);
  --chrome-nav-active-border: rgba(245,158,11,0.45);
  --chrome-nav-active-bar:    #fbbf24;
  --chrome-nav-section:       #78350f;
  --chrome-nav-hover-bg:      rgba(255,255,255,0.08);
}

/* Zinc (light sidebar) */
[data-theme="zinc"], html[data-theme="zinc"] body {
  --chrome-header-bg:         linear-gradient(135deg, #27272a 0%, #3f3f46 100%);
  --chrome-header-shadow:     0 2px 16px rgba(39,39,42,0.5);
  --chrome-sidebar-bg:        #27272a;
  --chrome-sidebar-shadow:    2px 0 16px rgba(39,39,42,0.3);
  --chrome-nav-text:          #a1a1aa;
  --chrome-nav-active-bg:     rgba(161,161,170,0.15);
  --chrome-nav-active-border: rgba(161,161,170,0.3);
  --chrome-nav-active-bar:    #e4e4e7;
  --chrome-nav-section:       #3f3f46;
  --chrome-nav-hover-bg:      rgba(255,255,255,0.07);
}


/* ── Responsive — Tablet (≤900px) ────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 220px; }
  .form-row { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .header-device-selector { min-width: 150px; }
  .header-logo-sub { display: none; }
}

/* ── Responsive — Mobile (≤640px) ────────────────────────────── */
@media (max-width: 640px) {

  /* Layout: stack vertically, sidebar becomes a drawer */
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) 1fr;
    max-height: none;
    overflow: visible;
  }

  /* Sidebar: off-screen drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    z-index: 500;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
    overflow-y: auto;
    padding-top: calc(var(--header-h) + 8px);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* Overlay behind open sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 490;
    backdrop-filter: blur(2px);
  }
  .sidebar-overlay.open { display: block; }

  /* Header: compact on mobile */
  .header {
    padding: 0 12px;
    gap: 8px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 400;
  }

  /* Hamburger button (mobile only) */
  .header-hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: var(--radius);
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s;
  }
  .header-hamburger:hover { background: rgba(255,255,255,0.20); }

  /* Hide elements that don't fit on small header */
  .header-device-selector { display: none; }
  .header-stat { display: none; }
  .header-divider { display: none; }
  .header-logo-sub { display: none; }
  #btn-sync-time { display: none; }
  #btn-open-door { display: none !important; }

  /* Shrink logo text */
  .header-logo-text { font-size: 1rem; }

  /* Main content: account for fixed header */
  .main {
    padding: 12px;
    margin-top: var(--header-h);
    height: auto;
    min-height: calc(100vh - var(--header-h));
    overflow-y: auto;
  }

  /* Page header: stack actions below title on mobile */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .page-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }
  .page-actions .btn { flex: 1; min-width: 120px; }

  /* Tables: horizontal scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 480px; }

  /* Cards: full width */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid-auto { grid-template-columns: 1fr; }

  /* Modals: full screen on mobile */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100% !important;
    width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
    overflow-y: auto;
  }

  /* Forms */
  .form-row { grid-template-columns: 1fr; gap: 8px; }
  .form-input, .form-select { font-size: 16px; } /* prevent iOS zoom */

  /* User menu: position from right */
  #user-menu-wrap #user-dropdown {
    right: -8px;
    min-width: 220px;
  }
  #user-name-badge { display: none; }

  /* Pagination */
  .pagination { padding: 8px 12px; }

  /* Hide complex table columns on mobile */
  .hide-mobile { display: none !important; }
}

/* ── Show hamburger only on mobile ───────────────────────────── */
.header-hamburger { display: none; }
@media (max-width: 640px) {
  .header-hamburger { display: flex; }
}

