/* ============================================================
   TormorOnline Vendor: Design System & App Styles
   Enterprise Telecom & Reseller Portal UI
   ============================================================ */

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

/* ---- Design Tokens ---- */
:root {
  /* Clean, authoritative telecom & fintech palette */
  --clr-primary: #2563EB;
  --clr-primary-dark: #1D4ED8;
  --clr-primary-light: #3B82F6;
  --clr-accent: #0284C7;
  --clr-success: #10B981;
  --clr-warning: #F59E0B;
  --clr-danger: #EF4444;
  --clr-info: #0284C7;

  /* Neutral Dark Theme (Deep Slate / Navy) */
  --clr-bg: #0A0D14;
  --clr-surface: #111622;
  --clr-surface-2: #182030;
  --clr-surface-3: #222D42;
  --clr-border: rgba(255, 255, 255, 0.09);
  --clr-border-subtle: rgba(255, 255, 255, 0.05);
  --clr-text: #F8FAFC;
  --clr-text-muted: #94A3B8;
  --clr-text-faint: #64748B;

  /* Spacing */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-2xl: 48px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-full: 9999px;

  /* Crisp, natural elevation shadows (No neon glows) */
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px -1px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.35), 0 2px 4px -2px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  /* Transitions */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 140ms;
  --dur-base: 220ms;
  --dur-slow: 350ms;

  /* Safe Area */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tab-h: calc(60px + var(--safe-bottom));
}

/* Light theme */
@media (prefers-color-scheme: light) {
  :root {
    --clr-bg: #F8FAFC;
    --clr-surface: #FFFFFF;
    --clr-surface-2: #F1F5F9;
    --clr-surface-3: #E2E8F0;
    --clr-border: #CBD5E1;
    --clr-border-subtle: #E2E8F0;
    --clr-text: #0F172A;
    --clr-text-muted: #64748B;
    --clr-text-faint: #94A3B8;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  }
}

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

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

body {
  font-family: var(--font);
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.5;
  min-height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  padding-top: var(--safe-top);
}

img, svg { display: block; max-width: 100%; }
a { color: var(--clr-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font); font-size: var(--text-base); }

/* ---- Layout ---- */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page {
  flex: 1;
  padding-bottom: var(--tab-h);
  animation: fadeIn var(--dur-base) var(--ease);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.container {
  max-width: 840px;
  margin: 0 auto;
  padding: 0 var(--sp-md);
}

/* ---- Splash Screen ---- */
#splash-screen {
  position: fixed;
  inset: 0;
  background: var(--clr-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-md);
  z-index: 9999;
  animation: splashOut 0.4s ease 1s forwards;
}

#splash-screen h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--clr-text);
  letter-spacing: -0.02em;
}

#splash-screen p {
  color: var(--clr-text-muted);
  font-size: var(--text-sm);
}

.splash-logo {
  width: 56px;
  height: 56px;
  background: var(--clr-primary);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

@keyframes splashOut {
  to { opacity: 0; pointer-events: none; visibility: hidden; }
}

/* ---- Top App Bar ---- */
.app-bar {
  position: sticky;
  top: var(--safe-top);
  left: 0; right: 0;
  z-index: 100;
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 var(--sp-md);
  gap: var(--sp-sm);
}

.app-bar__title {
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: -0.01em;
  flex: 1;
  color: var(--clr-text);
}

.app-bar__action {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--clr-text-muted);
  transition: all var(--dur-fast);
}

.app-bar__action:hover { background: var(--clr-surface-2); color: var(--clr-text); }

/* ---- Bottom Tab Bar (Mobile) ---- */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  z-index: 100;
  height: var(--tab-h);
  padding-bottom: var(--safe-bottom);
  background: var(--clr-surface);
  border-top: 1px solid var(--clr-border);
  display: flex;
  align-items: stretch;
}

.tab-bar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--clr-text-muted);
  font-size: 11px;
  font-weight: 500;
  min-height: 44px;
  padding: var(--sp-xs) 0;
  transition: color var(--dur-fast);
  -webkit-tap-highlight-color: transparent;
  text-decoration: none !important;
}

.tab-bar__item.active {
  color: var(--clr-primary-light);
  font-weight: 600;
}

.tab-bar__item svg {
  width: 22px;
  height: 22px;
}

.tab-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 14px);
  background: var(--clr-danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ---- Cards ---- */
.card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-md);
  padding: var(--sp-lg);
  box-shadow: var(--shadow-sm);
}

.card--muted {
  background: var(--clr-surface-2);
}

.card__title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--clr-text);
  margin-bottom: var(--sp-md);
}

/* ---- Stat Cards ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-md);
  margin-bottom: var(--sp-lg);
}

.stat-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-md);
  padding: var(--sp-md);
  box-shadow: var(--shadow-sm);
}

.stat-card__value {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  color: var(--clr-text);
}

.stat-card__label {
  font-size: var(--text-xs);
  color: var(--clr-text-muted);
  margin-top: var(--sp-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  padding: 10px var(--sp-md);
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  min-height: 42px;
  transition: background var(--dur-fast), border-color var(--dur-fast);
  cursor: pointer;
  border: 1px solid transparent;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  text-decoration: none !important;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px); }

.btn-primary {
  background: var(--clr-primary);
  color: #FFFFFF;
}
.btn-primary:hover:not(:disabled) {
  background: var(--clr-primary-dark);
}

.btn-success {
  background: var(--clr-success);
  color: #FFFFFF;
}
.btn-success:hover:not(:disabled) {
  background: #059669;
}

.btn-danger {
  background: var(--clr-danger);
  color: #FFFFFF;
}
.btn-danger:hover:not(:disabled) {
  background: #DC2626;
}

.btn-ghost {
  background: var(--clr-surface-2);
  color: var(--clr-text);
  border: 1px solid var(--clr-border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--clr-surface-3);
}

.btn-full { width: 100%; }
.btn-sm { padding: 6px var(--sp-sm); font-size: var(--text-xs); min-height: 32px; border-radius: var(--r-sm); }

/* Sticky bottom button */
.sticky-action {
  position: sticky;
  bottom: calc(var(--tab-h) + var(--sp-md));
  z-index: 10;
  padding: var(--sp-md);
  background: var(--clr-bg);
  border-top: 1px solid var(--clr-border);
  margin-top: var(--sp-lg);
}

/* ---- Forms ---- */
.form-group {
  margin-bottom: var(--sp-md);
}

.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--clr-text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-sm);
  padding: 10px var(--sp-md);
  color: var(--clr-text);
  font-size: var(--text-base);
  outline: none;
  transition: border-color var(--dur-fast);
}

.form-input:focus {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 1px var(--clr-primary);
}

.form-error {
  color: var(--clr-danger);
  font-size: var(--text-xs);
  margin-top: 4px;
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge--green, .badge--success {
  background: rgba(16, 185, 129, 0.12);
  color: #10B981;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge--yellow, .badge--warning {
  background: rgba(245, 158, 11, 0.12);
  color: #F59E0B;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge--red, .badge--danger {
  background: rgba(239, 68, 68, 0.12);
  color: #EF4444;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge--blue, .badge--info {
  background: rgba(37, 99, 235, 0.12);
  color: #3B82F6;
  border: 1px solid rgba(37, 99, 235, 0.25);
}

.badge--purple, .badge--neutral {
  background: rgba(148, 163, 184, 0.12);
  color: #94A3B8;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

/* ---- List Items ---- */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: 12px var(--sp-md);
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-sm);
  cursor: pointer;
  transition: background var(--dur-fast);
}

.list-item:hover {
  background: var(--clr-surface-2);
}

.list-item__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--clr-surface-2);
  color: var(--clr-text);
}

.list-item__content {
  flex: 1;
  min-width: 0;
}

.list-item__title {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--clr-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item__subtitle {
  font-size: var(--text-xs);
  color: var(--clr-text-muted);
  margin-top: 2px;
}

.list-item__right {
  text-align: right;
  flex-shrink: 0;
}

/* ---- Bottom Sheet & Modal Overlays ---- */
.sheet-backdrop, .overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-md);
  overflow-y: auto;
}

.modal-box {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--sp-lg);
  animation: modalScale 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.96) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  background: var(--clr-surface);
  border-top: 1px solid var(--clr-border);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  padding: var(--sp-lg);
  padding-bottom: calc(var(--sp-lg) + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform var(--dur-base) var(--ease);
}

.overlay .sheet {
  transform: translateY(0);
}

.sheet-backdrop.open .sheet {
  transform: translateY(0);
}

.sheet__handle {
  width: 36px;
  height: 4px;
  background: var(--clr-surface-3);
  border-radius: var(--r-full);
  margin: 0 auto var(--sp-md);
}

.sheet__title {
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--sp-md);
}

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed;
  top: calc(56px + var(--safe-top) + var(--sp-md));
  left: var(--sp-md);
  right: var(--sp-md);
  z-index: 500;
  pointer-events: none;
}

.toast {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-sm);
  padding: 12px var(--sp-md);
  margin-bottom: var(--sp-sm);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  font-size: var(--text-sm);
  animation: toastIn var(--dur-base) var(--ease);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast--success { border-left: 3px solid var(--clr-success); }
.toast--error   { border-left: 3px solid var(--clr-danger); }
.toast--info    { border-left: 3px solid var(--clr-info); }
.toast--warning { border-left: 3px solid var(--clr-warning); }

/* ---- Offline Banner ---- */
#offline-banner {
  display: none;
  position: fixed;
  top: calc(56px + var(--safe-top));
  left: 0; right: 0;
  z-index: 300;
  background: var(--clr-warning);
  color: #111827;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 8px var(--sp-md);
  text-align: center;
}

#offline-banner.show { display: block; }

/* ---- Update Banner ---- */
#update-banner {
  display: none;
  position: fixed;
  bottom: calc(var(--tab-h) + var(--sp-md));
  left: var(--sp-md);
  right: var(--sp-md);
  z-index: 300;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-primary);
  color: var(--clr-text);
  border-radius: var(--r-sm);
  padding: var(--sp-md);
  box-shadow: var(--shadow-md);
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-md);
  font-size: var(--text-sm);
}

#update-banner.show { display: flex; }

/* ---- Install Banner ---- */
#install-banner {
  display: none;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  color: var(--clr-text);
  padding: var(--sp-md);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-md);
  align-items: center;
  gap: var(--sp-md);
}

#install-banner.show { display: flex; }

/* ---- Copy Button Animation ---- */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  color: var(--clr-text);
  transition: all var(--dur-fast);
}

.copy-btn.copied {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--clr-success);
  color: var(--clr-success);
}

/* ---- Momo Payment Screen ---- */
.momo-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-lg);
  padding: var(--sp-xl) var(--sp-lg);
  text-align: center;
}

.momo-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #EAB308;
  color: #000000;
  font-weight: 700;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: var(--sp-md);
}

.momo-amount {
  font-size: 2.75rem;
  font-weight: 800;
  color: var(--clr-text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin: var(--sp-xs) 0 var(--sp-md);
}

.momo-number {
  font-size: var(--text-xl);
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  padding: var(--sp-md);
  border-radius: var(--r-sm);
  margin: var(--sp-md) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.momo-ref {
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  color: var(--clr-primary-light);
  padding: 8px var(--sp-md);
  border-radius: var(--r-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  font-size: var(--text-base);
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
}

/* ---- Purge Zone ---- */
.purge-zone {
  border: 1px solid var(--clr-danger);
  border-radius: var(--r-md);
  padding: var(--sp-lg);
  background: rgba(239, 68, 68, 0.04);
}

.purge-zone__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-md);
}

/* ---- Pull to Refresh indicator ---- */
.ptr-indicator {
  text-align: center;
  padding: var(--sp-md);
  color: var(--clr-text-muted);
  font-size: var(--text-xs);
  display: none;
}

.ptr-indicator.active { display: block; }

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: var(--sp-xl) var(--sp-md);
  color: var(--clr-text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--sp-md);
  color: var(--clr-text-faint);
}

.empty-state h3 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--clr-text);
  margin-bottom: var(--sp-xs);
}

.skeleton {
  background: linear-gradient(90deg, var(--clr-surface-2) 25%, var(--clr-surface-3) 50%, var(--clr-surface-2) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.6s infinite ease-in-out;
  border-radius: var(--r-sm);
}

@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Login PC Split Layout ---- */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-lg);
  background: radial-gradient(circle at 85% 15%, rgba(37, 99, 235, 0.12), transparent 45%),
              radial-gradient(circle at 15% 85%, rgba(2, 132, 199, 0.08), transparent 45%),
              var(--clr-bg);
}

.login-card-wrapper {
  width: 100%;
  max-width: 440px;
}

@media (min-width: 960px) {
  .login-card-wrapper {
    max-width: 1040px;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--r-xl);
    overflow: hidden;
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.6);
  }

  .login-hero {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: var(--sp-2xl) var(--sp-xl);
    background: linear-gradient(150deg, #111827 0%, #0c111d 100%);
    border-right: 1px solid var(--clr-border);
  }

  .login-hero-badges {
    display: flex;
    flex-direction: column;
    gap: var(--sp-md);
    margin: var(--sp-xl) 0;
  }

  .login-hero-item {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-md);
    padding: 14px var(--sp-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--clr-border-subtle);
    border-radius: var(--r-md);
  }

  .login-form-side {
    padding: var(--sp-2xl);
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
}

@media (max-width: 959px) {
  .login-hero { display: none; }
  .login-form-side { width: 100%; }
}

/* ---- Sidebar & PC Desktop Layout ---- */
@media (min-width: 768px) {
  .tab-bar { display: none !important; }
  .page { padding-bottom: 0; }

  .app-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
  }

  .app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: hidden;
    background: var(--clr-bg);
  }

  .desktop-topbar {
    height: 64px;
    background: var(--clr-surface);
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--sp-xl);
    position: sticky;
    top: 0;
    z-index: 50;
  }

  .desktop-topbar__left {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
  }

  .desktop-topbar__right {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
  }

  .container {
    max-width: 1240px;
    padding: var(--sp-xl) var(--sp-xl);
    margin: 0;
    width: 100%;
  }

  .stat-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: var(--sp-md) !important;
  }

  .desktop-table-container {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--r-md);
    overflow-x: auto;
    margin-bottom: var(--sp-lg);
  }

  .desktop-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: var(--text-sm);
  }

  .desktop-table th {
    background: var(--clr-surface-2);
    padding: 12px var(--sp-md);
    font-weight: 600;
    color: var(--clr-text-muted);
    border-bottom: 1px solid var(--clr-border);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
  }

  .desktop-table td {
    padding: 14px var(--sp-md);
    border-bottom: 1px solid var(--clr-border-subtle);
    color: var(--clr-text);
  }

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

  .sidebar {
    background: var(--clr-surface);
    border-right: 1px solid var(--clr-border);
    padding: var(--sp-lg);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }

  .sidebar__logo {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    margin-bottom: var(--sp-xl);
  }

  .sidebar__nav { flex: 1; }

  .sidebar__link {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    padding: 10px var(--sp-md);
    border-radius: var(--r-sm);
    color: var(--clr-text-muted);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--dur-fast);
    margin-bottom: var(--sp-xs);
    text-decoration: none !important;
  }

  .sidebar__link:hover { background: var(--clr-surface-2); color: var(--clr-text); }
  .sidebar__link.active { background: var(--clr-surface-2); color: var(--clr-primary-light); font-weight: 600; }

  /* Collapsible Sidebar States */
  .app-layout {
    transition: grid-template-columns 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .app-layout.sidebar-collapsed {
    grid-template-columns: 74px 1fr;
  }

  .sidebar.collapsed {
    padding: var(--sp-md) var(--sp-xs);
    width: 74px;
    align-items: center;
  }

  .sidebar.collapsed .sidebar__logo {
    justify-content: center;
    margin-bottom: var(--sp-lg);
  }

  .sidebar.collapsed .sidebar__logo .sidebar__brand-text {
    display: none !important;
  }

  .sidebar.collapsed .sidebar__nav {
    width: 100%;
  }

  .sidebar.collapsed .sidebar__link {
    justify-content: center;
    padding: 11px 0;
    gap: 0;
    position: relative;
    border-radius: var(--r-sm);
  }

  .sidebar.collapsed .sidebar__link span {
    display: none !important;
  }

  .sidebar.collapsed .sidebar__link svg {
    margin: 0 auto;
  }

  .sidebar.collapsed .sidebar__footer {
    width: 100%;
  }

  .sidebar.collapsed .sidebar__footer .sidebar__user-label {
    display: none !important;
  }

  .sidebar.collapsed .sidebar__collapse-btn svg {
    transform: rotate(180deg);
  }

  .sidebar__collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px 0;
    margin-top: 4px;
    background: transparent;
    border: 1px dashed var(--clr-border);
    border-radius: var(--r-sm);
    color: var(--clr-text-muted);
    cursor: pointer;
    transition: all var(--dur-fast);
  }

  .sidebar__collapse-btn:hover {
    background: var(--clr-surface-2);
    color: var(--clr-text);
    border-color: var(--clr-primary-light);
  }
}

/* ---- Reusable Table Pagination Controls ---- */
.pagination-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-md);
  padding: var(--sp-md) var(--sp-lg);
  background: var(--clr-surface);
  border-top: 1px solid var(--clr-border);
  border-radius: 0 0 var(--r-md) var(--r-md);
  flex-wrap: wrap;
}

.pagination-info {
  font-size: var(--text-xs);
  color: var(--clr-text-muted);
  font-weight: 500;
}

.pagination-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  border: 1px solid var(--clr-border);
  background: var(--clr-surface-2);
  color: var(--clr-text);
  cursor: pointer;
  transition: all var(--dur-fast);
  user-select: none;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--clr-primary);
  border-color: var(--clr-primary);
  color: #fff;
}

.pagination-btn.active {
  background: var(--clr-primary);
  border-color: var(--clr-primary);
  color: #fff;
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- Utility classes ---- */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--clr-text-muted); }
.text-sm     { font-size: var(--text-sm); }
.text-xs     { font-size: var(--text-xs); }
.text-lg     { font-size: var(--text-lg); }
.text-xl     { font-size: var(--text-xl); }
.font-bold   { font-weight: 700; }
.font-medium { font-weight: 500; }
.mt-sm       { margin-top: var(--sp-sm); }
.mt-md       { margin-top: var(--sp-md); }
.mt-lg       { margin-top: var(--sp-lg); }
.mb-xs       { margin-bottom: var(--sp-xs); }
.mb-sm       { margin-bottom: var(--sp-sm); }
.mb-md       { margin-bottom: var(--sp-md); }
.mb-lg       { margin-bottom: var(--sp-lg); }
.gap-sm      { gap: var(--sp-sm); }
.gap-md      { gap: var(--sp-md); }
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1      { flex: 1; }
.hidden      { display: none !important; }
.grid-2      { display: grid; grid-template-columns: repeat(2,1fr); gap: var(--sp-md); }
.w-full      { width: 100%; }

/* ---- Enhanced Mobile View & Touch Optimization ---- */
@media (max-width: 767px) {
  /* Page layout & scrolling */
  .page {
    padding: var(--sp-md) var(--sp-sm) calc(var(--tab-h) + var(--safe-bottom) + 24px) !important;
  }

  .container {
    padding-left: var(--sp-sm) !important;
    padding-right: var(--sp-sm) !important;
  }

  /* App bar on mobile */
  .app-bar {
    position: sticky;
    top: 0;
    z-index: 95;
    background: rgba(17, 22, 34, 0.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--clr-border);
    padding: 0 var(--sp-md);
    height: 54px;
  }

  /* Tab bar touch enhancements */
  .tab-bar {
    height: 60px;
    padding-bottom: max(var(--safe-bottom), 6px);
    background: rgba(17, 22, 34, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--clr-border);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.35);
  }

  .tab-bar__item {
    font-size: 10px;
    gap: 2px;
    min-height: 48px;
    position: relative;
    border-radius: var(--r-sm);
    margin: 2px 2px;
    transition: all var(--dur-fast);
  }

  .tab-bar__item:active {
    transform: scale(0.92);
  }

  .tab-bar__item.active {
    color: var(--clr-primary-light);
    background: rgba(37, 99, 235, 0.12);
  }

  .tab-bar__item svg {
    width: 20px;
    height: 20px;
  }

  /* Responsive Grid systems on mobile */
  .stat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    margin-bottom: var(--sp-md) !important;
  }

  .stat-card {
    padding: 10px 12px !important;
    border-radius: var(--r-sm) !important;
  }

  .stat-card__value {
    font-size: 1.15rem !important;
  }

  .stat-card__label {
    font-size: 10px !important;
    letter-spacing: 0.02em !important;
  }

  .grid-2, .grid-3 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Cards on mobile */
  .card {
    padding: var(--sp-md) !important;
    border-radius: var(--r-md) !important;
    margin-bottom: var(--sp-md) !important;
  }

  /* Touch-friendly inputs & buttons */
  .form-input, select.form-input, textarea.form-input {
    font-size: 16px !important; /* Prevents auto-zoom in iOS Safari */
    min-height: 44px;
  }

  .btn {
    min-height: 44px;
    touch-action: manipulation;
  }

  .btn-sm {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 12px;
  }

  /* Tables on mobile */
  .desktop-table-container {
    border-radius: var(--r-sm);
    margin-left: -4px;
    margin-right: -4px;
    -webkit-overflow-scrolling: touch;
  }

  .desktop-table {
    font-size: 12px !important;
  }

  .desktop-table th, .desktop-table td {
    padding: 8px 10px !important;
    white-space: nowrap;
  }

  /* Modals on mobile */
  .modal-box {
    padding: 16px !important;
    border-radius: var(--r-lg) !important;
    max-height: 88vh !important;
    width: 100% !important;
  }

  .overlay {
    padding: 12px !important;
    align-items: flex-end !important; /* Slide up nicely from bottom on mobile */
  }
}

/* Extra small screens (e.g. iPhone SE, 360px Android) */
@media (max-width: 380px) {
  .stat-card__value {
    font-size: 1.05rem !important;
  }
  .tab-bar__item span {
    font-size: 9px !important;
  }
}

