/* Caja y Facturación — sistema de diseño de la web.
   Mismo canon que la app iOS: neutro cálido (hueso), un solo acento grafito,
   verde SOLO para utilidad/positivo. La web sí soporta tema oscuro porque el
   mostrador y la oficina no siempre están igual de iluminados. */

:root {
  --bg: #F4F3EF;
  --surface: #FFFFFF;
  --surface-2: #FAF9F6;
  --element: #EFEEE9;
  --element-2: #E4E2DB;

  --ink: #1C1C1E;
  --ink-2: #56534E;
  --ink-3: #8A867E;

  --hairline: #E7E4DD;
  --hairline-strong: #D8D4CB;

  --accent: #1C1C1E;
  --on-accent: #FFFFFF;

  --profit: #3B7A57;
  --profit-soft: #E7F0EA;
  --warn: #A96518;
  --warn-soft: #F6EDE0;
  --danger: #B3402E;
  --danger-soft: #F6E7E2;

  --shadow-sm: 0 1px 2px rgba(28, 28, 30, .05);
  --shadow-md: 0 2px 6px rgba(28, 28, 30, .06), 0 12px 32px rgba(28, 28, 30, .08);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --r-chip: 11px;
  --r-control: 12px;
  --r-card: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1A1917;
    --surface: #232120;
    --surface-2: #2A2826;
    --element: #2E2C29;
    --element-2: #393632;

    --ink: #ECE8E1;
    --ink-2: #A8A39A;
    --ink-3: #79746B;

    --hairline: #35322E;
    --hairline-strong: #423E39;

    --accent: #ECE8E1;
    --on-accent: #1A1917;

    --profit: #6FB98C;
    --profit-soft: #22302A;
    --warn: #D69A54;
    --warn-soft: #322A1E;
    --danger: #D9765F;
    --danger-soft: #33211D;

    --shadow-md: 0 2px 6px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.012em; font-weight: 650; }
p { margin: 0; }
[hidden], .hidden { display: none !important; }

.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--profit); }
.neg { color: var(--danger); }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* ───────────────────────── marca ───────────────────────── */

.mark {
  display: grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: var(--on-accent);
  font-weight: 800; font-size: 16px; letter-spacing: -0.02em;
  background-size: cover; background-position: center;
}
.mark.lg { width: 40px; height: 40px; border-radius: 11px; font-size: 20px; }

/* ───────────────────────── acceso ───────────────────────── */

.gate { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.gate-card {
  width: 100%; max-width: 390px; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: 18px; padding: 32px 28px;
  box-shadow: var(--shadow-sm);
}
.gate-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.gate-card .brand h1 { font-size: 18px; }
.gate-sub { color: var(--ink-2); font-size: 14px; margin: 4px 0 20px; }
.gate-alt { margin-top: 16px; display: flex; gap: 14px; flex-wrap: wrap; }

/* ───────────────────────── shell ───────────────────────── */

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }

.side {
  border-right: 1px solid var(--hairline);
  background: var(--surface);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-head { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; min-width: 0; }
.side-head h2 { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-head .plan { font-size: 11px; color: var(--ink-3); }

.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--r-chip);
  color: var(--ink-2); text-decoration: none; font-size: 14.5px; font-weight: 500;
}
.nav a:hover { background: var(--element); color: var(--ink); }
.nav a.on { background: var(--element-2); color: var(--ink); font-weight: 640; }
.nav a .ico { width: 18px; text-align: center; font-size: 15px; opacity: .85; }
.nav .sep { height: 1px; background: var(--hairline); margin: 8px 11px; }

.side-foot { padding: 12px 14px 16px; border-top: 1px solid var(--hairline); }
.side-foot .who { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; word-break: break-all; }

.main { min-width: 0; display: flex; flex-direction: column; }
.view { padding: 26px 30px 72px; max-width: 1180px; width: 100%; }
.view.wide { max-width: none; }

.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.view-head h1 { font-size: 24px; }
.view-head p { color: var(--ink-2); font-size: 14px; margin-top: 3px; }
.view-head .acts { display: flex; gap: 8px; flex-wrap: wrap; }

.eyebrow {
  font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700; margin: 0 0 10px;
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--hairline); }
  .nav { flex-direction: row; overflow-x: auto; padding: 4px 8px 10px; }
  .nav a { white-space: nowrap; }
  .nav .sep { display: none; }
  .side-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .side-foot .who { margin: 0; }
  .view { padding: 20px 16px 64px; }
}

/* ───────────────────────── superficies ───────────────────────── */

.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-card); padding: 20px;
}
.card.tight { padding: 14px 16px; }
.card + .card { margin-top: 14px; }
.card h3 { font-size: 16px; margin-bottom: 3px; }
.card .sub { color: var(--ink-2); font-size: 13.5px; }

section { margin-bottom: 26px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--hairline); border-radius: 14px; padding: 15px 16px; }
.tile .k { font-size: 13px; color: var(--ink-2); }
.tile .v { font-family: var(--mono); font-size: 23px; font-weight: 650; margin-top: 5px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.tile .v.sm { font-size: 18px; }
.tile.clickable { cursor: pointer; text-align: left; width: 100%; font: inherit; color: inherit; }
.tile.clickable:hover { border-color: var(--hairline-strong); }
.tile.clickable.open { border-color: var(--ink); }

/* ───────────────────────── controles ───────────────────────── */

label { display: block; font-size: 13px; color: var(--ink-2); margin: 0 0 5px; font-weight: 500; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 15px;
  border: 1px solid var(--hairline-strong); border-radius: var(--r-control);
  background: var(--surface); color: var(--ink);
}
textarea { resize: vertical; min-height: 68px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input:disabled, select:disabled { background: var(--element); color: var(--ink-3); }
input[type=file] { font-size: 13.5px; padding: 8px; }

.field { margin-bottom: 14px; }
.field .hint { font-size: 12.5px; color: var(--ink-3); margin-top: 5px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
@media (max-width: 620px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

button { font: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: var(--r-control); border: 1px solid transparent;
  font-size: 14.5px; font-weight: 620; cursor: pointer;
  background: var(--element); color: var(--ink); border-color: var(--hairline-strong);
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--element-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { opacity: .88; background: var(--accent); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--hairline-strong); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-lg { padding: 14px 20px; font-size: 16px; border-radius: 13px; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: var(--ink-3); font-size: 14px; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.btn-link:hover { color: var(--ink); }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  padding: 7px 13px; border-radius: var(--r-chip); cursor: pointer;
  border: 1px solid var(--hairline-strong); background: var(--surface);
  color: var(--ink-2); font-size: 13.5px; font-weight: 550;
}
.chip:hover { background: var(--element); }
.chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chip.locked { opacity: .55; cursor: default; }

.seg { display: inline-flex; background: var(--element); border-radius: var(--r-chip); padding: 3px; gap: 2px; }
.seg button {
  border: none; background: none; padding: 6px 15px; border-radius: 9px;
  font-size: 13.5px; font-weight: 570; color: var(--ink-2); cursor: pointer;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.badge { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; letter-spacing: .3px; display: inline-block; }
.badge.free { background: var(--element); color: var(--ink-2); }
.badge.pro { background: var(--profit-soft); color: var(--profit); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.ok { background: var(--profit-soft); color: var(--profit); }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 14px; color: var(--ink); }
.switch input { width: auto; margin: 0; accent-color: var(--accent); width: 17px; height: 17px; }

/* ───────────────────────── tablas ───────────────────────── */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; }
tbody tr:last-child td { border-bottom: none; }
tr.tap { cursor: pointer; }
tr.tap:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

.empty { color: var(--ink-3); font-size: 14px; padding: 18px 4px; text-align: center; }
.foot-note { font-size: 12.5px; color: var(--ink-3); margin-top: 8px; }

/* ───────────────────────── punto de venta ───────────────────────── */

/* `pos-grid`, no `pos`: `.pos` ya es la clase de color para cifras positivas y
   el layout se lo heredaba en verde a todo el catálogo y al ticket. */
.pos-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 18px; align-items: start; }
@media (max-width: 1080px) { .pos-grid { grid-template-columns: 1fr; } }

.scan-bar { position: relative; margin-bottom: 14px; }
.scan-bar input {
  padding: 15px 16px 15px 46px; font-size: 16.5px; border-radius: 14px;
  border-width: 1.5px; background: var(--surface); box-shadow: var(--shadow-sm);
}
.scan-bar .ico { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 17px; opacity: .5; pointer-events: none; }

.cat-list { display: flex; flex-direction: column; gap: 8px; }
.prod {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 13px; padding: 11px 14px;
}
.prod:hover { border-color: var(--ink); }
.prod:disabled { opacity: .55; cursor: default; }
.prod:disabled:hover { border-color: var(--hairline); }
.prod .thumb { width: 40px; height: 40px; border-radius: 9px; background: var(--element) center/cover no-repeat; display: grid; place-items: center; color: var(--ink-3); font-size: 15px; font-weight: 700; }
.prod .nm { font-weight: 570; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prod .meta { font-size: 12.5px; color: var(--ink-3); }
.prod .pr { font-family: var(--mono); font-weight: 650; font-variant-numeric: tabular-nums; }

.ticket { position: sticky; top: 18px; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-card); box-shadow: var(--shadow-sm); overflow: hidden; }
.ticket-head { padding: 14px 16px; border-bottom: 1px solid var(--hairline); display: flex; justify-content: space-between; align-items: center; }
.ticket-head h3 { font-size: 15px; }
.ticket-body { max-height: 42vh; overflow-y: auto; padding: 4px 16px; }
.ticket-foot { padding: 14px 16px 16px; border-top: 1px solid var(--hairline); background: var(--surface-2); }

.line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 11px 0; border-bottom: 1px solid var(--hairline); }
.line:last-child { border-bottom: none; }
.line .nm { font-size: 14px; font-weight: 550; }
.line .tot { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.line .ctl { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--hairline-strong); border-radius: 9px; overflow: hidden; }
.stepper button { width: 28px; height: 28px; border: none; background: var(--surface); color: var(--ink); font-size: 15px; cursor: pointer; line-height: 1; }
.stepper button:hover { background: var(--element); }
.stepper input { width: 54px; border: none; border-left: 1px solid var(--hairline); border-right: 1px solid var(--hairline); border-radius: 0; text-align: center; padding: 4px; font-family: var(--mono); font-size: 13.5px; }
.stepper input:focus { outline-offset: -2px; }

.tot-row { display: flex; justify-content: space-between; font-size: 14px; color: var(--ink-2); margin: 4px 0; }
.tot-row .v { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); }
.tot-row.grand { font-size: 21px; font-weight: 700; color: var(--ink); margin: 12px 0 4px; align-items: baseline; }
.tot-row.grand .v { font-size: 25px; font-weight: 700; letter-spacing: -0.02em; }

/* ───────────────────────── modal ───────────────────────── */

.modal-bg {
  position: fixed; inset: 0; background: rgba(20, 19, 17, .38);
  display: grid; place-items: center; padding: 20px; z-index: 60;
  backdrop-filter: blur(2px); overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: 18px; width: 100%; max-width: 520px;
  box-shadow: var(--shadow-md); border: 1px solid var(--hairline);
  max-height: calc(100vh - 40px); display: flex; flex-direction: column; margin: auto;
}
.modal.lg { max-width: 720px; }
.modal-head { padding: 18px 22px 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.modal-head h3 { font-size: 17.5px; }
.modal-head .sub { font-size: 13.5px; color: var(--ink-2); margin-top: 3px; }
.modal-body { padding: 4px 22px 6px; overflow-y: auto; }
.modal-foot { padding: 14px 22px 20px; display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }
.x { background: none; border: none; font-size: 21px; line-height: 1; color: var(--ink-3); cursor: pointer; padding: 0 2px; }
.x:hover { color: var(--ink); }

/* ───────────────────────── avisos ───────────────────────── */

.msg { font-size: 13.5px; padding: 10px 13px; border-radius: var(--r-control); margin-top: 12px; }
.msg.err { background: var(--danger-soft); color: var(--danger); }
.msg.ok { background: var(--profit-soft); color: var(--profit); }
.msg.warn { background: var(--warn-soft); color: var(--warn); }

/* Abajo a la derecha: arriba tapaba el botón principal de cada pantalla. */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: var(--surface); border: 1px solid var(--hairline-strong);
  border-left: 3px solid var(--accent); border-radius: 12px;
  padding: 11px 16px; font-size: 14px; box-shadow: var(--shadow-md);
  max-width: 360px; animation: toast-in .18s ease-out;
}
.toast.ok { border-left-color: var(--profit); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

.quota-track { height: 8px; border-radius: 4px; background: var(--element); overflow: hidden; margin-top: 12px; }
.quota-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .2s; }

.lock { text-align: center; padding: 34px 20px; }
.lock .ico { font-size: 26px; opacity: .5; }
.lock h3 { margin: 10px 0 5px; font-size: 17px; }
.lock p { color: var(--ink-2); font-size: 14px; max-width: 44ch; margin: 0 auto; }

.spinner {
  display: inline-block; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .6s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading { padding: 40px; text-align: center; color: var(--ink-3); }

/* ───────────────────────── impresión ───────────────────────── */

#printArea { display: none; }

@media print {
  body { background: #fff; }
  .side, .view-head .acts, .toasts, .modal-bg, .no-print { display: none !important; }
  .shell { display: block; }
  .view { display: none; }
  #printArea { display: block; padding: 0; }
  @page { margin: 14mm; }
}
