/* =====================================================
   SESIONES — Design System (Stitch adaptation)
   ===================================================== */

/* ── 0. Critical override ───────────────────────────── */
[hidden] { display: none !important; }

/* ── 1. Design tokens ───────────────────────────────── */
:root {
  /* Palette */
  --bg:               #FAF9F6;
  --surface:          #FFFFFF;
  --surface-low:      #FEF1EE;
  --surface-mid:      #F8EBE8;
  --surface-high:     #F2E6E2;
  --surface-highest:  #ECE0DD;

  --sidebar-bg:       #2C2825;
  --sidebar-border:   rgba(255,255,255,0.08);

  --primary:          #2D5C3A;
  --primary-container:#4E8B5F;
  --on-primary:       #FFFFFF;
  --primary-light:    #E4EFE6;

  --text-primary:     #1A201B;
  --text-secondary:   #3F5244;
  --text-muted:       #6B7E6F;
  --text-sidebar:     rgba(255,255,255,0.65);
  --text-sidebar-active: #7BBF8E;

  --border:           #E8E3DC;
  --border-strong:    #D7C2BC;

  --success:          #266862;
  --success-bg:       #E1F5F3;
  --success-text:     #003F3B;

  --amber:            #BA7517;
  --amber-bg:         #FEF3E2;
  --amber-text:       #7A4700;

  --error:            #BA1A1A;
  --error-bg:         #FFDAD6;
  --error-text:       #93000A;

  /* Typography */
  --font: 'Inter', 'Segoe UI', Arial, sans-serif;

  /* Radius */
  --radius-pill:      9999px;
  --radius-card:      20px;
  --radius-sm:        10px;
  --radius-xs:        8px;

  /* Spacing */
  --sidebar-w:        260px;
  --sidebar-w-collapsed: 72px;
  /* Ancho util del contenido. Sube a 1520 para aprovechar los monitores grandes: con
     1120 el panel se quedaba en ~1330px y dejaba media pantalla en blanco a la derecha.
     Sigue habiendo tope para no estirar tablas y rejillas hasta lo ilegible en ultrapanoramicas. */
  --content-max:      1520px;
  /* Ancho comodo para leer y rellenar un formulario. Sin esto, al ensanchar el layout
     los campos de texto pasarian de 1500px de ancho, que no ayuda a nadie. */
  --form-max:         820px;
  --gap:              24px;

  /* Transitions */
  --t:                0.15s ease;
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); }
img { display: block; max-width: 100%; }

/* ── 3. Layout ───────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden; /* la cabecera y el pie son fijos; solo scrollea .sidebar-nav-scroll */
  transition: width 0.2s ease, box-shadow 0.2s ease;
}

/* Zona central: la única que scrollea (cabecera y pie quedan fijos siempre,
   incluso si la lista de menús no cabe entera). Barra fina y visible, no oculta. */
.sidebar-nav-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.sidebar-nav-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-nav-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: var(--radius-pill); }
.sidebar-nav-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.32); }

.app-shell {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 40px var(--gap) 80px;
  max-width: calc(var(--content-max) + var(--sidebar-w));
  transition: margin-left 0.2s ease;
}

/* Botón (⋮) para fijar el menú colapsado o expandido. Vive dentro de .brand,
   así que sigue siendo alcanzable incluso con el raíl estrecho. */
.sidebar-collapse-btn {
  margin-left: auto;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-sidebar);
  transition: background var(--t), color var(--t);
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,0.1); color: #FFFFFF; }
.sidebar-collapse-btn .material-symbols-outlined { font-size: 20px; }

/* ── Menú colapsado (escritorio): raíl estrecho de solo iconos, con "peek" al
   pasar el ratón. Acotado a min-width:781px para que quede completamente
   separado del comportamiento móvil (barra estrecha + cajón, más abajo) —
   sin pelear especificidad ni depender de si el táctil dispara :hover. ── */
@media (min-width: 781px) {
  body.sidebar-collapsed .sidebar {
    width: var(--sidebar-w-collapsed);
  }
  body.sidebar-collapsed .sidebar:hover {
    width: var(--sidebar-w);
    box-shadow: 6px 0 28px rgba(0,0,0,0.28);
  }
  body.sidebar-collapsed .app-shell {
    margin-left: var(--sidebar-w-collapsed);
  }

  /* Oculta las etiquetas de texto (no los iconos) mientras está colapsado y no
     se está pasando el ratón por encima; el hover las revierte automáticamente
     porque estas reglas dejan de aplicar bajo :not(:hover). En la cabecera, con
     el raíl estrecho solo se ve la hamburguesa (ni la "A" ni el nombre), centrada. */
  body.sidebar-collapsed .sidebar:not(:hover) .brand {
    justify-content: center;
    padding: 20px 8px;
  }
  body.sidebar-collapsed .sidebar:not(:hover) .sidebar-collapse-btn {
    margin-left: 0;
  }
  body.sidebar-collapsed .sidebar:not(:hover) .brand-mark,
  body.sidebar-collapsed .sidebar:not(:hover) .brand-text,
  body.sidebar-collapsed .sidebar:not(:hover) nav a span:not(.nav-icon),
  body.sidebar-collapsed .sidebar:not(:hover) .nav-group-toggle span:not(.nav-icon),
  body.sidebar-collapsed .sidebar:not(:hover) .nav-group-items,
  body.sidebar-collapsed .sidebar:not(:hover) .nav-section-label,
  body.sidebar-collapsed .sidebar:not(:hover) .sidebar-profile-text,
  body.sidebar-collapsed .sidebar:not(:hover) .sidebar-footer-details {
    display: none;
  }
  body.sidebar-collapsed .sidebar:not(:hover) nav a,
  body.sidebar-collapsed .sidebar:not(:hover) .nav-group-toggle {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }
  body.sidebar-collapsed .sidebar:not(:hover) .sidebar-profile {
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .app-shell, .sidebar-collapse-btn { transition: none; }
}

/* ── 4. Brand ────────────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 28px 24px 20px;
  flex-shrink: 0;
}

.brand-mark {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary-container);
  color: var(--on-primary);
  font-size: 16px;
  font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.brand-text strong {
  display: block;
  font-size: 16px;
  font-weight: 500;
  color: #FFFFFF;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-text span {
  display: block;
  font-size: 11px;
  color: var(--text-sidebar);
  letter-spacing: 0.01em;
  margin-top: 2px;
}

/* ── 5. Sidebar nav ──────────────────────────────────── */
.sidebar nav {
  padding: 8px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-xs);
  font-size: 14px;
  color: var(--text-sidebar);
  transition: background var(--t), color var(--t);
  position: relative;
  border-left: 3px solid transparent;
}

.sidebar nav a .nav-icon {
  font-size: 20px;
  flex-shrink: 0;
  transition: color var(--t);
}

/* Etiqueta de bloque: agrupa el menú por ritmo de trabajo (día a día / facturar /
   cuentas) sin añadir destinos. Muy tenue a propósito: ordena la vista, no compite
   con los enlaces. El primero no lleva margen superior porque ya abre el menú. */
.nav-section-label {
  display: block;
  margin: 18px 0 4px;
  padding: 0 14px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.34);
  pointer-events: none;
}
.sidebar nav > .nav-section-label:first-child { margin-top: 2px; }

.sidebar nav a:hover {
  background: rgba(255,255,255,0.07);
  color: #FFFFFF;
}

.sidebar nav a.active {
  color: var(--primary-container);
  border-left-color: var(--primary-container);
  background: rgba(78,139,95,0.12);
  font-weight: 500;
  padding-left: 11px;
}

.sidebar nav a.active .nav-icon {
  color: var(--primary-container);
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-container);
  color: var(--on-primary);
  font-size: 10px;
  font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: var(--radius-pill);
  padding: 0 5px;
  margin-left: auto;
}

/* Grupo de navegación desplegable (Facturas → generar/borradores/emitidas/resumen) */
.nav-group { display: flex; flex-direction: column; }
.nav-group-toggle {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-xs);
  font-size: 14px; color: var(--text-sidebar);
  background: none; border: 0; border-left: 3px solid transparent;
  cursor: pointer; text-align: left; width: 100%; font-family: inherit;
  transition: background var(--t), color var(--t);
}
.nav-group-toggle:hover { background: rgba(255,255,255,0.07); color: #FFFFFF; }
.nav-group-toggle .nav-icon { font-size: 20px; flex-shrink: 0; transition: color var(--t); }
.nav-caret { margin-left: auto; font-size: 18px; transition: transform var(--t); }
.nav-group.open .nav-caret { transform: rotate(180deg); }
.nav-group.has-active .nav-group-toggle,
.nav-group.has-active .nav-group-toggle .nav-icon { color: var(--primary-container); }
.nav-group-items { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.sidebar nav a.nav-subitem { padding: 8px 14px 8px 46px; font-size: 13.5px; }
.sidebar nav a.nav-subitem.active { padding-left: 43px; }

/* ── 6. Sidebar footer ───────────────────────────────── */
.sidebar-footer {
  padding: 16px 24px 24px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.sidebar-profile-avatar {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary-container);
  color: var(--on-primary);
  font-size: 14px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.sidebar-profile-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sidebar-profile-text { min-width: 0; }
.sidebar-profile-name {
  font-size: 13.5px;
  font-weight: 500;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-profile-sub {
  font-size: 11.5px;
  color: var(--text-sidebar);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-month {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-sidebar);
  margin-bottom: 4px;
}

.sidebar-stat {
  font-size: 12px;
  color: var(--text-sidebar);
  opacity: 0.7;
}

/* ── 7. Page header ──────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
}

.eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.page-header h1 {
  font-size: 32px;
  font-weight: 300;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.15;
}

.subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.5;
}

.page-header-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding-top: 4px;
  flex-shrink: 0;
}

/* ── 8. Views ────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── 9. Buttons ──────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  background: var(--primary-container);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius-pill);
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background var(--t), opacity var(--t);
  white-space: nowrap;
}
.btn-primary:hover:not(:disabled) { background: var(--primary); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  background: transparent;
  color: var(--primary-container);
  border: 1.5px solid var(--primary-container);
  border-radius: var(--radius-pill);
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background var(--t), color var(--t);
  white-space: nowrap;
}
.btn-secondary:hover { background: var(--surface-low); }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t);
  white-space: nowrap;
}
.btn-ghost:hover { background: var(--surface-high); color: var(--text-primary); }

.btn-danger-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  background: transparent;
  color: var(--error);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background var(--t);
  white-space: nowrap;
}
.btn-danger-ghost:hover { background: var(--error-bg); }

.btn-sm {
  padding: 7px 16px;
  font-size: 13px;
}

.btn-icon {
  padding: 7px 10px;
  min-width: 34px;
}
/* Botones de acción de fila (editar / eliminar) con icono */
.row-actions .btn-icon {
  width: 34px; height: 34px; min-width: 34px; padding: 0;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.row-actions .btn-icon .material-symbols-outlined { font-size: 18px; line-height: 1; }
.row-actions .btn-ghost.btn-icon { color: var(--text-muted); }
.row-actions .btn-ghost.btn-icon:hover { background: var(--primary-light); color: var(--primary); }
.row-actions .btn-danger-ghost.btn-icon { color: var(--text-muted); }
.row-actions .btn-danger-ghost.btn-icon:hover { background: var(--error-bg); color: var(--error); }

/* ── 10. Inputs & selects ────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="search"],
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  width: 100%;
  height: 42px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
  appearance: none;
  -webkit-appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary-container);
  box-shadow: 0 0 0 3px rgba(78,139,95,0.15);
}

input::placeholder { color: var(--text-muted); }

input:not([type="checkbox"]):not([type="radio"]):disabled,
select:disabled,
textarea:disabled {
  background: var(--surface-high, var(--bg));
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.75;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2385736E' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

/* ── Custom select component ─────────────────────────── */
.c-select-native {
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  border: 0 !important;
  padding: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.c-select-wrapper {
  position: relative;
  display: block;
  width: 100%;
}

.c-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 42px;
  padding: 0 36px 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--t), background var(--t);
  position: relative;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.c-select-trigger:hover { border-color: var(--primary-container); }
.c-select-trigger.is-open {
  border-color: var(--primary-container);
  box-shadow: 0 0 0 3px rgba(78,139,95,0.15);
}
.c-select-trigger::after {
  content: 'expand_more';
  font-family: 'Material Symbols Outlined';
  font-size: 18px;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  transition: transform 0.18s ease;
  pointer-events: none;
}
.c-select-trigger.is-open::after {
  transform: translateY(-50%) rotate(180deg);
}

.c-select-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 20px rgba(0,0,0,0.10);
  z-index: 300;
  overflow-y: auto;
  max-height: 240px;
}

.c-select-option {
  display: block;
  width: 100%;
  padding: 9px 16px;
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: background var(--t);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.c-select-option:hover { background: var(--primary-light); }
.c-select-option.is-selected { font-weight: 500; color: var(--primary); }

/* Small pill variant (sessionMonthFilter) */
.c-select-wrapper.sm {
  width: auto;
  min-width: 160px;
}
.c-select-wrapper.sm .c-select-trigger {
  height: 34px;
  font-size: 13px;
  font-weight: 700;
  padding: 0 32px 0 14px;
}
.c-select-wrapper.sm .c-select-trigger::after { font-size: 16px; right: 10px; }

/* Month/year controls in billing page */
.month-controls .c-select-wrapper {
  width: auto;
  min-width: 110px;
}
.month-controls .c-select-trigger {
  height: 36px;
  font-size: 13px;
  padding: 0 30px 0 14px;
}
.month-controls .c-select-trigger::after { font-size: 16px; right: 8px; }

/* Facturas toolbar */
.facturas-toolbar .c-select-wrapper {
  width: auto;
  min-width: 130px;
}
.facturas-toolbar .c-select-trigger {
  height: 38px;
  font-size: 13px;
  padding: 0 32px 0 14px;
}
.facturas-toolbar .c-select-trigger::after { font-size: 16px; right: 10px; }

@media (max-width: 640px) {
  .facturas-toolbar .c-select-wrapper { width: 100%; }
}

/* Selector de hora tipo rueda (horas / minutos, formato 24h) */
.time-wheel-wrapper { position: relative; display: block; width: 100%; }
.time-wheel-trigger { font-variant-numeric: tabular-nums; }
.time-wheel-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 40;
  width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: 0 8px 24px rgba(32,26,25,0.15);
  padding: 14px 14px 12px;
}
.time-wheel-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.time-wheel-highlight {
  position: absolute;
  left: 0; right: 0;
  background: var(--primary-light);
  border-radius: 10px;
  pointer-events: none;
  z-index: 0;
}
.time-wheel-col {
  position: relative;
  z-index: 1;
  width: 56px;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  mask-image: linear-gradient(to bottom, transparent 0, black 34px, black calc(100% - 34px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 34px, black calc(100% - 34px), transparent 100%);
}
.time-wheel-col::-webkit-scrollbar { display: none; }
.time-wheel-item {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: center;
  font-size: 15px;
  font-weight: 400;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: color var(--t), font-weight var(--t), font-size var(--t);
}
.time-wheel-item.is-selected { color: var(--text-primary); font-weight: 600; font-size: 18px; }
.time-wheel-colon { z-index: 1; font-size: 18px; font-weight: 600; color: var(--text-primary); }
.time-wheel-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

/* ── 11. Forms ───────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.stack-form {
  display: grid;
  gap: 16px;
  /* Un campo de texto de 1500px no se lee mejor, solo obliga a mover los ojos. Los
     formularios se quedan a un ancho comodo aunque el panel que los contiene sea ancho. */
  max-width: var(--form-max);
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.inline-form-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 36px 28px 28px;
  margin-bottom: 20px;
}

.inline-form-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}

.inline-form-help {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: -14px;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* ── 12. Stat cards ──────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: background var(--t);
}
.stat-card:hover { background: var(--surface-low); }

.stat-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.3;
}

.stat-value {
  font-size: 32px;
  font-weight: 300;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1;
}

.stat-card.warning .stat-value { color: var(--amber); }
.stat-card-ok   { border-left: 3px solid #4E8B5F; }
.stat-card-warn { border-left: 3px solid #E8A87C; }
.stat-card-ok   .stat-value { color: #2D5C3A; }
.stat-card-warn .stat-value { color: #C46B30; }

/* ── 13. Action cards (Inicio flow) ──────────────────── */
.action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 16px;
  margin-top: 12px;
}

.action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 32px 24px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
}

.action-num {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--surface-low);
  color: var(--primary-container);
  font-size: 22px;
  font-weight: 300;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 18px;
  flex-shrink: 0;
}

.action-card h2 {
  font-size: 18px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.action-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
  flex: 1;
}

.action-card .btn-secondary,
.action-card .btn-ghost,
.action-card .btn-primary {
  width: 100%;
  justify-content: center;
  margin-top: auto;
}

/* ── 15. List header ─────────────────────────────────── */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.list-header h2 {
  font-size: 18px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

/* ── 16. Data rows ───────────────────────────────────── */
.page-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.data-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: background var(--t);
}
.data-row:hover { background: var(--surface-low); }

/* Avatar */
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--surface-high);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.01em;
}
.avatar.blue   { background: #dbeafe; color: #1d4ed8; }
.avatar.green  { background: var(--success-bg); color: var(--success); }
.avatar.purple { background: #ede9fe; color: #7c3aed; }
.avatar.orange { background: var(--amber-bg); color: var(--amber); }

.client-info {
  flex: 1;
  min-width: 0;
}
.client-info strong {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.client-info small {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.amount {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}

.row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--t);
}
.data-row:hover .row-actions { opacity: 1; }
.factura-row .row-actions { opacity: 1; }

/* ── 17. Tags / badges ───────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.03em;
  white-space: nowrap;
  flex-shrink: 0;
}
.tag-pending  { background: var(--amber-bg);    color: var(--amber-text); }
.tag-invoiced { background: var(--surface-high); color: var(--text-muted); }
.tag-ok       { background: var(--success-bg);   color: var(--success-text); }
.tag-warning  { background: var(--amber-bg);     color: var(--amber-text); }
.tag-error    { background: var(--error-bg);     color: var(--error-text); }

/* ── 18. Client stats ────────────────────────────────── */
.client-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  grid-column: 1 / -1;
}
.client-stats span { font-weight: 500; }
.stats-sep { font-weight: 400 !important; opacity: 0.5; }

/* ── 18b. Data tables ─────────────────────────────────── */
/* Con el menu lateral desplegado y la ventana estrecha, la tabla se sale de su contenedor.
   Con `overflow: hidden` lo que sobraba quedaba RECORTADO y sin forma de llegar a ello: la
   columna de acciones (el lapiz de editar un cliente) se volvia inalcanzable. Ahora el
   contenido se desplaza, y esa columna se queda pegada a la derecha para no perderla. */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow-x: auto;
}
.data-table td:has(.row-actions),
.data-table thead th:empty {
  position: sticky;
  right: 0;
  background: var(--surface);
  box-shadow: -8px 0 8px -8px rgba(32, 26, 25, 0.18);
}
.data-table thead th:empty { background: var(--bg); }
.data-table tbody tr:hover > td:has(.row-actions) { background: var(--surface-low); }
.data-table tr.editing > td:has(.row-actions) { background: var(--primary-light) !important; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 11px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table th.col-num { text-align: right; }
.data-table td {
  padding: 13px 16px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child > td { border-bottom: none; }
.data-table tbody tr:hover > td { background: var(--surface-low); }
.data-table .row-actions { opacity: 1; }
.data-table tr.editing > td { background: var(--primary-light) !important; }
.data-table tbody tr.clickable-row { cursor: pointer; }
.data-table tbody tr.is-inactive > td:not(:last-child) { opacity: 0.55; }

/* Filtro segmentado de clientes (Activos / Inactivos / Todos) */
.clients-filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.seg-pill {
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.seg-pill:hover { background: var(--surface-low); }
.seg-pill.is-active {
  background: var(--primary-light);
  border-color: var(--primary-container);
  color: var(--primary);
}
.client-detail-header.is-inactive .avatar { opacity: 0.6; }
.tbl-avatar-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  max-width: 100%;
  text-align: left;
}
/* Un nombre largo se corta con puntos suspensivos (el completo queda en el title)
   en vez de ensanchar la columna y empujar al resto de datos. */
.tbl-name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.col-client { max-width: 260px; }
/* Etiqueta + detalle en una sola celda: el aviso de datos incompletos se queda
   dentro de la fila del cliente, sin fila extra que rompa los separadores. */
.cell-stack { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.cell-note {
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--text-muted);
  max-width: 190px;
}
.col-muted { color: var(--text-muted); font-size: 13px; }
.col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* Las celdas con etiqueta + detalle son más altas: alinear arriba evita que el
   resto de columnas quede flotando en mitad de la fila. */
.data-table td:has(.cell-stack) { vertical-align: top; }

/* ── 19. Tab bar ─────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--surface-high);
  padding: 4px;
  border-radius: var(--radius-pill);
  width: fit-content;
}

.tab-btn {
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t), color var(--t);
}
.tab-btn.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(32,26,25,0.08);
}
.tab-btn:hover:not(.active) { background: var(--surface-mid); }

/* ── Inicio: panel de trabajo ─────────────────────────────────────────────────
   "Hoy" (agenda del día) y "Este mes" (cifras de contexto). Sustituyen a las tres
   tarjetas de onboarding en cuanto la cuenta está configurada. */
/* Hoy y Atención comparten fila en escritorio; apilados por debajo de 900px, donde
   dos columnas dejarían las filas demasiado estrechas. */
.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
  /* Separación respecto al panel "Este mes" que viene debajo: sin esto, dos tarjetas
     con borde propio quedaban pegadas y costaba distinguir dónde acaba una y empieza otra. */
  margin-bottom: 20px;
}
@media (max-width: 900px) {
  .home-grid { grid-template-columns: 1fr; }
}

.home-alert-list { display: flex; flex-direction: column; gap: 8px; }
.home-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-high);
  border-left: 3px solid var(--border);
}
.home-alert-primary { background: var(--primary-light); border-left-color: var(--primary); }
.home-alert-warn { background: var(--amber-bg); border-left-color: var(--amber); }
.home-alert-neutral { background: var(--surface-high); border-left-color: var(--border); }
.home-alert-icon { font-size: 21px; color: var(--text-secondary); flex: 0 0 auto; }
.home-alert-primary .home-alert-icon { color: var(--primary); }
.home-alert-warn .home-alert-icon { color: var(--amber-text); }
.home-alert-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.home-alert-title { font-size: 13.5px; font-weight: 500; color: var(--text-primary); }
.home-alert-detail { font-size: 12.5px; color: var(--text-muted); }
.home-alert-action { flex: 0 0 auto; white-space: nowrap; }

@media (max-width: 480px) {
  .home-alert { flex-wrap: wrap; }
  .home-alert-action { margin-left: 33px; }
}

.home-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.home-panel-head h2 { font-size: 16px; font-weight: 500; margin: 0; }
.home-panel-note { font-size: 12.5px; color: var(--text-muted); }

.home-today-list { display: flex; flex-direction: column; gap: 2px; }
.home-today-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  transition: background var(--t);
}
.home-today-row:hover { background: var(--surface-high); }
.home-today-row.is-locked { cursor: default; }
.home-today-row.is-locked:hover { background: transparent; }
.home-today-time {
  flex: 0 0 auto;
  min-width: 54px;
  font-size: 14px;
  font-weight: 500;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.home-today-time.is-untimed { font-size: 11.5px; font-weight: 400; color: var(--text-muted); }
.home-today-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.home-today-client {
  font-size: 14px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-today-service { font-size: 12.5px; color: var(--text-muted); }

.home-add-session {
  width: 100%;
  margin-top: 14px;
}

.home-figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
}
.home-figure { display: flex; flex-direction: column; gap: 2px; }
.home-figure-value { font-size: 22px; font-weight: 500; color: var(--text-primary); }
.home-figure-ok { color: var(--primary); }
.home-figure-warn { color: var(--amber-text); }
.home-figure-label { font-size: 12px; color: var(--text-muted); }

@media (max-width: 640px) {
  .home-figures { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .home-figure-value { font-size: 19px; }
}

/* Aviso previo a restaurar una copia: la operación sustituye todos los datos, así que
   el riesgo tiene que verse antes de tocar nada, no en un toast a posteriori. */
.restore-warning {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--error-bg);
  color: var(--error-text);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.restore-warning-icon { font-size: 22px; flex: 0 0 auto; }
.restore-warning strong { display: block; font-size: 13.5px; font-weight: 500; }
.restore-warning p { margin: 4px 0 0; font-size: 12.5px; line-height: 1.5; }

/* ── Portada de Configuración (sección "Resumen") ─────────────────────────────
   Rejilla de tarjetas agrupadas por bloques, para poder llegar a cualquier ajuste
   sin recordar en qué sección estaba. */
.settings-home-group { margin-bottom: 34px; }
.settings-home-group:last-child { margin-bottom: 0; }
.settings-home-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--primary);
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.settings-home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 14px;
  /* Tope propio: con el ancho completo salían siete columnas y los grupos de dos o tres
     tarjetas quedaban desperdigados. Cuatro columnas es el máximo que se lee de un vistazo. */
  max-width: 1030px;
}
.settings-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 18px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  text-decoration: none;
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
.settings-card:hover {
  border-color: var(--primary-container);
  box-shadow: 0 6px 18px rgba(32,26,25,0.08);
  transform: translateY(-2px);
}
.settings-card-icon {
  font-size: 26px;
  color: var(--primary);
  background: var(--primary-light);
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  margin-bottom: 6px;
}
.settings-card-title { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.settings-card-desc { font-size: 12.5px; line-height: 1.45; color: var(--text-muted); }
.settings-card-go {
  position: absolute;
  top: 20px;
  right: 16px;
  font-size: 18px;
  color: var(--text-muted);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--t), transform var(--t);
}
.settings-card:hover .settings-card-go { opacity: 1; transform: translateX(0); color: var(--primary); }
@media (max-width: 780px) {
  .settings-home-grid { grid-template-columns: 1fr; }
  .settings-card-go { opacity: 1; transform: none; }
}

/* Barra de pestañas de Ajustes (siete secciones). En escritorio la navegación real es
   el submenú del lateral, así que aquí sobra y encima no cabe; solo aparece por debajo
   de 780px, que es donde el lateral desaparece y hace falta otra forma de moverse. */
.tab-bar-scroll { display: none; }
@media (max-width: 780px) {
  .tab-bar-scroll {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .tab-bar-scroll::-webkit-scrollbar { display: none; }
  .tab-bar-scroll .tab-btn { white-space: nowrap; flex: 0 0 auto; }
}

/* ── 19b. Segmented toggle (deslizante) ──────────────── */
.seg-toggle {
  position: relative;
  display: grid;
  /* Tres pestañas desde el 24 ago 2026 (Facturadas · Borradores · Sin cobrar). El control
     está oculto desde que existe el submenú lateral, pero sigue en el DOM: dejarlo cuadrado
     a dos columnas con tres botones lo rompería el día que alguien lo reactive. */
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface-high);
  border-radius: var(--radius-pill);
  padding: 4px;
  width: fit-content;
  margin-bottom: 18px;
}
.seg-indicator {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(33.333% - 3px);
  background: var(--surface);
  border-radius: var(--radius-pill);
  box-shadow: 0 1px 4px rgba(32,26,25,0.12);
  transition: transform 0.3s cubic-bezier(0.34, 1.2, 0.64, 1);
  will-change: transform;
}
.seg-toggle[data-active="draft"] .seg-indicator { transform: translateX(100%); }
.seg-toggle[data-active="unpaid"] .seg-indicator { transform: translateX(200%); }
.seg-btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 24px;
  border: none;
  background: transparent;
  border-radius: var(--radius-pill);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--t);
  white-space: nowrap;
}
.seg-btn.is-active { color: var(--text-primary); }
.seg-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-high);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  transition: background var(--t), color var(--t);
}
.seg-btn.is-active .seg-count {
  background: var(--primary-light);
  color: var(--primary);
}
@media (prefers-reduced-motion: reduce) {
  .seg-indicator { transition: none; }
}

/* ── 20. View toggle (Lista/Calendario) ──────────────── */
.view-toggle {
  display: flex;
  background: var(--surface-high);
  border-radius: var(--radius-pill);
  padding: 3px;
}

.view-toggle-btn {
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t), color var(--t);
}
.view-toggle-btn.active {
  background: var(--surface);
  color: var(--text-primary);
}

/* ── 21. Repeat label ────────────────────────────────── */
.repeat-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
  cursor: pointer;
  user-select: none;
  flex-direction: row;
}
.repeat-label input[type="checkbox"] {
  width: 16px; height: 16px;
  min-height: 16px;
  accent-color: var(--primary-container);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
  border-radius: 4px;
}

/* ── 22. Empty state ─────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 56px 24px;
  gap: 12px;
}
.empty-state-icon {
  font-size: 36px;
  color: var(--text-muted);
  opacity: 0.5;
  margin-bottom: 4px;
}
.empty-state-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
}
.empty-state-body {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 340px;
  line-height: 1.6;
}
.empty-state .btn-primary { margin-top: 4px; }

/* ── 23. Onboarding ──────────────────────────────────── */
.onboarding-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 28px;
  margin-bottom: 24px;
}
.onboarding-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.onboarding-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.onboarding-step {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.onboarding-step:first-child { border-top: none; }

.onboarding-step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface-high);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.onboarding-step.done .onboarding-step-num {
  background: var(--success-bg);
  color: var(--success);
}

.onboarding-step-text { flex: 1; font-size: 14px; color: var(--text-secondary); }
.onboarding-step.done .onboarding-step-text { color: var(--text-muted); text-decoration: line-through; }
.onboarding-step .btn-ghost,
.onboarding-step .btn-secondary { flex-shrink: 0; }

/* ── 24. Readiness bar ───────────────────────────────── */
.readiness-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.readiness-item {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 7px 16px;
  font-size: 13px;
  color: var(--text-secondary);
}
.readiness-check {
  font-size: 14px;
  color: var(--text-muted);
}
.readiness-item.readiness-ok {
  background: var(--success-bg);
  border-color: transparent;
  color: var(--success-text);
}
.readiness-item.readiness-ok .readiness-check { color: var(--success); }

/* ── 25. Billing panel ───────────────────────────────── */
.billing-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.billing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 24px 24px 0;
}
.billing-header h2 {
  font-size: 18px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.billing-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.month-controls {
  display: flex;
  gap: 8px;
}
.month-controls select {
  height: 36px;
  width: auto;
  min-width: 110px;
  font-size: 13px;
  padding: 0 32px 0 14px;
}

.billing-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 20px 24px 16px;
}
.billing-toolbar input[type="search"] {
  flex: 1;
  min-width: 200px;
  height: 38px;
}

.invoice-list {
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 8px;
}

/* Columna de checkbox de selección (facturar mes, sesiones sueltas) */
.data-table .col-check { width: 44px; text-align: center; }
.data-table td.col-check { padding-left: 16px; padding-right: 0; }
.billing-row { cursor: pointer; }
.billing-row > td { transition: background var(--t); }
.billing-row.selected > td { background: var(--surface-low); }
.billing-row.selected > td:first-child { box-shadow: inset 3px 0 0 var(--primary-container); }
.billing-row:hover > td { background: var(--surface-mid); }

.billing-table input[type="checkbox"] {
  width: 17px; height: 17px; min-height: 17px;
  accent-color: var(--primary-container);
  pointer-events: none;
  vertical-align: middle;
}

.billing-warn-row > td {
  padding-top: 0 !important;
  border-bottom: none;
}
.billing-warn-row:hover > td { background: transparent !important; }
.billing-candidate-hint {
  font-size: 12px;
  color: var(--amber);
}

/* Fila "Dividir facturación": el cliente entero se aparca (no cuenta para el lote)
   mientras se elige a mano qué sesiones suyas van juntas. */
.billing-row.is-splitting { cursor: default; }
.billing-row.is-splitting > td { background: var(--surface-low); }
.billing-split-row > td { padding: 0 0 16px; border-bottom: none; }
.billing-split-row:hover > td { background: transparent !important; }
.billing-split-panel {
  background: var(--surface-low);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
}
.billing-split-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.billing-split-sessions {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.billing-split-sessions li + li { border-top: 1px solid var(--border); }
/* Pisa el "label { flex-direction: column }" genérico de formularios: aquí es una fila
   de lista (checkbox · texto · precio en una sola línea), no un campo con etiqueta arriba. */
.billing-split-sessions li label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: normal;
  color: var(--text-primary);
  cursor: pointer;
}
.billing-split-sessions li label:hover { background: var(--surface-mid); }
.billing-split-sessions input[type="checkbox"] {
  flex: 0 0 auto;
  width: 17px; height: 17px; min-height: 17px;
  accent-color: var(--primary-container);
  pointer-events: auto;
}
.billing-split-session-info { flex: 1 1 auto; min-width: 0; }
.billing-split-sessions .col-num { flex: 0 0 auto; color: var(--text-secondary); }
.billing-split-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.billing-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  border-radius: 0 0 var(--radius-card) var(--radius-card);
}
.billing-footer-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: block;
  margin-bottom: 3px;
}
.billing-footer-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}
.billing-total-selected {
  display: flex;
  align-items: center;
  gap: 20px;
}
.total-selected-amount { text-align: right; }
.total-selected-amount .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 3px;
}
.total-selected-amount .value {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

/* Results card */
.results-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 28px;
  margin-top: 16px;
}
.results-card h2 {
  font-size: 18px;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.results-summary { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; }
.results-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.results-list li { font-size: 13px; color: var(--text-secondary); padding: 4px 0; border-bottom: 1px solid var(--border); }
.results-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── 26. Facturas KPIs ───────────────────────────────── */
.facturas-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px;
  margin-bottom: 20px;
}

/* ── 27. Facturas chart ──────────────────────────────── */
.factura-chart-wrap {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 24px 20px 16px;
  margin-bottom: 20px;
}
.factura-chart-wrap::before {
  content: "Facturación por mes";
  display: block;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.chart-bar         { fill: #7BBF8E; cursor: default; transition: fill 0.12s; }
.chart-bar:hover   { fill: var(--primary-container); }
.chart-bar-current { fill: var(--primary-container); }
.chart-bar-future  { fill: var(--surface-high); }
.chart-bar-empty   { fill: var(--border); }
.chart-month-label { font-size: 10px; fill: var(--text-muted); font-family: inherit; }
.chart-month-current { fill: var(--text-primary); font-weight: 700; }
.chart-empty-msg   { font-size: 13px; fill: var(--text-muted); font-family: inherit; }
.chart-tooltip {
  position: absolute;
  background: var(--text-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  pointer-events: none;
  white-space: nowrap;
  transform: translateX(-50%);
  z-index: 10;
}

/* ── 27b. Datos (analítica) ──────────────────────────── */
.datos-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 4px 0 14px;
}
.datos-section-head:not(:first-child) { margin-top: 28px; }
.datos-section-head h2 {
  font-size: 17px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
}
.datos-month-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.datos-head-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.datos-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px 22px;
  margin-bottom: 20px;
  min-width: 0;
}
.datos-card-title {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin: 0 0 14px;
}
.datos-empty {
  text-align: center !important;
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px 16px !important;
}
.datos-empty-inline { color: var(--text-muted); font-size: 13px; padding: 6px 0; }

/* KPI deltas (comparativa interanual) */
.kpi-delta {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: -2px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
}
.kpi-delta.delta-up   { background: var(--success-bg); color: var(--success-text); }
.kpi-delta.delta-down { background: var(--error-bg);   color: var(--error-text); }
.kpi-delta.delta-flat { background: var(--surface-high); color: var(--text-muted); }
.kpi-subnote { margin-top: -2px; font-size: 12px; color: var(--text-muted); }

/* Fila anillo + gráfica */
.datos-row {
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr;
  gap: 20px;
  margin-top: 4px;
  margin-bottom: 20px;
}
.datos-row .datos-card,
.datos-row .factura-chart-wrap { margin-bottom: 0; }

/* Anillo de cobros */
.datos-ring-card { display: flex; flex-direction: column; }
.ring-wrap {
  position: relative;
  width: 152px;
  height: 152px;
  margin: 6px auto 20px;
}
.ring-svg { width: 100%; height: 100%; }
.ring-track { fill: none; stroke: var(--surface-high); stroke-width: 11; }
.ring-progress {
  fill: none;
  stroke: var(--primary-container);
  stroke-width: 11;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.7s cubic-bezier(0.34, 1.1, 0.64, 1);
}
.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.ring-pct { font-size: 32px; font-weight: 300; color: var(--text-primary); line-height: 1; letter-spacing: -0.02em; }
.ring-center small {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.ring-stats { display: flex; flex-direction: column; margin-top: auto; }
.ring-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.ring-stat-label { color: var(--text-muted); }
.ring-stat-val { font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* Reparto por servicio (barras) */
.dist-list { display: flex; flex-direction: column; gap: 16px; }
.dist-row { display: flex; flex-direction: column; gap: 7px; }
.dist-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.dist-name { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.dist-count { font-size: 12px; font-weight: 400; color: var(--text-muted); }
.dist-val { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.dist-pct { color: var(--text-muted); font-weight: 500; margin-left: 4px; }
.dist-track { height: 8px; background: var(--surface-high); border-radius: var(--radius-pill); overflow: hidden; }
.dist-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #7BBF8E, var(--primary-container));
  border-radius: var(--radius-pill);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Pastilla de % (top clientes) */
.share-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

@media (max-width: 860px) {
  .datos-row { grid-template-columns: 1fr; }
}

/* ── 28. Facturas toolbar ────────────────────────────── */
.facturas-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.facturas-toolbar select,
.facturas-toolbar input {
  height: 38px;
  width: auto;
  min-width: 130px;
  font-size: 13px;
  padding: 0 32px 0 14px;
}
.facturas-toolbar input { padding: 0 16px; min-width: 180px; }

/* ── 29. Factura rows ────────────────────────────────── */
.facturas-list { display: flex; flex-direction: column; gap: 8px; }

.factura-wrap { display: flex; flex-direction: column; }

.factura-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px 18px;
  transition: background var(--t);
  cursor: pointer;
}
.factura-row:hover { background: var(--surface-low); }
/* Los botones de acción conservan el cursor normal de botón. */
.factura-row button { cursor: pointer; }
.factura-row.cobrada { opacity: 0.72; }
.factura-row.expanded { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

.factura-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 90px;
}

/* Enlace de texto en línea (p. ej. "Rectificada por INV/2026/00012" dentro de un <small>) */
.link-inline {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: inherit;
  color: var(--primary);
  text-decoration: underline;
  text-decoration-color: transparent;
  cursor: pointer;
  transition: text-decoration-color var(--t);
}
.link-inline:hover, .link-inline:focus-visible { text-decoration-color: currentColor; }

.factura-expand {
  flex-shrink: 0;
  width: 32px; min-width: 32px; height: 32px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t), color var(--t);
}
.factura-expand:hover { background: var(--primary-light); color: var(--primary); }
.factura-row.expanded .factura-expand { background: var(--primary-light); color: var(--primary); }

.factura-chevron {
  font-size: 22px;
  display: block;
  color: inherit;
  transition: transform 0.25s ease;
}
.factura-chevron.is-open { transform: rotate(180deg); }

.factura-sessions-detail {
  background: var(--surface-low);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-card) var(--radius-card);
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.factura-session-item {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.factura-session-item:last-child { border-bottom: none; padding-bottom: 0; }
.factura-session-date { color: var(--text-primary); font-weight: 500; }
.factura-session-price { font-weight: 500; color: var(--text-primary); text-align: right; }
.factura-sessions-empty { font-size: 13px; color: var(--text-muted); margin: 0; text-align: center; padding: 8px 0; }

/* ── 30. Ajustes ─────────────────────────────────────── */
.ajustes-single { max-width: none; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 28px;
}
.panel-header h2 {
  font-size: 18px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.panel-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.fiscal-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.fiscal-card-body { flex: 1; }
.fiscal-field-main {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.fiscal-field-row {
  display: flex;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 5px 0;
  border-top: 1px solid var(--border);
}
.fiscal-field-label { color: var(--text-muted); min-width: 80px; }
.fiscal-edit-btn { flex-shrink: 0; }

.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.settings-section h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 12px;
}

/* ── Selector de plantilla de factura ────────────────── */
.template-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 0 0 auto;
  margin-top: 10px;
}
.template-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 118px;
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
.template-card:hover { border-color: var(--primary-container); transform: translateY(-1px); }
/* Dos estados distintos y a la vez: "is-previewing" es la que se está mirando
   (contorno neutro) y "is-selected" la que se usa de verdad en las facturas (verde
   + marca). Pueden coincidir, y entonces gana el verde. */
.template-card.is-previewing {
  border-color: var(--text-secondary);
  box-shadow: 0 0 0 3px rgba(63, 82, 68, 0.10);
}
.template-card.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 92, 58, 0.12);
}
.template-name { font-size: 12.5px; font-weight: 500; color: var(--text-primary); }
.template-card.is-selected .template-name { color: var(--primary); }
/* Marca de "esta es la que usas", para no depender solo del color del borde. */
.template-card.is-selected .template-name::after {
  content: " ✓";
  font-weight: 600;
}

/* Miniatura de cada plantilla: una "hoja" A4 en miniatura dibujada solo con CSS. */
.template-thumb {
  position: relative;
  width: 96px;
  height: 128px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(32,26,25,0.08);
}
.template-thumb .tt-row {
  position: absolute;
  left: 10px; right: 10px;
  height: 14px;
  background: #eceae1;
  border-radius: 2px;
}
.template-thumb .tt-row.short { right: 40px; }
.template-thumb .tt-total {
  position: absolute;
  left: 10px; right: 10px; bottom: 10px;
  height: 12px;
  border-radius: 2px;
}

/* Clásica: línea verde superior + panel suave + total verde redondeado */
.template-thumb-classic .tt-head {
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: #2d5c3a;
}
.template-thumb-classic .tt-row { top: 30px; background: #f4f8f5; border: 0.5px solid #e4efe6; height: 30px; }
.template-thumb-classic .tt-row.short { top: 68px; height: 10px; }
.template-thumb-classic .tt-total { background: #2d5c3a; }

/* Moderna: banda oscura superior + cabecera de tabla oscura + total oscuro */
.template-thumb-modern .tt-band {
  position: absolute; top: 0; left: 0; right: 0; height: 32px;
  background: #0f172a;
}
.template-thumb-modern .tt-row { top: 46px; background: #0f172a; height: 8px; }
.template-thumb-modern .tt-row.short { top: 62px; background: #e2e8f0; height: 22px; }
.template-thumb-modern .tt-total { background: #0f172a; }

/* Minimalista: monocromo, sin bloques de color, todo a base de líneas finas */
.template-thumb-minimal .tt-head {
  position: absolute; top: 26px; left: 10px; right: 10px; height: 1px;
  background: #111;
}
.template-thumb-minimal .tt-row { top: 44px; background: transparent; border-bottom: 1px solid #dcdcdc; height: 16px; border-radius: 0; }
.template-thumb-minimal .tt-row.short { top: 68px; height: 10px; }
.template-thumb-minimal .tt-total { background: transparent; border-top: 1.5px solid #111; border-radius: 0; height: 0; bottom: 14px; }

.numeracion-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 10px 18px;
  width: fit-content;
}
.chip-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.chip-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

/* ── 31. Calendar ────────────────────────────────────── */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.calendar-month-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0 0 10px;
}
.calendar-day-header {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  text-transform: uppercase;
  padding: 8px 0;
  background: var(--bg);
}
.calendar-day {
  min-height: 92px;
  padding: 5px;
  cursor: default;
  transition: background var(--t);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  overflow: hidden;
  background: var(--surface);
}
.calendar-day:hover { background: var(--surface-low); }
.calendar-day.other-month { background: var(--bg); }
.calendar-day.other-month:hover { background: var(--bg); }
.calendar-day.other-month .calendar-day-num { color: var(--text-muted); font-weight: 400; opacity: 0.6; }
.calendar-day.selected { background: var(--primary-light); box-shadow: inset 0 0 0 1px var(--primary-container); }
.calendar-day.has-sessions { cursor: pointer; }
.calendar-day-head { display: flex; align-items: center; justify-content: space-between; }
.calendar-day.today .calendar-day-num {
  background: var(--primary-container);
  color: var(--on-primary);
  border-radius: 50%;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
}
.calendar-day-num {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}
.calendar-day-add {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; padding: 0; border-radius: 50%;
  border: 0; background: none; color: var(--text-muted); cursor: pointer;
  opacity: 0; transition: opacity var(--t), background var(--t), color var(--t);
}
.calendar-day:hover .calendar-day-add { opacity: 1; }
.calendar-day-add:hover { background: var(--primary-light); color: var(--primary); }
.calendar-chip {
  width: 100%; box-sizing: border-box;
  padding: 2px 6px; font-size: 10.5px; font-weight: 600;
  text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.calendar-more {
  font-size: 10px; font-weight: 600; color: var(--text-muted); padding: 1px 6px;
}
.calendar-detail {
  margin-top: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.calendar-detail-row { cursor: pointer; }
.calendar-detail-row.is-locked { cursor: default; opacity: 0.75; }
.calendar-detail-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── 32. Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(32,26,25,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 28px;
  max-width: 380px;
  width: calc(100% - 40px);
  box-shadow: 0 8px 32px rgba(32,26,25,0.15);
}
.modal-box h3 {
  font-size: 17px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}
.modal-box p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── 33. Toast ───────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--text-primary);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 400;
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  max-width: 340px;
  pointer-events: none;
  border-left: 3px solid transparent;
}
.toast.toast-success { border-left-color: #7BBF8E; }

/* Toast con acción "Deshacer" (al registrar sesiones). A diferencia del toast
   normal, sí recibe clics, y lleva una barrita que se va vaciando para avisar
   de cuánto tiempo queda para deshacer. */
.toast.toast-undo {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 380px;
  position: relative;
  overflow: hidden;
  padding-bottom: 15px;
}
.toast-undo-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #7BBF8E;
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.toast-undo-btn:hover { color: #FFFFFF; }
.toast-progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: rgba(255,255,255,0.3);
  transform-origin: left;
  animation-name: toast-progress-shrink;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
@keyframes toast-progress-shrink {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* ── 35. Responsive ──────────────────────────────────── */
@media (max-width: 780px) {
  /* El sidebar vuelve a ser visible en móvil, pero como barra estrecha por
     defecto: sin iconos de navegación, solo el botón para desplegar el menú
     (a diferencia del raíl de escritorio, que sí muestra iconos). */
  .sidebar {
    display: flex;
    width: var(--sidebar-w-collapsed);
    transition: width 0.2s ease, box-shadow 0.2s ease;
  }
  body.sidebar-collapsed .sidebar .brand {
    justify-content: center;
    padding: 20px 8px;
  }
  body.sidebar-collapsed .sidebar .brand-mark,
  body.sidebar-collapsed .sidebar .brand-text,
  body.sidebar-collapsed .sidebar .sidebar-nav-scroll,
  body.sidebar-collapsed .sidebar .sidebar-footer {
    display: none;
  }
  body.sidebar-collapsed .sidebar .sidebar-collapse-btn { margin-left: 0; }

  /* Cajón abierto: flota encima del contenido (no lo empuja), con sombra y
     un fondo oscuro detrás para poder cerrarlo tocando fuera. */
  body:not(.sidebar-collapsed) .sidebar {
    width: min(var(--sidebar-w), 82vw);
    box-shadow: 6px 0 28px rgba(0,0,0,0.28);
  }
  body:not(.sidebar-collapsed) .sidebar-backdrop { display: block; }

  .app-shell,
  body.sidebar-collapsed .app-shell,
  body:not(.sidebar-collapsed) .app-shell {
    margin-left: var(--sidebar-w-collapsed);
    padding: 24px 16px 40px;
  }

  .template-picker-layout { flex-direction: column; }
  .template-picker { flex-direction: row; flex-wrap: wrap; }
  .template-preview-pane { max-width: none; width: 100%; }

  .page-header h1 { font-size: 24px; }

  .summary-grid,
  .facturas-kpis {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }

  .action-grid { grid-template-columns: 1fr; }

  .form-grid { grid-template-columns: 1fr; }

  .billing-footer { flex-direction: column; align-items: stretch; }
  .billing-total-selected { justify-content: space-between; }

  .month-controls { flex-wrap: wrap; }

  .facturas-toolbar { flex-direction: column; align-items: stretch; }
  .facturas-toolbar select,
  .facturas-toolbar input { width: 100%; }

  .factura-row { flex-wrap: wrap; }

  .factura-session-item { grid-template-columns: 1fr auto; }
  .factura-session-svc { grid-column: 1; font-size: 12px; }
  .factura-session-price { grid-row: 1; }

  .calendar-day { min-height: 60px; padding: 3px; }
  .calendar-day-num { font-size: 11px; }
  .calendar-chip { font-size: 9.5px; padding: 1px 4px; }

  .toast-container { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: 100%; }
}

@media (max-width: 480px) {
  .summary-grid,
  .facturas-kpis {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
  .stat-value { font-size: 24px; }
}

/* ── 36. Flatpickr overrides ─────────────────────────── */

/* Reset our global input/select styles inside Flatpickr */
.flatpickr-calendar select,
.flatpickr-calendar input[type="number"] {
  height: auto !important;
  min-height: auto !important;
  background-image: none !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 2px !important;
  width: auto !important;
  font-weight: 500 !important;
}
.flatpickr-calendar select:focus,
.flatpickr-calendar input[type="number"]:focus {
  border: none !important;
  box-shadow: none !important;
}

/* Calendar container */
.flatpickr-calendar {
  font-family: var(--font) !important;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: 0 8px 28px rgba(0,0,0,0.12);
  padding: 12px;
  /* La rejilla de dias (.dayContainer/.flatpickr-days) trae de flatpickr un ancho fijo
     de 307.875px que no se puede encoger; el padding de 12px por lado hay que sumarlo
     aparte o la ultima columna (domingo) queda cortada. */
  width: calc(307.875px + 24px);
  background: var(--surface);
}

/* Remove the pointing arrow/nub */
.flatpickr-calendar.arrowTop::before,
.flatpickr-calendar.arrowTop::after,
.flatpickr-calendar.arrowBottom::before,
.flatpickr-calendar.arrowBottom::after { display: none; }

/* Month header */
.flatpickr-months { padding-bottom: 6px; }
.flatpickr-months .flatpickr-month {
  background: transparent;
  color: var(--text-primary);
  fill: var(--text-primary);
  height: 36px;
}
.flatpickr-current-month {
  font-size: 14px;
  font-weight: 500;
  padding-top: 6px;
}
.flatpickr-current-month .flatpickr-monthDropdown-months {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
}
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
  fill: var(--text-muted);
  padding-top: 8px;
}
.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg { fill: var(--primary); }

/* Weekday row */
.flatpickr-weekdays { background: transparent; }
span.flatpickr-weekday {
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Day cells */
.flatpickr-day {
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 400;
  border: 1px solid transparent;
  height: 36px;
  line-height: 36px;
  /* Sin max-width: flatpickr reparte cada dia al 14.2857% del ancho (igual que las
     cabeceras de dia de la semana). Un max-width menor que ese % desalinea las columnas
     y hace que cada fila "derive" respecto a la cabecera (bug real observado). */
}
.flatpickr-day:hover:not(.flatpickr-disabled):not(.selected):not(.today) {
  background: var(--primary-light);
  border-color: transparent;
  color: var(--text-primary);
}
.flatpickr-day.selected,
.flatpickr-day.selected:focus,
.flatpickr-day.selected:hover {
  background: var(--primary-container);
  border-color: var(--primary-container);
  color: var(--on-primary);
}
.flatpickr-day.today:not(.selected) {
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
}
.flatpickr-day.today:not(.selected):hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
  color: var(--border);
}
.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover {
  color: var(--border);
}

/* Alt input (visible date field) */
.date-input-alt {
  /* !important: la regla generica de inputs (input:not([type=checkbox]):not([type=radio]))
     tiene mas especificidad (usa :not() con selectores de atributo) y su `background`/
     `padding` en formato abreviado, si no se fuerza, se come el icono y el hueco para el. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7E6F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-size: 16px !important;
  padding-right: 38px !important;
  cursor: pointer;
}

/* =====================================================
   BACKEND INTEGRATION — añadidos sobre el diseño base
   ===================================================== */

/* ── Notice banner ───────────────────────────────────── */
.notice {
  margin: 0 0 22px;
  padding: 13px 18px;
  border: 1px solid rgba(78, 139, 95, 0.28);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
}
.notice.error {
  border-color: rgba(186, 26, 26, 0.34);
  background: var(--error-bg);
  color: var(--error-text);
}

/* ── Banner de verificación de email ─────────────────── */
.verify-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 22px;
  padding: 14px 18px;
  border: 1px solid rgba(122, 71, 0, 0.22);
  border-radius: var(--radius-sm);
  background: var(--amber-bg);
  color: var(--amber-text);
}
.verify-banner-icon { font-size: 24px; flex-shrink: 0; }
.verify-banner-body { flex: 1; min-width: 0; }
.verify-banner-body strong { display: block; font-weight: 600; }
.verify-banner-body p { margin: 2px 0 0; font-size: 13px; color: var(--amber-text); opacity: 0.85; }
.verify-banner .btn-secondary { flex-shrink: 0; }
@media (max-width: 640px) {
  .verify-banner { flex-wrap: wrap; }
  .verify-banner .btn-secondary { width: 100%; }
}

/* ── Logout link (sidebar footer) ────────────────────── */
.sidebar-logout {
  display: inline-flex;
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-sidebar);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.sidebar-logout:hover { color: var(--text-sidebar-active); }

/* Disparador de feedback: visible desde cualquier pantalla pero sin competir con la
   navegación — por eso vive en el pie y no como una entrada más del menú. */
.sidebar-feedback {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  margin-top: 12px;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-sidebar);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.sidebar-feedback:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.28);
  color: #fff;
}
.sidebar-feedback .material-symbols-outlined { font-size: 16px; }

/* ── Modal de feedback ──────────────────────────────── */
.feedback-box { max-width: 460px; width: 100%; }
.feedback-intro {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.5;
}
.feedback-faces { display: flex; gap: 8px; margin-bottom: 14px; }
.feedback-face {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 6px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  font-family: var(--font);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.feedback-face:hover { border-color: var(--primary-container); }
.feedback-face.is-active {
  border-color: var(--primary);
  background: var(--primary-light);
}
.feedback-face-icon { font-size: 22px; line-height: 1; }
.feedback-face-label { font-size: 11.5px; color: var(--text-secondary); }
.feedback-face.is-active .feedback-face-label { color: var(--primary); font-weight: 500; }

#feedbackMessage {
  width: 100%;
  min-height: 190px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  resize: vertical;
}
#feedbackMessage:focus { outline: none; border-color: var(--primary-container); }
.feedback-note {
  margin: 8px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-muted);
}
.help-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Declaración responsable del SIF (Ayuda › Cumplimiento normativo) ── */
.declaracion-datos { display: grid; gap: 8px; margin: 0 0 16px; }
.declaracion-datos > div { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: baseline; }
.declaracion-datos dt { color: var(--text-muted); font-size: 13px; }
.declaracion-datos dd { margin: 0; color: var(--text-primary); font-size: 14px; }
.declaracion-datos code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--surface-mid); padding: 1px 6px; border-radius: 4px; font-size: 13px;
}
.declaracion-estado {
  border-left: 3px solid var(--border); border-radius: 8px;
  padding: 12px 14px; margin: 0 0 12px; font-size: 14px; line-height: 1.6;
  background: var(--surface-low); color: var(--text-secondary);
}
.declaracion-estado.declaracion-ok { border-left-color: var(--success); background: var(--success-bg); color: var(--success-text); }
.declaracion-estado.declaracion-pendiente { border-left-color: var(--amber); background: var(--amber-bg); color: var(--amber-text); }
.declaracion-nota { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin: 0 0 16px; }
@media (max-width: 640px) {
  .declaracion-datos > div { grid-template-columns: 1fr; gap: 2px; }
}

/* ── Auth / login screen ─────────────────────────────── */
body.auth-locked .sidebar,
body.auth-locked .app-shell { display: none; }
body:not(.auth-locked) .auth-screen { display: none; }

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 44px);
  background:
    radial-gradient(1100px 560px at 100% 0%, rgba(78, 139, 95, 0.10), transparent 60%),
    var(--bg);
}
.auth-card {
  width: min(1060px, 100%);
  min-height: min(660px, calc(100vh - 48px));
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 30px 80px rgba(44, 40, 37, 0.14);
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(340px, 0.92fr);
  overflow: hidden;
}

/* Columna izquierda: formularios */
.auth-forms {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 5vw, 56px);
}
.auth-brand-sm {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  font-weight: 600;
  font-size: 16px;
  color: var(--text-primary);
}
.auth-brand-sm .brand-mark {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-form h2 {
  font-size: 24px;
  font-weight: 500;
  margin: 0;
}
.auth-sub {
  margin: -4px 0 8px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}
.auth-form label input {
  min-height: 46px;
}
.btn-google {
  width: 100%;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 14px;
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
.btn-google:hover {
  border-color: rgba(45, 92, 58, 0.42);
  box-shadow: 0 10px 24px rgba(44, 40, 37, 0.08);
  transform: translateY(-1px);
}
.google-mark {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.google-mark svg { display: block; }
.field-hint {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
}
.minor-req {
  color: var(--error);
  font-weight: 600;
}

/* Fila del toggle "menor de edad" */
.minor-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card, 16px);
  background: var(--surface);
}
.minor-toggle-copy { display: flex; flex-direction: column; gap: 2px; }
.minor-toggle-title { font-weight: 500; color: var(--text-primary); }
.minor-toggle-sub { font-size: 12px; color: var(--text-muted); }

/* Interruptor deslizante on/off */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex: none;
  cursor: pointer;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 9999px;
  transition: background 0.2s ease;
}
.switch-slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}
.switch input:checked + .switch-slider { background: var(--primary-container); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }
.switch input:focus-visible + .switch-slider {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Sección de datos del tutor (aparece al activar el toggle) */
/* Mismo trato que el resto del formulario: un bloque agrupado, no un panel de otro color.
   Antes tenia fondo tintado y un filete grueso a la izquierda, y cantaba dentro de la ficha.
   Ojo con --surface-low: es el tono calido de hover (rosado), y como fondo de panel canta
   igual que el verde anterior. --bg es el fondo neutro de la propia aplicacion. */
.guardian-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card, 16px);
  background: var(--bg);
}
.guardian-section-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text-muted);
}
.guardian-section-title {
  margin: 0;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-primary);
}
.guardian-hint {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 2px 0 0;
}
.modal-input {
  width: 100%;
  margin-top: 4px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill, 9999px);
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
}
.modal-input:focus {
  outline: none;
  border-color: var(--primary-container);
  box-shadow: 0 0 0 3px rgba(45, 92, 58, 0.12);
}
textarea.modal-input {
  border-radius: var(--radius-card);
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
}

/* Editor de líneas de la rectificativa por sustitución (corregir importe) */
.rectify-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 2px;
}
.rectify-line-row {
  display: grid;
  grid-template-columns: 1fr auto 88px;
  align-items: center;
  gap: 10px;
}
.rectify-line-desc {
  font-size: 13px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rectify-line-old {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: line-through;
  white-space: nowrap;
}
.rectify-line-input {
  margin-top: 0;
  padding: 6px 10px;
  font-size: 13px;
  text-align: right;
  border-radius: var(--radius-xs);
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--border);
}
.auth-link-inline {
  align-self: flex-end;
  margin-top: -4px;
  padding: 3px 2px;
  border: 0;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  border-radius: var(--radius-xs);
  transition: color var(--t);
}
.auth-link-inline::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 1px;
  height: 1.5px;
  background: currentColor;
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: right center;
  transition: transform 0.25s ease;
}
.auth-link-inline:hover { color: var(--primary); }
.auth-link-inline:hover::after {
  transform: scaleX(1);
  transform-origin: left center;
}
.auth-link-inline:focus-visible {
  outline: none;
  color: var(--primary);
  box-shadow: 0 0 0 3px rgba(78,139,95,0.2);
}
@media (prefers-reduced-motion: reduce) {
  .auth-link-inline::after { transition: none; }
}
.auth-switch {
  margin: 8px 0 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.auth-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}
.auth-link:hover { text-decoration: underline; }
.auth-message {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--error);
  font-weight: 500;
  font-size: 13px;
}
.auth-message[data-type="info"] { color: var(--text-secondary); }
.auth-message[data-type="success"] { color: var(--success-text); }

.pw-wrapper {
  position: relative;
  display: flex;
}
.pw-wrapper input {
  flex: 1;
  padding-right: 48px !important;
}
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  transition: color var(--t), background var(--t);
  -webkit-tap-highlight-color: transparent;
}
.pw-toggle:hover {
  color: var(--text-secondary);
  background: var(--surface-mid);
}
.pw-toggle:active {
  background: var(--surface-high);
}
.pw-toggle:focus-visible {
  outline: none;
  color: var(--primary-container);
  box-shadow: 0 0 0 3px rgba(78,139,95,0.25);
}
.pw-icon {
  position: absolute;
  width: 20px;
  height: 20px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.pw-icon-eye {
  opacity: 1;
  transform: scale(1) rotate(0);
}
.pw-icon-eye-off {
  opacity: 0;
  transform: scale(0.6) rotate(-12deg);
}
.pw-toggle.is-visible .pw-icon-eye {
  opacity: 0;
  transform: scale(0.6) rotate(12deg);
}
.pw-toggle.is-visible .pw-icon-eye-off {
  opacity: 1;
  transform: scale(1) rotate(0);
}
@media (prefers-reduced-motion: reduce) {
  .pw-icon { transition: opacity 0.2s ease; }
  .pw-icon-eye, .pw-icon-eye-off,
  .pw-toggle.is-visible .pw-icon-eye,
  .pw-toggle.is-visible .pw-icon-eye-off { transform: none; }
}

/* Columna derecha: panel de marca */
.auth-promo {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(32px, 5vw, 56px);
  color: #fff;
  background:
    radial-gradient(820px 460px at 100% 100%, rgba(123, 191, 142, 0.32), transparent 55%),
    linear-gradient(150deg, var(--primary) 0%, #244c30 58%, #1c3d27 100%);
}
.auth-promo .eyebrow {
  margin-bottom: 8px;
  color: var(--text-sidebar-active);
}
.auth-promo h1 {
  margin: 0 0 8px;
  font-size: clamp(32px, 4vw, 46px);
  font-weight: 300;
  letter-spacing: -0.01em;
  line-height: 1.08;
  color: #fff;
}
.auth-promo-text {
  max-width: 440px;
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 15px;
  line-height: 1.6;
}
.auth-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}
.auth-highlights span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-pill);
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 500;
}

@media (max-width: 860px) {
  .auth-screen { align-items: stretch; padding: 0; }
  .auth-card {
    min-height: 100vh;
    grid-template-columns: 1fr;
    border-radius: 0;
    border: 0;
  }
  .auth-promo { display: none; }
}

/* ── Collapsible "más datos" sections in forms ───────── */
.form-more {
  border: none;
  background: transparent;
  padding: 4px 0;
  color: var(--primary-container);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.form-more:hover { color: var(--primary); }
.form-more-panel { display: grid; gap: 16px; }

/* ── Invoice detail (backend) inside factura expand ──── */
.factura-detail {
  background: var(--surface-low);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-card) var(--radius-card);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.factura-detail .invoice-totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 18px;
  margin: 0;
}
.factura-detail .invoice-totals div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.factura-detail .invoice-totals dt { color: var(--text-muted); }
.factura-detail .invoice-totals dd { color: var(--text-primary); font-weight: 500; margin: 0; }

.detail-section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.issue-blockers {
  background: var(--amber-bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--amber-text);
}
.issue-blockers strong { display: block; margin-bottom: 4px; }
.issue-blockers ul { margin: 0; padding-left: 18px; }

.payment-line,
.event-line,
.integrity-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-secondary);
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.payment-line:last-child,
.event-line:last-child,
.integrity-line:last-child { border-bottom: none; }

/* Status pill tones for backend invoice statuses */
.tag-neutral { background: var(--surface-high); color: var(--text-muted); }
.tag-sent    { background: #dbeafe;             color: #1d4ed8; }
.tag-void    { background: var(--surface-high); color: var(--text-muted); text-decoration: line-through; }

/* Ajustes — herramientas extra */
.tools-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.tools-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 10px;
}

/* ── Tour guiado (onboarding interactivo) ────────────── */
.onboarding-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.tour-root {
  position: fixed;
  inset: 0;
  z-index: 1200;
  pointer-events: none;
}
.tour-spotlight {
  position: fixed;
  top: 0; left: 0;
  width: 0; height: 0;
  border-radius: 14px;
  box-shadow: 0 0 0 2px var(--primary-container), 0 0 0 9999px rgba(26, 32, 27, 0.55);
  transition: top 0.32s cubic-bezier(0.4,0,0.2,1), left 0.32s cubic-bezier(0.4,0,0.2,1),
              width 0.32s cubic-bezier(0.4,0,0.2,1), height 0.32s cubic-bezier(0.4,0,0.2,1);
  pointer-events: none;
}
.tour-pop {
  position: fixed;
  width: min(340px, calc(100vw - 24px));
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: 0 16px 48px rgba(26, 32, 27, 0.30);
  padding: 18px 20px 16px;
  pointer-events: auto;
  transition: top 0.28s cubic-bezier(0.4,0,0.2,1), left 0.28s cubic-bezier(0.4,0,0.2,1);
}
.tour-pop-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.tour-step-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary-container);
}
.tour-skip {
  background: none;
  border: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  padding: 2px 2px;
}
.tour-skip:hover { color: var(--text-secondary); text-decoration: underline; }
.tour-secondary-link {
  display: block;
  background: none;
  border: 0;
  color: var(--primary-container);
  font-size: 12.5px;
  font-family: var(--font);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  padding: 0;
  margin-top: 8px;
}
.tour-secondary-link:hover { text-decoration: underline; }
.tour-pop-title {
  font-size: 16px;
  font-weight: 500;
  margin: 0 0 6px;
  color: var(--text-primary);
}
.tour-pop-body {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0;
}
.tour-pop-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  min-height: 30px;
}
.tour-dots { display: flex; gap: 6px; flex-wrap: wrap; }
.tour-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--surface-high);
  transition: background var(--t), transform var(--t);
}
.tour-dot.is-active { background: var(--primary-container); transform: scale(1.25); }
.tour-dot.is-done { background: var(--primary-light); }
.tour-nav { display: flex; align-items: center; gap: 8px; }
.tour-nav button:disabled { opacity: 0.35; cursor: default; pointer-events: none; }

/* Tarjeta de bienvenida / final: más grande y centrada */
.tour-pop.is-intro {
  width: min(460px, calc(100vw - 24px));
  padding: 30px 32px 26px;
  text-align: center;
}
.tour-pop.is-intro .tour-pop-head { justify-content: flex-end; margin-bottom: 4px; }
.tour-pop.is-intro .tour-pop-title { font-size: 24px; margin-bottom: 10px; }
.tour-pop.is-intro .tour-pop-body { font-size: 15px; line-height: 1.55; }
.tour-pop.is-intro .tour-pop-foot { justify-content: center; margin-top: 22px; }
.tour-pop.is-intro .tour-primary { padding: 11px 32px; font-size: 15px; }

@media (prefers-reduced-motion: reduce) {
  .tour-spotlight, .tour-pop { transition: none; }
}

/* ── Avatar con foto / tamaños / pila ─────────────────── */
.avatar-photo { background: var(--surface-high); overflow: hidden; padding: 0; }
.avatar-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.avatar.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-stack { display: inline-flex; flex-shrink: 0; }
.avatar-stack > .avatar { margin-left: -10px; box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack > .avatar:first-child { margin-left: 0; }
.avatar-more { background: var(--primary-light); color: var(--primary); font-weight: 600; }

/* ── Fila de sesión grupal ────────────────────────────── */
.group-name { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.group-name-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: var(--text-primary); }
.group-name-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.group-badge {
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--primary-light); color: var(--primary);
  padding: 2px 7px; border-radius: var(--radius-pill);
}

/* ── Selección múltiple de clientes (sesión) ──────────── */
.field-label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.session-clients-multi {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px;
  max-height: 220px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px;
  background: var(--bg);
}
.client-check {
  display: flex; flex-direction: row; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; color: var(--text-primary);
}
.client-check:hover { background: var(--surface); }
.client-check input { width: 16px; height: 16px; flex-shrink: 0; accent-color: var(--primary-container); }
.client-check span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Subida de foto de cliente ────────────────────────── */
.photo-upload { display: flex; align-items: center; gap: 16px; margin-bottom: 4px; }
.photo-preview {
  width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-high); color: var(--text-secondary);
  font-size: 22px; font-weight: 500; overflow: hidden;
}
.photo-preview.blue   { background: #dbeafe; color: #1d4ed8; }
.photo-preview.green  { background: var(--success-bg); color: var(--success); }
.photo-preview.purple { background: #ede9fe; color: #7c3aed; }
.photo-preview.orange { background: var(--amber-bg); color: var(--amber); }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-upload-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.photo-upload-hint { flex-basis: 100%; font-size: 12px; color: var(--text-muted); margin: 0; }

/* ── Descarga de facturas (modal mes / año) ───────────── */
.facturas-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.download-box {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
}
.download-card-head {
  display: flex; align-items: center; justify-content: space-between;
  flex: 0 0 auto;
  padding: 28px 28px 18px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}
.download-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 28px 28px;
}
.download-card-head h3 { margin: 0; font-size: 17px; font-weight: 500; color: var(--text-primary); }

/* ── Vista previa de plantilla de factura (en línea, junto al selector) ── */
.template-picker-layout {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
}
.template-preview-pane {
  flex: 1 1 260px;
  min-width: 220px;
  max-width: 420px;
}
.template-preview-pane-title {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.template-preview-pane-hint {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
/* El botón vive junto al título: mirar plantillas y elegir una son acciones
   distintas, y la elegida se confirma aquí, no al pinchar la miniatura. */
.template-preview-pane-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.template-preview-pane-head > div { min-width: 0; }
#selectTemplateButton { flex: none; white-space: nowrap; }
#selectTemplateButton:disabled { cursor: default; opacity: 1; }
.template-preview-pane-frame-wrap {
  margin-top: 14px;
  /* Esquinas cuadradas a propósito: representa una página/PDF real, y una
     esquina redondeada recortaría diseños "a sangre" (p. ej. la banda oscura
     de la plantilla Moderna, que llega hasta el borde). */
  position: relative;
  width: 100%;
  aspect-ratio: 794 / 1123;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 0;
  background: #fff;
  box-shadow: 0 1px 3px rgba(32,26,25,0.08);
  transition: opacity 0.15s ease;
}
.template-preview-pane-frame-wrap.is-loading { opacity: 0.5; }
#templatePreviewFrame {
  position: absolute;
  top: 0; left: 0;
  width: 794px;
  height: 1123px;
  border: none;
  transform-origin: top left;
  transform: scale(var(--tp-scale, 0.4));
  pointer-events: none;
}
.download-section { display: flex; flex-direction: column; }
.download-section .field-label { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.download-hint { font-size: 12.5px; color: var(--text-muted); margin: 0 0 12px; line-height: 1.45; }
.download-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.download-row select { flex: 0 1 auto; min-width: 0; }
.download-row .btn-primary { flex: 1 1 auto; white-space: nowrap; }
.download-box .section-divider { margin: 20px 0; }

/* ── Plan / suscripción (Ajustes) ───────────────────── */
.plan-card { display: flex; flex-direction: column; gap: 10px; }
.plan-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.plan-usage-text { margin: 0; font-weight: 500; color: var(--text-primary); }
.plan-usage-sub { margin: 0; font-size: 13px; color: var(--text-muted); }
.plan-usage-sub.plan-warn { color: #B4690E; }
.plan-bar { height: 8px; border-radius: 9999px; background: var(--border); overflow: hidden; }
.plan-bar > span { display: block; height: 100%; border-radius: 9999px; background: var(--primary-container); }
.plan-bar > span.plan-bar-warn { background: #E0A106; }

/* Chip de sesión cubierta por bono */
.tag-bono { background: var(--primary-light); color: var(--primary); }

/* ── Reorganización paso 0 ───────────────────────────── */
/* Sidebar: bloque secundario (Ayuda + Ajustes) al pie, separado del flujo */
.sidebar-secondary {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--sidebar-border);
}

/* Cajón del menú en móvil: fondo oscuro tras el sidebar desplegado, para poder
   cerrarlo tocando fuera. Oculto por defecto; visible solo mientras el cajón
   está abierto en viewport estrecho (ver @media max-width:780px). */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 90;
}

/* Ayuda: guías de uso (acordeón nativo) */
.help-guides { display: flex; flex-direction: column; gap: 8px; }
.help-guide {
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  overflow: hidden;
}
.help-guide summary {
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 500;
  color: var(--text-primary);
  list-style: none;
}
.help-guide summary::-webkit-details-marker { display: none; }
.help-guide summary::after { content: "⌄"; float: right; color: var(--text-muted); font-size: 18px; line-height: 1.2; }
.help-guide[open] summary::after { content: "⌃"; }
.help-guide[open] summary { border-bottom: 1px solid var(--border); }
.help-guide p {
  margin: 0;
  padding: 12px 14px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

/* ── Ficha de cliente (paso 1) ───────────────────────── */
.client-name-link {
  background: none; border: none; padding: 0; margin: 0;
  font: inherit; color: inherit; cursor: pointer; text-align: left;
}
.client-name-link:hover span { text-decoration: underline; }
.client-detail-back { margin-bottom: 16px; }
.client-detail-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.client-detail-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.client-detail-id strong { font-size: 20px; color: var(--text-primary); }
.client-detail-id span { color: var(--text-muted); font-size: 13px; }
.client-detail-actions { display: flex; gap: 8px; flex-shrink: 0; }
.client-detail-tabs { margin-bottom: 18px; }
.client-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.client-kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.ck-value { font-size: 22px; font-weight: 600; color: var(--text-primary); }
.ck-label { font-size: 12px; color: var(--text-muted); }
.detail-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 16px 18px; margin-bottom: 14px;
}
.detail-empty { text-align: center; padding: 32px 12px; color: var(--text-muted); }
.detail-empty strong { display: block; color: var(--text-secondary); margin-bottom: 4px; }
.detail-empty p { margin: 0; font-size: 14px; }
@media (max-width: 720px) {
  .client-kpis { grid-template-columns: repeat(2, 1fr); }
  .client-detail-header { flex-wrap: wrap; }
  .client-detail-actions { width: 100%; }
}

/* ── Vista Semana (E) ────────────────────────────────── */
.week-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.week-range { font-weight: 600; color: var(--text-primary); min-width: 170px; text-align: center; }
.day-count-chip {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: var(--radius-pill);
  background: var(--primary-light); color: var(--primary);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.week-dup { margin-left: auto; }
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.week-col {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); overflow: hidden; min-height: 96px;
}
.week-col.is-today { border-color: var(--primary-container); box-shadow: 0 0 0 1px var(--primary-container); }
.week-col-head {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  padding: 8px 6px 8px 10px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
}
.week-col.is-today .week-col-head { color: var(--primary); }
.week-col-body { display: flex; flex-direction: column; gap: 6px; padding: 8px; }
.week-empty { color: var(--text-muted); font-size: 12px; text-align: center; padding: 10px 0; }
.week-card {
  display: flex; flex-direction: column; gap: 1px; text-align: left; width: 100%;
  background: var(--primary-light); border: none; border-radius: 10px; padding: 8px; cursor: pointer;
}
.week-card:hover:not([disabled]) { filter: brightness(0.97); }
.week-card[disabled] { cursor: default; opacity: 0.65; }
.week-card.is-absent { background: var(--amber-bg); }
.week-card.is-bono { background: var(--surface-high); }
.week-card-time { font-size: 12px; font-weight: 700; color: var(--primary); }
.week-card.is-absent .week-card-time { color: var(--amber-text); }
.week-card-client { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.week-card-svc { font-size: 11px; color: var(--text-muted); }
@media (max-width: 760px) {
  .week-grid { grid-template-columns: 1fr; }
  .week-col { min-height: auto; }
  .week-dup { margin-left: 0; width: 100%; }
}
/* Sesión grupal: una sola tarjeta. Fondo distinto para que el badge (primary-light) contraste,
   sin pisar el ámbar de las ausencias. */
.week-card-group:not(.is-absent) { background: var(--surface-high); }
.week-card .group-badge { font-size: 9px; padding: 1px 6px; margin-right: 4px; }
.week-card-group .week-card-client { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }

/* Vista previa de importación de clientes (I) */
.import-preview { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.import-preview-summary { margin: 0 0 8px; }
.import-warn { color: var(--amber-text); font-size: 13px; margin: 4px 0 8px; }
.import-skip td { color: var(--text-muted); }

/* Gastos (L) */
.expense-cat-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--primary-light); color: var(--primary);
}
.expense-cat-icon .material-symbols-outlined { font-size: 18px; }
.expense-total-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--radius-pill);
  background: var(--primary-light); color: var(--primary);
  font-size: 13px; font-weight: 500; white-space: nowrap;
}
/* El botón de registrar, al final de la barra y junto al total del periodo. */
.expense-toolbar-actions { display: inline-flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
@media (max-width: 640px) { .expense-toolbar-actions { margin-left: 0; } }

/* Impuestos (M) */
.tax-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.tax-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 20px 22px;
}
.tax-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.tax-card-head .material-symbols-outlined {
  color: var(--primary); background: var(--primary-light);
  width: 40px; height: 40px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
}
.tax-card-head h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text-primary); }
.tax-card-head p { margin: 0; font-size: 12px; color: var(--text-muted); }
.tax-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0; font-size: 14px; color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
.tax-row:last-of-type { border-bottom: 0; }
.tax-row.is-total {
  margin-top: 4px; padding-top: 12px; font-weight: 600; color: var(--text-primary);
  border-top: 2px solid var(--border); border-bottom: 0;
}
.tax-amount { font-variant-numeric: tabular-nums; font-weight: 500; }
.tax-amount.neg { color: var(--amber-text); }
.tax-amount.pos { color: var(--primary); }
.tax-card-note { margin: 12px 0 0; font-size: 12px; color: var(--text-muted); }
.tax-disclaimer {
  display: flex; gap: 8px; align-items: flex-start;
  margin: 18px 0 0; padding: 12px 14px; border-radius: 12px;
  background: var(--surface-high); color: var(--text-muted); font-size: 12.5px; line-height: 1.5;
}
.tax-disclaimer .material-symbols-outlined { flex-shrink: 0; color: var(--text-muted); }

/* Ticket de gasto (L, adjunto) */
.receipt-field { display: flex; flex-direction: column; gap: 8px; }
.receipt-upload-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.receipt-current {
  display: inline-flex; align-items: center; gap: 6px; max-width: 240px;
  padding: 5px 12px; border-radius: var(--radius-pill);
  background: var(--primary-light); color: var(--primary);
  font-size: 13px; font-weight: 500; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.receipt-current.is-pending { background: var(--surface-high); color: var(--text-secondary); }
.receipt-hint { font-size: 12px; color: var(--text-muted); }

/* Cuota recurrente (K) */
.detail-fee-form { margin-top: 4px; }
.fee-check {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13px; color: var(--text-secondary); line-height: 1.45; cursor: pointer;
}
.fee-check input { margin-top: 2px; flex-shrink: 0; }

/* Resumen de facturas (N1) — mini gráfico por mes */
.resumen-chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 8px; }
.resumen-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.resumen-bar { width: 100%; max-width: 34px; background: var(--primary-container); border-radius: 6px 6px 0 0; transition: height var(--t); }
.resumen-chart:has(.resumen-bar.is-active) .resumen-bar:not(.is-active) { opacity: 0.35; }
.resumen-bar.is-active { background: var(--primary); }
.resumen-bar-label { font-size: 11px; color: var(--text-muted); }

/* Proveedores / Importar (N2) */
.list-header-actions { display: flex; align-items: center; gap: 8px; }
.list-search-input { width: 220px; height: 38px; }
.import-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.import-cards .detail-card { display: flex; flex-direction: column; gap: 10px; }
.import-cards .detail-actions { flex-wrap: wrap; }

/* Aviso "sin factura" en gastos (N5) */
.expense-concept { display: inline-flex; flex-direction: column; line-height: 1.25; }
.expense-no-receipt {
  display: inline-flex; align-items: center; gap: 3px; margin-left: 8px;
  font-size: 11px; font-weight: 600; color: var(--amber-text);
  background: var(--amber-bg, rgba(217,164,65,0.14)); padding: 2px 8px; border-radius: 9999px; white-space: nowrap;
}
.expense-no-receipt .material-symbols-outlined { font-size: 14px; }

/* Impuestos: calendario y guía (N7) */
.fiscal-cal { display: flex; flex-direction: column; gap: 16px; }
.fiscal-guide { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.fiscal-guide .detail-card p { margin: 0; font-size: 13.5px; color: var(--text-secondary); line-height: 1.5; }
.fiscal-guide-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.fiscal-guide-head h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text-primary); }
.fiscal-model {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 26px; padding: 0 8px; border-radius: 8px;
  background: var(--primary); color: var(--on-primary);
  font-size: 12px; font-weight: 700; letter-spacing: 0.3px;
}

/* Agenda con rejilla horaria — Semana y Día (Fase 1) */
.agenda { --gutter-w: 54px; }
.agenda-scroll { max-height: 64vh; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
.agenda-topstick { position: sticky; top: 0; z-index: 4; background: var(--surface); }
.agenda-head { display: flex; border-bottom: 1px solid var(--border); }
.agenda-gutter { width: var(--gutter-w); flex: 0 0 var(--gutter-w); }
.agenda-dayhead {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  padding: 8px 4px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); border-left: 1px solid var(--border);
}
.agenda-dayhead.is-today { color: var(--primary); background: rgba(78,139,95,0.06); }

.agenda-add {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 9999px; border: 1px dashed var(--border);
  background: transparent; color: var(--text-muted); font-family: inherit;
  font-size: 10.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: color var(--t), border-color var(--t), background var(--t);
}
.agenda-add:hover { color: var(--primary); border-color: var(--primary-container); background: var(--primary-light); }
.agenda-add .material-symbols-outlined { flex-shrink: 0; }
.agenda-add-label { overflow: hidden; text-overflow: ellipsis; }

.day-mode-toggle { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.day-mode-toggle-label { font-size: 12.5px; color: var(--text-secondary); font-weight: 500; }

.day-list-view { padding: 2px; }
.day-list-head { display: flex; justify-content: flex-end; margin-bottom: 10px; }

.agenda-allday { display: flex; border-bottom: 1px solid var(--border); background: var(--surface); }
.agenda-allday-label { font-size: 10px; color: var(--text-muted); display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; text-align: right; }
.agenda-allday-col { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 3px; padding: 4px; border-left: 1px solid var(--border); }

.agenda-body { display: flex; }
.agenda-hours { flex: 0 0 var(--gutter-w); width: var(--gutter-w); position: relative; }
.agenda-hour { height: var(--hour-px); position: relative; }
.agenda-hour span { position: absolute; top: -7px; right: 8px; font-size: 10.5px; color: var(--text-muted); }
.agenda-cols { flex: 1; display: flex; min-width: 0; }
.agenda-col {
  flex: 1; min-width: 0; position: relative; border-left: 1px solid var(--border);
  background-image: repeating-linear-gradient(to bottom, var(--border) 0, var(--border) 1px, transparent 1px, transparent var(--hour-px));
}
.agenda-col.is-today { background-color: rgba(78,139,95,0.04); }
.agenda-col-empty { position: absolute; top: 10px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--text-muted); pointer-events: none; }

.agenda-block {
  position: absolute; overflow: hidden; text-align: left; z-index: 2;
  border: 0; border-left: 3px solid var(--svc, var(--primary-container));
  background: var(--svc-bg, var(--primary-light)); border-radius: 6px;
  padding: 3px 6px; cursor: pointer; display: flex; flex-direction: column; gap: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06); font-family: inherit;
}
.agenda-block:hover { filter: brightness(0.97); z-index: 3; }
.agenda-block[disabled] { cursor: default; opacity: 0.72; }
.agenda-block-time { font-size: 10.5px; font-weight: 700; color: var(--svc, var(--primary)); line-height: 1.25; }
.agenda-block-title { font-size: 12px; font-weight: 600; color: var(--text-primary); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda-block-svc { font-size: 10.5px; color: var(--text-muted); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda-block.is-absent { border-left-style: dashed; opacity: 0.72; }
.agenda-block.is-absent .agenda-block-title { text-decoration: line-through; }

.agenda-chip {
  border: 0; border-left: 3px solid var(--svc, var(--primary-container));
  background: var(--svc-bg, var(--primary-light)); border-radius: 6px;
  padding: 2px 8px; font-size: 11.5px; font-weight: 600; color: var(--text-primary); cursor: pointer;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: inherit;
}
.agenda-chip[disabled] { opacity: 0.7; cursor: default; }
.agenda-chip .group-badge { margin-right: 3px; }

.agenda-now { position: absolute; left: 0; right: 0; height: 2px; background: #e5484d; z-index: 1; }
.agenda-now::before { content: ""; position: absolute; left: -3px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: #e5484d; }

/* Paleta de color por servicio */
.svc-c0 { --svc: #2d5c3a; --svc-bg: #e4efe6; }
.svc-c1 { --svc: #1f6f8b; --svc-bg: #e1eef3; }
.svc-c2 { --svc: #8a5a00; --svc-bg: #f4ecdb; }
.svc-c3 { --svc: #7a3e9d; --svc-bg: #eee5f4; }
.svc-c4 { --svc: #b23a48; --svc-bg: #f6e3e5; }
.svc-c5 { --svc: #2b6cb0; --svc-bg: #e2ecf6; }
.svc-c6 { --svc: #557a1f; --svc-bg: #e9f1db; }
.svc-c7 { --svc: #a15c2b; --svc-bg: #f4e7db; }

@media (max-width: 1100px) {
  .agenda-week .agenda-add-label { display: none; }
  .agenda-week .agenda-add { padding: 4px; }
}

@media (max-width: 760px) {
  .agenda { --gutter-w: 42px; }
  .agenda-block-svc { display: none; }
  .agenda-scroll { max-height: 70vh; }
  .day-mode-toggle-label { display: none; }
}

/* Perfil fiscal — aviso de perfil incompleto en Impuestos */
.fiscal-profile-nudge {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 12px 16px; border-radius: 12px;
  background: var(--amber-bg, rgba(217,164,65,0.14)); color: var(--text-secondary); font-size: 13.5px;
}
.fiscal-profile-nudge .material-symbols-outlined { color: var(--amber-text); flex-shrink: 0; }
.fiscal-profile-nudge button { margin-left: auto; }

/* Cerrar la cuenta. Se separa del resto de "Herramientas" a propósito: es la única
   acción de la aplicación que no se puede deshacer ni restaurar desde una copia, así
   que no debe parecerse a los botones que tiene al lado. */
.zona-peligro {
  border: 1px solid var(--error);
  border-radius: var(--radius-card);
  padding: 18px 20px !important;
  margin-top: 4px;
  background: var(--error-bg);
}
.zona-peligro h3 { color: var(--error-text); }
.zona-peligro .settings-help { color: var(--error-text); opacity: .9; }

/* ── Objetivos táctiles ───────────────────────────────
   Medido a 375 px el 24 ago 2026: de 68 controles visibles en Sesiones, 66 estaban por
   debajo de 44x44. Los peores no eran detalles — los iconos de editar y eliminar de cada
   fila median 34x34 y van pegados el uno al otro, y "+ Nueva sesión", que es la acción
   principal de la página, tenía 27 px de alto.

   La condición es `pointer: coarse` y no un ancho: lo que obliga a agrandar es que se
   toque con un dedo, no que la ventana sea estrecha. Una ventana angosta con ratón no
   necesita esto, y un tablet grande con dedos sí. */
@media (pointer: coarse) {
  .btn-sm {
    padding: 12px 18px;
    min-height: 44px;
  }

  .btn-icon {
    min-width: 44px;
    min-height: 44px;
  }

  /* Editar y eliminar viven juntos en cada fila. Aparte de agrandarlos, se separan: dos
     objetivos de 44 px pegados siguen siendo fáciles de confundir, y uno de ellos borra. */
  .row-actions .btn-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }
  .row-actions { gap: 8px; }
  .row-actions .btn-icon .material-symbols-outlined { font-size: 20px; }

  /* Los desplegables propios y los campos de texto: el pulgar necesita lo mismo. */
  .c-select-trigger,
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    min-height: 44px;
  }

  /* Las opciones del desplegable se recorren con el pulgar en una lista larga. */
  .c-select-option { min-height: 44px; }

  /* Controles segmentados y chips de filtro: son navegacion, se usan constantemente. */
  .view-toggle-btn,
  .seg-btn,
  .seg-pill,
  .tab-btn { min-height: 44px; }

  /* Las casillas de formulario median 17x17. A 24 no llegan a los 44 recomendados -- una
     casilla de 44 px se ve desproporcionada -- pero duplican el area, y en la aplicacion
     van todas dentro de un <label>, asi que el texto de al lado tambien vale como
     objetivo.

     Las de "Facturar mes" quedan fuera a proposito: `.billing-table input[type=checkbox]`
     gana por especificidad y las deja en 17 px con `pointer-events: none`, porque ahi la
     casilla es decorativa -- lo que se pulsa es la fila entera, que mide 222 px de alto.
     Agrandarlas seria arreglar algo que no esta roto. */
  input[type="checkbox"],
  input[type="radio"] {
    width: 24px;
    height: 24px;
  }
}

/* Próximo vencimiento fiscal. Se separa del resto del calendario a propósito: las tablas
   de abajo son información de referencia, esto es una fecha que te afecta a ti. */
.cal-next { margin-bottom: 18px; border-left: 4px solid var(--primary); }
.cal-next.is-pronto { border-left-color: var(--amber); background: var(--amber-bg); }
.cal-next.is-urgente { border-left-color: var(--error); background: var(--error-bg); }
.cal-next-when { margin: 6px 0 2px; color: var(--text-secondary); }
.cal-next-date { margin: 0 0 10px; font-size: 17px; color: var(--text-primary); }
.cal-next .cal-next-fineprint { font-size: 12px; opacity: .85; }

/* ── Pestaña "Sin cobrar" ─────────────────────────────
   Lo que importa aquí no es cuánto has facturado —eso está en otra pantalla— sino cuánto
   te deben y cuánto de eso ya se pasó de plazo. */
.cobros-resumen {
  display: flex; gap: 28px; flex-wrap: wrap;
  padding: 14px 18px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card);
}
.cobros-resumen.tiene-vencidas { border-color: var(--amber); }
.cobros-dato { display: flex; flex-direction: column; gap: 2px; }
.cobros-dato .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.cobros-dato .value { font-size: 22px; font-weight: 600; color: var(--text-primary); }
.cobros-dato small { font-size: 12px; color: var(--text-muted); }
.cobros-dato.is-vencido .value { color: var(--amber-text); }

.cobro-retraso { color: var(--amber-text); font-weight: 600; }
.cobro-plazo { color: var(--text-muted); }
