/* =====================================================================
   BloodTrack — Design System Mobile-First
   Dark mode · Glassmorphism · Inter font
   ===================================================================== */

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

/* ─── CSS Custom Properties ─────────────────────────────────────────── */
:root {
  /* Palette */
  --bg-base: #060d1a;
  --bg-surface: #0d1b2e;
  --bg-elevated: #122035;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);

  /* Brand */
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.25);
  --primary-subtle: rgba(59, 130, 246, 0.1);

  /* Semantic */
  --success: #10b981;
  --success-subtle: rgba(16, 185, 129, 0.1);
  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.1);
  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.1);

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #475569;

  /* Layout */
  --sidebar-w: 260px;
  --nav-h: 64px;
  --bottom-nav-h: 68px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
  --glow-blue: 0 0 24px rgba(59, 130, 246, 0.3);

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 400ms;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  /* Safe area per iPhone notch */
  padding-bottom: env(safe-area-inset-bottom);
}

/* ─── Typography ────────────────────────────────────────────────────── */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
}

h2 {
  font-size: clamp(1.25rem, 4vw, 1.75rem);
}

h3 {
  font-size: 1.15rem;
}

p {
  color: var(--text-secondary);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}

a:hover {
  color: #60a5fa;
}

/* ─── Scrollbar ─────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-surface);
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

/* ─── Layout principale ─────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ─── Sidebar (desktop) ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--dur-base) var(--ease);
}

.sidebar-logo {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo svg {
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, #3b82f6, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 12px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  position: relative;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary-subtle);
  color: var(--primary);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active svg {
  opacity: 1;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast) var(--ease);
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--success));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: white;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ─── Main Content ──────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  padding: 24px;
  padding-bottom: 40px;
}

/* ─── Top bar ───────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.topbar-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topbar-title h1 {
  font-size: 1.6rem;
  font-weight: 800;
}

.topbar-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ─── Cards ─────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  backdrop-filter: blur(12px);
}

.card:hover {
  border-color: var(--border-strong);
}

.card-glass {
  background: rgba(13, 27, 46, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ─── Stat Cards ────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all var(--dur-base) var(--ease);
  cursor: default;
}

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

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.stat-icon.blue {
  background: var(--primary-subtle);
  color: var(--primary);
}

.stat-icon.green {
  background: var(--success-subtle);
  color: var(--success);
}

.stat-icon.amber {
  background: var(--warning-subtle);
  color: var(--warning);
}

.stat-icon.red {
  background: var(--danger-subtle);
  color: var(--danger);
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-trend {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.trend-up {
  color: var(--success);
}

.trend-down {
  color: var(--danger);
}

.trend-flat {
  color: var(--text-muted);
}

/* ─── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all var(--dur-fast) var(--ease);
  white-space: nowrap;
  min-height: 44px;
  /* Touch target */
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
  color: white;
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-success {
  background: var(--success);
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-danger {
  background: var(--danger);
  color: white;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8rem;
  min-height: 36px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
  min-height: 52px;
  border-radius: var(--radius);
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-loading {
  position: relative;
  color: transparent;
}

.btn-loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ─── Form Controls ─────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-control {
  width: 100%;
  padding: 11px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  min-height: 44px;
  outline: none;
  -webkit-appearance: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control::placeholder {
  color: var(--text-muted);
}

select.form-control {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.form-error {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 6px;
}

/* ─── Alert / Badge ─────────────────────────────────────────────────── */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  line-height: 1.6;
  margin-bottom: 16px;
}

/* SVG icon inline con il testo — nessun flex per evitare frammentazione */
.alert>svg:first-child {
  display: inline-block;
  vertical-align: -3px;
  margin-right: 8px;
  flex-shrink: 0;
}

.alert-error {
  background: var(--danger-subtle);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.alert-error strong {
  color: #fca5a5;
}

.alert-success {
  background: var(--success-subtle);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #bbf7d0;
}

.alert-success strong {
  color: #86efac;
}

.alert-info {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #e0f2ff;
}

.alert-info strong {
  color: #bfdbfe;
}

.alert-warning {
  background: var(--warning-subtle);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fef08a;
}

.alert-warning strong {
  color: #fde047;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-blue {
  background: var(--primary-subtle);
  color: var(--primary);
}

.badge-green {
  background: var(--success-subtle);
  color: var(--success);
}

.badge-amber {
  background: var(--warning-subtle);
  color: var(--warning);
}

.badge-red {
  background: var(--danger-subtle);
  color: var(--danger);
}

.badge-gray {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

/* ─── Table ──────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table.bt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.bt-table thead {
  background: var(--bg-elevated);
}

.bt-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
}

.bt-table td {
  padding: 13px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
}

.bt-table tbody tr:hover td {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* ─── Login Page ─────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(16, 185, 129, 0.06) 0%, transparent 50%),
    var(--bg-base);
}

.login-box {
  width: 100%;
  max-width: 420px;
}

.login-logo {
  text-align: center;
  margin-bottom: 40px;
}

.login-logo-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--primary), var(--success));
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 8px 32px rgba(59, 130, 246, 0.35);
}

.login-title {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, #f1f5f9, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg);
}

.totp-inputs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 24px 0;
}

.totp-digit {
  width: 48px;
  height: 56px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  -webkit-appearance: none;
}

.totp-digit:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.biometric-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 20px;
  background: var(--bg-elevated);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--dur-base) var(--ease);
  color: var(--text-secondary);
  font-family: inherit;
}

.biometric-btn:hover {
  border-color: var(--primary);
  background: var(--primary-subtle);
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--glow-blue);
}

.biometric-btn svg {
  opacity: 0.7;
  transition: opacity var(--dur-fast) var(--ease);
}

.biometric-btn:hover svg {
  opacity: 1;
}

.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── QR Code Setup ──────────────────────────────────────────────────── */
.qr-container {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px auto;
  width: fit-content;
}

/* ─── Upload Zone ───────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  transition: all var(--dur-base) var(--ease);
  cursor: pointer;
  position: relative;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-subtle);
}

.upload-zone input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  width: 56px;
  height: 56px;
  background: var(--primary-subtle);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--primary);
}

/* ─── Review Table ──────────────────────────────────────────────────── */
.review-row.unknown {
  background: rgba(245, 158, 11, 0.06);
}

.review-row.ok {
  background: rgba(16, 185, 129, 0.04);
}

/* ─── Progress Steps ─────────────────────────────────────────────────── */
.steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 32px;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--dur-base) var(--ease);
}

.step.active .step-num {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-subtle);
}

.step.done .step-num {
  border-color: var(--success);
  background: var(--success);
  color: white;
}

.step-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.step.active .step-label {
  color: var(--text-primary);
}

.step.done .step-label {
  color: var(--success);
}

.step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 4px;
}

.step-line.done {
  background: var(--success);
}

/* ─── Charts ─────────────────────────────────────────────────────────── */
.chart-container {
  width: 100%;
  height: 360px;
}

.chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}

.marker-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  transition: all var(--dur-fast) var(--ease);
  user-select: none;
}

.marker-chip.selected {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: var(--primary);
}

.marker-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* ─── Bottom Navigation (Mobile) ─────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(13, 27, 46, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  z-index: 200;
  justify-content: space-around;
  align-items: center;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 500;
  transition: color var(--dur-fast) var(--ease);
  cursor: pointer;
  text-decoration: none;
  min-width: 60px;
}

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-item svg {
  transition: transform var(--dur-fast) var(--ease);
}

.bottom-nav-item.active svg {
  transform: scale(1.1);
}

/* ─── Mobile Header ──────────────────────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(6, 13, 26, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 200;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
}

.mobile-header-logo {
  font-size: 1.1rem;
  font-weight: 800;
  background: linear-gradient(135deg, #3b82f6, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── PWA Install Banner ─────────────────────────────────────────────── */
.pwa-banner {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 16px);
  left: 16px;
  right: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  animation: slideUp 0.3s var(--ease);
}

.pwa-banner-text {
  flex: 1;
  font-size: 0.85rem;
}

.pwa-banner-text strong {
  display: block;
  margin-bottom: 2px;
}

/* ─── Loading Spinner ────────────────────────────────────────────────── */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(59, 130, 246, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 13, 26, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 999;
  backdrop-filter: blur(4px);
}

/* ─── Toast Notifications ───────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.3s var(--ease);
  max-width: 340px;
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.4);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.4);
}

.toast.info {
  border-color: rgba(59, 130, 246, 0.4);
}

/* ─── Animations ─────────────────────────────────────────────────────── */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(20px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.4s var(--ease);
}

/* ─── Responsive — Mobile (<768px) ──────────────────────────────────── */
@media (max-width: 767px) {
  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
    padding: 72px 16px calc(var(--bottom-nav-h) + 16px);
  }

  .bottom-nav {
    display: flex;
  }

  .mobile-header {
    display: flex;
  }

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

  .stat-card {
    padding: 16px;
  }

  .stat-value {
    font-size: 1.6rem;
  }

  .login-card {
    padding: 24px 20px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .totp-inputs {
    gap: 8px;
  }

  .totp-digit {
    width: 42px;
    height: 50px;
    font-size: 1.3rem;
  }

  .card {
    padding: 16px;
  }

  .chart-container {
    height: 280px;
  }

  .toast-container {
    top: 64px;
    right: 12px;
    left: 12px;
  }

  .toast {
    max-width: 100%;
  }

  .pwa-banner {
    bottom: calc(var(--bottom-nav-h) + 8px);
  }
}

/* ─── Responsive — Tablet (768px–1023px) ────────────────────────────── */
@media (min-width: 768px) and (max-width: 1023px) {
  :root {
    --sidebar-w: 70px;
  }

  .sidebar-logo-text,
  .nav-item span,
  .nav-section-label,
  .user-name,
  .user-role {
    display: none;
  }

  .sidebar-logo {
    justify-content: center;
    padding: 20px;
  }

  .nav-item {
    justify-content: center;
    padding: 14px;
  }

  .sidebar-footer {
    padding: 12px;
  }

  .user-info {
    justify-content: center;
    padding: 10px;
  }
}

/* ─── Utility ────────────────────────────────────────────────────────── */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-muted) !important;
}

.text-success {
  color: var(--success) !important;
}

.text-danger {
  color: var(--danger) !important;
}

.text-primary-color {
  color: var(--primary) !important;
}

.fw-bold {
  font-weight: 700;
}

.d-flex {
  display: flex;
}

.align-center {
  align-items: center;
}

.gap-8 {
  gap: 8px;
}

.gap-12 {
  gap: 12px;
}

.gap-16 {
  gap: 16px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-24 {
  margin-top: 24px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-24 {
  margin-bottom: 24px;
}

.w-100 {
  width: 100%;
}

.hidden {
  display: none !important;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

@media (max-width: 767px) {

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .hide-mobile {
    display: none !important;
  }
}