/* =====================================================================
   TripMate — style.css
   Material Design 3 inspired, teal + amber, light / dark / high-contrast.
   Sections: tokens · base · layout · components · trip · money · social · pages · utilities
   ===================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --scale: 1;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --primary: #0E6B66; --on-primary: #fff; --primary-container: #C6EDE8; --on-primary-container: #00201E;
  --secondary: #F5A623; --secondary-container: #FFE3B3; --on-secondary-container: #2A1800;
  --surface: #F6FAF9; --surface-1: #FFFFFF; --surface-2: #EEF4F3; --surface-3: #E3ECEA;
  --on-surface: #10201F; --on-surface-variant: #43524F; --outline: #73827F; --outline-variant: #C5D2CF;
  --error: #B3261E; --error-container: #F9DEDC; --warn: #B76E00; --warn-container: #FFEBC7; --ok: #1E7A3C; --ok-container: #D3F2DC;
  --scrim: rgba(0, 0, 0, .45);
  --glass: rgba(255, 255, 255, .18); --glass-border: rgba(255, 255, 255, .35);
  --r-sm: 10px; --r: 16px; --r-lg: 24px; --r-xl: 32px;
  --shadow-1: 0 1px 2px rgba(16, 32, 31, .06), 0 1px 3px rgba(16, 32, 31, .08);
  --shadow-2: 0 4px 12px rgba(16, 32, 31, .08), 0 2px 4px rgba(16, 32, 31, .06);
  --shadow-3: 0 12px 32px rgba(16, 32, 31, .16);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --nav-h: 68px; --bar-h: 60px; --rail-w: 92px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --primary: #7AD5CC; --on-primary: #003733; --primary-container: #00504B; --on-primary-container: #A6F2E9;
  --secondary: #FFC266; --secondary-container: #5C3D00; --on-secondary-container: #FFDDAE;
  --surface: #0B1E1F; --surface-1: #122828; --surface-2: #183231; --surface-3: #1F3C3B;
  --on-surface: #E0EEEC; --on-surface-variant: #B2C4C1; --outline: #839491; --outline-variant: #34504D;
  --error: #FFB4AB; --error-container: #6B1410; --warn: #FFC266; --warn-container: #4A3300; --ok: #7EDB98; --ok-container: #0D3F1E;
  --glass: rgba(10, 30, 31, .35); --glass-border: rgba(255, 255, 255, .14);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3); --shadow-2: 0 4px 14px rgba(0, 0, 0, .35); --shadow-3: 0 12px 32px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
:root.hc { --on-surface-variant: var(--on-surface); --outline-variant: var(--outline); --outline: currentColor; }
:root.hc[data-theme="light"] { --primary: #004D49; --surface: #fff; --on-surface: #000; }
:root.hc[data-theme="dark"] { --primary: #A6FFF5; --surface: #000; --surface-1: #0A0A0A; --on-surface: #fff; }
:root.hc .card, :root.hc .btn, :root.hc .field input, :root.hc .field select, :root.hc .field textarea { border-width: 2px !important; border-color: var(--on-surface) !important; }
:root.reduce-motion *, :root.reduce-motion *::before, :root.reduce-motion *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: calc(16px * var(--scale)); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); background: var(--surface); color: var(--on-surface); line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100dvh; overflow-x: hidden; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; font-weight: 800; } h2 { font-size: 1.2rem; font-weight: 700; } h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 .5em; }
a { color: var(--primary); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
:focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--primary); color: var(--on-primary); padding: 10px 16px; border-radius: var(--r-sm); }
.skip:focus { top: 8px; }
[hidden], .hidden { display: none !important; }

/* Material Symbols (hidden until the icon font has loaded, so names never show as text) */
html:not(.icons) .ms { display: none !important; }
html:not(.icons) .icon-btn::after { content: attr(aria-label); font-size: .62rem; font-weight: 700; line-height: 1.1; text-align: center; padding: 2px; }
html:not(.icons) .icon-btn { width: auto; min-width: 44px; border-radius: 12px; }
.ms { font-family: "Material Symbols Rounded"; font-weight: normal; font-style: normal; font-size: 1.35em; line-height: 1; letter-spacing: normal; text-transform: none;
  display: inline-block; white-space: nowrap; direction: ltr; -webkit-font-feature-settings: "liga"; font-feature-settings: "liga"; vertical-align: -.22em;
  font-variation-settings: "FILL" 0, "wght" 450, "GRAD" 0, "opsz" 24; overflow: hidden; max-width: 1.4em; flex-shrink: 0; }
.ms.fill { font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24; }
.ms.sm { font-size: 1.05em; margin-right: 3px; }
.ms.big { font-size: 2.6rem; max-width: none; color: var(--primary); }
.ms.xl { font-size: 2.4rem; max-width: none; }
.ms.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Layout ---------- */
.appbar { position: sticky; top: 0; z-index: 30; height: calc(var(--bar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0;
  display: flex; align-items: center; gap: 8px; background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--outline-variant); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--on-surface); font-weight: 800; font-size: 1.15rem; }
.brand img { border-radius: 9px; }
.appbar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.sync { color: var(--primary); }
.me { display: inline-flex; border-radius: 50%; margin-left: 4px; }
.icon-btn.em { color: var(--error); }
.count { position: absolute; top: 4px; right: 2px; background: var(--error); color: #fff; font-size: .65rem; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; font-weight: 700; }

main { padding: 16px 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; outline: none; }
body.signed-out main { padding-bottom: 32px; }
.nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; justify-content: space-around; background: color-mix(in srgb, var(--surface-1) 92%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--outline-variant); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--on-surface-variant); font-size: .75rem; font-weight: 600; }
.nav a .ms { padding: 3px 18px; border-radius: 16px; transition: background .2s var(--ease); }
.nav a.on { color: var(--on-surface); }
.nav a.on .ms { background: var(--primary-container); color: var(--on-primary-container); font-variation-settings: "FILL" 1; }
@media (min-width: 900px) {
  .nav { top: var(--bar-h); bottom: 0; right: auto; width: var(--rail-w); height: auto; flex-direction: column; justify-content: flex-start; padding-top: 16px; gap: 12px; border-top: 0; border-right: 1px solid var(--outline-variant); }
  .nav a { flex: 0; padding: 4px 0; }
  body:not(.signed-out) main { padding-left: calc(var(--rail-w) + 24px); padding-bottom: 48px; max-width: calc(1180px + var(--rail-w)); }
}
.boot { display: grid; place-items: center; gap: 12px; min-height: 60vh; color: var(--on-surface-variant); }
.boot img { border-radius: 18px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.94); opacity: .7; } }
.offline-bar { position: sticky; top: 0; z-index: 40; background: var(--warn-container); color: var(--on-surface); text-align: center; padding: 6px 12px; font-size: .85rem; font-weight: 600; }
.page { animation: rise .35s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.stack > * + * { margin-top: 16px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 20px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 650; font-size: .95rem; cursor: pointer; text-decoration: none; background: transparent; color: var(--primary); transition: background .15s, box-shadow .15s, transform .1s; white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn.filled { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-1); }
.btn.filled:hover { box-shadow: var(--shadow-2); }
.btn.tonal { background: var(--primary-container); color: var(--on-primary-container); }
.btn.text:hover, .btn.tonal:hover { background: color-mix(in srgb, var(--primary) 12%, var(--surface-2)); }
.btn.danger { background: var(--error); color: #fff; }
.btn.danger-text, .danger-t { color: var(--error) !important; }
.btn.google { background: var(--surface-1); color: var(--on-surface); border-color: var(--outline-variant); }
.btn.whatsapp { background: #25D366; color: #06351a; }
.icon-btn { position: relative; width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--on-surface-variant); display: inline-grid; place-items: center; cursor: pointer; text-decoration: none; flex-shrink: 0; }
.icon-btn:hover { background: var(--surface-3); }
.icon-btn.glass { background: var(--glass); border: 1px solid var(--glass-border); color: #fff; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.fab { position: fixed; z-index: 25; right: 20px; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); height: 58px; padding: 0 22px 0 18px; border-radius: 18px; border: 0;
  background: var(--secondary); color: #2A1800; font-weight: 750; font-size: 1rem; display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow-3); cursor: pointer; animation: pop .4s var(--ease); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@media (min-width: 900px) { .fab { bottom: 28px; right: 32px; } }

/* ---------- Cards, chips, badges ---------- */
.card { background: var(--surface-1); border: 1px solid var(--outline-variant); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-1); }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--outline-variant); background: var(--surface-1); color: var(--on-surface-variant); font-weight: 600; font-size: .85rem; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--primary-container); color: var(--on-primary-container); border-color: transparent; }
.chip.ok { background: var(--ok-container); color: var(--ok); border-color: transparent; }
.chip-radio, .chip-check { position: relative; cursor: pointer; }
.chip-radio input, .chip-check input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip-radio span, .chip-check span { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--outline-variant); font-size: .85rem; font-weight: 600; background: var(--surface-1); }
.chip-radio input:checked + span, .chip-check input:checked + span { background: var(--primary-container); color: var(--on-primary-container); border-color: var(--primary); }
.chip-radio input:focus-visible + span, .chip-check input:focus-visible + span { outline: 3px solid var(--secondary); }
.chip-check span i, .fam-chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.badge { display: inline-flex; align-items: center; gap: 3px; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--on-surface-variant); text-transform: capitalize; vertical-align: middle; }
.badge.live { background: #E8F7EE; color: #0E7A3A; }
.badge.ok, .badge.confirmed { background: var(--ok-container); color: var(--ok); }
.badge.pending { background: var(--warn-container); color: var(--warn); }
.badge.cancelled { background: var(--error-container); color: var(--error); }
.badge.role-owner { background: var(--secondary-container); color: var(--on-secondary-container); }
.badge.role-admin { background: var(--primary-container); color: var(--on-primary-container); }
.fam-chip { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; white-space: nowrap; }
.avatar { border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 700; object-fit: cover; flex-shrink: 0; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--primary); border-radius: inherit; transition: width .6s var(--ease); }
.progress.warn i { background: var(--warn); } .progress.over i { background: var(--error); }
.note { display: flex; gap: 8px; align-items: flex-start; padding: 10px 14px; border-radius: var(--r); background: var(--surface-2); font-size: .9rem; }
.note.warn { background: var(--warn-container); } .note.error { background: var(--error-container); }
.note .btn { margin-left: auto; }
.empty { text-align: center; padding: 40px 16px; color: var(--on-surface-variant); }
.empty h3 { color: var(--on-surface); margin-top: 8px; }
.skeleton { border-radius: var(--r); background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--outline-variant); min-height: 52px; }
.list-item:last-child { border-bottom: 0; }
.list-item[role=button] { cursor: pointer; border-radius: 12px; }
.list-item[role=button]:hover { background: var(--surface-2); }
.list-item small { display: block; }
.list-item a { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; flex: 1; }
.cat-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-container); color: var(--on-primary-container); flex-shrink: 0; }
.amt { font-weight: 750; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt small { display: block; font-weight: 500; font-size: .75rem; color: var(--on-surface-variant); }
.strike { text-decoration: line-through; opacity: .55; }
.day-h { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--on-surface-variant); margin: 20px 0 6px; display: flex; gap: 8px; align-items: baseline; }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; }

/* ---------- Forms & dialogs ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; }
.field > span { font-size: .8rem; font-weight: 650; color: var(--on-surface-variant); }
.field input, .field select, .field textarea, .filters select, .add-row input, .search input, .cl-status, .composer textarea, [data-role-uid] {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--outline-variant); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus, .add-row input:focus, .composer textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); outline: none; }
.field.amount input { font-size: 1.4rem; font-weight: 750; }
.field.mini { margin: 0; } .field.mini input { min-height: 38px; padding: 6px 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; } .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 10px; }
.span2 { grid-column: 1 / -1; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } .grid3 { grid-template-columns: 1fr 1fr; } }
.check, .switch { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 99px; background: var(--surface-3); border: 2px solid var(--outline); position: relative; cursor: pointer; transition: .2s; flex-shrink: 0; }
.switch input::after { content: ""; position: absolute; top: 4px; left: 4px; width: 16px; height: 16px; border-radius: 50%; background: var(--outline); transition: .2s var(--ease); }
.switch input:checked { background: var(--primary); border-color: var(--primary); }
.switch input:checked::after { left: 22px; width: 18px; height: 18px; top: 3px; background: var(--on-primary); }
.switch input:disabled { opacity: .4; }
fieldset { border: 1px solid var(--outline-variant); border-radius: var(--r); padding: 12px 14px; margin: 0 0 14px; }
legend { font-weight: 700; padding: 0 6px; font-size: .9rem; }
.dlg { border: 0; padding: 0; border-radius: var(--r-xl); background: var(--surface-1); color: var(--on-surface); width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); box-shadow: var(--shadow-3); }
.dlg.wide { width: min(760px, calc(100vw - 24px)); }
.dlg[open] { animation: dlgIn .28s var(--ease); }
@keyframes dlgIn { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.dlg::backdrop { background: var(--scrim); backdrop-filter: blur(3px); }
.dlg form { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 16px 12px 8px 22px; }
.dlg-head h2 { margin: 0; flex: 1; font-size: 1.25rem; }
.dlg-body { padding: 4px 22px 12px; overflow-y: auto; overscroll-behavior: contain; }
.dlg-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 18px 18px; border-top: 1px solid var(--outline-variant); }
@media (max-width: 600px) {
  .dlg, .dlg.wide { width: 100vw; max-width: 100vw; max-height: 94dvh; margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .dlg[open] { animation: sheetIn .3s var(--ease); }
  .dlg form { max-height: 94dvh; } .dlg-foot { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
}
@keyframes sheetIn { from { transform: translateY(40%); opacity: .4; } }
.menu { display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 10px; border: 0; background: none; text-align: left; cursor: pointer; border-radius: 12px; font-weight: 600; text-decoration: none; color: var(--on-surface); }
.menu-item:hover { background: var(--surface-2); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 1000; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: #1C2B2A; color: #EAF4F2; box-shadow: var(--shadow-3); font-size: .92rem; animation: rise .25s var(--ease); }
.toast.success .ms { color: #7EDB98; } .toast.error { background: #5A1410; } .toast.warn .ms { color: #FFC266; }
.toast span:not(.ms) { flex: 1; } .toast .btn { color: #7AD5CC; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .3s; }

/* ---------- Auth ---------- */
.auth { display: grid; gap: 24px; align-items: center; min-height: calc(100dvh - 64px); grid-template-columns: 1fr; max-width: 980px; margin: 0 auto; }
@media (min-width: 860px) { .auth { grid-template-columns: 1.1fr 1fr; } }
.auth-hero { padding: 28px; border-radius: var(--r-xl); color: #fff; background: radial-gradient(circle at 85% 15%, rgba(245, 166, 35, .55), transparent 40%), linear-gradient(150deg, #0E6B66, #083F44); box-shadow: var(--shadow-3); }
.auth-hero img { border-radius: 20px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
.auth-hero h1 { font-size: 2.4rem; margin-top: 12px; }
.auth-points { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 10px; font-weight: 600; }
.auth-points li { display: flex; gap: 10px; align-items: center; background: rgba(255, 255, 255, .12); padding: 10px 12px; border-radius: 14px; backdrop-filter: blur(6px); }
.auth-card { padding: 24px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--on-surface-variant); font-size: .8rem; margin: 14px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--outline-variant); }

/* ---------- Home ---------- */
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 22px; border-radius: var(--r-xl); margin-bottom: 18px;
  background: radial-gradient(circle at 90% 0%, color-mix(in srgb, var(--secondary) 35%, transparent), transparent 45%), linear-gradient(135deg, var(--primary-container), var(--surface-2)); }
.hero h1 { font-size: 2rem; margin: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: .75rem; font-weight: 700; color: var(--on-surface-variant); margin: 0; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.section-title { display: flex; align-items: center; gap: 8px; margin: 26px 0 10px; }
.section-title h2 { margin: 0; display: flex; gap: 8px; align-items: center; }
.trip-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); margin-top: 8px; }
.trip-card { position: relative; border-radius: var(--r-lg); overflow: hidden; background: var(--surface-1); border: 1px solid var(--outline-variant); box-shadow: var(--shadow-1); transition: transform .2s var(--ease), box-shadow .2s; }
.trip-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.trip-card-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.trip-cover { height: 132px; background: var(--cover) center / cover, var(--primary-container); position: relative; }
.trip-cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 50%, rgba(0, 0, 0, .25)); }
.trip-cover .badge { position: absolute; left: 12px; top: 12px; z-index: 2; }
.trip-cover .fav { position: absolute; right: 10px; top: 10px; z-index: 2; }
.fav.on { color: #FFD27A; }
.trip-body { padding: 14px 16px 16px; }
.trip-body h3 { font-size: 1.1rem; margin-bottom: 2px; }
.card.invite { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border-color: var(--secondary); }

/* ---------- Trip shell ---------- */
.trip { margin: -16px -16px 0; }
.trip-head { position: relative; min-height: 168px; display: flex; align-items: flex-end; background: var(--cover) center / cover, var(--primary); color: #fff; }
.trip-head::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, .15), rgba(5, 25, 26, .78)); }
.trip-head-inner { position: relative; display: flex; align-items: flex-end; gap: 12px; padding: 16px; width: 100%; }
.trip-head h1 { font-size: 1.6rem; margin: 0 0 2px; text-shadow: 0 2px 10px rgba(0, 0, 0, .3); }
.trip-head p { margin: 0; opacity: .92; font-size: .9rem; }
.trip-head .badge { margin-left: 4px; }
.grow { flex: 1; min-width: 0; }
.tabs { position: sticky; top: calc(var(--bar-h) + env(safe-area-inset-top)); z-index: 20; display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px; scrollbar-width: none;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--outline-variant); }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 12px; text-decoration: none; color: var(--on-surface-variant); font-weight: 650; font-size: .88rem; white-space: nowrap; }
.tab.on { background: var(--primary-container); color: var(--on-primary-container); }
.tab .dot { background: var(--error); color: #fff; font-size: .65rem; border-radius: 9px; padding: 0 5px; min-width: 16px; text-align: center; }
.tab-body { padding: 16px; animation: rise .25s var(--ease); }
@media (min-width: 900px) { .trip { margin: -16px 0 0 -24px; } .trip-head { border-radius: 0 0 var(--r-xl) var(--r-xl); min-height: 200px; } }

/* ---------- Dashboard ---------- */
.status-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; }
.status-bar small { display: block; }
.dash-top { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .dash-top { grid-template-columns: 1.2fr 1fr; } }
.budget-card { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.ring { --p: 0; --c: var(--primary); width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0); position: relative; transition: --p 1s; }
.ring::before { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--surface-1); }
.ring > div { position: relative; text-align: center; }
.ring b { display: block; font-size: 1.7rem; font-weight: 800; }
.ring small { color: var(--on-surface-variant); font-size: .75rem; }
.kv { margin: 0; display: grid; gap: 6px; flex: 1; min-width: 160px; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; }
.kv dt { color: var(--on-surface-variant); font-size: .88rem; } .kv dd { margin: 0; font-weight: 650; text-align: right; }
.strong { font-size: 1.15rem; font-weight: 800 !important; }
.pos { color: var(--ok); } .neg { color: var(--error); }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(46%, 170px), 1fr)); }
.kpi { background: var(--surface-1); border: 1px solid var(--outline-variant); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi > .ms { color: var(--primary); }
.kpi-l { font-size: .75rem; color: var(--on-surface-variant); font-weight: 600; }
.kpi-v { font-size: 1.05rem; font-weight: 800; overflow-wrap: anywhere; }
.kpi-v small { display: block; font-size: .75rem; font-weight: 600; color: var(--on-surface-variant); }
.kpi-v .btn { padding: 0; min-height: 0; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.chart-box { position: relative; height: 240px; }
.my-balance { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-left: 6px solid var(--outline); }
.my-balance.owe { border-left-color: var(--error); } .my-balance.get { border-left-color: var(--ok); }
.big-num { font-size: 1.4rem; font-weight: 800; margin: 0; }
.wx-main { display: flex; align-items: center; gap: 14px; margin: 6px 0 10px; }
.wx-main > .ms { color: var(--secondary); }
.wx-main div { display: flex; flex-direction: column; }
.wx-t { font-size: 2.3rem; font-weight: 800; line-height: 1; }
.wx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: .85rem; }
.wx-grid small { color: var(--on-surface-variant); }
.card.fair { border-color: var(--secondary); background: linear-gradient(135deg, var(--secondary-container), var(--surface-1) 60%); }
.card h3 .ms, .card h2 .ms { color: var(--primary); margin-right: 6px; }
.warn-t { color: var(--warn); } .ok-t { color: var(--ok); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 21px; top: 8px; bottom: 8px; width: 2px; background: var(--outline-variant); }
.tl { display: flex; gap: 12px; padding: 8px 0; position: relative; }
.tl-dot { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-container); color: var(--on-primary-container); display: grid; place-items: center; flex-shrink: 0; z-index: 1; border: 3px solid var(--surface); }
.tl.start .tl-dot, .tl.end .tl-dot { background: var(--secondary); color: #2A1800; }
.tl-c { flex: 1; background: var(--surface-1); border: 1px solid var(--outline-variant); border-radius: var(--r); padding: 10px 12px; min-width: 0; }
.tl-c[role=button] { cursor: pointer; }
.tl-c small { display: block; }
.tl-img { margin-top: 8px; max-height: 200px; border-radius: 12px; object-fit: cover; }

/* ---------- Map ---------- */
.map { height: min(62vh, 560px); border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--outline-variant); background: var(--surface-2); }
.pad { padding: 20px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.route-key { display: inline-block; width: 22px; border-top: 3px dashed #0072B2; margin-left: 6px; }
.pin { background: none; border: 0; }
.pin-body { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); border: 2px solid #fff; }
.pin-body .ms { transform: rotate(45deg); color: #fff; font-size: 16px; }
.leaflet-container { font-family: var(--font); }

/* ---------- Families ---------- */
.card.family { border-top: 5px solid var(--fc); }
.card.family h3 { margin: 0; }
.ppl { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 12px 0 8px; font-size: .9rem; }
.ppl b { font-size: 1.1rem; }

/* ---------- Expenses ---------- */
.filters { display: grid; gap: 8px; grid-template-columns: 2fr repeat(3, 1fr); }
@media (max-width: 700px) { .filters { grid-template-columns: 1fr 1fr; } .filters .search { grid-column: 1 / -1; } }
.search { position: relative; display: block; }
.search > .ms { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--on-surface-variant); pointer-events: none; }
.search input { padding-left: 42px; border-radius: 999px; background: var(--surface-1); }
.search.big input { min-height: 56px; font-size: 1.1rem; }
.exp.cancelled { opacity: .6; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.receipt-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px; border: 1px dashed var(--outline); border-radius: var(--r); margin-bottom: 14px; background: var(--surface-2); }
.receipt-box img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; }
.receipt-box #ocrState { flex-basis: 100%; }
.prev { max-height: 140px; border-radius: 12px; margin-top: 8px; }
.split-preview { margin-top: 8px; }
.share-bars { display: grid; gap: 6px; }
.share-bars > div { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr auto; align-items: center; gap: 10px; font-size: .88rem; }
.share-bars i { height: 10px; border-radius: 6px; min-width: 2px; display: block; }
.share-bars b { font-variant-numeric: tabular-nums; }
.people-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 8px; }
.people-row b { flex-basis: 100%; font-size: .85rem; }
.people-row .field { width: 96px; }
.big-amt { font-size: 2.2rem; font-weight: 800; }
.big-amt small { display: block; font-size: .9rem; font-weight: 500; color: var(--on-surface-variant); }
.receipt-full { margin-top: 12px; border-radius: var(--r); border: 1px solid var(--outline-variant); max-height: 420px; }

/* ---------- Settle ---------- */
.transfer { flex-wrap: wrap; }
.transfer .arrow { color: var(--on-surface-variant); }
.bal-table { display: grid; }
.bal-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.6fr; gap: 8px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--outline-variant); font-variant-numeric: tabular-nums; font-size: .9rem; }
.bal-row.head { font-size: .75rem; font-weight: 700; color: var(--on-surface-variant); text-transform: uppercase; letter-spacing: .04em; }
.bal { font-weight: 750; display: flex; flex-direction: column; gap: 4px; }
.bal-bar { position: relative; height: 8px; background: var(--surface-3); border-radius: 4px; }
.bal-bar i { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: currentColor; }
.bal-bar::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: var(--outline); }
@media (max-width: 560px) { .bal-row { grid-template-columns: 1fr 1fr; } .bal-row.head { display: none; } .bal-row span:nth-child(2)::before { content: "Paid "; color: var(--on-surface-variant); } .bal-row span:nth-child(3)::before { content: "Share "; color: var(--on-surface-variant); } }
.card.rule.locked { border-color: var(--primary); }
.proposal { margin-top: 12px; padding: 12px; border-radius: var(--r); background: var(--warn-container); }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; height: calc(100dvh - var(--bar-h) - 168px - 60px - var(--nav-h) - 24px); min-height: 420px; }
@media (min-width: 900px) { .chat { height: calc(100dvh - var(--bar-h) - 200px - 60px - 48px); } }
.chat-top { padding-bottom: 8px; }
.pinned { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--secondary-container); color: var(--on-secondary-container); border-radius: 12px; font-size: .85rem; margin-bottom: 8px; }
.pinned span.grow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msgs { flex: 1; overflow-y: auto; padding: 4px 2px 12px; display: flex; flex-direction: column; gap: 4px; overscroll-behavior: contain; }
.day-sep { text-align: center; margin: 10px 0; } .day-sep span { font-size: .72rem; background: var(--surface-3); padding: 3px 10px; border-radius: 99px; color: var(--on-surface-variant); font-weight: 600; }
.msg { display: flex; align-items: flex-end; gap: 6px; max-width: 86%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.av-sp { width: 28px; flex-shrink: 0; } .msg.mine .av-sp { display: none; }
.bubble { position: relative; background: var(--surface-1); border: 1px solid var(--outline-variant); border-radius: 18px 18px 18px 6px; padding: 8px 12px 18px; min-width: 70px; cursor: pointer; overflow-wrap: anywhere; }
.msg.mine .bubble { background: var(--primary-container); color: var(--on-primary-container); border-color: transparent; border-radius: 18px 18px 6px 18px; }
.msg.urgent .bubble { background: var(--error-container); border: 2px solid var(--error); }
.msg.flash .bubble { animation: flash 1.4s; }
@keyframes flash { 30% { box-shadow: 0 0 0 4px var(--secondary); } }
.bubble p { margin: 0; white-space: pre-wrap; }
.who { display: block; font-size: .78rem; }
.quote { border-left: 3px solid var(--primary); padding: 2px 8px; margin-bottom: 4px; font-size: .8rem; opacity: .85; background: rgba(0, 0, 0, .04); border-radius: 6px; }
.quote b { display: block; }
.meta { position: absolute; right: 10px; bottom: 3px; font-size: .66rem; opacity: .7; }
.reacts { position: absolute; left: 8px; bottom: -12px; background: var(--surface-1); border: 1px solid var(--outline-variant); border-radius: 99px; padding: 0 6px; font-size: .8rem; box-shadow: var(--shadow-1); }
.msg:has(.reacts) { margin-bottom: 12px; }
.msg-img { border-radius: 12px; max-height: 260px; display: block; }
.bubble audio { max-width: 240px; height: 40px; }
.loc-card { display: flex; gap: 8px; align-items: center; text-decoration: none; color: inherit; } .loc-card small { display: block; }
.composer { display: flex; align-items: flex-end; gap: 4px; padding: 8px 0 0; border-top: 1px solid var(--outline-variant); }
.composer textarea { min-height: 44px; max-height: 140px; resize: none; border-radius: 22px; padding: 10px 16px; }
.composer .send { background: var(--primary); color: var(--on-primary); }
#micBtn.rec { background: var(--error); color: #fff; animation: pulse 1s infinite; }
.reply-prev { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--surface-2); border-radius: 12px; font-size: .85rem; }
.react-row { display: flex; justify-content: space-around; margin-bottom: 10px; }
.react { font-size: 1.6rem; width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--surface-2); cursor: pointer; }
.react.on { background: var(--primary-container); }
.lightbox-img { width: 100%; max-height: 70vh; object-fit: contain; border-radius: var(--r); background: #000; }

/* ---------- Plan ---------- */
.seg { display: flex; background: var(--surface-2); border-radius: 14px; padding: 4px; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.seg button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; border: 0; border-radius: 10px; background: none; font-weight: 650; cursor: pointer; color: var(--on-surface-variant); white-space: nowrap; padding: 0 12px; font-size: .88rem; }
.seg button.on { background: var(--surface-1); color: var(--on-surface); box-shadow: var(--shadow-1); }
.add-row { display: flex; gap: 8px; margin-bottom: 10px; }
.cl { flex-wrap: wrap; }
.cl-check { width: 24px; height: 24px; accent-color: var(--primary); flex-shrink: 0; }
.cl.done b { text-decoration: line-through; opacity: .6; }
.cl-status { width: auto !important; min-height: 36px !important; padding: 4px 8px !important; font-size: .82rem; }
.poll { margin-top: 12px; } .poll.closed { opacity: .75; }
.poll-opts { display: grid; gap: 6px; margin: 10px 0; }
.poll-opt { position: relative; display: flex; align-items: center; justify-content: space-between; min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--outline-variant); background: var(--surface); cursor: pointer; overflow: hidden; text-align: left; font-weight: 600; }
.poll-opt i { position: absolute; left: 0; top: 0; bottom: 0; background: color-mix(in srgb, var(--primary) 16%, transparent); transition: width .5s var(--ease); }
.poll-opt span, .poll-opt b { position: relative; }
.poll-opt.on { border-color: var(--primary); }
.poll-opt.lead i { background: color-mix(in srgb, var(--secondary) 35%, transparent); }
.voters { font-size: .72rem; color: var(--on-surface-variant); margin: -2px 0 4px 6px; }
.notes-ta { width: 100%; min-height: 50vh; padding: 16px; border-radius: var(--r); border: 1px solid var(--outline-variant); background: var(--surface-1); line-height: 1.6; resize: vertical; }

/* ---------- Photos ---------- */
.gallery { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(min(31%, 140px), 1fr)); }
.ph { aspect-ratio: 1; padding: 0; border: 0; border-radius: 12px; overflow: hidden; cursor: pointer; background: var(--surface-3); }
.ph img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s var(--ease); }
.ph:hover img { transform: scale(1.05); }

/* ---------- Invite ---------- */
.invite-box { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.qr { width: 184px; height: 184px; padding: 8px; background: #fff; border-radius: 16px; display: grid; place-items: center; }
.code { font-size: 2rem; font-weight: 800; letter-spacing: .2em; margin: 0 0 8px; font-variant-numeric: tabular-nums; }
.share-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.mt { margin-top: 16px; }
.join-preview { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.join-preview img { width: 96px; height: 72px; object-fit: cover; border-radius: 12px; }
.cover-pick { display: flex; align-items: center; gap: 12px; }
.cover-pick img { width: 120px; height: 68px; object-fit: cover; border-radius: 12px; }
.tpl { border: 0; padding: 0; }

/* ---------- More ---------- */
.card.report { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.card.report .btn { margin-top: auto; }
.perm-table { display: grid; font-size: .9rem; }
.perm-row { display: grid; grid-template-columns: 2fr repeat(3, 1fr); align-items: center; padding: 8px 0; border-bottom: 1px solid var(--outline-variant); }
.perm-row span:not(:first-child) { text-align: center; text-transform: capitalize; }
.perm-row.head { font-weight: 700; font-size: .75rem; color: var(--on-surface-variant); }
.perm-row input { width: 20px; height: 20px; accent-color: var(--primary); }
.audit { list-style: none; padding: 0; margin: 0; }
.audit li { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--outline-variant); font-size: .9rem; }
.audit .when { width: 64px; flex-shrink: 0; color: var(--on-surface-variant); font-size: .78rem; font-variant-numeric: tabular-nums; }
.badges { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.ach { text-align: center; padding: 16px 10px; border-radius: var(--r); border: 1px dashed var(--outline-variant); opacity: .55; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.ach .ms { font-size: 2rem; max-width: none; color: var(--on-surface-variant); }
.ach small { color: var(--on-surface-variant); font-size: .75rem; }
.ach.got { opacity: 1; border-style: solid; border-color: var(--secondary); background: var(--secondary-container); color: var(--on-secondary-container); }
.ach.got .ms { color: var(--warn); font-variation-settings: "FILL" 1; }
.card.recap { margin-top: 16px; background: linear-gradient(135deg, var(--primary), #083F44); color: #fff; border: 0; }
.card.recap h3 .ms { color: var(--secondary); }
.profile .card { margin-top: 16px; }
.profile .card h2 { display: flex; align-items: center; }
.avatar-btn { position: relative; border: 0; background: none; padding: 0; cursor: pointer; margin-right: 14px; border-radius: 50%; }
.avatar-btn > .ms { position: absolute; right: -2px; bottom: -2px; background: var(--primary); color: var(--on-primary); border-radius: 50%; padding: 5px; font-size: 16px; max-width: none; }
.prose { max-width: 680px; } .prose ol { padding-left: 1.2em; } .prose li { margin-bottom: 6px; }
.notif-list .list-item a small { display: block; }

/* ---------- Emergency ---------- */
.emergency { position: fixed; inset: 0; z-index: 60; overflow-y: auto; background: var(--surface); padding: calc(16px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom)); animation: rise .25s; }
.emergency > * { max-width: 680px; margin-left: auto; margin-right: auto; }
.emergency h1 { color: var(--error); display: flex; align-items: center; gap: 8px; margin: 0; }
.em-calls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px auto 8px; }
.em-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 18px; border-radius: var(--r-lg); background: var(--error); color: #fff; text-decoration: none; box-shadow: var(--shadow-2); }
.em-btn:last-child { background: #7A1712; }
.em-btn b { font-size: 1.8rem; } .em-btn .ms { font-size: 1.8rem; max-width: none; }
.emergency h2 { margin-top: 24px; }
.fa { border: 1px solid var(--outline-variant); border-radius: var(--r); padding: 12px 14px; margin-bottom: 8px; background: var(--surface-1); }
.fa summary { font-weight: 700; cursor: pointer; }
.fa p { margin: 8px 0 0; }
.center { text-align: center; }

/* ---------- Utilities ---------- */
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.muted { color: var(--on-surface-variant); }
.small { font-size: .85rem; }
small { font-size: .8rem; }

/* ---------- Print (browser print of any page) ---------- */
@media print { .appbar, .nav, .fab, .tabs, .toasts { display: none !important; } main { padding: 0 !important; } .card { box-shadow: none; break-inside: avoid; } }
