:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1b1b1b;
  --muted: #5b5b5b;
  --line: #d9d4c7;
  --green: #14693b;
  --green-bg: #e3f3e9;
  --red: #b3261e;
  --red-bg: #fbe7e5;
  --amber: #8a5a00;
  --amber-bg: #fff2d6;
  --blue: #124a8a;
}
* { box-sizing: border-box; }
html { font-size: 20px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.35;
}
#print-area { display: none; }
.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px 120px; }
h1 { font-size: 1.6rem; margin: 8px 0 12px; }
h2 { font-size: 1.25rem; margin: 24px 0 8px; }
.muted { color: var(--muted); font-size: .85rem; }
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }

button, .btn {
  font: inherit; font-weight: 700; cursor: pointer;
  min-height: 60px; padding: 12px 18px; border-radius: 14px;
  border: 2px solid var(--green); background: var(--green); color: #fff;
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; text-align: center;
}
button.secondary, .btn.secondary { background: #fff; color: var(--green); }
button.danger { background: #fff; color: var(--red); border-color: var(--red); }
button.small { min-height: 44px; width: auto; padding: 6px 14px; font-size: .85rem; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 4px solid #ffbf47; outline-offset: 2px; }
.stack > * + * { margin-top: 12px; }

.card {
  background: var(--card); border: 2px solid var(--line); border-radius: 16px;
  padding: 16px; display: block; color: inherit; text-decoration: none;
}
a.card:active { background: #f0ede4; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.big { font-size: 1.9rem; font-weight: 800; letter-spacing: -.5px; }
.money { font-weight: 800; white-space: nowrap; }
.owe { color: var(--red); }
.ok { color: var(--green); }
.name { font-weight: 800; font-size: 1.1rem; word-break: break-word; }

.total-box {
  background: var(--green); color: #fff; border-radius: 18px; padding: 18px; margin-bottom: 16px;
}
.total-box .big { font-size: 2.4rem; }
.sum { background: var(--card); border: 2px solid var(--ink); border-radius: 16px; padding: 14px 16px; }
.sum .line { display: flex; justify-content: space-between; padding: 6px 0; font-size: 1.05rem; }
.sum .final { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 10px; font-size: 1.5rem; font-weight: 800; }

label { display: block; font-weight: 700; margin: 16px 0 6px; }
input[type=text], input[type=password], input[type=date], input[type=tel], input[type=number], input:not([type]) {
  font: inherit; width: 100%; min-height: 60px; padding: 10px 14px;
  border: 2px solid var(--ink); border-radius: 12px; background: #fff;
}
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices button { background: #fff; color: var(--ink); border-color: var(--line); }
.choices button[aria-pressed=true] { background: var(--green); color: #fff; border-color: var(--green); }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.pill.ok { background: var(--green-bg); color: var(--green); }
.pill.bad { background: var(--red-bg); color: var(--red); }
.pill.warn { background: var(--amber-bg); color: var(--amber); }
.file { border-width: 3px; }
.file.ok { border-color: var(--green); }
.file.bad { border-color: var(--red); background: var(--red-bg); }
.file.warn { border-color: #d19a1f; background: var(--amber-bg); }
.errs { margin: 8px 0 0; padding-left: 20px; color: var(--red); font-weight: 600; }

.item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }

nav.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 2px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
}
nav.bottom a {
  flex: 1; text-align: center; padding: 10px 4px; min-height: 68px; color: var(--muted);
  text-decoration: none; font-weight: 700; font-size: .8rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
nav.bottom a .ic { font-size: 1.5rem; line-height: 1; }
nav.bottom a[aria-current=page] { color: var(--green); background: var(--green-bg); }

.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 10;
}
.sheet {
  background: var(--bg); width: 100%; max-width: 720px; max-height: 94vh; overflow: auto;
  border-radius: 20px 20px 0 0; padding: 20px 16px 28px;
}
.toast {
  position: fixed; left: 16px; right: 16px; bottom: 90px; z-index: 20; max-width: 688px; margin: 0 auto;
  background: var(--ink); color: #fff; padding: 16px; border-radius: 14px; font-weight: 700; text-align: center;
}
.toast.err { background: var(--red); }
.center { text-align: center; padding: 40px 0; }

@media print {
  body { background: #fff; }
  #app { display: none !important; }
  #print-area { display: block !important; font-size: 12pt; color: #000; }
  #print-area h1 { font-size: 18pt; }
  #print-area table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; }
  #print-area th, #print-area td { border: 1px solid #000; padding: 5px 8px; text-align: left; }
  #print-area td.r, #print-area th.r { text-align: right; }
  #print-area tr.total td { font-weight: bold; background: #eee; }
}

/* iPhone / pantalla completa */
html { touch-action: manipulation; }
body { padding-top: env(safe-area-inset-top); }
.sheet { max-height: 94dvh; padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
.toast { bottom: calc(90px + env(safe-area-inset-bottom)); }
button, input { -webkit-appearance: none; appearance: none; }
.preview { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 12px; font-size: .8rem; overflow-x: auto; }
.preview h1 { font-size: 1.1rem; }
.preview h2 { font-size: 1rem; }
.preview table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
.preview th, .preview td { border: 1px solid #999; padding: 4px 6px; text-align: left; }
.preview td.r, .preview th.r { text-align: right; }
.preview tr.total td { font-weight: bold; background: #eee; }
.face { background: #124a8a; border-color: #124a8a; font-size: 1.15rem; }
