:root {
  --bg: #f3f4f1;
  --card: #ffffff;
  --text: #1b2320;
  --muted: #69736e;
  --line: #e4e7e2;
  --input: #cdd4ce;
  --marca: #F40A6A;   /* rosa charlotte shop (logo, encabezado, botón +) */
  --pri: #D4085B;     /* rosa un poco más oscuro para botones y textos: mejor contraste */
  --pri-2: #B50750;
  --pri-soft: #FDE7F0;
  --verde: #15803d;
  --verde-bg: #dcfce7;
  --amarillo: #92400e;
  --amarillo-bg: #fef3c7;
  --rojo: #b91c1c;
  --rojo-bg: #fee2e2;
  --gris-bg: #eceeea;
  --wa: #1c9e4f;
  --radius: 14px;
  --nav-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(var(--nav-h) + 90px + env(safe-area-inset-bottom));
}
body.bare { padding-bottom: 0; }
a { color: var(--pri); }

/* ---------- Encabezado ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 6px;
  min-height: 56px;
  padding: calc(6px + env(safe-area-inset-top)) 12px 6px 16px;
  background: var(--marca); color: #fff;
}
.top h1 { flex: 1; margin: 0; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .back { color: #fff; text-decoration: none; font-size: 34px; line-height: 1; padding: 0 10px 4px 0; }
.top .top-btn {
  color: #fff; text-decoration: none; font-weight: 600; font-size: 15px;
  padding: 8px 12px; border-radius: 10px; background: rgba(255,255,255,.16);
}

.top-logo { display: flex; align-items: center; }
.top-logo img { height: 34px; width: auto; }

main { max-width: 640px; margin: 0 auto; padding: 14px 16px; }

h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin: 22px 4px 8px;
}
h2:first-child { margin-top: 4px; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card > :last-child { margin-bottom: 0; }

/* ---------- Tarjetas de números ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat {
  display: block; background: var(--card); border-radius: var(--radius); padding: 13px 14px;
  color: inherit; text-decoration: none; min-width: 0;
}
.stat .lbl { font-size: 13px; color: var(--muted); }
.stat .val { font-size: 21px; font-weight: 700; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.rojo .val { color: var(--rojo); }
.stat.verde .val { color: var(--verde); }
.stat.pri .val { color: var(--pri); }
.stat.full { grid-column: 1 / -1; }

/* ---------- Listas ---------- */
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item[hidden] { display: none; }
a.item { color: inherit; text-decoration: none; }
.item-main { flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.item-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.item-side { text-align: right; flex-shrink: 0; }
.item.anulado .item-title, .item.anulado .amount { text-decoration: line-through; color: var(--muted); }
.amount { font-weight: 700; white-space: nowrap; }
.thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; background: var(--gris-bg); flex-shrink: 0; }
.group-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 14px; background: var(--pri-soft); font-weight: 700; font-size: 14px;
}
.empty { padding: 26px 16px; text-align: center; color: var(--muted); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); }
.kv:first-child { border-top: 0; }
.kv span:first-child { color: var(--muted); }
.kv strong { text-align: right; }
.kv.total { font-size: 18px; }

.badge {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px;
  border-radius: 99px; margin-top: 3px; white-space: nowrap;
}
.badge.verde { background: var(--verde-bg); color: var(--verde); }
.badge.amarillo { background: var(--amarillo-bg); color: var(--amarillo); }
.badge.rojo { background: var(--rojo-bg); color: var(--rojo); }
.badge.gris { background: var(--gris-bg); color: var(--muted); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; }
.btn-pri { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-danger { color: var(--rojo); border-color: #f1c5c5; background: #fff; }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-lg { min-height: 56px; font-size: 18px; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px; border: 0; flex-shrink: 0;
  background: var(--gris-bg); color: var(--text); text-decoration: none;
}
.btn-icon.wa { background: var(--wa); color: #fff; }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.row > .btn, .row > form { flex: 1 1 0; }
.row > form > .btn { width: 100%; }
.stack > * + * { margin-top: 8px; }

/* ---------- Formularios ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field small, .hint { display: block; font-size: 13px; color: var(--muted); margin-top: 5px; }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1px solid var(--input); border-radius: 10px;
  font: inherit; font-size: 16px; background: #fff; color: inherit;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--pri); outline-offset: -1px; border-color: var(--pri); }
input.big { font-size: 26px; font-weight: 700; text-align: center; min-height: 60px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 8px; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-weight: 600; }
.check input { width: 24px; height: 24px; min-height: 0; accent-color: var(--pri); }
.search { margin-bottom: 12px; }
details.card summary { font-weight: 600; cursor: pointer; }
details.card[open] summary { margin-bottom: 12px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.seg label {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 48px; padding: 4px; border: 1px solid var(--input); border-radius: 10px;
  font-weight: 600; background: #fff; cursor: pointer; font-size: 15px;
}
.seg input:checked + label { background: var(--pri); border-color: var(--pri); color: #fff; }

.chips { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.chip {
  flex-shrink: 0; padding: 8px 14px; border-radius: 99px; background: var(--card);
  color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px; border: 1px solid var(--line);
}
.chip.on { background: var(--pri); border-color: var(--pri); color: #fff; }

.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-weight: 600; }
.flash.ok { background: var(--verde-bg); color: var(--verde); }
.flash.error { background: var(--rojo-bg); color: var(--rojo); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.rojo-txt { color: var(--rojo); }
.verde-txt { color: var(--verde); }

.foto-prev { display: block; width: 120px; height: 120px; object-fit: cover; border-radius: 12px; margin-bottom: 8px; }
.foto-prev[hidden] { display: none; }

/* ---------- Etiquetas ---------- */
.tags { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 12px; background: var(--pri-soft); color: var(--pri); padding: 1px 8px; border-radius: 99px; white-space: nowrap; }
.chip-tag { font-weight: 500; }
.rank {
  width: 28px; height: 28px; border-radius: 50%; background: var(--pri-soft); color: var(--pri);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}

/* ---------- Perfil e historial ---------- */
.perfil-head { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; background: var(--pri); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; flex-shrink: 0;
}
.badge-lg { font-size: 14px; padding: 4px 12px; }
.nota-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px; }
.nota-form textarea { min-height: 48px; flex: 1; }
.nota-form .btn { flex-shrink: 0; }
.timeline .ev { display: flex; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); align-items: flex-start; }
.timeline .ev:first-child { border-top: 0; }
.ev-ico {
  width: 34px; height: 34px; border-radius: 50%; background: var(--gris-bg); color: var(--muted);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ev-ico .ico { width: 18px; height: 18px; }
.ev-body { flex: 1; min-width: 0; }
.ev-titulo { font-weight: 600; }
.ev-titulo a { color: inherit; }
.ev-detalle { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ev-fecha { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ev.es-nota { background: #fffbeb; }
.ev.es-nota .ev-ico { background: var(--amarillo-bg); color: var(--amarillo); }
.ev.anulado .ev-titulo { text-decoration: line-through; color: var(--muted); }
.btn-sm-icon { width: 34px; height: 34px; background: transparent; color: var(--muted); cursor: pointer; }

/* ---------- Buscador de productos ---------- */
.picker { margin-bottom: 14px; }
.picker-results { background: #fff; border-radius: 12px; margin-top: 6px; overflow: hidden; box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.picker-results:empty { display: none; }
.picker-opt {
  display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 8px;
  padding: 13px 14px; border: 0; border-top: 1px solid var(--line); background: #fff;
  font: inherit; text-align: left; cursor: pointer;
}
.picker-opt:first-child { border-top: 0; }
.picker-opt small { color: var(--muted); white-space: nowrap; }
.picker-opt:disabled { opacity: .5; }
.picker-lines { margin-top: 10px; }
.line { background: #fff; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.line-name { font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.line-name small { color: var(--muted); font-weight: 400; white-space: nowrap; }
.line-ctrl { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.stepper { display: flex; align-items: center; border: 1px solid var(--input); border-radius: 10px; overflow: hidden; }
.stepper button { width: 42px; height: 44px; border: 0; background: var(--gris-bg); font-size: 22px; cursor: pointer; }
.stepper input { width: 52px; min-height: 44px; border: 0; border-radius: 0; text-align: center; padding: 0; }
.line-price { display: flex; align-items: center; gap: 4px; flex: 1; font-weight: 600; }
.line-price input { min-height: 44px; }
.line-del { border: 0; background: transparent; color: var(--rojo); font-size: 20px; width: 40px; height: 44px; cursor: pointer; margin-left: auto; }
.picker-total { display: flex; justify-content: space-between; align-items: center; padding: 6px 4px; font-size: 18px; }

/* ---------- Navegación inferior y botón + ---------- */
nav.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.bottom a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: var(--nav-h); color: var(--muted); text-decoration: none; font-size: 12px;
}
nav.bottom a.on { color: var(--pri); font-weight: 700; }
nav.bottom svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); z-index: 21;
  width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--marca); color: #fff; font-size: 34px; line-height: 1;
  box-shadow: 0 6px 18px rgba(244,10,106,.45); cursor: pointer;
}
.sheet { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; }
.sheet[hidden] { display: none; }
.sheet-panel {
  width: 100%; max-width: 640px; margin: 0 auto; background: #fff;
  border-radius: 20px 20px 0 0; padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
}
.sheet-panel a {
  display: flex; align-items: center; gap: 14px; padding: 16px 6px;
  font-size: 17px; font-weight: 600; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line);
}
.sheet-panel a .ico { color: var(--pri); width: 26px; height: 26px; }
.sheet-panel .btn { margin-top: 12px; }

/* ---------- Login ---------- */
.login { max-width: 380px; margin: 0 auto; padding: 48px 20px; }
.login-logo { display: block; width: 260px; max-width: 80%; height: auto; margin: 0 auto 10px; }
.login h1 { text-align: center; margin: 0 0 4px; }
.login p.muted { text-align: center; margin: 0 0 24px; }

@media (min-width: 700px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .stats.dos { grid-template-columns: 1fr 1fr; }
}
