/* ================================================================
   main.css — Corporate Knowledge Base Design System
   Fonts: Inter (Google Fonts)
   No frameworks. Pure CSS custom properties.
   ================================================================ */

/* ── Variables ───────────────────────────────────────────────── */
:root {
  /* Colors */
  --c-bg:         #f0f2f5;
  --c-surface:    #ffffff;
  --c-surface-2:  #f8fafc;
  --c-border:     #e2e8f0;
  --c-border-light: #f1f5f9;

  --c-sidebar-bg:    #1a1d27;
  --c-sidebar-hover: rgba(255,255,255,0.07);
  --c-sidebar-active:#3d4166;
  --c-sidebar-text:  #c9cdd4;
  --c-sidebar-title: rgba(255,255,255,0.35);

  --c-header-bg:     #ffffff;
  --c-header-border: #e2e8f0;

  --c-primary:       #4f46e5;
  --c-primary-hover: #4338ca;
  --c-primary-light: #eef2ff;

  --c-success:       #10b981;
  --c-success-light: #ecfdf5;
  --c-warning:       #f59e0b;
  --c-warning-light: #fffbeb;
  --c-danger:        #ef4444;
  --c-danger-light:  #fef2f2;
  --c-info:          #3b82f6;
  --c-info-light:    #eff6ff;

  /* Texto de avisos y etiquetas. Va en variables y no a fuego porque el modo
     oscuro tiene que poder cambiarlo: un #065f46 sobre fondo oscuro no se lee. */
  --c-success-text:  #065f46;
  --c-warning-text:  #92400e;
  --c-danger-text:   #991b1b;
  --c-info-text:     #1e40af;

  --c-text:          #1e293b;
  --c-text-2:        #64748b;
  --c-text-3:        #94a3b8;

  /* Dimensions */
  --sidebar-w:      260px;
  --header-h:       60px;

  /* Typography */
  --font:           'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text-xs:        0.75rem;
  --text-sm:        0.875rem;
  --text-base:      1rem;
  --text-lg:        1.125rem;
  --text-xl:        1.25rem;
  --text-2xl:       1.5rem;
  --text-3xl:       1.875rem;
  --fw-normal:      400;
  --fw-medium:      500;
  --fw-semibold:    600;
  --fw-bold:        700;
  --lh-tight:       1.25;
  --lh-normal:      1.5;
  --lh-relaxed:     1.75;

  /* Radius */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   18px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(0,0,0,.05);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.05);
  --shadow-xl:  0 20px 25px -5px rgba(0,0,0,.1),  0 8px 10px -6px rgba(0,0,0,.05);

  /* Transitions */
  --t-fast:   150ms ease;
  --t-normal: 250ms ease;
  --t-slow:   350ms ease;
}

/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: var(--lh-normal);
  color: var(--c-text);
  background: var(--c-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

/* ── Layout ──────────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--c-header-bg);
  border-bottom: 1px solid var(--c-header-border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.app-layout {
  display: flex;
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
}

.app-sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--c-sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 90;
  transition: transform var(--t-normal);
}

.app-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 24px 20px;
  transition: margin-left var(--t-normal);
}

.main-inner { max-width: 1680px; margin: 0 auto; }
.main-inner--wide { max-width: 100%; }

/* ── Header Components ───────────────────────────────────────── */
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-img  { height: 36px; width: auto; border-radius: var(--r-sm); }
.logo-text { font-size: var(--text-lg); font-weight: var(--fw-bold); color: var(--c-text); white-space: nowrap; }
.header-spacer { flex: 1; }

/* Sidebar toggle (mobile) */
.sidebar-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 24px; height: 18px;
  background: none; border: none; cursor: pointer; padding: 0;
}
.sidebar-toggle span {
  display: block; height: 2px; border-radius: 2px;
  background: var(--c-text);
  transition: transform var(--t-fast), opacity var(--t-fast);
}

/* ── Dropdowns ───────────────────────────────────────────────── */
.lang-selector,
.user-menu { position: relative; }

.lang-btn,
.user-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: 1px solid var(--c-border);
  border-radius: var(--r-full); padding: 6px 12px;
  font-family: var(--font); font-size: var(--text-sm); font-weight: var(--fw-medium);
  color: var(--c-text); cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.lang-btn:hover, .user-btn:hover { background: var(--c-surface-2); border-color: var(--c-primary); }

.chevron { width: 16px; height: 16px; fill: var(--c-text-2); transition: transform var(--t-fast); }
.chevron path { fill: currentColor; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 200px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xl);
  z-index: 200;
  overflow: hidden;
  opacity: 0; pointer-events: none; transform: translateY(-4px);
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.dropdown-menu.open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.dropdown-right { left: auto; right: 0; }

.dropdown-header {
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 2px;
}
.dropdown-user-name  { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--c-text); }
.dropdown-user-email { font-size: var(--text-xs); color: var(--c-text-2); }

.dropdown-divider { height: 1px; background: var(--c-border); margin: 4px 0; }

.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  font-size: var(--text-sm); color: var(--c-text);
  text-decoration: none;
  transition: background var(--t-fast);
  cursor: pointer;
}
.dropdown-item svg { width: 16px; height: 16px; fill: var(--c-text-2); flex-shrink: 0; }
.dropdown-item:hover { background: var(--c-surface-2); }
.dropdown-item.active { color: var(--c-primary); font-weight: var(--fw-medium); }
.dropdown-item--danger { color: var(--c-danger); }
.dropdown-item--danger svg { fill: var(--c-danger); }
.dropdown-item--danger:hover { background: var(--c-danger-light); }

/* User avatar */
.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--c-primary), #7c3aed);
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-xs); font-weight: var(--fw-bold); color: #fff;
  flex-shrink: 0;
}
.user-avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.user-name-header {
  display: flex; flex-direction: column; align-items: flex-start;
  font-size: var(--text-xs); font-weight: var(--fw-medium); line-height: 1.15;
  max-width: 140px; text-align: left;
}
.user-name-header > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-name-header > span + span { color: var(--c-text-2); font-weight: var(--fw-regular, 400); }
.user-menu .user-btn { padding-top: 3px; padding-bottom: 3px; }

/* Fecha y hora junto al nombre */
.hdr-reloj {
  display: flex; flex-direction: column; align-items: center;
  font-size: var(--text-xs); line-height: 1.15; color: var(--c-text-2);
  white-space: nowrap; font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.hdr-reloj #hdrRelojHora { font-weight: var(--fw-semibold); color: var(--c-text); }


/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }

.sidebar-section { padding: 0 0 8px; }

.sidebar-section-title {
  padding: 6px 16px;
  font-size: 11px; font-weight: var(--fw-semibold);
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--c-sidebar-title);
}

.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; margin: 1px 8px;
  border-radius: var(--r-md);
  font-size: var(--text-sm); font-weight: var(--fw-medium);
  color: var(--c-sidebar-text); text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap; overflow: hidden;
}
.sidebar-link:hover { background: var(--c-sidebar-hover); color: #fff; text-decoration: none; }
.sidebar-link.active { background: var(--c-sidebar-active); color: #fff; }
.sidebar-link--new {
  background: rgba(79,70,229,0.18);
  color: #a5b4fc;
  margin-bottom: 4px;
}
.sidebar-link--new:hover { background: rgba(79,70,229,0.3); color: #c7d2fe; }
.sidebar-link--collection { font-size: var(--text-xs); padding: 7px 16px; }

.nav-icon { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 8px; border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 4px;
}
.sidebar-footer-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-md);
  text-decoration: none;
  transition: background var(--t-fast);
  flex: 1; min-width: 0;
}
.sidebar-footer-link:hover { background: var(--c-sidebar-hover); text-decoration: none; }
.sidebar-footer-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sidebar-footer-name  { font-size: var(--text-sm); font-weight: var(--fw-medium); color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer-role  { font-size: var(--text-xs); color: var(--c-sidebar-title); }
.sidebar-footer-logout {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--r-md);
  color: rgba(255,255,255,0.35); text-decoration: none; flex-shrink: 0;
  transition: background var(--t-fast), color var(--t-fast);
}
.sidebar-footer-logout:hover { background: rgba(239,68,68,0.15); color: #ef4444; }

/* Overlay mobile */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 80;
  transition: opacity var(--t-normal);
}
.sidebar-overlay.show { display: block; }

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 28px;
  flex-wrap: wrap;
}
.page-title {
  font-size: var(--text-2xl); font-weight: var(--fw-bold);
  color: var(--c-text); line-height: var(--lh-tight);
}
.page-subtitle { font-size: var(--text-sm); color: var(--c-text-2); margin-top: 4px; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: var(--text-base); font-weight: var(--fw-semibold); color: var(--c-text); }
.card-body   { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--c-border); background: var(--c-surface-2); }

/* Stat cards (dashboard) */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 11px; margin-bottom: 20px; }

.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 14px 14px 12px;          /* un 30 % menos que antes */
  display: flex; flex-direction: column; gap: 5px;
  position: relative; overflow: hidden;
  transition: box-shadow var(--t-fast), transform var(--t-fast);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--c-primary), #7c3aed);
}
.stat-icon  { font-size: 1.05rem; line-height: 1; }
.stat-value { font-size: var(--text-xl); font-weight: var(--fw-bold); color: var(--c-text); line-height: 1.15; }
.stat-label { font-size: var(--text-xs); color: var(--c-text-2); font-weight: var(--fw-medium); }
.stat-card::before { height: 2px; }
.stat-card--click { cursor: pointer; }
/* La (i) de stat_card(): qué es el número y de dónde sale (03/11/2026). */
.stat-info {
  position: absolute; top: 6px; right: 6px; z-index: 1;
  width: 18px; height: 18px; padding: 0; border-radius: 50%;
  border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-text-2);
  font: italic 700 11px/16px Georgia, 'Times New Roman', serif; text-align: center; cursor: help;
}
.stat-info:hover, .stat-info:focus-visible { color: var(--c-primary); border-color: var(--c-primary); }
.stat-card:has(> .stat-info) > .stat-icon { margin-right: 22px; }
/* Tarjetas de importes (panel contable): «10.881.483,83 €» en una sola línea. */
.stat-grid--imports { grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); }
.stat-grid--imports .stat-value { font-size: var(--text-lg); white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat-grid--imports .stat-label { padding-right: 20px; }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%; border-collapse: collapse;
  font-size: var(--text-sm);
}
.data-table th {
  padding: 10px 14px;
  text-align: left;
  background: var(--c-surface-2);
  border-bottom: 2px solid var(--c-border);
  font-size: var(--text-xs); font-weight: var(--fw-semibold);
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--c-text-2);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--c-border-light);
  color: var(--c-text); vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--c-surface-2); }
.data-table .actions { display: flex; gap: 6px; }
.table-empty { text-align: center; padding: 40px; color: var(--c-text-2); }
/* Cabeceras ordenables (assets/js/ordenar.js) */
.data-table th.ord-th { cursor: pointer; user-select: none; }
.data-table th.ord-th:hover { color: var(--c-text); }
.data-table th.ord-th::after {
  content: '⇅'; display: inline-block; margin-left: 5px;
  font-size: 0.9em; opacity: 0; transition: opacity var(--t-fast);
}
.data-table th.ord-th:hover::after { opacity: .35; }
.data-table th.ord-asc, .data-table th.ord-desc { color: var(--c-primary); }
.data-table th.ord-asc::after  { content: '▲'; opacity: .9; font-size: .75em; }
.data-table th.ord-desc::after { content: '▼'; opacity: .9; font-size: .75em; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-md); border: 1px solid transparent;
  font-family: var(--font); font-size: var(--text-sm); font-weight: var(--fw-medium);
  cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform 100ms;
  text-decoration: none;
  line-height: 1.4;
}
.btn:active { transform: scale(0.98); }
.btn svg { width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; }
.btn-sm  { padding: 5px 10px; font-size: var(--text-xs); }
.btn-lg  { padding: 11px 22px; font-size: var(--text-base); }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: var(--r-md); }

.btn-primary { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.btn-primary:hover { background: var(--c-primary-hover); border-color: var(--c-primary-hover); box-shadow: 0 0 0 3px rgba(79,70,229,0.15); }

.btn-secondary { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border); }
.btn-secondary:hover { background: var(--c-surface-2); border-color: var(--c-text-3); }

.btn-ghost { background: transparent; color: var(--c-text-2); border-color: transparent; }
.btn-ghost:hover { background: var(--c-surface-2); color: var(--c-text); }

.btn-danger { background: var(--c-danger); color: #fff; border-color: var(--c-danger); }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }

.btn-success { background: var(--c-success); color: #fff; border-color: var(--c-success); }

.btn:disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; margin-bottom: 6px;
  font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--c-text);
}
.form-label .required { color: var(--c-danger); margin-left: 2px; }
.form-hint { font-size: var(--text-xs); color: var(--c-text-2); margin-top: 4px; }

.form-control,
.form-select,
.form-textarea {
  display: block; width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-family: var(--font); font-size: var(--text-sm); color: var(--c-text);
  background: var(--c-surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  appearance: none;
}
.form-control:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.form-control::placeholder { color: var(--c-text-3); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-control.is-invalid,
.form-select.is-invalid { border-color: var(--c-danger); }
.form-error { font-size: var(--text-xs); color: var(--c-danger); margin-top: 4px; }

.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check-input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--c-primary); }
.form-check-label { font-size: var(--text-sm); cursor: pointer; }

/* Form row (inline groups) */
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: var(--r-full);
  font-size: 11px; font-weight: var(--fw-semibold);
  letter-spacing: 0.03em;
}
.badge-primary { background: var(--c-primary-light); color: var(--c-primary); }
.badge-success { background: var(--c-success-light); color: var(--c-success-text); }
.badge-warning { background: var(--c-warning-light); color: var(--c-warning-text); }
.badge-danger  { background: var(--c-danger-light);  color: var(--c-danger-text); }
.badge-info    { background: var(--c-info-light);    color: var(--c-info-text); }
.badge-neutral { background: #f1f5f9; color: var(--c-text-2); }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--r-md); border-left: 4px solid;
  font-size: var(--text-sm); margin-bottom: 16px;
}
.alert-success { background: var(--c-success-light); border-color: var(--c-success); color: var(--c-success-text); }
.alert-warning { background: var(--c-warning-light); border-color: var(--c-warning); color: var(--c-warning-text); }
.alert-danger  { background: var(--c-danger-light);  border-color: var(--c-danger);  color: var(--c-danger-text); }
.alert-info    { background: var(--c-info-light);    border-color: var(--c-info);    color: var(--c-info-text); }

/* ── Modals ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
/* Una ventana nunca puede ser mas alta que la pantalla. El fondo centra con
   flex, asi que lo que sobra se sale por arriba Y por abajo y no hay forma de
   llegar a ello: la ficha de infraestructura, con sus discos, sus eventos y su
   registro, se cortaba y el boton de cerrar quedaba fuera. En columna, la
   cabecera y el pie se quedan fijos y el cuerpo es lo unico que crece — y lo
   unico que hace scroll. El min-height:0 no es decorativo: sin el, un hijo de
   flex no encoge por debajo de su contenido y el overflow del cuerpo no llega
   a activarse nunca. */
.modal {
  background: var(--c-surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  width: 100%; max-width: 480px;
  max-height: calc(100vh - 40px);       /* los 20px de padding del fondo, arriba y abajo */
  display: flex; flex-direction: column;
  animation: modalFadeIn 200ms ease;
}
.modal-lg { max-width: 700px; }
/* Ventana a pantalla completa (la ficha de un componente: veinte campos o más
   en bloques). Ocupa todo menos el margen del fondo. */
.modal-full { max-width: none; width: 100%; height: calc(100vh - 40px); }
.modal-full > form, .modal-full > .modal-body { flex: 1 1 auto; }

/* Los campos de un componente: bloques uno debajo de otro y, dentro, una
   rejilla de columnas IGUALES, para que las casillas de todos los bloques
   caigan alineadas entre sí (cat_form_html en includes/catalogo.php). */
.comp-form { display: flex; flex-direction: column; gap: 14px; }
.comp-sec { border: 1px solid var(--c-border); border-radius: var(--r-lg, 10px); padding: 12px 16px 14px; background: var(--c-surface); }
.comp-sec > h4 { margin: 0 0 10px; font-size: .74rem; font-weight: 700; letter-spacing: .05em;
                 text-transform: uppercase; color: var(--c-text-2); }
.comp-campos { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px 16px; align-items: start; }
@media (max-width: 1400px) { .comp-campos { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .comp-campos { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 800px)  { .comp-campos { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px)  { .comp-campos { grid-template-columns: 1fr; } }
.comp-campos .form-group { margin: 0; min-width: 0; }
.comp-campos .form-label { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comp-campos .form-control[readonly] { background: var(--c-surface-2); color: var(--c-text-2); cursor: default; }
.comp-campos .comp-span2 { grid-column: span 2; }
.comp-campos .comp-span3 { grid-column: span 3; }
.comp-campos .comp-full  { grid-column: 1 / -1; }      /* de punta a punta */
@media (max-width: 1100px) { .comp-campos .comp-span3 { grid-column: span 2; } }
.comp-campos .comp-check { align-self: end; padding-bottom: 8px; }
.comp-candado { font-size: .7rem; opacity: .7; }
@media (max-width: 520px) { .comp-campos .comp-span2, .comp-campos .comp-span3 { grid-column: auto; } }
/* Cuando el contenido va dentro de un <form> —y va, en casi todas las fichas—
   el formulario se cuela entre .modal y su cuerpo. Como es un bloque corriente,
   .modal-body deja de ser hijo del flex: el max-height ya no lo encoge, no
   aparece el scroll, y el pie con Cancelar y Guardar se va fuera de la pantalla.
   Con la ficha del trabajador no había forma de cerrar la ventana. Heredando la
   misma columna, queda arreglado en todas las pantallas a la vez. */
.modal > form {
  display: flex; flex-direction: column;
  flex: 1 1 auto; min-height: 0; overflow: hidden;
}

/* Ficha de maestro con muchos campos (máquinas tiene dieciocho): en una sola
   columna no cabe en pantalla. auto-fit reparte lo que quepa y en el móvil
   vuelve a una columna sin más reglas. */
.maestro-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 4px 16px;
    max-height: 68vh;
    overflow-y: auto;
}
/* Las casillas ocupan poco: que no se lleven una columna entera. */
.maestro-grid .form-group { margin-bottom: 10px; }

@keyframes modalFadeIn { from { opacity:0; transform:scale(.96); } to { opacity:1; transform:scale(1); } }
.modal-header { padding: 20px 24px 0; flex: 0 0 auto; }
.modal-title  { font-size: var(--text-lg); font-weight: var(--fw-semibold); }
.modal-body   { padding: 16px 24px; overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.modal-footer { padding: 0 24px 20px; display: flex; justify-content: flex-end; gap: 10px; flex: 0 0 auto; }

/* ── Toast Notifications ─────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 400;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--r-md);
  font-size: var(--text-sm); font-weight: var(--fw-medium);
  box-shadow: var(--shadow-lg);
  animation: toastIn 250ms ease forwards;
  max-width: 340px;
}
.toast-success { background: #ecfdf5; border: 1px solid #6ee7b7; color: #064e3b; }
.toast-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #7f1d1d; }
.toast-info    { background: #eff6ff; border: 1px solid #93c5fd; color: #1e3a5f; }
@keyframes toastIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:translateX(0); } }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; padding: 20px 0 0; }
.page-link {
  display: flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 8px;
  border-radius: var(--r-md); border: 1px solid var(--c-border);
  font-size: var(--text-sm); color: var(--c-text-2);
  transition: all var(--t-fast); text-decoration: none;
}
.page-link:hover { background: var(--c-surface-2); color: var(--c-primary); border-color: var(--c-primary); text-decoration: none; }
.page-link.active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.page-link.disabled { opacity: 0.4; pointer-events: none; }
.pagination { flex-wrap: wrap; }
.page-gap { padding: 0 4px; color: var(--c-text-3); }
/* Filas por página (includes/paginacion.php), al final de la barra. */
.pag-pp { display: inline-flex; align-items: center; gap: 6px; margin-left: 14px;
          font-size: var(--text-sm); color: var(--c-text-2); white-space: nowrap; }
.pag-pp .form-select { width: auto; min-width: 72px; }

/* ── Utility ─────────────────────────────────────────────────── */
.text-sm    { font-size: var(--text-sm); }
.text-xs    { font-size: var(--text-xs); }
.text-muted { color: var(--c-text-2); }
.text-danger{ color: var(--c-danger); }
.text-success{color: var(--c-success);}
.fw-medium  { font-weight: var(--fw-medium); }
.fw-semibold{ font-weight: var(--fw-semibold); }
.fw-bold    { font-weight: var(--fw-bold); }
.d-flex     { display: flex; }
.gap-2      { gap: 8px; }
.gap-3      { gap: 12px; }
.gap-4      { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mb-6 { margin-bottom: 24px; }
.p-0  { padding: 0; }
.w-100 { width: 100%; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Search / filter bar */
.filter-bar {
  display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: flex-end;
}
.filter-bar .form-control { max-width: 260px; }
.filter-bar .form-select  { max-width: 200px; }

/* Empty state */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--c-text-2);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.4; }
.empty-state-title { font-size: var(--text-lg); font-weight: var(--fw-semibold); margin-bottom: 6px; color: var(--c-text); }
.empty-state-text  { font-size: var(--text-sm); }

/* Spinner */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid rgba(79,70,229,0.2);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login Page ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a1d27 0%, #2d3655 50%, #1a1d27 100%);
  padding: 20px;
}
.login-box {
  background: var(--c-surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  padding: 40px; width: 100%; max-width: 400px;
}
.login-logo {
  text-align: center; margin-bottom: 32px;
}
.login-logo img { height: 56px; margin: 0 auto 12px; }
.login-logo h1 {
  font-size: var(--text-xl); font-weight: var(--fw-bold); color: var(--c-text);
}
.login-logo p { font-size: var(--text-sm); color: var(--c-text-2); margin-top: 4px; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar-toggle { display: flex; }

  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .app-main { margin-left: 0; padding: 16px; }

  .logo-text { display: none; }
  .user-name-header, .hdr-reloj { display: none; }

  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid--imports .stat-value { white-space: normal; }

  .page-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .form-row   { flex-direction: column; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-control,
  .filter-bar .form-select  { max-width: 100%; }
}

/* ── Fichas con pestañas (artículo, tercero) ──────────────────────────────
   La cabecera y las pestañas se quedan pegadas bajo la barra de la app; lo
   único que se mueve es el contenido. La altura real del bloque fijo la
   publica la propia ficha en --fija-h, para que el salto a un apartado no
   quede tapado. */
.ficha-fija {
  position: sticky;
  top: var(--header-h);
  z-index: 30;
  background: var(--c-bg);
  /* Se estira hacia arriba lo que mide el padding de .app-main para que el
     contenido no asome por el hueco entre la barra de la app y este bloque. */
  padding: 24px 0 0;
  margin: -24px 0 14px;
  border-bottom: 1px solid var(--c-border);
  box-shadow: 0 8px 14px -14px rgba(0, 0, 0, .55);
}
.ficha-fija .page-header { margin-bottom: 8px; }
.ficha-bloque { scroll-margin-top: calc(var(--header-h) + var(--fija-h, 150px) + 14px); }
/* La cabecera y las pestañas de la ficha del artículo, compactas (IPE,
   07/10/2026). Las mismas arriba de la ruta y de la etapa (ruta_edit.php,
   23/10/2026), para que la barra se vea igual en las tres pantallas. */
.ficha-fija--art .page-title { font-size: 1.15rem; }
.ficha-fija--art .page-title .ficha-nom { color: var(--c-text-2); font-weight: 400; margin-left: 14px; }
.ficha-fija--art .page-subtitle { margin-top: 1px; font-size: .74rem; }
.ficha-fija--art .page-actions { gap: 6px; }
.ficha-fija--art .page-actions .btn { padding: 5px 12px; font-size: .8rem; }
.art-tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 0 0 6px; }
.art-tabs a { font-size: .76rem; padding: 3px 10px; border-radius: 999px; text-decoration: none;
  color: var(--c-text-2); background: var(--c-surface); border: 1px solid var(--c-border); }
.art-tabs a:hover { border-color: var(--c-primary); color: var(--c-primary); }
.art-tabs a.on { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

/* Orden de las pestañas de cada usuario (assets/js/pestanas_orden.js, 05/11/2026).
   «⇅» al final de la barra; ordenando, las pestañas se arrastran. Con un orden
   guardado, el contenedor de la ficha pasa a flex y los bloques llevan `order`. */
[data-pestanas] { align-items: center; }
.pt-boton, .pt-reset { font-size: .74rem; padding: 2px 8px; margin-left: 2px; border-radius: 999px; cursor: pointer;
  color: var(--c-text-2); background: transparent; border: 1px dashed var(--c-border); line-height: 1.4; }
.pt-boton { margin-left: auto; }
.pt-boton:hover, .pt-reset:hover { color: var(--c-primary); border-color: var(--c-primary); }
.pt-editando .pt-boton { background: var(--c-primary); border: 1px solid var(--c-primary); color: #fff; }
.pt-editando > a[href^="#b-"] { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  outline: 1px dashed var(--c-primary); outline-offset: -1px; }
.pt-editando > a.pt-arrastrando, [data-pestanas] > a.pt-arrastrando { cursor: grabbing; opacity: .55; }
.pt-moviendo, .pt-moviendo * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.pt-flujo { display: flex; flex-direction: column; }
.pt-flujo > * { min-width: 0; }
.pt-aplanado { display: contents; }

/* Botones de exportar que se cuelgan solos en cada tabla (assets/js/exportar.js) */
.exp-botones { display: flex; gap: 4px; margin-left: auto; flex-shrink: 0; }
.exp-botones .btn { font-size: .72rem; padding: 3px 8px; opacity: .75; }
.exp-botones .btn:hover { opacity: 1; }
.exp-botones--suelta { padding: 8px 12px 0; justify-content: flex-end; }
@media print { .exp-botones { display: none; } }

/* Diálogo «qué columnas exporto» */
.exp-sub { font-size: .82rem; color: var(--c-text-2); margin: 0 0 10px; }
.exp-acciones { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 8px; }
.exp-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px 12px;
    max-height: 46vh; overflow-y: auto; text-align: left; padding: 4px; }
.exp-col { display: flex; align-items: center; gap: 8px; font-size: .84rem; padding: 4px 6px;
    border-radius: 6px; cursor: pointer; }
.exp-col:hover { background: var(--c-bg); }

/* Vista de cada usuario: columnas, orden y filas por página (assets/js/vista_tabla.js) */
.data-table .vt-oculta, .data-table tr.vt-fuera { display: none !important; }
.vt-pag { padding-top: 12px; }
.vt-pag-info { margin-left: 12px; font-size: var(--text-xs); color: var(--c-text-2); font-variant-numeric: tabular-nums; }
@media print { .vt-pag { display: none; } }
.vt-dlg { text-align: left; }
.vt-opciones { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-bottom: 12px; }
.vt-opc { display: flex; align-items: center; gap: 6px; font-size: .84rem; }
.vt-opc .form-select { width: auto; }
.vt-cols { list-style: none; margin: 0; padding: 4px; max-height: 46vh; overflow-y: auto;
    border: 1px solid var(--c-border); border-radius: 8px; }
.vt-col { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 6px; font-size: .84rem; }
.vt-col:hover { background: var(--c-bg); }
.vt-col label { display: flex; align-items: center; gap: 8px; flex: 1; cursor: pointer; margin: 0; min-width: 0; }
.vt-col label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vt-col .vt-sin { color: var(--c-text-3); font-style: italic; }
.vt-asa { cursor: grab; color: var(--c-text-3); letter-spacing: -2px; padding: 0 4px; user-select: none; }
.vt-mover { border: 0; background: transparent; cursor: pointer; color: var(--c-text-3); padding: 2px 6px; border-radius: 4px; }
.vt-mover:hover { color: var(--c-primary); background: var(--c-surface-2); }
.vt-arrastrando { opacity: .45; }

/* ── Desplegables buscables (assets/js/selector.js) ─────────────────────── */
/* El campo se comporta como un desplegable normal: los dos botones van DENTRO,
   pegados a la derecha y sin recuadro, y el <select> de verdad queda oculto
   (pero presente, para que el formulario se envíe igual). */
.sel-caja { position: relative; display: block; }
/* Filtro de barra con su ancho puesto (selector.js copia el width del select).
   Con menos de 160 px, quitando los dos botones no quedaba sitio para escribir. */
.sel-caja--linea { display: inline-block; vertical-align: middle; min-width: 160px; }
.sel-caja .sel-input { width: 100%; padding-right: 52px; }
.sel-oculto { position: absolute; opacity: 0; pointer-events: none;
    width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.sel-btn { position: absolute; top: 50%; transform: translateY(-50%);
    border: 0; background: transparent; cursor: pointer; padding: 0 4px;
    font-size: .78rem; line-height: 1; color: var(--c-text-3); }
.sel-btn:nth-of-type(1) { right: 28px; }     /* ▾ el desplegable */
.sel-btn:nth-of-type(2) { right: 8px; }      /* 🔍 la búsqueda */
.sel-btn:hover { color: var(--c-primary); }

/* ── Filtros de barra ───────────────────────────────────────────────────── */
/* .form-control-sm lo usaban ONCE pantallas y no existía en ninguna hoja: el
   navegador se quedaba con .form-control a secas, que es display:block y
   width:100%, y por eso tres desplegables seguidos salían uno debajo de otro
   ocupando el ancho entero. Un filtro tiene que medir lo que mide su contenido
   y estar en la misma línea que los demás; si ocupa media pantalla, lo que se
   ha venido a ver queda debajo del pliegue. */
.form-control-sm {
  display: inline-block; width: auto;
  padding: 5px 9px; font-size: var(--text-xs);
  max-width: 220px;
}
select.form-control-sm { padding-right: 24px; }

/* El conmutador de dos posiciones (entradas / salidas). Es un control de UNA
   elección entre dos, no dos botones sueltos: pintarlo como un bloque con la
   opción activa en relieve dice cuál está puesta sin tener que leerla. */
.segmento { display: inline-flex; background: var(--c-surface-2);
            border: 1px solid var(--c-border); border-radius: var(--r-md); padding: 2px; gap: 2px; }
.segmento button {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: transparent; cursor: pointer;
  padding: 5px 12px; border-radius: calc(var(--r-md) - 2px);
  font-family: var(--font); font-size: var(--text-sm); font-weight: var(--fw-medium);
  color: var(--c-text-2); white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.segmento button:hover { color: var(--c-text); }
.segmento button.activo { background: var(--c-surface); color: var(--c-text);
                          box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.segmento .n {
  font-size: var(--text-xs); font-variant-numeric: tabular-nums;
  background: var(--c-border); color: var(--c-text-2);
  border-radius: 999px; padding: 0 6px; min-width: 18px; text-align: center;
}
.segmento button.activo .n { background: var(--c-primary); color: #fff; }

/* Selector de vista en la cabecera (Todas / Sin leer, Día / Semana…). Vivía
   solo en planificacion.php y produccion.php; avisos y MRP lo usan también y
   sin esto salían como botones nativos del navegador. */
.pln-vistas { display: inline-flex; border: 1px solid var(--c-border); border-radius: 9px;
              overflow: hidden; margin-right: 6px; }
.pln-v { padding: 6px 12px; font-family: var(--font); font-size: .8rem; background: var(--c-surface);
         border: 0; cursor: pointer; color: var(--c-text); white-space: nowrap; }
.pln-v + .pln-v { border-left: 1px solid var(--c-border); }
.pln-v:hover { background: var(--c-surface-2); }
.pln-v.on { background: var(--c-primary); color: #fff; font-weight: 600; }

/* ── Pantallas densas ───────────────────────────────────────────────────── */
/* Para las pantallas de parametrización con muchas filas (códigos contables,
   plan, tarifas…): la cabecera ocupa un tercio y en la tabla caben tres veces
   más filas. Se ponen como clases sueltas para que cualquier pantalla las use
   sin tocar el resto: .page-header--compacta, .card--compacta, .tabla-densa. */
.page-header--compacta { margin-bottom: 12px; }
.card--compacta .card-header { padding: 8px 14px; }
.card--compacta .card-body   { padding: 10px 14px; }
.card--compacta .form-group  { margin-bottom: 0; }
.card--compacta .form-label  { margin-bottom: 2px; font-size: var(--text-xs); }
.card--compacta .form-control, .card--compacta .form-select { padding: 5px 8px; }
.tabla-densa th { padding: 4px 8px; }
.tabla-densa td { padding: 2px 8px; line-height: 1.2; font-size: var(--text-xs); }
.tabla-densa td .form-control, .tabla-densa td .form-select {
  padding: 1px 6px; height: 22px; font-size: var(--text-xs); line-height: 1.2; border-radius: 4px;
}
.tabla-densa td .btn-sm { padding: 1px 6px; }
/* Tablas anchas que tienen que caber sin scroll lateral (Stock MP/PT, 26/10/2026):
   la cabecera parte en dos líneas en vez de marcar el ancho de la columna, las
   celdas van con menos aire y los textos largos (descripción, cliente) parten. */
.tabla-cabe th { white-space: normal; letter-spacing: 0; padding: 4px 4px; line-height: 1.15; vertical-align: bottom; }
.tabla-cabe td { padding: 2px 4px; }
.tabla-cabe td.tc-texto { min-width: 110px; max-width: 190px; white-space: normal; }
.tabla-cabe td.tc-corto { max-width: 110px; white-space: normal; overflow-wrap: anywhere; }
.tabla-cabe .nw { white-space: nowrap; }
/* En fixed y con las coordenadas puestas desde selector.js: dentro del flujo,
   .card (overflow:hidden) recortaba la lista de un desplegable de la primera
   fila y sólo se veían tres opciones. Un elemento fijo no lo recorta nadie. */
.sel-lista { position: fixed; z-index: 60; max-height: 260px; overflow-y: auto;
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 8px;
    box-shadow: 0 10px 26px -12px rgba(0,0,0,.45); }
.sel-op { padding: 6px 10px; font-size: .84rem; cursor: pointer; display: flex; gap: 8px; align-items: baseline; }
.sel-op code { color: var(--c-text-3); font-size: .76rem; }
.sel-op:hover, .sel-op.marcada { background: var(--c-bg); }
.sel-op.actual { color: var(--c-primary); font-weight: 600; }
.sel-vacio { padding: 10px; font-size: .82rem; color: var(--c-text-3); text-align: center; }
/* Selector de usuarios (assets/js/usuarios.js): fichas + buscador en lugar de texto libre. */
.usr-caja { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 36px; height: auto; cursor: text; padding: 3px 6px; }
.usr-caja.usr-off { opacity: .6; cursor: default; }
.usr-buscar { border: 0; outline: 0; background: transparent; flex: 1; min-width: 140px; font-size: .84rem; color: var(--c-text); padding: 2px 0; }
.usr-ficha { display: inline-flex; align-items: baseline; gap: 4px; padding: 1px 4px 1px 8px; border-radius: 999px; font-size: .78rem; white-space: nowrap;
    background: color-mix(in srgb, var(--c-primary) 12%, transparent); color: var(--c-text); }
.usr-ficha small { color: var(--c-text-3); font-size: .7rem; }
.usr-ficha.ext { background: color-mix(in srgb, #64748b 16%, transparent); }
.usr-ficha.mal { background: color-mix(in srgb, #d97706 20%, transparent); color: #b45309; }
.usr-ficha button { border: 0; background: transparent; cursor: pointer; color: inherit; opacity: .55; padding: 0 3px; font-size: .7rem; }
.usr-ficha button:hover { opacity: 1; color: #dc2626; }
.usr-lista { position: fixed; z-index: 1300; max-height: 260px; overflow-y: auto; background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: 8px; box-shadow: 0 10px 26px -12px rgba(0,0,0,.45); }
.usr-op { padding: 6px 10px; font-size: .84rem; cursor: pointer; }
.usr-op small { color: var(--c-text-3); }
.usr-op:hover, .usr-op.sel { background: var(--c-bg); }
.usr-vacio { padding: 10px; font-size: .82rem; color: var(--c-text-3); text-align: center; }
.sel-modal-q { margin-bottom: 10px; }
.sel-modal-tabla { max-height: 46vh; overflow: auto; text-align: left; }
.sel-modal-tabla tbody tr { cursor: pointer; }
.sel-modal-tabla tbody tr:hover td { background: var(--c-bg); }
.sel-modal-tabla tbody tr.actual td { background: var(--c-primary-light); color: var(--c-primary); }

/* Interruptor «todos los campos de la tabla» del diálogo de exportar */
.exp-todo { display: flex; align-items: center; gap: 8px; font-size: .84rem;
    padding: 7px 10px; margin-bottom: 8px; border: 1px solid var(--c-border);
    border-radius: 8px; background: var(--c-bg); cursor: pointer; }
.exp-aviso { font-size: .76rem; color: var(--c-text-2); margin: 8px 0 0; text-align: left; }

/* Ventana de histórico (assets/js/historial.js) */
.hist-cab { font-size: .82rem; color: var(--c-text-2); text-align: left; margin: 0 0 10px; }
.hist-tabla { max-height: 56vh; overflow: auto; text-align: left; }
.hist-tabla th { position: sticky; top: 0; z-index: 1; }
.hist-antes { color: var(--c-text-3); text-decoration: line-through; }
.hist-flecha { color: var(--c-text-3); }

/* Documentos relacionados 🔗 (assets/js/doc_relacionados.js): una columna por
   tipo en el orden del circuito, el documento abierto resaltado. */
.drel { text-align: left; max-height: 70vh; overflow: auto; }
.drel-flujo { display: flex; align-items: flex-start; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.drel-col { flex: 1 1 0; min-width: 170px; max-width: 260px; }
.drel-col h4 { font-size: .76rem; font-weight: 600; color: var(--c-text-2); margin: 0 0 6px;
    text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.drel-flecha { align-self: center; color: var(--c-text-3); font-size: 1.1rem; padding: 0 2px; }
.drel-doc { border: 1px solid var(--c-border); border-radius: 8px; background: var(--c-surface);
    padding: 6px 8px; margin-bottom: 6px; font-size: .78rem; line-height: 1.35; }
.drel-doc.abre { cursor: pointer; }
.drel-doc.abre:hover { border-color: var(--c-primary); }
.drel-doc.este { border: 2px solid var(--c-primary); background: var(--c-primary-light); }
.drel-doc.cerrado { opacity: .6; }
.drel-doc b { font-size: .84rem; }
.drel-doc .drel-sub { color: var(--c-text-2); font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drel-aviso { font-size: .76rem; color: var(--c-text-2); margin: 6px 0 0; }
.drel-lineas { margin-top: 14px; }
.drel-lineas h4 { font-size: .8rem; font-weight: 600; margin: 0 0 6px; }
.drel-chip { display: inline-block; font-size: .72rem; padding: 1px 6px; border-radius: 6px; margin: 1px 2px 1px 0;
    background: var(--c-bg); border: 1px solid var(--c-border); white-space: nowrap; }
.drel-chip.abre { cursor: pointer; color: var(--c-primary); }
.drel-chip.abre:hover { border-color: var(--c-primary); }
@media (max-width: 640px) {
    .drel-flujo { flex-direction: column; align-items: stretch; }
    .drel-col { max-width: none; }
    .drel-flecha { transform: rotate(90deg); }
}

/* Presupuestos que VUELVEN a Costes (Solicitado por segunda vez, con motivo):
   la fila entera en ámbar, en la bandeja de Costes y en la lista comercial. */
.data-table tr.fila-vuelve td { background: var(--c-warning-light); }
.data-table tr.fila-vuelve:hover td { background: var(--c-warning-light); filter: brightness(.97); }

/* Dentro de una tabla densa los botones de icono y el desplegable de estado
   también encogen: si no, la fila sigue midiendo lo que mide el botón. */
.tabla-densa td .btn-icon { width: 22px; height: 22px; min-width: 22px; padding: 0; font-size: .72rem; }
.tabla-densa td .form-select-sm { height: 22px; padding: 0 22px 0 6px; font-size: var(--text-xs); }
.tabla-densa td .d-flex.gap-2 { gap: 2px; }

/* ── Histórico EDI de una comanda (assets/js/edi.js) ──────────────────────── */
/* Cada mensaje es un bloque con su cabecera y su tabla de cambios. Se separan
   con borde y no sólo con aire porque lo que se lee aquí es una SECUENCIA —el
   pedido y luego sus tres modificaciones—, y sin separación se mezclan. */
.edi-hist    { text-align: left; }
.edi-hist-m  { border: 1px solid var(--c-border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.edi-hist-cab    { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.edi-hist-fich   { font-family: ui-monospace, Consolas, monospace; margin: 2px 0 6px; }
/* El histórico va TODO desplegado: cada mensaje con sus líneas y, debajo, lo
   que se acabó aplicando. Sin botones de abrir nada —volver a la bandeja a por
   el detalle es justo lo que esta ventana ahorra. */
.edi-hist-lin    { margin-top: 4px; }
.edi-hist-mono   { font-family: ui-monospace, Consolas, monospace; font-size: .76rem; }
.edi-hist-sub    { margin: 8px 0 2px; font-size: .7rem; color: var(--c-text-3);
                   text-transform: uppercase; letter-spacing: .04em; }

/* ── Ninguna ventana más alta que la pantalla ──────────────────────────────── */
/* SweetAlert no pone tope a lo que mide el popup: con un formulario largo
   —el socio del EDI tiene veinte campos— la ventana crece hasta 979 px en una
   pantalla de 720 y los botones de Guardar y Cancelar se quedan FUERA. La
   ventana parece bien, se rellena entera y no hay manera de aceptarla ni de
   cerrarla más que con Escape, que nadie prueba.

   Se topa aquí, una vez, y no en cada pantalla: quien escribe un modal nuevo no
   tiene por qué acordarse. El contenido ya hace scroll solo —el contenedor de
   SweetAlert lleva overflow:auto—, así que basta con decirle hasta dónde puede
   llegar. Por eso los modales de este ERP NO llevan su propio max-height: dos
   scrolls anidados es peor que uno. */
.swal2-popup          { max-height: 96vh; }
.swal2-html-container { max-height: 72vh; }

/* Pantalla completa (el botón de la cabecera del terminal): sin menú lateral. */
body.pantalla-completa .app-sidebar,
body.pantalla-completa .sidebar-toggle { display: none !important; }
body.pantalla-completa .app-main { margin-left: 0 !important; }

/* ── Buscador global (Ctrl+K): paleta de la lupa de la cabecera ───────── */
.bus-fondo { position: fixed; inset: 0; z-index: 350; display: none; justify-content: center;
  align-items: flex-start; padding: 8vh 16px 16px; background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.bus-fondo.abierta { display: flex; }
.bus-caja { width: 100%; max-width: 640px; max-height: 80vh; display: flex; flex-direction: column;
  background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border);
  border-radius: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, .32); overflow: hidden;
  transition: max-width .22s cubic-bezier(.2, .8, .2, 1); }
.bus-fondo.abierta .bus-caja { animation: busEntra .18s ease-out; }
@keyframes busEntra { from { opacity: 0; transform: translateY(-8px) scale(.985); } }
/* Con resultados, la caja se abre a lo ancho para dejar sitio a la ficha. */
.bus-caja.con-ficha { max-width: 1040px; height: 80vh; }
.bus-entrada { display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--c-border); color: var(--c-text-3); }
.bus-entrada input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  color: var(--c-text); font: inherit; font-size: 1.05rem; }
.bus-entrada kbd, .bus-pie kbd { font: inherit; font-size: .7rem; padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--c-border); color: var(--c-text-3); }
.bus-cuerpo { flex: 1; min-height: 0; display: flex; }
.bus-res { flex: 1; min-width: 0; overflow-y: auto; padding: 4px 0 8px; }
.bus-grupo { padding: 10px 16px 4px; font-size: .68rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--c-text-3); }
.bus-item { position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 12px 7px 16px; margin: 0 6px;
  border-radius: 8px; color: inherit; text-decoration: none; }
.bus-item.sel { background: var(--c-primary-light); color: var(--c-primary); }
.bus-item.sel::before { content: ''; position: absolute; left: 4px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 3px; background: var(--c-primary); }
.bus-caja.en-ficha .bus-item.sel { background: var(--c-surface-2); color: var(--c-text); }
.bus-ico { width: 22px; text-align: center; flex-shrink: 0; }
.bus-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.bus-txt b { font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bus-txt small { font-size: .74rem; color: var(--c-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bus-flecha { font-size: .65rem; color: var(--c-text-3); opacity: 0; transition: opacity .15s, transform .15s; }
.bus-item.sel .bus-flecha { opacity: 1; transform: translateX(2px); color: var(--c-primary); }
.bus-vacio { padding: 22px 16px; text-align: center; color: var(--c-text-3); font-size: .88rem; }
.bus-pie { display: flex; justify-content: space-between; gap: 10px; padding: 8px 14px;
  border-top: 1px solid var(--c-border); font-size: .74rem; color: var(--c-text-3); background: var(--c-surface-2); }
.bus-pie a { color: var(--c-primary); text-decoration: none; font-weight: 600; white-space: nowrap; }

/* La ficha corta de la derecha (includes/buscador_ficha.php). */
.bus-ficha { display: none; position: relative; width: 420px; flex-shrink: 0; overflow-y: auto; overflow-x: hidden;
  border-left: 1px solid var(--c-border); background: var(--c-surface-2); }
.bus-caja.con-ficha .bus-ficha { display: block; }
.bus-ficha.cargando .bf { opacity: .45; transition: opacity .2s .15s; }
.bus-ficha.cargando::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--c-primary), transparent); background-size: 50% 100%;
  background-repeat: no-repeat; animation: bfBarra 1s linear infinite; }
@keyframes bfBarra { from { background-position: -50% 0; } to { background-position: 150% 0; } }
.bf { padding: 18px 18px 22px; animation: bfEntra .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes bfEntra { from { opacity: 0; transform: translateX(10px); } }
.bf-cab { display: flex; gap: 14px; align-items: center; }
.bf-cab-txt { min-width: 0; }
.bf-avatar { --bf-h: 240; position: relative; width: 52px; height: 52px; flex-shrink: 0; border-radius: 14px;
  display: grid; place-items: center; font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; color: #fff;
  background: linear-gradient(135deg, hsl(var(--bf-h) 70% 58%), hsl(calc(var(--bf-h) + 40) 65% 45%));
  box-shadow: 0 6px 16px -6px hsl(var(--bf-h) 60% 40% / .6); }
.bf-avatar--ico { background: var(--c-surface); border: 1px solid var(--c-border); box-shadow: none; font-size: 1.6rem; }
.bf-avatar-ico { position: absolute; right: -6px; bottom: -6px; font-size: .8rem; background: var(--c-surface);
  border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid var(--c-border); }
.bf-titulo { font-size: 1.08rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.bf-sub { margin-top: 2px; font-size: .78rem; color: var(--c-text-2); overflow-wrap: anywhere; }
.bf-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.bf-chips .badge { font-size: .68rem; }
.bf-chip { display: inline-block; font-size: .66rem; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--c-surface); border: 1px solid var(--c-border); color: var(--c-text-2); vertical-align: middle; }
.bf-chip--azul { background: var(--c-info-light); border-color: transparent; color: var(--c-info-text); }
.bf-chip--naranja { background: var(--c-warning-light); border-color: transparent; color: var(--c-warning-text); }
.bf-chip--rojo { background: var(--c-danger-light); border-color: transparent; color: var(--c-danger-text); }

.bf-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-top: 16px; }
.bf-kpi { padding: 10px 12px; border-radius: 10px; background: var(--c-surface); border: 1px solid var(--c-border); min-width: 0; }
.bf-kpi b { display: block; font-size: 1rem; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bf-kpi small { display: block; font-size: .68rem; color: var(--c-text-2); margin-top: 1px; }
.bf-kpi--verde b { color: var(--c-success-text); }
.bf-kpi--rojo b { color: var(--c-danger-text); }
.bf-kpi--azul b { color: var(--c-info-text); }

.bf-sec { margin: 18px 0 8px; font-size: .66rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--c-text-3); }
.bf-accesos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.bf-acc { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px; text-decoration: none;
  color: var(--c-text); background: var(--c-surface); border: 1px solid var(--c-border); font-size: .8rem;
  transition: border-color .12s, transform .12s, box-shadow .12s; }
.bf-acc:hover, .bf-acc.sel { border-color: var(--c-primary); color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-light); transform: translateY(-1px); }
.bf-acc-ico { width: 18px; text-align: center; flex-shrink: 0; }
.bf-acc-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.bf-acc em { font-style: normal; font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  background: var(--c-primary-light); color: var(--c-primary); font-variant-numeric: tabular-nums; }
.bf-acc--cero em { background: var(--c-surface-2); color: var(--c-text-3); }

.bf-datos { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; margin: 16px 0 0; font-size: .8rem; }
.bf-datos dt { color: var(--c-text-2); }
.bf-datos dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.bf-copia { font: inherit; color: inherit; background: none; border: 0; padding: 0 2px; margin: 0 -2px; cursor: copy;
  border-radius: 4px; position: relative; text-align: left; overflow-wrap: anywhere; }
.bf-copia:hover { background: var(--c-primary-light); color: var(--c-primary); }
.bf-copia.copiado::after { content: '✓ ' attr(data-ok); position: absolute; left: 50%; bottom: calc(100% + 4px);
  transform: translateX(-50%); white-space: nowrap; font-size: .68rem; font-weight: 600; padding: 2px 8px;
  border-radius: 6px; background: var(--c-text); color: var(--c-surface); animation: bfCopiado 1.2s ease forwards; }
@keyframes bfCopiado { 0% { opacity: 0; transform: translate(-50%, 4px); } 15%, 75% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
.bf-mailto { color: var(--c-text-3); font-size: .75rem; }
.bf-mailto:hover { color: var(--c-primary); }

.bf-empresa { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 10px 12px; border-radius: 10px;
  text-decoration: none; color: var(--c-text); background: var(--c-surface); border: 1px solid var(--c-border); }
.bf-empresa .bf-avatar { width: 34px; height: 34px; border-radius: 9px; font-size: .78rem; }
.bf-empresa span { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.bf-empresa b { font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bf-empresa small { font-size: .7rem; color: var(--c-text-2); }
.bf-empresa > i { color: var(--c-text-3); font-size: .75rem; transition: transform .15s; }
.bf-empresa:hover, .bf-empresa.sel { border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-light); }
.bf-empresa:hover > i, .bf-empresa.sel > i { transform: translateX(3px); color: var(--c-primary); }

.bf-personas { display: flex; flex-direction: column; gap: 6px; }
.bf-persona { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px;
  background: var(--c-surface); border: 1px solid var(--c-border); }
.bf-persona .bf-avatar { width: 32px; height: 32px; border-radius: 50%; font-size: .72rem; box-shadow: none; }
.bf-persona-txt { min-width: 0; flex: 1; font-size: .8rem; line-height: 1.3; }
.bf-persona-txt > a { color: var(--c-text); text-decoration: none; border-radius: 4px; }
.bf-persona-txt > a:hover, .bf-persona-txt > a.sel { color: var(--c-primary); text-decoration: underline; }
.bf-persona-txt small { display: block; color: var(--c-text-2); font-size: .72rem; }
.bf-persona-medios { margin-top: 2px; font-size: .74rem; color: var(--c-text-2); display: flex; flex-wrap: wrap; gap: 2px 10px; }

.bf-lista { display: flex; flex-direction: column; border-radius: 10px; overflow: hidden;
  background: var(--c-surface); border: 1px solid var(--c-border); }
.bf-fila { display: flex; align-items: center; gap: 10px; padding: 7px 10px; text-decoration: none; color: var(--c-text);
  font-size: .8rem; border-top: 1px solid var(--c-border-light); }
.bf-fila:first-child { border-top: 0; }
.bf-fila:hover, .bf-fila.sel { background: var(--c-primary-light); }
.bf-fila-ico { width: 18px; text-align: center; flex-shrink: 0; }
.bf-fila-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.bf-fila-txt b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bf-fila-txt small { font-size: .7rem; color: var(--c-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bf-fila-dcha { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.bf-fila-dcha .badge { font-size: .62rem; }
.bf-importe { font-variant-numeric: tabular-nums; font-weight: 600; font-size: .78rem; }
.bf-pie-lista { margin-top: 5px; font-size: .7rem; color: var(--c-text-3); text-align: right; }
.bf-desc { margin: 14px 0 0; font-size: .8rem; line-height: 1.5; color: var(--c-text-2); }

.bf-avance { margin-top: 16px; padding: 10px 12px; border-radius: 10px; background: var(--c-surface); border: 1px solid var(--c-border); }
.bf-avance-txt { display: flex; justify-content: space-between; font-size: .76rem; color: var(--c-text-2); }
.bf-avance-txt b { color: var(--c-text); font-variant-numeric: tabular-nums; }
.bf-barra { height: 8px; margin: 6px 0 4px; border-radius: 999px; background: var(--c-surface-2); overflow: hidden; }
.bf-barra i { display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--c-primary), var(--c-success)); animation: bfBarraCrece .6s cubic-bezier(.2, .8, .2, 1); }
@keyframes bfBarraCrece { from { width: 0; } }
.bf-avance small { font-size: .7rem; color: var(--c-text-3); font-variant-numeric: tabular-nums; }

/* En pantallas estrechas no cabe: la paleta vuelve a ser sólo la lista. */
@media (max-width: 860px) {
  .bus-caja.con-ficha { max-width: 640px; height: auto; }
  .bus-caja.con-ficha .bus-ficha { display: none; }
  .bus-flecha { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .bf, .bf-barra i, .bus-fondo.abierta .bus-caja { animation: none; }
  .bus-caja { transition: none; }
}

/* El apartado al que se salta desde un acceso del buscador («#b-contactos») se ilumina un momento. */
.ancla-destello { animation: anclaDestello 1.8s ease-out; }
@keyframes anclaDestello { 0%, 30% { box-shadow: 0 0 0 3px var(--c-primary); } 100% { box-shadow: 0 0 0 3px transparent; } }

/* ── Preimpresión › Flujos: el dibujo del flujo (assets/js/pp_flujos.js) ── */
.ppf-lienzo { position: relative; overflow: auto; min-height: 320px; user-select: none; -webkit-user-select: none; border: 1px solid var(--c-border); border-radius: 10px; outline: none;
  background-color: var(--c-surface); background-image: radial-gradient(var(--c-border) 1px, transparent 1px); background-size: 10px 10px; }
.ppf-lienzo:focus { box-shadow: 0 0 0 2px var(--c-primary-light); }
.ppf-svg { display: block; font-family: inherit; }
.ppf-nodo .ppf-caja { fill: var(--c-bg, #fff); stroke: var(--c-border); stroke-width: 1.5; }
.ppf-nodo.editable { cursor: grab; }
.ppf-nodo.sel .ppf-caja { stroke: var(--c-primary); stroke-width: 2.5; }
.ppf-nodo.visitado .ppf-caja { stroke: #dc2626; stroke-width: 2.5; }
.ppf-nodo.actual .ppf-caja { stroke: #f59e0b; stroke-width: 3; animation: ppfLate 1.4s ease-in-out infinite; }
@keyframes ppfLate { 0%, 100% { filter: drop-shadow(0 0 0 rgba(245,158,11,0)); } 50% { filter: drop-shadow(0 0 8px rgba(245,158,11,.9)); } }
.ppf-icono { font-size: 16px; }
.ppf-titulo { font-size: 12px; font-weight: 600; fill: var(--c-text); }
.ppf-sub { font-size: 10.5px; fill: var(--c-text-2); }
.ppf-puerto-txt { font-size: 9px; fill: var(--c-text-2); text-anchor: end; }
.ppf-puerto { fill: var(--c-bg, #fff); stroke: var(--c-text-2); stroke-width: 1.5; cursor: crosshair; }
.ppf-puerto.p-aprobar, .ppf-puerto.p-si, .ppf-puerto.p-ok { stroke: #16a34a; }
.ppf-puerto.p-rechazar, .ppf-puerto.p-no { stroke: #dc2626; }
.ppf-puerto.p-cancelar { stroke: #64748b; }
.ppf-puerto:hover { fill: var(--c-primary-light); }
.ppf-entrada { fill: var(--c-text-2); stroke: none; }
.ppf-asa { fill: var(--c-border); cursor: ew-resize; opacity: .7; }
.ppf-nodo:hover .ppf-asa, .ppf-nodo.sel .ppf-asa { fill: var(--c-primary); }
.ppf-arista { fill: none; stroke: #94a3b8; stroke-width: 2; }
.ppf-arista.negativa { stroke-dasharray: 5 4; }
.ppf-arista.sel { stroke: var(--c-primary); stroke-width: 3; }
.ppf-arista.tomada { stroke: #dc2626; stroke-width: 3; stroke-dasharray: none; }
.ppf-arista.temp { stroke: var(--c-primary); stroke-dasharray: 4 4; pointer-events: none; }
.ppf-arista-hit { fill: none; stroke: transparent; stroke-width: 12; cursor: pointer; }
.ppf-flecha { fill: #94a3b8; } .ppf-flecha-roja { fill: #dc2626; } .ppf-flecha-sel { fill: var(--c-primary); }
.ppf-paleta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ppf-paleta .btn { font-size: .78rem; }
.ppf-props .form-group { margin-bottom: 8px; }
.ppf-props .form-label { font-size: var(--text-xs); margin-bottom: 2px; }
.ppf-props textarea.form-control { min-height: 110px; font-size: .8rem; }
.ppf-lang { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.ppf-lang button { font-size: .72rem; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--c-border); background: transparent; color: var(--c-text-2); cursor: pointer; }
.ppf-lang button.on { background: var(--c-primary); color: #fff; border-color: transparent; }
.ppf-lang button.con { font-weight: 600; }
.ppf-vars { font-size: .7rem; color: var(--c-text-2); line-height: 1.6; }
.ppf-vars code { cursor: pointer; }
.ppf-pasos td { font-size: .74rem; }
.ppf-modal { position: fixed; inset: 0; z-index: 1000; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.ppf-modal[hidden] { display: none; }
.ppf-modal-box { background: var(--c-bg, #fff); color: var(--c-text); border-radius: 12px; width: min(760px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.ppf-modal-box .ppf-modal-cab { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--c-border); }
.ppf-modal-box .ppf-modal-cab h3 { margin: 0; font-size: 1rem; flex: 1; }
.ppf-modal-box .ppf-props { padding: 12px 16px; overflow: auto; }
.ppf-dir { cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.ppf-dir:hover { background: var(--c-primary-light); }
.ppf-fila2 { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin-bottom: 4px; }

/* «Pasar a pedido» por líneas (05/11/2026, assets/js/doc_a_pedido.js) y menú ⋮ de fila */
.dap { text-align: left; font-size: var(--text-sm); }
.dap-cab { margin-bottom: 6px; }
.dap-aviso { margin-bottom: 8px; padding: 6px 10px; background: var(--c-warning-light); color: var(--c-warning-text); border-radius: 6px; font-size: var(--text-xs); }
.dap-caja { max-height: 52vh; overflow: auto; border: 1px solid var(--c-border); border-radius: 8px; }
.dap-caja th { position: sticky; top: 0; z-index: 1; background: var(--c-surface-2); }
.dap .dap-n { text-align: right; }
.dap-q { width: 90px; display: inline-block; text-align: right; }
.dap-off td { color: var(--c-text-3); }
.dap-pie { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.dap-res { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--c-border); cursor: pointer; text-align: left; font-size: var(--text-sm); }
.dap-res:hover { background: var(--c-primary-light); }
.dropdown-menu.doc-menu-fila { position: fixed; top: 0; left: 0; min-width: 220px; overflow-y: auto; }
.doc-menu-fila .dropdown-item i, .doc-menu-fila .dropdown-item .dmf-ico { width: 18px; text-align: center; flex-shrink: 0; }
