:root {
  --sea: #0b3a53;
  --sea-2: #11587a;
  --turq: #17b3b0;
  --turq-soft: #e3f6f5;
  --coral: #ff7a59;
  --sand: #fbf7f0;
  --card: #ffffff;
  --ink: #1d2b33;
  --muted: #6b7b84;
  --line: #e6e2da;
  --ok: #1f9d6b;
  --bad: #d6454b;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --sand: #0d1a21; --card: #15252e; --ink: #e8eef1; --muted: #93a6b0;
    --line: #26394349; --turq-soft: #123a3c;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--sand); color: var(--ink);
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
button, input, textarea, select { font: inherit; color: inherit; }
.loading { text-align: center; margin-top: 30vh; color: var(--muted); }

/* Hero */
.hero {
  background: linear-gradient(160deg, var(--sea) 0%, var(--sea-2) 60%, var(--turq) 140%);
  color: #fff; padding: calc(20px + env(safe-area-inset-top)) 16px 22px;
}
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; max-width: 760px; margin: 0 auto; }
.hero h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.hero .sub { opacity: .8; font-size: 14px; margin-top: 2px; }
.me-chip { background: rgba(255,255,255,.15); border: 0; border-radius: 999px; padding: 6px 12px; color: #fff; cursor: pointer; white-space: nowrap; }
.countdown { display: flex; gap: 8px; max-width: 760px; margin: 18px auto 0; }
.countdown div { flex: 1; background: rgba(255,255,255,.12); border-radius: 12px; padding: 10px 4px; text-align: center; }
.countdown b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.countdown span { font-size: 12px; opacity: .8; }

main { max-width: 760px; margin: 0 auto; padding: 16px; }
h2 { font-size: 18px; margin: 22px 0 10px; }
h2:first-child { margin-top: 4px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 8px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.muted { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }

/* Trip facts */
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.facts .card { margin: 0; }
.facts .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.facts .val { font-weight: 600; margin-top: 2px; white-space: pre-wrap; }
.facts .wide { grid-column: 1 / -1; }
@media (max-width: 420px) { .facts { grid-template-columns: 1fr; } }

/* Progress */
.prog { height: 8px; background: var(--turq-soft); border-radius: 99px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--turq); border-radius: 99px; transition: width .3s; }
.person-line { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.person-line:last-child { border-bottom: 0; }
.person-line .name { width: 120px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-line .pct { width: 44px; text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Buttons & inputs */
.btn { border: 0; border-radius: 10px; padding: 10px 14px; background: var(--sea); color: #fff; cursor: pointer; font-weight: 600; }
.btn.alt { background: var(--turq-soft); color: var(--sea-2); }
.btn.small { padding: 6px 10px; font-size: 14px; }
.btn.ghost { background: transparent; color: var(--muted); padding: 6px 8px; }
.btn:disabled { opacity: .5; }
input[type=text], input[type=date], input[type=number], input[type=password], textarea, select {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 12px;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--turq); outline-offset: -1px; }

.choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.choice { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px; cursor: pointer; }
.choice.on { background: var(--turq); border-color: var(--turq); color: #fff; font-weight: 600; }

.q-text { font-weight: 600; }
details.others { margin-top: 10px; }
details.others summary { cursor: pointer; color: var(--sea-2); font-size: 14px; }
@media (prefers-color-scheme: dark) { details.others summary { color: var(--turq); } }
.others ul { list-style: none; margin: 8px 0 0; padding: 0; }
.others li { padding: 6px 0; border-top: 1px dashed var(--line); font-size: 14px; }
.tally { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.tally .row { font-size: 14px; }
.tally .prog { flex: 1; }

/* Checklist */
.check { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--turq); flex-shrink: 0; }
.check.done .t { text-decoration: line-through; color: var(--muted); }
.list { padding: 0; overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }
.claim { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.tag { font-size: 12px; background: var(--turq-soft); color: var(--sea-2); padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
@media (prefers-color-scheme: dark) { .tag { color: var(--turq); } }

/* Matrix */
.matrix-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.matrix { border-collapse: collapse; width: 100%; font-size: 14px; }
.matrix th, .matrix td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.matrix th:first-child, .matrix td:first-child { text-align: left; white-space: normal; min-width: 170px; position: sticky; left: 0; background: var(--card); }
.matrix .y { color: var(--ok); font-weight: 700; }
.matrix .n { color: var(--bad); }

/* Board */
.msg { display: flex; gap: 10px; }
.msg .av { font-size: 22px; line-height: 1; }
.msg .meta { font-size: 12px; color: var(--muted); }
.msg .body { white-space: pre-wrap; word-wrap: break-word; }

/* Tabs */
nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5;
}
nav.tabs button {
  flex: 1; max-width: 150px; border: 0; background: none; padding: 8px 4px 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted);
}
nav.tabs button .i { font-size: 20px; filter: grayscale(1); opacity: .7; }
nav.tabs button.on { color: var(--sea-2); font-weight: 600; }
nav.tabs button.on .i { filter: none; opacity: 1; }
@media (prefers-color-scheme: dark) { nav.tabs button.on { color: var(--turq); } }
.badge { background: var(--coral); color: #fff; border-radius: 99px; font-size: 10px; padding: 0 5px; margin-left: 2px; }

/* Gate screens */
.gate { max-width: 420px; margin: 0 auto; padding: 14vh 20px 20px; text-align: center; }
.gate .big { font-size: 56px; }
.gate h1 { margin: 8px 0 4px; }
.gate form { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.people-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-top: 18px; }
.people-pick button { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px; cursor: pointer; }
.emoji-row { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-row button { font-size: 22px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; width: 44px; height: 44px; cursor: pointer; }
.emoji-row button.on { border-color: var(--turq); background: var(--turq-soft); }

#toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--sand); padding: 8px 14px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10; }
#toast.show { opacity: 1; }
.err { color: var(--bad); font-size: 14px; min-height: 1em; }
a { color: var(--sea-2); }
@media (prefers-color-scheme: dark) {
  a { color: var(--turq); }
  .btn.alt { color: var(--turq); }
  .btn { background: var(--sea-2); }
}

/* Estado, avisos y camarotes */
.card.status { border-left: 4px solid var(--coral); }
.card.status .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.card.warn { background: #fff3ee; border-color: #ffd5c7; }
.card.ok { background: var(--turq-soft); }
@media (prefers-color-scheme: dark) { .card.warn { background: #3a2119; border-color: #5a3326; } }
ul.ticks { margin: 0; padding-left: 20px; }
ul.ticks li { padding: 3px 0; }
ul.ticks.done li::marker { content: '✓  '; color: var(--ok); }
.cabin.mine { border-color: var(--turq); box-shadow: 0 0 0 1px var(--turq); }
.members { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.member { background: var(--turq-soft); border-radius: 99px; padding: 4px 4px 4px 10px; font-size: 14px; display: inline-flex; align-items: center; gap: 2px; }
.member button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 6px; }
.tag.ok { background: var(--ok); color: #fff; }
nav.tabs button { font-size: 10px; }
pre.listado { white-space: pre-wrap; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; margin: 0; max-height: 360px; overflow: auto; }

/* ===== v3: navegación, pagos, documentos, optimizador, móvil ===== */
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
input, select, textarea { font-size: 16px; min-height: 44px; }
textarea { min-height: 80px; }
.btn { min-height: 44px; }
.btn.small { min-height: 36px; }
.btn.wide { width: 100%; display: block; margin: 12px 0; }
.small { font-size: 13px; }
.lbl { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.row.wrap { flex-wrap: wrap; }
.good { color: var(--ok); }
.hero.compact { padding-top: calc(12px + env(safe-area-inset-top)); padding-bottom: 12px; }
.hero.compact h1 { font-size: 17px; }
.hero h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { border: 0; background: none; color: var(--sea-2); font-weight: 600; padding: 4px 0 0; cursor: pointer; font-size: 15px; }
@media (prefers-color-scheme: dark) { .back { color: var(--turq); } }
a.card.link { display: block; text-decoration: none; color: inherit; }

/* barra inferior */
nav.tabs button { font-size: 11px; min-height: 56px; }
nav.tabs .i { position: relative; }
nav.tabs .i .badge { position: absolute; top: -4px; right: -12px; font-size: 10px; line-height: 16px; min-width: 16px; padding: 0 4px; filter: none; }
nav.tabs button .i { filter: none; opacity: .55; }
nav.tabs button.on .i { opacity: 1; }

/* menú «Más» */
a.menu { display: flex; align-items: center; gap: 12px; padding: 14px; text-decoration: none; color: inherit; min-height: 60px; }
a.menu .i { font-size: 24px; width: 32px; text-align: center; }
.chev { color: var(--muted); font-size: 22px; }

/* tarjetas resumen */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 8px; text-align: center; text-decoration: none; color: inherit; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }

/* responsables */
.role { padding: 12px 14px; }
select.mini { width: auto; min-height: 32px; padding: 4px 8px; border-radius: 99px; font-size: 14px; }
.members .mini { margin-left: 2px; }

/* camarotes */
details.edit { margin-top: 10px; }
details.edit summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 6px 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid2 label { min-width: 0; }
@media (max-width: 380px) { .grid2 { grid-template-columns: 1fr; } }
.check-inline { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); min-height: 44px; }
.check-inline input { width: 22px; height: 22px; min-height: 0; accent-color: var(--turq); }
.claim input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--turq); }
.check input { min-height: 0; }

/* optimizador */
.card.opt h3 { margin-top: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 12px -16px; padding: 0 16px 4px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 7px 12px; cursor: pointer; font-size: 14px; white-space: nowrap; min-height: 36px; }
.chip.on { background: var(--turq); border-color: var(--turq); color: #fff; font-weight: 600; }
.rule { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--turq-soft); border-radius: 10px; padding: 8px 6px 8px 12px; margin-bottom: 6px; font-size: 14px; }
.rule.apart { background: #fde8e8; }
@media (prefers-color-scheme: dark) { .rule.apart { background: #3c1f22; } }
.rule button { border: 0; background: none; font-size: 20px; color: var(--muted); cursor: pointer; padding: 0 8px; min-height: 32px; }
.prefs { display: flex; flex-direction: column; }
label.pref { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line); }
label.pref span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
label.pref select { width: auto; max-width: 55%; min-height: 38px; }
.ptable { display: grid; grid-template-columns: 64px repeat(3, 1fr); gap: 6px; align-items: center; font-size: 13px; }
.ptable b { text-align: center; }
.ptable b:nth-child(4n+1) { text-align: left; }
.ptable input { min-height: 40px; padding: 6px; text-align: center; }
.result { margin-top: 14px; }
.pcabin { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }

/* pagos */
.trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.trio span { display: block; font-size: 12px; color: var(--muted); }
.trio b { font-size: 18px; font-variant-numeric: tabular-nums; }
@media (max-width: 360px) { .trio b { font-size: 15px; } }
.payer { padding: 12px 14px; }
.card.pay { padding: 12px 14px; }
.card.mine-money:empty { display: none; }

/* documentos */
.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 2px dashed var(--line); border-radius: 12px; padding: 18px; cursor: pointer; text-align: center; }
.drop:active { background: var(--turq-soft); }
.big-i { font-size: 28px; }
.doc { display: flex; gap: 12px; align-items: flex-start; }
.thumb { width: 64px; height: 64px; flex-shrink: 0; border-radius: 10px; background: var(--turq-soft); display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 28px; text-decoration: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.dtitle { font-weight: 600; color: inherit; text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.warn.small { font-size: 13px; }
.grid2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 380px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
input, select, textarea { max-width: 100%; min-width: 0; }
input[type=file] { font-size: 13px; padding: 8px; width: 100%; }
input[type=date] { -webkit-appearance: none; appearance: none; }
.grid2 .full { grid-column: 1 / -1; }
