/* Caleta — sistema visual
   Papel gris + tinta negra + un solo acento mango. Marcador a mano solo para notas humanas. */
@import url('https://fonts.googleapis.com/css2?family=Gochi+Hand&family=Schibsted+Grotesk:ital,wght@0,400..900;1,400..900&display=swap');

:root {
  --paper: #EDEDEA;
  --white: #FFFFFF;
  --ink: #000000;
  --graphite: #56564F;
  --mute: #8B8B84;
  --line: #D3D3CC;
  --fill: #F6F6F3;
  --mango: #FF6B12;
  --mango-ink: #B94600;
  --ok: #167A42;
  --ok-fill: #E3F3E8;
  --bad: #BF2519;
  --bad-fill: #FBE6E3;

  --sans: 'Schibsted Grotesk', system-ui, sans-serif;
  --hand: 'Gochi Hand', 'Comic Sans MS', cursive;

  /* Escala tipográfica 1.25 */
  --t-xs: .78rem;
  --t-sm: .875rem;
  --t-md: 1rem;
  --t-lg: 1.25rem;
  --t-xl: 1.563rem;
  --t-2xl: 1.953rem;
  --t-3xl: 2.441rem;
  --t-4xl: 3.815rem;

  --r-sm: 8px;
  --r-md: 12px;
  --r-card: 20px;
  --shadow-card: 0 1px 0 rgba(0,0,0,.06), 0 18px 40px -18px rgba(0,0,0,.45);
  --focus: 0 0 0 3px var(--white), 0 0 0 5px var(--ink);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: var(--t-md);
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.1; letter-spacing: -.02em; font-weight: 700; }
p { margin: 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hand { font-family: var(--hand); font-weight: 400; letter-spacing: 0; }
.muted { color: var(--graphite); }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 44px; padding: 0 1.25rem;
  border: 1.5px solid var(--ink); border-radius: 999px;
  background: var(--ink); color: var(--white);
  font-weight: 600; font-size: var(--t-sm); text-decoration: none; cursor: pointer;
  transition: transform .15s var(--ease), background .15s;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.white { background: var(--white); color: var(--ink); border-color: var(--line); }
.btn.mango { background: var(--mango); border-color: var(--mango); color: var(--ink); }
.btn.danger { background: var(--white); color: var(--bad); border-color: var(--bad); }
.btn.sm { min-height: 34px; padding: 0 .9rem; font-size: var(--t-xs); }
.btn.lg { min-height: 54px; padding: 0 1.75rem; font-size: var(--t-md); }
.btn.block { width: 100%; }
@media (hover: hover) {
  .btn:hover { background: var(--graphite); border-color: var(--graphite); }
  .btn.ghost:hover, .btn.white:hover { background: var(--white); border-color: var(--ink); color: var(--ink); }
  .btn.mango:hover { background: #FF8436; border-color: #FF8436; }
  .btn.danger:hover { background: var(--bad-fill); border-color: var(--bad); color: var(--bad); }
}

/* ---------- Formularios ---------- */
.field { display: grid; gap: .35rem; }
.field > span { font-size: var(--t-sm); font-weight: 600; }
.field > small { font-size: var(--t-xs); color: var(--graphite); }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: .6rem .85rem;
  border: 1.5px solid var(--line); border-radius: var(--r-md);
  background: var(--white); font-size: 16px; /* evita zoom en iOS */
  transition: border-color .15s;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink); box-shadow: none; }
.input[aria-invalid="true"] { border-color: var(--bad); }
.check { display: flex; gap: .7rem; align-items: flex-start; cursor: pointer; font-size: var(--t-sm); }
.check input { width: 20px; height: 20px; accent-color: var(--ink); margin: 2px 0 0; flex: none; }
.row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stack { display: grid; gap: 1rem; }
.stack-sm { display: grid; gap: .5rem; }

/* Selector de opciones grandes (tipo de programa, moneda) */
.choice { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.choice label {
  position: relative; display: grid; gap: .2rem; padding: .9rem 1rem; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: var(--r-md); background: var(--white);
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice label:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.choice label:has(input:focus-visible) { box-shadow: var(--focus); }
.choice b { font-size: var(--t-sm); }
.choice small { color: var(--graphite); font-size: var(--t-xs); line-height: 1.35; }

.swatches { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.swatch {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--white);
  box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; padding: 0;
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2.5px var(--ink); }

/* ---------- Superficies ---------- */
.sheet { background: var(--white); border-radius: var(--r-card); padding: 1.5rem; }
.sheet.flat { border: 1.5px solid var(--line); }

/* Globo de diálogo dibujado a mano */
.bubble {
  position: relative; padding: 1.6rem 1.8rem; background: var(--white);
  border: 2.5px solid var(--ink);
  border-radius: 34px 46px 38px 52px / 48px 32px 50px 36px;
}
.bubble.ink { background: var(--ink); color: var(--white); }
.bubble::after {
  content: ''; position: absolute; bottom: -18px; left: 22%;
  width: 26px; height: 22px; background: inherit;
  border-right: 2.5px solid var(--ink); border-bottom: 2.5px solid var(--ink);
  transform: skewX(32deg) rotate(8deg); border-bottom-right-radius: 6px;
}
.bubble.right::after { left: auto; right: 22%; transform: skewX(-32deg) rotate(-8deg); border-right: 0; border-left: 2.5px solid var(--ink); border-bottom-right-radius: 0; border-bottom-left-radius: 6px; }

/* ---------- Etiquetas de estado ---------- */
.tag {
  display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .6rem;
  border-radius: 999px; font-size: var(--t-xs); font-weight: 600; white-space: nowrap;
  background: var(--fill); color: var(--graphite); border: 1px solid var(--line);
}
.tag.ok { background: var(--ok-fill); color: var(--ok); border-color: transparent; }
.tag.bad { background: var(--bad-fill); color: var(--bad); border-color: transparent; }
.tag.warn { background: #FFF0E4; color: var(--mango-ink); border-color: transparent; }
.tag.ink { background: var(--ink); color: var(--white); border-color: var(--ink); }

.plus { color: var(--ok); }
.minus { color: var(--bad); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.list { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.list th { text-align: left; font-weight: 600; color: var(--graphite); padding: .6rem .75rem; border-bottom: 1.5px solid var(--ink); white-space: nowrap; }
.list td { padding: .7rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list tr[data-href] { cursor: pointer; }
@media (hover: hover) { .list tr[data-href]:hover td { background: var(--fill); } }
.list td.r, .list th.r { text-align: right; }

/* ---------- Toast y modal ---------- */
.toasts { position: fixed; z-index: 90; left: 50%; bottom: max(1rem, env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: .5rem; width: min(92vw, 420px); pointer-events: none; }
.toast {
  padding: .85rem 1.1rem; border-radius: 14px; background: var(--ink); color: var(--white);
  font-size: var(--t-sm); font-weight: 500; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  animation: toast-in .35s var(--ease);
}
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }

.modal-back {
  position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.45);
  display: grid; place-items: end center; padding: 0;
  animation: fade .2s ease;
}
@media (min-width: 640px) { .modal-back { place-items: center; padding: 1.5rem; } }
.modal {
  width: min(100%, 560px); max-height: 92dvh; overflow: auto; background: var(--white);
  border-radius: 24px 24px 0 0; padding: 1.5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
  animation: sheet-up .3s var(--ease);
}
@media (min-width: 640px) { .modal { border-radius: 24px; padding: 1.75rem; } }
.modal header { display: flex; justify-content: space-between; align-items: start; gap: 1rem; margin-bottom: 1.25rem; }
.modal header h3 { font-size: var(--t-xl); }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--white); cursor: pointer; display: grid; place-items: center; flex: none; }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } }

/* ---------- Tarjeta de wallet (vista previa) ---------- */
.wcard {
  --bg: #000; --fg: #fff; --fg2: rgba(255,255,255,.66);
  position: relative; width: 100%; max-width: 340px; min-width: 0; aspect-ratio: 1 / 1.42;
  display: flex; flex-direction: column; gap: .9rem;
  padding: 1rem 1.05rem 1.1rem; border-radius: 16px;
  background: var(--bg); color: var(--fg);
  box-shadow: var(--shadow-card); overflow: hidden;
  font-family: -apple-system, 'SF Pro Text', var(--sans);
}
.wc-top { display: flex; align-items: center; gap: .55rem; min-height: 34px; }
.wc-logo { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; flex: none; background: rgba(255,255,255,.15); }
.wc-logo-fallback { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: .95rem; background: var(--fg); color: var(--bg); flex: none; }
.wc-name { font-weight: 600; font-size: .95rem; line-height: 1.15; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wc-head { text-align: right; line-height: 1.1; }
.wc-label { display: block; font-size: .58rem; font-weight: 600; letter-spacing: .06em; color: var(--fg2); }
.wc-head b { font-size: 1.05rem; font-weight: 500; }
.wc-strip { border-radius: 4px; min-height: 84px; display: grid; align-content: center; }
.wc-strip img { width: 100%; aspect-ratio: 3 / 1; object-fit: cover; border-radius: 4px; }
.wc-primary b { display: block; font-size: 2rem; font-weight: 400; line-height: 1.05; letter-spacing: -.01em; }
.wc-stamps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .45rem; }
.wc-stamps i {
  aspect-ratio: 1; border-radius: 50%; border: 1.5px dashed var(--fg2);
  display: grid; place-items: center; font-style: normal;
}
.wc-stamps i.on { border: 0; background: var(--fg); color: var(--bg); }
.wc-stamps i.on::after { content: '✓'; font-weight: 700; font-size: .85rem; }
.wc-fields { display: flex; justify-content: space-between; gap: .75rem; }
.wc-fields > div { min-width: 0; }
.wc-fields b { display: block; font-size: .9rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wc-qr { margin-top: auto; align-self: center; background: #fff; padding: .45rem; border-radius: 6px; width: 38%; }
.wc-qr canvas, .wc-qr svg { width: 100%; height: auto; }
.wc-qr small { display: block; text-align: center; color: #000; font-size: .55rem; letter-spacing: .08em; margin-top: .2rem; }

/* ---------- Layout de apps (panel y admin) ---------- */
.app { min-height: 100dvh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 960px) { .app { grid-template-columns: 248px 1fr; } }
.side {
  background: var(--ink); color: var(--white); padding: 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  position: sticky; top: 0; z-index: 30;
}
.side .brand { font-family: var(--hand); font-size: 1.9rem; line-height: 1; text-decoration: none; }
.side .brand small { display: block; font-family: var(--sans); font-size: var(--t-xs); color: var(--mute); margin-top: .25rem; }
.side nav { display: none; }
.side .menu-btn { background: none; border: 1.5px solid #444; color: var(--white); border-radius: 999px; padding: .45rem .95rem; font-size: var(--t-sm); cursor: pointer; }
.side.open nav {
  display: grid; position: fixed; inset: 64px 0 0 0; background: var(--ink); padding: 1rem; align-content: start; gap: .15rem; overflow: auto;
}
@media (min-width: 960px) {
  .side { height: 100dvh; flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 1.5rem 1rem; }
  .side nav, .side.open nav { display: grid; position: static; padding: 0; gap: .15rem; margin-top: 2rem; background: none; }
  .side .menu-btn { display: none; }
  .side .foot { margin-top: auto; }
}
.side nav a, .side nav button {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .7rem .8rem; border-radius: 10px; color: #CFCFC8; text-decoration: none;
  font-size: var(--t-sm); font-weight: 500; background: none; border: 0; text-align: left; cursor: pointer; width: 100%;
}
.side nav a[aria-current="page"] { background: var(--white); color: var(--ink); }
@media (hover: hover) { .side nav a:not([aria-current="page"]):hover { background: #1C1C1A; color: var(--white); } }
.side nav hr { border: 0; border-top: 1px solid #2A2A27; margin: .75rem 0; }
.side .count { font-size: var(--t-xs); color: var(--mute); }
.side .foot { display: none; }
@media (min-width: 960px) { .side .foot { display: grid; gap: .5rem; font-size: var(--t-xs); color: var(--mute); } }

.main { padding: 1.25rem 1rem 5rem; min-width: 0; }
@media (min-width: 960px) { .main { padding: 2.25rem 2.5rem 4rem; } }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.75rem; }
.page-head h1 { font-size: var(--t-2xl); }
.page-head p { color: var(--graphite); margin-top: .35rem; font-size: var(--t-sm); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.kpis { display: grid; gap: 1px; grid-template-columns: repeat(2, 1fr); background: var(--line); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; margin-bottom: 1.5rem; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--white); padding: 1.1rem 1.2rem; }
.kpi span { font-size: var(--t-xs); color: var(--graphite); }
.kpi b { display: block; font-size: var(--t-2xl); font-weight: 700; letter-spacing: -.02em; margin-top: .2rem; }
.kpi small { font-size: var(--t-xs); color: var(--graphite); }

.grid-2 { display: grid; gap: 1.25rem; }
@media (min-width: 1100px) { .grid-2 { grid-template-columns: 1.4fr 1fr; align-items: start; } }

.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1.5px solid var(--line); margin-bottom: 1.5rem; scrollbar-width: none; }
.tabs button {
  padding: .7rem .95rem; border: 0; background: none; cursor: pointer; white-space: nowrap;
  font-weight: 600; font-size: var(--t-sm); color: var(--graphite); border-bottom: 2.5px solid transparent; margin-bottom: -1.5px;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--ink); }

.empty { text-align: center; padding: 3rem 1rem; display: grid; gap: .75rem; justify-items: center; }
.empty .hand { font-size: 1.8rem; line-height: 1.1; }

.bars { display: flex; align-items: end; gap: 4px; height: 120px; padding-top: .5rem; }
.bars div { flex: 1; background: var(--ink); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars div:last-child { background: var(--mango); }

.search { position: relative; }
.search .input { padding-left: 2.5rem; }
.search svg { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); width: 18px; color: var(--mute); }

/* ---------- Pasos del asistente ---------- */
.steps { display: flex; gap: .35rem; margin-bottom: 1.25rem; }
.steps i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.steps i.done { background: var(--ink); }
.steps i.now { background: var(--mango); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
