/* GRUPO · hoja única de estilos. Mobile-first, sin frameworks. */
:root {
  --barf: #e8731a;
  --sv: #2e8b57;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2429;
  --muted: #6b7280;
  --border: #e3e6ea;
  --primary: #1f6feb;
  --danger: #d43f3f;
  --ok: #2e8b57;
  --warn: #d99a00;
  --radius: 12px;
  --shadow: 0 4px 18px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { line-height: 1.2; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 16px; margin: 0 0 8px; }

/* ---------- barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
}
.topbar .logo { font-weight: 900; letter-spacing: 3px; font-size: 18px; color: var(--text); }
.topbar .logo b { background: linear-gradient(90deg, var(--barf), var(--sv)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a { padding: 8px 10px; border-radius: 8px; color: var(--text); white-space: nowrap; font-weight: 600; font-size: 14px; }
.topbar nav a.active { background: var(--bg); color: var(--primary); }
.topbar .user { color: var(--muted); font-size: 13px; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.topbar .user .name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
.btn-link { background: none; border: 0; color: var(--primary); font: inherit; cursor: pointer; padding: 6px; min-height: 44px; }

main { max-width: 1100px; margin: 0 auto; padding: 14px; padding-bottom: 110px; }
main.narrow { max-width: 720px; }

/* ---------- tarjetas / layout ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.card.barf { border-top: 4px solid var(--barf); }
.card.sv { border-top: 4px solid var(--sv); }
.card.flat { box-shadow: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 760px) {
  .grid2 { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr; }
}
.sep { height: 1px; background: var(--border); margin: 12px 0; }
.right { text-align: right; }
.center { text-align: center; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.hidden { display: none !important; }
.money { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.neg { color: var(--danger); }
.pos { color: var(--ok); }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px;
  border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--text);
  font: inherit; font-weight: 700; font-size: 15px;
  cursor: pointer; user-select: none; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.barf { background: var(--barf); border-color: var(--barf); color: #fff; }
.btn.sv { background: var(--sv); border-color: var(--sv); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 36px; padding: 4px 10px; font-size: 13px; }
.btn.lg { min-height: 54px; font-size: 17px; }
.btn.block { width: 100%; }
.btn.icon { min-width: 44px; padding: 8px; }

/* ---------- formularios ---------- */
input, select, textarea {
  font: inherit; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  width: 100%; background: #fff; color: var(--text);
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31, 111, 235, .35); border-color: var(--primary); }
input[readonly], input:disabled { background: #f0f1f3; color: var(--muted); }
input[type="file"] { padding: 6px; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--primary); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.field { margin-bottom: 12px; }
.field.inline { display: flex; align-items: center; gap: 10px; }
.field.inline label { margin: 0; }
.radios { display: flex; gap: 8px; flex-wrap: wrap; }
.radios label {
  display: flex; align-items: center; gap: 8px; margin: 0;
  min-height: 44px; padding: 6px 14px; border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 15px; cursor: pointer; background: #fff;
}
.radios label:has(input:checked) { border-color: var(--primary); background: #eaf2ff; }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.err-text { color: var(--danger); font-size: 13px; }

/* ---------- toggle empresa / tabs ---------- */
.toggle, .tabs { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.toggle button, .tabs button {
  flex: 1; min-height: 46px; border: 0; background: #fff; color: var(--muted);
  font: inherit; font-weight: 700; font-size: 16px; cursor: pointer;
}
.toggle button.on.barf { background: var(--barf); color: #fff; }
.toggle button.on.sv { background: var(--sv); color: #fff; }
.tabs button.on { background: var(--text); color: #fff; }

/* ---------- badges y chips ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; color: #fff; white-space: nowrap; vertical-align: middle; }
.badge.barf { background: var(--barf); }
.badge.sv { background: var(--sv); }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #eef0f3; color: #444; white-space: nowrap; vertical-align: middle; }
.tag.ok { background: #e3f3ea; color: #1d6b42; }
.tag.warn { background: #fff4d6; color: #7a5600; }
.tag.bad { background: #fde3e3; color: #9b2222; }
.tag.info { background: #e4edff; color: #1b4fa8; }

/* ---------- tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr.click { cursor: pointer; }
tr.click:hover { background: #f7f8fa; }
td.num, th.num { text-align: right; }

/* ---------- listas ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff;
}
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 700; }
.item .sub { font-size: 13px; color: var(--muted); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.kpi { background: #fafbfc; border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.kpi .v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi.big .v { font-size: 26px; }

/* ---------- desglose (cierre / liquidación) ---------- */
.breakdown { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; }
.breakdown .k { color: var(--muted); }
.breakdown .v { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.breakdown .neto { font-size: 18px; font-weight: 900; border-top: 2px solid var(--border); padding-top: 8px; margin-top: 4px; }

/* ---------- buscador con sugerencias ---------- */
.suggest { position: relative; }
.suggest ul {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  max-height: 260px; overflow: auto; list-style: none; margin: 4px 0 0; padding: 0;
  box-shadow: var(--shadow);
}
.suggest li { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.suggest li:last-child { border-bottom: 0; }
.suggest li:hover, .suggest li.hl { background: #f2f6ff; }
.suggest li .sub { font-size: 12px; color: var(--muted); }

/* ---------- productos / carrito ---------- */
.prod { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.prod:last-child { border-bottom: 0; }
.prod .name { flex: 1; min-width: 0; }
.prod .price { font-size: 13px; color: var(--muted); }
.qty { display: flex; align-items: center; gap: 4px; }
.qty button { width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 20px; font-weight: 700; cursor: pointer; }
.qty button:active { background: #eef0f3; }
.qty span { min-width: 30px; text-align: center; font-weight: 800; font-size: 16px; }
.prod-list { max-height: 320px; overflow: auto; }
.totals { background: #fafbfc; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.totals .line { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .line.total { font-size: 20px; font-weight: 900; border-top: 2px solid var(--border); margin-top: 6px; padding-top: 8px; }

/* ---------- ruta (celular) ---------- */
.parada {
  background: #fff; border: 1px solid var(--border); border-left: 6px solid var(--muted);
  border-radius: 12px; padding: 12px; margin-bottom: 10px;
}
.parada.barf { border-left-color: var(--barf); }
.parada.sv { border-left-color: var(--sv); }
.parada.done { opacity: .62; }
.parada .head { display: flex; align-items: center; gap: 8px; }
.parada .num { width: 30px; height: 30px; border-radius: 50%; background: var(--text); color: #fff; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.parada .partner { font-weight: 800; font-size: 16px; flex: 1; min-width: 0; }
.parada .addr { margin: 6px 0; font-size: 15px; }
.parada .addr a { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; }
.parada .meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 14px; margin: 4px 0; }
.parada .actions { display: flex; gap: 8px; margin-top: 8px; }
.parada .actions .btn { flex: 1; }
.parada .order { display: flex; flex-direction: column; gap: 4px; }
.parada .order button { width: 44px; height: 36px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 14px; cursor: pointer; }

.bottombar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: #fff; border-top: 1px solid var(--border);
  padding: 10px 14px; padding-bottom: calc(10px + env(safe-area-inset-bottom));
  display: flex; gap: 10px; align-items: center; box-shadow: 0 -4px 14px rgba(0,0,0,.06);
}
.bottombar .info { flex: 1; min-width: 0; font-size: 14px; line-height: 1.25; }
.bottombar .info b { font-size: 16px; }

/* ---------- teclado numérico (login / PIN) ---------- */
.login-wrap { min-height: calc(100vh - 60px); display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { width: 100%; max-width: 360px; text-align: center; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); display: block; }
.pin-dots i.on { background: var(--text); border-color: var(--text); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 300px; margin: 0 auto; }
.keypad button {
  min-height: 64px; font-size: 26px; font-weight: 700; border: 1px solid var(--border);
  border-radius: 14px; background: #fff; cursor: pointer; font-family: inherit;
}
.keypad button:active { background: #eef0f3; }
.keypad button.action { font-size: 20px; }

/* ---------- modal ---------- */
.modal-bg {
  position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
@media (min-width: 720px) {
  .modal-bg { align-items: center; }
  .modal { border-radius: 16px; }
}
.modal .mhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.modal .mhead h3 { margin: 0; font-size: 18px; }
.modal .mclose { background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); min-width: 44px; min-height: 44px; }
.modal .mactions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.modal .mactions .btn { flex: 1; }

/* ---------- toasts ---------- */
.toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: #1f2429; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 600; animation: toastin .2s ease-out; pointer-events: auto; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
@keyframes toastin { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- línea de tiempo ---------- */
.timeline { list-style: none; padding: 0; margin: 0 0 0 6px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 4px 0 4px 16px; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 10px; width: 12px; height: 12px; border-radius: 50%; background: var(--border); }
.timeline li.done::before { background: var(--ok); }

/* ---------- varios ---------- */
.photo-prev { max-width: 100%; max-height: 180px; border-radius: 8px; margin-top: 6px; display: block; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(0,0,0,.2); border-top-color: var(--text); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.primary .spinner, .btn.ok .spinner, .btn.warn .spinner, .btn.danger .spinner, .btn.barf .spinner, .btn.sv .spinner { border-color: rgba(255,255,255,.4); border-top-color: #fff; }
details summary { cursor: pointer; font-weight: 700; min-height: 36px; display: flex; align-items: center; }
.result-card { border: 2px solid var(--ok); background: #f1faf5; }
.result-card .big { font-size: 22px; font-weight: 900; }
.gps-state { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; min-height: 24px; }
.gps-state.ok { color: var(--ok); }
.gps-state.err { color: var(--danger); }

/* ---------- líneas de pedido en filas (G.lineasWidget) ---------- */
.lw-head, .ln { display: grid; grid-template-columns: minmax(0, 1fr) 76px 130px 110px 44px; gap: 8px; align-items: center; }
.lw-head { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 0 0 4px; }
.ln { padding: 6px 0; border-bottom: 1px solid var(--border); }
.ln:last-child { border-bottom: 0; }
.ln select { min-width: 0; }
.ln .ln-st { text-align: right; font-size: 15px; }
.ln .ln-x { width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--danger); font-size: 18px; font-weight: 700; cursor: pointer; }
.ln .ln-x:active { background: #fde3e3; }
@media (max-width: 760px) {
  .lw-head { display: none; }
  .ln { grid-template-columns: 1fr 1fr auto 44px; grid-template-areas: "p p p p" "q pr st x"; }
  .ln .ln-p { grid-area: p; } .ln .ln-q { grid-area: q; } .ln .ln-pr { grid-area: pr; } .ln .ln-st { grid-area: st; } .ln .ln-x { grid-area: x; }
}

/* ---------- rejilla de campos del pedido ---------- */
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 4px 14px; }
.fields .field.wide { grid-column: 1 / -1; }
.hint-inline { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; color: var(--text); font-weight: 600; margin: 0; cursor: pointer; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.filters .field { margin-bottom: 0; }

/* ---------- tabla que se vuelve tarjetas en celular ---------- */
table.cards td.chk { width: 36px; }
table.cards td.acts { text-align: right; white-space: nowrap; }
table.cards tr.cancelado td { opacity: .55; }
@media (max-width: 760px) {
  table.cards, table.cards tbody { display: block; width: 100%; }
  table.cards thead { display: none; }
  table.cards tr { display: block; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; padding: 6px 10px; background: #fff; }
  table.cards td { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 0; padding: 3px 0; text-align: right; }
  table.cards td::before { content: attr(data-l); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; font-weight: 700; text-align: left; flex-shrink: 0; }
  table.cards td.full { display: flex; justify-content: flex-start; text-align: left; }
  table.cards td.full::before, table.cards td.chk::before, table.cards td.acts::before { display: none; }
  table.cards td.chk { width: auto; }
  table.cards td.acts { justify-content: flex-end; padding-top: 6px; }
}
