/* Diseño pensado para lectura fácil: letra grande y gruesa, contraste alto (AAA), botones amplios.
   Tema claro por defecto; oscuro con el botón o automático según el dispositivo. */
:root {
  --c: #0F6B64;
  --bg: #f4f4ee; --card: #ffffff; --txt: #0a1a19; --mut: #33453f; --line: #8a9b94; --soft: #dfeae5;
  --c-txt: color-mix(in srgb, var(--c) 72%, #000);      /* color de marca legible sobre fondo claro */
  --c-btn: color-mix(in srgb, var(--c) 82%, #000);      /* fondo de botón; el texto blanco supera 7:1 */
  --btn-txt: #ffffff;
  --bar: color-mix(in srgb, var(--c) 82%, #000);
  --danger: #a4141b; --ok: #0d5c1f; --focus: #b45309;
  --shadow: 0 2px 6px rgba(10, 18, 32, .28);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0f16; --card: #171d27; --txt: #f7f9fc; --mut: #d0d8e4; --line: #7a8799; --soft: #263042;
  --c-txt: color-mix(in srgb, var(--c) 35%, #fff);
  --c-btn: color-mix(in srgb, var(--c) 80%, #000);
  --bar: #121a26;
  --danger: #ff8f8a; --ok: #7ee08f; --focus: #ffc857;
  --shadow: 0 2px 6px rgba(0, 0, 0, .7);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f16; --card: #171d27; --txt: #f7f9fc; --mut: #d0d8e4; --line: #7a8799; --soft: #263042;
    --c-txt: color-mix(in srgb, var(--c) 35%, #fff);
    --c-btn: color-mix(in srgb, var(--c) 80%, #000);
    --bar: #121a26;
    --danger: #ff8f8a; --ok: #7ee08f; --focus: #ffc857;
    --shadow: 0 2px 6px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--txt); font: 700 19px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }
button, .btn, input, select, textarea { font: inherit; }
body.locked #top, body.locked main, body.locked #tabs { display: none; }
body:not(.locked) #gate { display: none; }

/* ---- Barra superior ---- */
#top { position: sticky; top: 0; z-index: 5; background: var(--bar); color: #fff; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); font-weight: 900; font-size: 22px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 2px solid var(--line); }
#brand { line-height: 1.15; overflow-wrap: anywhere; }
.topTools { display: flex; align-items: center; gap: 8px; flex: none; }
#adminBadge { background: #fff; color: #0a1220; font-size: 14px; font-weight: 900; padding: 4px 10px; border-radius: 8px; }
.iconBtn { width: 48px; height: 48px; border-radius: 12px; border: 2px solid rgba(255,255,255,.85); background: transparent; color: #fff; font-size: 22px; cursor: pointer; }
main { max-width: 960px; margin: 0 auto; padding: 16px 14px 120px; }

/* ---- Navegación inferior ---- */
#tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; background: var(--card); border-top: 3px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#tabs a { flex: 1; text-align: center; padding: 9px 0 8px; text-decoration: none; color: var(--mut); font-size: 26px; line-height: 1.2; position: relative; }
#tabs a span { display: block; font-size: 14px; font-weight: 800; margin-top: 2px; }
#tabs a.on { color: var(--c-txt); background: var(--soft); box-shadow: inset 0 4px 0 var(--c-txt); }
#tabs a.on span { font-weight: 900; }
#cartCount { position: absolute; top: 2px; left: calc(50% + 10px); background: var(--danger); color: #fff; font-size: 14px; font-weight: 900; border-radius: 12px; min-width: 24px; padding: 1px 7px; }
:root[data-theme="dark"] #cartCount { color: #1a0505; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #cartCount { color: #1a0505; } }

/* ---- Textos ---- */
h1 { font-size: 30px; font-weight: 900; margin: 0 0 6px; }
h2 { margin: 8px 0 14px; font-size: 27px; font-weight: 900; line-height: 1.2; }
h3 { margin: 22px 0 10px; font-size: 19px; font-weight: 900; color: var(--mut); text-transform: uppercase; letter-spacing: .05em; }
b, strong { font-weight: 900; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px 8px; font-size: 18px; margin-bottom: 12px; color: var(--mut); }
.crumbs a { color: var(--c-txt); text-decoration: underline; text-underline-offset: 3px; font-weight: 800; }
.hint { font-size: 16px; font-weight: 700; color: var(--mut); margin-top: 6px; }
.empty { text-align: center; color: var(--mut); padding: 44px 10px; font-size: 21px; font-weight: 800; }
.chip { font-size: 15px; font-weight: 800; background: var(--soft); color: var(--c-txt); padding: 3px 10px; border-radius: 10px; }

/* ---- Tarjetas (una columna en teléfono: más grandes y legibles) ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 14px; }
.card { background: var(--card); border: 2px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; position: relative; }
.card .ph { aspect-ratio: 4/3; background: var(--soft) center/cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 44px; color: var(--mut); position: relative; }
.card .ph .gcount { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.65); color: #fff; font-size: 13px; font-weight: 800; padding: 3px 8px; border-radius: 20px; cursor: pointer; }
.pbadge { position: absolute; left: 8px; top: 8px; background: #dc2626; color: #fff; font-size: 13px; font-weight: 900; padding: 3px 10px; border-radius: 20px; box-shadow: 0 2px 6px rgba(0,0,0,.35); z-index: 2; }
.chip.st-web { background: #f3e8ff; color: #6b21a8; }
:root[data-theme="dark"] .chip.st-web { background: #3b0764; color: #e9d5ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.st-web { background: #3b0764; color: #e9d5ff; } }
.sheet.gallery { max-width: 720px; }
.gbig { aspect-ratio: 4/3; border-radius: 14px; background: var(--soft) center/contain no-repeat; border: 2px solid var(--line); }
.card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card .nm { font-weight: 900; font-size: 20px; line-height: 1.25; }
.card .ds { font-size: 16px; font-weight: 700; color: var(--mut); overflow-wrap: anywhere; }
.card .pr { color: var(--c-txt); font-weight: 900; font-size: 26px; }
.card s { font-weight: 700; }
a.card { text-decoration: none; color: inherit; }
.tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 8px; }
.tools button { width: 48px; height: 48px; border-radius: 24px; border: 2px solid var(--line); background: var(--card); color: var(--txt); font-size: 20px; box-shadow: var(--shadow); }

/* ---- Botones y campos ---- */
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 8px; background: var(--c-btn); color: var(--btn-txt); border: 3px solid var(--c-btn); border-radius: 12px; padding: 14px 20px; min-height: 58px; font-weight: 900; font-size: 20px; text-decoration: none; cursor: pointer; text-align: center; }
.btn.sec { background: var(--card); color: var(--c-txt); border-color: var(--c-txt); }
.btn.dan { background: var(--danger); border-color: var(--danger); color: #fff; }
:root[data-theme="dark"] .btn.dan { color: #1a0505; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.dan { color: #1a0505; } }
.btn.sm { padding: 10px 16px; min-height: 52px; font-size: 18px; }
.btn.block { display: flex; width: 100%; }
.btn:disabled { opacity: 1; background: var(--soft); border-color: var(--line); color: var(--mut); cursor: not-allowed; }
.linkBtn { background: none; border: 0; color: var(--c-txt); font-weight: 900; font-size: 19px; text-decoration: underline; text-underline-offset: 4px; padding: 14px; cursor: pointer; }
label { display: block; font-size: 18px; font-weight: 800; color: var(--txt); margin: 14px 0 6px; }
input, textarea, select { width: 100%; min-height: 56px; padding: 12px 14px; border: 3px solid var(--line); border-radius: 12px; font-weight: 700; font-size: 20px; background: var(--card); color: var(--txt); }
input::placeholder, textarea::placeholder { color: var(--mut); opacity: 1; font-weight: 600; }
input:focus, textarea:focus, select:focus { border-color: var(--c-txt); }
input[type=color] { padding: 4px; }
input[type=file] { font-size: 17px; }
textarea { min-height: 96px; }
.search { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: min(100%, 140px); }

/* ---- Paneles, líneas de cotización ---- */
.panel { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.line { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 2px solid var(--soft); }
.line:last-child { border-bottom: 0; }
.line .th { width: 68px; height: 68px; border-radius: 10px; background: var(--soft) center/cover; flex: none; }
.line .info { flex: 1; min-width: 0; }
.line .info b { display: block; font-size: 18px; line-height: 1.3; }
.line .info small { color: var(--mut); font-size: 16px; font-weight: 700; }
.qty { display: flex; align-items: center; gap: 10px; font-size: 22px; }
.qty button { width: 48px; height: 48px; border-radius: 24px; border: 3px solid var(--c-txt); background: var(--card); color: var(--c-txt); font-size: 26px; font-weight: 900; line-height: 1; }
.sum { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; font-size: 20px; }
.sum.big { font-size: 25px; font-weight: 900; color: var(--c-txt); }
.pay { background: var(--soft); border: 3px solid var(--c-txt); border-radius: 14px; padding: 14px; }

/* ---- Ventanas ---- */
#modal { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .7); display: flex; align-items: flex-end; justify-content: center; }
#modal[hidden], #toast[hidden], #gate[hidden] { display: none; }
#modal .sheet { background: var(--card); color: var(--txt); width: 100%; max-width: 620px; max-height: 94vh; overflow: auto; border-radius: 18px 18px 0 0; border: 2px solid var(--line); padding: 18px; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
#modal .sheet.wide { max-width: 960px; height: 94vh; }
@media (min-width: 640px) { #modal { align-items: center; } #modal .sheet { border-radius: 18px; } }
.imgpick { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.imgpick .pv { width: 88px; height: 88px; border-radius: 10px; background: var(--soft) center/cover; flex: none; border: 2px solid var(--line); }
.imgpick.multi { flex-direction: column; align-items: stretch; }
.imgpick .thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.imgpick .thumbs .hint { padding: 4px 0; }
.imgpick .thumb { position: relative; width: 78px; height: 78px; border-radius: 10px; background: var(--soft) center/cover; flex: none; border: 2px solid var(--line); }
.imgpick .thumb .cov { position: absolute; left: 3px; bottom: 3px; background: rgba(0,0,0,.65); color: #fff; font-size: 10px; font-weight: 800; padding: 2px 5px; border-radius: 6px; }
.imgpick .thumb button { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); color: var(--txt); font-weight: 900; line-height: 1; cursor: pointer; }
.ekPrice { min-height: 52px; }
#toast { position: fixed; bottom: 104px; left: 50%; transform: translateX(-50%); background: #0a1220; color: #fff; border: 2px solid #fff; padding: 14px 20px; border-radius: 14px; z-index: 40; font-size: 19px; font-weight: 800; max-width: 92%; text-align: center; }
:root[data-theme="dark"] #toast { background: #f7f9fc; color: #0a1220; border-color: #0a1220; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #toast { background: #f7f9fc; color: #0a1220; border-color: #0a1220; } }
.fab { position: fixed; right: 14px; bottom: 96px; z-index: 6; box-shadow: var(--shadow); border-radius: 30px; }

/* ---- Pantalla de PIN ---- */
#gate { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); }
#gate .iconBtn { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px; color: var(--txt); border-color: var(--line); }
.gateBox { width: 100%; max-width: 420px; text-align: center; margin-top: 28px; }
#gateLogo { max-width: 160px; max-height: 110px; object-fit: contain; margin: 0 auto 8px; display: block; }
.gateHelp { font-size: 22px; font-weight: 800; color: var(--mut); margin: 0 0 16px; }
#pinDots { min-height: 76px; display: flex; align-items: center; justify-content: center; background: var(--card); border: 3px solid var(--c-txt); border-radius: 14px; font-size: 40px; font-weight: 900; letter-spacing: .3em; padding: 6px 0 6px .3em; overflow: hidden; }
#pinDots.empty { color: var(--mut); font-size: 26px; letter-spacing: .2em; }
#gateMsg { min-height: 34px; margin: 10px 0; font-size: 20px; font-weight: 900; color: var(--danger); }
#keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
#keypad button { min-height: 76px; border-radius: 16px; border: 3px solid var(--line); background: var(--card); color: var(--txt); font-size: 34px; font-weight: 900; box-shadow: var(--shadow); cursor: pointer; }
#keypad button:active { background: var(--soft); }
#pinGo { min-height: 68px; font-size: 24px; }
@media (prefers-reduced-motion: no-preference) { .btn, #keypad button { transition: background .12s; } }

/* ---- Contado / crédito ---- */
.modeSwitch { display: flex; gap: 10px; margin-bottom: 14px; }
.modeSwitch button { flex: 1; min-height: 64px; border-radius: 14px; border: 3px solid var(--line); background: var(--card); color: var(--txt); font-weight: 900; font-size: 20px; cursor: pointer; }
.modeSwitch button.on { background: var(--c-btn); border-color: var(--c-btn); color: #fff; }
.card .pr2 { color: var(--c-txt); font-weight: 900; font-size: 22px; line-height: 1.2; }
.card .pr2 small { font-size: 15px; font-weight: 800; color: var(--mut); margin-right: 4px; }

/* ---- Seguimiento y estados de cotización ---- */
.filterChips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.fchip { min-height: 46px; padding: 8px 14px; border-radius: 24px; border: 2px solid var(--line); background: var(--card); color: var(--txt); font-size: 16px; font-weight: 800; cursor: pointer; }
.fchip.on { background: var(--c-btn); border-color: var(--c-btn); color: #fff; }
.chipRow { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; align-items: center; }
.chip.st-pendiente { background: #fef3c7; color: #78350f; }
.chip.st-seguimiento { background: #dbeafe; color: #1e3a8a; }
.chip.st-vendida { background: #dcfce7; color: #0d5c1f; }
.chip.st-cancelada { background: #fee2e2; color: #991b1b; }
.chip.urgent { background: #ffedd5; color: #9a3412; }
.chip.muted { background: var(--soft); color: var(--mut); }
:root[data-theme="dark"] .chip.st-pendiente { background: #452c05; color: #fde68a; }
:root[data-theme="dark"] .chip.st-seguimiento { background: #172554; color: #bfdbfe; }
:root[data-theme="dark"] .chip.st-vendida { background: #052e16; color: #86efac; }
:root[data-theme="dark"] .chip.st-cancelada { background: #450a0a; color: #fecaca; }
:root[data-theme="dark"] .chip.urgent { background: #431407; color: #fed7aa; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chip.st-pendiente { background: #452c05; color: #fde68a; }
  :root:not([data-theme="light"]) .chip.st-seguimiento { background: #172554; color: #bfdbfe; }
  :root:not([data-theme="light"]) .chip.st-vendida { background: #052e16; color: #86efac; }
  :root:not([data-theme="light"]) .chip.st-cancelada { background: #450a0a; color: #fecaca; }
  :root:not([data-theme="light"]) .chip.urgent { background: #431407; color: #fed7aa; }
}
.stGrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }
.stGrid .btn.sm { font-size: 16px; padding: 10px 8px; }
.stGrid .btn.on { background: var(--c-btn); color: var(--btn-txt); border-color: var(--c-btn); }
.waTemplates { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

/* ---- Etiquetas QR ---- */
.qrBox { margin: 14px auto 8px; display: flex; justify-content: center; background: #fff; padding: 10px; border-radius: 14px; border: 2px solid var(--line); max-width: 340px; }
.qrPreview { display: block; width: 100%; height: auto; border-radius: 8px; }
.qrUrl { text-align: center; word-break: break-all; }
.qrWarn { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #fef3c7; color: #78350f; font-size: 15px; font-weight: 800; border: 2px solid #f59e0b; }
:root[data-theme="dark"] .qrWarn { background: #452c05; color: #fde68a; border-color: #b45309; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .qrWarn { background: #452c05; color: #fde68a; border-color: #b45309; }
}

/* ---- Volantes promocionales y panel de ventas (Sprint 4) ---- */
.cardActs { display: flex; gap: 8px; margin-top: auto; }
.promoBtn { flex: none; min-width: 52px; padding: 10px 12px; }
.fmtSub { display: block; font-size: 13px; font-weight: 700; opacity: .85; margin-top: 2px; }
.promoBox { max-width: 360px; max-height: 460px; overflow: hidden; }
.promoBox .qrPreview { max-height: 436px; width: auto; max-width: 100%; object-fit: contain; }

.kpiGrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 14px; }
@media (max-width: 440px) { .kpiGrid { grid-template-columns: 1fr; } }
.kpiCard { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; text-align: left; color: var(--txt); }
.kpiCard.kpiOk { border-color: var(--ok); }
.kpiCard.kpiLink { cursor: pointer; border-color: var(--c-txt); }
.kpiCard.kpiLink:active { background: var(--soft); }
.kpiLbl { font-size: 15px; font-weight: 800; color: var(--mut); }
.kpiVal { font-size: 28px; font-weight: 900; color: var(--c-txt); line-height: 1.15; }
.kpiCard.kpiOk .kpiVal { color: var(--ok); }
.kpiSub { font-size: 14px; font-weight: 700; color: var(--mut); }
.statBar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--soft); margin-top: 6px; }
.statBar .sbV { background: #16a34a; }
.statBar .sbA { background: #f59e0b; }
.statBar .sbC { background: #dc2626; }
.statRow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 2px solid var(--soft); }
.statRow:last-child { border-bottom: 0; }
.statInfo { flex: 1; min-width: 0; }
.statInfo b { display: block; font-size: 18px; line-height: 1.25; }
.statInfo small { display: block; font-size: 15px; font-weight: 700; color: var(--mut); }
.statAmt { font-size: 20px; font-weight: 900; color: var(--ok); flex: none; }
.motRow { margin-bottom: 10px; }
.motRow:last-child { margin-bottom: 0; }
.motBar { height: 10px; border-radius: 6px; background: var(--soft); overflow: hidden; margin-top: 4px; }
.motBar span { display: block; height: 100%; background: var(--danger); border-radius: 6px; }
