/* Cierre de Caja — estilos
   Layout: banda superior oscura con navegación; contenido de ancho máximo 1200px;
   el cierre del día en dos columnas con el resumen fijo a la derecha como tirilla de caja. */
:root {
  --bg: #eef1ee;
  --surface: #ffffff;
  --surface-2: #f6f8f6;
  --ink: #16201c;
  --muted: #5d6a64;
  --line: #d6ddd9;
  --line-strong: #b9c3be;
  --accent: #0b6b4e;
  --accent-soft: #e2f1ea;
  --on-accent: #ffffff;
  --band: #14211c;
  --on-band: #e9efec;
  --on-band-muted: #9fb0a8;
  --bad: #b42318;
  --bad-soft: #fdeceb;
  --warn: #9a5b00;
  --warn-soft: #fff3dc;
  --info: #1d5fa8;
  --info-soft: #e7f0fb;
  --c-ef: #0b6b4e;
  --c-bc: #2e5aa8;
  --c-df: #c07a12;
  --shadow: 0 1px 2px rgba(20, 33, 28, .06), 0 4px 16px rgba(20, 33, 28, .06);
  --f-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --f-body: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --r: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1412; --surface: #161f1b; --surface-2: #1b2622; --ink: #e5ece8; --muted: #9aa8a1;
    --line: #2a3631; --line-strong: #3a4842; --accent: #3dbb8c; --accent-soft: #173229; --on-accent: #08130f;
    --band: #0a100e; --on-band: #e5ece8; --on-band-muted: #8c9c94;
    --bad: #f07a6a; --bad-soft: #3a1a17; --warn: #f0aa48; --warn-soft: #36280f; --info: #79aef0; --info-soft: #172a40;
    --c-ef: #3dbb8c; --c-bc: #6f9be6; --c-df: #e8a540;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1412; --surface: #161f1b; --surface-2: #1b2622; --ink: #e5ece8; --muted: #9aa8a1;
  --line: #2a3631; --line-strong: #3a4842; --accent: #3dbb8c; --accent-soft: #173229; --on-accent: #08130f;
  --band: #0a100e; --on-band: #e5ece8; --on-band-muted: #8c9c94;
  --bad: #f07a6a; --bad-soft: #3a1a17; --warn: #f0aa48; --warn-soft: #36280f; --info: #79aef0; --info-soft: #172a40;
  --c-ef: #3dbb8c; --c-bc: #6f9be6; --c-df: #e8a540;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--f-body); -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--f-display); line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
.num, td.n, .money { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Banda superior ---------- */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--band); }
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--band); color: var(--on-band);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.top-in { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 20px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--f-display); font-weight: 800; font-size: 17px; white-space: nowrap; }
.brand-mark { width: 28px; height: 28px; border-radius: 6px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: 14px; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: var(--on-band-muted); text-decoration: none; padding: 17px 12px 15px; font-weight: 600; font-size: 14px;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.nav a:hover { color: var(--on-band); }
.nav a[aria-current="page"] { color: var(--on-band); border-bottom-color: var(--accent); }
.who { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
@media (max-width: 760px) {
  .top-in { flex-wrap: wrap; gap: 0 12px; padding-top: 8px; }
  .brand { flex: 1; }
  .nav { order: 3; flex-basis: 100%; margin-inline: -8px; }
  .nav a { padding: 10px 8px 9px; }
}
.who-btn { background: transparent; border: 1px solid rgba(255,255,255,.18); color: var(--on-band); border-radius: 999px; padding: 5px 12px 5px 5px; display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 220px; padding: 6px; z-index: 20; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }
.menu .menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: 13px; }
.demo-band { background: var(--warn-soft); color: var(--warn); font-size: 13px; text-align: center; padding: 6px 16px; }

/* ---------- Contenido ---------- */
.wrap { max-width: 1200px; margin: 0 auto; padding-block: 24px 64px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.card-h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-h h2 { white-space: nowrap; }
.card-b { padding: 16px; }
.card-h .hint { font-size: 12px; color: var(--muted); }
.stack { display: grid; gap: 16px; min-width: 0; }

/* ---------- Controles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); border-radius: 6px; padding: 8px 14px; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap; min-height: 38px;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn-icon { padding: 4px 8px; min-height: 30px; border-color: transparent; background: transparent; color: var(--muted); }
.btn-icon:hover { color: var(--bad); background: var(--bad-soft); }

.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 6px; padding: 8px 10px; min-height: 38px;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.input:disabled, .input[readonly] { background: var(--surface-2); color: var(--muted); }
.input.money-in { text-align: right; font-variant-numeric: tabular-nums; }
textarea.input { min-height: 80px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 560px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 7px 10px; cursor: pointer; min-height: 36px; }
.seg button:hover { background: var(--surface-2); }
.seg .seg-label { padding: 7px 12px; font-weight: 700; min-width: 140px; text-align: center; border-inline: 1px solid var(--line); display: grid; place-items: center; text-transform: capitalize; }

/* ---------- Estados ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--accent-soft); color: var(--accent); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-mute { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pos { color: var(--info); } .neg { color: var(--bad); } .zero { color: var(--accent); }

.alert { border-radius: var(--r); padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-bad { background: var(--bad-soft); color: var(--bad); }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert-ok { background: var(--accent-soft); color: var(--accent); }

/* ---------- Cierre del día ---------- */
.cierre-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
@media (max-width: 980px) { .cierre-grid { grid-template-columns: 1fr; } }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .two { grid-template-columns: 1fr; } }

.lines { display: grid; gap: 10px; }
.line { display: grid; grid-template-columns: 1fr minmax(0, 170px); gap: 12px; align-items: center; }
.line label { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.total-line { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px dashed var(--line-strong); padding-top: 10px; margin-top: 4px; font-weight: 700; }
.total-line .num { font-size: 17px; }

table { border-collapse: collapse; width: 100%; }
.tbl-wrap { overflow-x: auto; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th.n, .tbl td.n { text-align: right; }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--line-strong); border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--surface-2); }
.tbl tr.missing td { color: var(--muted); font-style: italic; }
.tbl-gastos td { padding: 5px 4px; }
.tbl-gastos td:first-child { padding-left: 0; }
.tbl-gastos .input { min-height: 36px; }
@media (max-width: 560px) {
  .tbl-gastos thead { display: none; }
  .tbl-gastos tr { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .tbl-gastos td { padding: 0 !important; border: 0; width: auto !important; }
  .tbl-gastos tbody td:first-child { grid-column: 1 / -1; }
  .tbl-gastos tfoot tr { grid-template-columns: 1fr 1fr 1fr; border: 0; border-top: 2px solid var(--line-strong); }
  .tbl-gastos tfoot td { border-top: 0; }
  .tbl-gastos tfoot td { text-align: right; }
  .tbl-gastos tfoot td:first-child { text-align: left; }
}
.week { display: flex; gap: 4px; }
.week span { flex: 1; height: 22px; border-radius: 3px; display: grid; place-items: center; font-size: 10px; font-weight: 700; }
.week .w-ok { background: var(--accent-soft); color: var(--accent); }
.week .w-bad { background: var(--bad-soft); color: var(--bad); }
.week .w-warn { background: var(--warn-soft); color: var(--warn); }
.week .w-none { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line-strong); }

.denoms td { padding: 4px 6px; }
.denoms td.d { font-family: var(--f-mono); font-weight: 600; white-space: nowrap; }
.denoms td.x { color: var(--muted); width: 14px; text-align: center; padding: 0; }
.denoms .qty { width: 72px; text-align: center; }
.denoms td.n { min-width: 110px; }

/* Tirilla de resumen */
.ticket { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 72px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
@media (max-width: 980px) { .ticket { position: static; } }
.ticket-h { padding: 16px 18px 12px; border-bottom: 1px dashed var(--line-strong); }
.ticket-h .t-title { font-family: var(--f-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ticket-h .t-place { font-family: var(--f-display); font-weight: 800; font-size: 18px; margin-top: 2px; }
.ticket-b { padding: 12px 18px; font-family: var(--f-mono); font-size: 13px; }
.t-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.t-row span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.t-row.sub { color: var(--muted); padding-left: 10px; }
.t-row.strong { font-weight: 700; }
.t-sep { border-top: 1px dashed var(--line-strong); margin: 8px 0; }
.t-diff { margin: 10px 18px 0; border-radius: 6px; padding: 12px 14px; display: grid; gap: 2px; }
.t-diff .lbl { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.t-diff .val { font-family: var(--f-display); font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.t-diff.ok { background: var(--accent-soft); color: var(--accent); }
.t-diff.bad { background: var(--bad-soft); color: var(--bad); }
.t-diff.info { background: var(--info-soft); color: var(--info); }
.ticket-f { padding: 14px 18px 18px; display: grid; gap: 8px; }
.ticket-f .btn { width: 100%; }
.dirty { font-size: 12px; color: var(--warn); text-align: center; }

/* Barra fija en celular con la diferencia del cierre */
.mbar { display: none; }
@media (max-width: 980px) {
  .mbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; align-items: center; gap: 12px; justify-content: space-between;
    background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0,0,0,.08);
    padding-block: 10px calc(10px + env(safe-area-inset-bottom, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .mbar .m-l { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
  .mbar .m-v { font-family: var(--f-display); font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
  .mbar.ok { color: var(--accent); } .mbar.bad { color: var(--bad); } .mbar.info { color: var(--info); }
  .has-mbar { padding-bottom: 96px; }
}
@media print { .mbar { display: none !important; } }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 13px; }
.log li { display: flex; gap: 10px; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Panel / reportes ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 4px; align-content: start; }
.kpi .k-l { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .k-v { font-family: var(--f-display); font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .k-s { font-size: 12px; color: var(--muted); }
.delta-up { color: var(--accent); font-weight: 700; } .delta-down { color: var(--bad); font-weight: 700; }

.stores { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.store { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 10px; }
.store-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.store-h b { font-family: var(--f-display); font-size: 16px; }
.store dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; }
.store dt { color: var(--muted); } .store dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.mix { display: flex; height: 12px; border-radius: 3px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.mix > div { height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--f-body); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .bar-hit:hover { fill: var(--ink); fill-opacity: .06; }
.chart-tip { position: fixed; pointer-events: none; z-index: 30; background: var(--band); color: var(--on-band); border-radius: 6px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow); font-variant-numeric: tabular-nums; }
.chart-tip b { display: block; margin-bottom: 4px; }

.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 13px; }
.bar-row .bt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar-row .track > div { height: 100%; background: var(--c-df); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding-block: 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 18px; }
.login-card .card-b { display: grid; gap: 14px; padding: 24px; }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand .brand-mark { width: 40px; height: 40px; font-size: 20px; border-radius: 8px; }
.demo-users { font-size: 13px; color: var(--muted); display: grid; gap: 6px; }
.demo-users button { justify-self: start; }

/* ---------- Modal y avisos ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(8, 14, 12, .5); z-index: 40; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 10px; width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: var(--shadow); }
.modal-h { padding: 18px 20px 0; }
.modal-b { padding: 16px 20px; display: grid; gap: 14px; }
.modal-f { padding: 0 20px 18px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--band); color: var(--on-band); padding: 10px 16px; border-radius: 8px; z-index: 50; box-shadow: var(--shadow); font-weight: 600; max-width: calc(100vw - 32px); }
.toast.err { background: var(--bad); color: #fff; }
.loading { padding: 48px; text-align: center; color: var(--muted); }

/* ---------- Impresión ---------- */
@media print {
  .top, .no-print, .demo-band, .ticket-f { display: none !important; }
  body { background: #fff; }
  .wrap { padding: 0; }
  .card, .ticket { border-color: #999; box-shadow: none; }
  .cierre-grid { grid-template-columns: 1fr 300px; }
  .input { border: 0; padding: 0; min-height: 0; background: none !important; color: #000 !important; }
}
