:root {
	--bg: #f4f6f9;
	--surface: #ffffff;
	--surface-2: #eef1f6;
	--fg: #0f172a;
	--muted: #64748b;
	--border: #e2e8f0;
	--primary: #2563eb;
	--primary-fg: #ffffff;
	--primary-soft: #dbeafe;
	--ok: #15803d;
	--ok-soft: #dcfce7;
	--warn: #b45309;
	--warn-soft: #fef3c7;
	--bad: #b91c1c;
	--bad-soft: #fee2e2;
	--radius: 14px;
	--shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.05);
	--nav-h: 62px;
}
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0b1120;
		--surface: #131c31;
		--surface-2: #1b2640;
		--fg: #e8edf6;
		--muted: #94a3b8;
		--border: #263353;
		--primary: #60a5fa;
		--primary-fg: #0b1120;
		--primary-soft: #1e3a6b;
		--ok: #4ade80;
		--ok-soft: #14361f;
		--warn: #fbbf24;
		--warn-soft: #3b2a0a;
		--bad: #f87171;
		--bad-soft: #3d1414;
		--shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
	}
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { color-scheme: light dark; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	padding-bottom: calc(var(--nav-h) + 90px + env(safe-area-inset-bottom));
}
h1, h2, h3, p { margin: 0; }
h2 { font-size: 22px; letter-spacing: -0.01em; }
h3 { font-size: 16px; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* top bar */
.topbar {
	position: sticky; top: 0; z-index: 20;
	display: flex; align-items: center; justify-content: space-between; gap: 12px;
	padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
	background: color-mix(in srgb, var(--bg) 88%, transparent);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.live-dot {
	display: inline-block; width: 8px; height: 8px; margin-left: 8px; border-radius: 50%;
	background: var(--ok); vertical-align: middle; animation: pulse 2s infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }
.who {
	display: flex; align-items: center; gap: 8px;
	background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
	padding: 4px 12px 4px 4px; font-size: 14px;
}
.avatar {
	width: 28px; height: 28px; border-radius: 50%;
	background: var(--primary); color: var(--primary-fg);
	display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.avatar.sm { width: 22px; height: 22px; font-size: 11px; }
.banner {
	background: var(--warn-soft); color: var(--warn);
	padding: 8px 16px; font-size: 14px; text-align: center;
}

main { max-width: 720px; margin: 0 auto; padding: 16px 16px 0; }
.page-title { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.page-title .grow { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* cards */
.card {
	background: var(--surface); border: 1px solid var(--border);
	border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h3 { flex: 1; }
.hero { background: linear-gradient(135deg, #1d4ed8, #7c3aed); color: #fff; border: none; }
.hero .muted { color: rgba(255, 255, 255, 0.8); }
.hero .big { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }
.break { overflow-wrap: anywhere; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.pos { color: var(--ok); } .neg { color: var(--bad); }

/* buttons */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-height: 44px; padding: 0 16px; border-radius: 12px;
	border: 1px solid var(--border); background: var(--surface); font-weight: 600;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.55; pointer-events: none; }
.icon-btn {
	display: inline-grid; place-items: center; width: 40px; height: 40px;
	border: none; background: none; border-radius: 10px; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); }
.icon { display: inline-flex; width: 20px; height: 20px; }
.icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.link-btn { background: none; border: none; color: var(--primary); font-weight: 600; padding: 4px 0; }

.fab {
	position: fixed; right: 16px; z-index: 15;
	bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
	height: 56px; padding: 0 20px; border-radius: 28px; border: none;
	background: var(--primary); color: var(--primary-fg); font-weight: 700;
	display: inline-flex; align-items: center; gap: 8px;
	box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
}

/* nav */
.nav {
	position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
	display: flex; background: var(--surface); border-top: 1px solid var(--border);
	padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
	flex: 1; height: var(--nav-h); border: none; background: none; color: var(--muted);
	display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
	font-size: 11px; font-weight: 600;
}
.nav button.on { color: var(--primary); }

/* forms */
.field { display: block; margin-bottom: 14px; }
.field .lbl { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field .hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type="text"], input[type="search"], input[type="url"], input[type="date"], input[type="time"],
input[type="number"], input[type="password"], input:not([type]), select, textarea {
	width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px;
	border: 1px solid var(--border); background: var(--surface); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; min-height: 90px; }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .field { margin-bottom: 14px; }
.money-input { display: flex; gap: 8px; }
.money-input select { width: 92px; flex: none; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip {
	display: flex; align-items: center; gap: 8px; padding: 8px 12px; min-height: 44px;
	border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.split-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.split-row span { flex: 1; }
.split-row input { width: 110px; }

/* chips / segmented / badges */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 -16px 12px; padding-inline: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
	flex: none; min-height: 38px; padding: 0 14px; border-radius: 999px;
	border: 1px solid var(--border); background: var(--surface); font-size: 14px; font-weight: 600; color: var(--muted);
}
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.chip small { display: block; font-weight: 500; font-size: 11px; opacity: 0.85; line-height: 1; }
.chip.day { padding: 6px 14px; text-align: center; line-height: 1.15; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button {
	flex: 1; min-height: 38px; border: none; background: none; border-radius: 9px;
	font-weight: 600; font-size: 14px; color: var(--muted);
}
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }
.badge {
	display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
	background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.pri { background: var(--primary-soft); color: var(--primary); }
.status-pill { border: none; min-height: 34px; padding: 0 12px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.status-pill.pendiente { background: var(--surface-2); color: var(--muted); }
.status-pill.reservado { background: var(--warn-soft); color: var(--warn); }
.status-pill.pagado { background: var(--ok-soft); color: var(--ok); }

/* progress */
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1); }
.bar.stack { position: relative; }
.bar.stack > i { position: absolute; left: 0; top: 0; }
.bar > i.ok, .bar.ok > i { background: var(--ok); } .bar > i.warn, .bar.warn > i { background: var(--warn); } .bar > i.bad, .bar.bad > i { background: var(--bad); }
@media (prefers-reduced-motion: reduce) { .bar > i { transition: none; } }
.status-select { width: auto; min-height: 34px; padding: 0 28px 0 12px; border-radius: 999px; font-weight: 700; font-size: 13px; background-color: var(--surface-2); }
.status-select.elegido { background-color: var(--primary-soft); color: var(--primary); }
.status-select.comprado { background-color: var(--ok-soft); color: var(--ok); }
.status-select.descartado { color: var(--muted); }
.flight.discarded { opacity: 0.65; }
.cost-lines { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); }
.cost-summary { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; }
.chart { width: 100%; height: 44px; display: block; overflow: visible; }
.chart.tall { height: 150px; }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart-dot { stroke: var(--primary); stroke-width: 6; stroke-linecap: round; vector-effect: non-scaling-stroke; opacity: 0.55; }
.chart-dot.last { stroke-width: 10; opacity: 1; }
.chart-target { stroke: var(--ok); stroke-width: 1.5; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.leg { display: flex; gap: 8px; align-items: baseline; margin-top: 3px; }
.leg-title { flex: none; width: 50px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.hero .bar { background: rgba(255, 255, 255, 0.25); } .hero .bar > i { background: #fff; }

/* lists */
.list > .item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.list > .item:first-child { border-top: none; padding-top: 0; }
.list > .item:last-child { padding-bottom: 0; }
.item .title { font-weight: 600; }
.item.done .title { text-decoration: line-through; color: var(--muted); }
.stat { text-align: center; flex: 1; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 12px; color: var(--muted); }
.menu-item {
	display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
	padding: 14px 16px; background: var(--surface); border: 1px solid var(--border);
	border-radius: var(--radius); margin-bottom: 10px; min-height: 60px;
}
.menu-item .ic { width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.menu-item small { display: block; color: var(--muted); }

.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty p { margin-bottom: 12px; }

/* votes */
.vote { display: block; width: 100%; text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.vote.me { border-color: var(--primary); background: var(--primary-soft); }
.vote.lead .bar > i { background: var(--ok); }

/* timeline */
.tl-time { width: 58px; flex: none; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.tl-time b { display: block; color: var(--fg); }

/* map */
.map-frame { width: 100%; height: 280px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }

/* sheet */
dialog.sheet {
	border: none; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92vh;
	background: var(--surface); color: var(--fg);
	border-radius: 20px 20px 0 0; box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.25);
	overflow: hidden; animation: up 0.22s ease-out;
}
dialog.sheet::backdrop { background: rgba(2, 6, 23, 0.5); }
dialog.sheet[open] { display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 8px 8px 20px; }
.sheet-head h3 { flex: 1; font-size: 18px; }
.sheet-body { padding: 8px 20px calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; }
@media (min-width: 640px) {
	dialog.sheet { margin: auto; border-radius: 20px; }
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* toast */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 84px + env(safe-area-inset-bottom)); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; box-shadow: var(--shadow); animation: up 0.2s ease-out; }
.toast.error { background: #b91c1c; }

/* gate + skeleton */
.gate { max-width: 420px; margin: 0 auto; padding: 56px 16px; }
.gate h2 { font-size: 28px; margin-bottom: 4px; }
.skeleton { height: 90px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; margin-bottom: 12px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- undo snackbar ---------- */
#snackbar {
	position: fixed; left: 0; right: 0; z-index: 101; display: flex; justify-content: center; pointer-events: none; padding: 0 12px;
	bottom: calc(var(--nav-h) + 84px + env(safe-area-inset-bottom));
}
.snack {
	pointer-events: auto; position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px;
	background: #0f172a; color: #fff; padding: 12px 14px 15px; border-radius: 12px; width: 100%; max-width: 560px;
	box-shadow: var(--shadow); animation: up 0.2s ease-out;
}
.snack-btn { background: none; border: none; color: #93c5fd; font-weight: 700; padding: 6px 8px; }
.snack-timer { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: #93c5fd; transform-origin: left; animation: shrink linear forwards; }
@keyframes shrink { to { transform: scaleX(0); } }
#toasts { bottom: calc(var(--nav-h) + 150px + env(safe-area-inset-bottom)); }

/* ---------- small controls ---------- */
.mini-seg { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.mini-seg button { border: none; background: none; min-height: 34px; padding: 0 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.mini-seg button.on { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }
.rubro { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; color: var(--muted); }
.rubro.definido { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.rubro.estimado { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.person-dot { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); font-weight: 700; font-size: 12px; color: var(--muted); }
.person-dot.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.person-dot.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.person-dot.bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.count-dot { background: var(--primary); color: var(--primary-fg); border-radius: 999px; min-width: 22px; height: 22px; display: grid; place-items: center; font-size: 12px; font-weight: 700; padding: 0 6px; }
.star-on { color: #f59e0b; }
.star-on .icon svg { fill: #f59e0b; }
.item.todo { width: 100%; background: none; border: none; border-top: 1px solid var(--border); text-align: left; cursor: pointer; color: inherit; }
.list > .item.todo:first-child { border-top: none; }

/* ---------- reservas ---------- */
.option { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.option.chosen { border-color: var(--primary); background: var(--primary-soft); }
.vote-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; min-height: 34px; padding: 0 12px; font-size: 13px; font-weight: 600; }
.vote-btn.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.vote-btn .icon { width: 16px; height: 16px; }

/* ---------- tracker ---------- */
.cmp { display: grid; gap: 8px; align-items: start; padding: 8px 0; border-top: 1px solid var(--border); }
.cmp-table > .cmp:first-child { border-top: none; padding-top: 0; }
.cmp-h { font-weight: 700; }
.cmp-l { color: var(--muted); font-size: 12px; font-weight: 600; padding-top: 2px; }
.cmp-c { min-width: 0; }
.checklist { padding-left: 20px; margin: 0; display: grid; gap: 10px; }

/* ---------- trip mode: bigger, higher contrast, for sunlight and one hand ---------- */
body.trip-mode { font-size: 17px; }
body.trip-mode .btn { min-height: 52px; font-size: 17px; }
body.trip-mode .btn.sm { min-height: 44px; font-size: 16px; }
body.trip-mode .card { padding: 18px; }
body.trip-mode .muted { color: color-mix(in srgb, var(--muted) 70%, var(--fg)); }
body.trip-mode .small { font-size: 14px; }
body.trip-mode .nav button { font-size: 12px; }
body.trip-mode .fab { height: 62px; font-size: 18px; }
