/* ============================================================================
   GLS ERP · Design system · components.css
   Botones, formularios, filtros, tablas, cards, KPIs, chips/badges, alertas,
   empty states, paginación, tabs, dialog, dropdown, toasts + compatibilidad
   con las clases de los 232 templates existentes (ver docs/design_system.md).
   ============================================================================ */

/* ---------------------------------------------------------------------------
   1. Encabezado de página (.page-header / .title-row)
   --------------------------------------------------------------------------- */
.page-header, .title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); margin: 0 0 var(--sp-5); }
.page-header > div:first-child, .title-row > div:first-child { min-width: 0; }
.page-header h1 + p, .page-header .meta, .title-row > div > p, .title-row h1 + p, .page-header__subtitle { margin: 6px 0 0; color: var(--text-2); font-size: var(--fs-14); }
.page-header__actions, .title-row > div:last-child:not(:first-child) { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; justify-content: flex-end; flex: 0 1 auto; min-width: 0; }
.title-row h2 { margin: 0; }
.title-row + .meta, .title-row + .page-intro { margin-top: calc(-1 * var(--sp-3)); }
.card .title-row { margin-bottom: var(--sp-3); align-items: center; }
.card .title-row a:not(.button):not(.btn) { font-size: var(--fs-13); white-space: nowrap; }

/* ---------------------------------------------------------------------------
   2. Botones (.btn + compat .button / .primary / .secondary / .danger)
   --------------------------------------------------------------------------- */
.btn, .button, :where(button:not(.unstyled):not(.link):not(.icon-btn):not(.tabs__tab):not(.toast__close):not(.message__close)) {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--control-h); padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: var(--fs-14); font-weight: 500; line-height: 1.2; text-decoration: none; white-space: nowrap;
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.btn:hover, .button:hover, :where(button:not(.unstyled):not(.link):not(.icon-btn):not(.tabs__tab)):hover { background: var(--surface-2); border-color: var(--text-3); color: var(--text); text-decoration: none; }
.btn:active, .button:active { background: var(--surface-3); }
.btn:disabled, .button[aria-disabled="true"], .btn[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.btn .icon, .button .icon { width: 18px; height: 18px; margin-left: -2px; }

.btn--primary, .primary, .button.primary, button.primary, .btn.btn--primary {
  background: var(--brand); border-color: var(--brand); color: var(--text-inverse) !important;
}
.btn--primary:hover, .primary:hover, .button.primary:hover, button.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: var(--text-inverse) !important; }
.btn--primary:active, .primary:active { background: var(--brand-active); border-color: var(--brand-active); }
.btn--secondary, .secondary { background: var(--surface); border-color: var(--border-strong); color: var(--brand); font-weight: 600; }
.btn--secondary:hover, .secondary:hover { border-color: var(--brand); background: var(--blue-50); color: var(--brand); }
.btn--accent { background: var(--accent); border-color: var(--accent); color: #fff !important; }
.btn--accent:hover { background: #b84a34; border-color: #b84a34; }
.btn--ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); border-color: transparent; }
.btn--danger, .button.danger, button.danger, .btn.danger { background: var(--surface); border-color: var(--danger-border); color: var(--danger); }
.btn--danger:hover, .button.danger:hover, button.danger:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--red-700); }
.btn--danger.btn--solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger.btn--solid:hover { background: var(--red-700); border-color: var(--red-700); color: #fff; }
.btn--sm, .button--small, .btn.btn--sm { min-height: var(--control-h-sm); padding: 0 10px; font-size: var(--fs-13); border-radius: 6px; }
.btn--sm .icon { width: 16px; height: 16px; }
.btn--lg { min-height: var(--control-h-lg); padding: 0 20px; font-size: var(--fs-16); }
.btn--block { width: 100%; }
.btn--icon, .icon-btn { display: inline-flex; align-items: center; justify-content: center; width: var(--control-h); min-width: var(--control-h); height: var(--control-h); padding: 0; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--text-2); cursor: pointer; }
.btn--icon:hover, .icon-btn:hover { background: var(--surface-3); color: var(--text); }
.btn--icon.btn--sm { width: var(--control-h-sm); min-width: var(--control-h-sm); height: var(--control-h-sm); }
button.link, .btn--link { display: inline; min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; color: var(--blue-700); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
button.link:hover { color: var(--blue-900); background: none; }
button.link.danger { color: var(--danger); }
.button.export-csv::before { content: ""; width: 16px; height: 16px; flex: none; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v11'/%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3Cpath d='M4 20h16'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v11'/%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3Cpath d='M4 20h16'/%3E%3C/svg%3E") center / contain no-repeat; }
.btn-group, .button-group { display: inline-flex; flex-wrap: wrap; gap: var(--sp-2); }
.quick-actions, .form-actions, .setup-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.quick-actions { margin: 0 0 var(--sp-5); }
.form-actions { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--border); }
form.inline, .inline-form { display: inline-block; margin: 0; }
.inline-form button { margin: 0; }
.inline-form input[name="caption"] { max-width: 14rem; }
form[data-once].is-submitting button { opacity: .6; pointer-events: none; }
button[aria-busy="true"] { opacity: .6; cursor: progress; }

/* ---------------------------------------------------------------------------
   3. Formularios (.form, .form-grid, .field) y controles
   --------------------------------------------------------------------------- */
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"])),
:where(select), :where(textarea) {
  width: 100%; min-height: var(--control-h); padding: 8px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: var(--fs-14); line-height: 1.4;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
select { padding-right: 36px; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6673' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
select[multiple] { background-image: none; padding-right: 12px; min-height: 120px; }
textarea { min-height: 104px; resize: vertical; line-height: 1.5; }
input:where(:not([type="checkbox"]):not([type="radio"])):focus, select:focus, textarea:focus { border-color: var(--blue-600); box-shadow: var(--focus-ring); outline: none; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:disabled, select:disabled, textarea:disabled, input[readonly] { background: var(--surface-3); color: var(--text-2); cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); flex: none; cursor: pointer; vertical-align: middle; }
input[type="file"] { width: 100%; padding: 8px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); font-size: var(--fs-13); color: var(--text-2); }
input[type="file"]::file-selector-button { margin-right: 10px; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 5px; background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-13); font-weight: 500; cursor: pointer; }
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"] { min-width: 0; }
input[type="number"] { font-variant-numeric: tabular-nums; }
input.qty, .qty { width: 110px; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"], .field--error input, .field--error select, .field--error textarea, .errorlist + input, .errorlist + select, .errorlist + textarea, p:has(> .errorlist) input, p:has(> .errorlist) select, p:has(> .errorlist) textarea { border-color: var(--danger); }
.field--error input:focus, .field--error select:focus, .field--error textarea:focus { box-shadow: 0 0 0 3px rgba(168, 36, 36, .22); }

.form { max-width: 760px; }
.form-page .form { margin: 0; }
.form > p, .card form > p, .field, .form-grid > p { display: flex; flex-direction: column; gap: 6px; margin: 0 0 var(--sp-4); min-width: 0; }
.form label, .card form label, .field label, .field__label, .filters label { color: var(--text); font-size: var(--fs-13); font-weight: 600; }
.field__label .req, label .req, .required-mark { color: var(--danger); margin-left: 2px; }
.helptext, .field__help, .form .helptext { color: var(--text-2); font-size: var(--fs-12); line-height: 1.4; }
.errorlist, .field__error { margin: 0; padding: 0; list-style: none; color: var(--danger); font-size: var(--fs-12); font-weight: 500; }
.errorlist li { margin: 0; display: flex; align-items: flex-start; gap: 6px; }
.errorlist.nonfield, .form > .errorlist:first-child { margin-bottom: var(--sp-4); padding: 10px 12px; border: 1px solid var(--danger-border); border-radius: var(--radius-sm); background: var(--danger-bg); font-size: var(--fs-13); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2) var(--sp-5); }
.form-grid .field, .form-grid > p { margin-bottom: var(--sp-3); }
.form-grid .field--full, .form-grid .span-2, .form-grid > p.span-2 { grid-column: 1 / -1; }
.form-section { padding-top: var(--sp-4); margin-top: var(--sp-4); border-top: 1px solid var(--border); }
.form-section > h2, .form-section__title { font-size: var(--fs-14); font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; margin-bottom: var(--sp-3); }
.checkbox, label.checkbox, .field--checkbox label, .filters .checkbox, .filters label.checkbox, .dropzone label.checkbox, .board-prefs label { display: flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; min-height: 24px; }
.form > p:has(> input[type="checkbox"]), .card form > p:has(> input[type="checkbox"]) { flex-direction: row; align-items: center; gap: 8px; }
.form > p:has(> input[type="checkbox"]) label, .card form > p:has(> input[type="checkbox"]) label { order: 2; font-weight: 500; }
.form > p:has(> input[type="checkbox"]) .helptext, .card form > p:has(> input[type="checkbox"]) .helptext { flex-basis: 100%; order: 3; margin-left: 26px; }
.choice-list, ul.choice-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.choice-list label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.input-group { display: flex; align-items: stretch; }
.input-group > input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group > .btn, .input-group > .button, .input-group > button { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; box-shadow: none; }
fieldset { margin: 0 0 var(--sp-4); padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
legend { padding: 0 6px; font-weight: 600; font-size: var(--fs-13); color: var(--text-2); }
form.card textarea, form.card input:not([type="checkbox"]):not([type="radio"]), form.card select { width: 100%; max-width: 100%; }

/* ---------------------------------------------------------------------------
   4. Filtros (.filters) y toolbar
   --------------------------------------------------------------------------- */
.filters, .toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3);
  margin: 0 0 var(--sp-4); padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm);
}
.toolbar { align-items: center; }
.toolbar__spacer { flex: 1; }
.filters label { display: flex; flex-direction: column; gap: 5px; flex: 1 1 180px; min-width: 0; max-width: 100%; color: var(--text-2); font-size: var(--fs-12); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.filters label.checkbox, .filters .checkbox { flex-direction: row; align-items: center; text-transform: none; letter-spacing: 0; font-size: var(--fs-13); min-height: var(--control-h); flex: 0 0 auto; }
.filters label > input, .filters label > select { text-transform: none; letter-spacing: 0; font-weight: 400; }
.filters input, .filters select { min-width: 0; }
.filters input[type="search"] { min-width: 180px; }
.filters button, .filters .button, .filters .btn { flex: none; }
.filters > .button:last-child, .filters > button:last-child { margin-left: auto; }
.filters--compact { padding: var(--sp-2) var(--sp-3); }
.filters .export-csv { margin-left: auto; }
.active-filters, .filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: calc(-1 * var(--sp-2)) 0 var(--sp-4); }
.active-filters .chip a, .filter-chips .chip a { color: inherit; display: inline-flex; margin-left: 4px; text-decoration: none; }
.saved-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--sp-3); }
.bulk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin: 0 0 var(--sp-3); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); background: var(--blue-50); border: 1px solid var(--blue-100); }

/* ---------------------------------------------------------------------------
   5. Tablas (table, .data-table, .table-scroll)
   --------------------------------------------------------------------------- */
.table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.table-scroll table { min-width: 100%; }
table { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; font-size: var(--fs-14); }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--surface-2); color: var(--text-2); font-size: var(--fs-12); font-weight: 600; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
thead th { position: sticky; top: 0; z-index: 1; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td { color: var(--text); }
td .meta { display: block; margin-top: 2px; }
th.num, td.num, th.text-right, td.text-right, th[data-num], td[data-num] { text-align: right; font-variant-numeric: tabular-nums; }
td.actions, th.actions, .row-actions { text-align: right; white-space: nowrap; }
.row-actions { display: inline-flex; gap: 4px; justify-content: flex-end; }
td.actions .button, td.actions .btn, .row-actions .button, .row-actions .btn { min-height: var(--control-h-sm); padding: 0 10px; font-size: var(--fs-13); }
tfoot th, tfoot td { background: var(--surface-2); font-weight: 600; color: var(--text); text-transform: none; letter-spacing: 0; font-size: var(--fs-13); border-top: 1px solid var(--border-strong); }
table .chip, table .badge { vertical-align: middle; }
table a { font-weight: 500; }
.data-table--compact th, .data-table--compact td, .board td, .board th { padding: 7px 10px; font-size: var(--fs-13); }
.board td, .board th { vertical-align: top; }
.table-empty td { padding: var(--sp-8) var(--sp-4); text-align: center; color: var(--text-2); }
tr.row--warning td, tr.row--warning { background: var(--warning-bg); }
tr.row--danger td { background: var(--danger-bg); }
tr.is-selected td { background: var(--blue-50); }
.material-summary th { white-space: nowrap; }
.clock-table td, .cert-grid td { vertical-align: middle; }
.cert-grid input[type="number"] { width: 7.5em; text-align: right; }
.cert-suggested { color: var(--blue-700); font-size: var(--fs-13); }

/* ---------------------------------------------------------------------------
   6. Cards, grids y listas
   --------------------------------------------------------------------------- */
.card { position: relative; margin: 0 0 var(--sp-5); padding: var(--sp-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow-wrap: anywhere; min-width: 0; }
.card > :last-child { margin-bottom: 0; }
/* Resaltado transitorio al llegar por hash (#id): se apaga solo, así no queda un anillo permanente
   cuando el hash apunta a una card dentro de una tab (los paneles usan el hash para la pestaña activa). */
.card:target { animation: card-target 2.4s ease-out 1 both; }
@keyframes card-target { 0%, 60% { outline: 2px solid var(--blue-600); outline-offset: 2px; } 100% { outline: 2px solid transparent; outline-offset: 2px; } }
@media (prefers-reduced-motion: reduce) { .card:target { animation: none; outline: 2px solid var(--blue-600); outline-offset: 2px; } .tabs__panel .card:target { outline: none; } }
.card--danger { border-left: 4px solid var(--danger); }
.card--warning { border-left: 4px solid var(--warning); }
.card--accent { border-left: 4px solid var(--accent); }
.card--center { text-align: center; }
.card--flat { box-shadow: none; }
.card--muted { background: var(--surface-2); }
.card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.card__header h2, .card__title { margin: 0; font-size: var(--fs-16); }
.card__footer { margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: flex-end; }
.card h2 { font-size: var(--fs-16); }
.card ul:not([class]) { margin: 0; padding-left: 18px; }
.card ul:not([class]) li { margin: 8px 0; line-height: 1.45; }
.card table { margin: 0; }
.card .filters { box-shadow: none; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-5); margin-bottom: var(--sp-5); }
.grid > .card, .grid .card { margin: 0; }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.card-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); }
.card-list > li, .card-list__item { padding: var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-list__item--link { display: block; text-decoration: none; color: inherit; }
.card-list__item--link:hover { border-color: var(--blue-600); }
.key-values, .dl-grid { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: var(--sp-4) 0 0; }
.key-values dt, .dl-grid dt { color: var(--text-2); font-size: var(--fs-13); }
.key-values dd, .dl-grid dd { margin: 0; font-weight: 500; min-width: 0; }
.timeline, .activity { list-style: none; padding: 0; margin: 0; }
.timeline li, .activity li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-13); }
.timeline li:last-child, .activity li:last-child { border-bottom: 0; }
.activity li { border-bottom-style: dashed; }
.timeline--dots li { position: relative; padding-left: 18px; }
.timeline--dots li::before { content: ""; position: absolute; left: 2px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue-500); }
.conversation, .attachment-list, .observation-list, .notice-list, .pending-list, .search-results ul, .report-list, .checklist, .setup-steps { list-style: none !important; margin: 0; padding: 0 !important; }
.conversation li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.conversation li:last-child { border-bottom: 0; }
.conversation li > span, .attachment-list li > span { display: block; margin-top: 4px; color: var(--text-2); font-size: var(--fs-12); }
.conversation li > div { margin-top: 8px; }
.conversation li.is-read { opacity: .72; }
.conversation details { margin-top: 6px; }
.attachment-list li { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.attachment-list li:last-child { border-bottom: 0; }
.observation-list > li { display: flex; justify-content: space-between; gap: var(--sp-4); padding: 14px 0; border-bottom: 1px solid var(--border); }
.observation-list > li:last-child { border-bottom: 0; }
.observation-list p { margin: 8px 0; }
.observation-response { margin-top: 10px; padding: 10px 12px; border-left: 3px solid var(--blue-600); background: var(--blue-50); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
details:not([class]) { margin-top: 6px; color: var(--text-2); font-size: var(--fs-13); }
details:not([class]) > summary { color: var(--blue-700); font-weight: 500; }
.inline-menu { display: inline-block; position: relative; }
.inline-menu summary { list-style: none; cursor: pointer; }
.inline-menu[open] > ul { position: absolute; right: 0; z-index: 20; min-width: 260px; margin: 4px 0 0; padding: 6px 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
.inline-menu ul li { margin: 0; }
.inline-menu ul li a { display: block; padding: 8px 14px; white-space: nowrap; text-decoration: none; color: var(--text); }
.inline-menu ul li a:hover { background: var(--surface-2); }
.doc-checklist details { display: inline-block; margin-left: 6px; }
.doc-checklist ul { margin: 6px 0 0 0; }
.upcoming-card { border-style: dashed; opacity: .85; }
.upcoming-preview { opacity: .55; pointer-events: none; }
.upcoming-skeleton { display: inline-block; width: 70%; height: .7em; border-radius: 4px; background: currentColor; opacity: .15; }

/* ---------------------------------------------------------------------------
   7. KPIs (.kpi, .metrics, .stat, .summary-grid)
   --------------------------------------------------------------------------- */
.kpi-grid, .metrics, .summary-grid, .report-kpis { display: grid; gap: var(--sp-3); margin: 0 0 var(--sp-5); }
.kpi-grid, .metrics { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.summary-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: var(--sp-3) 0; }
.board-section .summary-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.kpi, .metrics article, .metrics > a > article { position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: var(--sp-4) var(--sp-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow-wrap: anywhere; }
.kpi__label, .metrics span, .stat-label { order: -1; color: var(--text-2); font-size: var(--fs-12); font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.kpi__value, .metrics strong { display: block; color: var(--text); font-size: var(--fs-28); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.kpi__trend, .stat-note { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: var(--fs-12); }
.kpi__trend--up { color: var(--success); } .kpi__trend--down { color: var(--danger); }
.kpi--accent { border-top: 3px solid var(--accent); }
.kpi--accent .kpi__value { color: var(--accent); }
.kpi--danger, .metrics article.stat--danger { border-top: 3px solid var(--danger); }
.kpi--danger .kpi__value, .metrics article.stat--danger strong { color: var(--danger); }
.kpi--warning, .metrics article.stat--warning { border-top: 3px solid var(--warning); }
.kpi--warning .kpi__value, .metrics article.stat--warning strong { color: var(--warning); }
.kpi--success .kpi__value { color: var(--success); }
.kpi--sm .kpi__value { font-size: var(--fs-22); }
.kpi--link, .metric-link { display: block; text-decoration: none; color: inherit; }
.metric-link article { height: 100%; }
.metric-link:hover article, .kpi--link:hover { border-color: var(--blue-600); }
.metric-link article[aria-current="page"] { outline: 2px solid var(--blue-600); }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); overflow-wrap: anywhere; }
.stat-value { font-size: var(--fs-22); font-weight: 700; color: var(--text); line-height: 1.1; letter-spacing: -.01em; }
.stat-value--text { font-size: var(--fs-14); line-height: 1.3; }
.stat-label { order: 0; }
.stat--danger { background: var(--danger-bg); border-color: var(--danger-border); } .stat--danger .stat-value { color: var(--danger); }
.stat--warning { background: var(--warning-bg); border-color: var(--warning-border); } .stat--warning .stat-value { color: var(--warning); }
.stat--success { background: var(--success-bg); border-color: var(--success-border); } .stat--success .stat-value { color: var(--success); }
.stat--active { outline: 2px solid var(--blue-600); }
a.stat { text-decoration: none; color: inherit; } a.stat:hover { border-color: var(--blue-600); }
.summary-grid--compact .stat { padding: 6px 10px; } .summary-grid--compact .stat-value { font-size: var(--fs-16); }
.board-focus { border-color: var(--blue-600); }

/* ---------------------------------------------------------------------------
   8. Chips / badges / etiquetas de estado
   --------------------------------------------------------------------------- */
.chip, .badge, .count, .role-tag--chip { display: inline-flex; align-items: center; gap: 4px; min-height: 22px; padding: 2px 9px; border-radius: var(--radius-pill); background: var(--blue-50); color: var(--blue-800); font-size: var(--fs-12); font-weight: 600; line-height: 1.2; white-space: nowrap; vertical-align: middle; }
.chip .icon, .badge .icon { width: 14px; height: 14px; }
.chip--neutral, .badge--neutral { background: var(--neutral-bg); color: var(--neutral); }
.chip--success, .badge--success { background: var(--success-bg); color: var(--success); }
.chip--warning, .badge--warning { background: var(--warning-bg); color: var(--warning); }
.chip--danger, .badge--danger { background: var(--danger-bg); color: var(--danger); }
.chip--info, .badge--info { background: var(--info-bg); color: var(--info); }
.chip--accent, .badge--accent { background: var(--orange-100); color: var(--orange-600); }
.chip--outline, .badge--outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); }
.chip--lg { min-height: 28px; padding: 4px 12px; font-size: var(--fs-13); }
.chip--dot::before, .badge--dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-count, .badge--count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-pill); background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 1; }
.count { min-width: 34px; justify-content: center; background: var(--neutral-bg); color: var(--text); font-size: var(--fs-13); }
.count--warning { background: var(--warning-bg); color: var(--warning); } .count--danger { background: var(--danger-bg); color: var(--danger); }
.category-tabs a .chip { margin-left: 4px; }
.light, .panel-lights a { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface); text-decoration: none; font-size: var(--fs-13); color: var(--text); }
.light::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--text-3); }
.light--danger::before { background: var(--danger); } .light--warning::before { background: var(--warning); } .light--success::before { background: var(--success); }
.panel-lights { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--blue-100); color: var(--blue-800); font-size: var(--fs-12); font-weight: 700; letter-spacing: .02em; text-transform: uppercase; flex: none; }
.avatar--lg { width: 44px; height: 44px; font-size: var(--fs-14); }

/* ---------------------------------------------------------------------------
   9. Alertas / mensajes (.message, .alert) y toasts
   --------------------------------------------------------------------------- */
.message, .alert { position: relative; display: flex; align-items: flex-start; gap: 10px; margin: 0 0 var(--sp-4); padding: 12px 14px; border: 1px solid var(--info-border); border-left-width: 4px; border-radius: var(--radius-sm); background: var(--info-bg); color: var(--text); font-size: var(--fs-14); box-shadow: var(--shadow-sm); }
.message > .icon, .alert > .icon { flex: none; margin-top: 1px; color: var(--info); }
.message__body, .alert__body { flex: 1; min-width: 0; }
.message__title, .alert__title { display: block; font-weight: 600; margin-bottom: 2px; }
.message--success, .alert--success { background: var(--success-bg); border-color: var(--success-border); border-left-color: var(--success); } .message--success > .icon { color: var(--success); }
.message--error, .message--danger, .alert--error, .alert--danger { background: var(--danger-bg); border-color: var(--danger-border); border-left-color: var(--danger); } .message--error > .icon, .message--danger > .icon { color: var(--danger); }
.message--warning, .alert--warning { background: var(--warning-bg); border-color: var(--warning-border); border-left-color: var(--warning); } .message--warning > .icon { color: var(--warning); }
.message--info, .alert--info { background: var(--info-bg); border-color: var(--info-border); border-left-color: var(--info); }
.message--neutral, .alert--neutral { background: var(--neutral-bg); border-color: var(--neutral-border); border-left-color: var(--neutral); } .message--neutral > .icon { color: var(--neutral); }
.message__close, .toast__close { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin: -4px -6px -4px 0; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); cursor: pointer; }
.message__close:hover, .toast__close:hover { background: rgba(0, 0, 0, .06); color: var(--text); }
.messages, .toasts { display: grid; gap: var(--sp-2); margin: 0 0 var(--sp-4); }
.messages:empty { display: none; }
.toast { animation: toast-in var(--t-base) both; }
.toast.is-leaving { opacity: 0; transform: translateY(-4px); transition: opacity var(--t-base), transform var(--t-base); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.callout, .help-content blockquote { margin: var(--sp-3) 0; padding: 10px 14px; border-left: 4px solid var(--blue-600); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--blue-50); color: var(--text); }

/* ---------------------------------------------------------------------------
   10. Empty states
   --------------------------------------------------------------------------- */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: var(--sp-8) var(--sp-5); color: var(--text-2); text-align: center; }
.empty-state .icon, .empty-state__icon { width: 40px; height: 40px; color: var(--text-3); margin-bottom: 4px; }
.empty-state h2, .empty-state h3, .empty-state__title { margin: 0; color: var(--text); font-size: var(--fs-16); }
.empty-state p { margin: 0; max-width: 46ch; }
.empty-state a { font-weight: 600; }
.empty-state .button, .empty-state .btn, .empty-state__action { margin-top: var(--sp-3); }
li.empty-state, td.empty-state { display: block; padding: var(--sp-3) 0; text-align: left; align-items: flex-start; }
li.empty-state { list-style: none; margin-left: -18px; }
td.empty-state { display: table-cell; text-align: center; padding: var(--sp-6) var(--sp-4); }
.card.empty-state { padding: var(--sp-10) var(--sp-6); }
.card.empty-state h1 { font-size: var(--fs-22); color: var(--text); }

/* ---------------------------------------------------------------------------
   11. Paginación y breadcrumbs
   --------------------------------------------------------------------------- */
.pagination { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); margin-top: var(--sp-4); color: var(--text-2); font-size: var(--fs-13); }
.pagination span:first-child { margin-right: auto; }
.pagination a, .pagination .page-link { display: inline-flex; align-items: center; justify-content: center; min-height: var(--control-h-sm); padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-weight: 500; text-decoration: none; box-shadow: var(--shadow-sm); }
.pagination a:hover { border-color: var(--text-3); background: var(--surface-2); }
.pagination [aria-current="page"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; margin: 0 0 var(--sp-3); color: var(--text-2); font-size: var(--fs-13); }
.breadcrumbs a { color: var(--text-2); text-decoration: none; }
.breadcrumbs a:hover { color: var(--brand); text-decoration: underline; }
.breadcrumbs [aria-current="page"] { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40ch; }
.breadcrumbs .icon, .breadcrumbs__sep { color: var(--text-3); width: 16px; height: 16px; flex: none; }

/* ---------------------------------------------------------------------------
   12. Tabs (.tabs ARIA, .section-tabs, .category-tabs)
   --------------------------------------------------------------------------- */
.tabs { margin: 0 0 var(--sp-5); }
.tabs__list, .section-tabs, .category-tabs { display: flex; gap: 2px; margin: 0 0 var(--sp-5); padding: 0; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; list-style: none; }
.tabs__list::-webkit-scrollbar, .section-tabs::-webkit-scrollbar { display: none; }
.tabs__tab, .section-tabs a, .category-tabs a { position: relative; display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: var(--control-h); padding: 0 14px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--text-2); font-size: var(--fs-14); font-weight: 500; text-decoration: none; white-space: nowrap; cursor: pointer; transition: color var(--t-fast), border-color var(--t-fast); }
.tabs__tab:hover, .section-tabs a:hover, .category-tabs a:hover { color: var(--text); background: none; border-bottom-color: var(--border-strong); }
.tabs__tab[aria-selected="true"], .section-tabs a[aria-current="page"], .category-tabs a[aria-current="page"], .section-tabs a.is-active, .category-tabs a.is-active { color: var(--brand); border-bottom-color: var(--accent); font-weight: 600; }
.tabs__tab:focus-visible { outline-offset: -3px; }
.tabs__panel[hidden] { display: none; }
.tabs__panel { animation: fade-in var(--t-base); }
.tabs__panel, .tabs__panel [id] { scroll-margin-top: calc(var(--topbar-height) + 64px); } /* el hash de la URL activa la pestaña y desplaza hasta el ancla */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.tabs--pills .tabs__list { border: 0; gap: 6px; }
.tabs--pills .tabs__tab { min-height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-pill); }
.tabs--pills .tabs__tab[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------------------------------------------------------------------------
   13. Dropdown (details.dropdown) y dialog
   --------------------------------------------------------------------------- */
.dropdown { position: relative; display: inline-block; }
.dropdown > summary { display: inline-flex; align-items: center; gap: 6px; list-style: none; cursor: pointer; }
.dropdown__menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 220px; margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xl); animation: fade-in var(--t-fast); }
.dropdown--left .dropdown__menu { right: auto; left: 0; }
.dropdown--up .dropdown__menu { top: auto; bottom: calc(100% + 6px); }
.dropdown__item, .dropdown__menu a, .dropdown__menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 8px 10px; border: 0; border-radius: 6px; background: none; box-shadow: none; color: var(--text); font-size: var(--fs-14); font-weight: 500; text-align: left; text-decoration: none; cursor: pointer; }
.dropdown__item:hover, .dropdown__menu a:hover, .dropdown__menu button:hover { background: var(--surface-3); color: var(--text); border: 0; }
.dropdown__item .icon { color: var(--text-2); }
.dropdown__item--danger, .dropdown__menu .danger { color: var(--danger); } .dropdown__item--danger .icon { color: var(--danger); }
.dropdown__sep { height: 1px; margin: 6px 4px; background: var(--border); }
.dropdown__menu li { margin: 0; }
dialog.dialog, .dialog { width: min(100% - 32px, 560px); padding: 0; border: 0; border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-xl); }
dialog.dialog::backdrop { background: rgba(13, 42, 71, .45); backdrop-filter: blur(2px); }
.dialog__header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) 0; }
.dialog__header h2 { margin: 0; font-size: var(--fs-18); }
.dialog__body { padding: var(--sp-4) var(--sp-5); }
.dialog__footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); padding: 0 var(--sp-5) var(--sp-5); }
.dialog--sm { width: min(100% - 32px, 420px); }

/* ---------------------------------------------------------------------------
   14. Búsqueda global (resultados), reportes, charts, avisos, ayuda, inicio
   --------------------------------------------------------------------------- */
.search-results .card h2 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.search-results .card h2 a { font-size: var(--fs-13); font-weight: 500; }
.search-results li { padding: 9px 0; border-top: 1px solid var(--border); margin: 0; }
.search-results li:first-child { border-top: 0; }
.search-results li .meta { display: block; margin-top: 2px; }
.report-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.report-list li { margin: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.report-list li a { text-decoration: none; font-weight: 600; }
.report-kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.charts { margin-bottom: 6px; }
.chart-card h2 { margin: 0 0 8px; }
.chart { display: block; width: 100%; height: auto; max-height: 280px; }
.chart--curve { max-height: 300px; }
.chart-grid { stroke: var(--border); stroke-width: 1; } .chart-zero { stroke: var(--text-3); stroke-width: 1; }
.chart-axis { fill: var(--text-2); font-size: 11px; } .chart-label { fill: var(--text-2); font-size: 11px; } .chart-value { fill: var(--text); font-size: 11px; font-weight: 700; }
.chart-bar { fill: var(--blue-600); } .chart-bar:hover { fill: var(--blue-800); }
.chart-line { fill: none; stroke: var(--blue-600); stroke-width: 2.5; stroke-linejoin: round; }
.chart-dot { fill: #fff; stroke: var(--blue-600); stroke-width: 2.5; }
.chart-line--planned { stroke: var(--text-3); stroke-width: 2; }
.board-prefs summary { cursor: pointer; color: var(--blue-700); font-weight: 600; }
.board-prefs ol { margin: 10px 0 0; padding-left: 20px; columns: 2; gap: 24px; }
.board-prefs li { margin: 6px 0; break-inside: avoid; }
.board-prefs input[type="number"] { width: 64px; min-height: 32px; padding: 4px 6px; }
.notice-day { margin: var(--sp-4) 0 6px; color: var(--text-2); font-size: var(--fs-12); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.notice-list li { margin: 0; padding: 10px 0 10px 12px; border-top: 1px solid var(--border); border-left: 3px solid transparent; }
.notice-list li:first-child { border-top: 0; }
.notice--unread { border-left-color: var(--accent) !important; background: var(--orange-50); }
.help-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--sp-5); align-items: start; }
.help-layout .card { margin: 0; }
.help-nav ul { list-style: none; margin: 0; padding: 0; } .help-nav li { margin: 2px 0; }
.help-nav a { display: block; padding: 6px 8px; border-radius: 6px; text-decoration: none; color: var(--text); }
.help-nav a:hover, .help-nav a[aria-current="page"] { background: var(--blue-50); color: var(--brand); }
.help-nav small { display: block; margin: 12px 0 4px; color: var(--text-2); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: var(--fs-12); }
.help-content h1 { font-size: var(--fs-22); } .help-content h2 { margin-top: var(--sp-6); font-size: var(--fs-18); } .help-content h3 { margin-top: var(--sp-4); font-size: var(--fs-16); }
.help-content table { margin: 10px 0; } .help-content p { margin-bottom: var(--sp-3); } .help-content ul { margin-bottom: var(--sp-3); }
.help-toc { font-size: var(--fs-13); } .help-toc a { display: block; padding: 3px 0; } .help-toc .toc-sub { padding-left: 12px; }
.role-home { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: var(--sp-5); margin-bottom: var(--sp-5); }
.role-home .card { margin: 0; }
.role-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: var(--sp-2); }
.role-actions a { display: grid; gap: 3px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); text-decoration: none; color: var(--text); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.role-actions a:hover, .role-actions a:focus-visible { border-color: var(--blue-600); box-shadow: var(--shadow-sm); }
.role-actions a strong { font-size: var(--fs-14); font-weight: 600; } .role-actions a span { color: var(--text-2); font-size: var(--fs-12); }
.role-actions a.primary-action { background: var(--brand); border-color: var(--brand); color: #fff; } .role-actions a.primary-action span { color: var(--blue-100); }
.role-actions a.primary-action:hover { background: var(--brand-hover); }
.pending-list { margin-top: var(--sp-2); }
.pending-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0; padding: 9px 0; border-top: 1px solid var(--border); }
.pending-list li:first-child { border-top: 0; }
.pending-list li a { font-weight: 500; color: var(--text); }
.pending-list .all-clear, .all-clear { color: var(--success); font-weight: 500; }
.welcome { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.welcome__greeting { color: var(--text-2); font-size: var(--fs-14); margin: 0 0 2px; }
.welcome h1 { margin: 0; }
.dashboard-grid .title-row { margin-bottom: 10px; } .dashboard-grid .title-row h2 { margin: 0; }
.dashboard-grid .title-row a { font-size: var(--fs-13); white-space: nowrap; } .dashboard-grid li .meta { display: inline-block; margin-top: 3px; }

/* ---------------------------------------------------------------------------
   15. Módulos existentes: portal de campo, evidencias, documentos, materiales
   (estilos heredados, armonizados con los tokens; no rediseñan la pantalla)
   --------------------------------------------------------------------------- */
.evidence-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 8px 0; }
.evidence-grid figure { margin: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.evidence-grid img { display: block; width: 100%; height: 120px; object-fit: cover; }
.evidence-grid figcaption { padding: 6px 8px; font-size: var(--fs-12); color: var(--text-2); }
.evidence-grid--discarded figure { opacity: .6; filter: grayscale(.6); }
.checklist > li { margin: 0 0 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.checklist .done { border-left: 4px solid var(--success); } .checklist .missing { border-left: 4px solid var(--warning); }
.checklist-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.field-task { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 56px; margin-bottom: 8px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); text-decoration: none; color: inherit; }
.field-task:active { transform: scale(.99); }
.field-task--done { opacity: .75; } .field-task--progress { border-color: var(--warning-border); background: var(--warning-bg); }
.field-task--rejected, .field-task--blocked { border-color: var(--danger-border); background: var(--danger-bg); }
.element-complete { border-left: 4px solid var(--success); }
.field-head h1 { margin-bottom: 2px; } .field-summary { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 4px; }
.field-element { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 14px 0 6px; font-size: var(--fs-16); }
.field-status { font-size: var(--fs-16); padding: 14px 16px; border-left: 5px solid var(--neutral); }
.field-status--missing { border-left-color: var(--warning); background: var(--warning-bg); } .field-status--ready, .field-status--done { border-left-color: var(--success); } .field-status--ready { background: var(--success-bg); } .field-status--rejected { border-left-color: var(--danger); background: var(--danger-bg); }
.field-notes { white-space: pre-wrap; }
.field-date summary, .setup-checklist summary { cursor: pointer; min-height: var(--touch); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field-upload input[type="file"] { font-size: var(--fs-16); padding: 10px 0; width: 100%; }
.field-upload button, .field-submit button, .field-start button { width: 100%; min-height: 52px; font-size: var(--fs-16); }
.field-start button, .field-submit button { min-height: 56px; font-size: var(--fs-18); }
.field-upload label.button { display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; width: 100%; min-height: 56px; margin: 6px 0 0; font-size: var(--fs-16); cursor: pointer; }
.field-upload label.button input[type="file"] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.field-upload-fallback { display: none; } .no-js .field-upload-fallback { display: block; width: 100%; min-height: 48px; }
.field-upload.is-busy label.button { opacity: .6; pointer-events: none; } .field-upload.is-busy label.button span::after { content: " · subiendo…"; }
.field-submit button[disabled] { opacity: .5; }
.field-order { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; margin-right: 4px; border-radius: 50%; background: var(--brand); color: #fff; font-size: var(--fs-12); font-weight: 600; }
.field-progress { width: 100%; height: 6px; margin: 0 0 8px; }
.field-upload-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } .field-upload-row .field-upload label.button { min-height: 52px; }
.field-block summary { cursor: pointer; color: var(--danger); }
.setup-checklist--pending { border-left: 4px solid var(--warning); } .setup-checklist--ready { border-left: 4px solid var(--success); }
.setup-steps { margin: 12px 0 0; }
.setup-steps li { display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; align-items: center; margin: 0; padding: 10px 0; border-top: 1px solid var(--border); }
.setup-steps li.is-done { opacity: .8; } .setup-steps li.is-missing .setup-mark { color: var(--warning); font-weight: 700; } .setup-steps li.is-done .setup-mark { color: var(--success); font-weight: 700; }
.setup-actions { justify-content: flex-end; }
.doc-sections { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin-top: 10px; }
.doc-section { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.doc-section--active { border-color: var(--brand); box-shadow: 0 0 0 2px var(--blue-100); }
.doc-section h3 { display: flex; justify-content: space-between; align-items: center; margin: 0 0 8px; }
.dropzone { margin: 0 0 10px; }
.dropzone-target { position: relative; display: flex; align-items: center; justify-content: center; min-height: 72px; padding: 10px; border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; text-align: center; color: var(--text-2); }
.dropzone-target input[type="file"] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.dropzone.is-dragover .dropzone-target { border-color: var(--brand); background: var(--blue-50); } .dropzone.is-busy .dropzone-target { opacity: .6; } .dropzone.is-busy .dropzone-text::after { content: " · subiendo…"; }
.dropzone label.checkbox { margin: 6px 0 0; font-size: var(--fs-13); }
.material-sheet { display: flex; gap: var(--sp-4); align-items: flex-start; flex-wrap: wrap; }
.material-photo { width: 180px; height: 180px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }
.material-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; vertical-align: middle; border: 1px solid var(--border); }
.ticket-heading > div:last-child { align-self: flex-start; }
.doc-preview { max-width: 100%; max-height: 70vh; border: 1px solid var(--border); border-radius: var(--radius); }
.doc-preview--frame { width: 100%; height: 70vh; }
.photo-preview { max-width: 100%; max-height: 360px; border-radius: var(--radius-sm); }
.code-secret { font-size: var(--fs-22); user-select: all; }
.input--amount { width: 9rem; text-align: right; }
.qr-image { display: block; max-width: 220px; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; background: #fff; }

/* ---------------------------------------------------------------------------
   16. Responsive de componentes
   --------------------------------------------------------------------------- */
@media (max-width: 980px) {
  .grid--3, .grid--sidebar, .help-layout, .role-home { grid-template-columns: minmax(0, 1fr); }
  .board-prefs ol { columns: 1; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 680px) {
  :root { --control-h: 44px; }
  .btn, .button, :where(button) { white-space: normal; text-align: center; max-width: 100%; }
  .inline-form, form.inline { max-width: 100%; }
  .page-header, .title-row, .card .title-row { flex-direction: column; align-items: stretch; gap: var(--sp-3); }
  .card .title-row { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  .page-header__actions, .title-row > div:last-child:not(:first-child) { justify-content: flex-start; }
  .page-header__actions .button, .page-header__actions .btn, .title-row > div:last-child:not(:first-child) .button { flex: 1 1 auto; }
  h1 { font-size: var(--fs-22); }
  .card { padding: var(--sp-4); margin-bottom: var(--sp-4); }
  .grid { grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); }
  .kpi-grid, .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi, .metrics article { padding: var(--sp-3) var(--sp-4); }
  .kpi__value, .metrics strong { font-size: var(--fs-22); }
  .filters label { flex-basis: 100%; }
  .filters > .button:last-child, .filters > button:last-child, .filters .export-csv { margin-left: 0; }
  .filters button, .filters .button { flex: 1 1 auto; }
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px; }
  .app-main table:not(.table-scroll table) { display: block; max-width: 100%; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .app-main table:not(.table-scroll table) td { white-space: normal; min-width: 90px; }
  .card table td:first-child { min-width: 160px; }
  [data-page="stock-movement-list"] .card table td:nth-child(3) { min-width: 220px; }
  .table-scroll table { display: table; white-space: normal; }
  thead th { position: static; }
  .pagination { justify-content: center; } .pagination span:first-child { flex-basis: 100%; text-align: center; margin: 0; }
  .key-values, .dl-grid { grid-template-columns: 1fr; gap: 2px; } .key-values dd, .dl-grid dd { margin-bottom: 8px; }
  .observation-list > li { flex-direction: column; } .observation-list > li .button { align-self: flex-start; }
  .setup-steps li { grid-template-columns: 24px 1fr; } .setup-actions { grid-column: 2; justify-content: flex-start; }
  .section-tabs, .tabs__list, .category-tabs { margin-left: calc(-1 * var(--sp-4)); margin-right: calc(-1 * var(--sp-4)); padding: 0 var(--sp-4); }
  .dialog__header, .dialog__body, .dialog__footer { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .form-actions .button, .form-actions .btn, .form-actions button { flex: 1 1 auto; }
  .empty-state { padding: var(--sp-6) var(--sp-3); }
}
@media (max-width: 360px) { .kpi-grid, .metrics { grid-template-columns: 1fr; } }

/* 17. Complementos (ola v5, bloque 4: formularios renderizados con {% form_fields %}) ---- */
.field__required { color: var(--danger); font-weight: 700; margin-left: 2px; }
.form-grid--1 { grid-template-columns: minmax(0, 1fr); }
.field--checkbox { justify-content: center; }
.field--checkbox .helptext { margin-left: 26px; }
.field .errorlist { margin: 0; padding: 0; list-style: none; color: var(--danger); font-size: var(--fs-12); }
form.is-submitting .btn, form.is-submitting .button, form.is-submitting button[type="submit"] { opacity: .6; pointer-events: none; }
button[aria-busy="true"] .btn__busy, .btn[aria-busy="true"] .btn__busy { display: inline; }
.btn__busy { display: none; }
/* Bug: un .visually-hidden (position:absolute) dentro de una tabla escapaba del recorte de .table-scroll y generaba scroll horizontal en móvil. */
.table-scroll { position: relative; }

/* Leyenda discreta «Registro operativo, no contable» (finance / certificaciones) */
.ops-note { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 var(--sp-5); padding: 8px 12px; border: 1px solid var(--border); border-left: 3px solid var(--neutral); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-2); font-size: var(--fs-12); line-height: 1.45; }
.ops-note .icon { flex: none; color: var(--text-3); margin-top: 1px; }
.ops-note strong { color: var(--text); font-weight: 600; }

/* Stepper (cadena presupuesto → certificado → factura → cobros) */
.stepper { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--sp-2); margin: 0 0 var(--sp-5); padding: 0; list-style: none; counter-reset: step; }
.stepper__step { position: relative; display: grid; gap: 4px; padding: var(--sp-3) var(--sp-4) var(--sp-3) 44px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.stepper__step::before { counter-increment: step; content: counter(step); position: absolute; left: 12px; top: 14px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-size: var(--fs-12); font-weight: 700; }
.stepper__step--done { border-color: var(--success-border); }
.stepper__step--done::before { content: "✓"; border-color: var(--success); background: var(--success); color: #fff; }
.stepper__step--current { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.stepper__step--current::before { border-color: var(--brand); background: var(--brand); color: #fff; }
.stepper__step--danger { border-color: var(--danger-border); background: var(--danger-bg); }
.stepper__step--danger::before { border-color: var(--danger); color: var(--danger); }
.stepper__step--muted { background: var(--surface-2); color: var(--text-3); }
.stepper__label { font-size: var(--fs-12); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-2); }
.stepper__value { font-size: var(--fs-16); font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stepper__meta { font-size: var(--fs-12); color: var(--text-2); overflow-wrap: anywhere; }
.stepper__meta a { color: inherit; text-decoration: underline; }
@media (max-width: 980px) { .stepper { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 680px) { .stepper { grid-template-columns: 1fr; } }

/* Encabezado de detalle con número / estado / importe */
.detail-head__title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.detail-head__title h1 { margin: 0; }
.detail-head__amount { font-size: var(--fs-22); font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Título de sección con acciones a la derecha (cards de detalle) */
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.section-head h2 { margin: 0; display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section-head .meta { flex-basis: 100%; margin: -6px 0 0; }
.section-head__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

