:root {
  --red: #9e1b22; --red2: #c8323a; --gold: #c9971f;
  --bg: #f7f3ec; --card: #ffffff; --ink: #1f1a17; --muted: #7a7068; --line: #e8e0d4;
  --ok: #2f8a4c; --warn: #c27c0e; --err: #b3261e;
  --radius: 14px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121010; --card: #1d1a19; --ink: #f1ece6; --muted: #a39a91; --line: #2e2926; --red: #d0454c; --red2: #e0646a; --gold: #dcae45; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "PingFang SC", "Noto Sans SC", sans-serif; padding-bottom: calc(70px + var(--safe-b)); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; font-size: 16px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 8px; font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }

/* cabecera */
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: calc(10px + var(--safe-t)) 16px 10px; background: var(--red); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; }
.seal { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: #fff; color: var(--red); font-size: 20px; font-weight: 700; }
.seal.big { width: 64px; height: 64px; font-size: 38px; border-radius: 14px; background: var(--red); color: #fff; margin: 0 auto 8px; }
.name { font-weight: 700; font-size: 17px; }
.sync { font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #9ee3b0; }
.sync.busy::before { background: #ffd36b; } .sync.off::before { background: #c9c2bb; } .sync.err::before { background: #ff8a80; }
.gear { color: #fff; font-size: 22px; padding: 6px; }

main { padding: 12px 14px 24px; max-width: 680px; margin: 0 auto; }

/* barra de pestañas */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabs button { flex: 1; padding: 8px 0 7px; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button span { font-size: 20px; filter: grayscale(1); opacity: .7; }
.tabs button.on { color: var(--red); font-weight: 600; } .tabs button.on span { filter: none; opacity: 1; }

/* tarjetas */
.card, details.day, .stay, .hero { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); }
.card { padding: 14px; margin-bottom: 12px; }
.hero { text-align: center; padding: 22px 16px; background: linear-gradient(160deg, var(--red), #6e0f16); color: #fff; border: 0; }
.hero .big { font-size: 56px; font-weight: 800; line-height: 1; }
.hero .sub { opacity: .85; margin-top: 6px; font-size: 14px; }
.hero.small { text-align: left; padding: 16px; margin-bottom: 10px; } .hero .title { font-size: 20px; font-weight: 700; margin-top: 2px; }

details.day { margin-bottom: 10px; overflow: hidden; }
details.day summary { list-style: none; display: grid; grid-template-columns: auto 1fr; column-gap: 10px; padding: 12px 14px; cursor: pointer; }
details.day summary::-webkit-details-marker { display: none; }
.dn { grid-row: span 2; align-self: center; background: var(--red); color: #fff; border-radius: 9px; padding: 6px 8px; font-weight: 700; font-size: 14px; min-width: 42px; text-align: center; }
.dd { font-size: 12px; color: var(--muted); text-transform: capitalize; } .dt { font-weight: 600; }
.items { list-style: none; margin: 0; padding: 0 14px 6px; }
.it { display: grid; grid-template-columns: 24px 44px 1fr; gap: 4px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 15px; }
.it .tm { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; padding-top: 1px; }
.it.k-o .tx { color: var(--muted); } .it.k-b .tx { color: var(--warn); } .it.k-w .tx { color: var(--err); } .it.k-m .tx { font-weight: 600; }
.it.k-i .ic { color: var(--muted); text-align: center; }
.sleep { display: block; width: 100%; text-align: left; padding: 10px 14px 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.chev { float: right; }
.legend { font-size: 13px; color: var(--muted); margin: 4px 4px 10px; }

.seg { display: flex; background: var(--line); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; padding: 7px; border-radius: 8px; font-size: 14px; } .seg button.on { background: var(--card); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.trans { list-style: none; padding: 0; margin: 0; }
.trans li { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.trans .td { font-size: 13px; color: var(--muted); text-transform: capitalize; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip { background: var(--line); color: var(--ink); border-radius: 20px; padding: 1px 8px; font-size: 12px; text-transform: none; }
.chip.hot { background: var(--gold); color: #fff; }

/* tareas */
.tasks { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.task { display: flex; align-items: flex-start; border-top: 1px solid var(--line); } .task:first-child { border-top: 0; }
.task label { flex: 1; display: flex; gap: 12px; padding: 12px 14px; cursor: pointer; }
.task input { width: 22px; height: 22px; flex: none; margin: 0; accent-color: var(--red); }
.task.done span { color: var(--muted); text-decoration: line-through; }
.meta { display: block; font-size: 12px; color: var(--ok); text-decoration: none; margin-top: 2px; }
.task.done .meta { text-decoration: none; display: block; }
.del { color: var(--muted); padding: 12px 14px; font-size: 14px; }
.bar { height: 8px; background: var(--line); border-radius: 8px; overflow: hidden; margin: 8px 0; }
.bar span { display: block; height: 100%; background: var(--red); border-radius: 8px; }
.bar.thin { height: 5px; margin: 4px 0 0; } .bar.over span { background: var(--err); }
.add { display: flex; gap: 8px; margin-top: 10px; }
.add button, .primary { background: var(--red); color: #fff; border-radius: 10px; padding: 10px 16px; font-weight: 600; white-space: nowrap; }
.link { color: var(--red); padding: 8px 4px; font-size: 14px; }
.guide { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-top: 18px; }
.guide summary { font-weight: 600; cursor: pointer; } .guide li { margin: 6px 0; font-size: 14px; }

/* gastos */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.grid label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.grid label:first-child, .grid .wide, .grid .primary, .grid .actions { grid-column: 1 / -1; }
.grid.even label:first-child { grid-column: auto; }
.addexp summary { font-weight: 600; cursor: pointer; color: var(--red); }
.cats { list-style: none; padding: 12px 14px; margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.cats li { padding: 6px 0; font-size: 14px; }
.exps { list-style: none; padding: 0; margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.exps li { display: flex; align-items: center; gap: 8px; padding: 10px 0 10px 14px; border-top: 1px solid var(--line); } .exps li:first-child { border-top: 0; }
.ed { flex: 1; display: flex; flex-direction: column; min-width: 0; } .ea { text-align: right; display: flex; flex-direction: column; }

/* taxi */
.stay { padding: 4px 12px 10px; margin-bottom: 12px; }
.stay h2 { margin: 12px 2px 8px; color: var(--ink); font-size: 16px; text-transform: none; letter-spacing: 0; }
.zhs { color: var(--red); margin-left: 4px; }
.places { list-style: none; padding: 0; margin: 0; }
.places button, .hotelbtn { width: 100%; text-align: left; display: flex; flex-direction: column; padding: 9px 4px; border-top: 1px solid var(--line); }
.places .zh, .hotelbtn .zh { font-size: 19px; font-family: "PingFang SC", "Noto Sans SC", sans-serif; }
.places .es, .hotelbtn .es { font-size: 13px; color: var(--muted); }
.hotel { display: flex; align-items: center; background: color-mix(in srgb, var(--gold) 14%, transparent); border-radius: 10px; padding: 0 8px; margin-bottom: 6px; }
.hotel .hotelbtn { border: 0; } .hotel .hotelbtn .es { color: var(--ink); font-weight: 600; font-size: 15px; }
.edit { color: var(--red); font-size: 14px; padding: 8px; }
.addhotel { width: 100%; text-align: left; padding: 10px; border: 1.5px dashed var(--line); border-radius: 10px; color: var(--muted); margin-bottom: 6px; font-size: 14px; }

/* overlays */
#overlay { display: none; }
#overlay.show { display: flex; position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45); align-items: flex-end; justify-content: center; }
#overlay.full { background: #fff; align-items: stretch; }
.sheet { background: var(--card); width: 100%; max-width: 680px; border-radius: 18px 18px 0 0; padding: 20px 18px calc(20px + var(--safe-b)); max-height: 92vh; overflow: auto; }
.sheet h3 { margin: 0 0 4px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.actions button { padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); }
.actions .primary { border: 0; }
.who { display: flex; gap: 10px; margin-top: 16px; } .who button { flex: 1; padding: 16px; font-size: 18px; }
.bigcard { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b)); background: #fff; color: #111; }
.please { font-size: 22px; color: #9e1b22; margin-bottom: 20px; font-family: "PingFang SC", "Noto Sans SC", sans-serif; }
.bzh { font-size: clamp(32px, 10vw, 64px); font-weight: 700; line-height: 1.25; font-family: "PingFang SC", "Noto Sans SC", sans-serif; word-break: break-word; }
.bes { font-size: 17px; color: #555; margin-top: 18px; }
.hint { position: absolute; bottom: calc(16px + var(--safe-b)); font-size: 13px; color: #999; }

/* login */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.loginbox { border-radius: 18px; max-width: 360px; text-align: center; display: flex; flex-direction: column; gap: 12px; border: 1px solid var(--line); padding-bottom: 24px; }
.loginbox h1 { margin: 0; } .loginbox p { margin: 0; }
.err { color: var(--err); font-size: 14px; }
