/* ═══════════════════════════════════════════════════════════════════════════
   Pycube Reader Platform — Production Design System
   Modern, futuristic UI with glassmorphism, gradients & micro-animations
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Google Fonts loaded via base.html <link> ── */

/* ── CSS Variables ────────────────────────────────────────────────────────── */
:root {
  /* ── Pycube Design System — from Figma Style Guide ─────────────────── */

  /* Brand / Primary */
  --brand-dark:   #01042E;   /* primary-color */
  --brand-mid:    #060d5e;
  --brand-accent: #0D6EFD;   /* accent / info blue */
  --brand-teal:   #0D6EFD;

  /* Sidebar */
  --sidebar-w:    240px;
  --sidebar-w-sm: 68px;

  /* Surface */
  --bg-page:   #F2F4F3;      /* background-color */
  --bg-card:   #ffffff;
  --bg-card2:  #f8f9fa;
  --border:    #dee2e6;
  --border-sm: #e9ecef;

  /* Text */
  --txt-primary:   #3A3A3A;  /* main body text */
  --txt-secondary: #6c757d;
  --txt-muted:     #adb5bd;

  /* Semantic — success / warning / error / info */
  --green:  #198754;         /* success-main-color */
  --yellow: #FFC107;         /* warning-main-color */
  --red:    #DC3545;         /* alert-main-color   */
  --blue:   #0D6EFD;         /* info color         */
  --gray:   #9ca3af;

  /* Misc */
  --radius-sm: 8px;
  --radius:    10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(1,4,46,.07), 0 0 1px rgba(1,4,46,.04);
  --shadow:    0 4px 14px rgba(1,4,46,.09), 0 1px 3px rgba(1,4,46,.05);
  --shadow-lg: 0 10px 36px rgba(1,4,46,.13), 0 2px 8px rgba(1,4,46,.06);
  --transition: .18s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-page);
  color: var(--txt-primary);
  min-height: 100vh;
  display: flex;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--brand-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 200;
  transition: width var(--transition);
  overflow: hidden;
  border-right: 1px solid rgba(255,255,255,.06);
  box-shadow: 4px 0 20px rgba(1,4,46,.22);
}
.sidebar::before { display: none; }
.sidebar.collapsed { width: var(--sidebar-w-sm); }

/* Logo */
.sidebar-logo {
  padding: 22px 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center;
  min-height: 70px;
}
.logo-full  { max-width: 164px; height: 40px; object-fit: contain; transition: opacity var(--transition); display: block; }
.logo-mini  { width: 34px; height: 34px; object-fit: contain; display: none; border-radius: 6px; }
.collapsed .logo-full { display: none; }
.collapsed .logo-mini { display: block; }

/* Nav */
.sidebar-nav { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  color: rgba(255,255,255,.6);
  font-size: .875rem; font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.nav-item::before { display: none; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-item.active {
  color: #fff;
  background: rgba(13,110,253,.25);
  border-left: 3px solid var(--brand-accent);
  padding-left: 9px;
}
.nav-icon {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; flex-shrink: 0;
}
.nav-icon svg { width: 18px; height: 18px; }
.nav-label { transition: opacity var(--transition); letter-spacing: .01em; }
.collapsed .nav-label { display: none; }

/* Sidebar Footer */
.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; gap: 10px;
}
.user-info   { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-accent), var(--brand-teal));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: .825rem; font-weight: 700; flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(59,130,246,.25);
}
.user-details { min-width: 0; }
.user-email  { display: block; color: rgba(255,255,255,.9); font-size: .775rem;
                white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role   { display: block; color: rgba(255,255,255,.45); font-size: .68rem; margin-top: 1px; }
.collapsed .user-details { display: none; }
.logout-btn  {
  color: rgba(255,255,255,.4); text-decoration: none; padding: 6px;
  border-radius: 6px; transition: all var(--transition);
  display: flex; align-items: center;
}
.logout-btn:hover { color: var(--red); background: rgba(239,68,68,.12); }
.logout-btn svg { width: 17px; height: 17px; }
.collapsed .logout-btn { display: none; }

/* ── Main Wrapper ────────────────────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}
.main-wrapper.sidebar-collapsed { margin-left: var(--sidebar-w-sm); }

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-sm);
  padding: 0 24px;
  height: 58px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 0 var(--border-sm), 0 4px 16px rgba(1,4,46,.04);
}
.sidebar-toggle {
  background: none; border: none;
  cursor: pointer; color: var(--txt-secondary);
  padding: 7px; border-radius: 8px;
  transition: all var(--transition);
  display: flex; align-items: center;
}
.sidebar-toggle:hover { background: var(--bg-card2); color: var(--txt-primary); }
.sidebar-toggle svg { width: 20px; height: 20px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* ── Main Content ────────────────────────────────────────────────────────── */
.main-content { padding: 28px; flex: 1; }

/* ── Auth Layout ─────────────────────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh; width: 100%;
  background: var(--brand-dark);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  position: relative; overflow: hidden;
}
.auth-wrapper::before { display: none; }

/* ── Page Header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex; justify-content: space-between;
  align-items: flex-start; margin-bottom: 28px;
}
.page-header h1 {
  font-size: 1.5rem; font-weight: 700;
  color: var(--txt-primary); letter-spacing: -.02em;
}
.sub { color: var(--txt-muted); font-size: .84rem; margin-top: 3px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius-sm); border: none;
  cursor: pointer; font-size: .865rem; font-weight: 500;
  text-decoration: none; transition: all var(--transition);
  white-space: nowrap; font-family: inherit;
  letter-spacing: .01em;
}
.btn-primary {
  background: var(--brand-dark);
  color: #fff;
  box-shadow: 0 2px 8px rgba(1,4,46,.25);
}
.btn-primary:hover {
  background: #060d5e;
  box-shadow: 0 4px 16px rgba(1,4,46,.35);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); background: var(--brand-dark); }
.btn-outline {
  background: #fff; border: 1.5px solid var(--brand-dark); color: var(--brand-dark);
  box-shadow: var(--shadow-sm);
}
.btn-outline:hover {
  background: var(--brand-dark); color: #fff;
  box-shadow: var(--shadow);
}
.btn-danger { background: #fff; border: 1.5px solid var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm {
  padding: 5px 12px; font-size: .8rem;
  background: var(--bg-card2); border: 1px solid var(--border);
  color: var(--txt-secondary); border-radius: 6px;
  transition: all var(--transition);
}
.btn-sm:hover { background: #fff; border-color: var(--brand-dark); color: var(--brand-dark); }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-sm);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.card-header h3 { font-size: 1rem; font-weight: 600; color: var(--txt-primary); }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrapper {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-sm);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; font-size: .865rem; }
.data-table thead { position: sticky; top: 0; z-index: 1; }
.data-table th {
  background: var(--bg-card2);
  padding: 12px 16px; text-align: left;
  font-weight: 700; font-size: .75rem; letter-spacing: .05em; text-transform: uppercase;
  color: var(--txt-secondary); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px; border-bottom: 1px solid var(--border-sm);
  vertical-align: middle; transition: background var(--transition);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #f8fbff; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-sm);
  box-shadow: var(--shadow-sm);
  padding: 28px;
}
.form-section { margin-bottom: 28px; }
.form-section h3 {
  font-size: .875rem; font-weight: 600; color: var(--txt-secondary);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 16px; padding-bottom: 10px;
  border-bottom: 2px solid var(--border-sm);
  display: flex; align-items: center; gap: 8px;
}
.form-section h3::before {
  content: ''; width: 3px; height: 14px;
  background: linear-gradient(to bottom, var(--brand-accent), var(--brand-teal));
  border-radius: 2px; flex-shrink: 0;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--txt-secondary); letter-spacing: .02em; }
.form-group input, .form-group select, .form-group textarea {
  padding: 10px 13px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: .875rem;
  background: var(--bg-card); color: var(--txt-primary);
  outline: none; transition: all var(--transition);
  font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--brand-dark);
  box-shadow: 0 0 0 3px rgba(1,4,46,.1);
}
.form-group input[disabled] { background: var(--bg-card2); color: var(--txt-muted); }
.form-group small { font-size: .75rem; color: var(--txt-muted); }
.form-actions { display: flex; gap: 12px; margin-top: 8px; }
.req { color: var(--red); }

/* ── Status Badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 99px;
  font-size: .75rem; font-weight: 600; letter-spacing: .02em;
}
.badge-online  { background: #d1e7dd; color: #0a3622; }
.badge-warning { background: #fff3cd; color: #664d03; }
.badge-offline { background: #f8d7da; color: #58151c; }
.badge-unknown { background: #f1f5f9; color: #495057; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.badge-online::before  { background: var(--green);  box-shadow: 0 0 0 2px rgba(25,135,84,.25); }
.badge-warning::before { background: var(--yellow); box-shadow: 0 0 0 2px rgba(255,193,7,.25); }
.badge-offline::before { background: var(--red);    box-shadow: 0 0 0 2px rgba(220,53,69,.25); }
.badge-unknown::before { background: var(--gray); }

.type-badge {
  background: #cfe2ff; color: #084298;
  padding: 3px 10px; border-radius: 6px;
  font-size: .75rem; font-weight: 700; letter-spacing: .04em;
}

/* ── MQTT Dots ───────────────────────────────────────────────────────────── */
.dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  position: relative;
}
.dot-green { background: var(--green); box-shadow: 0 0 0 3px rgba(25,135,84,.2); }
.dot-red   { background: var(--red);   box-shadow: 0 0 0 3px rgba(220,53,69,.2); }
.dot-green::after {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  border: 2px solid rgba(25,135,84,.4);
  animation: pulse-ring 2s ease infinite;
}
@keyframes pulse-ring {
  0%   { transform: scale(.9); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ── Antenna Badge ───────────────────────────────────────────────────────── */
.antenna-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: #065f46; padding: 3px 10px;
  border-radius: 6px; font-size: .75rem; font-weight: 700;
}

/* ── Toggle Switch ───────────────────────────────────────────────────────── */
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #cbd5e1; border-radius: 99px; cursor: pointer;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: ''; position: absolute; width: 16px; height: 16px;
  background: #fff; border-radius: 50%;
  left: 3px; top: 3px; transition: transform var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--green); }
.toggle-switch input:checked + .toggle-slider { background: #198754; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Filter Bar ──────────────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-bar input, .filter-bar select {
  padding: 9px 13px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: .875rem;
  background: #fff; color: var(--txt-primary);
  transition: all var(--transition); font-family: inherit;
}
.filter-bar input { flex: 1; min-width: 200px; }
.filter-bar input:focus, .filter-bar select:focus {
  outline: none; border-color: var(--brand-dark);
  box-shadow: 0 0 0 3px rgba(1,4,46,.1);
}

/* ── Alerts / Toast ──────────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-radius: var(--radius-sm);
  margin-bottom: 16px; font-size: .875rem; font-weight: 500;
}
.alert-error   { background: #f8d7da; color: #58151c; border: 1px solid #f5c2c7; }
.alert-success { background: #d1e7dd; color: #0a3622; border: 1px solid #badbcc; }
.alert-warning { background: #fff3cd; color: #664d03; border: 1px solid #ffecb5; }
.alert-info    { background: #cfe2ff; color: #084298; border: 1px solid #b6d4fe; }

#toast-container {
  position: fixed; top: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
/* ── Modern Figma-style toast: colored icon block + white body ── */
.toast {
  display: flex; align-items: stretch;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 0; transform: translateX(28px) scale(.97);
  transition: all .22s cubic-bezier(.4,0,.2,1);
  min-width: 280px; max-width: 360px; pointer-events: auto;
}
.toast.show { opacity: 1; transform: translateX(0) scale(1); }

/* Icon block (left colored square) */
.toast::before {
  content: '●'; /* replaced via type class below */
  display: flex; align-items: center; justify-content: center;
  width: 54px; flex-shrink: 0;
  font-size: 1.3rem; color: #fff;
  padding: 0;
}

/* Text body area — injected by showToast() as two-line div */
.toast-body { padding: 12px 14px; flex: 1; }
.toast-title { font-size: .875rem; font-weight: 700; color: var(--txt-primary); }
.toast-msg   { font-size: .8rem; color: var(--txt-secondary); margin-top: 2px; }

.toast-success::before { content: '✓'; background: var(--green);   font-size: 1.5rem; font-weight: 700; }
.toast-error::before   { content: '!'; background: var(--red);     font-size: 1.5rem; font-weight: 700; border-radius: 50%; width: 22px; height: 22px; margin: auto 16px; }
.toast-warning::before { content: '!'; background: var(--yellow);  font-size: 1.5rem; font-weight: 700; }
.toast-info::before    { content: 'i'; background: var(--blue);    font-size: 1.3rem; font-weight: 700; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(1,4,46,.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  animation: modal-in .2s ease;
}
.modal.hidden { display: none; }
@keyframes modal-in { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  background: #fff; border-radius: var(--radius-lg); padding: 32px;
  max-width: 520px; width: 90%; box-shadow: var(--shadow-lg);
  animation: modal-box-in .22s cubic-bezier(.4,0,.2,1);
}
@keyframes modal-box-in { from { transform: translateY(16px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-box h3 { margin-bottom: 20px; color: var(--txt-primary); font-weight: 700; font-size: 1.1rem; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; }

/* ── Info Box ────────────────────────────────────────────────────────────── */
.info-box {
  background: linear-gradient(135deg, #eff6ff, #f0f9ff);
  border: 1px solid #bfdbfe; border-radius: var(--radius-sm); padding: 16px;
}
.info-box h4 { font-size: .875rem; color: #1e40af; margin-bottom: 12px; font-weight: 600; }
.topics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.topics-grid label { display: block; font-size: .72rem; color: var(--txt-muted); margin-bottom: 2px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.topics-grid code { font-size: .78rem; color: var(--brand-accent); word-break: break-all; }

/* ── Stat Card ───────────────────────────────────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-sm);
  border-radius: var(--radius);
  padding: 20px 22px;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card.total::before   { background: var(--brand-dark); }
.stat-card.online::before  { background: var(--green); }
.stat-card.warning::before { background: var(--yellow); }
.stat-card.offline::before { background: var(--red); }
.stat-card.unknown::before { background: var(--gray); }
.stat-value { font-size: 2.2rem; font-weight: 800; letter-spacing: -.04em; line-height: 1; color: var(--txt-primary); }
.stat-label { font-size: .8rem; color: var(--txt-muted); margin-top: 5px; font-weight: 500; }
.stat-icon {
  position: absolute; right: 18px; top: 18px;
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; opacity: .15;
}

/* ── Misc Utilities ──────────────────────────────────────────────────────── */
.mono        { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: .85em; }
.small       { font-size: .8rem; }
.text-muted  { color: var(--txt-muted); }
.text-warn   { color: var(--yellow); font-weight: 600; }
.empty-state {
  text-align: center; padding: 56px; color: var(--txt-muted);
  font-size: .9rem;
}
.empty-state svg { opacity: .3; margin-bottom: 12px; }
.actions-cell { white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.cert-existing { display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
                  font-size: .8rem; color: #15803d; }
.user-avatar-sm {
  display: inline-flex; width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-accent), var(--brand-teal));
  color: #fff; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; margin-right: 8px; vertical-align: middle;
}

/* ── Section Divider ─────────────────────────────────────────────────────── */
.section-title {
  font-size: .8rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--txt-muted);
  margin-bottom: 14px; display: flex; align-items: center; gap: 10px;
}
.section-title::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── Auth Card ───────────────────────────────────────────────────────────── */
.auth-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo img {
  max-width: 180px;
  height: 52px;
  object-fit: contain;
  margin-bottom: 14px;
}
.auth-logo h1 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand-dark);
  letter-spacing: -.01em;
}
.auth-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--txt-primary);
  margin-bottom: 6px;
  text-align: center;
}
.auth-subtitle {
  text-align: center;
  color: var(--txt-secondary);
  font-size: .875rem;
  margin-bottom: 24px;
}
.auth-footer {
  text-align: center;
  margin-top: 18px;
  font-size: .825rem;
  color: var(--txt-secondary);
}
.auth-footer a { color: var(--brand-accent); font-weight: 500; }
.auth-footer a:hover { text-decoration: underline; }
.auth-card .form-group { margin-bottom: 16px; }
.btn-block { width: 100%; justify-content: center; margin-top: 4px; }

/* ── KPI / Dashboard Cards ───────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-sm);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.kpi-value {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  color: var(--txt-primary);
  letter-spacing: -.04em;
  line-height: 1;
}
.kpi-label {
  display: block;
  font-size: .8rem;
  color: var(--txt-muted);
  margin-top: 5px;
  font-weight: 500;
}
.kpi-icon {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .15;
  overflow: hidden;
  flex-shrink: 0;
}
.kpi-icon svg {
  width: 22px !important;
  height: 22px !important;
  min-width: 22px;
  min-height: 22px;
  max-width: 22px;
  max-height: 22px;
  flex-shrink: 0;
}
.kpi-green  { border-left: 4px solid var(--green); }
.kpi-red    { border-left: 4px solid var(--red); }
.kpi-blue   { border-left: 4px solid var(--blue); }
.kpi-yellow { border-left: 4px solid var(--yellow); }

/* ── Chart Cards ─────────────────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-sm);
  position: relative;
}
.chart-card h3 {
  margin: 0 0 16px;
  font-size: .95rem;
  font-weight: 600;
  color: var(--txt-primary);
}
.chart-card canvas {
  max-height: 220px !important;
  width: 100% !important;
}

/* ── Quick Links ─────────────────────────────────────────────────────────── */
.quick-links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 4px; }
.quick-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-sm);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  color: var(--txt-secondary);
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--transition);
}
.quick-link:hover {
  background: #eff6ff;
  border-color: var(--brand-accent);
  color: var(--brand-accent);
}
.quick-link svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar    { width: var(--sidebar-w-sm); }
  .main-wrapper { margin-left: var(--sidebar-w-sm); }
  .nav-label, .user-details, .logout-btn { display: none; }
  .logo-full { display: none; }
  .logo-mini { display: block; }
  .main-content { padding: 16px; }
  .page-header { flex-direction: column; gap: 12px; }
  .data-table th, .data-table td { padding: 10px 12px; }
}
