/* HIELO CONTIGO — estilos compartidos (PWA del cliente y panel del personal).
   Sin dependencias ni fuentes externas (CSP 'self'). Colores tomados del logo. */
:root {
  --navy: #1f3f6e;
  --navy-2: #2b5592;
  --ice: #e3edf8;
  --ice-2: #f3f7fc;
  --cyan: #1495d1;
  --ink: #17233a;
  --muted: #5d6b82;
  --line: #d7e1ee;
  --bg: #f5f8fc;
  --card: #ffffff;
  --ok: #1b7f4b;
  --ok-bg: #e4f5ec;
  --warn: #8a5a00;
  --warn-bg: #fff3d6;
  --err: #b42318;
  --err-bg: #fde8e6;
  --info-bg: #e6f2fb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(23, 35, 58, .06), 0 4px 14px rgba(23, 35, 58, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 64px;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.45; color: var(--ink); background: var(--bg); }
img { max-width: 100%; }
a { color: var(--navy-2); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; color: var(--navy); }
h1 { font-size: 1.45rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

/* ---------- Botones y formularios ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .55rem 1rem;
  border: 1px solid transparent; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--navy); color: #fff; }
.btn:hover { background: var(--navy-2); }
.btn[disabled], .btn.is-busy { opacity: .55; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--navy); border-color: var(--line); }
.btn-secondary:hover { background: var(--ice-2); }
.btn-danger { background: var(--err); }
.btn-danger:hover { background: #8f1c13; }
.btn-ghost { background: transparent; color: var(--navy-2); border-color: transparent; }
.btn-ghost:hover { background: var(--ice); }
.btn-sm { min-height: 34px; padding: .3rem .7rem; font-size: .9rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .25rem; }
.field { margin-bottom: .85rem; }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: .2rem; }
.field .error { font-size: .85rem; color: var(--err); margin-top: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=date], input[type=search],
input[type=datetime-local], select, textarea {
  width: 100%; min-height: 44px; padding: .55rem .7rem; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 10px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--cyan); outline: none; box-shadow: 0 0 0 3px rgba(20, 149, 209, .18); }
.is-invalid { border-color: var(--err) !important; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.check input { width: 20px; height: 20px; }
.grid-2 { display: grid; gap: .75rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ---------- Tarjetas, avisos, insignias ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card-title { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.card-title h2, .card-title h3 { margin: 0; }
.alert { padding: .75rem .9rem; border-radius: 10px; margin-bottom: 1rem; background: var(--info-bg); color: var(--navy); border: 1px solid #c7def2; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #f1d79a; }
.alert-err { background: var(--err-bg); color: var(--err); border-color: #f4c2bd; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: #b9e3cb; }
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--ice); color: var(--navy); white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-err { background: var(--err-bg); color: var(--err); }
.badge-promo { background: #1495d1; color: #fff; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--ice); border-top-color: var(--navy); border-radius: 50%; animation: spin .8s linear infinite; margin: 2rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .94rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--ice-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--ice-2); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.totals { margin-left: auto; max-width: 320px; }
.totals .row { display: flex; justify-content: space-between; padding: .2rem 0; }
.totals .row.total { font-weight: 800; font-size: 1.1rem; border-top: 1px solid var(--line); margin-top: .3rem; padding-top: .45rem; color: var(--navy); }

/* ---------- Diálogos y avisos flotantes ---------- */
dialog { border: none; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 30, 55, .45); }
.dlg-head { padding: 1rem 1rem .25rem; } .dlg-body { padding: .5rem 1rem 1rem; max-height: 70vh; overflow: auto; }
.dlg-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 1rem; border-top: 1px solid var(--line); background: var(--ice-2); }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 16px); z-index: 1000; display: grid; gap: .5rem; width: min(440px, calc(100vw - 24px)); }
.toast { padding: .75rem 1rem; border-radius: 10px; background: var(--ink); color: #fff; box-shadow: var(--shadow); }
.toast.err { background: var(--err); } .toast.ok { background: var(--ok); }
.offline-bar { position: sticky; top: 0; z-index: 50; background: var(--warn-bg); color: var(--warn); text-align: center; padding: .4rem; font-size: .9rem; font-weight: 600; }

/* ---------- Acceso (login / restablecer) ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem;
  background: linear-gradient(160deg, var(--ice) 0%, #fff 55%, var(--ice-2) 100%); }
.auth-card { width: min(420px, 100%); background: #fff; border-radius: 18px; padding: 1.5rem; box-shadow: var(--shadow); border: 1px solid var(--line); }
.auth-logo { display: block; width: 230px; margin: 0 auto 1rem; }
.auth h1 { text-align: center; font-size: 1.2rem; }
.auth .links { text-align: center; margin-top: 1rem; font-size: .92rem; }

/* =========================== PWA DEL CLIENTE =========================== */
.app-top { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .55rem 1rem; background: var(--navy); color: #fff; }
.app-top img { height: 32px; background: #fff; border-radius: 6px; padding: 2px 6px; }
.app-top .who { font-size: .85rem; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55vw; }
.app-main { max-width: 760px; margin: 0 auto; padding: 1rem 1rem calc(var(--tabbar-h) + 1.5rem); }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; height: var(--tabbar-h); display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none;
  color: var(--muted); font-size: .76rem; font-weight: 600; position: relative; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--navy); }
.tabbar a.active::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; border-radius: 0 0 3px 3px; background: var(--cyan); }
.tabbar .count { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--cyan); color: #fff; font-size: .7rem; line-height: 18px; text-align: center; }

.product { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: .9rem; box-shadow: var(--shadow); }
.product h2 { font-size: 1.08rem; margin-bottom: .2rem; }
.product .desc { color: var(--muted); font-size: .92rem; margin-bottom: .5rem; }
.pres { display: grid; grid-template-columns: 1fr auto; gap: .5rem .75rem; align-items: center; padding: .75rem 0; border-top: 1px dashed var(--line); }
.pres:first-of-type { border-top: none; }
.pres .name { font-weight: 700; }
.pres .price { font-size: 1.15rem; font-weight: 800; color: var(--navy); }
.pres .meta { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .25rem; }
.pres .tiers { font-size: .85rem; color: var(--muted); margin-top: .2rem; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.stepper button { width: 42px; height: 42px; border: none; background: var(--ice-2); font-size: 1.3rem; font-weight: 700; color: var(--navy); cursor: pointer; }
.stepper button:hover { background: var(--ice); }
.stepper input { width: 64px; height: 42px; border: none; text-align: center; font-weight: 700; border-radius: 0; min-height: 0; padding: 0; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: .4rem .75rem; padding: .75rem 0; border-bottom: 1px solid var(--line); align-items: center; }
.cart-line .sub { font-weight: 700; text-align: right; white-space: nowrap; }
.cart-line .ctl { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
.choice { display: grid; gap: .5rem; }
.choice label { display: flex; gap: .6rem; align-items: flex-start; font-weight: 500; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
.choice label:has(input:checked) { border-color: var(--cyan); background: var(--info-bg); }
.choice input { margin-top: .2rem; width: 18px; height: 18px; }
.sticky-cta { position: sticky; bottom: calc(var(--tabbar-h) + 8px); z-index: 30; margin-top: 1rem; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 3px solid var(--ice); }
.timeline li { position: relative; padding: 0 0 .9rem 1rem; }
.timeline li::before { content: ""; position: absolute; left: -8px; top: 4px; width: 13px; height: 13px; border-radius: 50%; background: var(--cyan); border: 2px solid #fff; }
.timeline time { display: block; font-size: .82rem; color: var(--muted); }
.order-card { display: block; text-decoration: none; color: inherit; }
.order-card .top { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.map { height: 260px; border-radius: 10px; border: 1px solid var(--line); margin-bottom: .75rem; }

/* =========================== PANEL DEL PERSONAL =========================== */
.panel { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #dfe8f5; padding: 1rem .75rem; }
.side .brand { display: flex; align-items: center; gap: .6rem; margin: 0 .25rem 1rem; color: #fff; font-weight: 800; }
.side .brand img { width: 38px; height: 38px; border-radius: 9px; }
.side nav a { display: flex; align-items: center; gap: .55rem; padding: .55rem .7rem; border-radius: 8px; color: #dfe8f5; text-decoration: none; font-weight: 600; font-size: .95rem; }
.side nav a:hover { background: rgba(255,255,255,.08); }
.side nav a.active { background: #fff; color: var(--navy); }
.side nav .group { margin: .9rem .7rem .3rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #9fb4d3; }
.side .me { margin-top: 1rem; padding: .75rem; border-top: 1px solid rgba(255,255,255,.15); font-size: .88rem; }
.menu-toggle { display: inline-flex; }
.side nav { display: none; }
.side.open nav { display: block; }
.content { padding: 1rem; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin-bottom: .75rem; }
.filters .field { margin: 0; min-width: 150px; }
.stats { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 1rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; }
.stat .n { font-size: 1.8rem; font-weight: 800; color: var(--navy); }
.stat .l { color: var(--muted); font-size: .9rem; }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; margin-top: .75rem; font-size: .9rem; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .55rem .9rem; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--navy); border-bottom-color: var(--cyan); }
@media (min-width: 960px) {
  .panel { grid-template-columns: 240px 1fr; }
  .side { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
  .side nav { display: block; }
  .menu-toggle { display: none; }
  .content { padding: 1.5rem 2rem; }
  .toasts { bottom: 24px; }
}
@media print {
  .side, .tabbar, .app-top, .btn, .filters, .page-head, .toasts { display: none !important; }
  .panel { display: block; } body { background: #fff; }
  .ticket { box-shadow: none; border: none; max-width: 80mm; font-size: 12px; }
}

/* Fase 7: líneas de pago en la venta de mostrador */
.pay { border-top: 1px dashed var(--line); padding-top: .5rem; }
@media (min-width: 640px) { .pay.grid-2 { grid-template-columns: 1fr 1.4fr auto; align-items: end; } .pay .field { margin-bottom: .5rem; } }

/* Fase 8: despacho y venta en ruta */
.order-pick { align-items: flex-start; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.order-pick input { margin-top: .2rem; flex: none; }
.pick-list { display: grid; gap: .25rem; margin-bottom: .5rem; }
.pick-list .btn { justify-content: flex-start; text-align: left; }
.cart-line .mp { max-width: 9rem; }
#stl input[type=number] { width: 5.5rem; text-align: right; }
@media print {
  .route-sheet { box-shadow: none; border: none; font-size: 12px; }
  .route-sheet td:last-child { min-width: 7rem; border-bottom: 1px solid #000; }
}

/* Reportes */
table.report tfoot th { border-top: 2px solid var(--line); font-weight: 700; background: var(--bg, transparent); }
table.report td, table.report th { white-space: nowrap; }
@media print { #flt, .tabs { display: none !important; } }
