/* Luna de miel · captura de gastos. Móvil primero, claro/oscuro según el teléfono. */

:root {
  --bg: #FBF7F0;
  --surface: #FFFFFF;
  --surface-2: #F3ECE0;
  --text: #1E2033;
  --muted: #6B6A7A;
  --line: #E6DDCF;
  --accent: #C9862A;        /* miel */
  --accent-strong: #A86A14;
  --accent-text: #FFFFFF;
  --night: #1E2440;         /* noche */
  --danger: #C2412D;
  --ok: #2F7D5B;
  --shadow: 0 1px 2px rgba(30, 32, 51, .06), 0 4px 16px rgba(30, 32, 51, .06);
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12152A;
    --surface: #1C2140;
    --surface-2: #252B50;
    --text: #F2EEE6;
    --muted: #A3A6C0;
    --line: #2E3560;
    --accent: #E8A84A;
    --accent-strong: #F2BD6B;
    --accent-text: #1E1A10;
    --night: #F2EEE6;
    --danger: #F0806C;
    --ok: #6CCB9E;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.4em; }

/* ---------- Vistas ---------- */

#app { min-height: 100%; }
.view {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
.view-center { align-items: center; justify-content: center; text-align: center; gap: 12px; }
.moon { font-size: 44px; margin: 0; }

/* ---------- Login ---------- */

.login { margin: auto 0; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.login h1 { margin: 0; font-size: 28px; letter-spacing: -.01em; }
.login p { margin: 0; }
.login-users { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.login-users button {
  min-height: 96px;
  font-size: 22px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
#login-form { display: flex; flex-direction: column; gap: 12px; }
#pin {
  font-size: 32px;
  text-align: center;
  letter-spacing: .4em;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.btn-primary {
  min-height: 56px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 18px;
  padding: 0 20px;
}
.btn-primary:active { background: var(--accent-strong); }
.btn-link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 8px; }

/* ---------- Captura ---------- */

.top { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.who {
  background: none;
  border: 0;
  font-size: 20px;
  font-weight: 700;
  padding: 6px 4px;
  margin-right: auto;
}
.who::after { content: " ▾"; font-size: 14px; color: var(--muted); }
.pill, .sync {
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.pill.has { background: var(--accent); color: var(--accent-text); }
.sync { background: transparent; border: 1px dashed var(--line); }

.budget { margin-bottom: 18px; }
.budget-text { margin: 0 0 8px; font-size: 15px; }
.budget-text b { font-weight: 700; }
.bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .4s ease; }
.budget.over .bar-fill { background: var(--danger); }
.budget.over .budget-text { color: var(--danger); }

.currency {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface-2);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 14px;
}
.currency button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-weight: 600;
  color: var(--muted);
}
.currency button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.draft {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  margin-bottom: 12px;
}
.draft p { margin: 0; }
.draft-info { flex: 1; min-width: 0; }
.draft-total { font-size: 40px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.draft-parts .btn-link { padding: 4px 0 4px 8px; font-size: 15px; }
.draft.empty .draft-total { color: var(--line); }
.draft-parts { font-size: 15px; min-height: 1.4em; font-variant-numeric: tabular-nums; }

.amounts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-content: start; }
.amount {
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 34px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: transform .08s ease;
}
.amount:active { transform: scale(.97); background: var(--surface-2); }
.amount.other { grid-column: 1 / -1; min-height: 72px; font-size: 22px; color: var(--muted); }

.save { flex: none; min-width: 132px; min-height: 64px; font-size: 20px; }
.save:disabled { background: var(--surface-2); color: var(--muted); }

.place { text-align: center; font-size: 14px; margin: 16px 0 0; }

/* ---------- Hoja inferior (pasos después del monto) ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 24, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
}
.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding: 18px 16px max(16px, env(safe-area-inset-bottom));
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } .bar-fill { transition: none; } }

.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-kicker { margin: 0; color: var(--muted); font-size: 14px; }
.sheet-head h2 { margin: 2px 0 0; font-size: 22px; }
.icon-btn {
  width: 44px; height: 44px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 18px;
}

.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips.single { grid-template-columns: 1fr; }
.chip {
  position: relative;
  min-height: 64px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  text-align: left;
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.chip:active { background: var(--surface-2); }
.chip .ico { font-size: 22px; }
.chip.suggested { border: 2px solid var(--accent); }
.chip .tag { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--accent-strong); }

.sheet-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.steps { display: flex; gap: 6px; }
.steps i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.steps i.on { background: var(--accent); }

.custom-amount { display: flex; flex-direction: column; gap: 12px; }
.custom-amount input {
  font-size: 40px;
  font-weight: 700;
  text-align: center;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.menu { display: flex; flex-direction: column; gap: 10px; }
.menu .danger { color: var(--danger); }

/* ---------- Aviso "Guardado · Deshacer" ---------- */

.toast {
  position: fixed;
  left: 50%;
  top: max(12px, env(safe-area-inset-top));
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 488px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  border-radius: 16px;
  background: var(--night);
  color: var(--bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  font-weight: 600;
}
#toast-msg { flex: 1; }
#toast-undo {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
}
