/* Layout: programa de gestión — barra de aplicación oscura fija, banda de indicadores, libro de existencias con barras de nivel y diario de movimientos agrupado por día */
:root {
  /* Colores de Starbody: rojo del logo sobre negro y grises neutros */
  --bg: #f2f2f3;
  --surface: #ffffff;
  --surface-2: #f7f7f8;
  --fg: #141416;
  --muted: #5f6168;
  --line: #e1e2e5;
  --line-strong: #c9cbd0;
  --bar: #0f0f10;
  --bar-fg: #f4f4f5;
  --bar-muted: #a1a1aa;
  --accent: #d7262c;
  --accent-hover: #b91f24;
  --accent-fg: #ffffff;
  --accent-soft: #fde4e4;
  --in: #0b7a55;
  --in-soft: #e0f0e9;
  --out: #b4441f;
  --out-soft: #fbe6de;
  --warn: #a86400;
  --warn-soft: #fcefd4;
  --warn-fg: #6e4300;
  --bad-fg: #962c0c;
  --ok-fg: #0b5a41;
  --track: #e7e7ea;
  --shadow: 0 1px 2px rgb(15 15 16 / 0.06), 0 2px 8px rgb(15 15 16 / 0.04);
  --font-display: "Familjen Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
/* Modo oscuro: el del sistema, salvo que se elija otro con el botón ☀️/🌙 (data-theme en <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0c0d; --surface: #161618; --surface-2: #1c1c1f; --fg: #ececee; --muted: #9b9ca3; --line: #2a2a2e; --line-strong: #38383d;
    --bar: #000000; --bar-fg: #f4f4f5; --bar-muted: #8b8b93;
    --accent: #ef3b41; --accent-hover: #ff5a5f; --accent-fg: #ffffff; --accent-soft: #3a1416;
    --in: #4fd09f; --in-soft: #153026; --out: #f08a62; --out-soft: #3a1c12;
    --warn: #f0b44c; --warn-soft: #36290c; --warn-fg: #f3c86b; --bad-fg: #ff9f7c; --ok-fg: #6fdcb1;
    --track: #2a2a2e; --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0c0d; --surface: #161618; --surface-2: #1c1c1f; --fg: #ececee; --muted: #9b9ca3; --line: #2a2a2e; --line-strong: #38383d;
  --bar: #000000; --bar-fg: #f4f4f5; --bar-muted: #8b8b93;
  --accent: #ef3b41; --accent-hover: #ff5a5f; --accent-fg: #ffffff; --accent-soft: #3a1416;
  --in: #4fd09f; --in-soft: #153026; --out: #f08a62; --out-soft: #3a1c12;
  --warn: #f0b44c; --warn-soft: #36290c; --warn-fg: #f3c86b; --bad-fg: #ff9f7c; --ok-fg: #6fdcb1;
  --track: #2a2a2e; --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

/* Botón ☀️/🌙 */
.theme-btn { width: 32px; height: 32px; min-height: 0; padding: 0; border-radius: 50%; background: transparent; color: var(--bar-fg); border: 1px solid rgb(255 255 255 / 0.22); flex: none; }
.theme-btn:hover { border-color: rgb(255 255 255 / 0.5); }
.theme-btn svg.i { width: 16px; height: 16px; }
.theme-float { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); left: calc(12px + env(safe-area-inset-left, 0px)); z-index: 30; background: var(--surface); color: var(--fg); border-color: var(--line-strong); }
* { box-sizing: border-box; }
html { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bar); }
[hidden] { display: none !important; }
.gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.inner { max-width: 1220px; margin: 0 auto; }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* App bar */
.appbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9; background: var(--bar); color: var(--bar-fg); border-bottom: 3px solid var(--accent); }
.brand h1 { font-style: italic; letter-spacing: 0.01em; }
.appbar .inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; padding-block: 8px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; flex: none; }
.mark svg.i { width: 20px; height: 20px; }
.mark.logo { background: #ffffff; padding: 2px; overflow: hidden; width: 42px; height: 42px; }
.mark.logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card .mark.logo { width: 56px; height: 56px; }
.brand h1 { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.005em; }
.live { display: flex; align-items: center; gap: 6px; font-size: 0.72rem; color: var(--bar-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--bar-muted); }
.live.on i { background: #4fd09f; box-shadow: 0 0 0 3px rgb(79 208 159 / 0.2); }
.bar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.who { font-size: 0.8rem; color: var(--bar-muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); padding: 8px 14px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; }
button:hover { border-color: var(--muted); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.ghost-bar { background: transparent; color: var(--bar-fg); border-color: rgb(255 255 255 / 0.18); }
button.ghost-bar:hover { border-color: rgb(255 255 255 / 0.4); }
button.danger { color: var(--out); }
button.link { border: 0; background: none; min-height: 32px; padding: 4px 6px; color: var(--accent); font-size: 0.88rem; }
button.link:hover { text-decoration: underline; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

main.gutter { padding-block: 22px 56px; }
main .inner { display: grid; gap: 22px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: grid; gap: 6px; box-shadow: var(--shadow); min-width: 0; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); }
.kpi .label { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; }
.kpi .value { font-family: var(--font-mono); font-size: 1.6rem; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .sub { font-size: 0.8rem; color: var(--muted); }
.kpi.alert .value, .kpi.alert .kpi-top { color: var(--out); }

.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--warn-soft); color: var(--warn-fg); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); border-radius: 10px; padding: 10px 14px; }
.banner p { margin: 0; flex: 1; min-width: 200px; }
.banner button { background: transparent; color: var(--warn-fg); border-color: color-mix(in srgb, var(--warn) 50%, transparent); min-height: 34px; padding: 6px 12px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-width: 0; box-shadow: var(--shadow); }
.panel-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 1.05rem; font-weight: 600; }
.panel-head .count { font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); margin-left: 6px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.search { position: relative; flex: 1 1 220px; min-width: 0; }
.search svg.i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
input, select { font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; min-height: 38px; }
.search input { width: 100%; padding-left: 34px; }
.chips { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }
.chips button { border: 0; border-radius: 0; min-height: 36px; padding: 6px 12px; font-size: 0.88rem; color: var(--muted); background: transparent; }
.chips button + button { border-left: 1px solid var(--line); }
.chips button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chips .n { font-family: var(--font-mono); font-size: 0.78rem; opacity: 0.85; }
#sort { font-size: 0.88rem; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover td { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
th.r, td.r { text-align: right; }
.pname { font-weight: 600; overflow-wrap: anywhere; }
#rows td:first-child { min-width: 200px; }
.psub { font-size: 0.78rem; color: var(--muted); font-family: var(--font-mono); }
.tag { display: inline-block; font-size: 0.78rem; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.stockcell { display: grid; gap: 5px; justify-items: end; min-width: 96px; }
.stock { font-family: var(--font-mono); font-size: 1.1rem; font-weight: 500; font-variant-numeric: tabular-nums; border-radius: 4px; padding: 0 4px; }
.level { width: 88px; height: 5px; border-radius: 99px; background: var(--track); overflow: hidden; }
.level span { display: block; height: 100%; border-radius: 99px; }
.level.ok span { background: var(--in); }
.level.low span { background: var(--warn); }
.level.zero span { background: var(--out); }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 0.74rem; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--in-soft); color: var(--ok-fg); }
.pill.low { background: var(--warn-soft); color: var(--warn-fg); }
.pill.zero { background: var(--out-soft); color: var(--bad-fg); }
.minline { font-size: 0.76rem; color: var(--muted); margin-top: 3px; }
.rowbtns { display: flex; gap: 6px; justify-content: flex-end; }
.ib { width: 38px; height: 38px; padding: 0; min-height: 0; }
.ib.in { color: var(--in); }
.ib.in:hover { background: var(--in-soft); border-color: var(--in); }
.ib.out { color: var(--out); }
.ib.out:hover { background: var(--out-soft); border-color: var(--out); }
.ib.edit { color: var(--muted); border-color: transparent; background: transparent; }
.ib.edit:hover { color: var(--fg); border-color: var(--line-strong); }
.show-sm { display: none; }

.empty { padding: 48px 20px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.empty .mark { width: 44px; height: 44px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.empty h3 { font-size: 1.1rem; }
.empty p { margin: 0; max-width: 46ch; }

.log { list-style: none; margin: 0; padding: 0 0 6px; max-height: 680px; overflow-y: auto; }
.day { position: sticky; top: 0; background: var(--surface-2); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; color: var(--muted); padding: 7px 16px; border-bottom: 1px solid var(--line); }
.mov { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.mov:last-child { border-bottom: 0; }
.dir { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; }
.dir svg.i { width: 15px; height: 15px; stroke-width: 2.2; }
.dir.in { background: var(--in-soft); color: var(--in); }
.dir.out { background: var(--out-soft); color: var(--out); }
.mov .what { min-width: 0; }
.mov .pn { font-weight: 500; overflow-wrap: anywhere; font-size: 0.92rem; }
.mov .meta { font-size: 0.78rem; color: var(--muted); overflow-wrap: anywhere; }
.mov .qty { text-align: right; display: grid; gap: 1px; }
.mov .q { font-family: var(--font-mono); font-weight: 500; font-variant-numeric: tabular-nums; }
.mov .q.in { color: var(--in); }
.mov .q.out { color: var(--out); }
.mov .after { font-family: var(--font-mono); font-size: 0.74rem; color: var(--muted); }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--fg); padding: 0; width: min(460px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgb(0 0 0 / 0.25); }
dialog::backdrop { background: rgb(8 16 13 / 0.5); }
dialog form, .card form { display: grid; gap: 16px; padding: 20px; }
.dlg-head { display: grid; gap: 2px; }
.dlg-head h2 { font-size: 1.2rem; font-weight: 600; overflow-wrap: anywhere; }
.dlg-head .sub { font-size: 0.85rem; color: var(--muted); }
.field { display: grid; gap: 5px; }
.field label { font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.field input { width: 100%; }
.hint { font-size: 0.76rem; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg { position: relative; }
.seg input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.seg label { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg label + input + label { border-left: 1px solid var(--line); }
.seg input:checked + label.in { background: var(--in-soft); color: var(--in); }
.seg input:checked + label.out { background: var(--out-soft); color: var(--out); }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: -2px; }
.qtyrow input { width: 100%; font-family: var(--font-mono); font-size: 1.1rem; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { min-height: 32px; padding: 4px 10px; font-family: var(--font-mono); font-size: 0.85rem; color: var(--muted); }
.preview { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.preview div { display: grid; gap: 1px; }
.preview .lbl { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 600; }
.preview .v { font-family: var(--font-mono); font-size: 1.25rem; font-weight: 500; }
.preview .arrow { color: var(--muted); }
.preview div:last-child { text-align: right; }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-top: 4px; }
.dlg-foot .spacer { flex: 1; }
.err { color: var(--out); font-size: 0.85rem; margin: 0; }
.confirm-del { background: var(--out-soft); color: var(--bad-fg); padding: 12px; border-radius: 8px; font-size: 0.9rem; display: grid; gap: 8px; }

/* Ventas */
.ventas-body { display: grid; grid-template-columns: 230px minmax(0, 1fr) 280px; }
.ventas-body > * { min-width: 0; padding: 14px 16px; }
.ventas-body > * + * { border-left: 1px solid var(--line); }
.vstats { display: grid; gap: 14px; align-content: start; }
.vstat { display: grid; gap: 2px; }
.vstat .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; color: var(--muted); }
.vstat .value { font-family: var(--font-mono); font-size: 1.35rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.vstat .sub { font-size: 0.8rem; color: var(--muted); }
.trend.up { color: var(--in); font-weight: 600; }
.trend.down { color: var(--out); font-weight: 600; }
.vtitle { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.vchart-svg svg { display: block; width: 100%; height: auto; }
.vchart-svg text { font-family: var(--font-mono); font-size: 11px; fill: var(--muted); }
.vchart-svg .val { fill: var(--fg); font-size: 10.5px; }
.vchart-svg .bar { fill: var(--accent); opacity: 0.45; }
.vchart-svg .bar.now { opacity: 1; }
.vchart-svg .base { stroke: var(--line-strong); }
.vchart-svg .grid { stroke: var(--line); stroke-dasharray: 3 4; }
.vtop ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.vtop li { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 8px; align-items: baseline; font-size: 0.9rem; }
.vtop .rk { font-family: var(--font-mono); color: var(--muted); font-size: 0.8rem; }
.vtop .nm { overflow-wrap: anywhere; }
.vtop .am { font-family: var(--font-mono); text-align: right; white-space: nowrap; }
.vtop .am small { display: block; color: var(--muted); font-size: 0.75rem; }
.seg-sm label { padding: 8px; font-size: 0.85rem; }
.mov .meta .sale { color: var(--in); font-weight: 600; }
.mov .undo { min-height: 0; padding: 0; font-size: 0.74rem; color: var(--muted); justify-self: end; }
.mov .undo:hover { color: var(--out); }
.mov.void .pn { text-decoration: line-through; color: var(--muted); }
.mov.void .q { color: var(--muted); }
.mov.void .meta .sale { color: var(--muted); }
.mov.void .dir { opacity: 0.45; }
.mov .voided { color: var(--out); font-weight: 600; }
@media (max-width: 1180px) {
  .ventas-body { grid-template-columns: 220px minmax(0, 1fr); }
  .vtop { grid-column: 1 / -1; border-left: 0 !important; border-top: 1px solid var(--line); }
}
@media (max-width: 700px) {
  .ventas-body { grid-template-columns: minmax(0, 1fr); }
  .ventas-body > * + * { border-left: 0; border-top: 1px solid var(--line); }
  .vstats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .vstat .value { font-size: 1.05rem; }
}
@media (max-width: 460px) {
  .vstats { grid-template-columns: minmax(0, 1fr); }
  .vstat .value { font-size: 1.25rem; }
}

/* Escáner */
.seg3 { grid-template-columns: repeat(3, 1fr); }
.seg3 label + input + label { border-left: 1px solid var(--line); }
.seg3 input:checked + label[for="scVer"] { background: var(--accent-soft); color: var(--accent); }
.qtyrow { display: flex; gap: 8px; align-items: stretch; }
.qtyrow input { flex: 1; min-width: 0; }
.video-box { position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: 48vh; border-radius: 10px; overflow: hidden; background: #000; }
.video-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-line { position: absolute; left: 10%; right: 10%; top: 50%; height: 2px; background: #ff4d4d; box-shadow: 0 0 10px #ff4d4d; }
.video-box.off .scan-line { display: none; }
.video-box.off::after { content: "Cámara apagada"; position: absolute; inset: 0; display: grid; place-items: center; color: #9aa; font-size: 0.9rem; }
@media (prefers-reduced-motion: no-preference) {
  .scan-line { animation: scan 1.6s ease-in-out infinite alternate; }
  @keyframes scan { from { top: 25%; } to { top: 75%; } }
}

/* Pestañas Tienda / Socios */
.view { display: grid; gap: 22px; }
.tabs { display: flex; gap: 4px; padding-top: 2px; }
.tab { background: transparent; border: 0; border-radius: 8px 8px 0 0; color: var(--bar-muted); min-height: 40px; padding: 8px 16px; font-weight: 600; position: relative; }
.tab:hover { color: var(--bar-fg); }
.tab[aria-selected="true"] { background: var(--bg); color: var(--fg); }
.tab-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--out); color: #fff; font-size: 0.72rem; font-family: var(--font-mono); display: inline-grid; place-items: center; }

/* Socios */
.seg4 { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 1fr; }
.seg4 label + input + label { border-left: 1px solid var(--line); }
.seg4 input:checked + label { background: var(--accent-soft); color: var(--accent); }
.ib.pay { color: var(--accent); width: auto; padding: 0 12px; gap: 6px; font-size: 0.88rem; }
.ib.pay:hover { background: var(--accent-soft); border-color: var(--accent); }
.ib.wa { color: #1fa855; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line-strong); border-radius: 8px; }
.ib.wa:hover { background: #e3f6ea; border-color: #1fa855; }
.ib.wa.off { opacity: 0.35; pointer-events: none; }
.due { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.due-sub { font-size: 0.76rem; color: var(--muted); }
.due-sub.bad { color: var(--bad-fg); font-weight: 600; }
.due-sub.warn { color: var(--warn-fg); font-weight: 600; }
.pill.off { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.first-pay { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.mes-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.mes-list li { display: flex; justify-content: space-between; gap: 10px; font-size: 0.9rem; }
.mes-list .am { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tarifas-list { display: grid; gap: 8px; max-height: 45vh; overflow-y: auto; }
.tarifa-row, .tarifa-new { display: grid; grid-template-columns: minmax(0, 1fr) 96px 104px auto; gap: 8px; align-items: center; }
.tarifa-row input, .tarifa-row select, .tarifa-new input, .tarifa-new select { min-width: 0; width: 100%; }
.tarifa-row.inactiva input { color: var(--muted); text-decoration: line-through; }
.tarifa-new { padding-top: 10px; border-top: 1px dashed var(--line-strong); }
@media (max-width: 600px) {
  .tarifa-row, .tarifa-new { grid-template-columns: minmax(0, 1fr) 80px; }
  .ib.pay span { display: none; }
  .ib.pay { width: 38px; padding: 0; }
  .tab { padding: 8px 12px; }
}

/* Elegir semana en Ventas */
.week-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-right: auto; margin-left: 12px; }
.week-nav .ib { width: 34px; height: 34px; font-size: 1.2rem; line-height: 1; }
.week-lbl { font-weight: 600; min-width: 110px; text-align: center; font-size: 0.92rem; }
#vThisW { min-height: 34px; padding: 4px 10px; font-size: 0.85rem; color: var(--accent); }
@media (max-width: 600px) { .week-nav { margin-left: 0; width: 100%; justify-content: center; } }

/* Secciones de productos */
.sec-bar { padding: 10px 16px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.sec-chips { display: flex; gap: 6px; width: max-content; }
.sec-chips button { min-height: 32px; padding: 4px 12px; border-radius: 999px; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.sec-chips button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.sec-chips .n, .sec-row .n { font-family: var(--font-mono); font-size: 0.75rem; opacity: 0.8; }
.sec-row th { background: var(--surface-2); color: var(--fg); font-size: 0.78rem; padding: 8px 14px; border-top: 1px solid var(--line); }
tbody tr.sec-row:hover th { background: var(--surface-2); }
tbody tr.sec-row:first-child th { border-top: 0; }

/* Fotos de productos */
.pcell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pcell > div { min-width: 0; }
.thumb { flex: none; width: 48px; height: 48px; border-radius: 8px; overflow: hidden; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.ph { background: hsl(var(--h) 45% 92%); color: hsl(var(--h) 45% 30%); border-color: hsl(var(--h) 35% 82%); font-weight: 700; font-size: 0.9rem; letter-spacing: 0.02em; }
:root[data-theme="dark"] .thumb.ph { background: hsl(var(--h) 30% 20%); color: hsl(var(--h) 60% 80%); border-color: hsl(var(--h) 25% 30%); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .thumb.ph { background: hsl(var(--h) 30% 20%); color: hsl(var(--h) 60% 80%); border-color: hsl(var(--h) 25% 30%); }
}
@media (max-width: 600px) { .thumb { width: 42px; height: 42px; } .pcell { gap: 10px; } }
.photo-field { display: flex; gap: 14px; align-items: center; }
.photo-prev { flex: none; width: 96px; height: 96px; border-radius: 10px; overflow: hidden; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; }
.photo-prev img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-prev.empty { background: var(--surface-2); border-style: dashed; border-color: var(--line-strong); color: var(--muted); }
.photo-prev.empty .i { width: 28px; height: 28px; }
.photo-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.photo-btns .hint { flex-basis: 100%; }

/* Vista de productos en tarjetas */
.view-chips button { gap: 6px; padding: 6px 12px; }
.view-chips .i { width: 16px; height: 16px; }
.pcards { padding: 8px 18px 22px; display: grid; gap: 26px; }
.psec-h { display: flex; align-items: center; gap: 10px; font-size: 1rem; font-weight: 700; margin: 10px 0 12px; }
.psec-h::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: var(--accent); }
.psec-h .n { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 500; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.pcard { position: relative; display: flex; flex-direction: column; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; transition: box-shadow 0.15s, border-color 0.15s; }
.pcard:hover { border-color: var(--line-strong); box-shadow: 0 6px 20px rgb(0 0 0 / 0.08); }
.pc-photo { display: block; width: 100%; padding: 0; min-height: 0; border: 0; border-radius: 0; background: #fff; aspect-ratio: 4 / 3; overflow: hidden; }
.pc-img { display: grid; place-items: center; width: 100%; height: 100%; }
.pc-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.25s; }
.pcard:hover .pc-img img { transform: scale(1.04); }
.pc-img.ph { font-size: 2.2rem; font-weight: 700; background: hsl(var(--h) 45% 92%); color: hsl(var(--h) 45% 30%); }
:root[data-theme="dark"] .pc-img.ph { background: hsl(var(--h) 30% 20%); color: hsl(var(--h) 60% 80%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pc-img.ph { background: hsl(var(--h) 30% 20%); color: hsl(var(--h) 60% 80%); } }
.pcard.zero .pc-img { filter: grayscale(1); opacity: 0.6; }
.pc-pill { position: absolute; top: 10px; left: 10px; box-shadow: 0 2px 6px rgb(0 0 0 / 0.15); }
.pc-body { display: grid; gap: 8px; padding: 12px 14px 4px; flex: 1; align-content: start; }
.pc-name { font-weight: 600; line-height: 1.3; min-height: 2.6em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.pc-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pc-price { font-family: var(--font-mono); font-weight: 600; font-size: 1.05rem; }
.pc-stock { font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
.pc-stock b { font-family: var(--font-mono); font-size: 1.05rem; color: var(--fg); border-radius: 4px; padding: 0 2px; }
.pcard.low .pc-stock b { color: var(--warn-fg); }
.pcard.zero .pc-stock b { color: var(--bad-fg); }
.pcard .level { width: 100%; }
.pc-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 14px 14px; }
.pc-btns button { min-height: 40px; min-width: 0; padding: 6px 4px; gap: 4px; font-size: 0.86rem; font-weight: 600; white-space: nowrap; overflow: hidden; }
.pc-btns .i { flex: none; width: 16px; height: 16px; }
.pc-btns .out { color: var(--out); }
.pc-btns .out:hover { background: var(--out-soft); border-color: var(--out); }
.pc-btns .in { color: var(--in); }
.pc-btns .in:hover { background: var(--in-soft); border-color: var(--in); }
@media (max-width: 600px) {
  .pcards { padding: 6px 12px 18px; gap: 20px; }
  .pgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pc-body { padding: 10px 10px 2px; }
  .pc-btns { padding: 8px 10px 10px; gap: 6px; }
  .pc-btns span { display: none; }
  .pc-btns .i { width: 20px; height: 20px; }
  .pc-price, .pc-stock b { font-size: 0.95rem; }
  .view-chips { width: auto; }
  .view-chips span { display: none; }
}

/* Caja: caja actual y cierres de caja */
.caja-tabs { width: 100%; }
.caja-tabs button { flex: 1; gap: 6px; }
.caja-tabs .i { width: 16px; height: 16px; }
.caja-panel { display: grid; gap: 14px; }
.caja-desde { font-size: 0.9rem; color: var(--muted); }
.caja-desde b { color: var(--fg); }
.caja-ef { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; }
.caja-ef > div { display: grid; align-content: start; gap: 2px; border-radius: 12px; padding: 14px 16px; }
.ce-main { background: var(--in-soft); color: var(--ok-fg); }
.ce-side { background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.ce-label { font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.ce-value { font-family: var(--font-mono); font-size: 2rem; font-weight: 600; line-height: 1.15; color: var(--fg); }
.ce-main .ce-value { color: var(--ok-fg); }
.ce-value.small { font-size: 1.15rem; margin-bottom: 4px; }
.ce-sub { font-size: 0.8rem; }
@media (max-width: 460px) { .caja-ef { grid-template-columns: 1fr; } .ce-value { font-size: 1.7rem; } }
.cierres-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 52vh; overflow-y: auto; }
.cierres-vacio { padding: 18px 4px; font-size: 0.9rem; }
.cierres-dia { display: flex; justify-content: space-between; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; color: var(--muted); padding: 10px 4px 2px; }
.cierre-item { width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "hora quien total" "hora quien cuadre"; gap: 2px 12px; align-items: center; text-align: left; padding: 10px 12px; border-radius: 10px; background: var(--surface); }
.cierre-item:hover { background: var(--surface-2); }
.cierre-item.reab { opacity: 0.6; }
.ci-hora { grid-area: hora; font-family: var(--font-mono); font-size: 0.86rem; font-weight: 600; }
.ci-quien { grid-area: quien; font-size: 0.86rem; color: var(--muted); overflow-wrap: anywhere; }
.ci-total { grid-area: total; font-family: var(--font-mono); font-weight: 600; text-align: right; }
.ci-cuadre { grid-area: cuadre; font-size: 0.76rem; font-weight: 600; text-align: right; }
.ci-cuadre.ok, .cd-res.ok .am { color: var(--ok-fg); }
.ci-cuadre.bad, .cd-res.bad .am { color: var(--bad-fg); }
.cierre-det { display: grid; gap: 14px; }
.cd-head { border-radius: 10px; padding: 12px 14px; font-size: 0.9rem; line-height: 1.5; background: var(--surface-2); }
.cd-head.ok { background: var(--in-soft); color: var(--ok-fg); }
.cd-head.bad { background: var(--warn-soft); color: var(--warn-fg); }
.cd-dia { font-weight: 700; font-size: 1rem; text-transform: capitalize; }
.cd-reab { margin-top: 4px; font-weight: 600; }

/* Caja sin el apartado de Socios: se quita la columna «Cuotas» */
.sin-cuotas .caja-table th:nth-child(3), .sin-cuotas .caja-table td:nth-child(3) { display: none; }

/* Equipo (jefe / empleados) y registro de actividad */
body:not([data-rol="jefe"]) .solo-jefe { display: none !important; }
/* El resumen (cifras de arriba y Ventas/Cobros) solo lo ve el jefe */
body:not([data-rol="jefe"]) .lock-bar,
body:not([data-rol="jefe"]) .view > .kpis,
body:not([data-rol="jefe"]) .view > .panel.ventas { display: none !important; }
.por { font-weight: 600; color: var(--fg); }
.dir.warn { background: var(--warn-soft); color: var(--warn-fg); }
.dir.neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.eq-list { list-style: none; margin: 0; padding: 0; }
.eq-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.eq-item.off { opacity: 0.6; }
.eq-avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; background: var(--surface-2); color: var(--fg); border: 1px solid var(--line); }
.eq-avatar.jefe { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.eq-who { line-height: 1.45; min-width: 0; overflow-wrap: anywhere; font-size: 0.92rem; }
.eq-who .muted { font-size: 0.82rem; }
.eq-rol { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); margin-left: 4px; }
.eq-rol.jefe { background: var(--accent-soft); color: var(--accent); }
.eq-state { display: flex; align-items: center; gap: 10px; }
.eq-help { margin: 0; padding: 12px 16px 16px; font-size: 0.86rem; line-height: 1.5; }
.act-filtros { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.act-filtros select { min-height: 36px; }
.act-resumen { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 0; }
.act-resumen:empty { display: none; }
.act-chip { font-size: 0.82rem; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.act-chip b { color: var(--fg); margin-right: 2px; }
.act-log { max-height: 720px; margin-top: 10px; border-top: 1px solid var(--line); }
.mov.act { grid-template-columns: 30px minmax(0, 1fr); }
@media (max-width: 600px) {
  .eq-item { grid-template-columns: auto minmax(0, 1fr); }
  .eq-state { grid-column: 2; justify-content: space-between; }
  .act-filtros { width: 100%; }
  .act-filtros select { flex: 1; }
}

/* Resumen oculto con contraseña (cifras de arriba + Ventas/Cobros) */
.lock-bar .panel-head { border-bottom: 0; padding: 8px 16px; }
.lock-bar .panel-head h2 { font-size: 0.95rem; }
.lock-bar button { min-height: 34px; padding: 4px 10px; font-size: 0.85rem; gap: 4px; }
.view.locked > .kpis,
.view.locked > .panel.ventas { display: none; }

/* Carrito */
dialog.wide { width: min(620px, calc(100vw - 32px)); }
.cart-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--bar); color: var(--bar-fg); padding-block: 10px calc(10px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -6px 20px rgb(0 0 0 / 0.25); }
.cart-bar-in { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cart-bar .spacer { flex: 1; }
.cart-bar button:not(.primary) { background: transparent; color: var(--bar-fg); border-color: rgb(255 255 255 / 0.2); }
.cart-ico { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; }
.cart-sum b { font-family: var(--font-mono); font-size: 1.15rem; }
.cart-sum span { color: var(--bar-muted); margin-left: 6px; font-size: 0.88rem; }
body.has-cart main.gutter { padding-bottom: 110px; }
.cart-search { position: relative; }
.cart-results { list-style: none; margin: 4px 0 0; padding: 4px; position: absolute; left: 0; right: 0; z-index: 2; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow); max-height: 240px; overflow-y: auto; }
.cart-results li button { width: 100%; justify-content: space-between; border: 0; background: transparent; min-height: 38px; text-align: left; }
.cart-results li button:hover, .cart-results li button:focus-visible { background: var(--surface-2); }
.cart-results .st { font-size: 0.78rem; color: var(--muted); font-family: var(--font-mono); }
.cart-lines { display: grid; gap: 6px; max-height: 40vh; overflow-y: auto; }
.cart-line { display: grid; grid-template-columns: minmax(0, 1fr) 96px auto 90px 32px; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.cart-line .nm { font-weight: 600; overflow-wrap: anywhere; font-size: 0.92rem; }
.cart-line .sub { font-size: 0.76rem; color: var(--muted); }
.cart-line input { width: 100%; font-family: var(--font-mono); min-height: 34px; padding: 4px 8px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.qty button { border: 0; border-radius: 0; min-height: 32px; width: 30px; padding: 0; }
.qty span { min-width: 30px; text-align: center; font-family: var(--font-mono); }
.cart-line .tot { text-align: right; font-family: var(--font-mono); font-weight: 500; }
.cart-line .rm { width: 32px; height: 32px; min-height: 0; padding: 0; border-color: transparent; color: var(--muted); }
.cart-line .rm:hover { color: var(--out); }
.cart-total { display: flex; justify-content: space-between; align-items: end; gap: 12px; padding: 10px 14px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.cart-total .lbl { display: block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 600; }
.cart-total .v { font-family: var(--font-mono); font-size: 1.7rem; font-weight: 500; }
.cart-profit { font-size: 0.85rem; color: var(--in); text-align: right; }
.change { font-family: var(--font-mono); font-size: 1.25rem; min-height: 38px; display: flex; align-items: center; }
@media (max-width: 600px) {
  .cart-line { grid-template-columns: minmax(0, 1fr) auto 32px; }
  .cart-line .price, .cart-line .tot { grid-column: span 1; }
  .cart-line .price { grid-row: 2; grid-column: 1; }
  .cart-line .tot { grid-row: 2; grid-column: 2 / 4; }
}

/* Cierre de caja */
.caja-table th, .caja-table td { padding: 8px 10px; }
.caja-table td.r, .caja-table th.r { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.caja-table tfoot td { font-weight: 700; border-top: 2px solid var(--line-strong); border-bottom: 0; }
.caja-count { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.xstatus.ok { background: var(--in-soft); color: var(--ok-fg); border-color: transparent; }
.xstatus.bad { background: var(--out-soft); color: var(--bad-fg); border-color: transparent; }

/* Copias de seguridad */
.backup { display: grid; gap: 10px; padding-top: 16px; margin-top: 4px; border-top: 1px solid var(--line); }
.backup .dlg-head h2 { font-size: 1.05rem; }

/* Excel */
.xstatus { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; font-size: 0.9rem; overflow-wrap: anywhere; }
.xstatus b { font-family: var(--font-mono); font-weight: 500; }
.xstatus.warn { background: var(--warn-soft); color: var(--warn-fg); border-color: transparent; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
.xdot { width: 7px; height: 7px; border-radius: 50%; background: #f0b44c; }

/* Login / setup */
.screen { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding-block: 32px; }
.card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.card .brand { padding: 20px 20px 0; }
.card .brand h1 { font-size: 1.25rem; }
.card button.primary { width: 100%; min-height: 44px; }
.card code { font-family: var(--font-mono); font-size: 0.85em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; overflow-wrap: anywhere; }
.card ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--bar); color: var(--bar-fg); padding: 10px 16px; border-radius: 8px; font-size: 0.9rem; z-index: 20; max-width: calc(100vw - 32px); display: flex; gap: 8px; align-items: center; box-shadow: 0 8px 24px rgb(0 0 0 / 0.25); }
.toast svg.i { color: #4fd09f; }
.toast.bad svg.i { color: var(--out); }

@media (max-width: 1180px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .hide-sm { display: none; }
  .show-sm { display: block; }
  td, th { padding: 10px 8px; }
  td:first-child, th:first-child { padding-left: 14px; }
  #rows td:first-child { min-width: 0; }
  .grid2 { grid-template-columns: 1fr; }
  .chips { width: 100%; }
  .chips button { flex: 1; }
  #sort { width: 100%; }
  .lbl-long, .who { display: none; }
  .level { width: 64px; }
  .stockcell { min-width: 64px; }
  .kpi .value { font-size: 1.3rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .stock.flash { animation: flash 1s ease-out; }
  @keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
  .level span { transition: width 0.4s ease; }
}
