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

:root {
  --color-bg:          #f8fafc;
  --color-surface:     #ffffff;
  --color-border:      #e2e8f0;
  --color-border-hover:#cbd5e1;
  --color-text:        #0f172a;
  --color-text-muted:  #64748b;
  --color-text-light:  #94a3b8;

  --color-primary:     #6366f1;
  --color-primary-dk:  #4f46e5;
  --color-primary-lt:  #eef2ff;

  --color-success:     #10b981;
  --color-success-lt:  #d1fae5;
  --color-danger:      #ef4444;
  --color-danger-lt:   #fee2e2;
  --color-warning:     #f59e0b;
  --color-warning-lt:  #fef3c7;
  --color-info:        #3b82f6;
  --color-info-lt:     #dbeafe;

  --color-owed:        #10b981;
  --color-owed-lt:     #d1fae5;
  --color-owes:        #ef4444;
  --color-owes-lt:     #fee2e2;

  --color-sidebar:     #1e1b4b;
  --color-sidebar-item:#312e81;

  --radius-sm:   6px;
  --radius-md:   12px;
  --radius-lg:   18px;
  --radius-full: 9999px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:  0 10px 32px rgba(0,0,0,.12);

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --sidebar-w: 240px;
  --topbar-h:  64px;
  --transition: 180ms ease;
}

[data-theme="dark"] {
  --color-bg:          #0f172a;
  --color-surface:     #1e293b;
  --color-border:      #334155;
  --color-border-hover:#475569;
  --color-text:        #f1f5f9;
  --color-text-muted:  #94a3b8;
  --color-text-light:  #64748b;
  --color-primary-lt:  #1e1b4b;
  --color-success-lt:  #064e3b;
  --color-danger-lt:   #450a0a;
  --color-warning-lt:  #451a03;
  --color-info-lt:     #1e3a8a;
  --color-owed-lt:     #064e3b;
  --color-owes-lt:     #450a0a;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--color-sidebar);
  color: #c7d2fe;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}
.sidebar-logo {
  padding: 20px 20px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 8px;
}
.sidebar-logo .logo-icon {
  width: 34px; height: 34px;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.sidebar-section { padding: 8px 12px 4px; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #818cf8; font-weight: 600; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  color: #a5b4fc;
  font-size: .9rem;
  transition: background var(--transition), color var(--transition);
  margin: 1px 8px;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: var(--color-sidebar-item);
  color: #fff;
  text-decoration: none;
}
.sidebar-nav a .nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  font-size: .85rem; color: #a5b4fc;
}

/* Main content */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-weight: 600; font-size: 1.05rem; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* Page content */
.page { padding: 28px 32px; flex: 1; max-width: 1100px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 1.5rem; font-weight: 700; }
.page-subtitle { color: var(--color-text-muted); font-size: .9rem; margin-top: 2px; }

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

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-muted); font-weight: 600; margin-bottom: 6px; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.stat-value.positive { color: var(--color-owed); }
.stat-value.negative { color: var(--color-owes); }
.stat-value.neutral  { color: var(--color-info); }

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 500;
  font-size: .9rem;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn-sm   { padding: 5px 12px; font-size: .8rem; }
.btn-lg   { padding: 12px 28px; font-size: 1rem; }
.btn-block { width: 100%; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dk); color: #fff; }

.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { filter: brightness(.9); }

.btn-danger  { background: var(--color-danger); color: #fff; }
.btn-danger:hover { filter: brightness(.9); }

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

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

.btn-icon {
  padding: 7px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid var(--color-border);
  color: var(--color-text-muted); cursor: pointer;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--color-bg); color: var(--color-text); }

/* ─── Forms ─────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: 6px; color: var(--color-text); }
.form-label .required { color: var(--color-danger); margin-left: 2px; }
.form-hint { font-size: .78rem; color: var(--color-text-muted); margin-top: 4px; }

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: .9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form-control.is-invalid { border-color: var(--color-danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239,68,68,.15); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; flex-shrink: 0; }
.input-prefix {
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: .9rem;
  white-space: nowrap;
}
.input-group.has-prefix .form-control { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: none; }

.form-error { color: var(--color-danger); font-size: .8rem; margin-top: 4px; }
.form-errors-list { background: var(--color-danger-lt); border: 1px solid var(--color-danger); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 20px; }
.form-errors-list li { color: var(--color-danger); font-size: .87rem; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row, .form-row-3 { grid-template-columns: 1fr; } }

/* Checkbox & Radio */
.check-group { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check-group input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--color-primary); }
.check-group label { font-size: .9rem; cursor: pointer; }

/* ─── Alerts / Flash ────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 20px;
}
.alert-success { background: var(--color-success-lt); color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger   { background: var(--color-danger-lt);  color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning  { background: var(--color-warning-lt); color: #92400e; border: 1px solid #fcd34d; }
.alert-info     { background: var(--color-info-lt);    color: #1e40af; border: 1px solid #93c5fd; }

/* ─── Tables ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--color-border); }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
tbody td {
  padding: 13px 16px;
  font-size: .88rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--color-bg); }

/* ─── Badges ────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-success  { background: var(--color-success-lt);  color: #065f46; }
.badge-danger   { background: var(--color-danger-lt);   color: #991b1b; }
.badge-warning  { background: var(--color-warning-lt);  color: #92400e; }
.badge-info     { background: var(--color-info-lt);     color: #1e40af; }
.badge-gray     { background: var(--color-border);      color: var(--color-text-muted); }
.badge-primary  { background: var(--color-primary-lt);  color: var(--color-primary-dk); }

/* ─── Avatar ────────────────────────────────────────────── */
.avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: .7rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 1rem; }
.avatar-xl { width: 72px; height: 72px; font-size: 1.4rem; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -8px; border: 2px solid var(--color-surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ─── Expense / Balance items ───────────────────────────── */
.expense-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
}
.expense-item:last-child { border-bottom: none; }
.expense-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  background: var(--color-primary-lt);
  color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
}
.expense-info { flex: 1; min-width: 0; }
.expense-title { font-weight: 500; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.expense-meta { font-size: .78rem; color: var(--color-text-muted); margin-top: 1px; }
.expense-amount { text-align: right; flex-shrink: 0; }
.expense-amount .owed  { color: var(--color-owed); font-weight: 600; font-size: .95rem; }
.expense-amount .owes  { color: var(--color-owes); font-weight: 600; font-size: .95rem; }
.expense-amount .total { font-size: .78rem; color: var(--color-text-muted); }

/* Balance bars */
.balance-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}
.balance-item:last-child { border-bottom: none; }
.balance-user { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.balance-name { font-weight: 500; font-size: .9rem; }
.balance-amount { font-weight: 600; font-size: .95rem; flex-shrink: 0; }
.balance-amount.positive { color: var(--color-owed); }
.balance-amount.negative { color: var(--color-owes); }
.balance-amount.zero     { color: var(--color-text-muted); }

/* Suggestion cards */
.suggestion-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
}
.suggestion-arrow { color: var(--color-text-muted); flex-shrink: 0; }
.suggestion-amount { font-weight: 700; color: var(--color-primary); font-size: 1.05rem; flex: 1; text-align: center; }

/* ─── Group cards ────────────────────────────────────────── */
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.group-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition);
  cursor: pointer;
}
.group-card:hover { box-shadow: var(--shadow-md); border-color: var(--color-border-hover); text-decoration: none; }
.group-card-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-primary), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  color: #fff;
  margin-bottom: 14px;
}
.group-card-name { font-weight: 600; font-size: 1rem; margin-bottom: 4px; color: var(--color-text); }
.group-card-meta { font-size: .8rem; color: var(--color-text-muted); }
.group-card-balance { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--color-border); display: flex; justify-content: space-between; align-items: center; }

/* ─── Split selector ─────────────────────────────────────── */
.split-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.split-tab {
  padding: 7px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  font-size: .84rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--color-surface);
  color: var(--color-text-muted);
  transition: all var(--transition);
}
.split-tab.active, .split-tab:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.split-panel { display: none; }
.split-panel.active { display: block; }

/* Participant row */
.participant-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}
.participant-row:last-child { border-bottom: none; }
.participant-info { flex: 1; display: flex; align-items: center; gap: 10px; }
.participant-amount { width: 130px; flex-shrink: 0; }

/* ─── Modals ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 16px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  transform: translateY(12px);
  transition: transform var(--transition);
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 1.1rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--color-text-muted); line-height: 1; padding: 4px; }
.modal-footer { margin-top: 24px; display: flex; gap: 10px; justify-content: flex-end; }

/* ─── Auth pages ─────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4f46e5 100%);
  padding: 24px 16px;
}
.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo .logo-mark {
  width: 52px; height: 52px;
  background: var(--color-primary);
  border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  color: #fff;
  margin-bottom: 12px;
}
.auth-logo h1 { font-size: 1.4rem; font-weight: 700; }
.auth-logo p  { color: var(--color-text-muted); font-size: .88rem; margin-top: 4px; }

.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--color-text-muted); font-size: .82rem;
  margin: 20px 0;
}
.divider::before, .divider::after { content:''; flex:1; height:1px; background:var(--color-border); }

.btn-google {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  width: 100%;
  padding: 10px;
  gap: 10px;
}
.btn-google:hover { border-color: var(--color-border-hover); background: var(--color-bg); }
.google-icon { width: 18px; height: 18px; }

/* ─── Empty states ───────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: .4; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--color-text); margin-bottom: 6px; }
.empty-state p { font-size: .88rem; }

/* ─── Utilities ──────────────────────────────────────────── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end  { justify-content: flex-end; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }
.gap-4        { gap: 16px; }
.gap-6        { gap: 24px; }
.flex-1       { flex: 1; }
.min-w-0      { min-width: 0; }
.text-sm      { font-size: .85rem; }
.text-xs      { font-size: .75rem; }
.text-lg      { font-size: 1.1rem; }
.text-xl      { font-size: 1.25rem; }
.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-bold    { font-weight: 700; }
.text-muted   { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-danger  { color: var(--color-danger); }
.text-primary { color: var(--color-primary); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rounded   { border-radius: var(--radius-sm); }
.rounded-full { border-radius: var(--radius-full); }
.hidden    { display: none !important; }
.w-full    { width: 100%; }
.divider-h { height: 1px; background: var(--color-border); margin: 20px 0; }

/* ─── Mobile ─────────────────────────────────────────────── */
.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  z-index: 100;
  padding: 6px 0 env(safe-area-inset-bottom);
}
.mobile-nav-inner { display: flex; }
.mobile-nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 6px 4px;
  color: var(--color-text-muted);
  font-size: .65rem;
  text-decoration: none;
  gap: 3px;
  transition: color var(--transition);
}
.mobile-nav-item.active, .mobile-nav-item:hover { color: var(--color-primary); text-decoration: none; }
.mobile-nav-item svg { width: 20px; height: 20px; }
.mobile-menu-btn { display: none; background: none; border: none; cursor: pointer; padding: 4px; color: var(--color-text); }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
  }
  .sidebar-overlay.active { display: block; }
  .main { margin-left: 0; }
  .page { padding: 20px 16px 80px; }
  .topbar { padding: 0 16px; }
  .mobile-nav { display: block; }
  .mobile-menu-btn { display: flex; align-items: center; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .group-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .modal { padding: 20px 16px; }
}

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-border-hover); }

/* ─── Animations ─────────────────────────────────────────── */
@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
.fade-in { animation: fadeIn .2s ease forwards; }

/* ─── Settlement marker ──────────────────────────────────── */
.settlement-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  background: var(--color-success-lt);
  color: var(--color-success);
  border-radius: var(--radius-full);
  font-size: .72rem;
  font-weight: 600;
}

/* ─── Progress / loading ─────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Tab bar (in-page) ──────────────────────────────────── */
.tabs-bar { display: flex; border-bottom: 2px solid var(--color-border); margin-bottom: 24px; gap: 4px; overflow-x: auto; }
.tab-item {
  padding: 10px 18px;
  font-size: .88rem; font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.tab-item.active, .tab-item:hover { color: var(--color-primary); border-bottom-color: var(--color-primary); text-decoration: none; }

/* ─── Currency display ───────────────────────────────────── */
.currency-tag {
  display: inline-flex;
  padding: 1px 6px;
  background: var(--color-primary-lt);
  color: var(--color-primary-dk);
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 600;
}
