:root {
  --bg: #f2f5f7;
  --card: #ffffff;
  --text: #1d2939;
  --muted: #5b6b7f;
  --line: #dde3ea;
  --primary: #0f766e;
  --primary-d: #0b5c56;
  --primary-l: #e3f3f1;
  --ok: #15803d;
  --ok-l: #e6f5ea;
  --warn: #b45309;
  --warn-l: #fdf2df;
  --danger: #c42727;
  --danger-l: #fdeaea;
  --control: #1d4ed8;
  --control-l: #e7eefc;
  --completo: #7c3aed;
  --completo-l: #f1eafd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html { font-size: 17px; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 .8rem; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .9rem; margin: .5rem 0 1rem; }
.center { text-align: center; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 48px; padding: .55rem 1.15rem;
  border-radius: 12px; border: 1px solid var(--line);
  background: #fff; font-weight: 600; text-decoration: none; color: var(--text);
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { border-color: #b4c0cc; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #116a32; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { min-height: 38px; padding: .3rem .8rem; font-size: .9rem; border-radius: 10px; }
.btn-xl { min-height: 64px; font-size: 1.3rem; width: 100%; }
.btn-link { background: none; border: none; color: var(--muted); text-decoration: underline; min-height: 40px; width: 100%; }

/* ---------- Formularios ---------- */
.lbl { display: block; font-weight: 600; margin: .9rem 0 .35rem; }
.input, input[type=text], input[type=number], input[type=password], input[type=date], select {
  width: 100%; min-height: 50px; padding: .5rem .8rem;
  border: 1px solid #c9d2dc; border-radius: 10px; background: #fff;
}
input:focus, select:focus { outline: 3px solid rgba(15, 118, 110, .25); border-color: var(--primary); }
.money { display: flex; align-items: center; border: 1px solid #c9d2dc; border-radius: 10px; background: #fff; }
.money span { padding: 0 .2rem 0 .8rem; font-weight: 700; color: var(--muted); }
.money input { border: none; font-size: 1.4rem; font-weight: 700; }
.money:focus-within { outline: 3px solid rgba(15, 118, 110, .25); border-color: var(--primary); }
.money input:focus { outline: none; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }

/* ---------- Tarjetas y tablas ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.3rem; margin-bottom: 1.2rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.page-head h1 { font-size: 1.7rem; margin: 0; }
.page-head p { margin: .25rem 0 0; color: var(--muted); }
.table-wrap { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; }
.tabla th { text-align: left; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: .55rem .7rem; border-bottom: 2px solid var(--line); white-space: nowrap; }
.tabla td { padding: .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tabla tr:last-child td { border-bottom: none; }
.tabla .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tabla .acciones { display: flex; gap: .4rem; justify-content: flex-end; flex-wrap: wrap; }
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--ok-l); color: var(--ok); }
.badge.warn { background: var(--warn-l); color: var(--warn); }
.badge.danger { background: var(--danger-l); color: var(--danger); }
.badge.muted { background: #eef1f4; color: var(--muted); }
.note { padding: .7rem .9rem; border-radius: 10px; margin: .8rem 0; font-weight: 600; }
.note.warn { background: var(--warn-l); color: var(--warn); }
.note.info { background: var(--primary-l); color: var(--primary-d); }
.note.danger { background: var(--danger-l); color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 2.2rem 1rem; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.kpi { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.2rem; }
.kpi span { color: var(--muted); font-size: .9rem; display: block; }
.kpi strong { font-size: 1.7rem; display: block; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.kpi.verde strong { color: var(--ok); }
.kpi.rojo strong { color: var(--danger); }

/* ---------- Estructura de la app ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: auto auto 1fr; min-height: 100vh; }
.topbar {
  grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .7rem 1.3rem; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.15rem; }
.logo { width: 38px; height: 38px; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 1.3rem; }
.pill { padding: .2rem .7rem; border-radius: 999px; font-size: .82rem; font-weight: 700; }
.pill.basico { background: var(--primary-l); color: var(--primary-d); }
.pill.control { background: var(--control-l); color: var(--control); }
.pill.completo { background: var(--completo-l); color: var(--completo); }
.top-right { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.caja-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .8rem; border-radius: 999px; font-weight: 600; font-size: .9rem; }
.caja-pill.abierta { background: var(--ok-l); color: var(--ok); }
.caja-pill.cerrada { background: var(--danger-l); color: var(--danger); }
.user-chip { display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--completo-l); color: var(--completo); display: grid; place-items: center; font-weight: 800; }
.banner { grid-column: 1 / -1; background: #fff8e6; color: #7a4b00; text-align: center; padding: .4rem 1rem; font-size: .88rem; font-weight: 600; border-bottom: 1px solid #f3e2b8; }

.side { background: #fff; border-right: 1px solid var(--line); padding: 1rem .7rem; display: flex; flex-direction: column; gap: .25rem; }
.nav-item {
  display: flex; align-items: center; gap: .65rem; width: 100%; text-align: left;
  min-height: 50px; padding: .5rem .8rem; border-radius: 10px; border: none; background: none; font-weight: 600;
}
.nav-item:hover { background: #f1f4f7; }
.nav-item.active { background: var(--primary-l); color: var(--primary-d); }
.nav-item .ico { font-size: 1.2rem; width: 1.6rem; text-align: center; }
.nav-item .count { margin-left: auto; background: var(--danger); color: #fff; border-radius: 999px; font-size: .78rem; padding: .05rem .5rem; }
.nav-item.locked { color: #98a2b3; }
.nav-item .tag { margin-left: auto; font-size: .7rem; padding: .1rem .45rem; border-radius: 6px; background: #eef1f4; color: var(--muted); }
.nav-sep { height: 1px; background: var(--line); margin: .5rem .4rem; }
.main { padding: 1.5rem; min-width: 0; }

/* ---------- Pantalla de venta ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 1.3rem; align-items: start; }
.search-box { display: flex; align-items: center; gap: .6rem; background: #fff; border: 2px solid var(--primary); border-radius: 14px; padding: 0 1rem; box-shadow: var(--shadow); }
.search-box input { border: none; min-height: 64px; font-size: 1.25rem; padding: 0; }
.search-box input:focus { outline: none; }
.grid-prod { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem; }
.prod {
  display: flex; flex-direction: column; gap: .3rem; text-align: left; padding: 1rem;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-height: 120px;
}
.prod:hover { border-color: var(--primary); }
.prod strong { font-size: 1.02rem; }
.prod .precios { font-size: .88rem; color: var(--primary-d); font-weight: 600; }
.prod .badge { align-self: flex-start; margin-top: auto; }
.pos-cart { position: sticky; top: 1rem; }
.seg-group { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;background: #eef1f4; border-radius: 12px; padding: 4px; margin-bottom: 1rem; }
.seg { border: none; background: none; min-height: 48px; border-radius: 9px; font-weight: 700; color: var(--muted); }
.seg.on { background: #fff; color: var(--primary-d); box-shadow: var(--shadow); }
.cart { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; }
.cart li { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "n x" "s t"; gap: .3rem .6rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.cart-name { grid-area: n; display: flex; flex-direction: column; }
.cart-name span { font-size: .88rem; }
.cart .x { grid-area: x; border: none; background: none; font-size: 1.5rem; color: #98a2b3; width: 36px; height: 36px; border-radius: 8px; }
.cart .x:hover { background: var(--danger-l); color: var(--danger); }
.stepper { grid-area: s; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; justify-self: start; }
.stepper button { width: 44px; height: 42px; border: none; background: #f5f7f9; font-size: 1.3rem; font-weight: 700; }
.stepper span { min-width: 42px; text-align: center; font-weight: 700; }
.cart-sub { grid-area: t; align-self: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.total { display: flex; justify-content: space-between; align-items: baseline; margin: 1rem 0; }
.total span { font-size: 1.2rem; font-weight: 600; }
.total strong { font-size: 2.3rem; font-variant-numeric: tabular-nums; }

.pres-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; margin-top: 1rem; }
.pres { display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: 1.1rem .6rem; border: 2px solid var(--line); border-radius: 14px; background: #fff; }
.pres:hover { border-color: var(--primary); background: var(--primary-l); }
.pres-tipo { font-size: 1.3rem; font-weight: 800; }
.pres-precio { font-size: 1.15rem; font-weight: 700; color: var(--primary-d); }
.pres span.muted { font-size: .85rem; }

.metodos { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.metodo { min-height: 72px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; }
.metodo .ico { font-size: 1.4rem; }
.metodo.on { border-color: var(--primary); background: var(--primary-l); color: var(--primary-d); }
.rapidos { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
.vuelto { margin-top: 1rem; padding: 1rem; border-radius: 12px; text-align: center; font-size: 1.1rem; font-weight: 700; background: #eef1f4; }
.vuelto strong { display: block; font-size: 2.2rem; }
.vuelto.ok { background: var(--ok-l); color: var(--ok); }
.vuelto.falta { background: var(--danger-l); color: var(--danger); }
.cliente-ok { margin-top: .6rem; padding: .7rem .9rem; border-radius: 10px; background: var(--ok-l); color: var(--ok); font-weight: 600; }
.cobro-total { display: flex; justify-content: space-between; align-items: baseline; padding: .8rem 1rem; background: #f5f7f9; border-radius: 12px; margin-bottom: .5rem; }
.cobro-total strong { font-size: 1.9rem; }

.opciones { display: grid; gap: .7rem; }
.opcion { text-align: left; padding: 1rem 1.1rem; border: 2px solid var(--line); border-radius: 12px; background: #fff; display: flex; flex-direction: column; gap: .2rem; }
.opcion:hover { border-color: var(--primary); background: var(--primary-l); }
.opcion strong { font-size: 1.08rem; }

/* ---------- Ticket ---------- */
.ticket {
  width: 300px; margin: 0 auto; background: #fff; padding: 1rem 1.1rem; border: 1px dashed #c9d2dc;
  font-family: "Consolas", "Courier New", monospace; font-size: 13px; line-height: 1.35; color: #000; position: relative;
}
.ticket .c { text-align: center; }
.ticket hr { border: none; border-top: 1px dashed #000; margin: .5rem 0; }
.ticket .l { display: flex; justify-content: space-between; gap: .5rem; }
.ticket .b { font-weight: 700; }
.ticket .grande { font-size: 15px; }
.ticket .sello { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg); border: 3px solid var(--danger); color: var(--danger); font-size: 26px; font-weight: 800; padding: .2rem .8rem; opacity: .85; }
.qr { display: grid; grid-template-columns: repeat(21, 4px); width: 84px; margin: .6rem auto; }
.qr i { width: 4px; height: 4px; }
.qr i.on { background: #000; }

/* ---------- Modal y avisos ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: grid; place-items: center; padding: 1rem; z-index: 50; overflow-y: auto; }
.modal-bg[hidden] { display: none; }
.modal { background: #fff; border-radius: 18px; padding: 1.6rem; width: 100%; max-width: 580px; position: relative; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); max-height: calc(100vh - 2rem); overflow-y: auto; }
.modal.wide { max-width: 880px; }
.modal-x { position: absolute; top: .7rem; right: .7rem; width: 42px; height: 42px; border-radius: 10px; border: none; background: #f1f4f7; font-size: 1.5rem; }
.modal-actions { display: flex; gap: .7rem; margin-top: 1.3rem; flex-wrap: wrap; }
.modal-actions .btn { flex: 1; }
#toasts { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; z-index: 60; width: min(560px, calc(100vw - 2rem)); }
.toast { background: #1d2939; color: #fff; padding: .85rem 1.1rem; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); animation: entra .2s ease-out; transition: opacity .3s, transform .3s; }
.toast.ok { background: var(--ok); }
.toast.error { background: var(--danger); }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes entra { from { opacity: 0; transform: translateY(8px); } }

.users { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; margin: 1rem 0; }
.user-card { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: 1.1rem .5rem; border: 2px solid var(--line); border-radius: 14px; background: #fff; }
.user-card.on, .user-card:hover { border-color: var(--completo); background: var(--completo-l); }
.user-card .avatar { width: 54px; height: 54px; font-size: 1.4rem; }

/* ---------- Gráficos ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 220px; padding-top: 1.4rem; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar div { width: 100%; max-width: 46px; background: #9fd3cd; border-radius: 6px 6px 0 0; position: relative; }
.bar.hoy div { background: var(--primary); }
.bar span { font-size: .75rem; color: var(--muted); margin-top: .3rem; }
.bar div:hover::after { content: attr(data-v); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: #1d2939; color: #fff; padding: .15rem .45rem; border-radius: 6px; font-size: .75rem; white-space: nowrap; margin-bottom: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.provs { display: flex; gap: .35rem; flex-wrap: wrap; }
.prov { font-size: .82rem; padding: .15rem .5rem; border-radius: 8px; background: #eef1f4; white-space: nowrap; }
.prov.mejor { background: var(--ok-l); color: var(--ok); font-weight: 700; }
.qty { width: 90px !important; min-height: 42px !important; text-align: center; }
.perm-list { display: grid; gap: .3rem; margin-top: .6rem; }
.perm-list label { display: flex; gap: .55rem; align-items: center; min-height: 34px; }
.perm-list input { width: 20px; height: 20px; accent-color: var(--completo); }

.phone { width: 270px; margin: 0 auto; border: 10px solid #1d2939; border-radius: 34px; padding: 1.2rem .9rem; background: var(--bg); }
.phone .kpi { margin-bottom: .6rem; padding: .7rem .9rem; }
.phone .kpi strong { font-size: 1.3rem; }

@media (max-width: 1100px) {
  .pos { grid-template-columns: 1fr; }
  .pos-cart { position: static; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); padding: .5rem; }
  .nav-item { width: auto; white-space: nowrap; }
  .nav-sep { display: none; }
  .main { padding: 1rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .metodos { grid-template-columns: repeat(2, 1fr); }
}

@media print {
  body * { visibility: hidden; }
  .ticket, .ticket * { visibility: visible; }
  .ticket { position: absolute; left: 0; top: 0; border: none; }
}
