/* ============================================================
   assets/css/app.css — Estilos comunes de Sistemas Zhenbo
   ------------------------------------------------------------
   FASE 1: extracción. Esto NO cambia el aspecto del sistema,
   solo reúne en un archivo lo que estaba repetido en cada
   módulo. Los colores salen de las variables que definen
   includes/sidebar.php y includes/tema.php.

   Se carga desde sidebar.php, o sea DESPUÉS del <style> de
   cada módulo, así que gana ante reglas de igual peso.
   Por eso reproduce los valores mayoritarios tal cual estaban.
   ============================================================ */


/* Los tokens (:root) viven en assets/css/tokens.css */

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

html, body {
  height: 100%;
  font-family: var(--font-ui);
  background: var(--negro);
  color: var(--blanco);
}

.main {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 28px;
  min-height: calc(100vh - var(--topbar-h));
}

/* ── ENCABEZADO DE PÁGINA ───────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-family: var(--font-display); font-size: 26px; font-weight: 700; }
.page-header p  { font-size: 13px; color: var(--gris-texto); margin-top: 2px; }
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── TABLAS COMO TARJETAS EN MÓVIL (app.js pone data-label) ── */
@media (max-width: 768px) {
  table.tabla-cards, table.tabla-cards tbody, table.tabla-cards tr, table.tabla-cards td { display: block; width: 100%; min-width: 0 !important; }
  table.tabla-cards thead { display: none; }
  table.tabla-cards tbody tr {
    border: 1px solid var(--border) !important; border-radius: 10px; margin: 10px; padding: 6px 0;
    background: var(--surface);
  }
  table.tabla-cards tbody tr:hover { background: var(--surface); }
  table.tabla-cards tbody td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 7px 14px !important; border: none !important; text-align: right;
  }
  table.tabla-cards tbody td[data-label]::before {
    content: attr(data-label); flex: 0 0 38%; text-align: left;
    font-size: 10px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted);
  }
  table.tabla-cards tbody td:not([data-label]) { justify-content: flex-start; text-align: left; }
  table.tabla-cards tbody td .acciones { justify-content: flex-end; flex-wrap: wrap; width: 100%; }
  table.tabla-cards tbody td:first-child { padding-top: 10px !important; }
  table.tabla-cards tbody td:last-child { padding-bottom: 10px !important; }
  .table-wrap { overflow: visible; background: transparent; border: none; }
}

/* ── SIDEBAR COMPACTO (html.sb-mini): solo iconos, se expande al pasar el mouse ── */
@media (min-width: 769px) {
  html.sb-mini { --sidebar-w: 64px; }
  html.sb-mini .sidebar { transition: width .18s ease; overflow-x: hidden; }
  html.sb-mini .sidebar:hover { width: 240px; box-shadow: var(--shadow); }
  html.sb-mini .sidebar:not(:hover) .sidebar-item,
  html.sb-mini .sidebar:not(:hover) .sidebar-toggle { padding-left: 22px; padding-right: 0; white-space: nowrap; overflow: hidden; }
  html.sb-mini .sidebar:not(:hover) .sidebar-sub .sidebar-item { padding-left: 22px; }
  html.sb-mini .sidebar:not(:hover) .sidebar-section-title { color: transparent; height: 8px; margin: 0; overflow: hidden; }
  html.sb-mini .sidebar:not(:hover) .rol-badge { font-size: 0; padding: 8px; margin: 10px 12px 2px; gap: 0; }
  html.sb-mini .sidebar:not(:hover) .rol-badge .ico { width: 15px; height: 15px; }
  html.sb-mini .sidebar:not(:hover) .sidebar-logo { padding: 14px 12px; }
  html.sb-mini .sidebar:not(:hover) .sidebar-logo img { width: 40px; max-height: 40px; }
  html.sb-mini .sidebar:not(:hover) .chevron { display: none; }
  html.sb-mini .sidebar .sidebar-item, html.sb-mini .sidebar .sidebar-toggle { transition: padding .18s; }
}
.sb-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 6px; margin-right: 10px;
  background: none; border: 1px solid transparent; color: var(--text-muted); cursor: pointer;
}
.sb-toggle:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.sb-toggle .ico { transition: transform .18s; }
html.sb-mini .sb-toggle .ico { transform: rotate(180deg); }
@media (max-width: 768px) { .sb-toggle { display: none; } }

/* ── FORMULARIOS: pie fijo del modal + validación en línea + secciones ── */
.modal .modal-footer {
  position: sticky; bottom: -28px; z-index: 3;
  background: var(--surface); margin: 22px -28px -28px; padding: 14px 28px 18px;
  border-top: 1px solid var(--border);
}
.is-invalid, .form-field .is-invalid, .ff .is-invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px var(--danger-soft) !important; }
.field-error { display: block; font-size: 11.5px; color: var(--danger); margin-top: 5px; line-height: 1.3; }
.section-label, .form-seccion {
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent);
  margin: 18px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.form-grid > .section-label, .form-grid > .form-seccion { grid-column: 1 / -1; margin-top: 8px; }
.req::after { content: ' *'; color: var(--danger); }

/* ── SELECTS CON FLECHA PROPIA + FOCO UNIFORME ─────────────── */
.form-field select, .ff select, .filter-select, .empresa-switcher select, select.sel {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 34px !important;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 14px;
  cursor: pointer;
}
.form-field select:focus, .ff select:focus, .filter-select:focus { border-color: var(--accent); }
/* Anillo de foco solo con teclado (no al hacer clic) */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.form-field input:focus-visible, .form-field select:focus-visible, .form-field textarea:focus-visible,
.ff input:focus-visible, .ff select:focus-visible, .ff textarea:focus-visible, .search-input:focus-visible, .filter-select:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus, .ff input:focus, .ff select:focus, .ff textarea:focus, .search-input:focus, .filter-select:focus {
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* Transiciones suaves y uniformes */
.btn, .sidebar-item, .stat-card, .sc, .form-field input, .form-field select, .ff input, .ff select, .search-input, .filter-select, .modal { transition: background .15s, border-color .15s, color .15s, box-shadow .15s, opacity .15s, transform .12s; }
.modal-overlay:not(.hidden) .modal { animation: zh-modal-in .18s ease-out; }
@keyframes zh-modal-in { from { opacity: 0; transform: translateY(8px) scale(.985) } to { opacity: 1; transform: none } }
@media (prefers-reduced-motion: reduce) { .modal-overlay:not(.hidden) .modal { animation: none } }
/* Importes y códigos: cifras alineadas */
.num, .monto, td.num, .stat-card .num, .sc .sn, .total, .subtotal { font-variant-numeric: tabular-nums; }

/* ── PALETA DE BÚSQUEDA Ctrl+K (assets/js/app.js) ───────── */
.zh-pal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 500; display: none; align-items: flex-start; justify-content: center; padding: 10vh 16px 0; backdrop-filter: blur(2px); }
.zh-pal-overlay.show { display: flex; }
.zh-pal { width: 100%; max-width: 640px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.zh-pal-in { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.zh-pal-lupa { font-size: 20px; color: var(--text-muted); }
.zh-pal-in input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-family: var(--font-ui); font-size: 16px; height: 32px; }
.zh-pal-in kbd { font-size: 11px; color: var(--text-muted); border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px; font-family: var(--font-ui); }
.zh-pal-list { max-height: 55vh; overflow-y: auto; padding: 6px; }
.zh-pal-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.zh-pal-item.on { background: var(--accent-soft); }
.zh-pal-tipo { flex: 0 0 74px; font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); }
.zh-pal-txt { display: flex; flex-direction: column; min-width: 0; }
.zh-pal-txt b { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zh-pal-txt small { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zh-pal-vacio { padding: 26px; text-align: center; color: var(--text-muted); font-size: 13px; }
.btn-buscar-global { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; color: var(--text-muted); font-family: var(--font-ui); font-size: 13px; padding: 7px 12px; cursor: pointer; }
.btn-buscar-global:hover { border-color: var(--accent); color: var(--text); }
.btn-buscar-global kbd { font-size: 10px; border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-family: var(--font-ui); }
@media (max-width: 768px) { .btn-buscar-global span, .btn-buscar-global kbd { display: none; } }

/* ── ICONOS (includes/iconos.php → ico('nombre')) ───────── */
.ico { display: inline-block; vertical-align: -0.18em; flex-shrink: 0; }
.btn .ico { vertical-align: middle; }

/* ── BOTONES ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 6px;
  font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; text-decoration: none;
  transition: opacity .2s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 15px; height: 15px; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-primary   { background: var(--naranja); color: #fff; }
.btn-primary:hover { opacity: .88; }
.btn-secondary { background: var(--gris-med); color: var(--blanco); border: 1px solid var(--gris-borde); }
.btn-secondary:hover { background: var(--sidebar-hover); }
.btn-danger    { background: rgba(240,68,68,.12);  color: var(--danger); border: 1px solid rgba(240,68,68,.3); }
.btn-danger:hover  { background: rgba(240,68,68,.22); }
.btn-info      { background: rgba(59,130,246,.12); color: var(--info); border: 1px solid rgba(59,130,246,.3); }
.btn-info:hover    { background: rgba(59,130,246,.22); }
.btn-success   { background: rgba(34,197,94,.15);  color: var(--success); border: 1px solid rgba(34,197,94,.3); }
.btn-success:hover { background: rgba(34,197,94,.25); }
.btn-warning   { background: rgba(234,179,8,.15);  color: var(--warning); border: 1px solid rgba(234,179,8,.3); }
.btn-warning:hover { background: rgba(234,179,8,.25); }
.btn-purple    { background: rgba(168,85,247,.15); color: var(--purple); border: 1px solid rgba(168,85,247,.3); }
.btn-purple:hover  { background: rgba(168,85,247,.25); }
.btn-disabled, .btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
/* Estado "enviando" (assets/js/app.js lo pone al hacer submit) */
.btn.is-loading, button.is-loading { opacity: .75; cursor: progress; pointer-events: none; }
.spin {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: zh-spin .7s linear infinite; vertical-align: -2px;
}
@keyframes zh-spin { to { transform: rotate(360deg) } }

.btn-remove {
  background: rgba(240,68,68,.15); border: none; color: var(--danger);
  width: 28px; height: 28px; border-radius: 4px; cursor: pointer;
  font-size: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.btn-remove:hover { background: rgba(240,68,68,.3); }

/* ── ALERTAS ────────────────────────────────────────────── */
.alert {
  padding: 12px 18px; border-radius: 8px; font-size: 13px;
  margin-bottom: 20px; display: flex; align-items: center; gap: 8px;
}
.alert-ok   { background: rgba(34,197,94,.12);  border: 1px solid rgba(34,197,94,.3);  color: var(--success); }
.alert-err  { background: rgba(240,68,68,.12);  border: 1px solid rgba(240,68,68,.3);  color: var(--danger); }
.alert-warn { background: rgba(234,179,8,.10);  border: 1px solid rgba(234,179,8,.25); color: var(--warning); }

/* ── TARJETAS DE CONTEO ─────────────────────────────────── */
.stats-row, .stats { display: flex; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.stat-card, .sc {
  background: var(--gris-osc); border: 1px solid var(--gris-borde);
  border-radius: 8px; padding: 12px 18px;
  display: flex; flex-direction: column; gap: 4px;
  min-width: 120px; cursor: pointer; transition: border-color .2s;
  text-decoration: none; color: inherit;
}
.stat-card:hover, .sc:hover { border-color: var(--naranja); }
.stat-card .num, .sc .sn { font-family: var(--font-display); font-size: 24px; font-weight: 700; }
.stat-card .lbl, .sc .sl { font-size: 10px; color: var(--gris-texto); text-transform: uppercase; letter-spacing: 1px; }

/* ── FILTROS Y BÚSQUEDA ─────────────────────────────────── */
.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.search-wrap { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 15px; color: var(--gris-texto); }
.search-input {
  width: 100%; height: 40px;
  background: var(--gris-med); border: 1px solid var(--gris-borde); border-radius: 6px;
  color: var(--blanco); font-family: var(--font-ui); font-size: 13px;
  padding: 0 14px 0 36px; outline: none;
}
.search-input:focus { border-color: var(--naranja); }
.filter-select {
  height: 40px; background: var(--gris-med); border: 1px solid var(--gris-borde);
  border-radius: 6px; color: var(--blanco); font-family: var(--font-ui);
  font-size: 13px; padding: 0 12px; outline: none; cursor: pointer;
}
.filter-select:focus { border-color: var(--naranja); }

/* ── TABLAS ─────────────────────────────────────────────── */
.table-wrap {
  background: var(--gris-osc); border: 1px solid var(--gris-borde);
  border-radius: 10px; overflow: hidden; overflow-x: auto; /* móvil: scroll lateral en vez de romper la tabla */
  -webkit-overflow-scrolling: touch;
}
.table-wrap table, table.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-wrap thead th, table.tabla thead th {
  background: var(--gris-med); padding: 12px 16px; text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase;
  color: var(--gris-texto); border-bottom: 1px solid var(--gris-borde); white-space: nowrap;
}
.table-wrap tbody tr, table.tabla tbody tr { border-bottom: 1px solid var(--gris-borde); transition: background .15s; }
.table-wrap tbody tr:last-child, table.tabla tbody tr:last-child { border-bottom: none; }
.table-wrap tbody tr:hover, table.tabla tbody tr:hover { background: var(--gris-med); }
.table-wrap tbody td, table.tabla tbody td { padding: 11px 16px; color: var(--text); }
.acciones { display: flex; gap: 6px; }
.empty-state { text-align: center; padding: 48px; color: var(--gris-texto); font-size: 14px; }
.empty-state--rich { display: flex; flex-direction: column; align-items: center; gap: 6px; line-height: 1.5; }
.empty-state--rich > .ico { width: 34px; height: 34px; opacity: .55; margin-bottom: 4px; }
.empty-state--rich small { color: var(--text-muted); }
.empty-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }
td.empty-state { display: table-cell; }

/* ── MODALES ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.8); z-index: 300;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--gris-osc); border: 1px solid var(--gris-borde); border-radius: 12px;
  padding: 28px; width: 100%; max-width: 960px; position: relative;
  max-height: 94vh; overflow-y: auto;
}
.modal-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; margin-bottom: 20px; }
.modal-title span { color: var(--naranja); }
.modal-sub { font-size: 13px; color: var(--gris-texto); margin: -14px 0 18px; }
.modal-close {
  position: absolute; top: 16px; right: 16px; background: none; border: none;
  color: var(--gris-texto); cursor: pointer; font-size: 20px; line-height: 1;
}
.modal-close:hover { color: var(--blanco); }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--gris-borde);
}

/* ── FORMULARIOS ────────────────────────────────────────── */
/* .ff y .form-field son el mismo componente con dos nombres */
.form-field, .ff { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-field label, .ff label {
  font-size: 11px; font-weight: 600; letter-spacing: 1px;
  text-transform: uppercase; color: var(--gris-texto);
}
.form-field input, .form-field select, .ff input, .ff select {
  height: 42px; background: var(--gris-med); border: 1px solid var(--gris-borde);
  border-radius: 6px; color: var(--blanco); font-family: var(--font-ui);
  font-size: 14px; padding: 0 14px; outline: none; width: 100%;
}
.form-field textarea, .ff textarea {
  background: var(--gris-med); border: 1px solid var(--gris-borde); border-radius: 6px;
  color: var(--blanco); font-family: var(--font-ui); font-size: 14px;
  padding: 10px 14px; outline: none; width: 100%; height: 72px; resize: vertical;
}
/* Checkbox / radio / file NO son cajas de texto: sin alto fijo ni ancho 100% */
.form-field input[type="checkbox"], .form-field input[type="radio"],
.ff input[type="checkbox"], .ff input[type="radio"] {
  width: 16px; height: 16px; padding: 0; margin: 0; flex: 0 0 auto;
  accent-color: var(--accent); cursor: pointer; border: none; background: none;
}
.form-field input[type="file"], .ff input[type="file"] { height: auto; padding: 8px 10px; }
/* Labels anidados (listas de opciones dentro de un campo) vuelven a texto normal */
.form-field label label, .form-field .check-list label, .ff label label {
  text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 400; color: var(--text);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus,
.ff input:focus, .ff select:focus, .ff textarea:focus { border-color: var(--naranja); }
.form-field input::placeholder, .ff input::placeholder,
.form-field textarea::placeholder, .ff textarea::placeholder { color: var(--gris-texto); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full, .full { grid-column: 1 / -1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }

/* ── TABLA DE ÍTEMS DENTRO DE MODALES ───────────────────── */
.items-section-title, .servs-section-title, .section-label {
  font-size: 13px; font-weight: 700; color: var(--naranja);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 10px; padding-bottom: 8px;
  border-bottom: 1px solid var(--gris-borde);
  display: flex; justify-content: space-between; align-items: center;
}
.items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.items-table th {
  background: var(--gris-med); padding: 8px 12px; text-align: left;
  font-size: 11px; font-weight: 600; color: var(--gris-texto);
  text-transform: uppercase; letter-spacing: .5px;
}
.items-table td { padding: 8px 12px; border-bottom: 1px solid var(--gris-borde); vertical-align: top; }
.items-table tr:last-child td { border-bottom: none; }
.items-table input {
  background: var(--gris-osc); border: 1px solid var(--gris-borde); border-radius: 4px;
  color: var(--blanco); font-family: var(--font-ui); font-size: 13px;
  padding: 4px 8px; width: 100%; outline: none; height: 34px;
}
.items-table input:focus { border-color: var(--naranja); }

/* ── SUBIDA DE ARCHIVOS ─────────────────────────────────── */
.upload-area, .file-input-wrap {
  border: 2px dashed var(--gris-borde); border-radius: 8px; padding: 20px;
  text-align: center; cursor: pointer; transition: border-color .2s;
}
.upload-area:hover, .file-input-wrap:hover { border-color: var(--naranja); }
.upload-area input[type=file], .file-input-wrap input[type=file] { display: none; }
.upload-area p { font-size: 13px; color: var(--gris-texto); margin-top: 6px; }
.upload-name, .file-name { font-size: 13px; color: var(--naranja); font-weight: 600; margin-top: 4px; }

/* ── BUSCADOR DESPLEGABLE (ítems, servicios, proveedores) ─ */
.item-dropdown, .combo-list, .cat-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--gris-med); border: 1px solid var(--gris-borde); border-radius: 8px;
  max-height: 380px; overflow-y: auto; z-index: 400; display: none;
  box-shadow: 0 12px 32px rgba(0,0,0,.6);
}
.item-dropdown.show, .combo-list.show, .cat-dropdown.show { display: block; }
.item-dropdown::-webkit-scrollbar, .combo-list::-webkit-scrollbar { width: 10px; }
.item-dropdown::-webkit-scrollbar-track, .combo-list::-webkit-scrollbar-track { background: transparent; }
.item-dropdown::-webkit-scrollbar-thumb, .combo-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
.item-dropdown::-webkit-scrollbar-thumb:hover, .combo-list::-webkit-scrollbar-thumb:hover { background: var(--naranja); }

.item-drop-head {
  position: sticky; top: 0; background: var(--sidebar-hover); padding: 7px 14px;
  font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--gris-texto); border-bottom: 1px solid var(--gris-borde); z-index: 1;
}
.item-drop-head b { color: var(--naranja); }
.item-option, .combo-item, .cat-option {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  cursor: pointer; font-size: 13px; transition: background .12s;
  border-bottom: 1px solid rgba(128,128,128,.10);
}
.item-option:last-child, .combo-item:last-child, .cat-option:last-child { border-bottom: none; }
.item-option:hover, .item-option.active,
.combo-item:hover, .combo-item.active,
.cat-option:hover, .cat-option.active { background: var(--accent-soft); }
.item-option .ico {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 7px;
  background: var(--accent-soft); color: var(--naranja);
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.item-option .txt { min-width: 0; flex: 1; }
.item-option .cod { color: var(--naranja); font-size: 11px; font-weight: 700; margin-bottom: 2px; letter-spacing: .5px; }
.item-option .nom { color: var(--blanco); font-weight: 500; white-space: normal; overflow-wrap: anywhere; line-height: 1.35; }
.item-option .uni {
  flex-shrink: 0; font-size: 10px; font-weight: 600; color: var(--gris-texto);
  background: var(--gris-med); padding: 3px 8px; border-radius: 4px; text-transform: uppercase;
}
.item-drop-empty, .combo-empty { padding: 26px 14px; text-align: center; color: var(--gris-texto); font-size: 13px; }
.item-drop-empty .em-ico { font-size: 26px; opacity: .4; margin-bottom: 8px; }

/* ── ETIQUETAS DE ESTADO ────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
}
.badge-borrador, .badge-anulada, .badge-anulado, .badge-inactivo { background: rgba(128,128,128,.15); color: var(--text-muted); }
.badge-pendiente        { background: rgba(234,179,8,.15);  color: var(--warning); }
.badge-valorizado, .badge-recibida_parcial, .badge-parcial { background: rgba(249,115,22,.15); color: var(--accent); }
.badge-aprobado, .badge-recibida, .badge-conformidad, .badge-pagado,
.badge-concluida, .badge-activo { background: rgba(34,197,94,.15); color: var(--success); }
.badge-rechazado        { background: rgba(240,68,68,.15);  color: var(--danger); }
.badge-emitida, .badge-enviada, .badge-compra, .badge-en_ejecucion { background: rgba(59,130,246,.15); color: var(--info); }
.badge-servicio         { background: rgba(168,85,247,.15); color: var(--purple); }

/* ── DETALLE DE DOCUMENTO ───────────────────────────────── */
.detail-header {
  background: var(--gris-med); border-radius: 8px; padding: 16px 20px; margin-bottom: 16px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
}
.detail-field .dlabel { font-size: 10px; color: var(--gris-texto); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 3px; }
.detail-field .dvalue { font-size: 14px; color: var(--blanco); font-weight: 500; }
.detail-items { background: var(--gris-osc); border: 1px solid var(--gris-borde); border-radius: 8px; overflow: hidden; }
.detail-items table { width: 100%; border-collapse: collapse; font-size: 13px; }
.detail-items thead th {
  background: var(--gris-med); padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 600; color: var(--gris-texto);
  text-transform: uppercase; border-bottom: 1px solid var(--gris-borde);
}
.detail-items tbody td { padding: 10px 14px; border-bottom: 1px solid var(--gris-borde); color: var(--text); }
.detail-items tbody tr:last-child td { border-bottom: none; }

/* ── MÓVIL ──────────────────────────────────────────────── */
@media (max-width: 860px) {
  .main { margin-left: 0; padding: 18px 14px; }
  .form-grid, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .modal { padding: 20px 16px; max-height: 96vh; }
  .search-wrap { max-width: none; }
  .table-wrap { overflow-x: auto; }
}

/* ============================================================
   FASE 2A — MEJORAS VISUALES
   ------------------------------------------------------------
   Todo lo de abajo se aplica a los 24 módulos sin editar
   ninguno, porque reutiliza las clases que ya existen.
   Si algo no te gusta, borra este bloque y vuelves al aspecto
   anterior sin tocar nada más.
   ============================================================ */

/* ── Números alineados ──────────────────────────────────────
   Los montos y cantidades usan cifras de ancho fijo, así las
   columnas de la tabla quedan alineadas en la coma decimal. */
td, th, .num, .sn, .res-val, .stat-card .num,
input[type=number] { font-variant-numeric: tabular-nums; }

/* ── Foco visible para teclado ──────────────────────────────
   Antes solo cambiaba el borde; con Tab no se notaba dónde
   estabas parado. */
:where(input, select, textarea, button, a, [tabindex]):focus-visible {
  outline: 2px solid var(--naranja);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ── Botones con más presencia ──────────────────────────── */
.btn { line-height: 1; white-space: nowrap; letter-spacing: .2px; }
.btn-primary { box-shadow: 0 1px 0 rgba(0,0,0,.25); }
.btn-primary:hover { opacity: 1; filter: brightness(1.08); }
.btn:disabled, .btn-disabled { filter: grayscale(.4); }

/* ── Campos de formulario ───────────────────────────────── */
.form-field input, .form-field select, .form-field textarea,
.ff input, .ff select, .ff textarea,
.search-input, .filter-select {
  transition: border-color .15s, background .15s;
}
.form-field input:hover, .form-field select:hover, .ff input:hover, .ff select:hover,
.search-input:hover, .filter-select:hover { border-color: var(--gris-texto); }
.form-field label, .ff label { display: flex; align-items: center; gap: 6px; }
/* Marca visual para campos obligatorios */
.form-field label .req, .ff label .req { color: var(--danger); font-size: 13px; line-height: 0; }
/* El select nativo con su flecha propia se ve distinto en cada
   navegador; esto lo empareja. */
.form-field select, .ff select, .filter-select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--gris-texto) 50%),
                    linear-gradient(135deg, var(--gris-texto) 50%, transparent 50%);
  background-position: calc(100% - 17px) center, calc(100% - 12px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

/* ── Filas de tabla más legibles ────────────────────────── */
.table-wrap tbody tr:hover, table.tabla tbody tr:hover {
  background: var(--gris-med);
  box-shadow: inset 3px 0 0 var(--naranja);
}
.table-wrap tbody td:first-child, table.tabla tbody td:first-child { color: var(--blanco); font-weight: 500; }
/* Los botones de acción se atenúan hasta que el cursor entra
   en la fila: la tabla se lee sin el ruido de 3 botones por línea. */
.table-wrap tbody .acciones { opacity: .6; transition: opacity .15s; }
.table-wrap tbody tr:hover .acciones,
.table-wrap tbody .acciones:focus-within { opacity: 1; }
.table-wrap { overflow-x: auto; }

/* ── Tarjetas de conteo ─────────────────────────────────── */
.stat-card, .sc { position: relative; overflow: hidden; }
.stat-card::after, .sc::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--naranja); opacity: 0; transition: opacity .2s;
}
.stat-card:hover::after, .sc:hover::after { opacity: 1; }
.stat-card.activa, .sc.activa { border-color: var(--naranja); }
.stat-card.activa::after, .sc.activa::after { opacity: 1; }

/* ── Modales ────────────────────────────────────────────── */
.modal-overlay { animation: zh-fade .14s ease-out; }
.modal { animation: zh-rise .18s ease-out; }
@keyframes zh-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes zh-rise { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }
/* El título del modal queda fijo al hacer scroll dentro de él */
.modal-title {
  position: sticky; top: -28px; z-index: 2;
  background: var(--gris-osc);
  margin: -28px -28px 20px; padding: 22px 28px 14px;
  border-bottom: 1px solid var(--gris-borde);
}
.modal-footer { position: sticky; bottom: -28px; background: var(--gris-osc); margin: 22px -28px -28px; padding: 16px 28px; }
@media (prefers-reduced-motion: reduce) {
  .modal-overlay, .modal { animation: none; }
}

/* ── Alertas con más jerarquía ──────────────────────────── */
.alert { border-left-width: 3px; border-radius: 0 8px 8px 0; font-weight: 500; }

/* ── Estados vacíos ─────────────────────────────────────── */
.empty-state { line-height: 1.7; }
.empty-state::before {
  content: ''; display: block; width: 46px; height: 46px; margin: 0 auto 14px;
  border: 2px dashed var(--gris-borde); border-radius: 12px;
}

/* ── Etiquetas de estado ────────────────────────────────── */
.badge { border: 1px solid currentColor; }

/* ── Desplegable de búsqueda ────────────────────────────── */
.item-option, .combo-item, .cat-option { scroll-margin: 8px; }
.item-option.active, .combo-item.active, .cat-option.active { box-shadow: inset 3px 0 0 var(--naranja); }

/* ── Barra de scroll de toda la app ─────────────────────── */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gris-borde); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--gris-texto); }

/* ── Impresión ──────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .filters, .acciones, .btn, .modal-overlay, .menu-toggle { display: none !important; }
  .main { margin: 0; padding: 0; }
  .table-wrap { border: none; }
  body { background: #fff; color: #000; }
}

/* ============================================================
   COMPONENTES (includes/componentes.php)
   ============================================================ */

/* ── Toasts ─────────────────────────────────────────────── */
.toast-wrap {
  position: fixed; right: 20px; bottom: 20px; z-index: 600;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 380px; transition: opacity .4s;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--gris-osc); border: 1px solid var(--gris-borde);
  border-left: 3px solid var(--gris-texto);
  border-radius: 8px; padding: 13px 14px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  animation: zh-toast-in .22s ease-out;
}
@keyframes zh-toast-in { from { opacity: 0; transform: translateX(24px) } to { opacity: 1; transform: none } }
.toast-ico { font-weight: 700; line-height: 1.3; }
.toast-txt { flex: 1; line-height: 1.45; color: var(--blanco); }
.toast-x { background: none; border: none; color: var(--gris-texto); cursor: pointer; font-size: 17px; line-height: 1; padding: 0 2px; }
.toast-x:hover { color: var(--blanco); }
.toast-ok   { border-left-color: var(--success); }
.toast-ok   .toast-ico { color: var(--success); }
.toast-info { border-left-color: var(--info); }
.toast-info .toast-ico { color: var(--info); }
.toast-err  { border-left-color: var(--danger); }
.toast-err  .toast-ico { color: var(--danger); }
.toast-warn { border-left-color: var(--warning); }
.toast-warn .toast-ico { color: var(--warning); }
@media (prefers-reduced-motion: reduce) { .toast { animation: none } }

/* ── Pestañas de estado ─────────────────────────────────── */
.tabs-estado {
  display: flex; gap: 4px; flex-wrap: wrap;
  margin-bottom: 16px; border-bottom: 1px solid var(--gris-borde); padding-bottom: 0;
}
.tabs-estado .tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px; font-size: 13px; font-weight: 500;
  color: var(--gris-texto); text-decoration: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tabs-estado .tab:hover { color: var(--blanco); }
.tabs-estado .tab.on { color: var(--naranja); border-bottom-color: var(--naranja); font-weight: 600; }
.tabs-estado .tab.vacio { opacity: .5; }
.tab-n {
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
  background: var(--gris-med); color: var(--gris-texto);
  padding: 1px 8px; border-radius: 20px; min-width: 24px; text-align: center;
}
.tabs-estado .tab.on .tab-n { background: rgba(249,115,22,.16); color: var(--naranja); }

/* ── Chips de filtro activo ─────────────────────────────── */
.chips { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.chips-lbl { font-size: 12px; color: var(--gris-texto); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--gris-med); border: 1px solid var(--gris-borde); border-radius: 20px;
  padding: 4px 11px; font-size: 12px; color: var(--blanco); text-decoration: none;
}
.chip:hover { border-color: var(--naranja); }
.chip b { color: var(--gris-texto); font-weight: 400; }
.chip:hover b { color: var(--naranja); }
.chip-clear { font-size: 12px; color: var(--naranja); text-decoration: none; margin-left: 4px; }

/* ── Paginación ─────────────────────────────────────────── */
.paginacion {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 16px; border-top: 1px solid var(--gris-borde);
  font-size: 12px; color: var(--gris-texto); flex-wrap: wrap;
}
.pag-btns { display: flex; align-items: center; gap: 4px; }
.pag-b {
  min-width: 30px; height: 30px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--gris-borde); border-radius: 6px;
  color: var(--blanco); text-decoration: none; font-size: 13px; background: var(--gris-med);
}
.pag-b:hover { border-color: var(--naranja); color: var(--naranja); }
.pag-b.on { background: var(--naranja); border-color: var(--naranja); color: #fff; font-weight: 600; }
.pag-b.off { opacity: .35; pointer-events: none; }
.pag-sep { color: var(--gris-texto); padding: 0 2px; }

/* ── Estado vacío con acción ────────────────────────────── */
.empty-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--blanco); }
.empty-text  { font-size: 13px; color: var(--gris-texto); margin-top: 5px; }
.empty-accion { margin-top: 16px; }

/* ============================================================
   PANEL LATERAL DE DETALLE (drawer + línea de tiempo)
   ============================================================ */
.dw-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 380;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.dw-overlay.abierto { opacity: 1; pointer-events: auto; }

.dw {
  position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 92vw;
  background: var(--gris-osc); border-left: 1px solid var(--gris-borde);
  z-index: 390; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .22s ease-out;
  box-shadow: -18px 0 40px rgba(0,0,0,.35);
}
.dw.abierto { transform: none; }
@media (prefers-reduced-motion: reduce) { .dw { transition: none } }
.dw-cargando, .dw-error { padding: 40px 22px; text-align: center; color: var(--gris-texto); font-size: 13px; }
.dw-error { color: var(--danger); }

.dw-head {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--gris-borde); flex-shrink: 0;
}
.dw-head-txt { flex: 1; min-width: 0; }
.dw-cod { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--blanco); }
.dw-sub { font-size: 12px; color: var(--gris-texto); margin-top: 2px; }
.dw-x { background: none; border: none; color: var(--gris-texto); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 2px; }
.dw-x:hover { color: var(--blanco); }

.dw-body { flex: 1; overflow-y: auto; }

/* ── Línea de tiempo ── */
.dw-timeline { padding: 16px 18px 4px; border-bottom: 1px solid var(--gris-borde); }
.dw-paso { display: flex; gap: 12px; }
.dw-punto {
  width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0; margin-top: 3px;
  border: 2px solid var(--gris-borde); background: var(--gris-osc); position: relative;
}
.dw-paso:not(:last-child) .dw-punto::after {
  content: ''; position: absolute; left: 50%; top: 15px; bottom: -18px;
  width: 1px; background: var(--gris-borde); transform: translateX(-50%);
}
.dw-paso.ok .dw-punto     { border-color: var(--success); background: var(--success); }
.dw-paso.actual .dw-punto { border-color: var(--warning); background: transparent; box-shadow: 0 0 0 3px rgba(234,179,8,.18); }
.dw-paso.malo .dw-punto   { border-color: #F04444; background: #F04444; }
.dw-paso.ok:not(:last-child) .dw-punto::after { background: var(--success); opacity: .35; }
.dw-paso-txt { padding-bottom: 16px; min-width: 0; }
.dw-paso-lbl { font-size: 14px; color: var(--blanco); font-weight: 500; }
.dw-paso.pendiente .dw-paso-lbl { color: var(--gris-texto); font-weight: 400; }
.dw-paso-meta { font-size: 12px; color: var(--gris-texto); margin-top: 2px; line-height: 1.5; }
.dw-paso.actual .dw-paso-meta { color: var(--warning); }
.dw-espera { font-weight: 600; }
.dw-paso-nota {
  font-size: 12px; color: var(--gris-texto); margin-top: 5px;
  padding: 6px 10px; background: var(--gris-med); border-radius: 6px; line-height: 1.5;
}

/* ── Secciones del panel ── */
.dw-sec { padding: 14px 18px; border-bottom: 1px solid var(--gris-borde); }
.dw-sec-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--gris-texto); margin-bottom: 9px; }
.dw-tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.dw-tabla td { padding: 6px 0; vertical-align: top; color: var(--blanco); }
.dw-cod-item { font-size: 10px; color: var(--naranja); margin-left: 6px; letter-spacing: .5px; }
.dw-cant { font-size: 11px; color: var(--gris-texto); margin-top: 2px; }
.dw-monto { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dw-total td { border-top: 1px solid var(--gris-borde); padding-top: 9px; font-weight: 600; color: var(--naranja); }
.dw-obs { font-size: 13px; color: var(--text); line-height: 1.6; }

.dw-pie {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 13px 18px; border-top: 1px solid var(--gris-borde); flex-shrink: 0;
}

/* Fila abierta en el listado */
tr.dw-activa { background: var(--gris-med) !important; box-shadow: inset 3px 0 0 var(--naranja); }
tr[data-dw] { cursor: pointer; }

@media (max-width: 620px) {
  .dw { width: 100%; max-width: 100%; }
}
