:root {
  /* Interfaz v2 (02-12-2026): mismas variables que antes con la paleta
     nueva (barra oscura + acento de la sociedad); todas las pantallas
     heredan el cambio sin tocar su plantilla. */
  --ink: #1b2026;
  --ink-soft: #6b7480;
  --paper: #f4f5f7;
  --paper-dim: #eef0f3;
  --panel: #ffffff;
  --line: #e3e6ea;
  --accent: #d0021b;
  --accent-strong: #a80016;
  --accent-soft: #fbe7ea;
  --accent-fg: #ffffff;
  --danger: #c0352b;
  --danger-bg: #fbe9e7;
  --success: #22804a;
  --success-bg: #e5f4ea;
  --warning: #b26a00;
  --warning-bg: #fdf1dd;
  --info: #2d6cdf;
  --info-bg: #e8effc;
  --bar: #1f252b;
  --bar-fg: #e9edf1;
  --bar-muted: #9aa4ae;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --head: "Space Grotesk", "Inter", system-ui, -apple-system, sans-serif;
  --radius-sm: 6px;
  --radius-md: 9px;
  --radius-lg: 14px;
  --topbar-height: 56px;
  --mobile-nav-height: 62px;
}
/* Caramel: acento provisional hasta que José elija el definitivo. */
body[data-co="caramel"] { --accent: #8a5a3c; --accent-strong: #6e4730; --accent-soft: #f3ebe5; }

/* Objetivos táctiles minimos (Tarea 061) -- WCAG 2.5.5/2.5.8 recomienda
   44x24px como minimo real, no solo como sugerencia visual. */
:root { --tap-min: 44px; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

.page { max-width: 1000px; margin: 0 auto; padding: 32px 20px 80px; }

header.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 1px 3px rgba(30, 42, 56, 0.04);
  position: sticky;
  top: 0;
  z-index: 10;
}

header.topbar .brand { font-weight: 700; letter-spacing: -0.01em; color: var(--accent-strong); }
header.topbar a { color: var(--ink-soft); text-decoration: none; font-size: 14px; }
header.topbar a:hover { color: var(--ink); }

/* Armazón antiguo (barra lateral, Tarea 061) retirado en la interfaz v2: ver el final del fichero. */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 32px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 8px 24px -12px rgba(30, 42, 56, 0.18);
}

.login-card h1 { font-size: 20px; margin: 0 0 24px; }

label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }

input[type="email"], input[type="password"], input[type="text"] {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 15px;
  margin-bottom: 16px;
}

button, .btn {
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 10px 16px;
  font-size: 15px;
  cursor: pointer;
  width: 100%;
  transition: background 0.12s ease;
}

button:hover, .btn:hover { background: var(--accent-strong); }

.btn-secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-secondary:hover { background: var(--paper-dim); }

/* Acciones de factura: una sola columna estable, sin depender de estilos
   inline. En móvil cada acción conserva el ancho completo y el texto se
   parte dentro del botón, nunca fuera de la tarjeta. */
.invoice-action-menu {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
  min-width: 0;
}
.invoice-action-menu .btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
  text-decoration: none;
}
.email-delivery-page { max-width: 760px; }
.email-delivery-page input[type="text"],
.email-delivery-page textarea { width: 100%; box-sizing: border-box; }
.email-delivery-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 12px 16px;
  margin-bottom: 14px;
}
.email-delivery-summary p { margin: 6px 0; overflow-wrap: anywhere; }
.email-delivery-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.email-delivery-actions .btn { width: auto; }

@media (max-width: 480px) {
  .email-delivery-actions { display: grid; grid-template-columns: 1fr; }
  .email-delivery-actions .btn { width: 100%; box-sizing: border-box; }
}
input[type="email"]:focus, input[type="password"]:focus, input[type="text"]:focus,
input[type="date"]:focus, input[type="file"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(156, 122, 68, 0.15);
}

.error { color: var(--danger); font-size: 14px; margin-bottom: 12px; }

.company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.company-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(30, 42, 56, 0.05);
  transition: box-shadow 0.15s ease;
}
.company-card:hover { box-shadow: 0 4px 14px -6px rgba(30, 42, 56, 0.14); }

.company-card h3 { margin: 0 0 4px; font-size: 16px; }
.company-card .nif { color: var(--ink-soft); font-size: 13px; margin-bottom: 12px; }
.company-card .placeholder { color: var(--ink-soft); font-size: 13px; }

.iva-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.iva-row { display: flex; justify-content: space-between; }
.iva-row.iva-saldo {
  font-weight: 700;
  border-top: 1px solid var(--line);
  padding-top: 4px;
  margin-top: 2px;
}

.deadline-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.deadline-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 1px 2px rgba(30, 42, 56, 0.04);
}

.deadline-row.urgent {
  border-color: var(--danger);
  background: #fdf3f0;
}

.deadline-days {
  font-weight: 700;
  font-size: 15px;
  min-width: 52px;
  text-align: center;
  color: var(--ink-soft);
}

.deadline-row.urgent .deadline-days { color: var(--danger); }

.deadline-title { font-size: 14.5px; font-weight: 600; }
.deadline-sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

.page-narrow { max-width: 460px; }

select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 15px;
  margin-bottom: 16px;
  background: #fff;
}

.success {
  color: #2f6b3a;
  background: #eef7ef;
  border: 1px solid #cfe8d3;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 14px;
  margin-bottom: 16px;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 16px;
  box-shadow: 0 1px 2px rgba(30, 42, 56, 0.04);
}

table { border-collapse: collapse; width: 100%; }
tbody tr:hover td { background: var(--paper-dim); }

thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  padding: 10px 14px;
  background: var(--paper-dim);
  border-bottom: 1px solid var(--line);
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
}

tbody tr:last-child td { border-bottom: none; }

.nowrap { white-space: nowrap; }

.review-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.review-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  flex-wrap: wrap;
  box-shadow: 0 1px 2px rgba(30, 42, 56, 0.04);
}

.review-form { display: flex; gap: 8px; }
.review-form select { margin-bottom: 0; min-width: 200px; }
.review-form button { width: auto; padding: 8px 14px; white-space: nowrap; }

/* Escritorio principal -- Tarea 061 (2026-07-31) */

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 18px 0 28px;
}

.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 84px;
  padding: 14px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  color: var(--ink);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 1px 2px rgba(30, 42, 56, 0.04);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.quick-action .icon { font-size: 22px; }
.quick-action:hover { box-shadow: 0 4px 14px -6px rgba(30, 42, 56, 0.18); border-color: var(--accent); }
.quick-action.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.quick-action.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.notice-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 28px; }
.notice-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--info-bg);
  border: 1px solid #cfe0f0;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14.5px;
  min-height: var(--tap-min);
}
a.notice-row:hover { filter: brightness(0.98); }
.notice-row .notice-icon { font-size: 18px; flex: none; }
.notice-row.notice-urgent { background: var(--warning-bg); border-color: #f0d9a8; }

.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 24px 0 32px;
}

.actions-group {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.actions-group h4 {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.action-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  margin: 0 0 4px;
  border-radius: 5px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14.5px;
  transition: background 0.12s ease;
}

.action-link:last-child { margin-bottom: 0; }
.action-link:hover { background: var(--paper-dim); }

.action-link.primary {
  background: var(--ink);
  color: #fff;
  font-weight: 600;
}
.action-link.primary:hover { background: var(--accent-strong); }

.action-link.badge .count {
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  padding: 1px 8px;
  line-height: 1.5;
}

h2 { letter-spacing: -0.01em; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 6px;
}
.back-link:hover { color: var(--accent-strong); }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.page-head h2 { margin: 4px 0 0; }
.page-head .page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-head .page-head-actions .btn { width: auto; }

/* Tarea urgente (2026-08-05, Parte A): barra de seleccion exacta de
   facturas -- independiente de .export-bar (que exporta el listado
   filtrado completo, sin cambios). */
.seleccion-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 16px; margin: 0 0 16px;
}
.seleccion-bar form { display: contents; }
.seleccion-bar .btn { width: auto; }
.seleccion-bar .btn:disabled { opacity: 0.5; cursor: not-allowed; }

.export-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 20px; }
.export-bar .btn {
  width: auto;
  display: inline-block;
  padding: 8px 14px;
  font-size: 13.5px;
  text-decoration: none;
}
.export-bar .btn-secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.export-bar .btn-secondary:hover { background: var(--paper-dim); }

.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 4px;
  box-shadow: 0 1px 2px rgba(30, 42, 56, 0.04);
}

.filter-field { min-width: 160px; }
.filter-field label { margin-bottom: 4px; }
.filter-field input[type="text"],
.filter-field input[type="date"] { margin-bottom: 0; width: 100%; }

.filter-actions {
  display: flex;
  gap: 8px;
  min-width: auto;
  align-items: center;
}
.filter-actions button {
  width: auto;
  padding: 9px 16px;
}
.filter-actions .btn {
  width: auto;
  display: inline-block;
  padding: 9px 14px;
  font-size: 14px;
  text-decoration: none;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.filter-actions .btn:hover { background: var(--paper-dim); }

.results-meta {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 10px 0 0;
}

.sort-link {
  color: inherit;
  text-decoration: none;
  display: inline-block;
}
.sort-link:hover { color: var(--accent-strong); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}
.pagination .btn {
  width: auto;
  display: inline-block;
  padding: 8px 16px;
  font-size: 14px;
  text-decoration: none;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.pagination .btn:hover { background: var(--paper-dim); }
.pagination-label { font-size: 13.5px; color: var(--ink-soft); }

.print-only { display: none; }

/* Captura movil de facturas/tickets -- Tarea 050 (2026-07-30) */

.capture-shell { max-width: 480px; margin: 0 auto; }

.capture-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 14px;
}
.capture-status .pill {
  background: var(--paper-dim);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12.5px;
  font-weight: 600;
}

.capture-actions { display: flex; flex-direction: column; gap: 12px; margin: 20px 0; }

.btn-big {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 64px;
  font-size: 17px;
  font-weight: 700;
  border-radius: 10px;
  border: none;
  cursor: pointer;
}
.btn-big.btn-camera { background: var(--accent); color: #fff; }
.btn-big.btn-camera:hover { background: var(--accent-strong); }
.btn-big.btn-choose { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.btn-big.btn-choose:hover { background: var(--paper-dim); }
.btn-big:disabled { opacity: 0.55; cursor: not-allowed; }

.capture-preview {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin: 16px 0;
}
.capture-preview img { width: 100%; border-radius: 6px; display: block; }
.capture-preview .file-chip {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; color: var(--ink-soft);
}
.capture-preview .preview-actions { display: flex; gap: 8px; margin-top: 10px; }
.capture-preview .preview-actions button { width: auto; padding: 8px 12px; font-size: 13.5px; }

.progress-track {
  background: var(--paper-dim);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
  margin: 12px 0;
}
.progress-fill { background: var(--accent); height: 100%; width: 0%; transition: width 0.15s ease; }

.badge { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; }
.badge-warn { background: #fdf3e2; color: #8a5a12; }
.badge-dup { background: #fdf0ef; color: var(--danger); }
.badge-ok { background: #eef7ef; color: #2f6b3a; }

.pending-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.pending-card .pending-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pending-card .pending-vendor { font-weight: 700; font-size: 15px; }
.pending-card .pending-meta { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.pending-card .pending-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.pending-card .pending-open { display: block; margin-top: 10px; text-align: center; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.field-grid > div { grid-column: span 2; }
.field-grid > div.half { grid-column: span 1; }

textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 15px;
  margin-bottom: 16px;
  font-family: inherit;
  resize: vertical;
}

/* Accesibilidad general -- Tarea 061 (2026-07-31): foco visible en
   cualquier elemento interactivo (antes solo los inputs de texto lo
   tenian), objetivo tactil minimo real en botones/enlaces de accion. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button, .btn, .action-link, .sort-link, td a, th a {
  min-height: var(--tap-min);
}
button, .btn { min-width: var(--tap-min); }

/* Confirmacion/anulacion -- boton de peligro reutilizable, mismo tamano
   de objetivo que el resto, color de aviso claro sin depender solo del
   color (siempre lleva texto explicito, nunca solo un icono). */
.btn-danger {
  background: #fff;
  color: var(--danger);
  border: 1.5px solid var(--danger);
}
.btn-danger:hover { background: var(--danger-bg); }

@media print {
  .no-print { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; }
  .page { max-width: none; padding: 0; margin: 0; }
  .table-wrap { border: none; box-shadow: none; margin-top: 8px; }
  thead th { background: #fff; border-bottom: 2px solid #000; }
  tbody td { border-bottom: 1px solid #ccc; }
  .print-summary { font-size: 13px; color: var(--ink-soft); margin: 0 0 4px; }
  .print-note { font-size: 12px; color: var(--ink-soft); font-style: italic; margin: 0 0 12px; }
}

/* Ficha de cliente -- Tarea 061 */
.subtitle { color: var(--ink-soft); font-size: 14px; margin: 2px 0 0; }
.muted { color: var(--ink-soft); font-size: 14px; }

.ficha-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.ficha-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md, 8px);
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(30, 42, 56, 0.04);
}
.ficha-card h3 { margin: 0 0 10px; font-size: 14px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; }
.ficha-dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.ficha-dl dt { color: var(--ink-soft); font-size: 13px; }
.ficha-dl dd { margin: 0; font-size: 14.5px; }

.ficha-section { margin: 26px 0; }
.ficha-section h3 { margin: 0 0 12px; }
.ficha-section-head { display: flex; align-items: center; justify-content: space-between; }

.ficha-add-address { margin-top: 14px; }
.ficha-add-address summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent-strong);
  padding: 8px 0;
  min-height: var(--tap-min);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md, 8px);
  padding: 16px;
  margin-top: 8px;
}
.form-grid .filter-field input[type="text"] { margin-bottom: 0; width: 100%; }
.filter-checkbox { display: flex; align-items: flex-end; }
.filter-checkbox label { display: flex; align-items: center; gap: 6px; font-size: 14px; min-height: var(--tap-min); }

/* Editor de factura -- aspecto de documento comercial, Tarea 061 */
.invoice-doc {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg, 12px);
  padding: 26px 30px;
  margin: 18px 0 24px;
  box-shadow: 0 1px 3px rgba(30, 42, 56, 0.06);
}
.invoice-doc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  margin-bottom: 20px;
  border-bottom: 1.5px solid var(--ink);
}
.invoice-doc-issuer strong { display: block; font-size: 17px; }
.invoice-doc-issuer span { color: var(--ink-soft); font-size: 13.5px; }
.invoice-doc-meta { text-align: right; }
.invoice-doc-meta .doc-title { font-size: 22px; font-weight: 700; letter-spacing: 0.02em; margin: 0 0 6px; }
.invoice-doc-meta .doc-line { font-size: 13.5px; color: var(--ink-soft); }
.invoice-doc-meta .doc-line strong { color: var(--ink); font-weight: 600; }

.invoice-doc-parties {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 22px;
}
.invoice-doc-party h4 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}
.invoice-doc-party p { margin: 0; font-size: 14.5px; line-height: 1.5; }
.invoice-doc-party .warn-inline { color: #8a5a12; font-size: 13px; }

.invoice-grid table { width: 100%; }
.invoice-grid input[type="text"], .invoice-grid select, .invoice-grid textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm, 4px);
  font-size: 14px;
  margin-bottom: 0;
}
/* 2026-08-27: descripcion de linea de venta como textarea (lineas
   informativas y saltos de linea manuales) -- 2 filas visibles por
   defecto, redimensionable solo en vertical, sin desbordar la columna. */
.invoice-grid textarea {
  resize: vertical;
  min-height: 2.6em;
  font-family: inherit;
  box-sizing: border-box;
}
.invoice-grid input[type="text"]:hover, .invoice-grid select:hover, .invoice-grid textarea:hover,
.invoice-grid input[type="text"]:focus, .invoice-grid select:focus, .invoice-grid textarea:focus {
  border-color: var(--line);
  background: #fff;
}
.invoice-grid tbody tr form { display: contents; }
.invoice-grid th, .invoice-grid td { padding: 8px 8px; }
.invoice-grid .btn {
  width: auto;
  min-width: 0;
  padding: 7px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.invoice-totals {
  margin: 18px 0 0 auto;
  max-width: 340px;
}
.invoice-totals table { width: 100%; }
.invoice-totals td { padding: 8px 14px; font-size: 14.5px; }
.invoice-totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.invoice-totals tr.total-row td { font-size: 17px; border-top: 1.5px solid var(--ink); padding-top: 12px; }

.invoice-section { margin: 26px 0; }
.invoice-section-danger { border-top: 1px solid var(--line); padding-top: 18px; }
.invoice-section-danger h3 { color: var(--danger); }
.invoice-section h3 { margin: 0 0 10px; font-size: 15px; }
.invoice-fiscal-note {
  background: var(--paper-dim);
  border: 1px solid var(--line);
  border-radius: var(--radius-md, 8px);
  padding: 12px 16px;
  font-size: 13.5px;
  color: var(--ink-soft);
}

/* Tarea 100 (2026-08-02): eleccion explicita de serie real al emitir/confirmar */
.radio-line { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14px; }

/* Tarea 074 (2026-08-01): sistema de iconos SVG (reemplaza los emoji) */
.icon-svg { display: block; }
.icon { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.quick-action .icon { width: 24px; height: 24px; }

/* Tarea 074: tarjetas de sección para los "hubs" de Ventas/Compras/Banco/Informes/Más */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.hub-card {
  display: block;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg, 12px);
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.12s ease, border-color 0.12s ease;
}
a.hub-card:hover { box-shadow: 0 4px 14px -6px rgba(30, 42, 56, 0.18); border-color: var(--accent); }
.hub-card-pending { background: var(--paper); }
.hub-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.hub-card-title { font-weight: 600; font-size: 15px; color: var(--ink); }
.hub-card-desc { margin: 0; font-size: 13.5px; color: var(--ink-soft); line-height: 1.45; }

/* Tarea 074: tarjetas de estadística rápida en Inicio */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.stat-card {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg, 12px);
  background: #fff;
}
.stat-card-label { font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.stat-card-value { font-size: 24px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-card-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; }
.stat-card-pending .stat-card-value { color: var(--ink-soft); font-size: 15px; font-weight: 500; }

/* Tarea 074: situación fiscal estimada (Inicio + Informes) */
.fiscal-section { margin: 24px 0; }
.fiscal-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fiscal-heading h3 { margin: 0; }
.fiscal-table { margin-top: 10px; }
.quarter-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.quarter-cell {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  text-align: center;
}
.quarter-cell.current { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 1px var(--accent); }
.quarter-cell-label { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 4px; }
.quarter-cell-state { font-size: 13px; font-weight: 600; }
.quarter-cell-amount { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
@media (max-width: 640px) {
  .quarter-strip { grid-template-columns: repeat(2, 1fr); }
}

/* Tarea 096 (2026-08-01): tabla -> tarjetas en movil, sin scroll
   horizontal ni columnas cortadas. Aplicar la clase .table-responsive-cards
   al div.table-wrap y data-label="..." a cada <td> (el <th> deja de
   pintarse, cada celda muestra su propia etiqueta delante del valor). */
@media (max-width: 480px) {
  .table-responsive-cards table,
  .table-responsive-cards thead,
  .table-responsive-cards tbody,
  .table-responsive-cards tr,
  .table-responsive-cards td { display: block; width: 100%; }
  .table-responsive-cards thead { display: none; }
  .table-responsive-cards tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 4px 12px;
  }
  .table-responsive-cards tr:last-child { margin-bottom: 0; }
  .table-responsive-cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid var(--line);
    text-align: right;
  }
  .table-responsive-cards td:last-child { border-bottom: none; }
  .table-responsive-cards td[data-label]::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--ink-soft);
    text-align: left;
    margin-right: 8px;
  }
  .table-responsive-cards td:not([data-label]) { justify-content: flex-end; }
}

/* Tarea 074: pestañas del editor de documento (CSS-only, sin JS) */
.doc-tab-radio {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
#doc-tab-editar:focus-visible ~ .doc-tabs label[for="doc-tab-editar"],
#doc-tab-preview:focus-visible ~ .doc-tabs label[for="doc-tab-preview"],
#doc-tab-vencimientos:focus-visible ~ .doc-tabs label[for="doc-tab-vencimientos"],
#doc-tab-recepcion:focus-visible ~ .doc-tabs label[for="doc-tab-recepcion"],
#doc-tab-historial:focus-visible ~ .doc-tabs label[for="doc-tab-historial"] {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.doc-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 0; }
.doc-tabs label {
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.doc-tab-panel { display: none; padding-top: 18px; }
#doc-tab-editar:checked ~ .doc-tabs label[for="doc-tab-editar"],
#doc-tab-preview:checked ~ .doc-tabs label[for="doc-tab-preview"],
#doc-tab-vencimientos:checked ~ .doc-tabs label[for="doc-tab-vencimientos"],
#doc-tab-recepcion:checked ~ .doc-tabs label[for="doc-tab-recepcion"],
#doc-tab-historial:checked ~ .doc-tabs label[for="doc-tab-historial"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
#doc-tab-editar:checked ~ .doc-tab-content .doc-tab-panel-editar,
#doc-tab-preview:checked ~ .doc-tab-content .doc-tab-panel-preview,
#doc-tab-vencimientos:checked ~ .doc-tab-content .doc-tab-panel-vencimientos,
#doc-tab-recepcion:checked ~ .doc-tab-content .doc-tab-panel-recepcion,
#doc-tab-historial:checked ~ .doc-tab-content .doc-tab-panel-historial {
  display: block;
}

/* Tarea urgente 2026-08-05: vista previa embebida del PDF de albaran +
   firma de recepcion -- responsive 390/768/1440 (ver informe de la
   tarea). */
.pdf-preview-frame {
  width: 100%;
  min-height: 70vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.reception-summary { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.reception-signature-img {
  max-width: 260px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px;
}
.reception-summary dl { margin: 0; }
.reception-summary dt { font-size: 12px; color: var(--ink-soft); margin-top: 8px; }
.reception-summary dd { margin: 0 0 2px; font-weight: 600; }
@media (max-width: 768px) {
  .pdf-preview-frame { min-height: 55vh; }
  .reception-summary { flex-direction: column; }
  .reception-signature-img { max-width: 100%; }
}

.doc-editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 24px; align-items: start; }
.doc-editor-summary {
  position: sticky;
  top: calc(var(--topbar-height) + 16px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg, 12px);
  padding: 16px 18px;
  background: #fff;
}
.doc-editor-summary h4 { margin: 0 0 10px; font-size: 14px; }
.doc-editor-summary .total-line { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13.5px; }
.doc-editor-summary .total-line.grand { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-size: 16px; font-weight: 700; }
.doc-editor-summary .total-line.collected span:last-child { color: var(--success); }
.doc-editor-summary .total-line.pending-amount span:last-child { color: var(--warning); }
@media (max-width: 960px) {
  .doc-editor-layout { grid-template-columns: minmax(0, 1fr); }
  .doc-editor-summary { position: static; }
}

/* Tarea urgente 2026-08-05: lienzo de firma de recepcion -- tactil y
   raton (Pointer Events, sin libreria externa). Responsive 390/768/1440. */
.signature-pad-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-top: 6px;
}
.signature-canvas {
  display: block;
  width: 100%;
  height: 220px;
  touch-action: none;
  cursor: crosshair;
  border-radius: 8px;
}
@media (min-width: 768px) {
  .signature-canvas { height: 260px; }
}
@media (min-width: 1440px) {
  .firma-page { max-width: 900px; }
  .signature-canvas { height: 300px; }
}
@media (max-width: 390px) {
  .signature-canvas { height: 180px; }
}

/* ------------------------------------------------------------------
   Tarea 2026-08-11: hacer usable la edición de líneas de documento.
   Tres problemas reales que resolvía esto:
   1. La columna de edición medía ~676px (.page a 1000px menos el
      resumen lateral de 260px + 24px de hueco) mientras la tabla de
      líneas tiene 10 celdas -> scroll horizontal permanente.
   2. Los campos llevaban anchos fijos en píxeles escritos a mano en la
      plantilla (concepto 140px, cantidad 60px...), así que no se
      adaptaban por mucho sitio que hubiera. Ya retirados.
   3. Al guardar una línea el servidor redirigía sin ancla y el
      navegador aterrizaba arriba del todo. Ya se redirige a
      #linea-<id>; aquí solo hace falta que el ancla no quede tapada
      por la barra superior fija.
   ------------------------------------------------------------------ */

/* 1) Solo las fichas de documento (factura/albarán/presupuesto) usan el
   ancho completo. El resto de la aplicación mantiene sus 1000px. */
.page-documento { max-width: min(1400px, 96vw); }

/* 2) Reparto de columnas: el concepto se queda todo el sobrante y los
   números ocupan lo justo. Sin píxeles fijos en la plantilla. */
.invoice-grid table { table-layout: fixed; }
.invoice-grid th:nth-child(1), .invoice-grid td:nth-child(1) { width: auto; min-width: 220px; }
.invoice-grid th:nth-child(2), .invoice-grid td:nth-child(2) { width: 7ch; }
.invoice-grid th:nth-child(3), .invoice-grid td:nth-child(3) { width: 10ch; }
.invoice-grid th:nth-child(4), .invoice-grid td:nth-child(4) { width: 7ch; }
.invoice-grid th:nth-child(5), .invoice-grid td:nth-child(5) { width: 9ch; }
.invoice-grid th:nth-child(6), .invoice-grid td:nth-child(6) { width: 7ch; }
.invoice-grid th:nth-child(7), .invoice-grid td:nth-child(7),
.invoice-grid th:nth-child(8), .invoice-grid td:nth-child(8) { width: 11ch; text-align: right; }

/* Los importes calculados se leen mejor alineados a la derecha y con
   cifras de ancho fijo, para que las columnas cuadren visualmente. */
.invoice-grid td:nth-child(7), .invoice-grid td:nth-child(8) {
  font-variant-numeric: tabular-nums;
}

/* Campos algo más altos y legibles: se pasa el día escribiendo aquí. */
.invoice-grid input[type="text"], .invoice-grid select {
  padding: 8px 8px;
  font-size: 15px;
}
.invoice-grid input[type="text"] { border-color: var(--line); background: #fff; }

/* 3) Que al volver del guardado la línea no quede debajo de la barra. */
.invoice-grid .linea-fila { scroll-margin-top: calc(var(--topbar-height, 56px) + 24px); }
.invoice-grid .linea-fila:target td { background: var(--paper-dim); }

/* En pantallas estrechas se mantiene el comportamiento de antes: la
   tabla scrollea dentro de su contenedor, nunca desborda la página. */
@media (max-width: 900px) {
  .invoice-grid table { table-layout: auto; }
  .invoice-grid th:nth-child(1), .invoice-grid td:nth-child(1) { min-width: 180px; }
}

/* Tarea T401A: tabla de "Líneas" de una remesa (Documento/Cliente/Mandato/
   Esquema/Secuencia/Importe/Estado/Devuelto). Columnas propias, no las de
   una línea de documento (concepto+importes) — nunca reutilizar
   .invoice-grid aquí: sus anchos fijos en "ch" están pensados para esas
   otras columnas y montaban las cabeceras de esta tabla. table-layout se
   deja en su valor por defecto (auto) para que cada columna se ajuste a
   su contenido real; .table-wrap ya aporta scroll horizontal si no cabe,
   y .table-responsive-cards ya aporta la vista apilada en móvil estrecho. */
.remesa-lineas th:nth-child(6), .remesa-lineas td:nth-child(6) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.remesa-lineas th:nth-child(4), .remesa-lineas td:nth-child(4),
.remesa-lineas th:nth-child(5), .remesa-lineas td:nth-child(5) {
  white-space: nowrap;
}

/* Propiedades (2026-10-27): carpetas por inmueble. Reutiliza hub-grid y
   hub-card; aquí solo lo propio de esta sección. */
.prop-year { margin-top: 8px; }
.prop-year .filter-field { min-width: 120px; }
.prop-owner { margin: 26px 0 0; font-size: 15px; color: var(--ink-soft); font-weight: 600; }
.prop-owner + .hub-grid { margin-top: 10px; }
.prop-card .hub-card-title, .prop-folder .hub-card-title { display: inline-flex; align-items: center; gap: 8px; }
.prop-card .hub-card-desc + .hub-card-desc { margin-top: 2px; }
.prop-card-total { margin-top: 10px; font-size: 20px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.prop-card-total span { font-size: 13px; font-weight: 400; color: var(--ink-soft); margin-left: 4px; }
.prop-card-total span:only-child { margin-left: 0; }
.prop-folder .prop-card-total { margin: 4px 0 4px; }
.prop-folder .hub-card-title .icon-svg { color: var(--accent); }
.prop-folder-empty { background: var(--paper); }
.prop-folder-empty .hub-card-title .icon-svg { color: var(--ink-soft); }
.prop-total { margin-top: 18px; font-size: 15px; }
.prop-notes { background: var(--info-bg); color: var(--info); padding: 10px 14px; border-radius: var(--radius-md); font-size: 14px; }
.prop-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 4px; }
.prop-tab { padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); text-decoration: none; font-size: 14px; }
.prop-tab:hover { background: var(--paper-dim); }
.prop-tab.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.prop-count { font-size: 14px; font-weight: 400; color: var(--ink-soft); margin-left: 6px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.prop-inline { margin: 0; }
.btn-link { background: none; border: none; color: var(--danger); padding: 4px 6px; width: auto; min-width: 0; font-size: 13.5px; text-decoration: underline; cursor: pointer; }
.btn-link:hover { background: var(--danger-bg); }
.prop-upload { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 14px; border: 1px dashed var(--line); border-radius: var(--radius-md); background: #fff; }
.prop-upload .filter-field input { margin-bottom: 0; width: 100%; box-sizing: border-box; }
.prop-assign { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; min-width: 300px; }
.prop-assign select { width: auto; max-width: 220px; margin: 0; padding: 6px 8px; font-size: 13.5px; }
.prop-assign button { width: auto; padding: 7px 12px; font-size: 13.5px; }
.prop-same { display: inline-flex; align-items: center; gap: 4px; margin: 0; font-size: 12.5px; }
.error-msg { background: var(--danger-bg); color: var(--danger); padding: 10px 14px; border-radius: var(--radius-md); }
@media (max-width: 640px) {
  .prop-assign { min-width: 220px; }
  .prop-upload .filter-field { min-width: 100%; }
}
.prop-year select { margin-bottom: 0; min-width: 120px; }
.prop-title { display: flex; align-items: center; gap: 10px; }
.prop-title .icon-svg { color: var(--accent); flex: none; }
td.nowrap { white-space: nowrap; }

/* 12-11-2026 (José): en la tabla de líneas, Cant./Precio ud./Dto./IVA
   quedaban cortados (anchos en "ch" que no contaban el relleno de celda e
   input, y en ventanas < 900px las casillas se encogían a casi nada).
   Anchos mínimos reales por campo; si no cabe, la tabla scrollea dentro
   de .table-wrap en lugar de aplastar las casillas. */
.invoice-grid table { min-width: 940px; }
.invoice-grid th:nth-child(2), .invoice-grid td:nth-child(2) { width: 84px; }
.invoice-grid th:nth-child(3), .invoice-grid td:nth-child(3) { width: 112px; }
.invoice-grid th:nth-child(4), .invoice-grid td:nth-child(4) { width: 80px; }
.invoice-grid th:nth-child(5), .invoice-grid td:nth-child(5) { width: 96px; }
.invoice-grid th:nth-child(6), .invoice-grid td:nth-child(6) { width: 90px; }
.invoice-grid th:nth-child(7), .invoice-grid td:nth-child(7) { width: 96px; }
.invoice-grid th:nth-child(8), .invoice-grid td:nth-child(8) { width: 100px; }
.invoice-grid td input[name="quantity"] { min-width: 64px; }
.invoice-grid td input[name="unit_price_eur"] { min-width: 92px; }
.invoice-grid td input[name="discount_pct"] { min-width: 60px; }
.invoice-grid td select[name="tax_rate_pct"] { min-width: 76px; }
.invoice-grid td input[type="text"], .invoice-grid td select { text-align: right; }
.invoice-grid th, .invoice-grid td { white-space: nowrap; }
.invoice-grid th:nth-child(1), .invoice-grid td:nth-child(1) { white-space: normal; min-width: 240px; }

/* 12-11-2026 (2): el concepto quedaba en ~140px al escribir. Columna de
   concepto con ancho propio y la del botón Eliminar (no tiene <th>)
   también; y en pantallas de menos de 1400px el resumen pasa debajo para
   que las líneas usen todo el ancho. */
.invoice-grid table { min-width: 0; }
.invoice-grid th:nth-child(1), .invoice-grid td:nth-child(1) { width: 256px; min-width: 0; }
.invoice-grid th:nth-child(2), .invoice-grid td:nth-child(2) { width: 72px; }
.invoice-grid th:nth-child(3), .invoice-grid td:nth-child(3) { width: 96px; }
.invoice-grid th:nth-child(4), .invoice-grid td:nth-child(4) { width: 68px; }
.invoice-grid th:nth-child(5), .invoice-grid td:nth-child(5) { width: 84px; }
.invoice-grid th:nth-child(6), .invoice-grid td:nth-child(6) { width: 84px; }
.invoice-grid th:nth-child(7), .invoice-grid td:nth-child(7) { width: 90px; }
.invoice-grid th:nth-child(8), .invoice-grid td:nth-child(8) { width: 84px; }
.invoice-grid td:nth-child(9) { width: 90px; }
.invoice-grid td input[name="quantity"] { min-width: 52px; }
.invoice-grid td input[name="unit_price_eur"] { min-width: 76px; }
.invoice-grid td input[name="discount_pct"] { min-width: 48px; }
.invoice-grid td select[name="tax_rate_pct"] { min-width: 66px; }
.invoice-grid textarea[name="description"] { min-height: 4.2em; }
@media (max-width: 1400px) {
  .doc-editor-layout { grid-template-columns: minmax(0, 1fr) !important; }
}

/* ==========================================================================
   INTERFAZ v2 (02-12-2026) -- barra superior oscura, lanzador, barra
   inferior en móvil y capa visual común (tipografía, tarjetas, tablas,
   botones, estados, formularios). Va al final para ganar a las reglas
   anteriores sin tener que tocar cada plantilla.
   ========================================================================== */

body { background: var(--paper); color: var(--ink); -webkit-font-smoothing: antialiased; }
body::before {
  content: ""; position: fixed; inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px); background: var(--bar); z-index: 60;
}
h1, h2, h3, .app-brand-name, .stat-card-value, .kpi-v, .home-row .v, .days-box {
  font-family: var(--head);
}
h1, h2 { letter-spacing: -0.02em; text-wrap: balance; }
h2 { font-weight: 600; font-size: 1.6rem; }
h3 { font-weight: 600; font-size: 1.1rem; letter-spacing: -0.01em; margin-top: 28px; }
a { color: var(--accent-strong); }
.placeholder, .muted, .subtitle { color: var(--ink-soft); }

/* ---------- barra superior ---------- */
.app-bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50;
  background: var(--bar); color: var(--bar-fg);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.app-bar-in {
  max-width: 1320px; margin: 0 auto; height: var(--topbar-height);
  display: flex; align-items: center; gap: 6px; position: relative;
}
.app-brand { display: flex; align-items: center; gap: 10px; margin-right: 12px; color: #fff; text-decoration: none; white-space: nowrap; }
.app-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font: 700 12px/1 var(--sans); letter-spacing: .02em;
}
.app-brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.app-menu { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.app-menu::-webkit-scrollbar { display: none; }
.app-menu a {
  display: flex; align-items: center; height: var(--topbar-height); padding: 0 12px;
  color: var(--bar-muted); text-decoration: none; font-weight: 600; font-size: 14px; white-space: nowrap;
  min-height: 0;
}
.app-menu a:hover { color: var(--bar-fg); }
.app-menu a.on { color: #fff; background: var(--accent); }

.app-launch { position: static; margin-left: 4px; }
.app-launch > summary, .app-user > summary { list-style: none; cursor: pointer; }
.app-launch > summary::-webkit-details-marker, .app-user > summary::-webkit-details-marker { display: none; }
.app-launch > summary {
  width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; color: var(--bar-fg);
}
.app-launch > summary:hover, .app-launch[open] > summary { background: rgba(255, 255, 255, .1); }
.app-drawer {
  position: absolute; top: calc(var(--topbar-height) + 6px); right: 0;
  width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - var(--topbar-height) - 24px); overflow-y: auto;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .18); padding: 16px;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 14px; z-index: 70;
}
.app-drawer-group h4 {
  margin: 4px 8px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft);
}
.app-drawer a {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px;
  color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 500; min-height: 40px;
}
.app-drawer a:hover { background: var(--paper-dim); }
.app-drawer .ic {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: var(--accent-soft); color: var(--accent); display: grid; place-items: center;
}

.app-bar-r { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-search {
  display: flex; align-items: center; gap: 8px; width: 210px; height: 36px; padding: 0 10px;
  background: rgba(255, 255, 255, .08); border-radius: 8px; color: var(--bar-muted); margin: 0;
}
.topbar-search input {
  border: 0; background: transparent; outline: none; color: var(--bar-fg);
  font: inherit; font-size: 13.5px; width: 100%; padding: 0; margin: 0; min-height: 0;
}
.topbar-search input::placeholder { color: var(--bar-muted); }
.topbar-search-icon { display: flex; flex: none; }
.company-switcher {
  display: flex; align-items: center; gap: 8px; max-width: 190px; height: 34px; padding: 0 10px 0 6px;
  border-radius: 999px; background: rgba(255, 255, 255, .08); color: var(--bar-fg);
  text-decoration: none; font-size: 13px; font-weight: 600;
}
.company-switcher:hover { background: rgba(255, 255, 255, .14); }
.company-switcher .cs-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); flex: none; }
.company-switcher .cs-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-switcher .cs-caret { color: var(--bar-muted); display: flex; flex: none; }
.topbar-alerts {
  position: relative; width: 36px; height: 36px; border-radius: 8px; flex: none;
  display: grid; place-items: center; color: var(--bar-fg);
}
.topbar-alerts:hover { background: rgba(255, 255, 255, .1); }
.alerts-badge {
  position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.app-user { position: relative; }
.app-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #3a434c; color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.app-user-menu {
  position: absolute; right: 0; top: 42px; min-width: 230px; z-index: 70;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .16); padding: 8px;
}
.app-user-email { padding: 8px 10px; font-size: 13px; color: var(--ink-soft); border-bottom: 1px solid var(--line); margin-bottom: 6px; word-break: break-all; }
.app-user-menu a { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 14px; }
.app-user-menu a:hover { background: var(--paper-dim); }

/* ---------- contenido ---------- */
.app-main { display: block; }
.page {
  max-width: 1320px;
  padding-top: 26px; padding-bottom: 90px;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.page.page-narrow, .page-narrow { max-width: 560px; }
.page-head { align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h2 { margin: 0; }
.back-link { color: var(--ink-soft); }

/* ---------- botones ---------- */
button, .btn {
  background: var(--accent); color: var(--accent-fg); border: 1px solid var(--accent);
  border-radius: var(--radius-md); font-family: var(--sans); font-weight: 600; font-size: 14px;
  padding: 9px 16px; text-decoration: none;
}
button:hover, .btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-secondary, button.btn-secondary {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
}
.btn-secondary:hover, button.btn-secondary:hover { background: var(--paper-dim); color: var(--ink); border-color: var(--ink-soft); }
.btn-danger, button.btn-danger { background: var(--panel); color: var(--danger); border: 1.5px solid var(--danger); }
.btn-danger:hover, button.btn-danger:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.app-launch > summary, .app-user > summary { min-height: 0; }

/* ---------- formularios ---------- */
label { color: var(--ink-soft); font-weight: 500; }
input[type="email"], input[type="password"], input[type="text"], input[type="search"],
input[type="number"], input[type="date"], input[type="tel"], input[type="url"], select, textarea {
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); color: var(--ink);
  font-family: var(--sans); font-size: 14.5px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-bar .topbar-search input, .app-bar .topbar-search input:focus { border: 0; background: transparent; box-shadow: none; color: var(--bar-fg); font-size: 13.5px; padding: 0; margin: 0; }

/* ---------- tarjetas y tablas ---------- */
.table-wrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: none;
}
thead th {
  background: var(--paper-dim); color: var(--ink-soft); font-size: 11.5px; font-weight: 600;
  letter-spacing: .06em; padding: 11px 14px;
}
tbody td { padding: 11px 14px; font-size: 14px; }
tbody tr:hover td { background: #f7f8fa; }
td { font-variant-numeric: tabular-nums; }
.stat-card, .company-card, .actions-group, .hub-card, .ficha-card, .pending-card, .invoice-doc, .login-card, .quarter-cell {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: none;
}
a.hub-card:hover { border-color: var(--accent); box-shadow: 0 6px 18px -10px rgba(0, 0, 0, .25); }
.hub-card-title { font-family: var(--head); font-weight: 600; }
.stat-card-value { font-weight: 600; letter-spacing: -0.01em; }
.quick-action { border-radius: var(--radius-lg); }
.quick-action.primary { background: var(--accent); border-color: var(--accent); }
.quick-action.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.notice-row { border-radius: 10px; }
.notice-row.notice-urgent { background: var(--warning-bg); border-color: #f1d9ad; }

/* ---------- estados ---------- */
.badge { border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 700; }
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-warn { background: var(--warning-bg); color: var(--warning); }
.badge-dup { background: var(--danger-bg); color: var(--danger); }
.pill { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.p-ok { background: var(--success-bg); color: var(--success); }
.p-warn { background: var(--warning-bg); color: var(--warning); }
.p-bad { background: var(--danger-bg); color: var(--danger); }
.p-info { background: var(--info-bg); color: var(--info); }
.p-mute { background: var(--paper-dim); color: var(--ink-soft); }
.success { background: var(--success-bg); color: var(--success); border-color: #c9e7d3; border-radius: 10px; }
.error { color: var(--danger); }

/* ---------- Inicio (dashboard) ---------- */
.home-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.home-head h2 { margin: 0; }
.home-head p { margin: 2px 0 0; color: var(--ink-soft); }
.home-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.home-actions .btn { width: auto; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; }
.home-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; min-width: 0; }
.home-card > h3 { display: flex; align-items: center; gap: 10px; font-size: 1rem; margin: 0 0 6px; }
.home-card > h3 .ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.home-card > h3 .more { margin-left: auto; font: 600 13px var(--sans); color: var(--ink-soft); text-decoration: none; }
.home-card > h3 .more:hover { color: var(--accent); }
.home-row { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 12px; padding: 12px 0; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.home-row:first-of-type { border-top: 0; }
.home-row .l { color: var(--ink-soft); font-size: 13.5px; }
.home-row .v { grid-column: 1 / -1; font-size: 1.35rem; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.home-row .v small { font-family: var(--sans); font-size: 13px; color: var(--ink-soft); font-weight: 500; }
a.home-row:hover .l { color: var(--accent); }
.home-cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.doc-li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.doc-li:first-of-type { border-top: 0; }
.doc-li:hover .t { color: var(--accent); }
.doc-li .ic { width: 34px; height: 34px; border-radius: 9px; background: var(--paper-dim); display: grid; place-items: center; color: var(--ink-soft); }
.doc-li .t { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-li .s { color: var(--ink-soft); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-li .a { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.tax-li { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.tax-li:first-of-type { border-top: 0; }
.days-box { height: 52px; border-radius: 10px; background: var(--paper-dim); display: grid; place-items: center; text-align: center; line-height: 1.05; font-weight: 700; font-size: 17px; }
.days-box small { display: block; font-family: var(--sans); font-size: 10px; color: var(--ink-soft); font-weight: 600; }
.days-box.urg { background: var(--danger-bg); color: var(--danger); }
.days-box.urg small { color: var(--danger); }
.tax-li .t { font-weight: 600; font-size: 14px; }
.tax-li .s { color: var(--ink-soft); font-size: 12.5px; }

/* ---------- barra inferior (móvil) ---------- */
.mobile-nav { display: none; }
@media (max-width: 1240px) {
  .topbar-search { width: 40px; padding: 0 11px; }
  .topbar-search input { display: none; }
  .company-switcher .cs-label { max-width: 110px; }
}
@media (max-width: 1100px) {
  .app-drawer { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .home-cols { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app-menu, .topbar-search, .company-switcher .cs-label, .company-switcher .cs-caret, .app-launch > summary { display: none; }
  .company-switcher { padding: 0 6px; }
  .app-brand { margin-right: auto; }
  .app-drawer {
    position: fixed; left: max(10px, env(safe-area-inset-left, 0px)); right: max(10px, env(safe-area-inset-right, 0px));
    top: auto; bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px) + 8px);
    width: auto; max-height: 70vh; grid-template-columns: 1fr 1fr;
  }
  .mobile-nav {
    display: flex; justify-content: space-around; position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
    background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0, 0, 0, .06);
    padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  }
  .mobile-nav-item {
    display: grid; justify-items: center; gap: 2px; padding: 4px 8px; min-width: 56px;
    color: var(--ink-soft); text-decoration: none; font-size: 11px; font-weight: 600;
  }
  .mobile-nav-item .icon { display: flex; }
  .mobile-nav-item.active { color: var(--accent); }
  .page { padding-top: 18px; padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px) + 28px);
    padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  h2 { font-size: 1.4rem; }
}
@media (max-width: 480px) {
  .app-drawer { grid-template-columns: 1fr; }
  .home-actions { width: 100%; }
  .home-actions .btn { flex: 1 1 calc(50% - 8px); justify-content: center; }
}
@media print {
  .app-bar, .mobile-nav, body::before { display: none !important; }
}

/* ---------- 02-12-2026 · alineación de filtros, cabeceras y exportar ---------- */
/* Los select llevaban margin-bottom:16px y la caja de texto no: con la barra
   alineada por abajo, «Sociedad» y «Estado» quedaban más altos que «Buscar». */
.filter-bar { align-items: flex-end; }
.filter-field { display: flex; flex-direction: column; }
.filter-field input[type="text"], .filter-field input[type="date"], .filter-field select {
  margin-bottom: 0; height: 42px; box-sizing: border-box;
}
.filter-actions button, .filter-actions .btn { height: 42px; display: inline-flex; align-items: center; }
/* Cabeceras ordenables: el enlace mide 44 px de alto y el texto quedaba
   arriba; las no ordenables (Email, Estado) quedaban más abajo. */
thead th { vertical-align: middle; }
th a.sort-link { display: inline-flex; align-items: center; min-height: 0; }
/* Barra de exportar: los tres botones iguales (antes Excel en rojo e Imprimir más alto). */
.export-bar .btn, .export-bar button {
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  padding: 8px 14px; font-size: 13.5px; line-height: 1.3; height: 38px; min-height: 0;
  display: inline-flex; align-items: center; width: auto; font-weight: 600;
}
.export-bar .btn:hover, .export-bar button:hover { background: var(--paper-dim); color: var(--ink); border-color: var(--ink-soft); }

/* ==========================================================================
   UI v3 (02-12-2026) -- más contraste tarjeta/fondo, ficha de cliente en
   secciones horizontales y menús de apartado agrupados con icono.
   ========================================================================== */
:root { --paper: #eceff3; --paper-dim: #e6e9ee; --line: #d9dee5; --card-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 6px -2px rgba(16, 24, 40, .06); }
.table-wrap, .stat-card, .company-card, .actions-group, .hub-card, .ficha-card, .pending-card, .invoice-doc, .login-card, .quarter-cell, .filter-bar, .ficha-block, .hub-item {
  box-shadow: var(--card-shadow);
}

/* ---------- ficha de cliente ---------- */
.ficha-head { align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.ficha-head-main { min-width: 0; }
.ficha-head h2 { margin-bottom: 8px; }
.ficha-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; }
.ficha-chips .badge { padding: 4px 10px; }
.ficha-block {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px 22px; margin: 16px 0 0; min-width: 0;
}
.ficha-block-title {
  margin: 0 0 14px; font-family: var(--head); font-size: 15px; font-weight: 600; color: var(--ink);
  padding-left: 10px; border-left: 3px solid var(--accent); line-height: 1.2;
}
.ficha-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 28px; margin: 0; }
.ficha-cols > div { min-width: 0; }
.ficha-cols dt { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; margin-bottom: 3px; }
.ficha-cols dd { margin: 0; font-size: 15px; color: var(--ink); overflow-wrap: anywhere; }
.wrap-any, .ficha-section td { overflow-wrap: anywhere; }
.ficha-aviso {
  margin-top: 14px; padding: 10px 14px; border-radius: 10px;
  background: var(--warning-bg); color: #6b4300; border: 1px solid #f1d9ad; font-size: 14px;
}
.ficha-tarifa { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ficha-tarifa select { width: auto; min-width: 240px; max-width: 100%; margin: 0; height: 40px; }
.ficha-tarifa button { width: auto; height: 40px; padding: 0 16px; margin: 0; }
.ficha-tarifa .placeholder { flex-basis: 100%; margin: 2px 0 0; font-size: 13px; }

/* secciones inferiores (cuentas, mandatos, direcciones, historial) como tarjeta */
.ficha-section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 22px; margin: 16px 0 0; box-shadow: var(--card-shadow); min-width: 0; }
.ficha-section h3 { margin: 0 0 10px; font-family: var(--head); font-size: 15px; font-weight: 600; padding-left: 10px; border-left: 3px solid var(--accent); line-height: 1.2; }
.ficha-section .table-wrap { box-shadow: none; border-radius: 10px; margin-top: 8px; }
.ficha-section td .inline-form { display: inline-flex; margin: 0 4px 4px 0; vertical-align: middle; }
.ficha-section td button, .ficha-section td .btn {
  width: auto; min-width: 0; min-height: 0; height: 32px; padding: 0 12px; font-size: 13px; margin: 0;
  display: inline-flex; align-items: center;
}
.ficha-section td:last-child { white-space: nowrap; }
input[type="file"].file-compact { width: auto; max-width: 220px; font-size: 12.5px; padding: 0; border: 0; background: none; margin: 0; }
input[type="file"].file-compact::file-selector-button {
  height: 32px; padding: 0 12px; margin-right: 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink); font: 600 13px/1 var(--sans); cursor: pointer;
}
input[type="file"].file-compact::file-selector-button:hover { background: var(--paper-dim); }

/* ---------- menús de apartado ---------- */
.hub-group { margin-top: 26px; }
.hub-group-title { margin: 0 0 10px; font-family: var(--sans); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.hub-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.hub-item {
  display: grid; grid-template-columns: 42px minmax(0, 1fr) auto auto; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 14px 16px; color: var(--ink); text-decoration: none; min-height: 0; min-width: 0;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
a.hub-item:hover { border-color: var(--accent); box-shadow: 0 8px 20px -12px rgba(16, 24, 40, .35); transform: translateY(-1px); color: var(--ink); }
.hub-ic { width: 42px; height: 42px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.hub-txt { display: grid; gap: 2px; min-width: 0; }
.hub-title { font-family: var(--head); font-weight: 600; font-size: 15.5px; line-height: 1.25; }
.hub-desc { font-size: 13px; color: var(--ink-soft); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hub-item .badge { white-space: nowrap; }
.hub-go { font-size: 22px; line-height: 1; color: var(--ink-soft); }
a.hub-item:hover .hub-go { color: var(--accent); }
.hub-item-off { opacity: .75; }
.hub-item-off .hub-ic { background: var(--paper-dim); color: var(--ink-soft); }

@media (max-width: 820px) {
  .ficha-block, .ficha-section { padding: 14px 14px; }
  .ficha-cols { grid-template-columns: 1fr 1fr; gap: 12px 16px; }
  .hub-list { grid-template-columns: 1fr; }
  .hub-item { grid-template-columns: 38px minmax(0, 1fr) auto; padding: 12px 14px; gap: 12px; }
  .hub-go { display: none; }
  .hub-ic { width: 38px; height: 38px; }
  .ficha-section td:last-child { white-space: normal; }
}
@media (max-width: 480px) {
  .ficha-cols { grid-template-columns: 1fr; }
}

/* ---------- UI v3 · subnavegación lateral por apartado (como STEL) ---------- */
.app-shell.has-subnav {
  display: grid; grid-template-columns: 228px minmax(0, 1fr); align-items: start;
  max-width: 1560px; margin: 0 auto;
}
.subnav {
  position: sticky; top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
  align-self: start; min-height: calc(100vh - var(--topbar-height));
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 18px 10px 24px;
}
.subnav-title { font: 700 11.5px/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); padding: 4px 12px 12px; }
.subnav-item {
  display: flex; align-items: center; gap: 10px; min-height: 0;
  padding: 9px 12px; margin: 1px 0; border-radius: 8px; border-left: 3px solid transparent;
  color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 500; line-height: 1.25;
}
.subnav-item:hover { background: var(--paper); color: var(--ink); }
.subnav-item.on { background: var(--accent-soft); border-left-color: var(--accent); color: var(--accent-strong); font-weight: 600; border-radius: 0 8px 8px 0; }
.subnav-ic { color: var(--ink-soft); display: inline-flex; }
.subnav-item.on .subnav-ic { color: var(--accent); }
.app-shell.has-subnav .page { margin: 0; max-width: 1280px; }

@media (max-width: 820px) {
  .app-shell.has-subnav { display: block; }
  .subnav {
    position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40; min-height: 0;
    display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; white-space: nowrap;
    border-right: 0; border-bottom: 1px solid var(--line); padding: 8px max(12px, env(safe-area-inset-left, 0px));
  }
  .subnav::-webkit-scrollbar { display: none; }
  .subnav-title, .subnav-ic { display: none; }
  .subnav-item { flex: 0 0 auto; padding: 7px 12px; border-left: 0; border-radius: 999px; font-size: 13.5px; background: var(--paper); }
  .subnav-item.on { border-radius: 999px; background: var(--accent); color: #fff; }
}

/* ---------- UI v3 · ficha de cliente estilo STEL ---------- */
.ficha-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.ficha-toolbar .btn, .ficha-toolbar summary.btn { width: auto; height: 38px; padding: 0 14px; display: inline-flex; align-items: center; min-height: 0; font-size: 14px; }
.ficha-toolbar-sp { flex: 1 1 auto; }
.ficha-more { position: relative; }
.ficha-more summary { list-style: none; cursor: pointer; }
.ficha-more summary::-webkit-details-marker { display: none; }
.ficha-more-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 220px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px -12px rgba(16,24,40,.35);
  padding: 6px; display: grid;
}
.ficha-more-menu a, .ficha-more-menu .btn-link {
  display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 6px; min-height: 0;
  background: none; border: 0; color: var(--ink); font: 500 14px/1.3 var(--sans); text-decoration: none; cursor: pointer;
}
.ficha-more-menu form { margin: 0; }
.ficha-more-menu a:hover, .ficha-more-menu .btn-link:hover { background: var(--paper); }
.ficha-more-menu .danger { color: var(--danger); }
.ficha-titlebar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 12px; }
.ficha-titlebar h2 { margin: 0; }
.ficha-num { color: var(--ink-soft); font-weight: 600; }
.ficha-page > .ficha-aviso { margin: 0 0 14px; }
.ficha-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; margin: 0; }
.ficha-2col > div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--paper-dim); min-width: 0; align-items: baseline; }
.ficha-2col dt { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.ficha-2col dd { margin: 0; font-size: 14.5px; color: var(--ink); overflow-wrap: anywhere; min-width: 0; }
.ficha-tabs { display: flex; gap: 2px; margin: 24px 0 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.ficha-tabs::-webkit-scrollbar { display: none; }
.ficha-tab {
  width: auto; min-width: 0; min-height: 0; height: 42px; padding: 0 16px; margin: 0 0 -1px;
  background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--ink-soft); font: 600 14px/1 var(--sans); white-space: nowrap; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.ficha-tab:hover { background: none; color: var(--ink); border-color: var(--line); }
.ficha-tab.on { color: var(--accent-strong); border-bottom-color: var(--accent); background: none; }
.ficha-tab-n { font-size: 11.5px; background: var(--paper-dim); color: var(--ink-soft); border-radius: 999px; padding: 2px 7px; }
.ficha-tab.on .ficha-tab-n { background: var(--accent-soft); color: var(--accent-strong); }
.ficha-panel > .ficha-section:first-child { margin-top: 14px; }
@media (max-width: 820px) {
  .ficha-2col { grid-template-columns: 1fr; }
  .ficha-2col > div { grid-template-columns: 120px minmax(0, 1fr); }
  .ficha-toolbar-sp { display: none; }
}

/* ===================== UI v4 (02-12-2026) · listados ===================== */
/* 1) Barra de filtros ordenada: rejilla de columnas iguales; «Buscar» ocupa
   dos columnas; el botón al final. Las barras de botones (cobros) y las de
   año de Propiedades no entran (no son form GET con campos). */
form.filter-bar:not(.prop-year) {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px 12px; align-items: end;
}
form.filter-bar:not(.prop-year) .filter-field { min-width: 0; }
form.filter-bar:not(.prop-year) .filter-field:first-child { grid-column: span 2; }
form.filter-bar:not(.prop-year) .filter-field select,
form.filter-bar:not(.prop-year) .filter-field input { width: 100%; min-width: 0; text-overflow: ellipsis; }
form.filter-bar:not(.prop-year) .filter-field label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
form.filter-bar:not(.prop-year) .filter-actions { justify-self: start; flex-wrap: nowrap; }
form.filter-bar:not(.prop-year) .filter-field > .placeholder { display: none; }
@media (max-width: 560px) {
  form.filter-bar:not(.prop-year) { grid-template-columns: 1fr 1fr; }
  form.filter-bar:not(.prop-year) .filter-field:first-child { grid-column: 1 / -1; }
}
.filter-help { font-size: 12px; color: var(--ink-soft); margin: 6px 2px 0; }
div.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 8px 10px; }
div.filter-bar .btn { width: auto; height: 34px; padding: 6px 14px; font-size: 13.5px; border-radius: 999px; display: inline-flex; align-items: center; min-height: 0; }

/* Contador y atajos en la misma fila, atajos como pastillas pequeñas */
.results-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 8px; }
.results-row .results-meta { margin: 0; }
.filter-quick-ranges { display: flex; gap: 6px; flex-wrap: wrap; margin: 0; }
.filter-quick-ranges .btn {
  width: auto; min-height: 0; height: 28px; padding: 3px 12px; font-size: 12.5px; font-weight: 600;
  border-radius: 999px; background: #fff; color: var(--ink); border: 1px solid var(--line); display: inline-flex; align-items: center;
}
.filter-quick-ranges .btn:hover { border-color: var(--accent); color: var(--accent); background: #fff; }

/* 2) Barra de selección: discreta sin selección (solo «Seleccionar todas las N
   filtradas»); con selección, barra fina fija encima de la tabla. */
.seleccion-bar {
  position: sticky; top: calc(var(--topbar-height, 56px) + env(safe-area-inset-top, 0px)); z-index: 20;
  padding: 6px 10px; gap: 8px; margin: 0 0 10px; border-radius: 8px;
  background: var(--ink); color: #fff; border: 0; font-size: 13.5px;
}
.seleccion-bar .btn, .seleccion-bar button {
  height: 30px; min-height: 0; padding: 4px 12px; font-size: 13px; display: inline-flex; align-items: center;
  background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.25);
}
.seleccion-bar .btn:hover, .seleccion-bar button:hover { background: rgba(255,255,255,.22); color: #fff; }
.seleccion-bar:has(#fac-sel-btn-excel:disabled) {
  position: static; background: transparent; color: var(--ink-soft); padding: 0; margin: 0 0 6px;
}
.seleccion-bar:has(#fac-sel-btn-excel:disabled) > span,
.seleccion-bar:has(#fac-sel-btn-excel:disabled) #fac-sel-ninguna,
.seleccion-bar:has(#fac-sel-btn-excel:disabled) form { display: none; }
.seleccion-bar:has(#fac-sel-btn-excel:disabled) #fac-sel-todas-filtradas {
  background: transparent; border: 0; color: var(--ink-soft); padding: 0; height: auto; font-size: 12.5px; text-decoration: underline;
}
.seleccion-bar:has(#fac-sel-btn-excel:disabled) #fac-sel-todas-filtradas:hover { color: var(--accent); background: transparent; }
/* Botones desactivados: gris neutro, nunca rosa */
button:disabled, .btn:disabled, button[disabled], .btn[disabled] {
  background: #eef0f3 !important; color: #9aa1a9 !important; border-color: #e1e4e8 !important; opacity: 1; cursor: not-allowed;
}

/* 5) Enlaces en tablas: tinta oscura, subrayado/acento solo al pasar */
tbody td a:not(.btn):not(.badge) { color: var(--ink); text-decoration: none; font-weight: 500; min-height: 0; }
tbody td a:not(.btn):not(.badge):hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
/* «Abrir» / «Editar» sueltos en la última columna → botón pequeño */
tbody td:last-child > a:only-child:not(.btn) {
  display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 6px; font-size: 12.5px; font-weight: 600; background: #fff; white-space: nowrap;
}
tbody td:last-child > a:only-child:not(.btn)::after { content: " →"; margin-left: 4px; }
tbody td:last-child > a:only-child:not(.btn):hover { border-color: var(--accent); text-decoration: none; }
/* Fechas e importes sin partir */
td.nowrap, th.nowrap { white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* UI v4b: listados con 6 o más filtros → dos filas fijas y ordenadas */
@media (min-width: 761px) {
  form.filter-bar:not(.prop-year):has(> .filter-field:nth-child(6)) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  form.filter-bar:not(.prop-year):has(> .filter-field:nth-child(6)) .filter-field:first-child { grid-column: span 3; }
}
@media (max-width: 760px) and (min-width: 561px) {
  form.filter-bar:not(.prop-year) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  form.filter-bar:not(.prop-year) .filter-field:first-child { grid-column: 1 / -1; }
}
/* UI v4c: botones dentro de tablas compactos y en línea */
tbody td .btn { height: 30px; min-height: 0; padding: 4px 10px; font-size: 12.5px; display: inline-flex; align-items: center; width: auto; margin: 2px 4px 2px 0; white-space: nowrap; }
tbody td .badge { white-space: nowrap; }

/* UI v4d (02-12-2026): con 7 u 8 filtros (Facturas) → dos filas de 4, sin campos huérfanos */
@media (min-width: 761px) {
  form.filter-bar:not(.prop-year):has(> .filter-field:nth-child(8)) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  form.filter-bar:not(.prop-year):has(> .filter-field:nth-child(8)) .filter-field:first-child { grid-column: auto; }
}

/* buscador plegado en una lupa (03-12-2026) */
.app-bar-r { position: relative; }
.topbar-search { width: 40px; padding: 0 11px; flex: none; transition: width .15s ease; }
.topbar-search-icon { cursor: pointer; color: var(--bar-fg); }
.app-bar .topbar-search input { width: 0; min-width: 0; }
.topbar-search:focus-within {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%); z-index: 60;
  width: min(340px, 80vw); background: var(--bar); box-shadow: 0 0 0 1px rgba(255,255,255,.25), 0 6px 18px rgba(0,0,0,.25);
}
.app-bar .topbar-search:focus-within input { width: 100%; }
@media (max-width: 1240px) { .topbar-search input { display: block; } }

/* Confirmación en dos pasos (04-12-2026): ver static/confirmar.js */
.confirmar-caja { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--danger); border-radius: 8px; background: var(--danger-bg); color: var(--ink); font-size: 13px; }

/* 04-12-2026: la lupa también en el móvil (antes se ocultaba a 820 px o menos) */
@media (max-width: 820px) { .topbar-search { display: flex; } }

/* 04-12-2026: botones «Presentado» / «Pagado» de cada vencimiento fiscal */
.deadline-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* 04-12-2026 (Ventas): confirmación en dos pasos dentro de la página
   (Marcar cobrado / Deshacer cobro / Anular mandato). */
details.cobro-confirm { display: inline-block; }
details.cobro-confirm > summary { list-style: none; cursor: pointer; }
details.cobro-confirm > summary::-webkit-details-marker { display: none; }
details.cobro-confirm[open] > form { margin-top: 6px; }
