:root {
  --bg: #fbf4f3; --card: #ffffff; --ink: #3a2a30; --muted: #76636a; --line: #ecdcdf;
  --rose: #b94a72; --rose-d: #9a3558; --on-rose: #ffffff; --rose-soft: #f8e4eb;
  --gold: #a87f33; --gold-soft: #f5ecd6; --ok: #2b7a58; --ok-soft: #dff1e7;
  --warn: #9a5b00; --warn-soft: #fcefd2; --danger: #b3304a; --danger-soft: #fbe3e8;
  --wa: #1f8a4c; --shadow: 0 2px 10px rgba(90, 40, 60, .09);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="claro"]) {
    --bg: #1a1317; --card: #261b21; --ink: #f6eaed; --muted: #bda7ae; --line: #3b2b33;
    --rose: #f09bb8; --rose-d: #f7b4ca; --on-rose: #2a1019; --rose-soft: #3a2230;
    --gold: #dcb872; --gold-soft: #35291a; --ok: #72d1a1; --ok-soft: #1c3328;
    --warn: #f0be6c; --warn-soft: #382a12; --danger: #ff8fa5; --danger-soft: #3d1b25;
    --wa: #3fc377; --shadow: 0 2px 10px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="oscuro"] {
  --bg: #1a1317; --card: #261b21; --ink: #f6eaed; --muted: #bda7ae; --line: #3b2b33;
  --rose: #f09bb8; --rose-d: #f7b4ca; --on-rose: #2a1019; --rose-soft: #3a2230;
  --gold: #dcb872; --gold-soft: #35291a; --ok: #72d1a1; --ok-soft: #1c3328;
  --warn: #f0be6c; --warn-soft: #382a12; --danger: #ff8fa5; --danger-soft: #3d1b25;
  --wa: #3fc377; --shadow: 0 2px 10px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
a { color: var(--rose-d); }
.muted { color: var(--muted); } .small { font-size: .88rem; } .center { text-align: center; }
.gold { color: var(--gold); }
.wrap { max-width: 560px; margin: 0 auto; }

/* Estructura */
#app { min-height: 100dvh; padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
.top {
  position: sticky; top: 0; z-index: 10; background: var(--bg);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.brand { font-weight: 700; letter-spacing: .2px; }
.brand span { color: var(--gold); }
main { padding: 14px 16px; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -2px 12px rgba(90, 40, 60, .07);
}
.nav .wrap { display: grid; grid-template-columns: repeat(5, 1fr); }
.nav button {
  background: none; border: 0; padding: 9px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: .72rem; min-height: 58px; cursor: pointer;
}
.nav button[aria-current="page"] { color: var(--rose); font-weight: 700; }
.ico { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico.sm { width: 18px; height: 18px; }
.fab {
  position: fixed; right: max(16px, calc(50% - 264px)); bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 19;
  background: var(--rose); color: var(--on-rose); border: 0; border-radius: 30px; min-height: 58px; padding: 0 22px 0 16px;
  display: flex; align-items: center; gap: 8px; font-weight: 700; box-shadow: 0 6px 18px rgba(150, 40, 80, .35); cursor: pointer;
}

/* Tarjetas y listas */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card.tap { cursor: pointer; }
.card.tap:active { background: var(--rose-soft); }
.card.cancelado { opacity: .62; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap-r { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hora { font-weight: 800; font-size: 1.05rem; min-width: 62px; color: var(--rose-d); font-variant-numeric: tabular-nums; }
.hora small { display: block; font-weight: 500; color: var(--muted); font-size: .78rem; }
.stack > * + * { margin-top: 12px; }
.gap { margin-top: 12px; }
.sec { margin: 20px 2px 8px; font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); font-weight: 700; }
.empty { text-align: center; padding: 30px 12px; color: var(--muted); }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 18px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--card); font-weight: 650; cursor: pointer; text-decoration: none; color: var(--ink); width: 100%;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--rose); border-color: var(--rose); color: var(--on-rose); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 42px; padding: 0 12px; font-size: .92rem; width: auto; border-radius: 12px; }
.btn[disabled] { opacity: .5; }
.btns { display: grid; gap: 10px; }
.btns.two { grid-template-columns: 1fr 1fr; }
.iconbtn { background: none; border: 0; padding: 8px; min-width: 44px; min-height: 44px; border-radius: 12px; color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.iconbtn:active { background: var(--rose-soft); }

/* Formularios */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .88rem; font-weight: 650; margin-bottom: 5px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 50px; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2.5px solid var(--rose); outline-offset: 1px; border-color: var(--rose); }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: 4px; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; font-weight: 600; }
.check input { width: 26px; height: 26px; accent-color: var(--rose); flex: none; }
button:focus-visible, a:focus-visible, .card.tap:focus-visible { outline: 3px solid var(--rose); outline-offset: 2px; }

/* Piezas */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--rose-soft); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; min-height: 44px; border-radius: 11px; font-weight: 650; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--rose-d); box-shadow: var(--shadow); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1.5px solid var(--line); background: var(--card); border-radius: 22px; min-height: 44px; padding: 0 16px; font-weight: 650; white-space: nowrap; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--rose); color: var(--on-rose); border-color: var(--rose); }
.badge { display: inline-block; font-size: .76rem; font-weight: 700; padding: 2px 9px; border-radius: 20px; background: var(--rose-soft); color: var(--rose-d); }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); } .badge.gold { background: var(--gold-soft); color: var(--gold); }
.banner { border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; background: var(--gold-soft); border: 1px solid var(--gold); }
.banner.warn { background: var(--warn-soft); border-color: var(--warn); }
.banner.danger { background: var(--danger-soft); border-color: var(--danger); }
.banner.ok { background: var(--ok-soft); border-color: var(--ok); }
.banner b { display: block; margin-bottom: 2px; }
.banner .btn { margin-top: 8px; }
.datebar { display: flex; align-items: center; gap: 4px; margin: 10px 0 12px; }
.datebar .ttl { flex: 1; text-align: center; font-weight: 750; line-height: 1.2; }
.datebar .ttl small { display: block; font-weight: 500; color: var(--muted); text-transform: none; font-size: .82rem; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.5rem; color: var(--rose-d); font-variant-numeric: tabular-nums; }
.stat span { font-size: .84rem; color: var(--muted); }
.menu { list-style: none; margin: 0; padding: 0; }
.menu button { width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; min-height: 60px; cursor: pointer; }
.menu .ico { color: var(--rose); }
.menu small { display: block; color: var(--muted); font-size: .82rem; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--rose-soft); color: var(--rose-d); display: grid; place-items: center; font-weight: 800; flex: none; }
.stamps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 6px 0; }
.stamp { aspect-ratio: 1; border-radius: 50%; border: 2px dashed var(--gold); display: grid; place-items: center; color: var(--gold); font-weight: 700; background: transparent; }
.stamp.on { background: var(--gold); border-style: solid; color: var(--card); }
.stamp .ico { width: 55%; height: 55%; stroke-width: 2.4; }
.fid { background: linear-gradient(135deg, var(--rose-soft), var(--gold-soft)); border: 1.5px solid var(--gold); }
footer.pie { text-align: center; color: var(--muted); font-size: .82rem; padding: 18px 16px 0; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: .95rem; }
.kv b { text-align: right; }
.pre { white-space: pre-wrap; background: var(--rose-soft); border-radius: 12px; padding: 12px; font-size: .95rem; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 46px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%; background: var(--rose); color: var(--on-rose); display: grid; place-items: center; font-weight: 800; }
details { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px 14px; margin-bottom: 10px; }
summary { min-height: 48px; display: flex; align-items: center; font-weight: 700; cursor: pointer; }
details > div { padding-bottom: 12px; }

/* Pantallas apiladas y diálogos */
.panel { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; animation: subir .18s ease-out; }
.panel .top { z-index: 3; }
.panel main { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
.panel .top h1 { font-size: 1.15rem; flex: 1; }
@keyframes subir { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.veil { position: fixed; inset: 0; z-index: 60; background: rgba(30, 10, 20, .55); display: flex; align-items: flex-end; justify-content: center; }
.dialog { background: var(--card); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 90dvh; overflow-y: auto; }
.dialog h2 { margin-bottom: 8px; }
.dialog .btns { margin-top: 16px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(74px + env(safe-area-inset-top)); z-index: 80; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; max-width: 90vw; font-weight: 600; box-shadow: var(--shadow); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); margin-right: 6px; }
.dot.no { background: var(--warn); }
@media (prefers-reduced-motion: reduce) { .panel { animation: none; } }
@media (min-width: 700px) { .veil { align-items: center; } .dialog { border-radius: 22px; } }
