:root {
  --blue: #4355ff;
  --blue-dark: #3442d9;
  --violet: #4e31dd;
  --teal: #1ad6d6;
  --ink: #12142b;
  --muted: #5f6480;
  --line: #e1e4f2;
  --bg: #f5f6fd;
  --card: #ffffff;
  --danger: #c62f43;
  --radius: 14px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.logo { height: 46px; width: auto; margin: -6px 0; }
.tag {
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
  background: #e9ecff;
  padding: 4px 10px;
  border-radius: 999px;
}
.topbar .link { margin-left: auto; }

main { padding: 32px 24px 56px; margin: 0 auto; }
.narrow { max-width: 420px; padding-top: 72px; }
.layout {
  max-width: 1080px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
aside { position: sticky; top: 24px; }

h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -0.02em; }
h2 { font-size: 18px; margin: 0; }
.muted { color: var(--muted); margin: 0 0 20px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 2px rgba(18, 20, 43, 0.04);
}

label, legend {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.optional { font-weight: 400; color: var(--muted); }

input, select {
  width: 100%;
  font: inherit;
  color: inherit;
  padding: 10px 12px;
  border: 1px solid #cfd3e6;
  border-radius: 10px;
  background: #fff;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
input[readonly] { background: var(--bg); font-size: 14px; }

fieldset { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.row { display: flex; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.field { min-width: 170px; }
.grow { flex: 1 1 200px; }

.item-head, .item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px 80px 36px;
  gap: 8px;
  align-items: center;
}
.item-head { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.item { margin-bottom: 8px; }
.cell { margin: 0; font-weight: 400; min-width: 0; }
/* En desktop el encabezado de columnas hace de label; en mobile se muestra por campo */
.cell > span {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.remove {
  height: 36px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  border-radius: 8px;
}
.remove:hover { background: var(--bg); color: var(--danger); }
.remove:disabled { visibility: hidden; }

button, .button { font: inherit; cursor: pointer; }
.primary {
  display: inline-block;
  width: 100%;
  padding: 12px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}
.primary:hover { background: var(--blue-dark); }
.primary:disabled { opacity: 0.6; cursor: progress; }
.secondary {
  width: 100%;
  padding: 12px 18px;
  border: 1px solid #cfd3e6;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-weight: 600;
}
.secondary:hover { border-color: var(--blue); color: var(--blue); }
.link {
  border: 0;
  background: none;
  padding: 4px 0;
  color: var(--blue);
  font-weight: 600;
  font-size: 14px;
}
.link:hover { text-decoration: underline; }
.link.danger { color: var(--danger); margin-top: 8px; }

.presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.preset {
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
}
.preset:hover { border-color: var(--blue); }
.preset[aria-pressed='true'] { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); background: #f3f4ff; }
.preset strong { display: block; font-size: 15px; }
.preset span { font-size: 12px; color: var(--muted); }

.error { color: var(--danger); font-size: 14px; margin: 0 0 14px; }
.notice { font-size: 12px; color: var(--muted); text-align: center; margin: 12px 0 0; }

.empty {
  text-align: center;
  color: var(--muted);
  border-style: dashed;
  padding: 56px 24px;
}
.empty p { margin: 0; }

.result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.total { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.result .muted { margin-bottom: 18px; font-size: 14px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 20px; }

.badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e9ecff;
  color: var(--blue);
  white-space: nowrap;
}
.badge.paid { background: #d9f7ee; color: #0b7a55; }
.badge.processing { background: #fff1d6; color: #8a5a00; }
.badge.ended { background: #eceef5; color: var(--muted); }

dl { margin: 0 0 14px; border-top: 1px solid var(--line); }
dl div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; word-break: break-all; }

/* Página de gracias */
.thanks { max-width: 460px; padding-top: 96px; text-align: center; }
.check {
  width: 64px; height: 64px; margin: 0 auto 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  color: #fff; font-size: 32px; line-height: 64px;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  aside { position: static; }
  main { padding: 24px 16px 40px; }
  .topbar { padding: 12px 16px; }
}
@media (max-width: 480px) {
  .card { padding: 18px 16px; }
  input, select { font-size: 16px; } /* evita el zoom automático en iOS */
  .item-head { display: none; }
  .item {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px;
    gap: 10px;
    align-items: end;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--line);
  }
  .item .cell:first-child { grid-column: 1 / -1; }
  .cell > span {
    position: static; width: auto; height: auto; overflow: visible; clip: auto;
    display: block; margin-bottom: 6px;
    font-size: 13px; font-weight: 600; color: var(--ink);
  }
  .remove { height: 44px; width: 44px; border: 1px solid var(--line); }
  .remove:disabled { visibility: hidden; }
  .field, .grow { flex: 1 1 100%; min-width: 0; }
  .actions { grid-template-columns: 1fr; }
}
