/* ERP POLANCO — tema claro y oscuro (automático o escogido por el usuario), colores del logo ERP POLANCO: azul y rojo dominicanos.
   Los colores son variables: todas las pantallas cambian juntas. */
:root {
  --ink: #0a1f3d; --ink-2: #102b52; --ink-3: #1a3a68; --ink-fg: #c3d0e2; --ink-strong: #ffffff; --ink-label: #7f93b0;
  --bg: #f3f5f9; --surface: #ffffff; --surface-2: #f8f9fb; --fg: #18212d; --muted: #5f6c7f; --line: #e3e7ee; --line-2: #d3d9e2;
  --field: #ffffff; --field-line: #d3d9e2;
  --accent: #0b3f80; --accent-hover: #002d62; --accent-soft: #e6eef8; --accent-fg: #ffffff;
  --brand-red: #ce1126; --side-accent: #ff6b78;
  --ok: #17784a; --ok-soft: #e2f3e9; --warn: #9a5c00; --warn-soft: #fcf0d9;
  --bad: #be3329; --bad-soft: #fbe7e5; --info: #2a5db0; --info-soft: #e6eefb;
  --ring: color-mix(in srgb, var(--accent) 28%, transparent);
  --shadow: 0 1px 2px rgba(20,28,40,.05), 0 1px 3px rgba(20,28,40,.04);
  --shadow-lg: 0 12px 32px rgba(20,28,40,.14), 0 2px 6px rgba(20,28,40,.06);
  --f-ui: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --f-num: "IBM Plex Mono", ui-monospace, "Cascadia Mono", monospace;
  --r: 12px; --r-sm: 8px; --h-ctl: 38px;
  color-scheme: light;
}
/* Oscuro: cuando el usuario lo escoge, o en automático si el equipo está en modo oscuro */
:root[data-theme="dark"] {
  --ink: #06142a; --ink-2: #0e2243; --ink-3: #18305a; --ink-fg: #a9b9d0; --ink-strong: #ffffff; --ink-label: #627897;
  --bg: #0b1322; --surface: #121c2e; --surface-2: #162236; --fg: #e6ebf2; --muted: #93a3ba; --line: #22304a; --line-2: #2d3d5a;
  --field: #0d1626; --field-line: #2c3b57;
  --accent: #5b9bf0; --accent-hover: #7db0f5; --accent-soft: #142742; --accent-fg: #04101f;
  --brand-red: #f0505f;
  --ok: #4cc386; --ok-soft: #133024; --warn: #e6a64a; --warn-soft: #362812;
  --bad: #f2786e; --bad-soft: #3a1c1a; --info: #82a9ee; --info-soft: #1a2944;
  --shadow: 0 1px 2px rgba(0,0,0,.35);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.3);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --ink: #06142a; --ink-2: #0e2243; --ink-3: #18305a; --ink-fg: #a9b9d0; --ink-strong: #ffffff; --ink-label: #627897;
  --bg: #0b1322; --surface: #121c2e; --surface-2: #162236; --fg: #e6ebf2; --muted: #93a3ba; --line: #22304a; --line-2: #2d3d5a;
  --field: #0d1626; --field-line: #2c3b57;
  --accent: #5b9bf0; --accent-hover: #7db0f5; --accent-soft: #142742; --accent-fg: #04101f;
  --brand-red: #f0505f;
  --ok: #4cc386; --ok-soft: #133024; --warn: #e6a64a; --warn-soft: #362812;
  --bad: #f2786e; --bad-soft: #3a1c1a; --info: #82a9ee; --info-soft: #1a2944;
  --shadow: 0 1px 2px rgba(0,0,0,.35);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.3);
  color-scheme: dark; } }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--f-ui); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.code { font-family: var(--f-num); font-size: 12.5px; color: var(--muted); }
.muted { color: var(--muted); }

/* ---------- Estructura: barra lateral + contenido ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100%; }
.side { background: var(--ink); color: var(--ink-fg); padding: 16px 12px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--ink-3) transparent; border-right: 1px solid color-mix(in srgb, var(--ink-3) 60%, transparent); }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 10px; color: var(--ink-strong); font-weight: 800; font-size: 16px; letter-spacing: -.01em; text-decoration: none; }
.brand:hover { color: var(--ink-strong); }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: #fff; border: 1px solid rgba(0,45,98,.15); display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0,45,98,.18); flex: none; }
.brand-mark svg { width: 18px; height: 18px; }
.brand small { display: block; font-size: 11px; font-weight: 600; color: var(--ink-label); letter-spacing: 0; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-label); font-weight: 700; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-sm); color: var(--ink-fg); text-decoration: none; font-weight: 500; font-size: 13.5px; transition: background .12s, color .12s; }
.nav a:hover { background: var(--ink-2); color: var(--ink-strong); }
.nav > a[aria-current="page"] { background: rgba(255,255,255,.09); color: var(--ink-strong); }
.nav > a[aria-current="page"] svg { color: var(--side-accent); opacity: 1; }
.nav svg { width: 17px; height: 17px; flex: none; opacity: .75; }
.nav-group summary { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-sm); color: var(--ink-fg); font-weight: 500; font-size: 13.5px; cursor: pointer; list-style: none; transition: background .12s, color .12s; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary:hover { background: var(--ink-2); color: var(--ink-strong); }
.nav-group[open] summary { color: var(--ink-strong); }
.nav-group[open] summary svg { opacity: 1; }
.nav-group:has(a[aria-current="page"]) > summary svg { color: var(--side-accent); }
.nav-group .caret { margin-left: auto; font-size: 10px; transition: transform .15s; opacity: .6; }
.nav-group:not([open]) .caret { transform: rotate(-90deg); }
.nav-sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 6px 18px; padding-left: 9px; border-left: 1px solid var(--ink-3); }
.nav-sub a { padding: 5px 10px; font-size: 13px; color: color-mix(in srgb, var(--ink-fg) 88%, transparent); }
.nav-sub a[aria-current="page"] { color: var(--ink-strong); background: var(--ink-2); box-shadow: inset 2px 0 0 var(--side-accent); font-weight: 600; }
.nav .badge { margin-left: auto; font-size: 11px; background: var(--brand-red); color: #fff; border-radius: 99px; padding: 0 7px; font-weight: 700; }
.side-foot { margin-top: auto; font-size: 11.5px; color: var(--ink-label); padding: 10px; border-top: 1px solid var(--ink-2); display: flex; align-items: center; gap: 8px; }
.side-foot .dot { width: 7px; height: 7px; border-radius: 50%; background: #3ccf86; box-shadow: 0 0 0 3px rgba(60,207,134,.18); flex: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 28px; min-height: 60px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.menu-btn, .btn.menu-btn { display: none; }
.empresa { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 4px 0 10px; height: var(--h-ctl); background: var(--surface-2); margin: 0; }
.empresa label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.empresa select { border: 0; background: transparent; font-weight: 700; padding: 4px; max-width: 46vw; cursor: pointer; }
.search { flex: 1; min-width: 180px; max-width: 560px; position: relative; margin: 0; }
.search input { width: 100%; height: var(--h-ctl); padding: 0 40px 0 38px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); transition: border-color .12s, box-shadow .12s, background .12s; }
.search input:focus { background: var(--field); border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); outline: none; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); }
kbd { font: 600 11px var(--f-num); color: var(--muted); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--surface); }
.top-der { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { width: var(--h-ctl); height: var(--h-ctl); display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--muted); cursor: pointer; transition: color .12s, border-color .12s, background .12s; }
.icon-btn:hover { color: var(--fg); border-color: var(--line-2); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
.user { display: flex; align-items: center; gap: 8px; font-weight: 600; position: relative; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 13px; border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); cursor: pointer; }
.user-menu { position: absolute; right: 0; top: 46px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg); min-width: 230px; padding: 6px; z-index: 20; display: flex; flex-direction: column; }
.user-menu a, .user-menu button { text-align: left; padding: 8px 10px; border-radius: 6px; border: 0; background: transparent; color: var(--fg); text-decoration: none; cursor: pointer; width: 100%; font-weight: 500; }
.user-menu a:hover, .user-menu button:hover { background: var(--surface-2); color: var(--fg); }
.user-menu .um-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.user-menu .um-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; padding: 6px 10px 4px; }
.tema { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 0 4px 4px; }
.tema button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px !important; font-size: 12px; border: 1px solid var(--line) !important; text-align: center !important; }
.tema button[aria-pressed="true"] { border-color: var(--accent) !important; background: var(--accent-soft) !important; color: var(--accent) !important; font-weight: 700; }
.tema svg { width: 16px; height: 16px; }

.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 18px; width: 100%; max-width: 1600px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-bottom: 2px; }
h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.025em; line-height: 1.2; text-wrap: balance; }
h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.sub { color: var(--muted); margin: 4px 0 0; }

/* ---------- Botones ---------- */
.btn { border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--r-sm); padding: 0 14px; min-height: var(--h-ctl); font-weight: 600; font-size: 13.5px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--fg); box-shadow: var(--shadow); transition: background .12s, border-color .12s, box-shadow .12s, color .12s; white-space: nowrap; }
.btn:hover { border-color: var(--muted); color: var(--fg); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 4px 12px color-mix(in srgb, var(--accent) 22%, transparent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-fg); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; min-height: 56px; }
.card-b { padding: 18px; }
.card > .table-wrap:first-child, .card > table:first-child { border-radius: var(--r) var(--r) 0 0; }

.msgs { display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 11px 14px; border-radius: var(--r-sm); font-weight: 600; border: 1px solid transparent; border-left-width: 3px; }
.msg { border-left-color: currentColor !important; }
.msg.success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 20%, transparent); }
.msg.error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 20%, transparent); }
.msg.warning, .msg.info { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 20%, transparent); }

/* ---------- Tablero ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { padding: 16px 18px 15px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--kpi, var(--accent)); }
.kpi:nth-child(2) { --kpi: var(--info); } .kpi:nth-child(3) { --kpi: var(--ok); } .kpi:nth-child(4) { --kpi: var(--warn); }
.kpi .lbl { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.kpi .lbl a { text-decoration: none; }
.kpi .lbl a:hover { color: var(--accent) !important; }
.kpi .val { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.kpi .delta { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.up { color: var(--ok) !important; } .down { color: var(--bad) !important; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }

.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font: 11px var(--f-num); }
.chart .grid { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .bar { fill: var(--accent); transition: opacity .12s; }
.chart .bar:hover { opacity: .8; }
/* Gráfico del tablero: ventas, compras y ganancia (paleta categórica validada para daltonismo, claro y oscuro) */
.viz { --s-venta: #2a78d6; --s-compra: #eb6834; --s-ganancia: #1baf7a; --s-perdida: #e34948; position: relative; }
:root[data-theme="dark"] .viz { --s-venta: #3987e5; --s-compra: #d95926; --s-ganancia: #199e70; --s-perdida: #e66767; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .viz { --s-venta: #3987e5; --s-compra: #d95926; --s-ganancia: #199e70; --s-perdida: #e66767; } }
.viz-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; padding: 16px 18px 4px; }
.viz-head h2 { margin: 0; font-size: 15px; }
.viz-head .sub { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.viz-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; padding: 12px 18px 4px; }
.viz-stat { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface-2); }
.viz-stat .k { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--muted); }
.viz-stat .k i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.viz-stat .v { display: block; margin-top: 4px; font: 600 17px var(--f-num); color: var(--fg); letter-spacing: -.01em; white-space: nowrap; }
.viz-stat .d { display: block; margin-top: 1px; font-size: 11.5px; color: var(--muted); }
.viz-plot { position: relative; padding: 6px 12px 0 4px; }
.viz-plot svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz-plot text { fill: var(--muted); font: 11px var(--f-num); }
.viz-plot .grid { stroke: var(--line); stroke-width: 1; }
.viz-plot .base { stroke: var(--line-2); stroke-width: 1; }
.viz-plot .col { fill: transparent; }
.viz-plot .col.on { fill: color-mix(in srgb, var(--fg) 5%, transparent); }
.viz-plot .m-venta { fill: var(--s-venta); } .viz-plot .m-compra { fill: var(--s-compra); }
.viz-plot .m-ganancia { fill: var(--s-ganancia); } .viz-plot .m-perdida { fill: var(--s-perdida); }
.viz-plot .barras { transition: opacity .15s; } .viz-plot.hover .barras:not(.on) { opacity: .45; }
.viz-tip { position: absolute; pointer-events: none; z-index: 3; min-width: 230px; text-align: left; white-space: nowrap; background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(10, 20, 40, .14); padding: 10px 12px; font-size: 12.5px; opacity: 0; transform: translateY(4px);
  transition: opacity .12s, transform .12s; }
.viz-tip.on { opacity: 1; transform: none; }
.viz-tip .vt-t { font-weight: 700; margin-bottom: 6px; color: var(--fg); }
.viz-tip .vt-f { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 2px 0; color: var(--muted); }
.viz-tip .vt-f span:first-child { display: inline-flex; align-items: center; gap: 7px; }
.viz-tip .vt-f i { width: 9px; height: 9px; border-radius: 2px; }
.viz-tip .vt-f b { font: 600 12.5px var(--f-num); color: var(--fg); }
.viz-tip .vt-mg { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.viz-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 18px 14px; font-size: 12px; color: var(--muted); }
.viz-foot button { background: none; border: 0; color: var(--accent); font: 600 12px inherit; cursor: pointer; padding: 4px 0; }
.viz-tabla { padding: 0 18px 14px; } .viz-tabla table { font-size: 12.5px; }
.seg-periodo { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; }
.seg-periodo button { border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; font: 600 12.5px inherit; color: var(--muted); cursor: pointer; transition: background .12s, color .12s; }
.seg-periodo button:hover { color: var(--fg); }
.seg-periodo button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(10, 20, 40, .12), 0 0 0 1px var(--line); }
.seg-periodo button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s; }
tbody tr.click { cursor: pointer; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line); }
.r { text-align: right; }
.strong { font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 99px; white-space: nowrap; line-height: 1.6; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill.ok { color: var(--ok); background: var(--ok-soft); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.bad { color: var(--bad); background: var(--bad-soft); }
.pill.info { color: var(--info); background: var(--info-soft); }
.pill.gray { color: var(--muted); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--fg); transition: background .1s; }
.list-item:hover { background: var(--surface-2); color: var(--fg); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .s { color: var(--muted); font-size: 12.5px; }

.toolbar { display: flex; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; margin: 0; }
.toolbar input:not([type=checkbox]):not([type=radio]), .toolbar select { height: var(--h-ctl); border: 1px solid var(--field-line); border-radius: var(--r-sm); padding: 0 10px; background: var(--field); }
.toolbar input[type=search] { flex: 1; min-width: 180px; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); outline: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-2); background: var(--surface); border-radius: 99px; padding: 5px 12px; cursor: pointer; font-weight: 600; font-size: 13px; text-decoration: none; color: var(--fg); transition: background .12s, border-color .12s; }
.chip:hover { border-color: var(--muted); color: var(--fg); }
.chip[aria-current="true"] { background: var(--fg); color: var(--surface); border-color: var(--fg); }
.pager { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); }

/* ---------- Campos en cualquier pantalla (reportes, filtros): mismo tamaño y estilo ---------- */
.content :where(input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=submit]):not([type=button]):not([type=hidden]):not([type=color]), select, textarea) {
  min-height: var(--h-ctl); border: 1px solid var(--field-line); border-radius: var(--r-sm); padding: 0 10px; background: var(--field); color: var(--fg); max-width: 100%; transition: border-color .12s, box-shadow .12s; }
.content :where(textarea) { padding: 8px 10px; }
.content :where(select) { padding-right: 6px; cursor: pointer; }
.content :where(input, select, textarea):hover { border-color: var(--muted); }
.content :where(input, select, textarea):focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); outline: none; }
.content :where(input[type=file]) { font-size: 13px; }
/* Etiqueta encima del campo («Desde<br><input>»): columna ordenada */
.content form label:has(> br) { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); min-width: 0; }
.content form label:has(> br) > br { display: none; }
.content form label:has(> br) > :is(select, input, span) { width: 100%; font-weight: 400; }
.content form label:has(> br) > span { display: flex; gap: 6px; }
.content form label:has(> br) > span > input { flex: 1; min-width: 0; width: auto; }
.content form label:has(> br) > span > select { flex: none; }
.content legend.lbl, .content .lbl { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.toolbar label.muted { font-size: 12.5px; font-weight: 600; }

/* Exportar: PDF, Excel, correo e imprimir */
.exportar { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-sm); box-shadow: var(--shadow); background: var(--surface); overflow: hidden; }
.exportar .btn { border: 0; border-radius: 0; box-shadow: none; border-right: 1px solid var(--line); gap: 6px; }
.exportar .btn:last-child { border-right: 0; }
.exportar .btn svg { width: 16px; height: 16px; color: var(--muted); }
.exportar .btn:hover svg { color: var(--accent); }
.dlg { border: 1px solid var(--line); border-radius: var(--r); padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--fg); box-shadow: var(--shadow-lg); }
.dlg::backdrop { background: rgba(10, 15, 22, .45); backdrop-filter: blur(2px); }
.dlg form { margin: 0; }
.dlg-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dlg-h h2 { display: flex; align-items: center; gap: 8px; }
.dlg-h svg { color: var(--accent); }
.dlg-b { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.dlg-adj { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.dlg-adj label { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; cursor: pointer; }
.dlg-adj svg { color: var(--muted); }
.dlg-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); }
@media print { .exportar, .dlg, .mas, .sesion-cerrada { display: none !important; } }
/* Pestañas de una pantalla */
.pestanas { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pestanas a { padding: 9px 14px; font-weight: 600; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 6px; align-items: center; }
.pestanas a:hover { color: var(--fg); }
.pestanas a[aria-current="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.pestanas .cuenta { font-size: 11px; background: var(--warn-soft); color: var(--warn); border-radius: 99px; padding: 0 7px; }
.pestanas .cuenta.mal { background: var(--bad-soft); color: var(--bad); }
.qr-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.qr-form video { width: 100%; max-width: 420px; border-radius: var(--r-sm); border: 1px solid var(--line); }
.autorizar { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.autorizar-pin { display: grid; grid-template-columns: 1.2fr 1fr 1.4fr auto; gap: 12px; align-items: end; }
@media (max-width: 760px) { .autorizar-pin { grid-template-columns: 1fr; } }
.sesion-cerrada { position: fixed; inset: 0; z-index: 100; background: rgba(10,15,22,.55); display: grid; place-items: center; padding: 16px; }
.sesion-cerrada > div { background: var(--surface); color: var(--fg); border-radius: var(--r); padding: 22px; max-width: 420px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 14px; }
/* Menú «Más acciones» */
.mas { position: relative; }
.mas > summary { list-style: none; }
.mas > summary::-webkit-details-marker { display: none; }
.mas[open] > summary { border-color: var(--accent); color: var(--accent); }
.mas-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 6px; z-index: 25; display: flex; flex-direction: column; }
.mas-menu form { margin: 0; }
.mas-menu a, .mas-menu button { display: block; width: 100%; text-align: left; padding: 9px 11px; border: 0; border-radius: 6px; background: transparent; color: var(--fg); font-weight: 500; text-decoration: none; cursor: pointer; }
.mas-menu a:hover, .mas-menu button:hover { background: var(--surface-2); color: var(--fg); }
.mas-menu .peligro { color: var(--bad); }
.mas-menu .peligro:hover { background: var(--bad-soft); color: var(--bad); }
.mas-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.dlg .btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.dlg .btn-danger:hover { filter: brightness(1.08); color: #fff; }
/* Resumen del documento: datos a la izquierda, total grande a la derecha */
.doc-resumen { display: grid; grid-template-columns: minmax(0, 1fr) 260px; overflow: hidden; }
.doc-resumen .doc-head { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.doc-total { background: var(--surface-2); border-left: 1px solid var(--line); padding: 18px 20px; display: flex; flex-direction: column; justify-content: center; gap: 4px; text-align: right; }
.doc-total-val { font-size: 26px; font-weight: 700; letter-spacing: -.02em; color: var(--accent); line-height: 1.2; }
.doc-total-sub { font-size: 13px; font-weight: 600; }
.enlace-sutil { color: inherit; text-decoration: none; border-bottom: 1px dashed var(--line-2); }
.enlace-sutil:hover { color: var(--accent); border-color: var(--accent); }
@media (max-width: 760px) { .doc-resumen { grid-template-columns: 1fr; } .doc-total { border-left: 0; border-top: 1px solid var(--line); text-align: left; } }
@media print { .doc-total { background: none; border: 0; } .doc-total-val { color: #000; } }

/* Atajos de fecha de los reportes */
.rangos { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; flex-basis: 100%; }
.rangos .chip { padding: 3px 10px; font-size: 12.5px; }
.rangos .chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
/* Filtro rápido y orden por columna en las tablas */
.tabla-filtro { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.tabla-filtro input { flex: 1; min-width: 160px; max-width: 360px; padding-left: 34px !important; background: var(--field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238793a5' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E") no-repeat 10px center / 16px; }
.tabla-filtro .cuenta { font-size: 12.5px; color: var(--muted); margin-left: auto; }
th.ordenable { cursor: pointer; user-select: none; }
th.ordenable:hover { color: var(--fg); }
th.ordenable::after { content: "↕"; margin-left: 5px; opacity: .35; font-size: 11px; }
th.ordenable[aria-sort="ascending"]::after { content: "↑"; opacity: 1; color: var(--accent); }
th.ordenable[aria-sort="descending"]::after { content: "↓"; opacity: 1; color: var(--accent); }
td.neg { color: var(--bad); }
tr.vencida td { color: var(--bad); background: color-mix(in srgb, var(--bad) 6%, transparent); }
tr.vencida td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
tr.vencida td.code { color: var(--bad); }
tr.oculta-filtro { display: none; }
@media print { .rangos, .tabla-filtro { display: none !important; } th.ordenable::after { content: none; } td.neg { color: #000; } }

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.f { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.f.span2 { grid-column: span 2; } .f.span3 { grid-column: 1 / -1; }
.f label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.f input:not([type=checkbox]):not([type=radio]), .f select, .f textarea { border: 1px solid var(--field-line); border-radius: var(--r-sm); padding: 0 11px; min-height: var(--h-ctl); background: var(--field); width: 100%; transition: border-color .12s, box-shadow .12s; }
.f textarea { padding: 9px 11px; line-height: 1.45; }
.f input:hover, .f select:hover, .f textarea:hover { border-color: var(--muted); }
.f input:focus, .f select:focus, .f textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); outline: none; }
.f input[readonly], .f input:disabled, .f select:disabled { background: var(--surface-2); color: var(--muted); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }
.f.check { flex-direction: row; align-items: center; gap: 8px; padding-top: 24px; }
.f.check label { color: var(--fg); font-size: 14px; }
.f .help { font-size: 12px; color: var(--muted); }
.f .err { font-size: 12.5px; color: var(--bad); font-weight: 600; }
.f.has-error input, .f.has-error select { border-color: var(--bad); }
.form-section { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; grid-column: 1 / -1; padding-top: 10px; border-top: 1px solid var(--line); margin-top: 4px; }
.form-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r) var(--r); }

/* ---------- Factura ---------- */
.inv { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.hint { font-size: 12.5px; font-weight: 600; min-height: 1em; }
.hint.ok { color: var(--ok); } .hint.bad { color: var(--bad); } .hint.muted { color: var(--muted); }
.ecf { display: flex; gap: 6px; flex-wrap: wrap; }
.ecf button { border: 1px solid var(--line-2); background: var(--surface); min-height: 34px; padding: 0 13px; border-radius: 99px; cursor: pointer; font-weight: 600; font-size: 13px; transition: background .12s, border-color .12s, color .12s; }
.ecf button:hover { border-color: var(--muted); }
.ecf button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.lines input { border: 1px solid var(--line); background: var(--field); padding: 6px 8px; border-radius: 6px; width: 100%; transition: border-color .12s, background .12s; }
.lines input:hover { border-color: var(--line-2); }
.lines input:focus { border-color: var(--accent); background: var(--field); box-shadow: 0 0 0 3px var(--ring); outline: none; }
.lines td { padding: 6px 10px; }
.lines .qty { width: 80px; } .lines .price, .lines .pricei { width: 110px; } .lines .disc { width: 70px; }
.del { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px 8px; border-radius: 6px; }
.del:hover { color: var(--bad); background: var(--bad-soft); }
.add-line { display: flex; gap: 8px; padding: 12px; border-top: 1px dashed var(--line-2); position: relative; background: var(--surface-2); }
.add-line input { flex: 1; min-width: 0; height: 42px; border: 1px dashed var(--line-2); border-radius: var(--r-sm); padding: 0 12px; background: var(--field); transition: border-color .12s, box-shadow .12s; }
.add-line input:focus { border: 1px solid var(--accent); box-shadow: 0 0 0 3px var(--ring); outline: none; }
.picker { position: relative; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow-lg); z-index: 10; overflow: hidden; max-height: 340px; overflow-y: auto; }
.add-line .suggest { left: 12px; right: 12px; top: 58px; }
.suggest button { display: flex; width: 100%; gap: 10px; align-items: center; text-align: left; border: 0; background: transparent; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.suggest button:last-child { border-bottom: 0; }
.suggest button:hover, .suggest button.sel { background: var(--accent-soft); }
.suggest .d { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .stk { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.suggest .none { padding: 10px 12px; color: var(--muted); }
.totals { position: sticky; top: 76px; }
.trow { display: flex; justify-content: space-between; padding: 6px 0; gap: 10px; }
.trow.big { font-size: 22px; font-weight: 800; letter-spacing: -.02em; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 14px; }
.trow.big .num { color: var(--accent); }
.note { margin-top: 12px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.note b { color: var(--fg); }
.note.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }

.doc-head { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.doc-head .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin-bottom: 2px; }

/* Entrar */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: var(--ink); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 16px; }
.login-card .brand { color: var(--fg); padding: 0; }
.login-card .f input { padding: 10px 12px; }
.login-card .btn { justify-content: center; padding: 10px; }

.toast { position: fixed; right: 20px; bottom: 20px; background: var(--fg); color: var(--bg); padding: 11px 16px; border-radius: var(--r-sm); font-weight: 600; box-shadow: var(--shadow-lg); z-index: 30; }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-2, .inv { grid-template-columns: minmax(0, 1fr); } .totals { position: static; } .doc-head { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Tableta: el menú lateral pasa a ser un cajón que se abre con ☰, así el contenido usa todo el ancho */
@media (max-width: 1024px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
  .menu-btn, .btn.menu-btn { display: inline-flex; }
  .nav a, .nav-group summary { padding-top: 10px; padding-bottom: 10px; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .top { padding: 8px 16px; gap: 8px; }
  .search { order: 5; flex-basis: 100%; max-width: none; }
  .search kbd { display: none; }
  .empresa label { display: none; }
  .content { padding: 18px 16px 40px; }
  h1 { font-size: 21px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); } .f.span2 { grid-column: auto; }
  .user > span { display: none; }
  .btn, .icon-btn { min-height: 42px; }
}
@media (max-width: 460px) { .kpis, .doc-head { grid-template-columns: minmax(0, 1fr); } }
.print-only { display: none; }
tr.esp-imp { display: none; }
.solo-imp { display: none; }
@media print {
  /* Mismo estilo de la factura impresa: todo en negro, encabezado de la empresa arriba,
     títulos de tabla en gris y filas alternadas. Margen 0 para que Chrome no imprima su fecha ni la dirección. */
  @page { margin: 0; }
  .side, .top, .actions, .no-print, .msgs, .toolbar .btn, .toolbar button, .toolbar input[type=search], .toolbar input[type=text] { display: none !important; }
  /* Los filtros (fechas, cuenta…) se imprimen como texto, sin cajas ni botones */
  .toolbar { margin: 0 0 4px; padding: 0 0 4px !important; gap: 4px 12px; justify-content: center; font-size: 11px; border: 0 !important; }
  .toolbar input::-webkit-calendar-picker-indicator { display: none; }
  .toolbar label { color: #000 !important; font-weight: 700; }
  .toolbar input, .toolbar select { border: 0 !important; background: none !important; padding: 0 !important; box-shadow: none !important; appearance: none; -webkit-appearance: none; font-weight: 700; color: #000; width: auto !important; min-width: 0 !important; }
  .print-only { display: flex !important; }
  .solo-imp { display: block !important; } span.solo-imp { display: inline !important; } .solo-pantalla { display: none !important; }
  html, body { background: #fff !important; color: #000 !important; font-family: Arial, Helvetica, sans-serif; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .app { display: block; } .content { padding: 10mm 12mm 12mm; max-width: none; }
  .card { box-shadow: none; border: 0; background: #fff; margin-bottom: 8px; }
  .card-b { padding: 4px 0; }
  .table-wrap { overflow: visible !important; }
  .muted, .sub, .lbl, .code, th, td, a { color: #000 !important; }
  a { text-decoration: none; }

  /* Encabezado como los reportes de Citrus: logo a la izquierda, empresa centrada, fecha de impresión a la derecha */
  .membrete { display: grid !important; grid-template-columns: 34mm 1fr 34mm; align-items: start; gap: 10px; margin-bottom: 6px; }
  .membrete .mb-marca { display: contents; }
  .membrete .mb-logo img, .membrete img { max-width: 32mm; max-height: 20mm; object-fit: contain; display: block; }
  .membrete .mb-centro { text-align: center; }
  .membrete .mb-nombre { font-size: 15px; font-weight: 800; margin: 2px 0 2px; }
  .membrete .mb-lin { font-size: 10.5px; }
  .membrete .mb-imp { font-size: 10px; text-align: right; line-height: 1.4; white-space: nowrap; }
  .membrete .mb-imp b { font-weight: 700; }

  .page-head { display: block !important; text-align: center; margin: 4px 0 10px; }
  .page-head h1 { font-size: 15px; font-weight: 800; letter-spacing: 0; text-transform: none; }
  .page-head .sub { font-size: 12px; font-weight: 700; margin-top: 2px; }
  .card-h h2 { font-size: 13px; font-weight: 800; }
  .pill { border: 0; background: none !important; color: #000 !important; padding: 0; font-weight: 700; }

  table { font-size: 11.5px; }
  thead { display: table-header-group; } tfoot { display: table-footer-group; }
  th { background: none !important; color: #000 !important; font-size: 11.5px; font-weight: 800; text-transform: none; letter-spacing: 0; padding: 5px 6px; border-top: 1px solid #000; border-bottom: 1px solid #000; }
  td { padding: 2px 6px; border-bottom: 0; line-height: 1.25; }
  tr { break-inside: avoid; }
  tbody.tot-imp td { font-weight: 800; background: none !important; border-top: 1px solid #000; }
  tr.esp-imp th, tr.esp-imp td { border: 0 !important; }
  tr.esp-imp { display: table-row; } tr.esp-imp td { height: 8mm; padding: 0; background: none !important; border: 0; }
  .kpis .kpi, .trow { color: #000; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.precio-fila { display: grid; grid-template-columns: 140px 130px 1fr 1fr 1fr; gap: 10px; align-items: end; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.precio-fila .precio-titulo { font-weight: 700; padding-bottom: 10px; }
@media (max-width: 720px) { .precio-fila { grid-template-columns: 1fr 1fr; } .precio-fila .precio-titulo { grid-column: 1 / -1; padding: 0; } }
.precio-fila, .form-grid > .span3 { grid-column: 1 / -1; }

/* Barra de avance del envío a la DGII */
.ecf-prog { margin: 10px 0 4px; max-width: 520px; }
.ecf-prog-barra { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.ecf-prog-barra span { display: block; height: 100%; border-radius: 999px; background: var(--info, #2f6fde); transition: width .6s ease; }
.ecf-prog.vivo .ecf-prog-barra span { background-image: linear-gradient(45deg, rgba(255,255,255,.28) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.28) 50%, rgba(255,255,255,.28) 75%, transparent 75%); background-size: 16px 16px; animation: ecf-rayas .8s linear infinite; }
.ecf-prog.fin .ecf-prog-barra span { background: var(--ok, #1f8a4c); }
.ecf-prog.mal .ecf-prog-barra span { background: var(--bad, #c0352b); }
.ecf-prog-txt { font-size: 12.5px; margin-top: 4px; color: var(--muted); }
.ecf-prog-txt b { color: var(--fg); margin-right: 6px; }
@keyframes ecf-rayas { from { background-position: 0 0; } to { background-position: 16px 0; } }
@media (prefers-reduced-motion: reduce) { .ecf-prog.vivo .ecf-prog-barra span { animation: none; } }
@media print { .ecf-prog { display: none !important; } }

/* ================= Teléfonos y tabletas: más fácil de ver y de tocar ================= */
/* Pantalla táctil: controles de 44 px (el tamaño de un dedo) */
@media (pointer: coarse) {
  :root { --h-ctl: 44px; }
  .chip { padding: 9px 14px; }
  .lines input { min-height: 40px; }
  .suggest button { min-height: 48px; }
  .user-menu a, .user-menu button { padding: 12px; }
}
/* Las tablas que no caben se deslizan de lado y una sombra avisa que hay más columnas */
.table-wrap { -webkit-overflow-scrolling: touch;
  background: linear-gradient(to right, var(--surface) 30%, transparent) left / 24px 100% no-repeat local,
              linear-gradient(to left, var(--surface) 30%, transparent) right / 24px 100% no-repeat local,
              radial-gradient(farthest-side at 0 50%, rgba(10,31,61,.18), transparent) left / 10px 100% no-repeat scroll,
              radial-gradient(farthest-side at 100% 50%, rgba(10,31,61,.18), transparent) right / 10px 100% no-repeat scroll; }
@media (max-width: 760px) {
  /* 16 px en los campos: el iPhone no hace zoom al tocar un campo */
  .content input:not([type=checkbox]):not([type=radio]), .content select, .content textarea, .search input, .lines input { font-size: 16px; }
  .page-head { align-items: stretch; }
  .page-head > .actions { width: 100%; }
  .page-head > .actions > .btn, .page-head > .actions > a.btn { flex: 1 1 auto; }
  .card-h, .card-b, .toolbar { padding-left: 14px; padding-right: 14px; }
  .toolbar input[type=search] { flex-basis: 100%; }
  .chips { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; margin: 0 -2px; padding: 2px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { white-space: nowrap; }
  .pager { justify-content: space-between; }
  .toast { left: 16px; right: 16px; bottom: 16px; text-align: center; }
  /* Diálogos como hoja que sube desde abajo */
  .dlg { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 16px 16px 0 0; max-height: 92vh; }
  .dlg-f { position: sticky; bottom: 0; }
  .dlg-f .btn { flex: 1; }

  /* Listados como tarjetas: el primer dato es el título, los demás «Columna ··· valor» */
  .table-wrap.tarjetas { background: none; overflow: visible; }
  .tarjetas table, .tarjetas tbody, .tarjetas tr, .tarjetas td { display: block; width: 100%; }
  .tarjetas thead { display: none; }
  .tarjetas tbody tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .tarjetas tbody tr:active { background: var(--accent-soft); }
  .tarjetas td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; text-align: right; min-height: 0; }
  .tarjetas td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex: none; }
  .tarjetas td:first-child { font-weight: 700; font-size: 15px; justify-content: flex-start; text-align: left; padding-bottom: 4px; }
  .tarjetas td:first-child::before, .tarjetas td[data-label=""]::before { content: none; }
  .tarjetas td:empty { display: none; }
  .tarjetas tfoot { display: block; }
  .tarjetas tfoot tr { display: flex; flex-wrap: wrap; justify-content: space-between; padding: 10px 14px; }
  .tarjetas tfoot td { width: auto; }

  /* Líneas de la factura y la cotización: cada artículo en su tarjeta, con los campos grandes */
  #facturaForm .lines thead { display: none; }
  #facturaForm .lines, #facturaForm .lines tbody { display: block; }
  #facturaForm .lines tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); position: relative; }
  #facturaForm .lines td { display: flex; flex-direction: column; gap: 3px; padding: 0; border: 0; text-align: left; }
  #facturaForm .lines td.r { text-align: left; }
  #facturaForm .lines td:first-child { grid-column: 1 / -1; padding-right: 44px; }
  #facturaForm .lines td:nth-child(2)::before { content: "Cantidad"; } #facturaForm .lines td:nth-child(3)::before { content: "Precio sin ITBIS"; }
  #facturaForm .lines td:nth-child(4)::before { content: "Precio con ITBIS"; } #facturaForm .lines td:nth-child(5)::before { content: "Descuento %"; }
  #facturaForm .lines td:nth-child(6)::before { content: "ITBIS"; } #facturaForm .lines td:nth-child(7)::before { content: "Importe"; }
  #facturaForm .lines td:nth-child(n+2)::before { font-size: 11.5px; font-weight: 600; color: var(--muted); }
  #facturaForm .lines td:nth-child(7) { font-size: 16px; }
  #facturaForm .lines .qty, #facturaForm .lines .price, #facturaForm .lines .pricei, #facturaForm .lines .disc { width: 100%; }
  #facturaForm .lines td:last-child { position: absolute; top: 8px; right: 8px; }
  #facturaForm .lines .del { width: 40px; height: 40px; font-size: 20px; }
  #facturaForm .lines td.empty { grid-column: 1 / -1; }
  .add-line input { font-size: 16px; }
  .add-line .suggest { top: 64px; max-height: 60vh; overflow-y: auto; }
  .suggest button { flex-wrap: wrap; row-gap: 2px; }
  .suggest .d { white-space: normal; flex-basis: 100%; order: 3; }

  /* Barra fija con el total para no perderlo al bajar por la factura */
  .barra-total { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; align-items: center; gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(10,31,61,.12); }
  .barra-total .bt-t { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
  .barra-total .bt-t small { color: var(--muted); font-size: 11.5px; font-weight: 600; }
  .barra-total .bt-t b { font: 700 19px var(--f-num); }
  .barra-total .btn { min-width: 132px; }
  body:has(.barra-total) .content { padding-bottom: 96px; }
}
@media (min-width: 761px) { .barra-total { display: none; } }
@media print { .barra-total { display: none !important; } }

/* Aviso de comprobantes por agotarse */
.aviso-series { position: relative; padding-right: 40px; font-weight: 500; line-height: 1.5; margin-bottom: 12px; }
.aviso-series b { font-weight: 700; }
.aviso-series .as-item { white-space: nowrap; font-weight: 700; }
.aviso-series a { color: inherit; text-decoration: underline; }
.aviso-series .as-cerrar { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border: 0; background: transparent; color: inherit; font-size: 20px; line-height: 1; cursor: pointer; border-radius: var(--r-sm); }
.aviso-series .as-cerrar:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
@media (max-width: 640px) { .aviso-series .as-item { white-space: normal; } }

/* Cierre de caja: conteo de billetes y monedas */
.conteo-billetes summary { cursor: pointer; font-weight: 600; color: var(--accent, inherit); }
.conteo-billetes .billetes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 12px; }
.conteo-billetes .billete { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.conteo-billetes .billete input { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--surface); min-height: 40px; }
.conteo-billetes .billetes-total { margin-top: 10px; font-size: 15px; }

/* Usuario: varios perfiles (casillas) */
.f:has(#id_perfiles) { grid-column: 1 / -1; }
#id_perfiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px; margin-top: 4px; }
#id_perfiles label { display: flex; align-items: center; gap: 8px; font-weight: 500; min-height: 36px; cursor: pointer; }
#id_perfiles input { width: 18px; height: 18px; }
@media (max-width: 760px) { .jornada-barra .muted { display: none; } }

/* Fotos de productos */
.fotos-prod { display: flex; gap: 10px; flex-wrap: wrap; }
.foto-prod { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 92px; font-size: 12px; }
.foto-mini { width: 84px; height: 84px; border: 1px solid var(--line); border-radius: 8px; padding: 0; overflow: hidden; background: var(--surface); cursor: zoom-in; }
.foto-mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-mini.vacia { display: grid; place-items: center; color: var(--muted); border-style: dashed; cursor: default; }
.foto-subir { position: relative; overflow: hidden; cursor: pointer; }
.foto-subir input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.foto-quitar { display: flex; gap: 4px; align-items: center; color: var(--muted); }
.ver-foto { border: 0; background: transparent; color: var(--accent); cursor: zoom-in; padding: 2px 4px; font-size: 15px; line-height: 1; }
.visor-fotos { border: 0; border-radius: 12px; padding: 12px; background: var(--surface); max-width: min(92vw, 460px); }
.visor-fotos::backdrop { background: rgba(0,0,0,.6); }
.visor-fotos img { display: block; width: min(80vw, 400px); height: min(80vw, 400px); object-fit: contain; margin: 0 auto; background: #fff; border-radius: 8px; }
.visor-fotos .vf-cerrar { position: absolute; top: 4px; right: 8px; border: 0; background: transparent; font-size: 26px; cursor: pointer; color: var(--muted); }
.visor-fotos .vf-flecha { position: absolute; top: 50%; transform: translateY(-50%); border: 0; background: var(--surface); border-radius: 50%; width: 36px; height: 36px; font-size: 24px; cursor: pointer; box-shadow: var(--shadow-lg); }
.visor-fotos .vf-ant { left: 4px; } .visor-fotos .vf-sig { right: 4px; }
.visor-fotos .vf-cont { text-align: center; font-size: 12px; color: var(--muted); margin-top: 6px; min-height: 1em; }
.ver-foto svg { width: 17px; height: 17px; vertical-align: -3px; display: inline-block; }
