/* ==========================================================================
   SVOBODA VPN ADMIN - ULTRA-PREMIUM CYBER-STEALTH DESIGN SYSTEM
   ========================================================================== */

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

:root {
  /* Typography */
  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  /* Surfaces & Canvas (Deep Obsidian) */
  --bg-canvas: #06080e;
  --bg-card: rgba(13, 19, 33, 0.72);
  --bg-card-hover: rgba(22, 30, 52, 0.85);
  --bg-card-solid: #0d1322;
  --bg-input: rgba(255, 255, 255, 0.04);
  --bg-input-focus: rgba(255, 255, 255, 0.07);

  /* Borders & Dividers */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-card: rgba(255, 255, 255, 0.1);
  --border-highlight: rgba(99, 102, 241, 0.45);
  --border-success: rgba(16, 185, 129, 0.45);
  --border-danger: rgba(244, 63, 94, 0.45);

  /* Typography Colors */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-dim: #475569;

  /* Primary Brand (Electric Indigo / Violet) */
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-primary-glow: rgba(99, 102, 241, 0.35);
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
  --accent-gradient-hover: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #c026d3 100%);

  /* Semantic Accents */
  --accent-success: #10b981;
  --accent-success-bg: rgba(16, 185, 129, 0.12);
  --accent-danger: #f43f5e;
  --accent-danger-bg: rgba(244, 63, 94, 0.12);
  --accent-warning: #f59e0b;
  --accent-warning-bg: rgba(245, 158, 11, 0.12);
  --accent-cyan: #06b6d4;
  --accent-cyan-bg: rgba(6, 182, 212, 0.12);

  /* Shadows & Ambient Glows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-card: 0 16px 36px -10px rgba(0, 0, 0, 0.6), inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
  --shadow-card-hover: 0 22px 48px -12px rgba(0, 0, 0, 0.75), inset 0 1px 0 0 rgba(255, 255, 255, 0.15);
  --shadow-modal: 0 30px 60px -15px rgba(0, 0, 0, 0.85), 0 0 40px -10px rgba(99, 102, 241, 0.2);
  --glow-primary: 0 0 25px rgba(99, 102, 241, 0.35);
  --glow-success: 0 0 25px rgba(16, 185, 129, 0.35);
  --glow-danger: 0 0 25px rgba(244, 63, 94, 0.35);

  /* Radii */
  --radius-2xl: 24px;
  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --radius-full: 9999px;

  /* Safe Area Insets (iOS Safari / Dynamic Island / Home Bar) */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

/* Ambient Cyber Mesh Background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse 70% 50% at 15% 10%, rgba(99, 102, 241, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 45% at 85% 85%, rgba(16, 185, 129, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 50% 50% at 50% 45%, rgba(139, 92, 246, 0.05) 0%, transparent 70%);
  pointer-events: none;
  z-index: -1;
  animation: ambient-drift 20s infinite alternate ease-in-out;
}

@keyframes ambient-drift {
  0% { transform: scale(1.0) rotate(0deg); }
  100% { transform: scale(1.08) rotate(1deg); }
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px 90px;
}

/* Typography Helpers */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  letter-spacing: -0.025em;
  color: #fff;
}

.mono {
  font-family: var(--font-mono);
}

/* SVG Icon Helper */
.icon-svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.icon-svg-sm {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.icon-svg-lg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ==========================================================================
   Header & Navbar
   ========================================================================== */

header.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  background: var(--bg-card);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
  flex-wrap: wrap;
  gap: 14px;
  position: relative;
}

.navbar-top {
  display: flex;
  align-items: center;
}

.nav-system-actions {
  display: none;
}

.nav-desktop-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.brand-icon {
  width: 44px;
  height: 44px;
  background: var(--accent-gradient);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 18px rgba(99, 102, 241, 0.4);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.brand-icon::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.25), transparent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.2;
  background: linear-gradient(180deg, #ffffff 30%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand span {
  font-size: 0.775rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand span::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent-success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-success);
  display: inline-block;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
  outline: none;
  text-decoration: none;
  user-select: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  min-height: 36px;
}

/* Primary Button */
.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  background: var(--accent-gradient-hover);
  box-shadow: 0 6px 22px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

/* Secondary Button (Glass) */
.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(10px);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
  transform: translateY(-1px);
}

/* Danger Button */
.btn-danger {
  background: rgba(244, 63, 94, 0.14);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.35);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.24);
  border-color: rgba(244, 63, 94, 0.6);
  color: #fff;
  transform: translateY(-1px);
}

/* Soft Styled Action Buttons */
.btn-primary-soft {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
}

.btn-primary-soft:hover {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(99, 102, 241, 0.5);
  color: #fff;
}

.btn-success-soft {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.btn-success-soft:hover {
  background: rgba(16, 185, 129, 0.24);
  border-color: rgba(16, 185, 129, 0.55);
  color: #fff;
}

.btn-danger-soft {
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fda4af;
}

.btn-danger-soft:hover {
  background: rgba(244, 63, 94, 0.22);
  border-color: rgba(244, 63, 94, 0.55);
  color: #fff;
}

.btn-icon {
  padding: 8px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
}

/* ==========================================================================
   Bento Grid: Statistics
   ========================================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  transition: background 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: var(--shadow-card-hover);
}

.stat-card:nth-child(1):hover::after { background: var(--accent-gradient); }
.stat-card:nth-child(2):hover::after { background: linear-gradient(90deg, #10b981, #06b6d4); }
.stat-card:nth-child(3):hover::after { background: linear-gradient(90deg, #f43f5e, #fb923c); }
.stat-card:nth-child(4):hover::after { background: linear-gradient(90deg, #f59e0b, #eab308); }

.stat-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.stat-icon-wrap.users {
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #818cf8;
}

.stat-icon-wrap.active {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.stat-icon-wrap.disabled {
  background: rgba(244, 63, 94, 0.14);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fb7185;
}

.stat-icon-wrap.requests {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.stat-content {
  flex: 1;
}

.stat-content .stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.stat-content .stat-val {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.1;
  color: #fff;
}

/* ==========================================================================
   Content Box & Table
   ========================================================================== */

.content-box {
  background: var(--bg-card);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.box-header {
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 16px;
  background: rgba(255, 255, 255, 0.015);
}

.box-title h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.box-title p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.box-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-input {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px 10px 38px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  width: 280px;
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  background: var(--bg-input-focus);
  border-color: var(--border-highlight);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.search-input::placeholder {
  color: var(--text-dim);
}

/* Desktop Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table.users-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

table.users-table th {
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

table.users-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.875rem;
  vertical-align: middle;
  transition: background 0.15s ease;
}

table.users-table tr:last-child td {
  border-bottom: none;
}

table.users-table tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}

/* User Identity Cell */
.user-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #c7d2fe;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name-title {
  font-weight: 600;
  color: #fff;
  font-size: 0.925rem;
}

.token-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 0.775rem;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.2s ease;
}

.token-pill:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
}

/* Switch (Tactile iOS Toggle) */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: #fff;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}

input:checked + .slider {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

input:checked + .slider:before {
  transform: translateX(18px);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge-active {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-active .status-dot {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: breathing 2s infinite ease-in-out;
}

.badge-disabled {
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.badge-disabled .status-dot {
  background: #64748b;
}

.badge-alert {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.35);
}

.badge-alert .status-dot {
  background: #f43f5e;
  box-shadow: 0 0 8px #f43f5e;
  animation: pulse-danger 1.5s infinite ease-in-out;
}

@keyframes breathing {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* Device Badge Buttons */
.btn-device-badge {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.28);
  color: #c7d2fe;
  padding: 5px 11px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-device-badge:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.5);
  color: #fff;
  transform: translateY(-1px);
}

.btn-device-badge-sm {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.28);
  color: #c7d2fe;
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.btn-device-badge-sm:hover {
  background: rgba(99, 102, 241, 0.22);
}

.btn-device-badge.limit-exceeded,
.btn-device-badge-sm.limit-exceeded {
  background: rgba(244, 63, 94, 0.15) !important;
  border-color: rgba(244, 63, 94, 0.45) !important;
  color: #fda4af !important;
  animation: pulse-danger 2s infinite ease-in-out;
}

@keyframes pulse-danger {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.3); }
  50% { box-shadow: 0 0 12px 2px rgba(244, 63, 94, 0.45); }
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   Mobile Cards View (<= 768px)
   ========================================================================== */

.mobile-cards-view {
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 0;
  width: 100%;
}

.user-card {
  background: rgba(13, 19, 33, 0.78);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-card);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 8px 24px -5px rgba(0, 0, 0, 0.5), inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 0;
  width: 100%;
}

.user-card:active {
  transform: scale(0.99);
  border-color: rgba(99, 102, 241, 0.35);
}

.user-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.user-card-top .user-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.user-card-header-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.user-card-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card-token {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  max-width: 100%;
  width: fit-content;
  touch-action: manipulation;
}

.user-card-token span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card-token:active {
  background: rgba(99, 102, 241, 0.25);
  color: #c7d2fe;
}

.device-limit-alert-bar {
  background: rgba(244, 63, 94, 0.14);
  border: 1px solid rgba(244, 63, 94, 0.4);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  color: #fda4af;
  font-weight: 600;
}

.user-card-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.card-mode-badge {
  font-size: 0.725rem;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 500;
}

.card-requests-count {
  font-size: 0.75rem;
  color: var(--accent-warning);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-weight: 600;
  margin-left: auto;
}

.user-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.card-last-seen {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.card-last-seen .meta-val {
  color: #cbd5e1;
  font-weight: 500;
}

.card-last-seen .meta-ip {
  font-family: var(--font-mono);
  color: #94a3b8;
  font-size: 0.725rem;
}

.user-card-actions {
  display: grid;
  grid-template-columns: 1fr 44px 44px;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 12px;
}

.btn-touch {
  min-height: 44px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  touch-action: manipulation;
}

.btn-icon-touch {
  min-height: 44px;
  width: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  touch-action: manipulation;
}

.btn-icon-touch svg {
  width: 18px;
  height: 18px;
}

/* Mobile Floating Action Button */
.mobile-fab {
  display: none;
  position: fixed;
  right: 20px;
  bottom: calc(24px + var(--sab));
  width: 58px;
  height: 58px;
  background: var(--accent-gradient);
  border-radius: 29px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 10px 28px rgba(99, 102, 241, 0.55);
  align-items: center;
  justify-content: center;
  z-index: 999;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

.mobile-fab:active {
  transform: scale(0.92);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(4, 6, 12, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #0d1322;
  background: linear-gradient(180deg, rgba(20, 28, 48, 0.95) 0%, rgba(13, 19, 34, 0.98) 100%);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 480px;
  padding: 26px 28px;
  position: relative;
  transform: scale(0.95) translateY(10px);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.open .modal-card {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 14px;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.close-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  transition: all 0.2s ease;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transform: rotate(90deg);
}

/* Forms */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: #fff;
  font-family: var(--font-body);
  font-size: 16px; /* Prevents auto-zoom on iOS */
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  background: var(--bg-input-focus);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.form-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.4;
}

/* ==========================================================================
   Devices Modal & Item Cards
   ========================================================================== */

.device-modal-alert {
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.4);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.device-list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.device-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: all 0.2s ease;
}

.device-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}

.device-item.device-active {
  border-left: 3px solid var(--accent-success);
}

.device-item.device-inactive {
  border-left: 3px solid var(--text-muted);
  opacity: 0.8;
}

.device-item.device-blocked,
.device-item-blocked {
  border-left: 3px solid var(--accent-danger) !important;
  background: rgba(244, 63, 94, 0.06) !important;
}

.device-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.device-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a5b4fc;
  flex-shrink: 0;
}

.device-icon.icon-blocked {
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.3);
  color: #fda4af;
}

.device-info {
  flex: 1;
  min-width: 0;
}

.device-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.device-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.925rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-status-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.badge-online {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-offline {
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.badge-blocked {
  background: rgba(244, 63, 94, 0.18);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.4);
}

.text-strikethrough {
  text-decoration: line-through;
  opacity: 0.75;
}

.device-meta {
  font-size: 0.775rem;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.device-meta .device-ip {
  color: #cbd5e1;
  font-family: var(--font-mono);
}

.device-meta .device-requests {
  color: #818cf8;
  font-family: var(--font-mono);
}

.device-timestamps {
  font-size: 0.725rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.device-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-device-action {
  font-size: 0.775rem;
  padding: 5px 11px;
  border-radius: 8px;
  white-space: nowrap;
}

/* ==========================================================================
   QR Code Modal
   ========================================================================== */

.qr-container {
  background: #fff;
  padding: 16px;
  border-radius: var(--radius-lg);
  display: inline-block;
  margin: 16px auto;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.qr-link-copy {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin-top: 14px;
}

.qr-link-copy span {
  font-family: var(--font-mono);
  font-size: 0.775rem;
  color: #cbd5e1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Login Screen (Cyber Security Theme)
   ========================================================================== */

.login-container {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--sat)) calc(16px + var(--sar)) calc(20px + var(--sab)) calc(16px + var(--sal));
  width: 100%;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-2xl);
  padding: 42px 32px;
  box-shadow: var(--shadow-modal);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.35) 0%, transparent 70%);
  pointer-events: none;
}

.btn-passkey-main {
  width: 100%;
  min-height: 56px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  background: var(--accent-gradient);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.45);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.btn-passkey-main:hover {
  background: var(--accent-gradient-hover);
  box-shadow: 0 12px 36px rgba(99, 102, 241, 0.6);
  transform: translateY(-2px);
}

.btn-passkey-main:active {
  transform: scale(0.98);
}

.btn-passkey-main::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    60deg,
    transparent 40%,
    rgba(255, 255, 255, 0.2) 50%,
    transparent 60%
  );
  animation: shine 4s infinite linear;
}

@keyframes shine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.passkey-lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  font-size: 0.775rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  margin-bottom: 24px;
}

/* ==========================================================================
   Toasts
   ========================================================================== */

#toast-container {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 380px;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  pointer-events: auto;
  animation: toast-slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.success { border-left: 4px solid var(--accent-success); }
.toast.error { border-left: 4px solid var(--accent-danger); }
.toast.warning { border-left: 4px solid var(--accent-warning); }

@keyframes toast-slide-up {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  html, body {
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100vw;
  }

  .container {
    width: 100%;
    max-width: 100vw;
    padding: calc(12px + var(--sat)) calc(12px + var(--sar)) calc(90px + var(--sab)) calc(12px + var(--sal));
  }

  /* Header Navbar on iPhone 15 Pro */
  header.navbar {
    padding: 12px 14px;
    border-radius: 18px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
  }

  .navbar-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }

  .brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .brand-text {
    min-width: 0;
  }

  .brand-text h1 {
    font-size: 1.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand-text span {
    font-size: 0.7rem;
    white-space: nowrap;
  }

  .nav-system-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }

  .nav-system-actions .btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .nav-desktop-actions {
    display: none !important;
  }

  .nav-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    width: 100%;
  }

  .nav-actions .btn {
    min-height: 40px;
    padding: 6px 4px;
    font-size: 0.775rem;
    font-weight: 600;
    border-radius: 10px;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
  }

  .nav-actions .btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
  }

  /* Stats Bento Grid on iPhone 15 Pro */
  .stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
    width: 100%;
  }

  .stat-card {
    padding: 12px 14px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
    width: 100%;
  }

  .stat-icon-wrap {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .stat-icon-wrap svg {
    width: 18px;
    height: 18px;
  }

  .stat-content {
    min-width: 0;
    width: 100%;
  }

  .stat-content .stat-label {
    font-size: 0.675rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stat-content .stat-val {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1.1;
  }

  /* Content Box & Controls */
  .content-box {
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
    width: 100%;
  }

  .box-header {
    padding: 4px 0 12px;
    background: transparent;
    border-bottom: none;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
  }

  .box-title h2 {
    font-size: 1.2rem;
    font-family: var(--font-display);
    font-weight: 800;
  }

  .box-title p {
    font-size: 0.75rem;
    color: var(--text-muted);
  }

  .box-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
  }

  .search-input-wrap {
    flex: 1;
    min-width: 0;
    width: auto;
  }

  .search-input {
    width: 100%;
    min-height: 44px;
    font-size: 16px !important; /* CRITICAL: Prevents iOS auto-zoom */
    border-radius: 12px;
    padding-left: 38px;
  }

  .box-controls .btn-primary {
    min-height: 44px;
    padding: 0 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  /* Switch desktop table to native mobile cards */
  .table-responsive {
    display: none !important;
  }

  .mobile-cards-view {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
    padding: 0;
    width: 100%;
  }

  .mobile-fab {
    display: flex !important;
  }

  /* Bottom sheet modal on iPhone 15 Pro */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .modal-card {
    border-radius: 28px 28px 0 0;
    max-width: 100vw;
    width: 100vw;
    max-height: 90vh;
    max-height: 90dvh;
    padding: 14px 20px calc(24px + var(--sab));
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* iOS Grabber handle */
  .modal-card::before {
    content: '';
    display: block;
    width: 44px;
    height: 5px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.25);
    margin: 0 auto 14px;
  }

  .modal-overlay.open .modal-card {
    transform: translateY(0);
  }

  .form-control,
  select.form-control,
  .search-input {
    font-size: 16px !important;
    min-height: 44px;
    -webkit-appearance: none;
  }

  /* Device item inside modal on mobile */
  .device-item {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px;
  }

  .device-item-left {
    width: 100%;
    align-items: flex-start;
  }

  .device-item-actions {
    display: grid;
    grid-template-columns: 1fr 40px;
    gap: 8px;
    width: 100%;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 10px;
  }

  .btn-device-action {
    width: 100%;
    min-height: 38px;
    font-size: 0.825rem;
    font-weight: 600;
    text-align: center;
  }

  .device-item-actions .btn-icon {
    width: 40px;
    height: 38px;
  }

  #toast-container {
    bottom: calc(20px + var(--sab));
    width: calc(100% - 32px);
    max-width: 380px;
  }
}
