:root {
  --bg: #fff7fb;
  --card: #ffffff;
  --ink: #3a2740;
  --muted: #8b7a93;
  --line: #f1e3ee;
  --pink: #ec6fa5;
  --pink-dark: #d4538c;
  --lilac: #a78bfa;
  --mint: #34c9a0;
  --mint-bg: #e0f8f0;
  --amber: #f59e0b;
  --amber-bg: #fff3d6;
  --danger: #e5484d;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(180, 90, 150, .12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1522; --card: #2a1f31; --ink: #f6eaf8; --muted: #b3a0bb; --line: #3d2d46;
    --mint-bg: #153d33; --amber-bg: #4a3512; --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; font-family: 'Nunito', system-ui, sans-serif; background: var(--bg); color: var(--ink);
  min-height: 100vh; padding-bottom: env(safe-area-inset-bottom);
  background-image: radial-gradient(circle at 10% -10%, rgba(236,111,165,.18), transparent 40%),
                    radial-gradient(circle at 100% 0%, rgba(167,139,250,.18), transparent 35%);
  background-attachment: fixed;
}
button, input, select, textarea { font: inherit; color: inherit; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px 110px; }

header.top {
  position: sticky; top: 0; z-index: 10; backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  padding: calc(env(safe-area-inset-top) + 12px) 0 12px; padding-inline: 16px;
}
.bar { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 800; font-size: 1.25rem; display: flex; align-items: center; gap: 8px; flex: 1; }
.brand span.logo {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem;
  background: linear-gradient(135deg, var(--pink), var(--lilac)); box-shadow: var(--shadow);
}
.brand em { font-style: normal; background: linear-gradient(90deg, var(--pink), var(--lilac)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.icon-btn {
  border: 0; background: var(--card); width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
  box-shadow: var(--shadow); font-size: 1.1rem; display: grid; place-items: center;
}

.search {
  width: 100%; border: 2px solid transparent; background: var(--card); border-radius: 14px;
  padding: 13px 16px; box-shadow: var(--shadow); outline: none; margin: 6px 0 14px;
}
.search:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--pink); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 16px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.1rem; }
.stat small { color: var(--muted); font-weight: 600; font-size: .75rem; }

.list { display: grid; gap: 10px; }
.client {
  display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); cursor: pointer; border: 0; width: 100%; text-align: left;
  transition: transform .12s;
}
.client:active { transform: scale(.98); }
.avatar {
  width: 48px; height: 48px; border-radius: 16px; flex: none; display: grid; place-items: center; color: #fff;
  font-weight: 800; background: linear-gradient(135deg, var(--pink), var(--lilac));
}
.client .info { flex: 1; min-width: 0; }
.client .name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client .sub { color: var(--muted); font-size: .85rem; font-weight: 600; }
.pill { font-size: .75rem; font-weight: 800; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill.pendiente { background: var(--amber-bg); color: var(--amber); }
.pill.entrega { background: #e8e1ff; color: #7c5ce0; }
@media (prefers-color-scheme: dark) { .pill.entrega { background: #342a58; color: #c3b0ff; } }
.pill.entregado { background: var(--mint-bg); color: var(--mint); }
.pill.none { background: var(--line); color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; font-weight: 600; }
.empty .big { font-size: 3rem; display: block; }

.fab {
  position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 18px); border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--pink), var(--lilac)); color: #fff; font-weight: 800;
  padding: 15px 22px; border-radius: 999px; box-shadow: 0 10px 28px rgba(236,111,165,.5); font-size: 1rem;
}

.hero { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.hero h1 { margin: 0 0 4px; font-size: 1.4rem; }
.hero .row { color: var(--muted); font-weight: 600; font-size: .92rem; margin-top: 4px; }
.hero a { color: var(--pink-dark); text-decoration: none; }
.hero { display: flex; gap: 14px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.hero .actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
@media (max-width: 560px) { .hero .actions { margin-left: 0; justify-content: flex-start; } }

.btn {
  border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 800; cursor: pointer;
  background: var(--line); color: var(--ink);
}
.btn.primary { background: linear-gradient(135deg, var(--pink), var(--lilac)); color: #fff; }
.btn.danger { background: #fde8e9; color: var(--danger); }
@media (prefers-color-scheme: dark) { .btn.danger { background: #4a1f23; } }

h2.section { font-size: 1.05rem; margin: 20px 0 10px; display: flex; justify-content: center; align-items: center; text-align: center; }
.plush { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; }
.plush .emoji { font-size: 1.8rem; }
.plush .info { flex: 1; min-width: 0; }
.plush .name { font-weight: 800; }
.plush .sub { color: var(--muted); font-size: .85rem; font-weight: 600; }
.plush .side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.plush { flex-wrap: wrap; }
.plush .price { font-weight: 800; }
.plush .mini { display: flex; gap: 6px; }
.mini button { border: 0; background: var(--line); border-radius: 10px; width: 34px; height: 34px; cursor: pointer; }
button.pill { border: 0; cursor: pointer; }

dialog {
  border: 0; border-radius: 24px; padding: 22px; width: min(440px, calc(100vw - 24px)); background: var(--card); color: var(--ink);
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(40, 20, 50, .45); backdrop-filter: blur(3px); }
dialog h3 { margin: 0 0 14px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: .8rem; font-weight: 800; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  font: inherit; resize: vertical; width: 100%; border: 2px solid var(--line); background: var(--bg); border-radius: 12px; padding: 12px 14px; outline: none;
}
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.err { color: var(--danger); font-weight: 700; font-size: .85rem; min-height: 1.2em; }

.login { max-width: 360px; margin: 14vh auto 0; padding: 0 16px; text-align: center; }
.login .logo-big { font-size: 4rem; }
.login h1 { margin: 6px 0 20px; }
.login .field { text-align: left; }

#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-weight: 700; opacity: 0; pointer-events: none; transition: .25s; z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  .stat b { font-size: 1.3rem; }
  .list { grid-template-columns: 1fr 1fr; }
}

/* Ositos cayendo de fondo */
#bears { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
#bears span {
  position: absolute; top: -12vh; opacity: .16; will-change: transform;
  animation: caer linear infinite;
}
@keyframes caer {
  0%   { transform: translate3d(0, 0, 0) rotate(-12deg); }
  50%  { transform: translate3d(24px, 56vh, 0) rotate(14deg); }
  100% { transform: translate3d(-8px, 120vh, 0) rotate(-10deg); }
}
@media (prefers-color-scheme: dark) { #bears span { opacity: .1; } }
@media (prefers-reduced-motion: reduce) { #bears { display: none; } }

[hidden] { display: none !important; }

.chips { display: flex; gap: 8px; margin: 8px 0 4px; }
.chip { border: 0; cursor: pointer; background: var(--card); box-shadow: var(--shadow); padding: 9px 16px; border-radius: 999px; font-weight: 800; color: var(--muted); }
.chip.on { background: linear-gradient(135deg, var(--pink), var(--lilac)); color: #fff; }
h2.grupo { justify-content: flex-start; gap: 10px; margin-top: 22px; }
h2.grupo .count { background: var(--line); color: var(--muted); border-radius: 999px; padding: 2px 10px; font-size: .8rem; }
.client.envio .side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.client.envio .sub { white-space: normal; }
@media (max-width: 520px) { .client.envio { flex-wrap: wrap; } .client.envio .side { flex-direction: row; flex-wrap: wrap; width: 100%; justify-content: flex-start; } }

.hint { color: var(--muted); font-weight: 600; margin: 6px 0 0; }
.envcard { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: grid; gap: 4px; }
.envcard .envhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.envcard .name { font-weight: 800; font-size: 1.05rem; }
.envcard .sub, .selclient .sub { color: var(--muted); font-size: .88rem; font-weight: 600; }
.envcard a { color: var(--pink-dark); text-decoration: none; }
.envps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag { background: var(--line); border-radius: 999px; padding: 5px 12px; font-size: .82rem; font-weight: 700; }
.selclient { background: var(--card); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); margin-bottom: 10px; }
.selhead { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: none; border: 0; padding: 6px 0; cursor: pointer; text-align: left; font-size: 1rem; }
.selhead .selmeta { display: flex; align-items: center; gap: 8px; flex: none; }
.selhead .chev { color: var(--muted); width: 1em; text-align: center; }
.selhead + .selrow { margin-top: 6px; }
.selrow { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-top: 1px solid var(--line); cursor: pointer; border-radius: 10px; flex-wrap: wrap; }
.selrow:first-of-type { border-top: 0; }
.selrow input { width: 22px; height: 22px; accent-color: var(--pink); flex: none; }
.selrow .info { flex: 1; min-width: 0; }
.selrow .name { font-weight: 800; }
.selrow.on { background: color-mix(in srgb, var(--pink) 12%, transparent); }
.selrow.off { opacity: .5; cursor: not-allowed; }
.selbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 18px calc(env(safe-area-inset-bottom) + 14px); background: var(--card); box-shadow: 0 -8px 24px rgba(180, 90, 150, .15);
}
fieldset.opt { border: 2px solid var(--line); border-radius: 14px; margin: 0 0 12px; padding: 8px 12px 12px; }
fieldset.opt legend { font-size: .8rem; font-weight: 800; color: var(--muted); padding: 0 6px; }
.radio { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; cursor: pointer; }
.radio input { margin-top: 3px; accent-color: var(--pink); }
input.otro { width: 100%; border: 2px solid var(--line); background: var(--bg); border-radius: 12px; padding: 11px 14px; outline: none; margin-top: 4px; }
input.otro:focus { border-color: var(--pink); }

.toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 16px; }
.toolbar .btn {
  text-decoration: none; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center;
  text-align: center; line-height: 1.2; padding: 14px 10px; gap: 6px; min-height: 56px;
}

@media (min-width: 700px) {
  .toolbar { grid-template-columns: repeat(4, 1fr); }
}
.toolbar .btn.ancho { grid-column: span 2; }
.toolbar .btn:not(.primary) { background: var(--card); }
.selclient.off { opacity: .55; }
.selclient.off .selrow.off { opacity: 1; }

.filtros { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.filtros .search { margin: 0; flex: 1 1 200px; width: auto; }
.filtros select.search { flex: 0 1 220px; min-width: 170px; }
.fechaf { position: relative; flex: 0 1 200px; min-width: 170px; display: block; }
.fechaf input { width: 100%; }
.fechaf .ph { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; display: none; right: 46px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.fechaf.vacio .ph { display: block; }
.fechaf.vacio input { color: transparent; } /* oculta el dd/mm/aaaa vacío del navegador */

/* Cabecera principal: marca centrada, acciones a la derecha */
.bar.centrado { display: grid; grid-template-columns: 1fr auto 1fr; }
.bar.centrado .brand { flex: none; justify-content: center; }
.bar.centrado .acts { display: flex; gap: 6px; justify-self: end; }
@media (max-width: 480px) {
  .bar.centrado .brand { font-size: 1.05rem; gap: 6px; }
  .bar.centrado .brand span.logo { width: 32px; height: 32px; font-size: 1.1rem; border-radius: 10px; }
}

/* Bodega */
.bodprog { background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin: 8px 0 4px; }
.bodnum { font-size: 1.05rem; margin-bottom: 8px; }
.bar-prog { height: 10px; border-radius: 99px; background: color-mix(in srgb, var(--pink) 15%, transparent); overflow: hidden; }
.bar-prog i { display: block; height: 100%; background: linear-gradient(135deg, var(--pink), var(--lilac)); transition: width .25s; }
.selrow.bod { padding: 14px 8px; }
.selrow.bod input { width: 26px; height: 26px; }
.selrow.bod .info { display: grid; gap: 2px; }
.selrow.bod .sub { color: var(--muted); font-size: .88rem; font-weight: 600; }
.selhead.static { cursor: default; padding-bottom: 8px; }

/* Botón de música del login */
.mus { position: fixed; top: 14px; right: 14px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow); font-size: 1.3rem; cursor: pointer; z-index: 5; }
