/* =====================================================================
   PayWe — design system (tokens + components)
   ===================================================================== */

/* ---- Primitive tokens (theme-invariant) ---- */
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 17px;
  --text-lg: 20px;
  --text-xl: 26px;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-full: 999px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --tap: 44px;
}

/* ---- Semantic tokens: light (default) ---- */
:root {
  --color-bg: #F7F9FC;
  --color-surface: #FFFFFF;
  --color-surface-alt: #F0F3F7;
  --color-text: #1B2431;
  --color-text-muted: #5C6B7A;
  --color-border: #E2E6EC;
  --color-border-strong: #C8CED6;

  --color-primary: #0891B2;
  --color-primary-dark: #0E7490;
  --color-primary-contrast: #FFFFFF;
  --color-primary-muted: #E0F7FA;

  --color-owed: #15803D;
  --color-owed-bg: #DCFCE7;
  --color-owe: #B45309;
  --color-owe-bg: #FEF3C7;
  --color-danger: #DC2626;
  --color-danger-dark: #B91C1C;
  --color-danger-contrast: #FFFFFF;

  --cat-dining: #DC2626;    --cat-dining-bg: #FEE2E2;
  --cat-petrol: #7C3AED;    --cat-petrol-bg: #EDE9FE;
  --cat-accommodation: #2563EB; --cat-accommodation-bg: #DBEAFE;
  --cat-transport: #0891B2; --cat-transport-bg: #E0F7FA;
  --cat-groceries: #16A34A; --cat-groceries-bg: #DCFCE7;
  --cat-activities: #D97706; --cat-activities-bg: #FEF3C7;
  --cat-other: #64748B;     --cat-other-bg: #F1F5F9;

  --shadow-sm: 0 1px 2px rgba(15, 22, 41, 0.05);
  --shadow: 0 2px 8px rgba(15, 22, 41, 0.08);
  --shadow-lg: 0 8px 24px rgba(15, 22, 41, 0.12);

  --topbar-bg: #FFFFFF;
  --brand-from: #F0F9FF;
  --brand-to: #E0F2FE;
  --skeleton-from: #E2E6EC;
  --skeleton-via: #F0F3F7;
  --focus-ring: rgba(8, 145, 178, 0.25);
}

/* ---- Semantic tokens: dark ---- */
[data-theme="dark"] {
  --color-bg: #0F1623;
  --color-surface: #1A2332;
  --color-surface-alt: #232E3F;
  --color-text: #E8ECF2;
  --color-text-muted: #94A3B8;
  --color-border: #2D3B50;
  --color-border-strong: #3D4F66;

  --color-primary: #22D3EE;
  --color-primary-dark: #06B6D4;
  --color-primary-contrast: #0F1623;
  --color-primary-muted: #164E63;

  --color-owed: #4ADE80;
  --color-owed-bg: #14532D;
  --color-owe: #FBBF24;
  --color-owe-bg: #451A03;
  --color-danger: #F87171;
  --color-danger-dark: #EF4444;
  --color-danger-contrast: #FFFFFF;

  --cat-dining: #F87171;    --cat-dining-bg: #450A0A;
  --cat-petrol: #A78BFA;    --cat-petrol-bg: #2E1065;
  --cat-accommodation: #60A5FA; --cat-accommodation-bg: #1E3A5F;
  --cat-transport: #22D3EE; --cat-transport-bg: #164E63;
  --cat-groceries: #4ADE80; --cat-groceries-bg: #14532D;
  --cat-activities: #FBBF24; --cat-activities-bg: #451A03;
  --cat-other: #94A3B8;     --cat-other-bg: #1E293B;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.45);

  --topbar-bg: #1A2332;
  --brand-from: #164E63;
  --brand-to: #1A2332;
  --skeleton-from: #232E3F;
  --skeleton-via: #2D3B50;
  --focus-ring: rgba(34, 211, 238, 0.35);
}

/* No-JS fallback: follow OS preference when data-theme is not set */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #0F1623;
    --color-surface: #1A2332;
    --color-surface-alt: #232E3F;
    --color-text: #E8ECF2;
    --color-text-muted: #94A3B8;
    --color-border: #2D3B50;
    --color-border-strong: #3D4F66;
    --color-primary: #22D3EE;
    --color-primary-dark: #06B6D4;
    --color-primary-contrast: #0F1623;
    --color-primary-muted: #164E63;
    --color-owed: #4ADE80;
    --color-owed-bg: #14532D;
    --color-owe: #FBBF24;
    --color-owe-bg: #451A03;
    --color-danger: #F87171;
    --color-danger-dark: #EF4444;
    --color-danger-contrast: #FFFFFF;
    --cat-dining: #F87171;    --cat-dining-bg: #450A0A;
    --cat-petrol: #A78BFA;    --cat-petrol-bg: #2E1065;
    --cat-accommodation: #60A5FA; --cat-accommodation-bg: #1E3A5F;
    --cat-transport: #22D3EE; --cat-transport-bg: #164E63;
    --cat-groceries: #4ADE80; --cat-groceries-bg: #14532D;
    --cat-activities: #FBBF24; --cat-activities-bg: #451A03;
    --cat-other: #94A3B8;     --cat-other-bg: #1E293B;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.45);
    --topbar-bg: #1A2332;
    --brand-from: #164E63;
    --brand-to: #1A2332;
    --skeleton-from: #232E3F;
    --skeleton-via: #2D3B50;
    --focus-ring: rgba(34, 211, 238, 0.35);
  }
}

/* ---- Base ---- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  max-width: 100%;
  overflow-x: hidden;
}

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

/* ---- Focus-visible (a11y) ---- */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

button:focus-visible,
.button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[type="checkbox"]:focus-visible,
[type="radio"]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* =====================================================================
   Layout
   ===================================================================== */
.shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}
.shell--narrow { max-width: 460px; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--color-border);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.topbar__title {
  font-size: var(--text-md);
  font-weight: 800;
}
.topbar__title a {
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
}
.topbar__logo { width: 28px; height: 28px; border-radius: var(--radius-sm); flex-shrink: 0; }

.beta-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  background: var(--color-owe-bg);
  color: var(--color-owe);
  border: 1px solid var(--color-border);
}

.topbar__actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

/* Page */
.page { padding: var(--space-5) 0 var(--space-7); }
.page--with-bar { padding-bottom: calc(var(--space-7) + 80px); }
.page__title {
  font-size: var(--text-xl);
  font-weight: 800;
  margin: 0 0 var(--space-2);
}
.page__subtitle {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin: 0 0 var(--space-5);
}

/* Brand hero (auth screens) */
.brand {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  background: linear-gradient(160deg, var(--brand-from), var(--brand-to));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
}
.brand__logo { width: 64px; height: 64px; border-radius: 18px; box-shadow: var(--shadow); }
.brand__name { font-size: var(--text-xl); font-weight: 800; margin: var(--space-3) 0 var(--space-1); }
.brand__tagline { color: var(--color-text-muted); margin: 0 0 var(--space-4); }
.brand__points { display: flex; justify-content: center; gap: var(--space-3); flex-wrap: wrap; }
.brand__point {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 600;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3);
}

/* =====================================================================
   Components
   ===================================================================== */

/* Card */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}
.card + .card { margin-top: var(--space-3); }
.card--muted { background: var(--color-surface-alt); }
[data-theme="dark"] .card { border-color: var(--color-border-strong); }

/* List row */
.list-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--color-text);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.list-row:hover { text-decoration: none; }
.list-row:active { transform: scale(0.99); }
.list-row + .list-row { margin-top: var(--space-2); }
.list-row__main { flex: 1; min-width: 0; }
.list-row__title { font-weight: 600; }
.list-row__sub { color: var(--color-text-muted); font-size: var(--text-sm); }
.list-row__end { text-align: right; flex-shrink: 0; min-width: 0; }

.list-row--plain {
  border: none;
  padding: var(--space-2) 0;
  background: transparent;
}
.list-row--plain:active { transform: none; }
.list-row--divider {
  border: none;
  border-top: 1px solid var(--color-border);
  border-radius: 0;
  padding: var(--space-3) 0 0;
  background: transparent;
}
.list-row--divider:active { transform: none; }

.list-row--self {
  background: var(--color-surface-alt);
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
  max-width: 100%;
}
.badge--owed { background: var(--color-owed-bg); color: var(--color-owed); }
.badge--owe { background: var(--color-owe-bg); color: var(--color-owe); }
.badge--neutral { background: var(--color-surface-alt); color: var(--color-text-muted); }
.badge--code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px var(--space-4);
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  min-height: var(--tap);
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.button:active { transform: translateY(1px); }
.button--primary { background: var(--color-primary); color: var(--color-primary-contrast); }
.button--primary:hover { background: var(--color-primary-dark); text-decoration: none; }
.button--secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.button--secondary:hover { border-color: var(--color-border-strong); text-decoration: none; }
.button--danger { background: var(--color-danger); color: var(--color-danger-contrast); }
.button--danger:hover { background: var(--color-danger-dark); text-decoration: none; }
.button--block { width: 100%; }
.button--sm { padding: 6px var(--space-3); font-size: var(--text-sm); min-height: 36px; }
.button--icon {
  padding: var(--space-2);
  min-width: var(--tap);
  min-height: var(--tap);
}

/* Forms */
.form-field { display: block; margin-bottom: var(--space-4); }
.form-field label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-1);
  color: var(--color-text);
}
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 10px var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: var(--text-base);
  font-family: var(--font);
  background: var(--color-surface);
  color: var(--color-text);
  min-height: var(--tap);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Dark mode inputs */
[data-theme="dark"] .form-field input,
[data-theme="dark"] .form-field select,
[data-theme="dark"] .form-field textarea,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.form-field textarea { resize: vertical; min-height: 80px; }
.form-hint { color: var(--color-text-muted); font-size: var(--text-xs); margin-top: 2px; }
.form-error { color: var(--color-danger); font-size: var(--text-sm); margin-top: var(--space-1); }
.inline-error { color: var(--color-danger); font-size: var(--text-sm); }

.form-actions { margin-top: var(--space-5); }

/* Segmented control (for split-mode radios) */
.segmented {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface-alt);
}
.segmented__option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background 0.15s, color 0.15s;
  min-height: var(--tap);
  align-self: stretch;
}
.segmented__option input { position: absolute; opacity: 0; pointer-events: none; }
.segmented__option:has(input:checked) {
  background: var(--color-surface);
  color: var(--color-text);
}
.segmented__option:has(input:checked):first-child {
  border-top-left-radius: var(--radius);
  border-bottom-left-radius: var(--radius);
}
.segmented__option:has(input:checked):last-child {
  border-top-right-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}
.segmented__option + .segmented__option { border-left: 1px solid var(--color-border); }

/* Toast */
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
  font-weight: 500;
}
.toast--success { background: var(--color-owed-bg); color: var(--color-owed); }
.toast--error { background: var(--color-owe-bg); color: var(--color-danger); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-4);
  color: var(--color-text-muted);
}
.empty-state__icon { margin-bottom: var(--space-3); }
.empty-state__icon .icon { width: 40px; height: 40px; color: var(--color-text-muted); }
.empty-state__title { font-weight: 600; color: var(--color-text); }

/* Category glyphs (SVG icons) */
.glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.glyph .icon { width: 20px; height: 20px; }
.glyph--dining { background: var(--cat-dining-bg); color: var(--cat-dining); }
.glyph--petrol { background: var(--cat-petrol-bg); color: var(--cat-petrol); }
.glyph--accommodation { background: var(--cat-accommodation-bg); color: var(--cat-accommodation); }
.glyph--transport { background: var(--cat-transport-bg); color: var(--cat-transport); }
.glyph--groceries { background: var(--cat-groceries-bg); color: var(--cat-groceries); }
.glyph--activities { background: var(--cat-activities-bg); color: var(--cat-activities); }
.glyph--other { background: var(--cat-other-bg); color: var(--cat-other); }

/* Amount */
.amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.amount--owed { color: var(--color-owed); }
.amount--owe { color: var(--color-owe); }

/* Section title */
.section-title {
  font-size: var(--text-md);
  font-weight: 700;
  margin: var(--space-5) 0 var(--space-3);
}

/* Icon component */
.icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
  flex-shrink: 0;
}
.icon--filled { fill: currentColor; stroke: none; }
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 24px; height: 24px; }
.icon--xl { width: 40px; height: 40px; }

/* Self tag for settle screen */
.self-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--color-primary-muted);
  color: var(--color-primary);
  margin-left: var(--space-1);
}

/* Skeleton / loading shimmer */
.skeleton {
  background: linear-gradient(90deg, var(--skeleton-from) 25%, var(--skeleton-via) 50%, var(--skeleton-from) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Split row (subset panel) */
.split-row { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
.split-row input[type="number"] { width: 72px; }
.split-row--check { margin-top: var(--space-1); }
.split-row--check label { cursor: pointer; font-weight: 500; }

.split-row__pct,
.split-row__amt {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.split-row__pct input { width: 72px; text-align: right; }
.split-row__pct-sign { font-weight: 600; color: var(--color-text-muted); font-size: var(--text-sm); }
.split-row__amt input { width: 96px; text-align: right; }
.split-row__cur { font-weight: 600; color: var(--color-text-muted); font-size: var(--text-sm); min-width: 20px; }

.segmented--sub {
  border-radius: var(--radius-sm);
}
.segmented--sub .segmented__option {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  min-height: 36px;
}
.segmented--sub .segmented__option:has(input:checked):first-child {
  border-top-left-radius: var(--radius-sm);
  border-bottom-left-radius: var(--radius-sm);
}
.segmented--sub .segmented__option:has(input:checked):last-child {
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
}

/* Expense card (collapsible) */
.expense-card {
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}
.expense-card:active { transform: scale(0.99); }
.expense-card__summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.expense-card__chevron {
  color: var(--color-text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.expense-card.is-expanded .expense-card__chevron {
  transform: rotate(180deg);
}
.expense-card__detail {
  display: none;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}
.expense-card.is-expanded .expense-card__detail {
  display: block;
}
.expense-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}
.expense-card__contribs {
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
}
.expense-card__contrib-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-1) 0;
  font-size: var(--text-sm);
}
.expense-card__contrib-row + .expense-card__contrib-row {
  border-top: 1px solid var(--color-border);
}

/* Copy button for invite code */
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
  min-width: var(--tap);
  min-height: var(--tap);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.copy-btn:hover { color: var(--color-text); border-color: var(--color-border-strong); }

/* Avatars */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-primary-muted);
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: 700;
  flex-shrink: 0;
}

/* =====================================================================
   Utilities
   ===================================================================== */
.u-mb-0 { margin-bottom: 0; }
.u-mt-0 { margin-top: 0; }
.u-mt-2 { margin-top: var(--space-2); }
.u-mt-3 { margin-top: var(--space-3); }
.u-mt-4 { margin-top: var(--space-4); }
.u-mt-5 { margin-top: var(--space-5); }
.u-mb-4 { margin-bottom: var(--space-4); }
.u-mb-5 { margin-bottom: var(--space-5); }
.u-text-center { text-align: center; }
.u-flex-1 { flex: 1; }
.u-min-w-0 { min-width: 0; }
.u-upper { text-transform: uppercase; }
.u-fw-700 { font-weight: 700; }
.u-ls-wide { letter-spacing: 1px; }
.u-w-130 { width: 130px; }
.u-gap-2 { gap: var(--space-2); }
.u-gap-3 { gap: var(--space-3); }
.u-form-0 { margin: 0; }
.u-inline-flex { display: inline-flex; }
.u-nowrap { white-space: nowrap; }

.row { display: flex; align-items: center; gap: var(--space-3); }
.muted { color: var(--color-text-muted); font-size: var(--text-sm); }
.spacer { flex: 1; }

.stack { display: flex; flex-direction: column; }
.stack--gap-2 { gap: var(--space-2); }
.stack--gap-3 { gap: var(--space-3); }

/* =====================================================================
   Action bar (mobile bottom bar for primary action)
   ===================================================================== */
.action-bar {
  display: none;
}

@media (max-width: 480px) {
  .action-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: var(--space-3) var(--space-4);
    padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
    box-shadow: var(--shadow);
  }
  .action-bar .button { flex: 1; }
  .action-bar__secondary {
    display: flex;
    gap: var(--space-2);
  }
  /* Hide desktop-only versions of these actions when bar is visible */
  .desktop-only-sm { display: none; }
}

@media (min-width: 481px) {
  .desktop-only-sm { display: inline-flex; }
  .mobile-only { display: none; }
}

/* =====================================================================
   Details / collapsible
   ===================================================================== */
details {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}
details + details { margin-top: var(--space-3); }
summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  cursor: pointer;
  background: var(--color-surface);
  list-style: none;
  min-height: var(--tap);
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--color-text-muted);
  border-bottom: 2px solid var(--color-text-muted);
  transform: rotate(-45deg);
  transition: transform 0.2s;
  margin-left: auto;
}
details[open] > summary::after {
  transform: rotate(45deg);
}
details > *:not(summary) {
  padding: var(--space-4);
}

/* =====================================================================
   Trip-specific: category summary chips
   ===================================================================== */
.cat-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
}
.cat-chip .glyph {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}
.cat-chip .glyph .icon { width: 14px; height: 14px; }

.currency-block {
  padding: var(--space-3);
}
.currency-block + .currency-block {
  border-top: 1px solid var(--color-border);
}
.currency-block__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: var(--space-2);
}

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 480px) {
  .shell { padding: 0 var(--space-3); }
  .page { padding-top: var(--space-4); }
}

/* Dark mode checkbox/radio */
[data-theme="dark"] input[type="checkbox"],
[data-theme="dark"] input[type="radio"] {
  color-scheme: dark;
}

/* =====================================================================
   User menu dropdown
   ===================================================================== */
.user-menu {
  position: relative;
}

.user-menu__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  min-width: var(--tap);
  min-height: var(--tap);
}

.user-menu__toggle .avatar {
  transition: box-shadow 0.15s ease;
}

.user-menu__toggle:hover .avatar,
.user-menu__toggle:focus-visible .avatar {
  box-shadow: 0 0 0 2px var(--color-primary);
}

.user-menu__dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  min-width: 200px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 100;
}

.user-menu__dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-menu__header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.user-menu__name {
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.user-menu__username {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.user-menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  color: var(--color-text);
  font-size: var(--text-base);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
  min-height: var(--tap);
}

.user-menu__item:hover,
.user-menu__item:focus-visible {
  background: var(--color-surface-alt);
  outline: none;
}

@media (max-width: 480px) {
  .user-menu__dropdown {
    right: var(--space-2);
  }
}
