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

/* ============================================================
   S.M.A.R.T C2 — COMMAND INTERFACE v2
   Aesthetic: Dark Editorial - Deep Slate - Precision Data
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

/* ── Token System ─────────────────────────────────────────── */
:root {
  /* Sidebar dark bg */
  --sidebar-bg:     #0b0e1a;
  --sidebar-border: rgba(255,255,255,0.06);
  --sidebar-width:  220px;
  --sidebar-mini:   60px;

  /* Main bg */
  --bg-base:    #0f1117;
  --bg-surface: #161b27;
  --bg-raised:  #1c2333;
  --bg-inset:   #0d1018;
  --bg-overlay: rgba(22,27,39,0.9);
  --bg-hover:   rgba(255,255,255,0.035);

  /* Accent — Electric Violet */
  --accent:        #7c3aed;
  --accent-hi:     #9d5ff5;
  --accent-lo:     #5b21b6;
  --accent-glow:   rgba(124,58,237,0.22);
  --accent-border: rgba(124,58,237,0.3);
  --accent-dim:    rgba(124,58,237,0.08);

  /* Semantic */
  --success:        #10b981;
  --success-dim:    rgba(16,185,129,0.10);
  --success-border: rgba(16,185,129,0.20);
  --warning:        #f59e0b;
  --warning-dim:    rgba(245,158,11,0.10);
  --warning-border: rgba(245,158,11,0.22);
  --danger:         #ef4444;
  --danger-dim:     rgba(239,68,68,0.10);
  --danger-border:  rgba(239,68,68,0.22);
  --info:           #38bdf8;
  --info-dim:       rgba(56,189,248,0.10);

  /* Text */
  --text-primary:   #e8eaf2;
  --text-secondary: #7e8aa8;
  --text-muted:     #4a5270;
  --text-disabled:  #2e3450;
  --text-accent:    #a78bfa;

  /* Borders */
  --border:        rgba(255,255,255,0.06);
  --border-light:  rgba(255,255,255,0.10);
  --border-subtle: rgba(255,255,255,0.03);

  /* Shadows */
  --shadow-sm:   0 1px 4px rgba(0,0,0,0.35);
  --shadow-md:   0 4px 20px rgba(0,0,0,0.45);
  --shadow-lg:   0 12px 40px rgba(0,0,0,0.55);
  --shadow-glow: 0 0 24px var(--accent-glow), 0 0 8px rgba(124,58,237,0.12);

  /* Fonts */
  --font: 'Geist', sans-serif;
  --mono: 'Geist Mono', monospace;

  /* Radii */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 18px;

  /* Transitions */
  --t: 0.18s ease;
  --t-fast: 0.12s ease;
  --t-spring: 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

/* Light Mode */
[data-theme="light"] {
  --sidebar-bg:     #ffffff;
  --sidebar-border: rgba(0,0,0,0.07);
  --bg-base:        #f4f5f9;
  --bg-surface:     #ffffff;
  --bg-raised:      #fafbfd;
  --bg-inset:       #f0f1f7;
  --bg-hover:       rgba(0,0,0,0.025);
  --accent:         #6d28d9;
  --accent-hi:      #7c3aed;
  --accent-lo:      #5b21b6;
  --accent-glow:    rgba(109,40,217,0.15);
  --accent-border:  rgba(109,40,217,0.22);
  --accent-dim:     rgba(109,40,217,0.07);
  --success:        #059669;
  --success-dim:    rgba(5,150,105,0.08);
  --warning:        #d97706;
  --warning-dim:    rgba(217,119,6,0.08);
  --danger:         #dc2626;
  --danger-dim:     rgba(220,38,38,0.08);
  --info:           #0284c7;
  --info-dim:       rgba(2,132,199,0.08);
  --text-primary:   #0c0f1d;
  --text-secondary: #4a5270;
  --text-muted:     #8a92b0;
  --text-disabled:  #c0c5da;
  --text-accent:    #6d28d9;
  --border:         rgba(0,0,0,0.07);
  --border-light:   rgba(0,0,0,0.12);
  --border-subtle:  rgba(0,0,0,0.03);
  --shadow-sm:      0 1px 4px rgba(0,0,0,0.07);
  --shadow-md:      0 4px 20px rgba(0,0,0,0.09);
  --shadow-lg:      0 12px 40px rgba(0,0,0,0.12);
  --shadow-glow:    0 0 20px rgba(109,40,217,0.12);

  /* ── Missing light overrides ── */
  --bg-overlay:         rgba(255,255,255,0.95);
  --bg-void:            #e8e9f0;
  --success-border:     rgba(5,150,105,0.18);
  --warning-border:     rgba(217,119,6,0.18);
  --danger-border:      rgba(220,38,38,0.18);
  --info-border:        rgba(2,132,199,0.18);
  --success-light:      #16a34a;
  --warning-light:      #d97706;
}

/* ── Base ─────────────────────────────────────────────────── */
body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input { font-family: inherit; }
::selection { background: var(--accent-glow); color: var(--text-accent); }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 99px; }

/* Theme transition */
.theme-transitioning,
.theme-transitioning * {
  transition: background-color 0.28s ease, border-color 0.25s ease,
              color 0.15s ease, box-shadow 0.28s ease !important;
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes fade-up   { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:none; } }
@keyframes fade-in   { from { opacity:0; } to { opacity:1; } }
@keyframes slide-in-r { from { opacity:0; transform:translateX(16px); } to { opacity:1; transform:none; } }
@keyframes slide-in-l { from { opacity:0; transform:translateX(-8px); } to { opacity:1; transform:none; } }
@keyframes scale-in  { from { opacity:0; transform:scale(0.94); } to { opacity:1; transform:scale(1); } }
@keyframes pulse-dot {
  0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
  50%      { box-shadow: 0 0 0 5px rgba(16,185,129,0); }
}
@keyframes spin  { to { transform:rotate(360deg); } }
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
@keyframes toast-in { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:none; } }
@keyframes shake {
  0%,100% { transform:translateX(0); }
  20%,60% { transform:translateX(-5px); }
  40%,80% { transform:translateX(5px); }
}
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0; } }
@keyframes grid-scroll { from { background-position:0 0; } to { background-position:40px 40px; } }
@keyframes logo-float {
  from { transform:translateY(0);    filter:drop-shadow(0 0 12px var(--accent)); }
  to   { transform:translateY(-7px); filter:drop-shadow(0 0 24px var(--accent)); }
}

/* ── LAYOUT ───────────────────────────────────────────────── */
.dashboard-layout {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
  overflow: hidden;
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 50;
  will-change: width;
}

.sidebar.mini {
  width: var(--sidebar-mini);
}

/* Accent strip at top */
.sidebar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 50%, transparent 100%);
  opacity: 0.7;
}

/* Header */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0.875rem;
  height: 58px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-mark {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent-hi), var(--accent-lo));
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 0 18px var(--accent-glow), 0 2px 8px rgba(0,0,0,0.3);
  position: relative;
  transition: box-shadow 0.4s ease;
}

/* Server status dot on the logo */
.sidebar-mark .status-ring {
  position: absolute;
  bottom: -2px; right: -2px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text-disabled);
  border: 2px solid var(--sidebar-bg);
  transition: background 0.4s ease;
}
.sidebar-mark .status-ring.online  { background: var(--success); }
.sidebar-mark .status-ring.offline { background: var(--danger); }

/* Radar pulse animation in mini mode */
.sidebar.mini .sidebar-mark::after {
  content: '';
  position: absolute; inset: -4px;
  border-radius: var(--r-lg);
  border: 1.5px solid var(--accent);
  opacity: 0;
  animation: radar-ping 2.4s ease-out infinite;
}
@keyframes radar-ping {
  0%   { transform: scale(0.85); opacity: 0.6; }
  100% { transform: scale(1.4);  opacity: 0; }
}

.sidebar-wordmark {
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--t), transform var(--t);
}

.sidebar-toggle {
  margin-left: auto;
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--t-fast);
}
.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Mini mode: re-center header, enlarge toggle */
.sidebar.mini .sidebar-header {
  justify-content: center;
  padding: 0 0.5rem;
}
.sidebar.mini .sidebar-toggle {
  margin-left: 0;
  width: 32px;
  height: 32px;
  background: var(--accent-dim);
  color: var(--accent-hi);
  border: 1px solid var(--accent-border);
  border-radius: var(--r-md);
}
.sidebar.mini .sidebar-toggle:hover {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-glow);
}
.sidebar.mini .sidebar-mark {
  display: none;
}

/* Expand strip — hover on right edge of collapsed sidebar */
.sidebar-expand-strip {
  display: none;
  position: absolute;
  right: -1px;
  top: 0; bottom: 0;
  width: 4px;
  cursor: pointer;
  z-index: 60;
  transition: width 0.2s ease, background 0.2s ease;
}
.sidebar.mini .sidebar-expand-strip {
  display: block;
}
.sidebar-expand-strip::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 10%, var(--accent) 50%, transparent 90%);
  opacity: 0;
  transition: opacity 0.25s ease;
  border-radius: 0 3px 3px 0;
}
.sidebar-expand-strip:hover::after {
  opacity: 0.5;
  width: 6px;
}
.sidebar-expand-strip:hover {
  width: 6px;
  background: var(--accent-dim);
}

.sidebar.mini .sidebar-wordmark {
  opacity: 0;
  transform: translateX(-6px);
  pointer-events: none;
}
.sidebar.mini .nav-label,
.sidebar.mini .nav-section-title,
.sidebar.mini .sidebar-profile-info,
.sidebar.mini .nav-badge { opacity: 0; pointer-events: none; }

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-title {
  font-family: var(--mono);
  font-size: 0.56rem;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: var(--text-disabled);
  padding: 0.9rem 0.7rem 0.25rem;
  white-space: nowrap;
  transition: opacity var(--t);
  overflow: hidden;
}

/* ---- Nav Item ---- */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.55rem 0.75rem;
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 0.81rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
  border: 1px solid transparent;
  position: relative;
  overflow: visible;
  text-decoration: none;
}

.nav-item i {
  font-size: 1.05rem;
  flex-shrink: 0;
  width: 18px;
  transition: transform 0.2s ease;
}
.nav-label { transition: opacity var(--t), transform var(--t); }

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.nav-item:hover i { transform: scale(1.1); }

/* Active state */
.nav-item.active {
  background: var(--accent-dim);
  color: var(--text-accent);
  border-color: var(--accent-border);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 15%; bottom: 15%;
  width: 3px;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent-lo));
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px var(--accent-glow);
}

.nav-item.danger:hover {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: rgba(220,38,38,0.15);
}

/* Nav Badge */
.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  border-radius: 99px;
  background: var(--warning);
  color: white;
  font-family: var(--mono);
  font-size: 0.57rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  transition: opacity var(--t), transform 0.3s var(--t-spring);
  animation: badge-pop 0.4s var(--t-spring);
}
@keyframes badge-pop {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* Tooltip for mini mode */
.nav-item[data-tooltip] { overflow: visible; }
.sidebar.mini .nav-item[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  pointer-events: none;
  animation: tooltip-in 0.15s ease;
}
.sidebar.mini .nav-item[data-tooltip]:hover::before {
  /* Override the active indicator in mini+tooltip context */
}
.nav-item.active[data-tooltip]:hover::after { border-color: var(--accent-border); }
@keyframes tooltip-in {
  from { opacity: 0; transform: translateY(-50%) translateX(-4px); }
  to   { opacity: 1; transform: translateY(-50%) translateX(0); }
}

/* Profile card at bottom */
.sidebar-profile {
  padding: 0.75rem 0.625rem;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.55rem 0.65rem;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-hover);
  cursor: default;
  overflow: hidden;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.sidebar-profile-card:hover {
  background: var(--accent-dim);
  border-color: var(--accent-border);
}

.sidebar-profile-avatar {
  width: 30px; height: 30px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--accent-hi), var(--accent-lo));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
  letter-spacing: 0.5px;
  position: relative;
}
.sidebar-profile-avatar::after {
  content: '';
  position: absolute;
  bottom: -1px; right: -1px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  border: 1.5px solid var(--sidebar-bg);
}

.sidebar-profile-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  transition: opacity var(--t);
  min-width: 0;
}
.sidebar-profile-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-profile-role {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--accent-hi);
  white-space: nowrap;
}

/* ── MAIN WRAPPER ─────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ── TOP NAVBAR ───────────────────────────────────────────── */
.top-navbar {
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 1.5rem;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 40;
}

/* Search */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0.45rem 0.875rem;
  max-width: 300px;
  width: 100%;
  transition: all var(--t);
}
.search-bar:focus-within {
  border-color: var(--accent-border);
  background: var(--bg-raised);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-bar i { color: var(--text-muted); font-size: 0.875rem; flex-shrink: 0; }
.search-bar input {
  border: none; outline: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.82rem; width: 100%;
}
.search-bar input::placeholder { color: var(--text-muted); }

/* Navbar Right */
.navbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Connection Badge */
.conn-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 99px;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.35s ease;
  white-space: nowrap;
}
.conn-badge .pulse { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.conn-badge.connecting { background: var(--warning-dim); color: var(--warning); border-color: var(--warning-border); }
.conn-badge.online {
  background: var(--success-dim); color: var(--success); border-color: var(--success-border);
}
.conn-badge.online .pulse { animation: pulse-dot 2s infinite; background: var(--success); }
.conn-badge.offline { background: var(--danger-dim); color: var(--danger); border-color: var(--danger-border); }

/* Icon Buttons */
.icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  font-size: 0.95rem;
  transition: all var(--t-fast);
}
.icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Avatar */
.avatar {
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--accent), #6366f1);
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.72rem;
  cursor: pointer;
  border: 1px solid var(--accent-border);
  box-shadow: 0 0 16px var(--accent-glow);
  transition: all var(--t);
}
.avatar:hover { transform: translateY(-1px); box-shadow: 0 0 24px var(--accent-glow); }

/* Theme toggle in navbar */
.theme-toggle {
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  font-size: 0.95rem;
  transition: all var(--t-fast);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text-primary); border-color: var(--accent-border); background: var(--accent-dim); }

/* ── CONTENT AREA ─────────────────────────────────────────── */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem;
}

/* Page Header */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  animation: fade-up 0.28s ease;
}

.page-header-left h1 {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1;
}

.page-header-left p {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 5px;
}

/* ── STAT CARDS ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
  animation: fade-up 0.3s ease both;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.25rem 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: relative;
  overflow: hidden;
  transition: all var(--t);
}

/* Top accent line */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, var(--card-accent, var(--accent)), transparent);
}

/* Glow bg */
.stat-card::after {
  content: '';
  position: absolute;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--card-accent, var(--accent)) 0%, transparent 70%);
  opacity: 0.04;
  right: -30px; top: -30px;
  pointer-events: none;
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card.accent-violet  { --card-accent: var(--accent); }
.stat-card.accent-amber   { --card-accent: var(--warning); }
.stat-card.accent-emerald { --card-accent: var(--success); }

.stat-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: block;
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--text-primary);
  line-height: 1;
}

.stat-value.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.stat-icon.vi { background: var(--accent-dim); color: var(--accent-hi); }
.stat-icon.am { background: var(--warning-dim); color: var(--warning); }
.stat-icon.em { background: var(--success-dim); color: var(--success); }

/* Mini sparkline bars */
.stat-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 24px;
  margin-top: 10px;
}
.stat-bar {
  width: 4px;
  border-radius: 2px;
  background: var(--card-accent, var(--accent));
  opacity: 0.35;
  transition: opacity var(--t);
}
.stat-bar.hi { opacity: 0.8; }
.stat-card:hover .stat-bar { opacity: 0.5; }
.stat-card:hover .stat-bar.hi { opacity: 1; }

/* ── DASHBOARD GRID ───────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 1200px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

/* ── SECTION CARDS ────────────────────────────────────────── */
.section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: visible;  /* allow dropdowns to overflow - was: hidden */
  display: flex;
  flex-direction: column;
  animation: fade-up 0.35s ease both;
}


.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}
.section-title i { color: var(--accent-hi); font-size: 1rem; }

/* ── DEVICE GRID ──────────────────────────────────────────── */
.devices-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 0.75rem;
  padding: 1.1rem;
}

/* Device Card */
.device-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: visible;   /* allow dropdown to overflow card bounds */
  transition: all var(--t);
  animation: fade-up 0.28s ease both;
  position: relative;
}


/* Clip inner content (meta + action) to the card radius without touching .device-card overflow */
.device-card > :not(.device-card-header):not(.dropdown) {
  /* handled individually below */
}
.device-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: var(--bg-inset);
  border-top: 1px solid var(--border-subtle);
}

.device-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.device-card.pulsing {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 1px var(--accent-border), var(--shadow-glow);
}

.device-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem 0.7rem;
}

.device-identity {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.device-avatar {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  color: var(--accent-hi);
  flex-shrink: 0;
}

.device-name {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.device-status-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.online  { background: var(--success); animation: pulse-dot 2.5s infinite; }
.status-dot.offline { background: var(--text-disabled); }

/* Device meta bar */
.device-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: var(--bg-inset);
  border-top: 1px solid var(--border-subtle);
}

.device-meta-item {
  padding: 0.55rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-right: 1px solid var(--border-subtle);
}
.device-meta-item:last-child { border-right: none; }

.meta-label {
  font-family: var(--mono);
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-disabled);
}

.meta-value {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Device action */
.device-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 0.77rem;
  font-weight: 600;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  transition: all var(--t-fast);
  background: transparent;
}
.device-action:hover {
  color: var(--accent-hi);
  background: var(--accent-dim);
}

/* ── ACTIVITY FEED ────────────────────────────────────────── */
.activity-section {
  max-height: 600px;
}

.activity-feed {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 0.6rem 0.75rem;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  transition: all var(--t-fast);
  animation: slide-in-l 0.18s ease;
}
.log-item:hover { background: var(--bg-hover); border-color: var(--border-subtle); }

.log-icon {
  width: 26px; height: 26px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem;
  flex-shrink: 0;
}
.log-icon.info    { background: var(--info-dim); color: var(--info); }
.log-icon.success { background: var(--success-dim); color: var(--success); }
.log-icon.warning { background: var(--warning-dim); color: var(--warning); }
.log-icon.error   { background: var(--danger-dim); color: var(--danger); }

.log-content { flex: 1; min-width: 0; }
.log-title {
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.log-desc {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-time {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--text-disabled);
  flex-shrink: 0;
  padding-top: 2px;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  gap: 0.75rem;
  grid-column: 1/-1;
}
.empty-state i { font-size: 2rem; color: var(--text-disabled); opacity: 0.4; }
.empty-state h3 { font-size: 0.875rem; color: var(--text-muted); font-weight: 600; }
.empty-state p  { font-family: var(--mono); font-size: 0.65rem; color: var(--text-disabled); }

/* ── DROPDOWN ─────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }

.dropdown-btn {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  transition: all var(--t-fast);
}
.dropdown-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.dropdown-content {
  display: none;
  position: absolute;
  right: 0; top: calc(100% + 6px);
  min-width: 185px;
  background: var(--bg-overlay);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: 9000;       /* high enough to always show above everything */
  overflow: hidden;
  backdrop-filter: blur(12px);
}
.dropdown-content.show { display: block; animation: scale-in 0.14s ease; }

.dropdown-header {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.575rem 0.875rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast);
  border-bottom: 1px solid var(--border-subtle);
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-dim); }
.dropdown-divider { height: 1px; background: var(--border); }

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 0.55rem 1.1rem;
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  transition: all var(--t-fast);
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent); color: white; border-color: var(--accent);
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hi);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-light);
}
.btn-outline:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger {
  background: var(--danger); color: white; border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* ── MODALS ───────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  z-index: 9000;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; animation: fade-in 0.18s ease; }

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-xl);
  padding: 2rem;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: scale-in 0.2s cubic-bezier(0.16,1,0.3,1);
}

.modal-icon {
  width: 50px; height: 50px;
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 1.25rem;
}
.modal-icon.danger  { background: var(--danger-dim);  color: var(--danger); }
.modal-icon.primary { background: var(--accent-dim);  color: var(--accent-hi); }

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.6rem;
  color: var(--text-primary);
}

.modal-desc {
  font-size: 0.83rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 1.5rem;
}

.modal-input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: var(--bg-raised);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.875rem;
  outline: none;
  margin-bottom: 1.25rem;
  transition: all var(--t);
}
.modal-input:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── TOASTS ───────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 99999;
  display: flex;
  flex-direction: column-reverse;
  gap: 12px;
  pointer-events: none;
  max-width: 360px;
  width: calc(100vw - 3rem);
}

@keyframes toast-slide-in {
  0% { opacity: 0; transform: translateX(30px) translateY(10px) scale(0.95); filter: blur(5px); }
  100% { opacity: 1; transform: translateX(0) translateY(0) scale(1); filter: blur(0); }
}
@keyframes toast-slide-out {
  0% { opacity: 1; transform: translateX(0) scale(1); max-height: 120px; margin-bottom: 0; filter: blur(0); }
  100% { opacity: 0; transform: translateX(40px) scale(0.9); max-height: 0; margin-bottom: -12px; filter: blur(3px); }
}
@keyframes toast-progress {
  from { width: 100%; }
  to   { width: 0%; }
}

.toast-notif {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-overlay, rgba(20, 20, 20, 0.8));
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid var(--border-light, rgba(255, 255, 255, 0.12));
  border-radius: 18px;
  box-shadow: 0 16px 40px -8px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.06);
  pointer-events: all;
  animation: toast-slide-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s;
  color: var(--text-primary);
}
.toast-notif:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 20px 48px -10px rgba(0,0,0,0.5), 0 8px 16px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.1);
  border-color: var(--border, rgba(255, 255, 255, 0.2));
}
.toast-notif.dismissing {
  animation: toast-slide-out 0.35s cubic-bezier(0.5, 0, 0.2, 1) forwards;
  pointer-events: none;
}

/* Subtle glowing accent line on top */
.toast-notif::before {
  content: '';
  position: absolute;
  left: 0; top: 0; right: 0; height: 1.5px;
  background: linear-gradient(90deg, transparent, var(--tn-accent, var(--primary)), transparent);
  opacity: 0.7;
}

/* Progress bar auto-dismiss at the bottom */
.toast-progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 2.5px;
  background: var(--tn-accent, var(--primary));
  opacity: 0.8;
  animation: toast-progress var(--tn-dur, 6s) linear forwards;
  box-shadow: 0 0 10px var(--tn-accent, var(--primary));
  border-radius: 0 4px 4px 0;
}

/* Modern App-Icon style */
.toast-notif-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.01) 100%);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 10px var(--tn-bg, rgba(0,0,0,0.1)), inset 0 1px 0 rgba(255,255,255,0.1);
  color: var(--tn-accent, var(--primary));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  position: relative;
}
/* Icon inner glow */
.toast-notif-icon::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  box-shadow: inset 0 0 12px var(--tn-bg, transparent);
  opacity: 0.5; pointer-events: none;
}

.toast-notif-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }

.toast-notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}
.toast-notif-cat {
  font-family: var(--mono, monospace);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tn-accent, var(--primary));
}
.toast-notif-time {
  font-family: var(--mono, monospace);
  font-size: 0.62rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.toast-notif-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.toast-notif-msg {
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.toast-notif-close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.8rem;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(4px);
  margin-left: 2px;
}
.toast-notif-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  transform: scale(1.1) rotate(90deg);
  border-color: rgba(255, 255, 255, 0.15);
}

/* ── Legacy .toast compatibility ── */
.toast { display: none !important; }



/* ── SKELETON ──────────────────────────────────────────── */
@keyframes skeleton-shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}

.skeleton {
  /* Uses only surface-level vars that are correctly overridden in both themes */
  background: linear-gradient(
    90deg,
    var(--bg-surface)  0%,
    var(--bg-inset)   40%,
    var(--bg-raised)  50%,
    var(--bg-inset)   60%,
    var(--bg-surface) 100%
  );
  background-size: 600px 100%;
  animation: skeleton-shimmer 1.6s ease infinite;
}

.device-card-skeleton {
  height: 130px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  opacity: 0.7;
}

/* ── AUTH PAGE ────────────────────────────────────────────── */
@keyframes grid-pan { from { background-position:0 0; } to { background-position:40px 40px; } }

.auth-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100dvh;
}

.auth-hero {
  position: relative;
  background: var(--bg-inset);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

.auth-hero-bg {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--accent-dim) 1px, transparent 1px),
    linear-gradient(90deg, var(--accent-dim) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: grid-pan 20s linear infinite;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 40%, transparent 100%);
}

.auth-hero-content {
  position: relative; z-index: 2;
  text-align: center; padding: 2.5rem; max-width: 420px;
}

.auth-hero-logo {
  font-size: 3.5rem;
  color: var(--accent-hi);
  display: block; margin-bottom: 1.5rem;
  animation: logo-float 3s ease-in-out infinite alternate;
}

.auth-hero-content h1 {
  font-size: 2rem; font-weight: 900;
  color: var(--text-primary);
  letter-spacing: -0.04em; margin-bottom: 0.75rem;
}

.auth-hero-content p {
  font-size: 0.83rem;
  color: var(--text-secondary);
  line-height: 1.75;
}

.auth-hero-tags {
  display: flex; flex-wrap: wrap; gap: 7px;
  justify-content: center; margin-top: 1.75rem;
}
.hero-tag {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 11px;
  background: var(--bg-raised);
  border: 1px solid var(--border-light);
  border-radius: 99px;
  font-family: var(--mono); font-size: 0.65rem;
  color: var(--text-secondary);
}
.hero-tag i { color: var(--success); }

.auth-panel {
  display: flex; align-items: center; justify-content: center;
  padding: 3rem 2rem;
  background: var(--bg-base);
  position: relative;
}

.auth-theme-toggle {
  position: absolute; top: 1.25rem; right: 1.25rem;
}

.auth-card { width: 100%; max-width: 390px; }

.auth-header { margin-bottom: 2.25rem; }
.auth-header h2 {
  font-size: 1.7rem; font-weight: 900;
  color: var(--text-primary); letter-spacing: -0.04em;
  margin-bottom: 0.375rem;
}
.auth-header p { font-size: 0.83rem; color: var(--text-muted); }

.auth-input-group { margin-bottom: 1rem; }
.auth-input-group label {
  display: block;
  font-family: var(--mono); font-size: 0.68rem;
  font-weight: 500; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-secondary); margin-bottom: 0.425rem;
}
.auth-input-wrapper { position: relative; }
.auth-input-icon {
  position: absolute; left: 0.875rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 1rem; pointer-events: none;
}
.auth-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.6rem;
  background: var(--bg-raised);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  color: var(--text-primary); font-family: var(--font); font-size: 0.875rem;
  outline: none; transition: all var(--t);
}
.auth-input:focus { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-glow); }
.auth-input::placeholder { color: var(--text-muted); }
.auth-toggle-pass {
  position: absolute; right: 0.875rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 1rem; background: none; border: none;
  transition: color var(--t-fast); cursor: pointer;
}
.auth-toggle-pass:hover { color: var(--text-secondary); }

.auth-options {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.auth-checkbox-group {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.8rem; color: var(--text-secondary); cursor: pointer;
}
.auth-checkbox-group input { accent-color: var(--accent); }
.auth-link { font-size: 0.8rem; color: var(--accent-hi); font-weight: 500; }
.auth-link:hover { text-decoration: underline; }

.auth-btn {
  width: 100%; padding: 0.825rem 1.5rem;
  background: var(--accent); color: white;
  border: none; border-radius: var(--r-md);
  font-family: var(--font); font-size: 0.9rem; font-weight: 800;
  letter-spacing: -0.02em; cursor: pointer;
  transition: all var(--t); display: flex; align-items: center;
  justify-content: center; gap: 8px;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.auth-btn:hover:not(:disabled) {
  background: var(--accent-hi); transform: translateY(-2px);
  box-shadow: 0 8px 28px var(--accent-glow);
}
.auth-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.auth-footer {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 1.75rem; padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-family: var(--mono); font-size: 0.62rem; color: var(--text-disabled);
}
.auth-footer i { color: var(--success); }

.shake-animation { animation: shake 0.4s cubic-bezier(0.36,0.07,0.19,0.97); }

@media (max-width: 768px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}

/* -- RESPONSIVE -- */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .content-area { padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   UX IMPROVEMENTS
   ============================================================ */

/* Search highlight */
mark.hl {
  background: var(--accent-dim);
  color: var(--accent-hi);
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 700;
}

/* Stats trend indicator */
.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 99px;
  vertical-align: middle;
  animation: trend-pop 0.4s var(--t-spring);
}
@keyframes trend-pop {
  0%   { transform: scale(0) translateY(4px); opacity: 0; }
  70%  { transform: scale(1.15) translateY(0); }
  100% { transform: scale(1); opacity: 1; }
}
.stat-trend.up   { background: var(--success-dim); color: var(--success); }
.stat-trend.down { background: var(--danger-dim);  color: var(--danger);  }

/* Sort dropdown */
.sort-wrap {
  position: relative;
}
.sort-panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: 6px;
  min-width: 160px;
  z-index: 200;
  animation: scale-in 0.15s cubic-bezier(0.16,1,0.3,1);
}
.sort-panel.open { display: block; }
.sort-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border-radius: var(--r-sm);
  font-size: 0.79rem;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all var(--t-fast);
  cursor: pointer;
}
.sort-opt i { font-size: 0.9rem; width: 16px; }
.sort-opt:hover { background: var(--bg-hover); color: var(--text-primary); }
.sort-opt.active { background: var(--accent-dim); color: var(--text-accent); font-weight: 600; }

/* View toggle active */
.icon-btn.active-view {
  background: var(--accent-dim);
  color: var(--accent-hi);
  border: 1px solid var(--accent-border);
}

/* List view for device cards */
.devices-container.list-view {
  grid-template-columns: 1fr;
  gap: 4px;
}
.devices-container.list-view .device-card {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: 1fr;
  align-items: center;
  padding: 0.6rem 1rem;
  gap: 12px;
}
.devices-container.list-view .device-card-header {
  align-items: center;
}
.devices-container.list-view .device-meta { display: none; }
.devices-container.list-view .device-action {
  border: none;
  margin: 0;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  border-radius: var(--r-md);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  width: auto;
  flex-shrink: 0;
}
.devices-container.list-view .device-action i:last-child { display: none; }

/* Auto-refresh countdown ring */
.refresh-ring-wrap {
  position: relative;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.refresh-ring-wrap svg.ring {
  position: absolute;
  inset: -3px;
  width: calc(100% + 6px);
  height: calc(100% + 6px);
  transform: rotate(-90deg);
  pointer-events: none;
  opacity: 0.6;
}
.refresh-ring-wrap svg.ring circle {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 94;
  stroke-dashoffset: 94;
  transition: stroke-dashoffset 0.5s linear;
}
.refresh-ring-wrap .icon-btn {
  width: 100%;
  height: 100%;
}

/* Device card slide-in for new devices */
@keyframes card-slide-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.device-card.new-arrival {
  animation: card-slide-in 0.4s cubic-bezier(0.16,1,0.3,1) both;
  border-color: var(--accent-border) !important;
  box-shadow: 0 0 0 1px var(--accent-border), var(--shadow-sm);
}

/* Copy device name cursor */
.device-name.copyable {
  cursor: pointer;
  transition: color var(--t-fast);
}
.device-name.copyable:hover { color: var(--accent-hi); }

/* Connection uptime */
.conn-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-muted);
  white-space: nowrap;
  transition: all 0.4s ease;
}
.conn-badge .pulse {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-disabled);
  flex-shrink: 0;
}
.conn-badge.online  { border-color: var(--success-dim, rgba(5,150,105,0.2)); color: var(--success); }
.conn-badge.online .pulse  { background: var(--success); box-shadow: 0 0 0 3px rgba(5,150,105,0.2); animation: pulse-ring 1.5s infinite; }
.conn-badge.offline { border-color: var(--danger-dim); color: var(--danger); }
.conn-badge.offline .pulse { background: var(--danger); }
.conn-badge.connecting { border-color: var(--accent-border); color: var(--text-muted); }
.conn-badge.connecting .pulse { background: var(--accent); animation: pulse-ring 1s infinite; }
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(5,150,105,0.5); }
  70%  { box-shadow: 0 0 0 5px rgba(5,150,105,0); }
  100% { box-shadow: 0 0 0 0 rgba(5,150,105,0); }
}

/* Keyboard shortcut hint (Ctrl+R etc.) */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-inset);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  box-shadow: 0 1px 0 var(--border-light);
}
