/* ─────────────────────────────────────────────────────
   ERPkurten — sistema de diseño
   Carbón + azul vidrio. Inter + JetBrains Mono.
───────────────────────────────────────────────────── */

:root {
  /* Surfaces */
  --bg:        #f6f6f4;
  --bg-elev:   #fbfbf9;
  --surface:   #ffffff;
  --surface-2: #f1f1ee;
  --surface-3: #e9e9e5;

  /* Ink */
  --ink:       #1a1d21;
  --ink-2:     #3d434b;
  --ink-3:     #6b7079;
  --ink-4:     #9aa0a8;
  --line:      #e3e3df;
  --line-2:    #d4d4cf;

  /* Brand */
  --carbon:    #3a4048;       /* del logo */
  --carbon-2:  #2a2f35;
  --glass:     #5fb4d9;       /* azul vidrio del logo */
  --glass-2:   #bfdbe8;
  --glass-3:   #e8f2f7;

  /* Accent */
  --accent:    #5fb4d9;
  --accent-ink:#1f6e92;

  /* Semáforo */
  --ok:        #15803d;
  --ok-bg:     #dcf2e3;
  --warn:      #b45309;
  --warn-bg:   #fbe9c8;
  --err:       #b91c1c;
  --err-bg:    #f7d6d4;
  --info:      #1f6e92;
  --info-bg:   #d8eaf3;
  --neutral-bg:#e9e9e5;

  /* INC-046: color por proceso del flujo de barras (cortar / lacar / cortar F) */
  --p-corte:     #4b5563;
  --p-corte-bg:  #e5e7eb;
  --p-lacado:    #7e22ce;
  --p-lacado-bg: #f3e8ff;
  --p-cortef:    #1d4ed8;
  --p-cortef-bg: #dbeafe;
  /* INC-057: recibido parcial (verde azulado: ni «Pedido» azul ni «Recibido» verde) */
  --p-parcial:    #0f766e;
  --p-parcial-bg: #ccfbf1;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Sizing */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --sidebar-w: 224px;
  --row-h: 32px;
}

[data-theme="dark"] {
  --bg:        #0f1115;
  --bg-elev:   #14171c;
  --surface:   #181b21;
  --surface-2: #1e222a;
  --surface-3: #262b34;

  --ink:       #e8eaee;
  --ink-2:     #c2c7cf;
  --ink-3:     #8b919b;
  --ink-4:     #5a606a;
  --line:      #262b34;
  --line-2:    #323844;

  --carbon:    #2a2f35;
  --carbon-2:  #1a1d21;

  --ok-bg:     rgba(21,128,61,.18);
  --warn-bg:   rgba(180,83,9,.20);
  --err-bg:    rgba(185,28,28,.20);
  --info-bg:   rgba(31,110,146,.22);
  --neutral-bg:#262b34;
  --glass-3:   rgba(95,180,217,.10);
}

[data-density="comfortable"] { --row-h: 40px; }
[data-density="dense"]       { --row-h: 28px; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv02','cv03','cv04','cv11';
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 13px; color: var(--ink); }

/* Aspecto ERP por defecto para controles de texto: borde, padding y fondo, de
   modo que ningún input suelto (p.ej. los modales de Configuración, que no usan
   .field ni .modal-card) salga con el estilo nativo del navegador. Va envuelto
   en :where() → especificidad 0: cualquier regla por clase (.field, .tb-search,
   .modal-card, .login-card, .cfg-select…) o estilo inline lo sobreescribe sin
   conflicto, así que no regresa ningún control ya estilado. Con box-sizing:
   border-box, en inputs de ancho fijo el borde/padding no desplaza el layout.
   Se excluyen checkbox/radio/file/range/color y los input-botón, que no deben
   llevar aspecto de campo de texto. */
:where(
  input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]):not([type=color]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image]),
  select,
  textarea
) {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 5px 8px;
  outline: none;
}
:where(
  input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]):not([type=color]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image]),
  select,
  textarea
):focus {
  border-color: var(--glass);
  box-shadow: 0 0 0 3px var(--glass-3);
}
a { color: inherit; text-decoration: none; }

.mono { font-family: var(--font-mono); font-feature-settings: 'tnum'; }
.tnum { font-variant-numeric: tabular-nums; }

/* ── App shell ─────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  transition: grid-template-columns .18s ease;
}

:root[data-sb-collapsed="true"] { --sidebar-w: 56px; }

/* ── Sidebar ─────────────────────────────── */
.sb {
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sb-brand {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sb-brand img { height: 22px; width: auto; display: block; }
.sb-brand .env-pill {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  padding: 2px 6px;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.sb-brand-mini {
  display: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.sb-toggle {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-3);
  width: 22px; height: 22px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sb-toggle:hover { background: var(--surface-2); color: var(--ink); }

.sb-search {
  position: relative;
  margin: 12px 12px 4px;
}
.sb-search input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 6px 10px 6px 28px;
  font-size: 12.5px;
  color: var(--ink);
  outline: none;
}
.sb-search input:focus { border-color: var(--glass); box-shadow: 0 0 0 3px var(--glass-3); }
.sb-search svg {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 13px; height: 13px; color: var(--ink-3);
}
.sb-search kbd {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 9.5px;
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 1px 4px; border-radius: 3px; color: var(--ink-3);
}

.sb-nav { flex: 1; overflow-y: auto; padding: 8px 8px 16px; }
.sb-nav::-webkit-scrollbar { width: 6px; }
.sb-nav::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }

.sb-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-4);
  padding: 12px 10px 4px;
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  position: relative;
}
.sb-item:hover { background: var(--surface-2); color: var(--ink); }
.sb-item.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}
.sb-item svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--ink-3); }
.sb-item.active svg { color: var(--accent-ink); }
.sb-item .count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 8px;
  min-width: 18px;
  text-align: center;
}
.sb-item.active .count { background: var(--glass-3); color: var(--accent-ink); }
.sb-item .soon {
  margin-left: auto;
  font-size: 9px;
  font-weight: 600;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.sb-foot {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 9px;
}
.avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--carbon);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
}
.sb-foot .who { line-height: 1.2; flex: 1; min-width: 0; }
.sb-foot .who .n { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.sb-foot .who .r { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.sb-foot .more {
  background: transparent; border: none; color: var(--ink-3);
  width: 24px; height: 24px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
}
.sb-foot .more:hover { background: var(--surface-2); color: var(--ink); }

/* ── Sidebar collapsed (icons-only) ─────────────────────────────── */
:root[data-sb-collapsed="true"] .sb {
  overflow: visible;
}
:root[data-sb-collapsed="true"] .sb-brand {
  padding: 14px 4px 12px;
  justify-content: center;
  gap: 6px;
}
:root[data-sb-collapsed="true"] .sb-brand img,
:root[data-sb-collapsed="true"] .sb-brand .env-pill {
  display: none;
}
:root[data-sb-collapsed="true"] .sb-brand-mini {
  display: block;
}
:root[data-sb-collapsed="true"] .sb-search {
  display: none;
}
:root[data-sb-collapsed="true"] .sb-group-label {
  display: none;
}
:root[data-sb-collapsed="true"] .sb-item {
  justify-content: center;
  gap: 0;
  padding: 8px 0;
}
:root[data-sb-collapsed="true"] .sb-label,
:root[data-sb-collapsed="true"] .sb-item .count {
  display: none;
}
:root[data-sb-collapsed="true"] .sb-foot {
  flex-direction: column;
  gap: 8px;
  padding: 10px 4px;
}
:root[data-sb-collapsed="true"] .sb-foot .who {
  display: none;
}
:root[data-sb-collapsed="true"] .sb-foot .more {
  width: 100%;
}
:root[data-sb-collapsed="true"] .user-menu {
  left: 100%;
  right: auto;
  bottom: 0;
  margin-left: 6px;
  width: 180px;
}

/* ── Main pane ─────────────────────────────── */
.main {
  display: flex; flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  height: 48px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 14px;
  flex-shrink: 0;
}
.crumbs { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-3); min-width: 0; }
.crumbs .sep { color: var(--ink-4); }
.crumbs .last { color: var(--ink); font-weight: 600; }
.topbar .spacer { flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-3);
  width: 30px; height: 30px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn.has-dot { position: relative; }
.icon-btn.has-dot::after {
  content: ''; position: absolute; top: 6px; right: 7px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--err); border: 2px solid var(--bg-elev);
}

.scroll {
  flex: 1; overflow: auto;
  padding: 22px 24px 60px;
}

/* ── Page header ─────────────────────────────── */
.page-h {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 18px; gap: 16px;
}
.page-h h1 {
  font-size: 22px; font-weight: 700; margin: 0;
  letter-spacing: -0.01em;
}
.page-h .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.page-h-actions { display: flex; gap: 8px; align-items: center; }

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-4); }
.btn svg { width: 13px; height: 13px; }
.btn.primary {
  background: var(--carbon); color: #fff; border-color: var(--carbon);
}
.btn.primary:hover { background: var(--carbon-2); border-color: var(--carbon-2); }
.btn.glass {
  background: var(--glass); color: #fff; border-color: var(--glass);
}
.btn.glass:hover { filter: brightness(.95); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 4px 8px; font-size: 11.5px; }

/* ── KPI Cards ─────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
}
.kpi .lbl {
  font-size: 11px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.kpi .lbl .dot { width: 6px; height: 6px; border-radius: 50%; }
.kpi .row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.kpi .num {
  font-family: var(--font-mono);
  font-size: 22px; font-weight: 600;
  letter-spacing: -0.02em; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.kpi .sub {
  font-family: var(--font-mono);
  font-size: 12px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.kpi .delta {
  font-size: 11px; font-weight: 600;
  padding: 2px 6px; border-radius: 3px;
  display: inline-flex; align-items: center; gap: 3px;
}
.kpi .delta.up { color: var(--ok); background: var(--ok-bg); }
.kpi .delta.down { color: var(--err); background: var(--err-bg); }
.kpi .spark { height: 28px; margin-top: 2px; }
/* INC-040: tarjetas que filtran (Órdenes a proveedor). */
.kpi.kpi-filtro { cursor: pointer; user-select: none; transition: border-color .12s, background .12s; }
.kpi.kpi-filtro:hover { border-color: var(--ink-4); }
.kpi.kpi-filtro.activa { border-color: var(--info); background: var(--info-bg); box-shadow: inset 0 0 0 1px var(--info); }
.kpi.kpi-filtro:focus-visible { outline: 2px solid var(--info); outline-offset: 1px; }

/* ── Toolbar (filters) ─────────────────────────────── */
.toolbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 8px 10px;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.tb-search {
  position: relative; min-width: 240px;
}
.tb-search input {
  width: 100%; background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 6px 10px 6px 28px;
  font-size: 12.5px;
  outline: none;
}
.tb-search input:focus { border-color: var(--glass); box-shadow: 0 0 0 3px var(--glass-3); }
.tb-search svg {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 13px; height: 13px; color: var(--ink-3);
}

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 9px; border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px dashed var(--line-2);
  font-size: 12px; color: var(--ink-2);
}
.chip:hover { border-color: var(--ink-4); color: var(--ink); }
.chip.active {
  background: var(--glass-3);
  border-style: solid; border-color: var(--glass);
  color: var(--accent-ink);
}
.chip svg { width: 12px; height: 12px; }
.chip .x { color: var(--ink-4); cursor: pointer; }
.chip .x:hover { color: var(--ink); }
.tb-spacer { flex: 1; }
.tb-divider { width: 1px; height: 18px; background: var(--line); margin: 0 2px; }

/* segmented */
.seg {
  display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 2px; gap: 2px;
}
.seg button {
  border: none; background: transparent;
  font-size: 12px; padding: 4px 10px;
  border-radius: 4px; color: var(--ink-3);
  font-weight: 500;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }

/* ── Table ─────────────────────────────── */
.tbl-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.tbl-wrap .tbl-scroll {
  overflow: auto;
  max-height: calc(100vh - 360px);
}
.tbl {
  width: 100%; border-collapse: collapse;
  font-size: 12.5px;
}
.tbl thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 8px 12px;
  white-space: nowrap;
  user-select: none;
}
.tbl thead th.sortable { cursor: pointer; }
.tbl thead th.sortable:hover { color: var(--ink); }
.tbl thead th .sort { margin-left: 4px; opacity: .35; }
.tbl thead th.sort-asc .sort, .tbl thead th.sort-desc .sort { opacity: 1; color: var(--accent-ink); }
.tbl tbody td {
  padding: 0 12px;
  height: var(--row-h);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  color: var(--ink-2);
  vertical-align: middle;
}
.tbl tbody tr { cursor: pointer; transition: background .1s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.selected { background: var(--glass-3); }
.tbl tbody tr.selected td { color: var(--ink); }
.tbl td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tbl td.right { text-align: right; }
.tbl td.strong { color: var(--ink); font-weight: 500; }
.tbl td.muted { color: var(--ink-3); }
.tbl td.truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
/* GUT-221: tablas dentro de un drawer, donde el ancho es escaso y el scroll
   horizontal es inusable para el personal de oficina. */
.tbl.tbl-compact thead th,
.tbl.tbl-compact tbody td { padding-left: 8px; padding-right: 8px; }
.tbl .ck {
  width: 14px; height: 14px;
  border: 1.5px solid var(--line-2); border-radius: 3px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.tbl .ck.on { background: var(--carbon); border-color: var(--carbon); }
.tbl .ck.on::after { content: ''; width: 7px; height: 4px; border-left: 1.5px solid #fff; border-bottom: 1.5px solid #fff; transform: rotate(-45deg) translate(1px,-1px); }

/* ── Status pill (chip with dot) ─────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px 2px 7px;
  border-radius: 11px;
  font-size: 11px; font-weight: 500;
  background: var(--neutral-bg);
  color: var(--ink-2);
  white-space: nowrap;
}
.pill .d { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-4); }
.pill.ok    { background: var(--ok-bg); color: var(--ok); }
.pill.ok .d    { background: var(--ok); }
.pill.warn  { background: var(--warn-bg); color: var(--warn); }
.pill.warn .d  { background: var(--warn); }
.pill.err   { background: var(--err-bg); color: var(--err); }
.pill.err .d   { background: var(--err); }
.pill.info  { background: var(--info-bg); color: var(--info); }
.pill.info .d  { background: var(--info); }
.pill.glass { background: var(--glass-3); color: var(--accent-ink); }
/* INC-046: Cortar gris · Lacar morado · Cortar F (corte final) azul */
.pill.p-corte  { background: var(--p-corte-bg);  color: var(--p-corte); }
.pill.p-corte .d  { background: var(--p-corte); }
.pill.p-lacado { background: var(--p-lacado-bg); color: var(--p-lacado); }
.pill.p-lacado .d { background: var(--p-lacado); }
.pill.p-cortef { background: var(--p-cortef-bg); color: var(--p-cortef); }
.pill.p-cortef .d { background: var(--p-cortef); }
.pill.p-parcial { background: var(--p-parcial-bg); color: var(--p-parcial); }
.pill.p-parcial .d { background: var(--p-parcial); }
.pill.glass .d { background: var(--glass); }

/* progress bar */
.pbar {
  width: 90px; height: 5px;
  background: var(--surface-3);
  border-radius: 3px; overflow: hidden;
  display: inline-block; vertical-align: middle;
  margin-right: 8px;
}
.pbar > i {
  display: block; height: 100%;
  background: var(--glass);
  border-radius: 3px;
}
.pbar.ok > i { background: var(--ok); }
.pbar.warn > i { background: var(--warn); }

/* ── Drawer (right side detail) ─────────────────────────────── */
.drawer-bg {
  position: fixed; inset: 0;
  background: rgba(20,22,26,.32);
  backdrop-filter: blur(2px);
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.drawer-bg.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 720px; max-width: 92vw;
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  z-index: 210;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.2,.7,.2,1);
  display: flex; flex-direction: column;
  box-shadow: -16px 0 40px rgba(20,22,26,.10);
}
.drawer.open { transform: translateX(0); }
.dr-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.dr-head .id { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.dr-head h2 { font-size: 16px; margin: 0; font-weight: 600; }
.dr-head .actions { margin-left: auto; display: flex; gap: 6px; }
.dr-tabs {
  display: flex; gap: 0;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.dr-tabs button {
  background: transparent; border: none;
  padding: 10px 14px;
  font-size: 12.5px; font-weight: 500;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.dr-tabs button.on { color: var(--ink); border-bottom-color: var(--carbon); }
.dr-body { flex: 1; overflow: auto; padding: 18px; }
/* GUT-262: ficha del expediente amplia (como la de Programación) y pestañas más grandes;
   en modo completo ocupa toda la pantalla. */
.drawer.exp-drawer { width: min(1180px, 96vw); max-width: 96vw; }
.drawer.exp-drawer.exp-drawer-full { width: 100vw; max-width: 100vw; }
.exp-drawer .dr-tabs { padding: 0 22px; }
.exp-drawer .dr-tabs button { font-size: 14px; padding: 12px 18px; }
.exp-drawer .dr-body { padding: 18px 22px 40px; }
.exp-drawer .tbl-compact { font-size: 13px !important; }
/* INC-002: ficha del proyecto = ficha del expediente + pestañas de Programación (11 pestañas). */
.exp-drawer.pg-drawer .dr-tabs { overflow-x: auto; scrollbar-width: thin; }
.exp-drawer.pg-drawer .dr-tabs button { padding: 12px 13px; white-space: nowrap; flex: none; }
/* Órdenes a proveedor / Compras: ficha amplia (como Expediente) y modo pantalla
   completa; las tarjetas de material de la OC van en rejilla según el ancho. */
.drawer.oc-drawer { width: min(1180px, 96vw); max-width: 96vw; }
/* INC-020: la OC a pantalla casi completa (deja ver un filo de la lista detrás). */
.drawer.oc-drawer.oc-drawer-xl { width: calc(100vw - 40px); max-width: calc(100vw - 40px); }
.drawer.oc-drawer.oc-drawer-full { width: 100vw; max-width: 100vw; }
.oc-drawer .dr-body { padding: 18px 22px 40px; }
.oc-mat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 500px), 1fr)); gap: 12px; align-items: start; }
.oc-form-head { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 12px; }
.oc-form-head .wide { grid-column: span 2; }
.oc-form-head .full { grid-column: 1 / -1; }
/* GUT-275: líneas de OC en tabla (modal Nueva orden y detalle › Materiales). Sin
   overflow en el contenedor: el desplegable del ComboBuscador tiene que salir. */
.oc-lines { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12.5px; }
.oc-lines th { text-align: left; font-size: 10.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; padding: 6px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.oc-lines td { padding: 5px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.oc-lines input, .oc-lines select { width: 100%; padding: 5px 7px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); font-size: 12.5px; min-width: 0; }
.oc-lines tr.oc-line-new td { background: var(--surface-2); }
/* INC-054: la tabla de Materiales de la OC (con TOTAL por línea) no se estruja en
   pantallas estrechas: por debajo de este ancho, scroll horizontal en el cuadro. */
.oc-lines.oc-lines-ficha { min-width: 1120px; }
.oc-line-mat { font-weight: 600; font-size: 12.5px; line-height: 1.3; padding-top: 5px; }
.oc-line-acts { display: flex; gap: 4px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.oc-exp-cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.oc-exp-cell select.oc-exp-vinc { font-size: 11.5px; padding: 3px 6px; color: var(--ink-2); }
.oc-exp-hint { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* GUT-272: cantidad/medidas que vienen de la hoja del proyecto (no editables en la OC). */
.oc-ro { padding: 5px 7px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); color: var(--ink-2); font-size: 12.5px; text-align: right; min-width: 0; cursor: not-allowed; font-variant-numeric: tabular-nums; }
.oc-ro-group { display: flex; align-items: center; gap: 3px; }
.oc-ro-group .oc-ro { flex: 1; padding: 5px 3px; text-align: center; font-size: 12px; }
.oc-lines select.oc-forma { margin-top: 3px; font-size: 11.5px; padding: 3px 6px; color: var(--ink-2); }
.oc-resumen td { padding: 6px 4px; font-variant-numeric: tabular-nums; }
/* INC-008: fila del material (con las barras) y sus cortes debajo. */
.oc-resumen tr.oc-resumen-grupo td { background: var(--surface-2); border-top: 1px solid var(--line); }
.oc-resumen tr.oc-resumen-corte td { padding: 3px 4px; font-size: 12px; border-bottom-color: transparent; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.field .v {
  font-size: 13px; color: var(--ink);
  padding: 5px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  min-height: 28px;
  display: flex; align-items: center;
}
.field input, .field select, .field textarea {
  font-size: 13px; color: var(--ink);
  padding: 5px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  outline: none;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--glass);
  box-shadow: 0 0 0 3px var(--glass-3);
}

.fields-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 14px; }
.fields-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.fields-grid .full { grid-column: 1 / -1; }

.section-title {
  font-size: 11px; font-weight: 700;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em;
  padding: 16px 0 8px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}

/* ── Tweaks panel ─────────────────────────────── */
.tweaks {
  position: fixed;
  bottom: 16px; right: 16px;
  width: 280px;
  background: var(--bg-elev);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: 0 12px 32px rgba(20,22,26,.18);
  z-index: 300;
  font-size: 12.5px;
  overflow: hidden;
}
.tweaks .h {
  padding: 10px 14px;
  background: var(--carbon);
  color: #fff;
  font-size: 12px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
  display: flex; align-items: center; gap: 8px;
}
.tweaks .h .dot { width: 6px; height: 6px; background: var(--glass); border-radius: 50%; }
.tweaks .body { padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.tweaks .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tweaks .row label { font-size: 12px; color: var(--ink-2); }
.tweaks .swatches { display: flex; gap: 6px; }
.tweaks .sw {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--surface);
  outline: 1px solid var(--line);
  cursor: pointer;
}
.tweaks .sw.on { outline: 2px solid var(--carbon); }

/* placeholder image (striped) */
.ph {
  background:
    repeating-linear-gradient(45deg, var(--surface-2) 0 8px, var(--surface-3) 8px 16px);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* timeline */
.tl { display: flex; flex-direction: column; gap: 0; }
.tl-item {
  display: grid; grid-template-columns: 16px 1fr; gap: 10px;
  padding: 8px 0;
  position: relative;
}
.tl-item::before {
  content: ''; position: absolute;
  left: 7px; top: 22px; bottom: -8px;
  width: 1px; background: var(--line-2);
}
.tl-item:last-child::before { display: none; }
.tl-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--ink-4);
  margin: 8px 4px 0;
}
.tl-dot.ok { border-color: var(--ok); background: var(--ok); }
.tl-dot.glass { border-color: var(--glass); background: var(--glass); }
.tl-dot.warn { border-color: var(--warn); background: var(--warn); }
.tl-content .t { font-size: 12.5px; color: var(--ink); font-weight: 500; }
.tl-content .m { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.tl-content time { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-4); }

/* card grid for Live partes */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.lcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px;
  position: relative;
  overflow: hidden;
}
.lcard .live-dot {
  position: absolute; top: 12px; right: 12px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(21,128,61,.5);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(21,128,61,.5); }
  70%  { box-shadow: 0 0 0 8px rgba(21,128,61,0); }
  100% { box-shadow: 0 0 0 0 rgba(21,128,61,0); }
}
.lcard .who { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.lcard .who .n { font-weight: 600; font-size: 13.5px; }
.lcard .who .r { font-size: 11px; color: var(--ink-3); }
.lcard .meta { font-size: 11.5px; color: var(--ink-3); margin-bottom: 10px; }
.lcard .meta strong { color: var(--ink); font-weight: 500; }
.lcard .progress { display: flex; align-items: center; gap: 8px; }
.lcard .pbar { flex: 1; width: auto; }
.lcard .pct { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); min-width: 32px; text-align: right; }
.lcard .last { font-size: 10.5px; color: var(--ink-4); margin-top: 8px; font-family: var(--font-mono); }

/* segmented tabs (subnav) */
.subnav {
  display: flex; align-items: center; gap: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.subnav button {
  background: transparent; border: none;
  padding: 8px 0;
  font-size: 13px; font-weight: 500;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subnav button.on { color: var(--ink); border-bottom-color: var(--carbon); }
.subnav button:hover { color: var(--ink); }
.subnav .ct {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--surface-2);
  padding: 1px 6px; border-radius: 8px;
  color: var(--ink-3); margin-left: 6px;
}

/* tooltip */
.tip { position: relative; }
.tip::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--carbon-2); color: #fff;
  padding: 4px 8px; border-radius: 4px; font-size: 11px;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .15s;
}
.tip:hover::after { opacity: 1; }

/* GUT-226: icono de ayuda `?` con explicación al hover. A diferencia de .tip,
   el texto envuelve — aquí caben frases, no etiquetas de un botón. */
.helptip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px;
  margin-left: 4px;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-3);
  font-family: var(--font-sans);
  font-size: 9px; font-weight: 700; line-height: 1;
  letter-spacing: 0; text-transform: none;
  vertical-align: middle;
  cursor: help;
  position: relative;
  outline: none;
}
.helptip:hover, .helptip:focus-visible {
  background: var(--glass-3);
  border-color: var(--glass);
  color: var(--accent-ink);
}
.helptip::after {
  content: attr(data-help);
  position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%);
  width: 240px;
  background: var(--carbon-2); color: #fff;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  font-size: 11.5px; font-weight: 400; line-height: 1.4;
  text-align: left; white-space: normal;
  opacity: 0; pointer-events: none;
  transition: opacity .15s;
  z-index: 300;
}
/* Cerca del borde derecho el tooltip se ancla por su lado derecho. */
.helptip.flip::after { left: auto; right: -6px; transform: none; }
.helptip:hover::after, .helptip:focus-visible::after { opacity: 1; }

/* product avatar (mini) */
.prod {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  background: var(--glass-3);
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden;
  vertical-align: middle;
}
.prod img { width: 100%; height: 100%; object-fit: cover; }

/* tag stack */
.tags { display: inline-flex; flex-wrap: wrap; gap: 3px; }
.tag {
  font-size: 10.5px;
  padding: 1px 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink-2);
}

/* split layout for production planning */
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.panel-h {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600;
}
.panel-h .badge {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  background: var(--surface-2); padding: 1px 6px; border-radius: 3px;
  color: var(--ink-3);
}
.panel-b { padding: 12px 14px; }

/* form layout in drawer */
.dr-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
}

/* attachment chip */
.attach {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: 12px;
}
.attach .ic {
  width: 24px; height: 24px;
  background: var(--glass-3);
  color: var(--accent-ink);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 9px; font-weight: 700;
}
.attach .sz { color: var(--ink-3); margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; }

/* reusable attachments */
.archivos-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.archivos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}
.archivo-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  font-family: inherit;
}
button.archivo-card { cursor: pointer; }
.archivo-card:hover { background: var(--surface-2); }
.archivo-thumb {
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--glass-3);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
}
.archivo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.archivo-ext {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}
.archivo-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border: 0;
  padding: 0;
  background: transparent;
  text-align: left;
  color: inherit;
  font-family: inherit;
}
.archivo-name {
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.archivo-sub { font-size: 11px; color: var(--ink-3); }
.archivo-actions { display: inline-flex; align-items: center; gap: 2px; }

/* INC-004 — datos de facturación y envío encima de la carpeta del cliente */
.cli-datos {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); padding: 12px 14px; margin-bottom: 12px;
}
.cli-datos-col { min-width: 0; }
.cli-datos .section-title { margin-top: 0; }
@media (max-width: 760px) { .cli-datos { grid-template-columns: 1fr; } }

/* GUT-225 — explorador de archivos tipo escritorio */
.fx {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.fx-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.fx-nav {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.fx-nav:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line-2); }
.fx-nav:disabled { color: var(--ink-4); cursor: default; }
.fx-nav.on { background: var(--glass-3); border-color: var(--glass-2); color: var(--accent-ink); }
.fx-views { display: inline-flex; gap: 2px; }
.fx-path {
  display: flex; align-items: center; gap: 4px;
  flex: 1 1 200px; min-width: 0;
  padding: 3px 8px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  height: 26px;
  overflow: hidden;
}
.fx-crumb {
  display: inline-flex; align-items: center; gap: 5px;
  border: 0; background: transparent; padding: 2px 4px;
  border-radius: var(--r-sm);
  font-family: inherit; font-size: 12px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
button.fx-crumb { cursor: pointer; }
button.fx-crumb:hover { background: var(--surface-2); }
.fx-crumb.current { color: var(--ink); font-weight: 600; }
.fx-sep { color: var(--ink-4); flex: 0 0 auto; }
.fx-search {
  display: inline-flex; align-items: center; gap: 5px;
  flex: 0 1 190px;
  height: 26px; padding: 0 8px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-3);
}
.fx-search input {
  border: 0; background: transparent; outline: none;
  width: 100%; font-family: inherit; font-size: 12px; color: var(--ink);
}
.fx .btn:disabled, .fx .btn.disabled { opacity: .45; }
.fx-body { display: grid; grid-template-columns: 190px minmax(0, 1fr); min-height: 260px; }
.fx-tree {
  border-right: 1px solid var(--line);
  background: var(--bg-elev);
  padding: 6px;
  display: flex; flex-direction: column; gap: 1px;
}
.fx-tree-item {
  display: flex; align-items: center; gap: 7px;
  width: 100%; padding: 5px 8px;
  border: 0; border-radius: var(--r-sm);
  background: transparent; cursor: pointer;
  font-family: inherit; font-size: 12px; color: var(--ink-2);
  text-align: left;
}
.fx-tree-item span {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fx-tree-item em {
  font-style: normal; font-family: var(--font-mono);
  font-size: 10px; color: var(--ink-4);
}
.fx-tree-item svg { color: var(--accent-ink); flex: 0 0 auto; }
.fx-tree-item:hover { background: var(--surface-2); }
.fx-tree-item.on { background: var(--glass-3); color: var(--ink); font-weight: 600; }
.fx-tree-item.root { margin-bottom: 4px; }
.fx-main { position: relative; overflow: auto; outline: none; max-height: 460px; }
.fx-main.dragging { background: var(--glass-3); }
.fx-empty { font-size: 12px; padding: 26px 16px; text-align: center; }
.fx-drop {
  position: absolute; inset: 6px;
  border: 2px dashed var(--glass);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 600; color: var(--accent-ink);
  background: rgba(255, 255, 255, .7);
  pointer-events: none;
}
.fx-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.fx-table th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-weight: 600; font-size: 11px;
  color: var(--ink-3); background: var(--surface);
  padding: 6px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.fx-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  white-space: nowrap;
}
.fx-table td:first-child { display: flex; align-items: center; gap: 8px; }
.fx-row { cursor: default; user-select: none; }
.fx-row:hover { background: var(--surface-2); }
.fx-row.sel, .fx-row.sel:hover { background: var(--glass-3); }
.fx-row.sel .fx-name { color: var(--ink); }
.fx-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink); font-weight: 500;
}
.fx-icon {
  width: 24px; height: 24px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  background: var(--glass-3); color: var(--accent-ink);
  overflow: hidden;
}
.fx-icon img { width: 100%; height: 100%; object-fit: cover; }
.fx-icon.folder { background: transparent; }
.fx-ext { font-family: var(--font-mono); font-size: 8.5px; font-weight: 700; }
.fx-icons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 6px; padding: 10px;
}
.fx-tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 6px;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: transparent; cursor: default;
  font-family: inherit; user-select: none;
  min-width: 0;
}
.fx-tile:hover { background: var(--surface-2); }
.fx-tile.sel, .fx-tile.sel:hover { background: var(--glass-3); border-color: var(--glass-2); }
.fx-tile-img {
  width: 54px; height: 54px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  background: var(--glass-3); color: var(--accent-ink);
  overflow: hidden;
}
.fx-tile-img img { width: 100%; height: 100%; object-fit: cover; }
.fx-tile-img.folder { background: transparent; }
.fx-tile-img .fx-ext { font-size: 12px; }
.fx-tile-name {
  font-size: 11.5px; font-weight: 500; color: var(--ink);
  width: 100%; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fx-tile-sub { font-size: 10.5px; color: var(--ink-3); }
.fx-status {
  display: flex; align-items: center; gap: 14px;
  padding: 6px 10px;
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
  font-size: 11.5px; color: var(--ink-3);
}
.fx-status-actions { margin-left: auto; display: inline-flex; gap: 4px; }
.fx-status-actions .btn { padding: 4px 8px; font-size: 11.5px; }
.fx-menu {
  position: fixed; z-index: 300;
  min-width: 160px; padding: 4px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
  display: flex; flex-direction: column;
}
.fx-menu button {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border: 0; border-radius: var(--r-sm);
  background: transparent; cursor: pointer;
  font-family: inherit; font-size: 12px; color: var(--ink-2);
  text-align: left;
}
.fx-menu button:hover { background: var(--surface-2); }
.fx-menu button.danger { color: var(--err); }
@media (max-width: 760px) {
  .fx-body { grid-template-columns: minmax(0, 1fr); }
  .fx-tree { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .fx-tree-item { width: auto; white-space: nowrap; }
}

/* phase 7: presupuestos + configurador */
.cfg-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 340px;
  gap: 14px;
  align-items: start;
}
.cfg-tarifa {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 12px;
  color: var(--ink-2);
}
.cfg-select {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
}
.cfg-product-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: calc(100vh - 330px);
  overflow: auto;
}
.cfg-product {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}
.cfg-product.on {
  border-color: var(--glass);
  background: var(--glass-3);
}
.cfg-product strong,
.cfg-product small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cfg-product strong { font-size: 12.5px; }
.cfg-product small { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.cfg-bool {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--ink);
}
.cfg-price-total {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
}
.cfg-price-total span {
  font-size: 13px;
  color: var(--ink-3);
  font-weight: 500;
}
.cfg-price-sub { margin-top: 4px; font-size: 12.5px; color: var(--ink-2); }
.cfg-price-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.cfg-price-grid div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.cfg-price-grid span {
  display: block;
  font-size: 10.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 4px;
}
.cfg-warnings {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--warn);
  border-radius: var(--r-sm);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 12px;
}
.presu-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.presu-list {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 370px);
  overflow: auto;
}
.presu-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  font-family: inherit;
}
.presu-list-item:hover,
.presu-list-item.on {
  background: var(--glass-3);
}
.presu-list-item strong,
.presu-list-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.presu-list-item strong { font-size: 12.5px; }
.presu-list-item small { font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.presu-list-item > span:last-child {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  font-size: 11.5px;
}
.presu-detail .tbl-wrap .tbl-scroll { max-height: none; }
.presu-totals {
  width: min(360px, 100%);
  margin: 14px 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.presu-totals div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.presu-totals div:last-child { border-bottom: 0; }
.presu-totals .total {
  background: var(--carbon);
  color: #fff;
  font-size: 14px;
}
.presu-notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.presu-notes div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.presu-notes strong,
.presu-notes span {
  display: block;
  font-size: 12px;
}
.presu-notes strong { margin-bottom: 5px; color: var(--ink); }
.presu-notes span { color: var(--ink-2); white-space: pre-wrap; }
.presu-modal { max-width: 720px; }
.presu-linea-modal { max-width: 780px; }
.presu-preview {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: 13px;
}

@media (max-width: 1180px) {
  .cfg-layout,
  .presu-layout { grid-template-columns: 1fr; }
  .cfg-product-list,
  .presu-list { max-height: none; }
  .presu-notes { grid-template-columns: 1fr; }
}

/* small color marker for vendedor */
.vend {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px;
}
.vend .av {
  width: 18px; height: 18px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 9.5px; font-weight: 600;
}

/* ── helpers ─────────────────────────────── */
.hide { display: none !important; }
.flex { display: flex; }
.gap-6 { gap: 6px; }
.gap-10 { gap: 10px; }
.mb-12 { margin-bottom: 12px; }
.mt-12 { margin-top: 12px; }
.muted { color: var(--ink-3); }
.right { text-align: right; }
.row-flex { display: flex; align-items: center; gap: 8px; }

/* ── Login screen ─────────────────────────────────── */
.login-shell {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--glass-3) 0%, var(--surface) 100%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.08);
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 8px; }
.login-logo  { width: 56px; height: 56px; object-fit: contain; }
.login-brand h1 { font-size: 18px; font-weight: 600; margin: 0; color: var(--ink-1); }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
.login-card input {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px;
  background: var(--surface); color: var(--ink-1);
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-error { color: #b91c1c; font-size: 12px; padding: 6px 10px; background: #fee2e2; border-radius: 4px; }

/* ── Modal ─────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-card {
  background: var(--surface); border-radius: 10px; width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 12px; padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
.modal-card header { display: flex; align-items: center; justify-content: space-between; }
.modal-card header h2 { font-size: 15px; font-weight: 600; margin: 0; }
.modal-card .x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--ink-3); line-height: 1; }
.modal-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
.modal-card input {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px;
  background: var(--surface);
}
.modal-card footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ── Toast ─────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; max-width: min(90vw, 520px);
  background: #1a1d21; color: #fff; padding: 10px 16px; border-radius: 6px;
  font-size: 13px; z-index: 2000; box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast--err { background: #b42318; }
.toast-msg { flex: 1; line-height: 1.4; }
.toast-close {
  flex: none; background: none; border: 0; color: #fff; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 0 2px; opacity: .8;
}
.toast-close:hover { opacity: 1; }

/* ── User menu (sidebar footer) ───────────────────── */
.sb-foot { position: relative; }
.user-menu {
  position: absolute; bottom: calc(100% + 4px); right: 8px; left: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 10; overflow: hidden;
}
.user-menu button {
  display: block; width: 100%; padding: 9px 12px; text-align: left;
  background: none; border: 0; font-size: 13px; cursor: pointer; color: var(--ink-1);
}
.user-menu button:hover { background: var(--glass-3); }

/* ── Programación (sustituye PROGRAMACIÓN.xlsm) ───────────────── */
.pg-tbl tbody tr.pg-row { cursor: default; }
.pg-tbl tbody td { padding: 0 6px; }
/* Proyectos (GUT-248): anchos fijos por cabecera; el sobrante va a Observación, no a Instaladores */
.pg-tbl.pg-main { min-width: 1700px; table-layout: fixed; }
.pg-tbl.pg-main tbody td { overflow: hidden; text-overflow: ellipsis; }
.pg-tbl.pg-wide { min-width: 1700px; } /* Materiales global: tabla compartida con Expediente (GUT-272) + Proyecto e Instalación (GUT-273) */
.pg-art-x { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; margin-left: 4px; padding: 0;
  border: 1px solid currentColor; border-radius: 50%; background: var(--surface); color: inherit; cursor: pointer; }
.pg-art-x:hover { background: var(--info); color: #fff; border-color: var(--info); }
.pg-tbl.pg-mid { min-width: 1250px; }
.pg-tbl.pg-main input[type=number] { min-width: 52px; }
.pg-tbl tbody tr.pg-done td { opacity: .55; }
/* GUT-273: Materiales global — instalación en ≤7 días (o pasada) con material pendiente */
.pg-tbl tbody tr.pg-urgente td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.pg-tbl tbody tr.pg-urgente td { background: color-mix(in srgb, var(--warn-bg) 45%, transparent); }
.pg-urg-fecha { font-weight: 600; }
.pg-urg-fecha.warn { color: var(--warn); }
.pg-urg-fecha.err { color: var(--err, #b91c1c); }
.pg-in {
  font: inherit; font-size: 12.5px; color: var(--ink-2);
  border: 1px solid transparent; background: transparent; border-radius: 4px;
  padding: 3px 6px; width: 100%; min-width: 0; box-sizing: border-box;
}
.pg-in:hover { border-color: var(--line); background: var(--surface); }
/* INC-072: prioridad + nº de orden dentro de la prioridad, en la misma celda. */
.pg-prio { display: flex; align-items: center; gap: 4px; min-width: 0; }
.pg-prio > select { flex: 1 1 auto; min-width: 0; }
.pg-prio .pg-prio-n { flex: 0 0 38px; width: 38px; min-width: 38px !important; text-align: center; padding-left: 2px; padding-right: 2px; font-weight: 600; }
.pg-in:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 2px var(--glass-3); color: var(--ink); }
textarea.pg-in { resize: vertical; min-height: 60px; line-height: 1.4; }
/* Textos que crecen con el contenido: nunca se recorta lo escrito */
textarea.pg-in.pg-area { resize: none; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; }
textarea.pg-in.pg-cell-area { min-height: 26px; padding: 4px 6px; line-height: 1.35; display: block; }
/* INC-070: en la tabla de Proyectos, las observaciones largas no estiran la fila: ~3 líneas y scroll. */
.pg-tbl.pg-main textarea.pg-in.pg-cell-area { max-height: 62px; overflow-y: auto; }
.pg-tbl tbody td.pg-td-text { white-space: normal; padding-top: 3px; padding-bottom: 3px; height: auto; }
.pg-tbl tbody tr { height: var(--row-h); }
/* Ficha de proyecto: panel amplio; en modo completo ocupa toda la pantalla */
.drawer.pg-drawer { width: min(1180px, 96vw); max-width: 96vw; }
.drawer.pg-drawer.pg-drawer-full { width: 100vw; max-width: 100vw; }
.pg-drawer .dr-head h2 { white-space: normal; line-height: 1.3; overflow-wrap: anywhere; }
.pg-drawer .dr-body { padding: 18px 22px 40px; }
.pg-drawer textarea.pg-in { min-height: 72px; font-size: 13px; color: var(--ink); }
select.pg-in { cursor: pointer; }
select.pg-pill { font-weight: 500; }
select.pg-pill.ok    { background: var(--ok-bg);   color: var(--ok); }
select.pg-pill.warn  { background: var(--warn-bg); color: var(--warn); }
select.pg-pill.err   { background: var(--err-bg);  color: var(--err); }
select.pg-pill.info  { background: var(--info-bg); color: var(--info); }
select.pg-pill.glass { background: var(--glass-3); color: var(--accent-ink); }
.pg-ck { width: 15px; height: 15px; cursor: pointer; accent-color: var(--carbon); vertical-align: middle; }
.pg-check-lbl { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; padding-top: 4px; }
.pg-color { width: 26px; height: 22px; border: 1px solid var(--line); border-radius: 4px; padding: 0; background: none; cursor: pointer; }
.pg-fields .field .pg-in { border-color: var(--line); background: var(--surface); }
.pg-fields .field .v { font-size: 13px; padding: 4px 0; }
.pg-addrow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pg-addrow input, .pg-addrow select {
  font: inherit; font-size: 12.5px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); min-width: 0;
}
.pg-note { font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; }
.pg-exp-row { display: flex; gap: 12px; align-items: center; padding: 8px 12px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--line); }
.pg-exp-row:hover { background: var(--surface-2); }
.pg-exp-row.ya { background: var(--surface-2); }
.pg-exp-row.ya .mono { color: var(--ink-3); }
/* GUT-260: "ya en Programación", caja "ya existe" y aviso de coincidencias terminadas */
.pg-ya { font-size: 11px; color: var(--info); background: var(--info-bg); border-radius: 10px; padding: 2px 8px; white-space: nowrap; }
.pg-existe { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; font-size: 13px; border: 1px solid var(--warn); background: var(--warn-bg); border-radius: 6px; }
.pg-existe-tit { display: flex; gap: 6px; align-items: center; font-weight: 600; color: var(--warn); }
/* INC-038: confirmación en pantalla de Cerrar proyecto / expediente (cabecera de la ficha). */
.pg-confirm-cierre { display: inline-flex; gap: 6px; align-items: center; padding: 2px 4px 2px 10px; font-size: 12px; background: var(--warn-bg); border: 1px solid var(--warn); border-radius: 6px; }
.pg-aviso-todos { display: flex; gap: 8px; align-items: center; margin: 0 0 8px; padding: 6px 10px; font-size: 12px; background: var(--info-bg); color: var(--info); border-radius: 6px; }
.pg-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; background: var(--ink-4); }

/* Calendario semanal */
.pg-scroll-x { overflow-x: auto; }
.pg-cal-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.pg-cal { display: grid; min-width: 100%; }
.pg-cal .hd {
  padding: 8px 10px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3);
  background: var(--bg-elev); border-bottom: 1px solid var(--line); border-left: 1px solid var(--line);
}
.pg-cal .hd:first-child, .pg-cal .inst { border-left: none; }
.pg-cal .inst { padding: 8px 10px; white-space: nowrap; font-size: 12.5px; font-weight: 500; color: var(--ink); border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.pg-cal .cell { min-height: 56px; min-width: 0; padding: 4px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); }
.pg-cal .off { background: var(--surface-2); }
.pg-cal .today { background: var(--glass-3); }
.pg-cal .hd.today { color: var(--accent-ink); }
.pg-chip {
  position: relative; display: block; font-size: 11px; line-height: 1.25; padding: 4px 6px 4px 8px; border-radius: 4px; margin-bottom: 3px;
  color: var(--pg-tc-ink, #fff); background: var(--pg-tc, var(--carbon)); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18);
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pg-chip:hover { filter: brightness(1.1); }
.pg-chip.pg-solo-ver { cursor: default; }
.pg-chip.pg-solo-ver:hover { filter: none; }
.tbl tbody tr.pg-solo-ver { cursor: default; }
.tbl tbody tr.pg-solo-ver:hover { background: transparent; }
.pg-chip .mono { font-family: var(--font-mono); }
.pg-chip em { font-style: normal; }
.pg-chip small { opacity: .75; font-size: 10px; }
.pg-chip.ko { text-decoration: line-through; opacity: .6; }
/* INC-050: hecho = tono claro del color de su tipo, con raya de ese color (el texto se sigue leyendo). */
.pg-chip.done { background: color-mix(in srgb, var(--pg-tc, var(--carbon)) 28%, #fff); color: #1f2937; box-shadow: inset 4px 0 0 var(--pg-tc, var(--carbon)), inset 0 0 0 1px rgba(0, 0, 0, .18); }
.pg-chip .pg-warn { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--warn); }
/* GUT-245: fecha que pide el cliente — marcador punteado, no asignación. */
.pg-chip.t-prevista { background: transparent; color: var(--ink); border: 1px dashed var(--ink-3); box-shadow: none; }
.pg-gantt .bar.t-prevista { background: transparent; border: 1px dashed var(--ink-3); height: 12px; box-sizing: border-box; }
.pg-tbl td.pg-fc.warn { background: var(--warn-bg); box-shadow: inset 3px 0 0 var(--warn); }
.pg-tbl td.pg-fc.err { background: var(--err-bg, #fee2e2); box-shadow: inset 3px 0 0 var(--err, #b91c1c); }
.pg-fc-note { margin-bottom: 10px; }
.pg-fc-note.warn { background: var(--warn-bg); border-color: var(--warn); }
.pg-fc-note.err { background: var(--err-bg, #fee2e2); border-color: var(--err, #b91c1c); }
.pg-legend { display: flex; gap: 6px 14px; flex-wrap: wrap; margin-bottom: 10px; font-size: 11.5px; color: var(--ink-2); }
.pg-legend span { display: inline-flex; align-items: center; }
.pg-legend-sep { padding-left: 14px; border-left: 1px solid var(--line); }
/* INC-075: la leyenda filtra por tipo */
.pg-legend .pg-leg-tipo.click { cursor: pointer; padding: 1px 6px 1px 3px; margin: -1px -6px -1px -3px; border-radius: 4px; }
.pg-legend .pg-leg-tipo.click:hover { background: var(--surface-2); }
.pg-legend .pg-leg-tipo.on { font-weight: 600; color: var(--ink); background: var(--surface-2); }
.pg-legend .pg-leg-tipo.off { opacity: .4; }
.pg-swatch { display: inline-block; width: 14px; height: 14px; margin-right: 5px; border-radius: 3px; background: var(--pg-tc, var(--carbon)); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18); box-sizing: border-box; }
.pg-swatch.t-prevista { background: transparent; border: 1px dashed var(--ink-3); box-shadow: none; }
.pg-swatch.done { background: color-mix(in srgb, var(--ink-3) 28%, #fff); box-shadow: inset 4px 0 0 var(--ink-3); }
.pg-swatch.warn { background: var(--warn); }

/* Gantt mensual */
.pg-gantt th.day, .pg-gantt td.day { padding: 2px 0; text-align: center; min-width: 22px; width: 22px; border-left: 1px solid var(--line); }
.pg-gantt th.day small { font-weight: 400; opacity: .7; }
.pg-gantt .off { background: var(--surface-2); }
.pg-gantt .today { background: var(--glass-3); }
/* INC-050: el color llega por --pg-tc desde cada tipo; .bar.t-prevista lo sustituye por el punteado. */
.pg-gantt .bar { display: block; height: 14px; margin: 0 -1px; background: var(--pg-tc, var(--carbon)); }
.pg-gantt .bar.done { background: color-mix(in srgb, var(--pg-tc, var(--carbon)) 28%, #fff); box-shadow: inset 0 3px 0 var(--pg-tc, var(--carbon)); }
.pg-gantt .bar.ko { opacity: .5; }
.pg-gantt tr.ko td.strong { text-decoration: line-through; }
.pg-dias { display: flex; gap: 6px; flex-wrap: wrap; }
.pg-dia { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; cursor: pointer; background: var(--surface); color: var(--ink-3); user-select: none; }
.pg-dia.on { background: var(--carbon); color: #fff; border-color: var(--carbon); }
.pg-dia input { display: none; }
.pg-cal .pg-ausencia { font-size: 10.5px; color: var(--ink-3); font-style: italic; padding: 2px 4px; }
/* Selector de proyecto con buscador (Programación) */
.pg-picker-btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 12.5px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; cursor: pointer; text-align: left; max-width: 100%;
}
.pg-picker-btn .truncate { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-picker-btn.empty { color: var(--ink-3); }
.pg-picker-btn.compact { width: 100%; border-color: transparent; background: transparent; padding: 3px 6px; border-radius: 4px; color: var(--ink-2); }
.pg-picker-btn.compact:hover { border-color: var(--line); background: var(--surface); }
.pg-picker-btn .mono { font-family: var(--font-mono); }
.pg-picker-dd {
  position: fixed; z-index: 1100; background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15,23,42,.14); display: flex; flex-direction: column; overflow: hidden;
}
.pg-picker-q { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--ink-3); }
.pg-picker-q input { flex: 1; border: none; outline: none; background: transparent; font: inherit; font-size: 13px; color: var(--ink); }
.pg-picker-list { overflow: auto; }
.pg-picker-it { display: flex; gap: 10px; align-items: center; padding: 7px 12px; font-size: 12.5px; cursor: pointer; border-bottom: 1px solid var(--line); }
.pg-picker-it:last-child { border-bottom: none; }
.pg-picker-it.on { background: var(--surface-2); }
.pg-picker-it.sel { font-weight: 600; }
.pg-picker-it .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-picker-ck { width: 16px; height: 16px; border: 1px solid var(--line); border-radius: 4px; font-size: 11px; line-height: 14px; text-align: center; color: #fff; flex: none; }
.pg-picker-ck.on { background: var(--carbon); border-color: var(--carbon); }


/* ═══════════════════════════════════════════════════════
   Impresión de Programación (botón "Imprimir"): solo el contenido de la
   pestaña activa o, si hay una ficha abierta, solo la ficha. Apaisado.
   ═══════════════════════════════════════════════════════ */
.pg-print-head { display: none; }
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body.pg-printing { background: #fff; }
  body.pg-printing .app { display: block; height: auto; overflow: visible; }
  body.pg-printing .sb, body.pg-printing .topbar, body.pg-printing .subnav, body.pg-printing .toolbar,
  body.pg-printing .page-h, body.pg-printing .pg-addrow, body.pg-printing .section-title,
  body.pg-printing .pg-tbl .icon-btn, body.pg-printing .toast, body.pg-printing .btn,
  body.pg-printing .kpi-grid, body.pg-printing .pg-no-print { display: none !important; }
  /* Calendario: se conserva el título del rango (semana / mes) */
  body.pg-printing .toolbar:has(.pg-cal-titulo) { display: flex !important; margin: 0 0 4px; border: none; background: transparent; padding: 0; box-shadow: none; }
  body.pg-printing .toolbar:has(.pg-cal-titulo) > * { display: none !important; }
  body.pg-printing .toolbar:has(.pg-cal-titulo) > .pg-cal-titulo { display: block !important; text-align: left; font-size: 11px; }
  body.pg-printing .main, body.pg-printing .main .scroll { overflow: visible; height: auto; padding: 0; }
  body.pg-printing .pg-print-head { display: block; font-size: 13px; font-weight: 600; margin: 0 0 6px; }
  body.pg-printing .tbl-wrap { border: none; border-radius: 0; }
  body.pg-printing .tbl-scroll { max-height: none !important; overflow: visible !important; }
  body.pg-printing .pg-tbl, body.pg-printing .pg-tbl.pg-main, body.pg-printing .pg-tbl.pg-wide, body.pg-printing .pg-tbl.pg-mid { min-width: 0 !important; width: 100%; font-size: 9px; }
  body.pg-printing .tbl th, body.pg-printing .tbl td { padding: 2px 4px; }
  body.pg-printing .tbl thead th { font-size: 8px; }
  body.pg-printing .pg-tbl.pg-main { zoom: .82; table-layout: auto; }
  body.pg-printing .pg-tbl input[type=date] { width: 62px; min-width: 0; }
  body.pg-printing .pg-tbl input[type=number] { width: 36px; min-width: 0 !important; }
  body.pg-printing .pg-tbl input[type=number]::-webkit-inner-spin-button { display: none; }
  body.pg-printing .tbl tbody tr { height: auto; page-break-inside: avoid; }
  body.pg-printing .tbl tbody tr:nth-child(even) td { background: #f5f6f8; }
  /* Celdas editables → texto plano */
  body.pg-printing .pg-in, body.pg-printing .pg-addrow input { border: none !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; font-size: 9px; color: #111; -webkit-appearance: none; appearance: none; }
  body.pg-printing .pg-in::placeholder { color: transparent; }
  body.pg-printing .pg-in.pg-empty::-webkit-datetime-edit { color: transparent; }
  body.pg-printing input[type=date]::-webkit-calendar-picker-indicator { display: none; }
  body.pg-printing select.pg-in { background-image: none !important; }
  body.pg-printing .pg-pill { padding: 0 4px; }
  body.pg-printing .pg-tbl th { width: auto !important; min-width: 0 !important; max-width: none !important; white-space: nowrap; }
  body.pg-printing .pg-tbl td { max-width: none !important; }
  body.pg-printing .pg-tbl td.pg-td-text { min-width: 140px !important; }
  body.pg-printing select.pg-in { width: auto; max-width: none; text-overflow: clip; }
  body.pg-printing .pg-in.pg-cell-area, body.pg-printing .pg-tbl textarea.pg-in { min-height: 0; height: auto; line-height: 1.2; }
  /* Selector de proyecto/persona → texto plano */
  body.pg-printing .pg-picker-btn, body.pg-printing .pg-picker-btn.compact { display: block; border: none !important; background: transparent !important; padding: 0 !important; font-size: 9px; color: #111; width: auto; min-width: 120px; }
  body.pg-printing .pg-picker-btn svg { display: none; }
  body.pg-printing .pg-picker-btn .truncate { white-space: normal; }
  body.pg-printing .pg-picker-btn.empty { color: transparent; }
  body.pg-printing .pg-picker-dd { display: none !important; }
  /* Calendario / carga: cuadrículas completas y chips con color */
  body.pg-printing .pg-cal-wrap { overflow: visible; border: none; }
  body.pg-printing .pg-cal { min-width: 0; font-size: 9px; }
  body.pg-printing .pg-cal .cell { min-height: 40px; }
  body.pg-printing .pg-chip, body.pg-printing .pg-pill, body.pg-printing .pill, body.pg-printing .pg-cal .off, body.pg-printing .pg-cal .today, body.pg-printing .pg-swatch, body.pg-printing .pg-gantt .bar { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body.pg-printing .pg-legend { font-size: 9px; margin-bottom: 4px; }
  body.pg-printing .pg-leg-tipo.off { display: none; }
  /* Ficha abierta: solo la ficha, a página completa */
  body.pg-printing .pg-view:has(.drawer.open) > :not(.drawer-bg):not(.drawer) { display: none !important; }
  body.pg-printing .drawer-bg { display: none !important; }
  body.pg-printing .drawer.pg-drawer { position: static; transform: none; width: 100%; max-width: 100%; height: auto; box-shadow: none; border: none; overflow: visible; }
  body.pg-printing .drawer.pg-drawer .dr-body { overflow: visible; height: auto; max-height: none; flex: none; }
  body.pg-printing .drawer.pg-drawer .dr-tabs, body.pg-printing .drawer.pg-drawer .icon-btn { display: none !important; }
  body.pg-printing .drawer.pg-drawer .dr-head { border-bottom: 1px solid #ddd; padding: 0 0 6px; }
  body.pg-printing .drawer.pg-drawer input, body.pg-printing .drawer.pg-drawer textarea, body.pg-printing .drawer.pg-drawer select { border: none !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; }
}

/* ── GUT-252: estado de material (material-estado.jsx) ── */
.mat-pill { border: none; cursor: pointer; font: inherit; font-size: 11.5px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.mat-pill:hover { filter: brightness(.96); }
.mat-dd {
  position: fixed; z-index: 1100; background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15,23,42,.14); overflow: auto; font-size: 12.5px;
}
.mat-panel { display: flex; flex-direction: column; }
.mat-sec { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.mat-sec:last-child { border-bottom: none; }
.mat-h { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); margin-bottom: 6px; }
.mat-proc { display: flex; align-items: center; gap: 6px; padding: 4px 0; flex-wrap: wrap; }
.mat-decide.esperando { background: var(--err-bg); }
.mat-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mat-form { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; }
.mat-form input, .mat-form select { font: inherit; font-size: 12.5px; padding: 5px 8px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); }
.mat-lbl { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: 12px; }
.mat-seg { display: flex; gap: 4px; }
.mat-seg button { flex: 1; border: 1px solid var(--line-2); background: var(--surface); border-radius: 6px; padding: 5px; cursor: pointer; font: inherit; font-size: 12px; }
.mat-seg button.on { background: var(--info-bg); color: var(--info); border-color: var(--info); font-weight: 600; }

/* ── GUT-254: Necesidades de compra (demanda.jsx) ── */
.nc-search { min-width: 280px; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: 6px; font: inherit; font-size: 13px; background: var(--surface); }
.nc-bulk { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 12px; background: var(--info-bg); border-radius: 8px; font-size: 13px; }
.nc-grupo { margin-bottom: 18px; }
.nc-grupo-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 2px; font-size: 13px; }
/* INC-023: columna Observación de Necesidades. Ancho generoso y texto en varias líneas;
   si la tabla no cabe, la .tbl-scroll del grupo da la barra de desplazamiento lateral. */
.tbl tbody td.nc-obs-td { white-space: normal; min-width: 300px; max-width: 460px; padding-top: 5px; padding-bottom: 5px; }
.nc-obs { padding: 5px 8px; border-radius: 6px; background: color-mix(in srgb, var(--warn-bg) 55%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); color: var(--ink); font-size: 12.5px; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ── GUT-257: Programación › Tareas (tipo, proyecto en dos líneas, grupos por tipo al imprimir) ── */
.pg-tbl tbody td.pg-td-proyecto { min-width: 200px; max-width: 260px; line-height: 1.25; }
.pg-td-proyecto .mono { font-size: 11px; color: var(--ink-3); }
.pg-tbl tbody tr.pg-tipo-grupo td { background: var(--surface-2); font-weight: 600; font-size: 12px; padding: 5px 8px; color: #1f2937; height: auto; }
.pg-print-filtros { display: none; }
@media print {
  body.pg-printing .pg-print-filtros { display: block; font-size: 10px; color: #444; margin: 0 0 6px; }
  body.pg-printing .pg-tbl tr.pg-tipo-grupo td { -webkit-print-color-adjust: exact; print-color-adjust: exact; font-size: 10px; page-break-after: avoid; }
  body.pg-printing .pg-tbl td.pg-td-proyecto { min-width: 120px !important; }
}

/* ── ComboBuscador (combobox.jsx): desplegable en el que se escribe para filtrar ── */
.cb { position: relative; min-width: 0; }
.cb .cb-input { width: 100%; padding-right: 24px; text-overflow: ellipsis; }
.cb-caret { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--ink-3); font-size: 11px; }
.cb-dd {
  position: absolute; z-index: 1100; left: 0; right: 0; top: calc(100% + 3px); max-height: 320px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(15,23,42,.14);
}
.cb-grp { padding: 6px 10px 3px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); background: var(--surface-2); position: sticky; top: 0; }
.cb-it { display: flex; gap: 8px; align-items: baseline; padding: 6px 10px; font-size: 12.5px; cursor: pointer; }
.cb-it.ind { padding-left: 18px; }
.cb-it.on { background: var(--info-bg); }
.cb-it.sel { font-weight: 600; }
.cb-it .mono { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-2); flex: none; }

/* Observación en la tabla de Expediente › Materiales: parte línea, no ensancha la tabla. */
.bom-obs { min-width: 110px; max-width: 220px; white-space: normal; overflow-wrap: anywhere; font-size: 11.5px; cursor: text; }
.bom-obs:hover { background: var(--surface-2); }
.bom-obs textarea { width: 100%; min-height: 44px; font: inherit; font-size: 12px; padding: 4px 6px; border: 1px solid var(--info); border-radius: 5px; resize: vertical; background: var(--surface); }

/* ── INC-011: costes de proyectos (public/js/erp/costes.jsx) ── */
.coste-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; flex: none; }
.coste-resumen { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 18px; }
.coste-donut { flex: none; }
.coste-provs { flex: 1; min-width: 280px; }
.coste-h { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin-bottom: 8px; }
.coste-prov { display: grid; grid-template-columns: 14px minmax(90px, 180px) 1fr minmax(110px, auto); gap: 8px; align-items: center; padding: 4px 0; font-size: 12.5px; }
.coste-prov-n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coste-prov-bar { display: flex; height: 10px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.coste-prov-bar > span, .coste-fila-bar > span { display: block; height: 100%; }
.coste-prov-v { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.coste-prov-v small { display: block; font-weight: 400; font-size: 10.5px; color: var(--ink-3); }
.coste-total { border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 8px; font-size: 13.5px; }
.tbl tr.coste-sec td { background: var(--surface-2); font-size: 12px; padding-top: 6px; padding-bottom: 6px; }
.tbl tr.coste-subtotal td { font-weight: 600; color: var(--ink-2); border-bottom: 1px solid var(--line-2); }
.tbl tr.coste-grantotal td { font-weight: 700; font-size: 13.5px; background: var(--bg-elev); color: var(--ink); }
.coste-leyenda { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 10px; font-size: 12px; align-items: center; }
.coste-leyenda b { font-family: var(--font-mono); font-weight: 600; margin-left: 4px; }
.coste-chart { padding: 6px 0; }
.coste-fila { display: grid; grid-template-columns: minmax(200px, 300px) 1fr minmax(120px, auto); gap: 12px; align-items: center; padding: 7px 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.coste-fila:last-child { border-bottom: none; }
.coste-fila:hover { background: var(--surface-2); }
.coste-fila-n { display: flex; gap: 8px; align-items: center; min-width: 0; font-size: 12.5px; }
.coste-fila-cli { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.coste-fila-bar { display: flex; height: 18px; border-radius: 3px; overflow: hidden; background: var(--surface-2); }
.coste-fila-bar > span + span { box-shadow: inset 1px 0 0 rgba(255,255,255,.7); }
.coste-fila-v { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12.5px; }
.coste-fila-v small { display: block; font-weight: 400; font-size: 10.5px; color: var(--err); }
@media (max-width: 760px) {
  .coste-fila { grid-template-columns: 1fr auto; }
  .coste-fila-bar { grid-column: 1 / -1; grid-row: 2; }
}

/* INC-011 (feedback Juanjo): coste por línea en la tabla de materiales y pestaña Costes simplificada. */
.tbl tfoot tr.mat-coste-pie td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line-2); font-size: 12.5px; }
.tbl tfoot tr.mat-coste-pie td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.mat-coste-total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-top: 4px; padding: 10px 14px; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--surface); font-weight: 700; font-size: 13.5px; }
.mat-coste-total .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 16px; }

/* INC-064 (Juanjo): cortinas plegables en la lista de materiales. */
.bom-grupo { margin-bottom: 6px; }
.bom-grupo.abierto { margin-bottom: 18px; }
.bom-grupo-cab { display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; margin-bottom: 6px; padding: 3px 6px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); cursor: pointer; }
.bom-grupo-cab:hover { background: var(--surface-2); }
.bom-grupo-toggle { display: inline-flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; min-width: 0; padding: 2px; border: 0; border-radius: 4px; background: none; color: inherit; font-size: inherit; text-align: left; }
.bom-grupo-toggle:focus-visible { outline: 2px solid var(--info); outline-offset: 1px; }
.bom-grupo-chev { flex: none; color: var(--ink-3); transition: transform .15s; }
.bom-grupo-toggle[aria-expanded="true"] .bom-grupo-chev { transform: rotate(90deg); }
.bom-grupo-acciones { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; cursor: default; }
/* INC-067: coste de la cortina en su cabecera; en el drawer estrecho baja de línea. */
.bom-grupo-coste { display: inline-flex; align-items: baseline; gap: 2px 8px; flex-wrap: wrap; min-width: 0; font-size: 11.5px; }
.bom-grupo-coste .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; white-space: nowrap; }
.coste-hero { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 18px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--carbon); border-radius: var(--r-lg); padding: 14px 18px; margin-bottom: 14px; }
.coste-hero-lbl { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.coste-hero-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 28px; font-weight: 700; color: var(--ink); line-height: 1.15; }
.coste-hero-sub { font-size: 12px; color: var(--ink-3); }
.coste-hero-sub b { font-family: var(--font-mono); font-weight: 600; color: var(--ink-2); }
.coste-detalle { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.coste-detalle > summary { cursor: pointer; padding: 10px 14px; font-size: 12.5px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
.coste-detalle > summary::-webkit-details-marker { display: none; }
.coste-detalle > summary::before { content: '▸'; display: inline-block; transition: transform .15s; color: var(--ink-3); }
.coste-detalle[open] > summary::before { transform: rotate(90deg); }
.coste-detalle > summary:hover { background: var(--surface-2); }
.coste-detalle-body { padding: 0 14px 14px; }
.coste-detalle-body .tbl-wrap { margin-top: 8px; }

/* INC-018: nombre del cliente clicable → hoja del cliente (materiales y medidas). */
.cli-link { all: unset; cursor: pointer; color: var(--accent-ink, var(--info)); text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: 2px; overflow-wrap: anywhere; }
.cli-link:hover { text-decoration-color: currentColor; }
.cli-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 2px; }

/* ── INC-005: Programación › Mapa (Leaflet, public/js/erp/programacion-mapa.jsx) ── */
.pg-mapa { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; align-items: start; }
.pg-mapa-main { position: relative; z-index: 0; /* encierra los z-index de Leaflet bajo drawers y menús */ }
.pg-mapa-map { height: calc(100vh - 290px); min-height: 420px; border: 1px solid var(--line); border-radius: 8px; background: #eef0ec; }
.pg-mapa-colocando { display: flex; gap: 8px; align-items: center; margin: 0 0 8px; padding: 6px 10px; font-size: 12.5px; background: var(--info-bg); color: var(--info); border-radius: 6px; }
.pg-mapa-colocando .btn { margin-left: auto; }
.pg-mapa-leyenda { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-top: 8px; font-size: 12px; }
.pg-mapa-ley { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font: inherit; color: var(--ink); cursor: pointer; }
.pg-mapa-ley.off { opacity: .45; }
.pg-mapa-ley-n { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); }
.pg-mapa-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.pg-mapa-dot.manual { background: #fff; border: 2px dashed #334155; width: 12px; height: 12px; box-sizing: border-box; }
.pg-mapa-pin-wrap { background: none; border: none; }
.pg-mapa-pin { display: block; width: 18px; height: 18px; margin: 0 2px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45); box-sizing: border-box; }
.pg-mapa-pin.manual { border: 2px dashed #fff; outline: 1px solid #334155; }
.pg-mapa-side { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 10px 12px; max-height: calc(100vh - 290px); min-height: 420px; overflow: auto; }
.pg-mapa-item { padding: 8px 4px; border-top: 1px solid var(--line); }
.pg-mapa-item.on { background: var(--info-bg); }
.pg-mapa-item-h { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12.5px; }
.pg-mapa-item-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pg-mapa-item-a { display: flex; gap: 6px; margin-top: 5px; }
.pg-mapa-link { all: unset; cursor: pointer; color: var(--accent-ink); text-decoration: underline; font-size: 12.5px; }
.pg-mapa-pop { font-size: 12.5px; }
.pg-mapa-pop-h { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.pg-mapa-pop-t { margin: 3px 0 6px; font-weight: 600; }
.pg-mapa-pop dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 8px; margin: 0; }
.pg-mapa-pop dt { color: var(--ink-3); }
.pg-mapa-pop dd { margin: 0; }
.pg-mapa-pop select, .pg-mapa-pop input[type="date"] { width: 100%; }
.pg-mapa-pop-a { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.pg-mapa-pop-n { font-size: 11px; margin-top: 6px; }
@media (max-width: 900px) {
  .pg-mapa { grid-template-columns: 1fr; }
  .pg-mapa-side { max-height: none; min-height: 0; }
}
@media print { .pg-mapa-side { display: none; } .pg-mapa { grid-template-columns: 1fr; } }

/* ── Ayuda › Conectar ChatGPT ─────────────────────────────── */
.ayu { max-width: 880px; }
.ayu-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.ayu-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 14px; font: inherit; font-size: 14px; color: var(--ink-3); cursor: pointer; margin-bottom: -1px; }
.ayu-tabs button:hover { color: var(--ink); }
.ayu-tabs button.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--carbon); }
.ayu h2 { font-size: 18px; margin: 28px 0 8px; }
.ayu h2:first-child { margin-top: 0; }
.ayu p, .ayu li { font-size: 14.5px; line-height: 1.6; color: var(--ink-2); }
.ayu p { margin: 0 0 12px; }
.ayu-chat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin: 14px 0 18px; display: flex; flex-direction: column; gap: 10px; }
.ayu-burbuja { max-width: 85%; padding: 9px 13px; border-radius: 12px; font-size: 14px; line-height: 1.5; }
.ayu-burbuja.tu { align-self: flex-end; background: var(--carbon); color: #fff; }
.ayu-burbuja.ia { align-self: flex-start; background: var(--surface-2); color: var(--ink); }
.ayu-paso-erp { align-self: flex-start; font-size: 12.5px; color: var(--ink-3); }
.ayu-video { width: 100%; border-radius: 10px; border: 1px solid var(--line); background: #000; display: block; }
.ayu-video-acc { display: flex; justify-content: flex-end; margin: 8px 0 22px; }
.ayu-url { display: flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; margin: 10px 0 18px; }
.ayu-url code { flex: 1; font-size: 15px; font-weight: 600; word-break: break-all; }
.ayu-pasos { padding-left: 22px; margin: 0 0 18px; }
.ayu-pasos li { margin-bottom: 9px; }
.ayu-aviso { background: var(--glass-3); border: 1px solid var(--glass-2); border-radius: 8px; padding: 12px 14px; margin: 0 0 18px; font-size: 14px; line-height: 1.55; color: var(--ink); }
.ayu-buscar { width: 100%; box-sizing: border-box; padding: 10px 12px; font: inherit; font-size: 14px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--ink); margin-bottom: 8px; }
.ayu-leyenda { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--ink-3); margin: 6px 0 16px; }
.ayu-grupo { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; overflow: hidden; }
.ayu-grupo > button { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 13px 15px; font: inherit; font-size: 15px; font-weight: 600; color: var(--ink); text-align: left; cursor: pointer; }
.ayu-grupo > button:hover { background: var(--surface-2); }
.ayu-grupo > button .n { margin-left: auto; font-size: 12.5px; font-weight: 400; color: var(--ink-3); }
.ayu-cuerpo { padding: 2px 15px 14px; }
.ayu-cuerpo .ej { margin: 8px 0 14px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; }
.ayu-cuerpo .ej li { font-size: 14px; color: var(--ink); }
.ayu-sub { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); margin: 12px 0 5px; }
.ayu-fun { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-2); line-height: 1.45; }
.ayu-tipo { flex: 0 0 auto; width: 70px; font-size: 11.5px; font-weight: 600; }
.ayu-tipo.c { color: #2f6f4f; }
.ayu-tipo.m { color: #1f6e92; }
.ayu-tipo.d { color: #b4531a; }
.ayu-faq h3 { font-size: 15px; margin: 18px 0 4px; }


/* ── GUT-290: Consumo de IA ─────────────────────────── */
.ia-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.ia-tbar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-3); min-width: 60px; }
.ia-tbar span { display: block; height: 100%; }
.ia-leyenda { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11.5px; color: var(--ink-3); margin: -6px 0 14px; }
.ia-leyenda i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.ia-aviso { background: var(--warn-bg); color: var(--warn); border-radius: 6px; padding: 8px 12px; font-size: 12.5px; margin-bottom: 12px; }
.ia-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; margin-bottom: 14px; min-width: 0; }
.ia-card h3, .ia-h3 { font-size: 13px; font-weight: 600; margin: 0 0 10px; color: var(--ink); }
.ia-card h3 small { font-weight: 400; color: var(--ink-4); margin-left: 6px; font-size: 11.5px; }
.ia-h3 { margin: 18px 0 8px; }
.ia-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.ia-grid .ia-card { margin-bottom: 0; }
.ia-grid + .ia-card { margin-top: 14px; }
.ia-barras { display: flex; flex-direction: column; gap: 6px; }
.ia-barra { display: grid; grid-template-columns: minmax(120px, 34%) 1fr 118px; align-items: center; gap: 10px; font-size: 12.5px; }
.ia-barra-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.ia-barra-b { height: 12px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.ia-barra-b span { display: block; height: 100%; border-radius: 3px; min-width: 2px; }
.ia-barra-v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.ia-barra-v small { display: block; font-weight: 400; font-size: 10.5px; color: var(--ink-4); }
.ia-dias { display: flex; align-items: flex-end; gap: 4px; height: 130px; overflow-x: auto; }
.ia-dia { flex: 1 0 18px; max-width: 46px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.ia-dia-col { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.ia-dia-col span { display: block; width: 100%; background: var(--glass); border-radius: 3px 3px 0 0; }
.ia-dia:hover .ia-dia-col span { background: var(--accent-ink); }
.ia-dia-l { font-size: 10px; color: var(--ink-4); margin-top: 4px; font-family: var(--font-mono); }
@media (max-width: 1100px) { .ia-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .ia-grid { grid-template-columns: 1fr; } }


/* ── GUT-291: Mi actividad (solo David) ─────────────── */
.ma-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.ma-titulo { font-size: 13px; min-width: 210px; text-align: center; text-transform: capitalize; }
.ma-resumen { background: var(--glass-3); border: 1px solid var(--glass-2); border-radius: var(--r-lg); padding: 10px 14px; font-size: 13px; color: var(--ink-2); margin-bottom: 14px; line-height: 1.5; }
.ma-heat { overflow-x: auto; }
.ma-heat-txt { font-size: 9px; fill: var(--ink-4); font-family: var(--font-mono); }
.ma-heat-pie { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.ma-heat-ley { display: inline-flex; align-items: center; gap: 3px; }
.ma-heat-ley i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.ma-areabar { display: flex; }
.ma-areabar span { border-radius: 0; }
.ma-tipobar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--surface-3); }
.ma-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.ma-brief { display: flex; flex-direction: column; gap: 10px; }
.ma-brief-dia { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px 14px; break-inside: avoid; }
.ma-brief-h { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 6px; text-transform: capitalize; }
.ma-brief-h .muted { text-transform: none; font-size: 11.5px; }
.ma-brief-it { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; padding: 3px 0; border-top: 1px dashed var(--line); }
.ma-brief-it:first-of-type { border-top: none; }
.ma-brief-it a { color: var(--ink); text-decoration: none; }
.ma-brief-it a:hover { text-decoration: underline; }
.ma-brief-it > span:last-child.mono { margin-left: auto; white-space: nowrap; font-size: 11px; }
.ma-pill-pr { background: var(--ok-bg); color: var(--ok); font-size: 10px; white-space: nowrap; }
.ma-pill-inc { background: var(--info-bg); color: var(--info); font-size: 10px; white-space: nowrap; }
.ma-pill-gl { background: #ede9fe; color: #6d28d9; font-size: 10px; white-space: nowrap; }
.ma-print-head { display: none; }
@media (max-width: 1100px) { .ma-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body.ma-printing { background: #fff; }
  body.ma-printing .app { display: block; height: auto; overflow: visible; }
  body.ma-printing .sb, body.ma-printing .topbar, body.ma-printing .subnav, body.ma-printing .toast,
  body.ma-printing .ma-no-print, body.ma-printing .page-h { display: none !important; }
  body.ma-printing .main, body.ma-printing .main .scroll { overflow: visible; height: auto; padding: 0; }
  body.ma-printing .ma-print-head { display: block; font-size: 16px; font-weight: 700; margin: 0 0 10px; }
  body.ma-printing .ia-card, body.ma-printing .kpi, body.ma-printing .ma-brief-dia { break-inside: avoid; box-shadow: none; }
  body.ma-printing .ma-kpis { grid-template-columns: repeat(5, 1fr); }
  body.ma-printing .ia-grid { grid-template-columns: 1fr 1fr; }
  body.ma-printing .ma-brief-it a { color: #111; }
}

/* ── MapaPuntos: mapa pequeño con ubicaciones GPS (jornada, partes) ── */
.mapa-puntos { position: relative; z-index: 0; /* encierra los z-index de Leaflet bajo drawers y menús */ border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #eef0ec; }
.mapa-puntos-map { position: absolute; inset: 0; }
.mapa-puntos-vacio { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 500; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.mapa-pt-wrap { background: none; border: none; }
.mapa-pt { display: flex; align-items: center; justify-content: center; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45); box-sizing: border-box; color: #fff; font: 700 11px/1 var(--font-sans, system-ui, sans-serif); }
.mapa-pt.grupo { font-size: 12px; }
.mapa-pop { font-size: 12.5px; max-height: 260px; overflow: auto; }
.mapa-pop-h { font-weight: 600; margin-bottom: 4px; }
.mapa-pop-f { display: flex; gap: 6px; align-items: flex-start; padding: 3px 0; }
.mapa-pop-d { flex: none; width: 9px; height: 9px; border-radius: 50%; margin-top: 4px; }
.mapa-pop-s { color: var(--ink-3); font-size: 11.5px; }
.mapa-pop-g { display: inline-block; margin-top: 6px; font-size: 11.5px; }
/* Registro de jornada: tabla + mapa al lado */
.jor-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.jor-layout.con-mapa { grid-template-columns: minmax(0, 1fr) 400px; }
.jor-mapa { position: sticky; top: 12px; }
.jor-mapa-h { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px; }
.jor-mapa-h select { max-width: 150px; }
.jor-mapa-ley { display: flex; gap: 12px; align-items: center; margin-top: 6px; font-size: 11.5px; color: var(--ink-3); flex-wrap: wrap; }
.jor-mapa-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
.jor-pin { all: unset; cursor: pointer; display: inline-flex; color: var(--accent-ink); }
@media (max-width: 1180px) {
  .jor-layout.con-mapa { grid-template-columns: minmax(0, 1fr); }
  .jor-mapa { position: static; order: -1; }
}
