/* ============================================================================
   Surtirepuestos Herga — Sistema de diseño (UI kit compartido)
   ----------------------------------------------------------------------------
   Fuente de verdad de la interfaz: colores, tipografía, y componentes
   reutilizables (botones, tarjetas, tablas, formularios, badges, alerts...).

   Reglas:
   - Colores: marca naranja (--brand), neutros slate, semánticos
     emerald (éxito) / red (peligro) / amber (aviso) / blue (info).
   - Radios: tarjetas 12px, controles 8px, pills 999px.
   - Los utilitarios de Tailwind se siguen usando para layout (flex, grid,
     spacing). Estos componentes cubren la apariencia (color, borde, sombra).
   ========================================================================= */

:root {
  /* Marca. Texto blanco sobre --brand cumple WCAG AA (4,6:1); --brand-fg es la
     marca usada COMO TEXTO sobre superficies claras (5,2:1). */
  --brand:        #cc4a0e;
  --brand-dark:   #a93a0a;
  --brand-fg:     #b8420c;
  --brand-soft:   #fff7ed;
  --brand-line:   #fed7aa;
  --brand-ink:    #9a3412;

  /* Neutros (slate). En modo nocturno la escala se invierte (ver html.dark),
     así que --n-50 es siempre "casi superficie" y --n-900 "casi texto". */
  --n-50:  #f8fafc;
  --n-100: #f1f5f9;
  --n-200: #e2e8f0;
  --n-300: #cbd5e1;
  --n-400: #94a3b8;   /* sólo decorativo (iconos, separadores): 2,6:1 sobre blanco */
  --n-500: #5f6f86;   /* texto secundario mínimo: 5,1:1 sobre blanco, 4,7:1 sobre el fondo */
  --n-600: #475569;
  --n-700: #334155;
  --n-800: #1e293b;
  --n-900: #0f172a;

  /* Semánticos. --X = relleno sólido (texto blanco encima), --X-ink = texto
     sobre fondo claro o sobre --X-soft. */
  --ok:        #047857;  --ok-soft:   #ecfdf5;  --ok-line:   #a7f3d0;  --ok-ink:   #065f46;
  --info:      #2563eb;  --info-soft: #eff6ff;  --info-line: #bfdbfe;  --info-ink: #1d4ed8;
  --warn:      #b45309;  --warn-soft: #fffbeb;  --warn-line: #fde68a;  --warn-ink: #92400e;
  --danger:    #dc2626;  --danger-soft: #fef2f2; --danger-line: #fecaca; --danger-ink: #b91c1c;

  /* Hover de botones suaves y sólidos */
  --ok-hover: #065f46;  --danger-hover: #991b1b;
  --ok-soft-hover: #d1fae5;  --info-soft-hover: #dbeafe;
  --warn-soft-hover: #fef3c7;  --danger-soft-hover: #fee2e2;

  /* Sólidos oscuros (btn-dark, badge-dark, toast) */
  --solid-dark: #1e293b;  --solid-dark-hover: #334155;  --toast-bg: #0f172a;

  /* Superficies */
  --surface:   #ffffff;
  --canvas:    #f1f5f9;
  --line:      #e2e8f0;
  --line-soft: #f1f5f9;

  /* Sombras */
  --shadow-sm: 0 1px 2px 0 rgb(15 23 42 / 0.04);
  --shadow-md: 0 4px 12px -2px rgb(15 23 42 / 0.08);

  /* Radios */
  --r-card: 0.75rem;
  --r-ctl:  0.5rem;
  --r-pill: 999px;
}

/* ── Modo nocturno ─────────────────────────────────────────────────────────
   Lo activa static/theme.js (clase "dark" en <html>): automático de 6 p. m. a
   6 a. m. (hora de Bogotá) o fijado a mano con el botón del topbar.
   Se redefinen las mismas variables; ningún componente necesita reglas propias. */
html.dark {
  color-scheme: dark;

  --brand-fg:   #fb923c;
  --brand-soft: rgb(234 88 12 / .14);
  --brand-line: rgb(251 146 60 / .35);
  --brand-ink:  #fdba74;

  --n-50:  #182238;
  --n-100: #1d2a44;
  --n-200: #2a3a58;
  --n-300: #3d4e6e;
  --n-400: #7c8ba3;
  --n-500: #94a3b8;
  --n-600: #b4c0d0;
  --n-700: #cbd5e1;
  --n-800: #e2e8f0;
  --n-900: #f1f5f9;

  --ok-soft:     rgb(16 185 129 / .14);  --ok-line:     rgb(52 211 153 / .35);  --ok-ink:     #6ee7b7;
  --info-soft:   rgb(59 130 246 / .16);  --info-line:   rgb(96 165 250 / .35);  --info-ink:   #93c5fd;
  --warn-soft:   rgb(245 158 11 / .14);  --warn-line:   rgb(251 191 36 / .35);  --warn-ink:   #fcd34d;
  --danger-soft: rgb(239 68 68 / .14);   --danger-line: rgb(248 113 113 / .35); --danger-ink: #fca5a5;

  --ok-soft-hover:     rgb(16 185 129 / .26);
  --info-soft-hover:   rgb(59 130 246 / .28);
  --warn-soft-hover:   rgb(245 158 11 / .26);
  --danger-soft-hover: rgb(239 68 68 / .26);

  --solid-dark: #334155;  --solid-dark-hover: #475569;  --toast-bg: #2a3a58;

  --surface:   #151f33;
  --canvas:    #0d1424;
  --line:      #26334d;
  --line-soft: #1d2940;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / .35);
  --shadow-md: 0 4px 14px -2px rgb(0 0 0 / .5);
}

/* ── Base ──────────────────────────────────────────────────────────────── */

[x-cloak] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  color: var(--n-700);
  background-color: var(--canvas);
}

::selection { background: var(--brand); color: #fff; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Scrollbar discreto */
* { scrollbar-width: thin; scrollbar-color: var(--n-300) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--n-300); border: 3px solid transparent; border-radius: 999px; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--n-400); background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* Números: ancho fijo para que las columnas alineen */
.nums { font-variant-numeric: tabular-nums; }

/* Texto monoespaciado (referencias, códigos) */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.75rem; }

/* Texto utilitario */
.muted     { color: var(--n-500); }
.dim       { color: var(--n-600); }
.link      { color: var(--brand-fg); font-weight: 500; }
.link:hover { text-decoration: underline; }
.link-danger { color: var(--danger-ink); font-weight: 500; }
.link-danger:hover { text-decoration: underline; }
.link-sm   { font-size: 0.75rem; }

/* Separadores entre bloques de un formulario/página */
.divide-soft > * + * { border-top: 1px solid var(--line-soft); }

/* ── Tipografía de secciones ───────────────────────────────────────────── */

.page-title { font-size: 1.0625rem; font-weight: 600; color: var(--n-800); }
.section-title {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--n-500);
}
.card-title { font-size: 0.875rem; font-weight: 600; color: var(--n-700); }
.card-sub   { font-size: 0.75rem; color: var(--n-500); }

/* ── Botones ───────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.5rem 1rem; border: 1px solid transparent; border-radius: var(--r-ctl);
  font-size: 0.875rem; font-weight: 500; line-height: 1.25rem;
  white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background-color .12s ease, color .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn svg { flex-shrink: 0; }

/* Tamaños */
.btn-xs { padding: 0.25rem 0.625rem; font-size: 0.75rem; line-height: 1rem; gap: 0.375rem; border-radius: var(--r-ctl); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; line-height: 1rem; gap: 0.375rem; }
.btn-lg { padding: 0.625rem 1.25rem; font-size: 0.875rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 0.5rem; }           /* solo icono */
.btn-icon.btn-sm { padding: 0.375rem; }

/* Variantes */
.btn-primary   { background: var(--brand); color: #fff; }
.btn-primary:hover   { background: var(--brand-dark); }

.btn-secondary { background: var(--surface); color: var(--n-700); border-color: var(--line); }
.btn-secondary:hover { background: var(--n-50); border-color: var(--n-300); }

.btn-dark      { background: var(--solid-dark); color: #fff; }
.btn-dark:hover      { background: var(--solid-dark-hover); }

.btn-success   { background: var(--ok); color: #fff; }
.btn-success:hover   { background: var(--ok-hover); }

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

.btn-danger-soft  { background: var(--danger-soft); color: var(--danger-ink); border-color: var(--danger-line); }
.btn-danger-soft:hover { background: var(--danger-soft-hover); }

.btn-success-soft { background: var(--ok-soft); color: var(--ok-ink); border-color: var(--ok-line); }
.btn-success-soft:hover { background: var(--ok-soft-hover); }

.btn-warn-soft   { background: var(--warn-soft); color: var(--warn-ink); border-color: var(--warn-line); }
.btn-warn-soft:hover { background: var(--warn-soft-hover); }

.btn-info-soft   { background: var(--info-soft); color: var(--info-ink); border-color: var(--info-line); }
.btn-info-soft:hover { background: var(--info-soft-hover); }

.btn-ghost     { background: transparent; color: var(--n-500); }
.btn-ghost:hover { background: var(--n-100); color: var(--n-700); }

.btn-link { background: none; border: none; padding: 0; color: var(--brand-fg); font-weight: 500; }
.btn-link:hover { text-decoration: underline; }

/* Botón en forma de tarjeta (accesos / opciones) */
.tile {
  display: flex; align-items: center; gap: 0.875rem; width: 100%;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-card); padding: 1rem;
  color: var(--n-800); text-align: left; cursor: pointer; text-decoration: none;
  transition: border-color .12s ease, box-shadow .12s ease, background-color .12s ease;
}
.tile:hover { border-color: var(--brand-line); box-shadow: var(--shadow-md); }
.tile-icon {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 2.5rem; height: 2.5rem; border-radius: var(--r-ctl);
  background: var(--n-100); color: var(--n-600);
}
.tile-title { font-size: 0.875rem; font-weight: 600; color: var(--n-800); }
.tile-text  { font-size: 0.75rem; color: var(--n-500); margin-top: 0.125rem; }
.tile.is-disabled { opacity: .55; cursor: not-allowed; background: var(--n-50); border-style: dashed; }

/* ── Formularios ───────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; }
.label {
  display: block; margin-bottom: 0.375rem;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--n-500);
}
.label-plain { text-transform: none; letter-spacing: 0; font-size: 0.75rem; }

.input, .select, .textarea {
  width: 100%; padding: 0.5rem 0.75rem;
  background: var(--surface); color: var(--n-800);
  border: 1px solid var(--n-300); border-radius: var(--r-ctl);
  font-size: 0.875rem; font-family: inherit; line-height: 1.25rem;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--n-500); opacity: 1; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgb(234 88 12 / 0.15);
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--n-100); color: var(--n-500); cursor: not-allowed; }
.select { padding-right: 2rem; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%2364748b' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.5rem center; background-size: 1rem; }
html.dark .select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%2394a3b8' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
}
.textarea { min-height: 5rem; resize: vertical; }

.input-sm, .select-sm { padding: 0.3125rem 0.5rem; font-size: 0.75rem; line-height: 1rem; }
.select-sm { padding-right: 1.75rem; }

/* Campos con prefijo ($) o sufijo */
.input-wrap { position: relative; display: block; }
.input-wrap > .prefix,
.input-wrap > .suffix {
  position: absolute; top: 50%; transform: translateY(-50%);
  color: var(--n-500); font-size: 0.875rem; pointer-events: none;
}
.input-wrap > .prefix { left: 0.75rem; }
.input-wrap > .suffix { right: 0.75rem; }
.input-wrap > .prefix ~ .input { padding-left: 1.75rem; }
.input-wrap > .suffix ~ .input { padding-right: 2.25rem; }

/* Checkbox / radio */
.check {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.875rem; color: var(--n-600); cursor: pointer;
}
.check input[type="checkbox"], .check input[type="radio"] {
  width: 1rem; height: 1rem; accent-color: var(--brand); cursor: pointer; flex-shrink: 0;
}

.help { font-size: 0.75rem; color: var(--n-500); margin-top: 0.25rem; }
.error-text { font-size: 0.75rem; color: var(--danger-ink); margin-top: 0.25rem; }

/* Fila de filtros */
.filters {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-card); padding: 1rem;
}

/* ── Tarjetas / paneles ────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sm);
}
.card-flush { overflow: hidden; }
.card-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem 0.75rem; flex-wrap: wrap;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--line-soft);
}
.card-bd { padding: 1.25rem; }
.card-ft { padding: 0.875rem 1.25rem; border-top: 1px solid var(--line-soft); background: var(--n-50); }
.card-hl { border-color: var(--brand-line); }
.card-hl .card-hd { background: var(--brand-soft); }

/* Tarjeta que es un enlace / fila clicable */
.card-link { display: block; text-decoration: none; color: inherit;
  transition: border-color .12s ease, box-shadow .12s ease; }
.card-link:hover { border-color: var(--brand-line); box-shadow: var(--shadow-md); }

/* Tarjetas de indicador */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 1.25rem; box-shadow: var(--shadow-sm); }
.stat-label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--n-500); }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--n-900); margin-top: 0.25rem; font-variant-numeric: tabular-nums; }
.stat-hint  { font-size: 0.75rem; color: var(--n-500); margin-top: 0.25rem; }
.stat-hd { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.75rem; }
.stat-icon {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 2rem; height: 2rem; border-radius: var(--r-ctl);
  background: var(--n-100); color: var(--n-500);
}
.stat-icon-brand { background: var(--brand-soft); color: var(--brand-fg); }
.stat-icon-ok    { background: var(--ok-soft);    color: var(--ok-ink); }
.stat-icon-info  { background: var(--info-soft);  color: var(--info-ink); }
.stat-icon-warn  { background: var(--warn-soft);  color: var(--warn-ink); }
.stat-brand { border-color: var(--brand-line); background: linear-gradient(var(--brand-soft), var(--surface)); }
.stat-brand .stat-label { color: var(--brand-ink); }
.stat-brand .stat-value { color: var(--brand-ink); }
.stat-ok .stat-value { color: var(--ok-ink); }
.stat-warn .stat-value { color: var(--warn-ink); }
.stat-danger .stat-value { color: var(--danger-ink); }

/* ── Tablas ────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th {
  padding: 0.75rem 1rem; text-align: left; white-space: nowrap;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--n-500); background: var(--n-50); border-bottom: 1px solid var(--line);
}
.table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--line-soft); color: var(--n-600); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--n-50); }
.table thead th:first-child, .table tbody td:first-child { padding-left: 1.25rem; }
.table thead th:last-child, .table tbody td:last-child { padding-right: 1.25rem; }
.table tfoot td {
  padding: 0.75rem 1rem; background: var(--n-50); border-top: 1px solid var(--line);
  font-weight: 600; color: var(--n-700);
}
.table .num, .table .right { text-align: right; font-variant-numeric: tabular-nums; }
.table .center { text-align: center; }
.table .strong { font-weight: 600; color: var(--n-900); }
.table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.75rem; color: var(--n-500); }
.table .actions { text-align: right; white-space: nowrap; }
.table .col-cost  { color: var(--danger-ink); }
.table .col-price { color: var(--ok-ink); }
.table .muted-row { opacity: .5; }
.table-sm th, .table-sm td { padding: 0.5rem 1rem; }

/* Tabla densa: captura de datos con muchas columnas (asistentes de importación) */
.table-dense { font-size: 0.8125rem; }
.table-dense th, .table-dense td { padding: 0.5rem 0.75rem; }
.table-dense thead th:first-child, .table-dense tbody td:first-child { padding-left: 1rem; }
.table-dense thead th:last-child, .table-dense tbody td:last-child { padding-right: 1rem; }

/* ── Badges / chips ────────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.125rem 0.5rem; border-radius: var(--r-pill);
  font-size: 0.75rem; font-weight: 500; line-height: 1.125rem; white-space: nowrap;
}
.badge-ok      { background: var(--ok-soft);     color: var(--ok-ink); }
.badge-info    { background: var(--info-soft);   color: var(--info-ink); }
.badge-warn    { background: var(--warn-soft);   color: var(--warn-ink); }
.badge-danger  { background: var(--danger-soft); color: var(--danger-ink); }
.badge-brand   { background: var(--brand-soft);  color: var(--brand-ink); }
.badge-neutral { background: var(--n-100);       color: var(--n-600); }
.badge-dark    { background: var(--solid-dark);  color: #fff; }
.badge-dot::before {
  content: ''; width: 0.375rem; height: 0.375rem; border-radius: 999px;
  background: currentColor; flex-shrink: 0;
}
.badge-block { border-radius: 0.25rem; }

.chip {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.125rem 0.375rem; border-radius: 0.25rem;
  background: var(--n-100); color: var(--n-600);
  font-size: 0.75rem; font-weight: 500; white-space: nowrap;
}
.chip-info { background: var(--info-soft); color: var(--info-ink); }
.chip-warn { background: var(--warn-soft); color: var(--warn-ink); }
.chip-brand { background: var(--brand-soft); color: var(--brand-ink); }

/* Estado con punto (caja abierta, conexiones...) */
.dot { width: 0.5rem; height: 0.5rem; border-radius: 999px; background: var(--ok); flex-shrink: 0; }
.dot-pulse { animation: pulse 2s cubic-bezier(.4,0,.6,1) infinite; }
@keyframes pulse { 50% { opacity: .4; } }

/* ── Alerts ───────────────────────────────────────────────────────────── */

.alert {
  display: flex; align-items: flex-start; gap: 0.5rem;
  padding: 0.75rem 1rem; border-radius: var(--r-card); border: 1px solid transparent;
  font-size: 0.875rem; box-shadow: var(--shadow-sm);
}
.alert svg { flex-shrink: 0; margin-top: 0.125rem; }
.alert-ok      { background: var(--ok-soft);     border-color: var(--ok-line);     color: var(--ok-ink); }
.alert-info    { background: var(--info-soft);   border-color: var(--info-line);   color: var(--info-ink); }
.alert-warn    { background: var(--warn-soft);   border-color: var(--warn-line);   color: var(--warn-ink); }
.alert-error   { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger-ink); }
.alert-neutral { background: var(--n-50);        border-color: var(--line);        color: var(--n-600); }

/* ── Estado vacío ─────────────────────────────────────────────────────── */

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  padding: 2.5rem 1.5rem; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
}
.empty-icon { width: 2.75rem; height: 2.75rem; border-radius: 999px; background: var(--n-100);
  display: flex; align-items: center; justify-content: center; color: var(--n-500); margin-bottom: 0.25rem; }
.empty-title { font-size: 0.875rem; font-weight: 600; color: var(--n-700); }
.empty-text  { font-size: 0.875rem; color: var(--n-500); max-width: 28rem; }

/* ── Paginación ───────────────────────────────────────────────────────── */

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.pagination-info { font-size: 0.75rem; color: var(--n-500); }
.pagination-links { display: flex; align-items: center; gap: 0.25rem; }
.pg {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2rem; height: 2rem; padding: 0 0.625rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctl);
  font-size: 0.8125rem; color: var(--n-600); text-decoration: none;
  transition: background-color .12s ease, border-color .12s ease;
}
.pg:hover { background: var(--n-50); border-color: var(--n-300); }
.pg.is-active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pg.is-disabled { color: var(--n-300); background: var(--n-50); pointer-events: none; }
.pg-gap { color: var(--n-500); padding: 0 0.25rem; }

/* ── Pestañas ─────────────────────────────────────────────────────────── */

.tabs { display: flex; gap: 1.25rem; border-bottom: 1px solid var(--line); }
.tab {
  padding: 0.625rem 0.125rem; margin-bottom: -1px;
  border-bottom: 2px solid transparent; font-size: 0.875rem; font-weight: 500;
  color: var(--n-500); text-decoration: none; white-space: nowrap;
}
.tab:hover { color: var(--n-800); }
.tab.is-active { border-color: var(--brand); color: var(--brand-fg); font-weight: 600; }

/* ── Modales ──────────────────────────────────────────────────────────── */

.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgb(15 23 42 / .6); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal {
  width: 100%; max-width: 32rem; max-height: 90vh; overflow: auto;
  background: var(--surface); border-radius: var(--r-card); box-shadow: 0 24px 48px -12px rgb(15 23 42 / .35);
}
.modal-hd { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--line-soft); }
.modal-bd { padding: 1.25rem; }
.modal-ft { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem;
  padding: 1rem 1.25rem; border-top: 1px solid var(--line-soft); background: var(--n-50);
  border-radius: 0 0 var(--r-card) var(--r-card); }

/* ── Barra de herramientas / cabecera de página ──────────────────────── */

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; flex-wrap: wrap;
}
.toolbar-end { justify-content: flex-end; }

/* ── Burbujas de chat (WhatsApp) ──────────────────────────────────────── */

.bubble {
  max-width: 20rem; padding: 0.625rem 1rem;
  border-radius: var(--r-card); font-size: 0.875rem; line-height: 1.5;
  box-shadow: var(--shadow-sm); overflow-wrap: anywhere;
}
.bubble-in { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 0.25rem; }
.bubble-out { background: var(--brand-soft); border: 1px solid rgb(234 88 12 / 0.3); border-bottom-right-radius: 0.25rem; }
@media (min-width: 1024px) { .bubble { max-width: 28rem; } }

/* ── Toasts ───────────────────────────────────────────────────────────── */

#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 80; pointer-events: none; }
.toast {
  pointer-events: auto; padding: 0.75rem 1rem; border-radius: var(--r-ctl);
  background: var(--toast-bg); color: #fff; font-size: 0.875rem; font-weight: 500;
  box-shadow: var(--shadow-md); max-width: 22rem;
}
.toast-error { background: var(--danger); }
.toast-warn  { background: var(--warn); }

/* ── Navegación lateral ───────────────────────────────────────────────── */

.sidebar { background: #0b0f19; }
.nav-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0.75rem; border-radius: var(--r-ctl);
  font-size: 0.875rem; font-weight: 500; text-decoration: none;
  color: var(--n-400); transition: background .12s ease, color .12s ease;
}
.nav-link:hover { background: rgb(255 255 255 / .07); color: #fff; }
.nav-link.is-active { background: var(--brand); color: #fff; }
.nav-section {
  padding: 1.25rem 0.75rem 0.375rem;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: #fb923c;
}
.nav-sep { border-top: 1px solid rgb(255 255 255 / .08); }
html.dark .sidebar { background: #080c15; border-right: 1px solid var(--line); }

/* Barra superior */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-sm); }

/* Botón de solo icono sobre el menú lateral (cambiar sucursal, cerrar sesión) */
.sidebar-btn {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 2rem; height: 2rem; border: 0; border-radius: var(--r-ctl);
  background: transparent; color: #94a3b8; cursor: pointer; text-decoration: none;
  transition: background .12s ease, color .12s ease;
}
.sidebar-btn:hover { background: rgb(255 255 255 / .1); color: #fff; }
.sidebar-label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: #94a3b8; }
.sidebar-meta  { font-size: 0.75rem; color: #94a3b8; }
.nav-badge {
  margin-left: auto; min-width: 1.1rem; height: 1.1rem; padding: 0 0.25rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
}

/* ── Utilidades ───────────────────────────────────────────────────────── */

/* Cargando: un solo estilo de spinner en toda la app.
   Los tres nombres (spinner, spinner-xl, spinner-lg) funcionan por separado.
   Nota: se duplican las clases (.spinner.spinner) para ganarle en especificidad
   a las utilidades de Tailwind (border-*, que se inyectan despues de app.css). */
.spinner, .spinner-xl, .spinner-lg {
  display: inline-block;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 999px;
  animation: spin .7s linear infinite; vertical-align: -0.125em;
}
.spinner    { width: 1rem;   height: 1rem; }
.spinner-xl { width: 2rem;   height: 2rem; }
.spinner-lg { width: 3rem;   height: 3rem; border-width: 4px; }
.spinner.spinner, .spinner-xl.spinner-xl, .spinner-lg.spinner-lg { border-top-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.scroll-y { overflow-y: auto; }
.skeleton { background: linear-gradient(90deg, var(--n-100) 25%, var(--n-200) 37%, var(--n-100) 63%);
  background-size: 400% 100%; animation: skeleton 1.4s ease infinite; border-radius: 0.375rem; }
@keyframes skeleton { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ── Círculo con icono y fondos de estado ───────────────────────────────
   .icon-circle   círculo centrado (el tamaño se da con w-* h-*)
   .tint-*        fondo suave de estado para filas, campos y avisos          */
.icon-circle { display: flex; align-items: center; justify-content: center; border-radius: 999px;
  background: var(--n-100); color: var(--n-500); }
.icon-circle-ok     { background: var(--ok-soft);     color: var(--ok-ink); }
.icon-circle-danger { background: var(--danger-soft); color: var(--danger-ink); }
.icon-circle-warn   { background: var(--warn-soft);   color: var(--warn-ink); }
.icon-circle-info   { background: var(--info-soft);   color: var(--info-ink); }
.icon-circle-brand  { background: var(--brand-soft);  color: var(--brand-fg); }

.tint-ok     { background-color: var(--ok-soft); }
.tint-danger { background-color: var(--danger-soft); }
.tint-warn   { background-color: var(--warn-soft); }
.tint-info   { background-color: var(--info-soft); }
.tint-brand  { background-color: var(--brand-soft); }

/* ── Utilidades de color de Tailwind que siguen el tema ──────────────────
   Tailwind (CDN) inyecta sus utilidades DESPUÉS de este archivo, por eso
   estas reglas llevan "html" delante: ganan por especificidad.

   1) Textos semánticos: se remapean a los tokens -ink, que cumplen WCAG AA
      en claro y se aclaran solos en oscuro (los tonos -500/-600 de Tailwind
      sobre blanco quedaban en 3:1).
   2) Neutros, fondos y bordes: sólo en modo nocturno; la escala slate de
      Tailwind se mapea a la escala invertida --n-*.                       */

html .text-emerald-500, html .text-emerald-600, html .text-emerald-700 { color: var(--ok-ink); }
html .text-amber-500, html .text-amber-600, html .text-amber-700, html .text-amber-800 { color: var(--warn-ink); }
html .text-red-400, html .text-red-500, html .text-red-600, html .text-red-700 { color: var(--danger-ink); }
html .text-blue-500, html .text-blue-600, html .text-blue-700, html .text-blue-900 { color: var(--info-ink); }
html .text-slate-500 { color: var(--n-500); }
html .text-brand { color: var(--brand-fg); }
html .text-brand-dark { color: var(--brand-ink); }
html .hover\:text-red-500:hover, html .hover\:text-red-600:hover { color: var(--danger-ink); }
html .hover\:text-blue-700:hover { color: var(--info-ink); }
html .hover\:text-brand-dark:hover { color: var(--brand-ink); }
html .group:hover .group-hover\:text-brand { color: var(--brand-fg); }

html.dark .bg-white { background-color: var(--surface); }
html.dark .bg-slate-50  { background-color: var(--n-50); }
html.dark .bg-slate-100 { background-color: var(--n-100); }
html.dark .bg-slate-200 { background-color: var(--n-200); }
html.dark .bg-slate-300 { background-color: var(--n-300); }
html.dark .bg-slate-400 { background-color: var(--n-400); }
html.dark .bg-slate-50\/80 { background-color: color-mix(in srgb, var(--n-50) 80%, transparent); }
html.dark .hover\:bg-slate-50:hover  { background-color: var(--n-50); }
html.dark .hover\:bg-slate-50\/60:hover { background-color: color-mix(in srgb, var(--n-50) 60%, transparent); }
html.dark .hover\:bg-slate-100:hover { background-color: var(--n-100); }
html.dark .hover\:bg-slate-200:hover { background-color: var(--n-200); }

html.dark .text-slate-300 { color: var(--n-300); }
html.dark .text-slate-400 { color: var(--n-400); }
html.dark .text-slate-600, html.dark .hover\:text-slate-600:hover { color: var(--n-600); }
html.dark .text-slate-700 { color: var(--n-700); }
html.dark .text-slate-800 { color: var(--n-800); }
html.dark .text-slate-900 { color: var(--n-900); }

html.dark .border-slate-50  { border-color: var(--line-soft); }
html.dark .border-slate-100 { border-color: var(--line-soft); }
html.dark .border-slate-200 { border-color: var(--line); }
html.dark .border-slate-300, html.dark .hover\:border-slate-300:hover { border-color: var(--n-300); }
html.dark .divide-slate-50  > :not([hidden]) ~ :not([hidden]),
html.dark .divide-slate-100 > :not([hidden]) ~ :not([hidden]) { border-color: var(--line-soft); }

html.dark .hover\:bg-brand-light:hover { background-color: var(--brand-soft); }
html.dark .border-emerald-200 { border-color: var(--ok-line); }
html.dark .border-blue-200 { border-color: var(--info-line); }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}
