/* Layout: aplicación de trabajo. Barra lateral azul Metal Mallas con íconos, área clara y densa;
   la marca (azul/verde/naranja) vive en una franja fina arriba, en el acceso y en los estados.
   Tipografía: Archivo (variable en ancho y peso) para todo; IBM Plex Mono para códigos y lotes. */
:root {
  --navy: #004566; --navy-d: #00344D; --green: #009347; --green-d: #00853F; --orange: #E8650A; --orange-d: #C4500A;
  --bg: #F3F5F7; --surface: #FFFFFF; --surface-2: #F7F9FA; --hover: #F0F4F6; --ink: #142533; --ink-2: #33475A; --muted: #607386; --line: #DCE3E9; --line-2: #EBEFF2;
  --accent: #004566; --accent-hover: #003A56; --accent-ink: #FFFFFF; --cta: #E8650A; --cta-hover: #CF5808; --link: #005E8A; --focus: #2B8CC4;
  --ok: #0B7A43; --ok-bg: #E4F4EB; --warn: #9A4F00; --warn-bg: #FDF0E3; --bad: #B42318; --bad-bg: #FCE9E7; --info: #005E8A; --info-bg: #E5F0F6;
  --side: #004566; --side-ink: #DCE8EF; --side-muted: #7FA6BC; --side-hover: rgba(255,255,255,.07); --side-active: rgba(255,255,255,.13);
  --bar: #004566;
  --f-ui: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --r: 6px; --r-lg: 10px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0B151C; --surface: #111F28; --surface-2: #152733; --hover: #18303E; --ink: #E4ECF1; --ink-2: #C3D1DA; --muted: #8DA2B2; --line: #233A48; --line-2: #1B303C;
  --accent: #2C86B5; --accent-hover: #3A97C7; --accent-ink: #FFFFFF; --cta: #F07A26; --cta-hover: #FF8A3A; --link: #74C3EA; --focus: #74C3EA;
  --ok: #4CC488; --ok-bg: #133628; --warn: #F2A75E; --warn-bg: #3A2614; --bad: #F2806F; --bad-bg: #3B1C19; --info: #74C3EA; --info-bg: #13324A;
  --side: #08273A; --side-ink: #DCE8EF; --side-muted: #7FA6BC; --bar: #4BA9D6; color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0B151C; --surface: #111F28; --surface-2: #152733; --hover: #18303E; --ink: #E4ECF1; --ink-2: #C3D1DA; --muted: #8DA2B2; --line: #233A48; --line-2: #1B303C;
  --accent: #2C86B5; --accent-hover: #3A97C7; --accent-ink: #FFFFFF; --cta: #F07A26; --cta-hover: #FF8A3A; --link: #74C3EA; --focus: #74C3EA;
  --ok: #4CC488; --ok-bg: #133628; --warn: #F2A75E; --warn-bg: #3A2614; --bad: #F2806F; --bad-bg: #3B1C19; --info: #74C3EA; --info-bg: #13324A;
  --side: #08273A; --side-ink: #DCE8EF; --side-muted: #7FA6BC; --bar: #4BA9D6; color-scheme: dark; }

html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font: 400 14px/1.5 var(--f-ui); -webkit-font-smoothing: antialiased; }
* { box-sizing: border-box; }
h1, h2, h3 { font-family: var(--f-ui); margin: 0; text-wrap: balance; color: var(--ink); }
h1 { font-size: 1.6rem; line-height: 1.2; font-weight: 650; font-variation-settings: "wdth" 108; letter-spacing: -.01em; }
h2 { font-size: 1rem; line-height: 1.3; font-weight: 620; font-variation-settings: "wdth" 104; }
h3 { font-size: .95rem; line-height: 1.3; font-weight: 620; }
a { color: var(--link); }
.mono, code { font-family: var(--f-mono); font-size: .88em; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Estructura */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
.side { background: var(--side); color: var(--side-ink); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.side .logo { display: block; text-decoration: none; padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.side .logo img { width: 100%; max-width: 176px; display: block; }
.side .logo .lema { display: block; margin-top: 8px; color: var(--side-muted); font-size: .72rem; letter-spacing: .02em; }
.side nav { display: flex; flex-direction: column; padding: 8px 10px 16px; gap: 1px; }
.side nav .grupo { font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--side-muted); padding: 16px 10px 6px; }
.side nav a { color: var(--side-ink); text-decoration: none; padding: 7px 10px; border-radius: var(--r); display: flex; align-items: center; gap: 10px; font-weight: 500; }
.side nav a .ico { width: 18px; height: 18px; flex: none; opacity: .75; }
.side nav a .badge { margin-left: auto; }
.side nav a:hover { background: var(--side-hover); }
.side nav a.activo { background: var(--side-active); color: #fff; }
.side nav a.activo .ico { opacity: 1; }
.side .pie { margin-top: auto; padding: 14px 18px 16px; font-size: .75rem; color: var(--side-muted); border-top: 1px solid rgba(255,255,255,.08); }
.badge { background: var(--cta); color: #fff; border-radius: 999px; font-size: .7rem; font-weight: 700; line-height: 1; padding: 3px 7px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding-block: 9px 8px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.topbar::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, var(--navy) 0 60%, var(--green) 60% 80%, var(--orange) 80%); }
.topbar .menu { display: none; }
.topbar .espacio { flex: 1; }
.sandbox-tag { background: var(--warn-bg); color: var(--warn); font-size: .72rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; padding: 5px 8px; border-radius: 4px; }
.usuario-chip { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid transparent; background: none; text-align: left; font-weight: 400; }
.usuario-chip:hover { background: var(--hover); border-color: var(--line); }
.usuario-chip .txt { display: flex; flex-direction: column; gap: 2px; }
.usuario-chip .n { font-weight: 600; font-size: .86rem; line-height: 1.1; }
.usuario-chip .r { color: var(--muted); font-size: .74rem; line-height: 1.1; }
.contenido { padding-block: 22px 56px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); max-width: 1320px; width: 100%; }
.encabezado { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 18px; }
.encabezado > div:first-child { min-width: 0; }
.encabezado p { margin: 4px 0 0; color: var(--muted); max-width: 75ch; }
.eyebrow { font-size: .78rem; font-weight: 500; color: var(--muted); }

/* Avatares */
.avatar { width: var(--av, 32px); height: var(--av, 32px); border-radius: 50%; flex: none; display: inline-grid; place-items: center; overflow: hidden; color: #fff; font-weight: 650; font-size: calc(var(--av, 32px) * .38); letter-spacing: .02em; object-fit: cover; vertical-align: middle; }
.persona { display: inline-flex; align-items: center; gap: 8px; }

/* Paneles */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel > .cab { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.panel > .cuerpo { padding: 14px 16px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-pos { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
.pila { display: flex; flex-direction: column; gap: 14px; }
.fila { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fila.fin { justify-content: flex-end; }

/* KPI */
.kpi { padding: 14px 16px; }
.kpi .v { font-size: 1.6rem; line-height: 1.15; font-weight: 650; font-variation-settings: "wdth" 104; font-variant-numeric: tabular-nums; margin-top: 4px; letter-spacing: -.01em; }
.kpi .d { font-size: .8rem; margin-top: 4px; }
.sube { color: var(--ok); } .baja { color: var(--bad); }

/* Tablas */
.tabla-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top; }
th { font-size: .74rem; font-weight: 600; letter-spacing: .02em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
tbody tr:hover { background: var(--hover); }
tr.click { cursor: pointer; }
td.cero { color: var(--muted); }
tfoot td { font-weight: 650; border-top: 1px solid var(--line); background: var(--surface-2); }

/* Formularios */
label.campo { display: flex; flex-direction: column; gap: 5px; font-size: .8rem; color: var(--ink-2); font-weight: 550; min-width: 0; }
input, select, textarea { font: inherit; font-size: .92rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
input[type=number] { font-variant-numeric: tabular-nums; }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; vertical-align: -2px; }
textarea { min-height: 64px; resize: vertical; }
.campos { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
button, .btn { font: inherit; font-size: .88rem; font-weight: 550; line-height: 1; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 9px 13px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; white-space: nowrap; }
button:hover, .btn:hover { background: var(--hover); }
button.prim, .btn.prim { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.prim:hover, .btn.prim:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.cta, .btn.cta { background: var(--cta); border-color: var(--cta); color: #fff; }
button.cta:hover, .btn.cta:hover { background: var(--cta-hover); border-color: var(--cta-hover); }
button.ok { background: var(--green); border-color: var(--green); color: #fff; }
button.ok:hover { background: var(--green-d); }
button.peligro { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
button.grande { padding: 12px 20px; font-size: 1rem; font-weight: 600; }
button.mini { padding: 5px 9px; font-size: .78rem; }
button:disabled { opacity: .45; cursor: not-allowed; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 12px; text-decoration: none; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.activo { color: var(--ink); border-bottom-color: var(--accent); }

/* Estados */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 600; line-height: 1; padding: 4px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.pill.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.pill.ok::before, .pill.warn::before, .pill.bad::before, .pill.info::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.aviso { padding: 10px 14px; border-radius: var(--r); background: var(--info-bg); }
.aviso.warn { background: var(--warn-bg); } .aviso.bad { background: var(--bad-bg); } .aviso.ok { background: var(--ok-bg); }
.vacio { padding: 28px 16px; text-align: center; color: var(--muted); }

/* Rollos */
.metros { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.metros .b { flex: 1; height: 6px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.metros .b i { display: block; height: 100%; background: var(--bar); border-radius: 3px; }
.metros.retazo .b i { background: var(--orange); }

/* Punto de venta */
.resultados { max-height: 380px; overflow-y: auto; border-top: 1px solid var(--line-2); }
.res { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 9px 6px; border-bottom: 1px solid var(--line-2); cursor: pointer; border-radius: 4px; }
.res:hover, .res:focus-visible { background: var(--hover); }
.res .cod { font: 500 .78rem/1 var(--f-mono); color: var(--muted); margin-bottom: 3px; }
.total-grande { font-size: 2.2rem; line-height: 1; font-weight: 650; font-variation-settings: "wdth" 106; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.lineas td { vertical-align: middle; }
.lineas input { width: 72px; }

/* Modal */
.velo { position: fixed; inset: 0; background: rgba(9,22,30,.5); z-index: 20; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto;
  padding: max(28px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
.modal { background: var(--surface); border-radius: var(--r-lg); width: 100%; max-width: 760px; box-shadow: 0 24px 64px rgba(0,0,0,.28); }
.modal.angosto { max-width: 480px; }
.modal > .cab { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line-2); gap: 10px; }
.modal > .cab h2 { font-size: 1.08rem; }
.modal > .cuerpo { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal > .pie { padding: 12px 18px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.cerrar { border: none; background: none; font-size: 1.4rem; line-height: 1; padding: 4px 8px; color: var(--muted); }

/* Toast */
.toasts { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px)); z-index: 30; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: #142533; color: #fff; padding: 11px 14px; border-radius: var(--r); box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: .9rem; }
.toast.error { background: var(--bad); }

/* Gráficos */
.barras { display: flex; flex-direction: column; gap: 8px; }
.barra { display: grid; grid-template-columns: minmax(90px, 180px) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: .86rem; }
.barra .b i { display: block; height: 12px; background: var(--bar); border-radius: 0 3px 3px 0; min-width: 2px; }
.barra:hover .b i { background: var(--orange); }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .eje { fill: var(--muted); font: 11px var(--f-ui); }
.chart .grilla { stroke: var(--line-2); }
.chart rect.col { fill: var(--bar); }
.chart rect.col:hover { fill: var(--orange); }
.tip { position: fixed; pointer-events: none; z-index: 40; background: #142533; color: #fff; padding: 6px 9px; border-radius: 4px; font-size: .8rem; }

/* Etiquetas QR */
.etiquetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.etiqueta { background: #fff; color: #142533; border: 1px dashed #A8BAC6; border-radius: 4px; padding: 10px; display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; align-items: center; }
.etiqueta .qr svg { width: 96px; height: 96px; display: block; }
.etiqueta .n { font-weight: 600; font-size: .78rem; line-height: 1.25; }
.etiqueta .c { font: 500 .76rem/1 var(--f-mono); margin-top: 6px; color: #004566; }
.etiqueta .p { font-weight: 700; font-size: 1.1rem; margin-top: 6px; color: #C4500A; }
.etiqueta img { height: 14px; margin-bottom: 6px; }

/* Asistencia */
.kiosco { max-width: 380px; margin: 0 auto; text-align: center; }
.pin { font: 600 2rem/1 var(--f-mono); letter-spacing: .4em; min-height: 2.4rem; margin: 10px 0; }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.teclado button { font-size: 1.35rem; font-weight: 600; padding: 18px; }
.reloj { font-size: 2.8rem; line-height: 1; font-weight: 650; font-variation-settings: "wdth" 106; font-variant-numeric: tabular-nums; }

.factura { border: 1px solid var(--line); border-radius: var(--r); padding: 14px; background: var(--surface-2); }
.historial { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.historial li { padding-left: 14px; border-left: 2px solid var(--line); }

/* Fábrica en vivo */
.cronometro { font-size: 2.3rem; line-height: 1; font-weight: 650; font-variation-settings: "wdth" 106; font-variant-numeric: tabular-nums; color: var(--ink); }
.cronometro.mini { font-size: 1rem; font-weight: 600; }
.panel.maquina.activa { border-color: color-mix(in srgb, var(--green) 55%, var(--line)); }
.panel.maquina.activa .cronometro { color: var(--green-d); }
.panel.maquina.pausada { border-color: color-mix(in srgb, var(--orange) 55%, var(--line)); }
.panel.maquina.pausada .cronometro { color: var(--orange-d); }
@media (prefers-reduced-motion: no-preference) { .panel.maquina.activa .cab h2::after { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-left: 8px; vertical-align: middle; animation: latido 1.6s ease-in-out infinite; } }
@keyframes latido { 50% { opacity: .25; } }

/* Matriz de permisos */
.matriz th.rol { white-space: normal; min-width: 84px; text-align: center; font-size: .7rem; line-height: 1.2; vertical-align: bottom; }
.matriz td.c { text-align: center; }
.matriz tr.grupo td { background: var(--surface-2); font-weight: 650; font-size: .78rem; color: var(--ink-2); }
.matriz td.cambiado { background: var(--warn-bg); }

/* Perfil */
.perfil-cab { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

/* Acceso */
.acceso { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.acceso .marca { position: relative; overflow: hidden; background-color: #004566; color: #fff; display: flex; flex-direction: column; justify-content: space-between; gap: 24px;
  padding: 40px 40px 40px max(40px, env(safe-area-inset-left, 0px));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='30'%3E%3Cpath d='M0 15 30 0l30 15-30 15z' fill='none' stroke='%23ffffff' stroke-opacity='.09' stroke-width='3'/%3E%3C/svg%3E"); }
.acceso .marca::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: linear-gradient(90deg, #004566 0 34%, #009347 34% 67%, #E8650A 67%); }
.acceso .marca img { width: 220px; max-width: 70%; }
.acceso .marca h1 { color: #fff; font-size: clamp(1.8rem, 3.2vw, 2.6rem); font-variation-settings: "wdth" 112; font-weight: 700; line-height: 1.08; max-width: 15ch; }
.acceso .marca p { color: #B9D1DE; max-width: 42ch; margin: 12px 0 0; }
.acceso .marca .datos { display: flex; gap: 26px; flex-wrap: wrap; color: #B9D1DE; font-size: .82rem; }
.acceso .marca .datos b { display: block; color: #fff; font-size: 1.3rem; font-weight: 650; }
.acceso .formulario { display: flex; flex-direction: column; justify-content: center; padding: 40px max(24px, env(safe-area-inset-right, 0px)) 40px 24px; }
.acceso .formulario .caja { width: 100%; max-width: 380px; margin: 0 auto; }
.acceso .formulario h2 { font-size: 1.5rem; font-variation-settings: "wdth" 108; font-weight: 650; }
.clave-w { position: relative; display: flex; }
.clave-w input { flex: 1; padding-right: 74px; }
.clave-w button { position: absolute; right: 4px; top: 4px; bottom: 4px; padding: 0 10px; font-size: .78rem; border: none; background: transparent; color: var(--link); }
.acceso .pie-acceso { margin-top: 28px; font-size: .78rem; color: var(--muted); }
.cuentas-prueba { margin-top: 22px; border: 1px solid var(--line); border-radius: var(--r); }
.cuentas-prueba summary { cursor: pointer; padding: 10px 12px; font-weight: 600; font-size: .85rem; }
.cuentas-prueba .lista { max-height: 260px; overflow-y: auto; border-top: 1px solid var(--line-2); }
.cuentas-prueba button { width: 100%; justify-content: space-between; border: none; border-bottom: 1px solid var(--line-2); border-radius: 0; padding: 9px 12px; font-weight: 500; }
.cuentas-prueba button span { color: var(--muted); font-size: .76rem; font-weight: 400; }
.ingreso { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; background: var(--bg); padding-block: 24px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* Recursos humanos */
.cal-dias { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dias div { border: 1px solid var(--line-2); border-radius: 4px; min-height: 54px; padding: 4px 6px; font-size: .74rem; }
.cal-dias .fds { background: var(--surface-2); }
.cal-dias .t { font-weight: 650; }

@media (max-width: 980px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3, .g-pos { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 15; left: 0; top: 0; width: 264px; transform: translateX(-100%); transition: transform .2s; padding-top: env(safe-area-inset-top, 0px); }
  .side.abierto { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .topbar .menu { display: inline-flex; }
  .usuario-chip .txt { display: none; }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .barra { grid-template-columns: minmax(70px, 110px) minmax(0, 1fr) auto; }
  .acceso { grid-template-columns: minmax(0, 1fr); }
  .acceso .marca { padding: 24px max(20px, env(safe-area-inset-right, 0px)) 28px max(20px, env(safe-area-inset-left, 0px)); gap: 14px; }
  .acceso .marca .datos { display: none; }
  .acceso .marca h1 { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

/* Impresión de etiquetas (sin reporte) */
@media print {
  body:not(.imprimiendo) .side, body:not(.imprimiendo) .topbar, body:not(.imprimiendo) .no-print, body:not(.imprimiendo) .toasts { display: none !important; }
  body:not(.imprimiendo) .app { display: block; } body:not(.imprimiendo) .contenido { padding: 0; max-width: none; }
  .etiqueta { break-inside: avoid; }
  body { background: #fff; }
}

/* Reportes impresos */
#impresion { display: none; }
@page { size: A4 portrait; margin: 14mm 12mm 16mm; @bottom-right { content: "Página " counter(page) " de " counter(pages); font: 8pt Archivo, Arial, sans-serif; color: #607386; } @bottom-left { content: "Metal Mallas SRL"; font: 8pt Archivo, Arial, sans-serif; color: #607386; } }
@page apaisado { size: A4 landscape; }
@media print {
  html, body.imprimiendo { height: auto !important; min-height: 0 !important; padding: 0 !important; margin: 0 !important; background: #fff !important; }
  body.imprimiendo > :not(#impresion) { display: none !important; }
  body.imprimiendo #impresion { display: block; }
  .rep { color: #142533; font: 9pt/1.35 Archivo, Arial, sans-serif; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rep.apaisado { page: apaisado; }
  .rep-cab { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #004566; padding-bottom: 6px; position: relative; }
  .rep-cab::after { content: ""; position: absolute; right: 0; bottom: -2px; width: 120px; height: 2px; background: linear-gradient(90deg, #009347 50%, #E8650A 50%); }
  .rep-cab img { height: 38px; }
  .rep-emp { text-align: right; font-size: 8pt; color: #607386; }
  .rep-titulo { margin: 12px 0 4px; }
  .rep-titulo h1 { font: 650 17pt/1.1 Archivo, Arial, sans-serif; color: #004566; }
  .rep-titulo div { margin-top: 3px; }
  .rep-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 8pt; color: #607386; margin-bottom: 8px; }
  .rep-sandbox { color: #C4500A; font-weight: 700; }
  .rep h2 { font: 650 10.5pt/1.2 Archivo, Arial, sans-serif; color: #004566; margin: 12px 0 5px; }
  .rep table { width: 100%; border-collapse: collapse; }
  .rep th { background: #EEF2F5 !important; color: #142533; font: 650 7.5pt/1.2 Archivo, Arial, sans-serif; letter-spacing: .02em; padding: 4px 5px; border-bottom: 1px solid #B9C7D2; position: static; }
  .rep td { padding: 3px 5px; border-bottom: 1px solid #E6ECF0; vertical-align: top; }
  .rep tr { break-inside: avoid; }
  .rep thead { display: table-header-group; } .rep tfoot { display: table-row-group; }
  .rep tfoot td { font-weight: 700; border-top: 1.5px solid #142533; background: none; }
  .rep .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .rep .mono { font-family: 'IBM Plex Mono', monospace; font-size: 7.5pt; }
  .rep .rep-grupo td { background: #F5F8FA !important; }
  .rep .rep-sub td { font-weight: 700; }
  .rep .rep-haber { padding-left: 16px; display: inline-block; }
  .rep .rep-nota { font-size: 7.5pt; color: #607386; margin: 4px 0 0; }
  .rep .rep-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .rep .factura { border: 1px solid #DCE3E9; padding: 10px; background: none; }
  .rep-firmas { display: flex; gap: 30px; margin-top: 46px; break-inside: avoid; }
  .rep-firmas > div { flex: 1; text-align: center; font-size: 8pt; }
  .rep-firmas .linea { border-top: 1px solid #142533; margin-bottom: 4px; }
  .rep-pie { margin-top: 14px; font-size: 7pt; color: #607386; border-top: 1px solid #E6ECF0; padding-top: 4px; }
}

/* Plan de cuentas */
table.plan tr.titulo-cta td { background: var(--surface-2); }
table.plan tr.inactiva td { color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; flex-direction: row; }

/* Asistente en burbuja */
#asistente { position: fixed; right: 18px; bottom: 18px; z-index: 60; }
.as-burbuja { border-radius: 999px; padding: 12px 18px 12px 14px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 22px rgba(0, 40, 60, .28); font-size: .92rem; }
.as-burbuja:hover { background: var(--accent-hover); }
.as-panel { width: min(420px, calc(100vw - 24px)); height: min(620px, calc(100dvh - 36px)); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: 0 14px 44px rgba(0, 30, 45, .3); overflow: hidden; }
.as-panel header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 12px 14px; background: var(--side); color: var(--side-ink); border-top: 3px solid var(--orange); }
.as-panel header strong { color: #fff; }
.as-panel header .small { color: var(--side-muted); }
.as-panel header .cerrar { background: transparent; border: 0; color: #fff; font-size: 1.4rem; padding: 0 4px; }
.as-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.as-m { max-width: 92%; padding: 9px 12px; border-radius: 10px; line-height: 1.45; font-size: .9rem; overflow-x: auto; }
.as-m.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 3px; }
.as-m.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.as-m ul { margin: 4px 0; padding-left: 18px; }
.as-m table { border-collapse: collapse; margin: 6px 0; font-size: .82rem; }
.as-m th, .as-m td { border: 1px solid var(--line); padding: 3px 6px; text-align: left; }
.as-herr { margin-top: 6px; font-size: .75rem; color: var(--muted); }
.as-hola { color: var(--ink-2); font-size: .9rem; }
.as-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.as-chips button { white-space: normal; text-align: left; line-height: 1.3; }
.as-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--surface); }
.as-form input { flex: 1; min-width: 0; }
.as-panel footer { padding: 6px 12px 9px; background: var(--surface); }
@media print { #asistente { display: none !important; } }
@media (max-width: 640px) { .as-burbuja span { display: none; } .as-burbuja { padding: 14px; } }
body:has(#asistente) .toasts { bottom: 86px; z-index: 70; }

/* Roly IA */
.as-logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--orange); color: #fff; font-weight: 800; font-size: .95rem; flex: none; font-stretch: 112%; }
.as-burbuja { display: inline-flex; align-items: center; gap: 10px; }
.as-burbuja .as-logo { width: 28px; height: 28px; }
.as-panel header { align-items: center; }
.as-ico { background: transparent; border: 1px solid rgba(255,255,255,.28); color: #fff; padding: 5px 7px; border-radius: 8px; line-height: 0; }
.as-ico[aria-pressed="true"] { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.55); }
.as-mic { padding: 0 10px; line-height: 0; }
.as-mic.activo { background: var(--bad); border-color: var(--bad); color: #fff; animation: as-pulso 1.2s ease-in-out infinite; }
.as-form.escuchando input { border-color: var(--bad); background: var(--bad-bg); }
.as-micchip { display: inline-block; vertical-align: -4px; opacity: .85; }
.as-micchip svg { width: 15px; height: 15px; }
@keyframes as-pulso { 0%, 100% { box-shadow: 0 0 0 0 rgba(180, 35, 24, .45); } 50% { box-shadow: 0 0 0 7px rgba(180, 35, 24, 0); } }
@media (prefers-reduced-motion: reduce) { .as-mic.activo { animation: none; } }

/* Resumen diario (vista tipo WhatsApp) */
.wa-burbuja { background: #E7F8DC; color: #142533; border-radius: 10px 10px 10px 2px; padding: 12px 14px; font-size: .9rem; line-height: 1.5; max-width: 520px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
/* Etapas de importación */
.etapas { display: flex; gap: 3px; margin-bottom: 4px; }
.etapas span { width: 18px; height: 6px; border-radius: 3px; background: var(--line); }
.etapas span.hecha { background: var(--green); }
.etapas span.actual { background: var(--orange); }

/* Factura: representación gráfica con el formato del SIAT (carta) */
.fac { position: relative; font-family: Arial, Helvetica, sans-serif; color: #000; font-size: 9pt; width: 100%; }
.fac-marca { position: absolute; top: 38%; left: 0; right: 0; text-align: center; font-size: 34pt; font-weight: 700; color: rgba(180, 35, 24, .18); transform: rotate(-24deg); pointer-events: none; }
.fac-cab { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.fac-emisor { text-align: center; width: 44%; font-size: 8pt; line-height: 1.4; }
.fac-emisor img { width: 64px; display: block; margin: 0 auto 6px; }
.fac-emisor b { font-size: 10.5pt; display: block; margin-bottom: 2px; }
.fac-dir { font-size: 7pt; }
.fac-ids th { text-align: right; padding: 2px 10px; font-size: 9pt; vertical-align: top; }
.fac-ids td { font-size: 9pt; padding: 2px 0; max-width: 190px; }
.fac-ids .cuf { word-break: break-all; font-size: 8.5pt; }
.fac h1 { text-align: center; font-size: 14pt; letter-spacing: 2px; margin: 18px 0 2px; }
.fac-sub { text-align: center; margin-bottom: 26px; }
.fac table { border-collapse: collapse; }
.fac-cli { width: 100%; border: 1px solid #000; border-bottom: 0; }
.fac-cli td { padding: 4px 6px; } .fac-cli .r { text-align: left; width: 34%; }
.fac-items { width: 100%; border: 1px solid #000; }
.fac-items thead th { background: #D9D9D9; border: 1px solid #000; padding: 6px 4px; font-size: 8.5pt; }
.fac-items tbody td { border: 1px solid #000; padding: 2px 4px; font-size: 7.5pt; }
.fac-items .n { text-align: right; }
.fac-items tfoot th { border: 1px solid #000; text-align: right; padding: 2px 4px; font-size: 7.5pt; }
.fac-items tfoot td.n { border: 1px solid #000; font-weight: 700; padding: 2px 4px; }
.fac-items tfoot .vacia { border: 0; }
.fac-items .son { border-top: 1px solid #000; font-size: 10pt; padding: 4px; }
.fac-pie { display: flex; gap: 20px; margin-top: 18px; align-items: flex-start; }
.fac-leyendas { flex: 1; text-align: center; font-size: 7.5pt; }
.fac-leyendas p { margin: 0 0 8px; }
.fac-qr svg { width: 150px; height: 150px; }
@page factura { size: letter portrait; margin: 12mm 14mm; @bottom-left { content: none; } @bottom-right { content: "1/1"; font: 8pt Arial, sans-serif; color: #000; } }
.fac { page: factura; }
.fac table th, .fac table td { border-bottom: 0; background: none; letter-spacing: 0; text-transform: none; color: #000; }
.fac-items { table-layout: fixed; }
.fac-items thead th { background: #D9D9D9 !important; text-align: center; vertical-align: middle; }
.fac-items tbody td, .fac-items thead th, .fac-items tfoot th, .fac-items tfoot td.n { border: 1px solid #000 !important; }
.fac-items tfoot .vacia { border: 0 !important; border-left: 1px solid #000 !important; }
.fac-items .son { border: 1px solid #000 !important; }
.fac table th, .fac table td { white-space: normal !important; overflow-wrap: anywhere; }
.fac-items, .fac-cli { width: 100% !important; box-sizing: border-box; }
.fac-cli { border-right: 1px solid #000 !important; }
.fac-marca { white-space: nowrap; font-size: 30pt; }
.fac table th { overflow-wrap: normal; font-size: 7.5pt !important; }
.fac-items, .fac-cli { width: calc(100% - 2px) !important; }
.fac-ids th { font-size: 9pt !important; }
