/* CodexSMS · estilo iOS: vidrio, tarjetas redondeadas, animaciones suaves */
:root {
  color-scheme: light dark;
  --bg: #f2f2f7;
  --bg-grad-1: rgba(10, 132, 255, .14);
  --bg-grad-2: rgba(52, 199, 89, .12);
  --card: rgba(255, 255, 255, .78);
  --card-solid: #ffffff;
  --fill: rgba(120, 120, 128, .12);
  --fill-strong: rgba(120, 120, 128, .2);
  --line: rgba(60, 60, 67, .14);
  --text: #1c1c1e;
  --muted: #6e6e73;
  --accent: #0a84ff;
  --accent-2: #5e5ce6;
  --accent-ink: #fff;
  --ok: #30b350;
  --warn: #ff9f0a;
  --danger: #ff453a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 30px rgba(0, 0, 0, .06);
  --radius: 22px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --bg-grad-1: rgba(10, 132, 255, .22);
    --bg-grad-2: rgba(94, 92, 230, .2);
    --card: rgba(28, 28, 30, .72);
    --card-solid: #1c1c1e;
    --fill: rgba(120, 120, 128, .24);
    --fill-strong: rgba(120, 120, 128, .36);
    --line: rgba(84, 84, 88, .55);
    --text: #f5f5f7;
    --muted: #98989f;
    --ok: #32d74b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 40px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background:
    radial-gradient(900px 500px at 10% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, var(--bg-grad-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, .brand { font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', system-ui, sans-serif; }
h1 { font-size: 34px; line-height: 1.1; letter-spacing: -.03em; margin: 0 0 10px; font-weight: 700; }
h2 { font-size: 22px; letter-spacing: -.02em; font-weight: 700; margin: 22px 0 12px; }
h2:first-child { margin-top: 0; }
h2 .step { color: var(--accent); margin-right: 6px; }
code { font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', monospace; font-size: .9em; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- barra superior (vidrio) ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px max(20px, calc((100vw - 1100px) / 2 + 16px));
  background: var(--card);
  -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  border-bottom: .5px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: -.02em; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 4px 12px rgba(10, 132, 255, .4);
}
.brand .logo svg { width: 18px; height: 18px; }
.brand span { color: var(--accent); }
#userbox { display: flex; gap: 10px; align-items: center; font-size: 14px; }
#userbox .email { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) { #userbox .email { display: none; } }
.balance {
  font: 600 14px ui-monospace, 'SF Mono', 'JetBrains Mono', monospace;
  background: var(--fill); padding: 6px 12px; border-radius: 999px;
  transition: transform .4s var(--spring), background .3s;
}
.balance.bump { transform: scale(1.18); background: rgba(48, 179, 80, .25); }

.banner {
  margin: 12px auto 0; max-width: 1068px; width: calc(100% - 32px);
  background: rgba(255, 159, 10, .15); color: var(--warn);
  padding: 10px 16px; border-radius: 14px; font-size: 13px;
}

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 80px; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; margin-bottom: 20px; align-items: start; }
.grid > *, .card, .card > * { min-width: 0; }   /* evita que el contenido ensanche la pantalla */
@media (max-width: 820px) { .grid { grid-template-columns: minmax(0, 1fr); } }
#shop, main { max-width: 100%; }

/* ---------- tarjetas ---------- */
.card {
  background: var(--card);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border: .5px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
  animation: rise .6s var(--ease) both;
}
.grid > .card:nth-child(2) { animation-delay: .08s; }
.grid + .grid > .card:nth-child(1) { animation-delay: .12s; }
.grid + .grid > .card:nth-child(2) { animation-delay: .18s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }

/* ---------- acceso ---------- */
.auth { max-width: 440px; margin: 28px auto; padding: 32px 26px; text-align: center; }
.auth h1 { font-size: 30px; }
.auth form { text-align: left; }
.hero-icon {
  width: 76px; height: 76px; margin: 0 auto 20px; border-radius: 22px;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow: 0 14px 34px rgba(10, 132, 255, .42);
  animation: float 4s ease-in-out infinite;
}
.hero-icon svg { width: 38px; height: 38px; }
@keyframes float { 50% { transform: translateY(-6px); } }

/* ---------- controles ---------- */
input {
  width: 100%; background: var(--fill); color: var(--text);
  border: 1.5px solid transparent; border-radius: 14px; padding: 13px 15px;
  font: inherit; margin-bottom: 10px; transition: border-color .2s, background .2s, box-shadow .2s;
}
input::placeholder { color: var(--muted); }
input:focus { outline: none; border-color: var(--accent); background: var(--card-solid); box-shadow: 0 0 0 4px rgba(10, 132, 255, .18); }
.row { display: flex; gap: 10px; align-items: center; }
.row input { margin: 0; }
.row.wrap { flex-wrap: wrap; }
.row.wrap input { flex: 1 1 140px; }
.between { justify-content: space-between; }

.btn {
  position: relative; overflow: hidden;
  background: var(--fill); color: var(--accent); border: 0; border-radius: 14px;
  padding: 12px 18px; font: 600 15px -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  cursor: pointer; white-space: nowrap;
  transition: transform .25s var(--spring), filter .2s, background .2s, opacity .2s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.95); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: linear-gradient(180deg, #2b95ff, var(--accent)); color: #fff; box-shadow: 0 4px 14px rgba(10, 132, 255, .35); }
.btn.ghost { background: var(--fill); color: var(--text); }
.btn.small { padding: 7px 14px; font-size: 13px; border-radius: 999px; }
.btn.danger { background: rgba(255, 69, 58, .14); color: var(--danger); }
.btn.loading { color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ''; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn:not(.primary).loading::after { border-color: var(--fill-strong); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
form > .btn { width: 100%; padding: 14px; font-size: 16px; }

/* control segmentado */
.tabs { display: flex; position: relative; background: var(--fill); border-radius: 12px; padding: 3px; margin: 22px 0 16px; }
.tabs::before {
  content: ''; position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px);
  background: var(--card-solid); border-radius: 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, .14);
  transition: transform .35s var(--ease);
}
.tabs[data-active="register"]::before { transform: translateX(100%); }
.tab { position: relative; flex: 1; background: none; border: 0; color: var(--muted); padding: 8px; border-radius: 10px; cursor: pointer; font: 600 14px inherit; font-family: inherit; transition: color .25s; }
.tab.active { color: var(--text); }

/* servicios: cuadrícula ordenada de logos */
.chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 6px; }
.chip {
  display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0;
  padding: 10px 4px 8px; background: var(--fill); color: var(--text);
  border: 2px solid transparent; border-radius: 16px; cursor: pointer; font: 500 11px inherit; font-family: inherit;
  transition: transform .3s var(--spring), background .25s, border-color .25s, box-shadow .25s;
}
.logo-tile {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .18), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform .35s var(--spring);
}
.logo-tile i { width: 22px; height: 22px; background: #fff; display: block; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: center; mask-position: center; -webkit-mask-size: contain; mask-size: contain; }
.chip .lbl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.2; }
.chip:hover .logo-tile { transform: scale(1.1) rotate(-4deg); }
.chip:active { transform: scale(.94); }
.chip.active { background: var(--card-solid); border-color: var(--accent); box-shadow: 0 6px 18px rgba(10, 132, 255, .25); font-weight: 600; }

/* lista agrupada estilo ajustes */
.list { max-height: 400px; overflow-y: auto; background: var(--card-solid); border-radius: 18px; border: .5px solid var(--line); }
.item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px;
  border-bottom: .5px solid var(--line); animation: rise .45s var(--ease) both;
  transition: background .2s;
}
.item:hover { background: var(--fill); }
.item:last-child { border-bottom: 0; }
.item .who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.item .av {
  flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  font: 700 14px inherit; font-family: inherit; color: #fff;
}
.item .av.flag { width: 40px; height: 30px; border-radius: 6px; object-fit: cover; background: var(--fill); box-shadow: 0 0 0 .5px rgba(0, 0, 0, .18), 0 2px 6px rgba(0, 0, 0, .18); }
.item .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .price { font: 600 15px ui-monospace, 'SF Mono', 'JetBrains Mono', monospace; }
.item small { color: var(--muted); font-size: 12px; }
.list .muted, .empty { padding: 18px 14px; margin: 0; text-align: center; }
.list::-webkit-scrollbar { width: 8px; } .list::-webkit-scrollbar-thumb { background: var(--fill-strong); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }

/* skeleton de carga */
.skel { height: 62px; margin: 0; border-bottom: .5px solid var(--line); background: linear-gradient(100deg, transparent 30%, var(--fill) 50%, transparent 70%); background-size: 220% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

/* pedidos */
.order {
  background: var(--card-solid); border: .5px solid var(--line); border-radius: 18px;
  padding: 14px 16px; margin-bottom: 12px; animation: pop .5s var(--spring) both;
}
@keyframes pop { from { opacity: 0; transform: scale(.92) translateY(10px); } to { opacity: 1; transform: none; } }
.order .phone { font: 600 19px ui-monospace, 'SF Mono', 'JetBrains Mono', monospace; cursor: pointer; letter-spacing: -.01em; }
.order .code {
  margin: 10px 0 4px; padding: 12px; text-align: center; border-radius: 14px; cursor: pointer;
  font: 700 32px ui-monospace, 'SF Mono', 'JetBrains Mono', monospace; letter-spacing: .18em; color: var(--ok);
  background: rgba(48, 179, 80, .12); animation: pop .5s var(--spring) both; transition: transform .2s var(--spring);
}
.order .code:active { transform: scale(.97); }
.order .meta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.order .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--fill); display: inline-flex; align-items: center; gap: 6px; }
.pill.waiting { color: var(--warn); background: rgba(255, 159, 10, .15); }
.pill.waiting::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }
.pill.received, .pill.done { color: var(--ok); background: rgba(48, 179, 80, .15); }
.pill.cancelled { color: var(--muted); }

/* estadísticas admin */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--fill); border-radius: 16px; padding: 14px; }
.stat b { display: block; font: 700 20px ui-monospace, 'SF Mono', 'JetBrains Mono', monospace; letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--muted); }

/* ---------- panel de administración ---------- */
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.admin-head h1 { font-size: 28px; margin: 0; }
.seg { display: grid; grid-template-columns: repeat(var(--n), 1fr); position: relative; background: var(--fill); border-radius: 14px; padding: 3px; margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg::before {
  content: ''; position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc((100% - 6px) / var(--n));
  background: var(--card-solid); border-radius: 11px; box-shadow: 0 2px 8px rgba(0, 0, 0, .14);
  transform: translateX(calc(var(--i) * 100%)); transition: transform .35s var(--ease);
}
.seg button { position: relative; background: none; border: 0; color: var(--muted); padding: 9px 6px; border-radius: 11px; cursor: pointer; font: 600 13px inherit; font-family: inherit; white-space: nowrap; transition: color .25s; }
.seg button.on { color: var(--text); }
@media (max-width: 560px) { .seg { grid-template-columns: repeat(var(--n), minmax(84px, 1fr)); } .admin-head h1 { font-size: 22px; } }
.view { animation: rise .45s var(--ease) both; }
.view > .card + .card { margin-top: 16px; }
.stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 460px) { .stats-3 { grid-template-columns: 1fr; } }
.stats b { overflow-wrap: anywhere; }
.list.tall { max-height: 62dvh; }
.list.short { max-height: 220px; }
.item.clickable { cursor: pointer; }
.item.clickable:active { background: var(--fill-strong); }
.avatar { background: linear-gradient(145deg, var(--accent), var(--accent-2)); border-radius: 50% !important; font-size: 15px; }
.badge { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .02em; padding: 2px 7px; border-radius: 999px; vertical-align: middle; margin-left: 4px; }
.badge.adm { background: rgba(94, 92, 230, .18); color: var(--accent-2); }
.badge.ban { background: rgba(255, 69, 58, .16); color: var(--danger); }
.small { font-size: 12px; }
.chips-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.chips-row::-webkit-scrollbar { display: none; }
.fchip { flex: none; background: var(--fill); color: var(--text); border: 0; border-radius: 999px; padding: 7px 14px; font: 600 13px inherit; font-family: inherit; cursor: pointer; transition: background .2s, color .2s, transform .25s var(--spring); }
.fchip:active { transform: scale(.94); }
.fchip.on { background: var(--accent); color: #fff; }

/* gráfica de barras */
.chart { position: relative; display: flex; align-items: flex-end; gap: 10px; height: 190px; padding-top: 8px; }
.chart .col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.chart .bar { width: 100%; max-width: 46px; background: rgba(10, 132, 255, .28); border-radius: 8px 8px 4px 4px; position: relative; overflow: hidden; animation: grow .7s var(--ease) both; transform-origin: bottom; }
.chart .bar i { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(180deg, #2b95ff, var(--accent)); border-radius: 0 0 4px 4px; }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.chart .val { font: 600 10px ui-monospace, 'SF Mono', monospace; color: var(--muted); white-space: nowrap; }
.chart .lab { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.chart .legend { position: absolute; top: -26px; right: 0; display: flex; gap: 12px; font-size: 11px; color: var(--muted); }
.chart .legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }
.chart .legend .k1 { background: rgba(10, 132, 255, .4); } .chart .legend .k2 { background: var(--accent); }
.view .card > h2 { position: relative; }
#v-overview .card { padding-top: 22px; }
#v-overview .chart { margin-top: 30px; }

/* campos de acceso: ojito, interruptor, aviso de código */
.pw { position: relative; }
.pw input { padding-right: 50px; }
.eye {
  position: absolute; right: 6px; top: 6px; width: 38px; height: 38px; border: 0; background: none; border-radius: 12px;
  color: var(--muted); cursor: pointer; display: grid; place-items: center; transition: color .2s, background .2s, transform .25s var(--spring);
}
.eye:hover { color: var(--text); background: var(--fill); }
.eye:active { transform: scale(.88); }
.eye[aria-pressed="true"] { color: var(--accent); }
.eye svg { width: 21px; height: 21px; }
.reg-only:not([hidden]), .login-only:not([hidden]) { animation: rise .35s var(--ease) both; }
.field-note { margin: -4px 4px 10px; font-size: 12px; color: var(--muted); }
.field-note.ok { color: var(--ok); }
.field-note.bad { color: var(--danger); }
input.ok-field { border-color: var(--ok); }
input.bad-field { border-color: var(--danger); }

.switch { display: flex; align-items: center; gap: 12px; margin: 4px 2px 14px; cursor: pointer; user-select: none; -webkit-user-select: none; font-size: 15px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; pointer-events: none; }
.switch i {
  position: relative; flex: none; width: 51px; height: 31px; border-radius: 999px; background: var(--fill-strong);
  transition: background .3s var(--ease);
}
.switch i::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3); transition: transform .35s var(--spring), width .2s;
}
.switch:active i::after { width: 32px; }
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch:active input:checked + i::after { transform: translateX(15px); }
.switch input:focus-visible + i { box-shadow: 0 0 0 4px rgba(10, 132, 255, .3); }

/* ajustes */
.set-card { margin-bottom: 16px; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: .5px solid var(--line); }
.set-row:last-child { border-bottom: 0; padding-bottom: 0; }
.set-info { min-width: 0; flex: 1; }
.set-info label { display: block; font-weight: 600; }
.set-info small { color: var(--muted); font-size: 12px; line-height: 1.35; display: block; margin-top: 2px; }
.set-input { flex: none; width: 150px; text-align: right; }
.unit-input { position: relative; display: flex; align-items: center; }
.unit-input input { margin: 0; padding-right: 44px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.unit-input span { position: absolute; right: 13px; color: var(--muted); font-size: 12px; font-weight: 600; pointer-events: none; }
.link { background: none; border: 0; color: var(--accent); font: 500 12px inherit; font-family: inherit; cursor: pointer; padding: 6px 0 0; }
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.svc-cell { display: flex; flex-direction: column; gap: 8px; background: var(--fill); border-radius: 16px; padding: 12px; }
.svc-cell .unit-input input { background: var(--card-solid); }
.svc-name { display: flex; align-items: center; gap: 10px; }
.svc-name .logo-tile { width: 30px; height: 30px; border-radius: 9px; }
.svc-name .logo-tile i { width: 17px; height: 17px; }
.savebar {
  position: sticky; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--card); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  border: .5px solid var(--line); border-radius: 18px; padding: 10px 12px 10px 16px; box-shadow: var(--shadow);
}
.savebar .btn { flex: none; }
@media (max-width: 560px) {
  .set-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .set-input { width: 100%; text-align: left; }
  .savebar .muted { display: none; }
  .savebar .btn { width: 100%; }
}
#userbox .balance small { font: 600 10px -apple-system, BlinkMacSystemFont, 'Inter', sans-serif; color: var(--muted); letter-spacing: .03em; text-transform: uppercase; margin-right: 3px; }

/* hoja deslizable de usuario */
body.noscroll { overflow: hidden; }
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); opacity: 0; transition: opacity .3s; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.sheet.open .sheet-bg { opacity: 1; }
.sheet-panel {
  position: relative; width: min(100%, 640px); max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--card-solid); border-radius: 26px 26px 0 0; padding: 10px 20px max(24px, env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .45s var(--ease); box-shadow: 0 -12px 50px rgba(0, 0, 0, .3);
}
.sheet.open .sheet-panel { transform: none; }
.sheet-grab { width: 38px; height: 5px; border-radius: 3px; background: var(--fill-strong); margin: 0 auto 14px; }
.sheet-panel h3 { font-size: 15px; margin: 22px 0 10px; letter-spacing: -.01em; }
.sheet-panel form.row input { margin: 0; }
.sheet-panel form.row { flex-wrap: wrap; }
.sheet-panel form.row input { flex: 1 1 160px; }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-panel { border-radius: 26px; transform: translateY(30px) scale(.97); opacity: 0; transition: transform .4s var(--ease), opacity .3s; } .sheet.open .sheet-panel { opacity: 1; transform: none; } }

/* movimientos */
#ledger .item .who { gap: 10px; }
.mv-ico { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 16px; font-weight: 700; color: #fff; }
.mv-ico.in { background: var(--ok); }
.mv-ico.out { background: var(--accent); }
.mv-amt { font: 600 15px ui-monospace, 'SF Mono', 'JetBrains Mono', monospace; white-space: nowrap; }
.mv-amt.in { color: var(--ok); }

/* cuenta atrás */
.countdown { font: 600 13px ui-monospace, 'SF Mono', monospace; color: var(--warn); font-variant-numeric: tabular-nums; }
.countdown.low { color: var(--danger); animation: pulse 1s ease-in-out infinite; }
.progress { height: 4px; border-radius: 4px; background: var(--fill); margin-top: 10px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--warn), var(--ok)); border-radius: 4px; transform-origin: left; transition: transform 1s linear; }

.ref-banner { margin: 16px 0 0; padding: 10px 14px; border-radius: 14px; background: rgba(48, 179, 80, .14); color: var(--ok); font-size: 13px; text-align: left; }
#ref-link { font: 500 13px ui-monospace, 'SF Mono', monospace; text-overflow: ellipsis; }
#ref-copy { flex: none; }
.alert { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; padding: 12px 14px; border-radius: 16px; background: rgba(255, 69, 58, .14); color: var(--danger); font-size: 13px; animation: pop .5s var(--spring) both; }
.alert b { font-size: 14px; }

/* aviso flotante */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 50; max-width: min(92vw, 420px);
  display: flex; align-items: center; gap: 10px;
  background: var(--card); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  border: .5px solid var(--line); padding: 12px 18px; border-radius: 18px; box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
  font-weight: 500; transform: translate(-50%, 140%); opacity: 0; pointer-events: none;
  transition: transform .5s var(--spring), opacity .3s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast::before { content: '✓'; flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--ok); color: #fff; font-size: 13px; font-weight: 700; }
.toast.error::before { content: '!'; background: var(--danger); }

/* ---------- móvil ---------- */
html { touch-action: manipulation; }          /* sin zoom por doble toque */
body { overflow-x: hidden; min-height: 100dvh; overscroll-behavior-y: none; }
input, button, select, textarea { font-size: 16px; touch-action: manipulation; } /* <16px hace que iOS haga zoom al enfocar */
input[type=search] { -webkit-appearance: none; appearance: none; }
.btn, .chip, .tab { user-select: none; -webkit-user-select: none; }
.order .phone, .order .code { -webkit-user-select: all; user-select: all; }
.top { padding-top: max(12px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
main { padding-bottom: max(80px, calc(40px + env(safe-area-inset-bottom))); }
.toast { bottom: max(28px, calc(16px + env(safe-area-inset-bottom))); }
.btn.small { min-height: 36px; }

@media (max-width: 560px) {
  .top { padding-left: 16px; padding-right: 16px; }
  main { padding: 14px 12px 60px; }
  .grid { gap: 14px; margin-bottom: 14px; }
  .card { padding: 16px; border-radius: 20px; }
  .auth { margin: 12px auto; padding: 24px 18px; }
  h1, .auth h1 { font-size: 26px; }
  h2 { font-size: 20px; margin: 18px 0 10px; }
  .btn { min-height: 44px; }
  .btn.small { min-height: 36px; padding: 6px 14px; }
  input { padding: 14px 15px; }
  #topup-form { flex-direction: column; align-items: stretch; }
  #topup-form input { margin-bottom: 10px; }
  #topup-form .btn { width: 100%; }
  .row.wrap input, .row.wrap .btn { flex: 1 1 100%; }
  .stats { gap: 8px; }
  .stat { padding: 12px; }
  .stat b { font-size: 17px; }
  .chips { gap: 6px; }
  .chip { padding: 9px 2px 7px; font-size: 10.5px; border-radius: 14px; }
  .logo-tile { width: 38px; height: 38px; }
  .order .row.between { flex-wrap: wrap; gap: 6px; }
  .order .phone { overflow-wrap: anywhere; }
  .item .price { font-size: 14px; }
  .item .row { gap: 8px; flex: none; }
  .list { max-height: 55dvh; }
  .item { padding: 11px 12px; }
  .item .nm { max-width: 38vw; }
  .item .btn { min-height: 36px; }
  .order .code { font-size: 28px; letter-spacing: .14em; }
  .order .phone { font-size: 18px; }
  .order .actions .btn { flex: 1 1 auto; }
  .toast { width: calc(100vw - 24px); }
}

@media (hover: none) {            /* en pantallas táctiles no hay "hover" pegajoso */
  .btn:hover { filter: none; }
  .chip:hover .ico { transform: none; }
  .item:hover { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
