/* Inventario — estilos */
:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #1c1f23;
  --ink-2: #4a5059;
  --muted: #7a808a;
  --line: #e4e1da;
  --accent: #0e6b5c;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ee;
  --danger: #b4321f;
  --danger-soft: #fbe9e5;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --info: #24569b;
  --info-soft: #e5eefb;
  --ok: #1d6b39;
  --ok-soft: #e2f3e7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .05), 0 1px 1px rgba(20, 20, 20, .03);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141618; --surface: #1c1f22; --surface-2: #212528; --ink: #ecebe7; --ink-2: #c3c6cb; --muted: #8d939b;
    --line: #2e3337; --accent: #3bb39c; --accent-ink: #08201b; --accent-soft: #163a33;
    --danger: #ef7a66; --danger-soft: #3b1d18; --warn: #f0b45a; --warn-soft: #3a2c14;
    --info: #86b1ec; --info-soft: #1b2a40; --ok: #6fcf8f; --ok-soft: #173322;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1rem; margin: 0 0 .75rem; }
.mt { margin-top: 1.5rem; }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; }
.nowrap { white-space: nowrap; }
.upper { text-transform: uppercase; }

/* Barra superior */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--ink); text-decoration: none !important; }
.brand span:last-child { display: flex; flex-direction: column; line-height: 1.15; }
.brand small { color: var(--muted); font-size: .75rem; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: 18px; }
.brand-lg .brand-mark { width: 42px; height: 42px; }
.nav { display: flex; gap: .15rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: .45rem .7rem; border-radius: 7px; color: var(--ink-2); white-space: nowrap; font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.logout { display: flex; align-items: center; gap: .5rem; margin: 0; }
.who { color: var(--muted); font-size: .85rem; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 1rem 2rem; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head p { margin: .35rem 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* Tarjetas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + .grid-2 { margin-top: 1rem; }
.empty { color: var(--muted); margin: .25rem 0; padding: .75rem 0; }
.card.flush .empty { padding: 1.25rem; }
.danger-zone .inline-form { align-items: center; }

/* Indicadores */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; gap: .15rem; box-shadow: var(--shadow); color: var(--ink); }
.stat-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-sub { color: var(--muted); font-size: .85rem; }
a.stat-sub { color: var(--accent); }
.stat-alert { border-color: var(--warn); background: var(--warn-soft); }
.stat-link:hover { text-decoration: none; border-color: var(--accent); }
.stat-link.on { border-color: var(--accent); background: var(--accent-soft); }

/* Tablas */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table thead th { background: var(--surface-2); color: var(--ink-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; white-space: nowrap; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td, .table tfoot th { border-top: 1px solid var(--line); border-bottom: 0; }
.card:not(.flush) .table th:first-child, .card:not(.flush) .table td:first-child { padding-left: 0; }
.card:not(.flush) .table thead th { background: transparent; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
tr.inactive td { opacity: .55; }
tr.sub td { background: var(--surface-2); font-size: .88rem; }
tr.warn-row td { background: var(--warn-soft); }
.w-qty { width: 110px; } .w-cost { width: 140px; } .w-sm { width: 90px; }
.lines input, .lines select { width: 100%; }

.qty { font-weight: 700; font-variant-numeric: tabular-nums; }
.qty-in { color: var(--ok); } .qty-out { color: var(--danger); } .qty-adj { color: var(--warn); }

.badge { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; margin-left: .25rem; white-space: nowrap; vertical-align: 1px; }
td > .badge:first-child, .page-head .badge:first-child { margin-left: 0; }
.badge-neutral { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }

/* Avisos */
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert ul { margin: 0; padding-left: 1.1rem; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.note { background: var(--surface-2); border: 1px dashed var(--line); border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem; font-size: .9rem; }

/* Formularios */
.form label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; margin-bottom: .9rem; }
.form label small { font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1rem; }
.span-2 { grid-column: 1 / -1; }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; min-height: 38px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
textarea { resize: vertical; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: none; }
label.inline, .form label.inline { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; margin-bottom: .5rem; }
fieldset.choice { border: 1px solid var(--line); border-radius: 8px; padding: .75rem 1rem .4rem; margin: 0 0 1rem; }
fieldset.choice legend { font-weight: 600; font-size: .9rem; padding: 0 .3rem; }
.checks { margin-bottom: .75rem; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .25rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .75rem 0 0; }
.inline-form.compact { margin: 0; flex-wrap: nowrap; }
.inline-form select, .inline-form input:not([type=checkbox]) { width: auto; flex: 1 1 220px; }
.inline-form input.w-sm { flex: 0 0 90px; width: 90px; }
form.inline { display: inline; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filters input[type=search] { flex: 1 1 260px; width: auto; }
.filters select, .filters input[type=date] { width: auto; }
.filters label.inline { margin: 0; white-space: nowrap; }
.counter { font-weight: 700; }
.counter.bad { color: var(--danger); } .counter.ok { color: var(--ok); }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .5rem .9rem; min-height: 38px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, black); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: .25rem .6rem; min-height: 30px; font-size: .82rem; }
.btn-block { width: 100%; }

/* Movimientos */
.product-strip { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; }
.comp-list { margin: 0 0 1rem; padding-left: 1.2rem; }
.check-group { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 1rem; overflow: hidden; }
.check-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; padding: .6rem .8rem; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.check-head .check-filter { width: auto; flex: 1 1 180px; min-height: 32px; padding: .3rem .55rem; }
.check-count { font-weight: 700; font-size: .85rem; }
.check-count.ok { color: var(--ok); } .check-count.bad { color: var(--danger); }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .1rem .75rem; padding: .6rem .8rem; max-height: 280px; overflow-y: auto; }
.form .check-list label { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; margin: 0; padding: .3rem 0; }
.check-list label.hidden { display: none; }

/* Acceso */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.75rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .06); }
.auth-card .brand { margin-bottom: 1.5rem; }
.auth-card h1 { margin-bottom: .35rem; }
.auth-card .form { margin-top: 1rem; }

@media (max-width: 860px) {
  .topbar-inner { flex-wrap: wrap; gap: .5rem; }
  .nav { order: 3; flex-basis: 100%; }
  .logout { margin-left: auto; }
  .grid-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .wrap { padding-top: 1rem; }
  h1 { font-size: 1.3rem; }
}
@media print {
  .topbar, .actions, .filters, .foot, .danger-zone, form .form-actions { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}

/* ======================= Marca SIM (negro carbón + dorado del membrete) ======================= */
:root {
  --brand-dark: #2b2b2b;
  --brand-gold: #e3b94d;
  --accent: #8a6516;
  --accent-ink: #ffffff;
  --accent-soft: #fbf1d6;
  --primary: #2b2b2b;
  --primary-ink: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root { --accent: #e3b94d; --accent-ink: #1b1b1b; --accent-soft: #3a3020; --primary: #e3b94d; --primary-ink: #1b1b1b; }
}
.topbar { background: var(--brand-dark); border-bottom: 3px solid var(--brand-gold); }
.topbar .brand { color: #fff; }
.topbar .brand small, .topbar .who { color: #c9c4b8; }
.brand-mark { background: var(--brand-gold); color: var(--brand-dark); }
.topbar .nav a { color: #dcd8cf; }
.topbar .nav a:hover { background: rgba(255,255,255,.08); }
.topbar .nav a.on { background: var(--brand-gold); color: var(--brand-dark); }
.topbar .btn-ghost { color: #fff; }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.1); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 85%, var(--brand-gold)); }
.auth-card { border-top: 4px solid var(--brand-gold); }

/* Semáforo de rentabilidad */
.sem { display: inline-flex; align-items: center; gap: .35rem; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.sem::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; background: currentColor; }
.sem-verde { background: #e2f3e7; color: #1d6b39; }
.sem-amarillo { background: #fdf6d3; color: #8a6d00; }
.sem-naranja { background: #fde9d6; color: #b25400; }
.sem-rojo { background: #fbe4e0; color: #b4321f; }
.sem-perdida { background: #b4321f; color: #fff; }
.sem-gris { background: var(--surface-2); color: var(--muted); }
.sem-legend { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
@media (prefers-color-scheme: dark) {
  .sem-verde { background: #173322; color: #6fcf8f; } .sem-amarillo { background: #3a3414; color: #f2d55c; }
  .sem-naranja { background: #3d2814; color: #f7a35c; } .sem-rojo { background: #3b1d18; color: #ef7a66; }
}

/* Formularios ampliados */
.form-sec { margin: .5rem 0 .75rem; padding-top: .75rem; border-top: 1px solid var(--line); font-size: .95rem; }
.form-sec:first-of-type { border-top: 0; padding-top: 0; }
.form-sec-details { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .9rem; margin-bottom: 1rem; }
.form-sec-details summary { cursor: pointer; font-weight: 600; }
.form-sec-details[open] summary { margin-bottom: .75rem; }
[hidden] { display: none !important; }
.thumb { max-width: 140px; max-height: 140px; border-radius: 8px; border: 1px solid var(--line); display: block; margin-bottom: .4rem; }
.small { font-size: .85rem; }
.calc td { padding: .45rem 0; }
.calc tr.hl td { background: var(--accent-soft); padding-left: .5rem; padding-right: .5rem; }
.grid-2.tight { gap: 1.5rem; }
.total-line { align-self: end; font-size: 1.05rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: .3rem; }
details.mini summary { cursor: pointer; color: var(--muted); font-size: .8rem; margin-top: .3rem; }
.inactive-card { opacity: .7; }
h3 { font-size: .9rem; margin: 1rem 0 .4rem; color: var(--ink-2); }

/* Ficha de producto */
.product-top { display: flex; gap: 1rem; align-items: flex-start; }
.product-top-main { flex: 1; min-width: 0; }
.product-photo { width: 180px; max-width: 40vw; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
.qty-move { color: var(--info); }

/* ======================= Interfaz de técnicos (móvil) ======================= */
.tech-head { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tech-back { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-size: 1.8rem; line-height: 1; color: var(--ink); text-decoration: none !important; }
.big-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.big-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; min-height: 200px; border-radius: 18px; font-size: 1.4rem; font-weight: 800; letter-spacing: .04em; text-decoration: none !important; box-shadow: var(--shadow); }
.big-btn small { font-size: .85rem; font-weight: 500; letter-spacing: 0; opacity: .85; }
.big-ico { font-size: 3rem; line-height: 1; }
.big-prod { background: var(--brand-dark); color: #fff; }
.big-tool { background: var(--brand-gold); color: var(--brand-dark); }
.tech-secondary { text-align: center; margin-top: 1.5rem; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; }
.menu-btn { display: flex; flex-direction: column; gap: .2rem; padding: 1.1rem 1.2rem; min-height: 86px; justify-content: center; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--brand-gold); color: var(--ink); text-decoration: none !important; box-shadow: var(--shadow); }
.menu-btn strong { font-size: 1.15rem; }
.menu-btn small { color: var(--muted); }
.menu-btn:active { transform: scale(.98); }
.scan-box { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.scan-box input[type=search] { flex: 1 1 200px; min-height: 52px; font-size: 1.1rem; }
.scan-box .btn { min-height: 52px; }
.tile-list { display: flex; flex-direction: column; gap: .5rem; }
.tile-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1rem; min-height: 64px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--ink); text-decoration: none !important; }
.tile-row span:first-child { display: flex; flex-direction: column; min-width: 0; }
.tile-row small { color: var(--muted); }
.tile-qty { font-weight: 800; font-size: 1.1rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
a.tile-row:active { background: var(--accent-soft); }
.big-form .input-big { font-size: 1.6rem; min-height: 56px; text-align: center; font-weight: 700; }
.btn-big { min-height: 56px; font-size: 1.1rem; }
fieldset.seg { display: flex; gap: .5rem; flex-wrap: wrap; }
fieldset.seg label { flex: 1 1 100px; flex-direction: row !important; align-items: center; justify-content: center; gap: .4rem; padding: .7rem; border: 1px solid var(--line); border-radius: 10px; font-weight: 600; margin: 0 !important; }
fieldset.seg label:has(input:checked) { border-color: var(--brand-gold); background: var(--accent-soft); }
.price-big { font-size: 2rem; font-weight: 800; margin: .25rem 0; }
.card .product-photo { width: 100%; max-width: 320px; margin-bottom: .75rem; }
@media (max-width: 520px) { .big-grid { grid-template-columns: 1fr; } .big-btn { min-height: 150px; } }

/* Escáner con cámara */
.scan-wrap { position: relative; display: flex; gap: .4rem; flex: 1 1 200px; }
.scan-wrap > input { flex: 1; min-width: 0; }
.scan-cam { flex: none; min-width: 44px; padding: 0 .7rem; }
.scan-modal { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 1rem; }
.scan-modal video { width: min(92vw, 520px); max-height: 60vh; border-radius: 12px; background: #000; object-fit: cover; }
.scan-modal p { color: #fff; text-align: center; margin: 0; }

/* Etiquetas */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(62mm, 1fr)); gap: 4mm; }
.label { border: 1px dashed var(--line); background: #fff; color: #000; padding: 3mm; text-align: center; break-inside: avoid; border-radius: 4px; }
.label svg { max-width: 100%; height: 14mm; }
.label-t { font-weight: 700; font-size: 9pt; line-height: 1.15; max-height: 2.4em; overflow: hidden; }
.label-c { font-family: ui-monospace, monospace; font-size: 8pt; }
.label-s { font-size: 8pt; }
@media print {
  .no-print, .page-head .actions, .alert { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .label { border-color: #ccc; }
}
/* Menú del administrador en su propia fila (muchas secciones) */
.topbar:not(.topbar-tech) .topbar-inner { flex-wrap: wrap; row-gap: .4rem; }
.topbar:not(.topbar-tech) .nav { order: 3; flex-basis: 100%; }
.topbar:not(.topbar-tech) .logout { margin-left: auto; }
img.brand-mark { width: 40px; height: 40px; object-fit: cover; padding: 0; background: var(--brand-dark); border: 1px solid rgba(255,255,255,.15); }
.table td.num { white-space: nowrap; }
/* Fase 2 */
.nested { border-left: 3px solid var(--brand-gold); padding-left: .9rem; }
.doc-lines td { vertical-align: middle; }
.doc-lines select { min-width: 260px; }
.approval-card { border-left: 5px solid var(--brand-gold); }
.claim { border-top: 1px solid var(--line); padding: .6rem 0; }
.claim:first-of-type { border-top: 0; }
.claim p { margin: .2rem 0; }
@media (max-width: 640px) {
  .doc-lines thead { display: none; }
  .doc-lines tbody tr { display: grid; grid-template-columns: 1fr 84px; gap: .4rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
  .doc-lines td { padding: 0 !important; border: 0; }
  .doc-lines td:nth-child(n+3) { grid-column: 1 / -1; }
  .doc-lines select { min-width: 0; }
  .doc-lines input[name="qty[]"]::placeholder { color: var(--muted); }
}
/* Fase 3 */
.topbar:not(.topbar-tech) .nav { flex-wrap: wrap; overflow: visible; }
.topbar:not(.topbar-tech) .nav a { padding: .35rem .6rem; font-size: .9rem; }
.sec-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 1.4rem 0 .6rem; }
.small-value { font-size: 1.05rem; }
.pad { padding: 1rem 1.2rem 0; }
.chart { margin: .5rem 0 0; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--ink-2); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 11px; font-family: system-ui, sans-serif; }
.chart .s1 { fill: #2b2b2b; } .chart .s2 { fill: #d9a52b; } .chart .s3 { fill: #9aa3ad; }
.chart figcaption { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--ink-2); margin-top: .3rem; }
.chart .lg i { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; }
.lg i.s1 { background: #2b2b2b; } .lg i.s2 { background: #d9a52b; } .lg i.s3 { background: #9aa3ad; }
@media (prefers-color-scheme: dark) { .chart .s1, .lg i.s1 { fill: #e9e6df; background: #e9e6df; } }
.seg-links { display: flex; gap: .25rem; }
.seg-links a { padding: .25rem .6rem; border-radius: 6px; border: 1px solid var(--line); font-size: .82rem; color: var(--ink-2); text-decoration: none; }
.seg-links a.on { background: var(--brand-dark); color: #fff; border-color: var(--brand-dark); }
.pnl .pnl-total td { font-weight: 700; border-top: 1px solid var(--ink-2); }
.pnl .pnl-sub td { color: var(--muted); font-size: .85rem; }
.pnl td:first-child { white-space: pre; }
.kit-custom { border-top: 1px solid var(--line); padding-top: .75rem; margin-top: .75rem; }
.kit-custom h3 { margin: 0 0 .25rem; font-size: 1rem; }
ul.plain { list-style: none; padding: 0; margin: .25rem 0; }
ul.plain li { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .2rem 0; }
/* Logotipo configurable */
img.brand-logo { height: 40px; width: auto; max-width: 150px; object-fit: contain; display: block; }
.topbar img.brand-logo.chip { background: #fff; border-radius: 8px; padding: 3px 6px; box-sizing: content-box; }
img.brand-logo-lg { height: 64px; max-width: 220px; }
.auth-card img.brand-logo.art-light { background: var(--brand-dark); border-radius: 10px; padding: 6px 10px; box-sizing: content-box; }
.logo-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin: 1rem 0; }
.logo-preview figure { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.logo-preview figcaption { font-size: .8rem; color: var(--muted); padding: .4rem .6rem; background: var(--surface-2); }
.logo-stage { display: flex; align-items: center; justify-content: center; min-height: 120px; padding: 1rem; }
.logo-stage img { max-width: 100%; max-height: 90px; height: auto; width: auto; }
.logo-stage.dark { background: var(--brand-dark); }
.logo-stage.light { background: #fff; }
.logo-stage.check { background-color: #fff; background-image: linear-gradient(45deg, #e8e8e8 25%, transparent 25%), linear-gradient(-45deg, #e8e8e8 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e8e8e8 75%), linear-gradient(-45deg, transparent 75%, #e8e8e8 75%); background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }
.logo-stage .chip { background: #fff; border-radius: 8px; padding: 4px 8px; display: inline-flex; }
.logo-stage .chip img { max-height: 40px; }
.logo-hist { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .8rem; }
.logo-hist .item { border: 1px solid var(--line); border-radius: 10px; padding: .6rem; display: flex; flex-direction: column; gap: .4rem; }
.logo-hist .item.on { border-color: var(--brand-gold); box-shadow: 0 0 0 2px var(--accent-soft); }
.logo-hist img { max-height: 56px; max-width: 100%; object-fit: contain; align-self: center; }
.logo-current { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem; padding: .6rem; margin-bottom: 1rem; border-radius: 10px; background: var(--brand-dark); }
.logo-current small { color: #c9c4b8; }
.logo-current img.brand-logo.chip { background: #fff; border-radius: 8px; padding: 3px 6px; box-sizing: content-box; }
.logo-hist .badge { align-self: flex-start; }
.sem-critico { background: #8f2416; color: #fff; }
.sem-perdida { background: #1f1f1f; color: #ff7b6b; }
@media (prefers-color-scheme: dark) { .sem-critico { background: #8f2416; color: #fff; } }
.pnl-head th { text-align: left; background: var(--surface-2); font-size: .8rem; letter-spacing: .02em; text-transform: uppercase; color: var(--ink-2); }

/* Evita desbordes horizontales en celular (selects con nombres largos) */
select { max-width: 100%; }

/* Equipos instalados (fichas con QR) */
.dl { display: grid; grid-template-columns: minmax(8rem, max-content) 1fr; gap: .45rem 1rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .85rem; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.eq-qr { text-align: center; }
.eq-qr svg { width: 180px; height: 180px; max-width: 100%; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 1rem .75rem; overflow-wrap: anywhere; }
.timeline li::before { content: ""; position: absolute; left: -1.42rem; top: .35rem; width: .7rem; height: .7rem; border-radius: 50%; background: var(--brand-gold); }
.labels-qr { grid-template-columns: repeat(auto-fill, minmax(78mm, 1fr)); }
.label-eq { display: flex; align-items: center; gap: 2mm; text-align: left; }
.label-eq svg { width: 26mm; height: 26mm; flex: 0 0 26mm; }
.label-eq-txt { min-width: 0; }
.label-eq-code { font-size: 11pt; font-weight: 700; }
.label-eq-co { margin-top: 1mm; font-weight: 600; }
@media (max-width: 640px) { .dl { grid-template-columns: 1fr; gap: .1rem; } .dl dd { margin-bottom: .5rem; } }

/* Agenda MASTER */
.text-danger { color: var(--danger); }
.agenda-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0 0 1rem; }
.agenda-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 1rem; }
.agenda-cols .agenda-col { margin-bottom: 0; }
.agenda-day.is-today { border-color: var(--brand-gold); }
.visit { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .15rem .75rem; padding: .6rem .7rem; margin: 0 0 .5rem; border: 1px solid var(--line); border-left: 4px solid var(--info); border-radius: 8px; color: inherit; text-decoration: none; }
.visit:hover { text-decoration: none; border-color: var(--accent); }
.visit-time { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.visit-main { min-width: 0; overflow-wrap: anywhere; }
.visit-badges { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .25rem; min-width: 0; }
.visit-terminada { border-left-color: var(--ok); opacity: .8; }
.visit-cancelada { border-left-color: var(--line); opacity: .6; }
.visit-pendiente_regreso, .visit-pausada, .visit-trabajando { border-left-color: var(--warn, #c98a00); }
.visit-conflict { border-left-color: var(--danger); background: var(--danger-soft); }
.visit-badges .badge { margin-left: 0; }

/* Agenda del técnico */
.agenda-today { display: block; color: inherit; text-decoration: none; border-left: 4px solid var(--brand-gold); }
.ma-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.ma-step { margin-bottom: .6rem; }
.ma-step input { margin-bottom: .4rem; }
.btn-block { display: block; width: 100%; text-align: center; }
details > summary.btn-block { list-style: none; margin-bottom: .5rem; }
.visit-when { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.attention { border-color: var(--danger); }
.req-item { border-top: 1px solid var(--line); padding-top: .6rem; margin-top: .6rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.inline-form input:not([type=checkbox]) { flex: 1 1 180px; min-width: 0; }

/* Avisos */
.bell { position: relative; text-decoration: none; font-size: 1.15rem; padding: .2rem .4rem; border-radius: 8px; color: inherit; }
.bell.on { background: var(--brand-gold); }
.bell-n { position: absolute; top: -.3rem; right: -.35rem; min-width: 1.1rem; padding: 0 .25rem; border-radius: 999px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; text-align: center; line-height: 1.1rem; }
.alerts-list { list-style: none; margin: 0; padding: 0; }
.al { display: flex; gap: .5rem; align-items: flex-start; border-left: 4px solid var(--info); padding: .5rem .6rem; margin-bottom: .5rem; background: var(--surface-2, transparent); border-radius: 6px; }
.al-warn { border-left-color: var(--warn); } .al-danger { border-left-color: var(--danger); } .al-read { opacity: .7; }
.al-open { flex: 1; min-width: 0; margin: 0; }
.al-btn { all: unset; cursor: pointer; display: block; width: 100%; overflow-wrap: anywhere; }
.al-btn:focus-visible { outline: 2px solid var(--accent); }
.al-rule { display: block; font-size: .75rem; color: var(--muted); }
.al-body { display: block; font-size: .85rem; }
li.al-danger strong { color: var(--danger); }

/* Historial de mantenimiento */
.stat-value.small-v { font-size: 1.1rem; }
.history .tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.history .tl-head .badge { margin-left: 0; }
.h-children { list-style: none; margin: .35rem 0 0; padding: .35rem .5rem; border-left: 2px dashed var(--line); }
.h-children li { padding: .15rem 0; overflow-wrap: anywhere; }
@media print { .history li { break-inside: avoid; } .stats { display: flex; flex-wrap: wrap; gap: 4mm; } }
.h-children li::before { display: none; }
