/* ─── Design Tokens ──────────────────────────────────────────────────────── */
:root {
  --primary:            #6366f1;
  --primary-hover:      #4f46e5;
  --primary-soft:       #eef2ff;
  --primary-border:     #c7d2fe;

  --success:            #10b981;
  --success-soft:       #d1fae5;
  --success-border:     #6ee7b7;

  --warning:            #f59e0b;
  --warning-soft:       #fef3c7;
  --warning-border:     #fcd34d;

  --danger:             #ef4444;
  --danger-soft:        #fee2e2;
  --danger-border:      #fca5a5;

  --info:               #3b82f6;
  --info-soft:          #dbeafe;
  --info-border:        #93c5fd;

  --sidebar-bg:         #0f172a;
  --sidebar-hover:      #1e293b;
  --sidebar-active-bg:  rgba(99,102,241,0.12);
  --sidebar-border:     #1e293b;
  --sidebar-text:       #94a3b8;
  --sidebar-text-hover: #e2e8f0;
  --sidebar-width:      260px;

  --bg:                 #f8fafc;
  --surface:            #ffffff;
  --surface-2:          #f1f5f9;
  --border:             #e2e8f0;
  --border-2:           #cbd5e1;
  --text:               #0f172a;
  --text-muted:         #64748b;
  --text-faint:         #94a3b8;

  --radius:             8px;
  --radius-lg:          12px;
  --radius-full:        9999px;
  --shadow-sm:          0 1px 2px rgba(0,0,0,0.05);
  --shadow:             0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:          0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
}

/* ─── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── App Shell ──────────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,0.04);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-brand .brand-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand .brand-icon svg { width: 16px; height: 16px; stroke: white; }
.sidebar-brand .brand-text {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.sidebar-brand .brand-sub {
  font-size: 10px;
  color: var(--sidebar-text);
  font-weight: 400;
  letter-spacing: 0.02em;
}
.gateway-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16,185,129,0.25);
  flex-shrink: 0;
  margin-left: auto;
}
.gateway-dot.offline {
  background: #ef4444;
  box-shadow: 0 0 0 2px rgba(239,68,68,0.25);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}
.nav-label {
  padding: 14px 20px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
  cursor: pointer;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-hover);
  text-decoration: none;
}
.nav-item.active {
  background: var(--sidebar-active-bg);
  border-left-color: var(--primary);
  color: #a5b4fc;
  font-weight: 600;
}
.nav-item svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.sidebar-user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 11px;
  color: var(--sidebar-text);
}
.btn-signout {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sidebar-text);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  transition: color 0.15s;
  flex-shrink: 0;
}
.btn-signout:hover { color: #ef4444; }
.btn-signout svg { width: 15px; height: 15px; }

/* ─── Main Content ───────────────────────────────────────────────────────── */
.main {
  padding: 28px 36px;
  min-width: 0;
}

/* ─── Page Header ────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}
.page-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-header-icon {
  width: 40px; height: 40px;
  background: var(--primary-soft);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.page-header-icon svg { width: 20px; height: 20px; stroke: var(--primary); }
.page-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.page-header .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
.page-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

/* ─── Flash Messages ─────────────────────────────────────────────────────── */
.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13.5px;
  font-weight: 500;
  border-left: 4px solid;
}
.flash-success {
  background: var(--success-soft);
  border-color: var(--success);
  color: #065f46;
}
.flash-error {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: #7f1d1d;
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.card-body { padding: 20px; }
.card-tight { }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
}
.card-header .card-header-actions { display: flex; gap: 8px; }
.card h2, .card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ─── Stat Cards ─────────────────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--border);
  transition: box-shadow 0.15s;
}
.stat:hover { box-shadow: var(--shadow-md); }
.stat.accent-indigo  { border-top-color: var(--primary); }
.stat.accent-green   { border-top-color: var(--success); }
.stat.accent-amber   { border-top-color: var(--warning); }
.stat.accent-blue    { border-top-color: var(--info); }
.stat.accent-red     { border-top-color: var(--danger); }
.stat-icon {
  position: absolute;
  top: 16px; right: 16px;
  width: 36px; height: 36px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 18px; height: 18px; }
.accent-indigo .stat-icon { background: var(--primary-soft); }
.accent-indigo .stat-icon svg { stroke: var(--primary); }
.accent-green  .stat-icon { background: var(--success-soft); }
.accent-green  .stat-icon svg { stroke: var(--success); }
.accent-amber  .stat-icon { background: var(--warning-soft); }
.accent-amber  .stat-icon svg { stroke: var(--warning); }
.accent-blue   .stat-icon { background: var(--info-soft); }
.accent-blue   .stat-icon svg { stroke: var(--info); }
.accent-red    .stat-icon { background: var(--danger-soft); }
.accent-red    .stat-icon svg { stroke: var(--danger); }
.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1;
}
.stat-value.alert { color: var(--danger); }
.stat-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}
table.data th {
  text-align: left;
  padding: 11px 16px;
  background: var(--surface-2);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
  color: var(--text);
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: #fafbfd; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .actions-cell { white-space: nowrap; }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge-green  { background: var(--success-soft);  color: #065f46; }
.badge-yellow { background: var(--warning-soft);  color: #92400e; }
.badge-red    { background: var(--danger-soft);   color: #7f1d1d; }
.badge-blue   { background: var(--info-soft);     color: #1e40af; }
.badge-gray   { background: var(--surface-2);     color: var(--text-muted); }
.badge-indigo  { background: var(--primary-soft);  color: #3730a3; }
.badge-purple  { background: #f3e8ff;             color: #6b21a8; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-primary { background: var(--primary); color: white; border-color: var(--primary); font-weight: 600; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: white; }

.btn-success { background: var(--success); color: white; border-color: var(--success); font-weight: 600; }
.btn-success:hover { background: #059669; border-color: #059669; color: white; }

.btn-danger { color: var(--danger); border-color: var(--border-2); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-sm svg { width: 13px; height: 13px; }

.btn-icon {
  padding: 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon svg { width: 14px; height: 14px; }
.btn-icon.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

.btn-link {
  border: 0; background: transparent; padding: 0;
  color: var(--primary); font-family: inherit;
  cursor: pointer; font-size: inherit;
}

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.field label .hint {
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 6px;
  font-size: 12px;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="tel"],
.field input[type="number"],
.field input[type="date"],
.field input[type="url"],
.field textarea,
.field select {
  width: 100%;
  max-width: 520px;
  padding: 9px 13px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-family: 'Poppins', sans-serif;
  background: white;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
/* two-column field grid */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field-grid-4 { grid-template-columns: repeat(4, 1fr); }

.field-grid .field input,
.field-grid .field select,
.field-grid .field textarea {
  max-width: 100%;
}

.field-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin: 20px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.field-section-label .hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  margin-left: 6px;
}

@media (max-width: 640px) {
  .field-grid { grid-template-columns: 1fr; }
  .field-grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 400px) {
  .field-grid-4 { grid-template-columns: 1fr; }
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.field input[disabled],
.field input[readonly] {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
}
.field textarea { min-height: 90px; resize: vertical; }
.field .error { color: var(--danger); font-size: 12px; margin-top: 4px; font-weight: 500; }
.field .hint-text { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

.form-actions { margin-top: 24px; display: flex; gap: 8px; align-items: center; }

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 600px;
  box-shadow: var(--shadow-sm);
}

/* ─── Filters Bar ────────────────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.filters select,
.filters input[type="text"] {
  padding: 6px 10px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: 'Poppins', sans-serif;
  background: white;
  color: var(--text);
  outline: none;
}
.filters select:focus,
.filters input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.filters-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.filters-label svg { width: 14px; height: 14px; }

/* ─── Two-column layout ──────────────────────────────────────────────────── */
.cols { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.cols-equal { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ─── Code / API key ─────────────────────────────────────────────────────── */
code, pre {
  font-family: "JetBrains Mono", "Fira Code", "Menlo", "Consolas", monospace;
  font-size: 12.5px;
}
.code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.65;
}
.code-inline {
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--text);
  border: 1px solid var(--border);
}

/* ─── API Key Reveal ─────────────────────────────────────────────────────── */
.api-key-reveal {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.api-key-reveal .reveal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 10px;
  font-size: 13.5px;
}
.api-key-reveal .reveal-title svg { width: 16px; height: 16px; }
.api-key-reveal .reveal-body {
  display: flex;
  align-items: center;
  gap: 8px;
}
.api-key-reveal code {
  display: block;
  flex: 1;
  background: #1c1917;
  color: #fbbf24;
  padding: 11px 14px;
  border-radius: var(--radius);
  word-break: break-all;
  font-size: 13px;
}
.api-key-reveal .btn-copy {
  flex-shrink: 0;
}

/* ─── Empty State ────────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-icon {
  width: 48px; height: 48px;
  background: var(--surface-2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.empty-icon svg { width: 22px; height: 22px; stroke: var(--text-faint); }
.empty-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-text  { font-size: 13px; }

/* ─── QR Pair Page ───────────────────────────────────────────────────────── */
.qr-container {
  text-align: center;
  padding: 36px 30px;
  max-width: 480px;
  margin: 0 auto;
}
.qr-container h2 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.qr-area {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 24px 0;
}
.qr-area img {
  width: 240px; height: 240px;
  border: 8px solid white;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
}
.qr-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  margin-top: 8px;
}
.qr-status-badge.connecting { background: var(--info-soft); color: #1e40af; }
.qr-status-badge.qr_pending { background: var(--warning-soft); color: #92400e; }
.qr-status-badge.connected  { background: var(--success-soft); color: #065f46; }
.pulse-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}
.connected-message {
  font-size: 20px;
  font-weight: 700;
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ─── Auth Pages ─────────────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 50%, #1e293b 100%);
}
.auth-card {
  background: white;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.auth-logo {
  width: 48px; height: 48px;
  background: var(--primary);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 4px 12px rgba(99,102,241,0.4);
}
.auth-logo svg { width: 24px; height: 24px; stroke: white; }
.auth-card h1 {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}
.auth-card .auth-sub {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}
.auth-card .field input {
  max-width: 100%;
  padding: 10px 14px;
  font-size: 14px;
}
.auth-card .btn-primary {
  width: 100%;
  justify-content: center;
  padding: 11px 14px;
  font-size: 14px;
  margin-top: 6px;
  border-radius: var(--radius);
}
.auth-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.auth-remember input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--primary); }
.auth-remember label { font-size: 13px; font-weight: 400; color: var(--text-muted); margin: 0; }

/* ─── Gateway health inline badge ────────────────────────────────────────── */
.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 600;
}
.health-badge.online  { background: var(--success-soft); color: #065f46; }
.health-badge.offline { background: var(--danger-soft);  color: #7f1d1d; }
.health-badge svg { width: 13px; height: 13px; }

/* ─── Detail / Info Lists ────────────────────────────────────────────────── */
.info-list { list-style: none; }
.info-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.info-list li:last-child { border-bottom: 0; }
.info-list .info-key {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 140px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.info-list .info-key svg { width: 13px; height: 13px; }
.info-list .info-val { color: var(--text); }

/* ─── Pagination ─────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 4px;
  margin-top: 16px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  padding: 6px 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  transition: all 0.12s;
}
.pagination a:hover { background: var(--surface-2); text-decoration: none; }
.pagination .active span {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ─── Misc Utilities ─────────────────────────────────────────────────────── */
.muted   { color: var(--text-muted); }
.small   { font-size: 12px; }
.right   { text-align: right; }
.gap-md  { margin-bottom: 20px; }
.gap-sm  { margin-bottom: 12px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ─── Topbar (mobile only) ───────────────────────────────────────────────── */
.topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 300;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.topbar-brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  letter-spacing: -0.3px;
}
.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.hamburger:hover { background: var(--surface-2); }
.hamburger svg { width: 22px; height: 22px; }

/* ─── Sidebar overlay (mobile) ───────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
  opacity: 0;
  transition: opacity 0.2s;
}
.sidebar-overlay.visible {
  opacity: 1;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

/* Tablet: 768px – 1024px */
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .main { padding: 24px; }
  .cols, .cols-equal { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .filters { flex-wrap: wrap; gap: 6px; }
  .filters select, .filters input { flex: 1 1 160px; }
}

/* Mobile: < 768px */
@media (max-width: 767px) {
  .topbar { display: flex; }
  .sidebar-overlay { display: block; }

  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 260px;
    height: 100vh;
    border-right: 1px solid var(--border);
    border-bottom: none;
    z-index: 200;
    transform: translateX(-260px);
    transition: transform 0.22s ease;
    overflow-y: auto;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .main {
    padding: 16px;
    padding-top: 72px; /* 56px topbar + 16px gap */
    min-width: 0;
  }

  .stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  .page-header { flex-direction: column; gap: 10px; align-items: flex-start; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { width: 100%; justify-content: center; }

  .cols, .cols-equal { grid-template-columns: 1fr; gap: 16px; }

  .filters { flex-wrap: wrap; gap: 6px; }
  .filters select, .filters input { flex: 1 1 140px; min-width: 0; }

  .table-wrap {
    margin-left: -16px;
    margin-right: -16px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .form-card { padding: 20px 16px; }

  .card-body { padding: 16px; }

  .qr-container { padding: 20px 16px; }

  .auth-card { margin: 16px; padding: 28px 20px; }
}

/* Small mobile: < 480px */
@media (max-width: 479px) {
  .stats { grid-template-columns: 1fr; }
  .main { padding: 12px; padding-top: 68px; }
  .table-wrap { margin-left: -12px; margin-right: -12px; }
}

/* ─── Table scroll wrapper (prevents horizontal overflow on mobile) ──────── */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-scroll table.data { min-width: 560px; }

/* ─── Mobile topbar: user profile chip ──────────────────────────────────── */
.topbar-user {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.topbar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.topbar-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Badge additions ────────────────────────────────────────────────────── */
.badge-teal {
  background: #ccfbf1;
  color: #0f766e;
  border-color: #99f6e4;
}

/* ─── User management: small avatar in table ─────────────────────────────── */
.user-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ─── Role option checkboxes ─────────────────────────────────────────────── */
.role-groups { display: flex; flex-direction: column; gap: 16px; }

.role-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.role-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  padding: 8px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.role-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: background .15s;
}
.role-option:not(:last-child) { border-bottom: 1px solid var(--border); }
.role-option:hover { background: var(--primary-soft); }
.role-option input[type="checkbox"] {
  margin-top: 3px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
.role-info { display: flex; flex-direction: column; gap: 2px; }
.role-name { font-weight: 600; font-size: 13.5px; text-transform: capitalize; }
.role-desc { font-size: 12px; color: var(--text-muted); }

/* ─── Field error & invalid state ───────────────────────────────────────── */
.field-error {
  display: block;
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
  font-weight: 500;
}
.field-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.field input.is-invalid,
.field select.is-invalid,
.field textarea.is-invalid {
  border-color: var(--danger);
  background: #fff8f8;
}

/* ─── Form card (standalone) ─────────────────────────────────────────────── */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 600px;
  box-shadow: var(--shadow-sm);
}

/* ─── Table wrap (legacy alias) ─────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrap table.data { min-width: 560px; }

/* ─── Docs page ─────────────────────────────────────────────────────────── */
.doc-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.btn-copy-code {
  position: absolute;
  top: 10px; right: 10px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--radius);
  color: #94a3b8;
  cursor: pointer;
  padding: 5px 8px;
  display: flex; align-items: center;
  transition: background .15s, color .15s;
}
.btn-copy-code:hover { background: rgba(255,255,255,.22); color: #e2e8f0; }
.btn-copy-code svg { width: 13px; height: 13px; }

.try-it-panel {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.try-it-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
.try-it-header svg { width: 14px; height: 14px; }
.try-it-body { padding: 16px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Impersonation banner ───────────────────────────────────────────────── */
.impersonate-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--warning-soft);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  color: #92400e;
}
.impersonate-banner svg { width: 15px; height: 15px; stroke: #92400e; flex-shrink: 0; }
.impersonate-banner .btn { margin-left: auto; flex-shrink: 0; }

/* ─── Permission groups (roles create/edit) ─────────────────────────────── */
.perm-groups { display: flex; flex-direction: column; gap: 12px; }
.perm-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.perm-group-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  padding: 7px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.perm-group-items { display: flex; flex-wrap: wrap; gap: 0; }
.perm-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  min-width: 200px;
  flex: 1 1 200px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.perm-option:hover { background: var(--primary-soft); }
.perm-option input[type="checkbox"] { accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }

/* ─── Two-column layout (permissions page) ──────────────────────────────── */
.two-col-layout { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
@media (max-width: 767px) {
  .two-col-layout { flex-direction: column; }
  .two-col-layout > * { width: 100%; max-width: 100% !important; }
  .field input, .field textarea, .field select { max-width: 100% !important; }
}
