:root {
  --primary: #667eea;
  --secondary: #764ba2;
  --gradient: linear-gradient(135deg, var(--primary), var(--secondary));
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1a1a2e;
  --muted: #8b8fa3;
  --line: #eef0f7;
  --ok: #16a34a; --ok-soft: #e9f8ef;
  --warn: #d97706; --warn-soft: #fdf3e3;
  --err: #dc2626; --err-soft: #fdeaea;
  --violet-soft: #f1f3fd;
  --shadow: 0 1px 3px rgba(26, 26, 46, .05), 0 6px 20px rgba(26, 26, 46, .04);
  --radius: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.45;
}
.app { max-width: 480px; margin: 0 auto; padding: 0 0 120px; }
button { font: inherit; cursor: pointer; border: none; background: none; }
input, select { font: inherit; }

/* ── barra superior ── */
.top {
  position: sticky; top: 0; z-index: 30;
  background: rgba(246, 247, 251, .92);
  backdrop-filter: blur(10px);
  padding: 14px 16px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.top-title { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.top-title .dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--gradient); margin-right: 7px;
}
.top-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.top-actions { display: flex; gap: 6px; align-items: center; }
.alert-chip {
  min-height: 32px; padding: 5px 10px; border-radius: 999px;
  background: var(--warn-soft); color: var(--warn); font-size: 12px; font-weight: 900;
}
.pro-chip {
  background: var(--violet-soft); color: var(--secondary);
  border-radius: 999px; padding: 5px 11px; font-size: 10.5px; font-weight: 800;
  letter-spacing: .04em; white-space: nowrap;
}

.content { padding: 4px 16px 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 800; letter-spacing: -.01em; }
.date { font-size: 11px; color: var(--muted); }


/* ── botones ── */
.btn {
  border-radius: 12px; padding: 9px 14px; font-size: 13px; font-weight: 700;
  background: var(--card); color: var(--text); box-shadow: var(--shadow);
  min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
}
.btn.primary { background: var(--gradient); color: #fff; box-shadow: 0 6px 18px rgba(102, 126, 234, .35); }
.btn.ok { background: var(--ok-soft); color: var(--ok); box-shadow: none; }
.btn.danger { background: var(--err-soft); color: var(--err); box-shadow: none; }
.btn.warn { background: var(--warn-soft); color: var(--warn); box-shadow: none; }
.btn.small { min-height: 34px; padding: 6px 11px; font-size: 12px; border-radius: 10px; }
.btn:disabled { opacity: .5; }

/* ── estadísticas ── */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat.wide {
  grid-column: 1 / -1; background: var(--gradient); color: #fff;
  box-shadow: 0 8px 22px rgba(102, 126, 234, .35);
}
.stat.wide small { color: rgba(255, 255, 255, .85); }
.stat small { font-size: 11px; color: var(--muted); display: block; margin-bottom: 3px; font-weight: 600; }
.stat b { font-size: 17px; }
.stat .delta { font-size: 11px; font-weight: 700; }
.delta.up { color: var(--ok); }
.stat.wide .delta.up { color: #d9f2e3; }

/* ── tarjetas y filas ── */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 10px; }
.request-alert-card {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  color: var(--text); border: 1px solid #f6d7a8; background: var(--warn-soft);
}
.focus-card {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  color: var(--text); border: 1px solid transparent; cursor: pointer;
}
.focus-card.points { background: linear-gradient(135deg, #f5f1ff, #edf0ff); border-color: #d9d2fa; }
.focus-card.credit { background: linear-gradient(135deg, #eefbf5, #f3fbef); border-color: #ccebdc; }
.focus-card .focus-icon { font-size: 25px; }
.focus-card .name, .focus-card .sub { display: block; }
.focus-card .amt { color: var(--primary); }
.gift-card { border: 1px solid #d9d2fa; background: linear-gradient(145deg, #fff, #f7f4ff); }
.gift-client-list {
  max-height: 310px; overflow-y: auto; margin-top: 7px; padding: 4px;
  border: 1px solid var(--line); border-radius: 13px; background: var(--card);
}
.gift-client-option {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 9px;
  color: var(--text); text-align: left; background: transparent; border-radius: 10px;
  border-bottom: 1px solid var(--line);
}
.gift-client-option:last-of-type { border-bottom: none; }
.gift-client-option:hover { background: var(--violet-soft); }
.gift-client-option.on { background: var(--gradient); color: #fff; }
.gift-client-option.on .sub { color: rgba(255, 255, 255, .82); }
.gift-client-option.on .badge { background: rgba(255, 255, 255, .2); color: #fff; }
.gift-client-index {
  width: 25px; height: 25px; display: grid; place-items: center; flex: 0 0 25px;
  border-radius: 50%; color: var(--muted); background: var(--violet-soft); font-size: 10px; font-weight: 800;
}
.gift-client-option.on .gift-client-index { color: var(--primary); background: #fff; }
.gift-client-option .name, .gift-client-option .sub { display: block; }
.gift-client-empty { padding: 18px 10px; color: var(--muted); text-align: center; font-size: 12px; }
.sec-title {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 16px 0 8px; padding: 0 2px;
}
.row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.name { font-weight: 700; font-size: 13.5px; }
.sub { font-size: 11px; color: var(--muted); }
.amt { font-weight: 800; font-size: 13.5px; white-space: nowrap; }

/* ── badges ── */
.badge { border-radius: 999px; padding: 4px 10px; font-size: 10.5px; font-weight: 800; white-space: nowrap; display: inline-block; }
.badge.pendiente { background: var(--warn-soft); color: var(--warn); }
.badge.pagado { background: var(--ok-soft); color: var(--ok); }
.badge.entregado { background: var(--ok-soft); color: var(--ok); }
.badge.fiado { background: var(--violet-soft); color: var(--secondary); }
.badge.bajo { background: var(--warn-soft); color: var(--warn); }
.badge.agotado { background: var(--err-soft); color: var(--err); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }

/* ── herramientas ── */
.tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tools input[type=text] {
  flex: 1; min-width: 150px; border: none; border-radius: 14px; padding: 12px 14px;
  background: var(--card); color: var(--text); box-shadow: var(--shadow);
}

/* ── formularios ── */
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; font-weight: 700; }
.field input, .field select {
  width: 100%; border: none; border-radius: 12px; padding: 11px 12px;
  background: var(--violet-soft); color: var(--text);
}
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }

.catalog-sale-fields {
  width: min(100%, 320px); display: grid; gap: 7px; padding: 10px;
  border-radius: 12px; background: var(--violet-soft);
}
.catalog-sale-fields label { font-size: 10.5px; font-weight: 700; color: var(--muted); text-align: left; }
.catalog-sale-fields input, .catalog-sale-fields select {
  display: block; width: 100%; margin-top: 3px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text);
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border-radius: 999px; padding: 8px 13px; font-size: 12.5px; font-weight: 700;
  background: var(--card); color: var(--text); box-shadow: var(--shadow);
}
.chip.on { background: var(--gradient); color: #fff; box-shadow: 0 6px 16px rgba(102, 126, 234, .35); }

.order-item-row { display: grid; grid-template-columns: 1.2fr 1.4fr 70px 36px; gap: 6px; align-items: start; margin-bottom: 8px; }
.order-item-row select, .order-item-row input {
  width: 100%; border: none; border-radius: 10px; padding: 8px 9px;
  background: var(--violet-soft); color: var(--text); font-size: 13px;
}
.order-product-chips, .order-variant-chips { display: flex; gap: 5px; flex-wrap: wrap; min-width: 0; }
.order-product-chips .chip, .order-variant-chips .chip { padding: 6px 9px; font-size: 11.5px; box-shadow: none; border: 1px solid var(--line); }
.order-product-chips .chip small, .order-variant-chips .chip small { display: block; margin-top: 2px; font-size: 9px; opacity: .8; }
@media (max-width: 420px) {
  .order-item-row { grid-template-columns: 1fr 70px 36px; align-items: start; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .order-product-chips { grid-column: 1 / -1; }
  .order-variant-chips { grid-column: 1; }
}

.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--gradient); }

.cfgrow { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 6px; align-items: center; margin-bottom: 6px; }
.cfgrow input { width: 100%; border: none; border-radius: 10px; padding: 8px 9px; background: var(--violet-soft, #f1f3fd); color: var(--text); font-size: 13px; }
.cfgrow .vlabel { font-weight: 800; font-size: 13px; }

/* ── estados vacíos ── */
.empty { text-align: center; padding: 30px 14px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* ── navegación inferior ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 40;
  background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; align-items: center;
  padding: 8px 6px calc(10px + env(safe-area-inset-bottom, 0px));
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 9.5px; font-weight: 700; color: var(--muted);
  padding: 6px 0; border-radius: 12px;
}
.nav-btn .ic { position: relative; font-size: 20px; }
.nav-alert {
  position: absolute; top: -6px; right: -10px; min-width: 17px; height: 17px;
  padding: 0 4px; border-radius: 999px; background: var(--err); color: #fff;
  font-size: 9px; line-height: 17px; font-style: normal; font-weight: 900;
}
.nav-btn.on { color: var(--primary); background: var(--violet-soft); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; background: var(--card);
  box-shadow: var(--shadow); font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
}

/* ── login de usuario ── */
.splash {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 60vh; color: var(--muted); font-weight: 600; gap: 10px; font-size: 14px;
}
.login { display: flex; align-items: center; justify-content: center; min-height: 82vh; padding: 20px 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--card); border-radius: 22px; padding: 28px 22px; box-shadow: var(--shadow); }
.login-logo { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 7px; }
.login-logo .dot { width: 11px; height: 11px; }
.login-sub { font-size: 12.5px; color: var(--muted); margin: 6px 0 16px; }
.login-card input {
  width: 100%; border: none; border-radius: 12px; padding: 12px 13px;
  background: var(--violet-soft, #f1f3fd); color: var(--text); margin-bottom: 9px;
}
.login-btn { width: 100%; margin-bottom: 8px; }
.login-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; margin: 6px 0 10px; }
.login-or::before, .login-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.login-err {
  background: var(--err-soft); color: var(--err); border-radius: 11px;
  padding: 10px 12px; font-size: 12.5px; font-weight: 600; margin-bottom: 10px;
  line-height: 1.35;
}
/* ── toast, caja cerrada, pie ── */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(94px + env(safe-area-inset-bottom, 0px));
  z-index: 50; background: #1a1a2e; color: #fff; border-radius: 999px;
  padding: 11px 18px; font-size: 13px; font-weight: 600; max-width: 90%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.toast.err { background: var(--err); }
.caja-closed { text-align: center; padding: 14px; color: var(--ok); font-weight: 800; font-size: 13px; }
.foot { margin-top: 16px; text-align: center; font-size: 11px; color: var(--muted); padding-bottom: 8px; }
