:root {
  color-scheme: light;
  --bg: #F4F7F5;
  --surface: #FFFFFF;
  --ink: #17241D;
  --muted: #53625A;
  --line: #D9E2DC;
  --accent: #3E6B55;
  --accent-ink: #FFFFFF;
  --accent-soft: #E2EDE6;
  --gold: #8F6410;
  --gold-soft: #F7EEDB;
  --danger: #A8372B;
  --danger-soft: #FBE8E5;
  --radius-lg: 22px;
  --radius: 14px;
  --radius-sm: 10px;
  --nav-h: 68px;
  --font: "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0F1713; --surface: #18231D; --ink: #E7EFEA; --muted: #A4B3AA; --line: #2A3A31;
    --accent: #8CC4A6; --accent-ink: #0D1A13; --accent-soft: #1E3428;
    --gold: #E2B85C; --gold-soft: #33290F; --danger: #F2907F; --danger-soft: #3B1E1A;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0F1713; --surface: #18231D; --ink: #E7EFEA; --muted: #A4B3AA; --line: #2A3A31;
  --accent: #8CC4A6; --accent-ink: #0D1A13; --accent-soft: #1E3428;
  --gold: #E2B85C; --gold-soft: #33290F; --danger: #F2907F; --danger-soft: #3B1E1A;
}

*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 17px; line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
a { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Layout ---------- */
.shell { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom, 0px)); }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--bg);
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
}
.topbar h1 { font-size: 1.15rem; font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.lang button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: .9rem; cursor: pointer; min-height: 36px; }
.lang button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; }
main { padding: 4px 18px 0; }
.view-title { font-size: 1.6rem; font-weight: 800; margin: 8px 0 14px; letter-spacing: -0.01em; }
.section-title { font-size: 1.1rem; font-weight: 800; margin: 26px 0 10px; display: flex; align-items: center; gap: 8px; }
.count { font-size: .85rem; font-weight: 700; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 1px 10px; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.banner { background: var(--gold-soft); color: var(--ink); border-radius: var(--radius); padding: 10px 14px; font-size: .92rem; margin: 0 18px 10px; }

/* ---------- Bottom nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav ul { list-style: none; margin: 0 auto; padding: 0 6px; display: flex; max-width: 560px; height: var(--nav-h); }
.nav li { flex: 1; }
.nav button {
  width: 100%; height: 100%; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: .78rem; font-weight: 700;
}
.nav svg { width: 25px; height: 25px; }
.nav button[aria-current="page"] { color: var(--accent); }
.nav button[aria-current="page"] .pill { background: var(--accent-soft); }
.nav .pill { padding: 3px 16px; border-radius: 999px; display: grid; place-items: center; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 800; cursor: pointer; text-decoration: none; font-size: 1rem;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: .92rem; }
.row { display: flex; gap: 10px; align-items: center; }
form .row, .sheet .row { align-items: flex-end; }
.row > .field { min-width: 0; }
.row > * { flex: 1; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 700; font-size: .95rem; margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 50px; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--surface); font-size: 1rem;
}
textarea.input { min-height: 90px; resize: vertical; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); font-weight: 700; font-size: .93rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.segmented { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin-bottom: 14px; }
.segmented button { flex: 1; min-height: 42px; border: 0; background: transparent; border-radius: 999px; font-weight: 800; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* ---------- Countdown hero ---------- */
.hero { display: flex; align-items: center; gap: 18px; padding: 8px 0 4px; }
.ring { position: relative; width: 148px; height: 148px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--accent-soft); }
.ring .fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.ring .num { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .num b { font-size: 2.9rem; font-weight: 900; line-height: 1; letter-spacing: -0.03em; display: block; }
.ring .num small { font-size: .78rem; font-weight: 700; color: var(--muted); display: block; max-width: 96px; line-height: 1.2; margin-top: 4px; }
.hero-text h2 { font-size: 1.35rem; font-weight: 800; }
.hero-text p { margin: 4px 0 0; color: var(--muted); }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--line); }
.item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; min-height: 64px; }
.item .body { flex: 1; min-width: 0; background: none; border: 0; text-align: left; padding: 6px 0; cursor: pointer; }
.item .t { font-weight: 700; display: block; overflow-wrap: anywhere; }
.item .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 3px; font-size: .88rem; color: var(--muted); }
.item.is-done .t { text-decoration: line-through; color: var(--muted); font-weight: 600; }
.check {
  flex: none; width: 34px; height: 34px; margin-top: 4px; border-radius: 10px; border: 2px solid var(--muted);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.check svg { width: 20px; height: 20px; opacity: 0; transform: scale(.4); transition: transform .18s ease, opacity .18s; }
.check[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check[aria-checked="true"] svg { opacity: 1; transform: scale(1); }
.tag { display: inline-flex; align-items: center; border-radius: 999px; padding: 0 9px; font-size: .8rem; font-weight: 800; line-height: 1.7; background: var(--accent-soft); color: var(--ink); }
.tag-late { background: var(--danger-soft); color: var(--danger); }
.tag-today { background: var(--gold-soft); color: var(--gold); }
.tag-paid { background: var(--accent); color: var(--accent-ink); }
.tag-booked { background: var(--accent-soft); color: var(--accent); }
.tag-quoting { background: var(--gold-soft); color: var(--gold); }
.month-head { font-size: 1rem; font-weight: 800; margin: 22px 4px 8px; display: flex; justify-content: space-between; gap: 8px; }
.month-head span { color: var(--muted); font-weight: 700; font-size: .88rem; }
.empty { text-align: center; padding: 28px 18px; background: var(--surface); border: 1.5px dashed var(--line); border-radius: var(--radius-lg); color: var(--muted); }
.empty .btn { margin-top: 14px; }
.notice { background: var(--gold-soft); border-radius: var(--radius); padding: 10px 14px; font-size: .92rem; margin-bottom: 10px; }

/* Vendor & expense cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px; margin-bottom: 10px; }
.card-head { display: flex; align-items: flex-start; gap: 10px; }
.card-head .body { flex: 1; min-width: 0; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.card-head .t { font-weight: 800; font-size: 1.05rem; display: block; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.bar { height: 10px; background: var(--accent-soft); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.money-row { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: .92rem; }
.money-row b { font-weight: 800; }

.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 6px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat span { display: block; font-size: .85rem; color: var(--muted); font-weight: 700; }
.stat b { display: block; font-size: 1.15rem; font-weight: 900; overflow-wrap: anywhere; }
.stat.owed b { color: var(--danger); }
.cur-label { font-weight: 800; margin: 16px 2px 8px; }

/* Quick add */
.quick { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px; margin-bottom: 12px; }
.quick .row { margin-top: 10px; }
.quick select.input { flex: 1.2; }
.quick .btn { flex: 1; }

/* FAB */
.fab {
  position: fixed; right: max(18px, calc(50% - 262px)); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); z-index: 22;
  min-height: 56px; padding: 0 22px; border-radius: 999px; border: 0; background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 1rem; display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  box-shadow: 0 6px 18px -6px rgba(30, 60, 45, .55);
}
.fab svg { width: 22px; height: 22px; }

/* Progress */
.progress-item { margin-bottom: 14px; }
.progress-item .money-row { margin-top: 0; }

/* ---------- Sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 20, 15, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 24px 24px 0 0; padding: 10px 18px calc(22px + env(safe-area-inset-bottom, 0px));
  animation: up .22s ease-out;
}
.sheet .grab { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { font-size: 1.3rem; font-weight: 800; margin-bottom: 16px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 8px; }
.sheet-actions .btn { flex: 1; }
.pay-list { list-style: none; padding: 0; margin: 0 0 12px; }
.pay-list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pay-list li > div { flex: 1; }
.pay-list .x { border: 0; background: none; color: var(--danger); font-weight: 800; cursor: pointer; min-height: 40px; padding: 0 8px; }
.subcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0 16px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Auth ---------- */
.auth { max-width: 440px; margin: 0 auto; padding: 48px 22px 40px; }
.auth .mark { width: 64px; height: 64px; border-radius: 20px; background: var(--accent-soft); display: grid; place-items: center; margin-bottom: 20px; color: var(--accent); }
.auth .mark svg { width: 36px; height: 36px; }
.auth h1 { font-size: 2rem; font-weight: 900; letter-spacing: -0.02em; }
.auth p.lead { color: var(--muted); margin: 8px 0 26px; font-size: 1.05rem; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 22px 0 16px; font-size: .92rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.linkish { background: none; border: 0; color: var(--accent); font-weight: 700; cursor: pointer; padding: 10px 0; text-decoration: underline; text-underline-offset: 3px; }
.auth-top { position: absolute; top: calc(14px + env(safe-area-inset-top, 0px)); right: 18px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 86px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-weight: 700; z-index: 60;
  max-width: calc(100% - 36px); text-align: center; animation: up .2s ease-out;
}

/* Members */
.member { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.member > div { flex: 1; min-width: 0; }
.member .t { font-weight: 700; overflow-wrap: anywhere; }


/* ---------- Invitados ---------- */
.item .rsvp { flex: none; align-self: center; border: 0; min-height: 40px; padding: 0 12px; font-size: .85rem; cursor: pointer; font-family: inherit; }
.cand { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 4px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.cand input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }
.check-field { display: flex; align-items: center; gap: 10px; min-height: 50px; }
.check-field input { width: 24px; height: 24px; accent-color: var(--accent); }
.check-field span { margin: 0 !important; }
.over-txt { color: var(--danger); }

/* ---------- Plano de mesas ---------- */
.summary.four { grid-template-columns: repeat(4, 1fr); gap: 8px; }
.summary.three { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.side-stat { text-align: left; font: inherit; color: inherit; cursor: pointer; }
.side-stat.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
/* Lado del invitado: color + texto (nunca solo color) */
.tag-side-bride { background: #F6E3EA; color: #8A2E52; }
.tag-side-groom { background: #E1EAF5; color: #234E7E; }
.tag-side-both { background: var(--accent-soft); color: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tag-side-bride { background: #3D2230; color: #F2B6CB; } :root:not([data-theme="light"]) .tag-side-groom { background: #1E2B3D; color: #A9C6EC; } }
:root[data-theme="dark"] .tag-side-bride { background: #3D2230; color: #F2B6CB; }
:root[data-theme="dark"] .tag-side-groom { background: #1E2B3D; color: #A9C6EC; }
.summary.four .stat { padding: 10px; }
.summary.four .stat span { font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-tools { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.stage-tools .btn-sm { min-width: 44px; font-size: 1.05rem; white-space: nowrap; padding: 0 12px; }
.stage-wrap {
  height: min(62vh, 560px); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); touch-action: pan-x pan-y; overscroll-behavior: contain;
}
.stage {
  --z: .4; position: relative; width: calc(900px * var(--z)); height: calc(1200px * var(--z));
  background-image: radial-gradient(var(--line) calc(1.6px), transparent calc(1.6px));
  background-size: calc(50px * var(--z)) calc(50px * var(--z));
}
.tbl {
  position: absolute; left: calc(var(--x) * var(--z) * 1px); top: calc(var(--y) * var(--z) * 1px);
  width: calc(var(--w) * var(--z) * 1px); height: calc(var(--h) * var(--z) * 1px); transform: translate(-50%, -50%);
  border-radius: 50%; border: 2px solid var(--accent); background: var(--accent-soft); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  font-size: calc(var(--z) * 40px); line-height: 1; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
}
.tbl.rect { border-radius: calc(var(--z) * 16px); flex-direction: row; gap: .4em; }
.tbl .n { font-weight: 900; }
.tbl .c { font-size: .62em; font-weight: 800; color: var(--muted); margin-top: .15em; }
.tbl.head { background: var(--gold-soft); border-color: var(--gold); }
.tbl.over { border-color: var(--danger); background: var(--danger-soft); }
.tbl.over .c { color: var(--danger); }
.tbl.deco { border: 2px dashed var(--muted); background: transparent; color: var(--muted); border-radius: calc(var(--z) * 16px); font-size: calc(var(--z) * 24px); font-weight: 800; padding: 4px; }
.tbl.dragging { cursor: grabbing; z-index: 5; box-shadow: 0 8px 22px -6px rgba(20, 50, 35, .5); }

.sched-time { flex: none; width: 92px; padding-top: 10px; font-weight: 900; color: var(--accent); font-size: .9rem; white-space: nowrap; }
.bar.over > i { background: var(--danger); }
.bar.near > i { background: var(--gold); }
.cat-row { margin-bottom: 8px; align-items: center !important; }
.cat-row .cat-name { flex: 1.3; font-weight: 700; font-size: .92rem; }
.cat-row .input { min-height: 44px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
#print-area { display: none; }
@media print {
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing::before { display: none; }
  body.printing { background: #fff; color: #111; }
  #print-area { display: block; font-family: var(--font); color: #111; }
  #print-area h1 { font-size: 20pt; margin-bottom: 10pt; }
  .print-plan { width: 100%; max-height: 24cm; display: block; margin: 0 auto 14pt; border: 1px solid #999; }
  .print-lists { columns: 2; column-gap: 18pt; break-before: page; }
  .print-lists section { break-inside: avoid; margin-bottom: 12pt; }
  .print-lists h2 { font-size: 13pt; margin: 0 0 4pt; }
  .print-lists small { font-weight: 400; color: #555; }
  .print-lists ol { margin: 0; padding-left: 18pt; font-size: 11pt; }
  .az-sub { margin: -6pt 0 12pt; color: #444; }
  .az { columns: 2; column-gap: 24pt; }
  .az-letter { font-size: 18pt; margin: 10pt 0 4pt; break-after: avoid; border-bottom: 1px solid #999; }
  .az-row b { white-space: nowrap; }
  .az-row { display: flex; justify-content: space-between; gap: 8pt; font-size: 12pt; padding: 2pt 0; break-inside: avoid; }
  .cat-table { width: 100%; border-collapse: collapse; font-size: 10.5pt; }
  .cat-table th, .cat-table td { border: 1px solid #999; padding: 4pt 6pt; text-align: left; vertical-align: top; }
  .cat-table th { background: #eee; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
