:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #efe9e0;
  --ink: #17202e;
  --muted: #6b7280;
  --line: #e2dbd0;
  --navy: #0f1b2d;
  --navy-2: #1c2f4d;
  --accent: #b5323b;      /* rojo tartán */
  --accent-2: #2f6b4f;    /* verde highland */
  --gold: #c9a24b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .06), 0 6px 20px rgba(15, 27, 45, .06);
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1320;
    --surface: #131e30;
    --surface-2: #1a2840;
    --ink: #eef1f6;
    --muted: #93a0b4;
    --line: #26354f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--accent); margin: 8px 0 0; font-size: 14px; }

/* ---------- Login ---------- */
.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 50% -10%, #2a4470 0%, transparent 60%),
    linear-gradient(180deg, var(--navy) 0%, #0a1220 100%);
}
.login-card {
  width: 100%; max-width: 360px; text-align: center; color: #fff;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  border-radius: 24px; padding: 32px 24px; backdrop-filter: blur(8px);
}
.login-card h1 { font-size: 34px; }
.login-card .muted { color: #b8c3d6; margin: 4px 0 24px; }
.crest { font-size: 48px; margin-bottom: 8px; }
.login-card input {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.08); color: #fff; margin-bottom: 12px; text-align: center; font-size: 16px;
}
.login-card input::placeholder { color: #9fb0c8; }
.who-btns { display: grid; gap: 10px; }

/* ---------- Buttons / forms ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 10px 16px; cursor: pointer; font-weight: 500; transition: transform .08s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; width: 100%; padding: 14px; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--accent); }
.login .btn { width: 100%; padding: 14px; font-size: 16px; }
.login .btn:not(.primary) { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.2); color: #fff; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); font-size: 16px;
}
.field textarea { min-height: 70px; resize: vertical; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden; color: #fff;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  padding: calc(28px + env(safe-area-inset-top)) 16px 30px;
}
.tartan {
  position: absolute; inset: 0; opacity: .14; pointer-events: none;
  background:
    repeating-linear-gradient(90deg, transparent 0 22px, var(--accent) 22px 30px, transparent 30px 52px, var(--accent-2) 52px 56px),
    repeating-linear-gradient(0deg, transparent 0 22px, var(--accent) 22px 30px, transparent 30px 52px, var(--accent-2) 52px 56px);
  mask-image: linear-gradient(180deg, #000 0%, transparent 95%);
}
.hero-inner { position: relative; max-width: 720px; margin: 0 auto; text-align: center; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 11px; color: var(--gold); margin: 0 0 6px; font-weight: 600; }
.hero-title { font-size: clamp(34px, 9vw, 54px); font-weight: 700; line-height: 1.05; }
.hero-title span { color: var(--gold); font-style: italic; font-weight: 400; }
.countdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 22px auto 10px; max-width: 440px; }
.cd-box { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); border-radius: 14px; padding: 12px 4px 8px; }
.cd-num { font-family: var(--serif); font-size: clamp(28px, 8vw, 42px); font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.cd-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: #b8c3d6; margin-top: 6px; }
.hero-sub { color: #c9d3e3; margin: 8px 0 0; font-size: 14px; }
.cd-live { font-family: var(--serif); font-size: 26px; margin: 18px 0 4px; }

/* ---------- Layout ---------- */
main { max-width: 720px; margin: 0 auto; padding: 18px 16px 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 10px; }
.section-head:first-child { margin-top: 4px; }
.section-head h2 { font-size: 22px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat .v { font-family: var(--serif); font-size: 26px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 13px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 24px 12px; }
.empty .big { font-size: 34px; display: block; margin-bottom: 6px; }

/* ---------- Plan ---------- */
.day { margin-top: 18px; }
.day-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.day-head h3 { font-size: 18px; }
.day-head .tag { font-size: 12px; color: var(--muted); }
.item {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 8px;
}
.item.done .title { text-decoration: line-through; color: var(--muted); }
.check {
  flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line);
  background: transparent; cursor: pointer; display: grid; place-items: center; margin-top: 1px; padding: 0;
}
.item.done .check { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.item .body { flex: 1; min-width: 0; cursor: pointer; }
.item .title { font-weight: 600; }
.item .meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; }
.item .meta a { color: var(--accent-2); text-decoration: none; }
.item .notes { font-size: 14px; margin-top: 4px; white-space: pre-wrap; }
.time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px dashed var(--line); background: transparent; border-radius: 999px; padding: 6px 12px;
  font-size: 13px; cursor: pointer;
}
.chip:hover { border-color: var(--accent-2); }

/* ---------- Gastos ---------- */
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--accent-2); border-radius: 99px; }
.bar.over > i { background: var(--accent); }
.cat-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin-bottom: 10px; font-size: 14px; }
.cat-row .bar { grid-column: 1 / -1; margin-top: 0; height: 6px; }
.money { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.balance { font-size: 15px; }
.balance strong { font-family: var(--serif); font-size: 20px; }
.exp-list .item .body { display: flex; justify-content: space-between; gap: 10px; }
.exp-icon { font-size: 20px; flex: none; width: 28px; text-align: center; }

/* ---------- Álbum ---------- */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
@media (min-width: 560px) { .gallery { grid-template-columns: repeat(4, 1fr); } }
.gallery button { padding: 0; border: 0; aspect-ratio: 1; overflow: hidden; border-radius: 8px; cursor: pointer; background: var(--surface-2); }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.upload-status { font-size: 14px; color: var(--muted); margin: 8px 0; }
.lightbox {
  position: fixed; inset: 0; z-index: 50; background: rgba(5, 9, 16, .96); color: #fff;
  display: flex; flex-direction: column;
}
.lb-top { display: flex; justify-content: space-between; align-items: center; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; gap: 8px; }
.lb-top .btn { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.15); color: #fff; }
.lb-img { flex: 1; display: grid; place-items: center; min-height: 0; position: relative; }
.lb-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); border: 0; color: #fff; width: 44px; height: 44px; border-radius: 50%; font-size: 22px; cursor: pointer; }
.lb-nav.prev { left: 10px; } .lb-nav.next { right: 10px; }
.lb-info { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
.lb-info input { width: 100%; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15); border-radius: 10px; padding: 10px 12px; color: #fff; font-size: 16px; }
.lb-info .muted { color: #9fb0c8; font-size: 13px; margin-top: 6px; }

/* ---------- Tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabs button {
  background: none; border: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center;
  gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; font-weight: 500;
}
.tabs button span { font-size: 20px; filter: grayscale(1); opacity: .7; }
.tabs button.active { color: var(--accent); }
.tabs button.active span { filter: none; opacity: 1; }

/* ---------- Sheet (modal) ---------- */
.sheet {
  border: 0; padding: 0; width: 100%; max-width: 520px; border-radius: 20px;
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.sheet::backdrop { background: rgba(5, 9, 16, .55); }
@media (max-width: 560px) {
  .sheet { margin: auto 0 0; max-width: 100%; border-radius: 20px 20px 0 0; max-height: 92dvh; }
}
.sheet form { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet h2 { font-size: 22px; margin-bottom: 14px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 8px; }
.sheet-actions .btn.primary { flex: 2; }
.sheet-actions .btn:not(.primary) { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 60; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: calc(100% - 32px);
}
