/* =====================================================
   Panel interno - Design system
   Paleta: beige cálido + sidebar oscuro + acentos semánticos
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500&family=Source+Serif+4:opsz,wght@8..60,400;8..60,500&display=swap');

:root {
  --bg-page: #EDE9DD;
  --bg-card: #FFFDF8;
  --bg-card-soft: #F6F4EE;
  --bg-sidebar: #0E1626;
  --bg-sidebar-active: #1B2436;

  --text-primary: #0E1626;
  --text-secondary: #8B8779;
  --text-muted: #A8A496;
  --text-on-dark: #F6F4EE;
  --text-on-dark-muted: #8089A0;
  --text-on-dark-faint: #5C6478;

  --border-soft: #F0EDE3;
  --border-card: #E4E0D2;

  --coral-50: #FAECE7;  --coral-600: #D85A30; --coral-700: #993C1D; --coral-800: #712B13;
  --amber-50: #FAEEDA;  --amber-600: #BA7517; --amber-700: #854F0B; --amber-800: #633806;
  --teal-50:  #E1F5EE;  --teal-600:  #0F6E56; --teal-700: #085041;  --teal-800: #04342C;
  --green-50: #EAF3DE;  --green-700: #3B6D11;
  --blue-50:  #E6F1FB;  --blue-700:  #185FA5;
  --gray-50:  #F1EFE8;  --gray-500:  #888780; --gray-700: #5F5E5A;

  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 16px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Source Serif 4', Georgia, serif;

  --shadow-card: 0 1px 3px rgba(14, 22, 38, 0.06), 0 1px 2px rgba(14, 22, 38, 0.04);
  --shadow-card-hover: 0 4px 16px rgba(14, 22, 38, 0.1), 0 1px 4px rgba(14, 22, 38, 0.06);
  --shadow-hero: 0 4px 20px rgba(14, 22, 38, 0.14);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:  cubic-bezier(0.4, 0, 1, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }

/* =====================================================
   LAYOUT
   ===================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* =====================================================
   SIDEBAR
   ===================================================== */

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.22s var(--ease-out), padding 0.22s var(--ease-out);
  z-index: 20;
}

.sidebar.collapsed {
  width: 62px;
  padding: 20px 8px;
}

.sidebar-top {
  margin-bottom: 28px;
  padding: 0 4px;
}

/* --- Brand --- */

.brand { width: 100%; }

.brand-expanded { width: 100%; }
.brand-collapsed { display: flex; align-items: center; justify-content: center; }

.brand-logo {
  display: block;
  width: 100%;
  height: auto;
  max-height: 54px;
  filter: brightness(0) invert(1);
}

.brand-logo-small {
  width: 32px;
  height: 32px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  color: var(--text-on-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--text-on-dark);
  white-space: nowrap;
  overflow: hidden;
  max-width: 140px;
  opacity: 1;
  transform: translateX(0);
  transition: opacity 0.18s ease, max-width 0.22s var(--ease-out), transform 0.18s ease;
}

.sidebar.collapsed .brand-name {
  opacity: 0;
  max-width: 0;
  transform: translateX(-6px);
  pointer-events: none;
}

/* --- Toggle button --- */

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  padding: 5px;
  border-radius: 7px;
  flex-shrink: 0;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-toggle:hover { background: var(--bg-card-soft); color: var(--text-primary); }

/* --- Nav --- */

.sidebar-nav { flex: 1; overflow: hidden; }

.nav-section-title {
  font-size: 10px;
  color: var(--text-on-dark-faint);
  letter-spacing: 0.1em;
  margin: 0 0 6px;
  padding: 0 10px;
  overflow: hidden;
  white-space: nowrap;
  max-height: 22px;
  opacity: 1;
  transition: opacity 0.15s ease, max-height 0.22s var(--ease-out), margin 0.22s var(--ease-out);
}

.sidebar.collapsed .nav-section-title {
  opacity: 0;
  max-height: 0;
  margin: 0;
  pointer-events: none;
}

.nav-group { display: flex; flex-direction: column; gap: 1px; margin-bottom: 18px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--text-on-dark-muted);
  font-size: 13px;
  white-space: nowrap;
  position: relative;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-item i {
  font-size: 17px;
  flex-shrink: 0;
  transition: color 0.12s ease;
  width: 20px;
  text-align: center;
}

.nav-item:hover { background: var(--bg-sidebar-active); color: #E0E4EF; }
.nav-item:hover i { color: var(--text-on-dark); }

.nav-item.active {
  background: var(--bg-sidebar-active);
  color: var(--text-on-dark);
}
.nav-item.active i { color: var(--text-on-dark); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--text-on-dark);
  border-radius: 0 3px 3px 0;
  opacity: 0.6;
}

/* Nav label */
.nav-label {
  overflow: hidden;
  white-space: nowrap;
  max-width: 120px;
  opacity: 1;
  transform: translateX(0);
  transition: opacity 0.15s ease, max-width 0.22s var(--ease-out), transform 0.15s ease;
}

.sidebar.collapsed .nav-label {
  opacity: 0;
  max-width: 0;
  transform: translateX(-4px);
  pointer-events: none;
}

.nav-count {
  font-size: 10px;
  font-family: var(--font-serif);
  color: var(--text-on-dark-faint);
  margin-left: auto;
  overflow: hidden;
  max-width: 30px;
  opacity: 1;
  transition: opacity 0.15s ease, max-width 0.22s var(--ease-out);
}

.sidebar.collapsed .nav-count {
  opacity: 0;
  max-width: 0;
  pointer-events: none;
}

.nav-item.active .nav-count { color: var(--coral-600); }

.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }

/* Tooltip for collapsed sidebar items */
.sidebar.collapsed .nav-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-sidebar-active);
  color: var(--text-on-dark);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 7px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  z-index: 200;
}

.sidebar.collapsed .nav-item:hover::after {
  opacity: 1;
}

/* --- User card --- */

.sidebar-bottom { margin-top: auto; padding-top: 14px; }

.user-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 11px;
  background: var(--bg-sidebar-active);
}

.sidebar.collapsed .user-card { justify-content: center; padding: 9px; }

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: var(--text-on-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
}

.user-avatar.small {
  width: 32px;
  height: 32px;
  background: var(--bg-sidebar);
  color: var(--text-on-dark);
  font-size: 12px;
}

.user-info {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  max-width: 120px;
  opacity: 1;
  transition: opacity 0.15s ease, max-width 0.22s var(--ease-out);
}

.sidebar.collapsed .user-info {
  opacity: 0;
  max-width: 0;
  pointer-events: none;
}

.user-name { font-size: 12px; color: var(--text-on-dark); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--text-on-dark-faint); margin: 0; }

.user-logout {
  color: var(--text-on-dark-faint);
  font-size: 16px;
  flex-shrink: 0;
  padding: 5px;
  border-radius: 7px;
  transition: color 0.12s ease, background 0.12s ease, opacity 0.15s ease, max-width 0.22s var(--ease-out);
  overflow: hidden;
  max-width: 32px;
}

.sidebar.collapsed .user-logout {
  opacity: 0;
  max-width: 0;
  padding: 0;
  pointer-events: none;
}

.user-logout:hover { color: var(--text-on-dark); background: rgba(255,255,255,0.07); }

/* --- Sidebar overlay (mobile) --- */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(14,22,38,0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 19;
}
.sidebar-overlay.visible { display: block; }

/* =====================================================
   MAIN AREA
   ===================================================== */

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
}

.mobile-menu-btn {
  display: none;
  background: var(--bg-card);
  border: 0.5px solid var(--border-card);
  border-radius: 9px;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: var(--text-primary);
  flex-shrink: 0;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.mobile-menu-btn:hover { background: var(--bg-card-soft); }

/* Logo en el topbar — solo visible en mobile (sidebar oculto) */
.topbar-brand {
  display: none;
  align-items: center;
  flex-shrink: 0;
}
.topbar-brand-logo {
  display: block;
  height: 30px;
  width: auto;
  max-width: 150px;
  object-fit: contain;
}
.topbar-brand-logo-small {
  height: 30px;
  width: 30px;
}
.topbar-brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--bg-sidebar);
  color: var(--text-on-dark);
  font-size: 14px;
  font-weight: 600;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-muted);
}
.breadcrumb-link,
.breadcrumb-current {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.breadcrumb-link {
  color: var(--text-secondary);
  transition: color 0.12s ease;
}
.breadcrumb-link:hover {
  color: var(--text-primary);
}
.breadcrumb-current {
  color: var(--text-muted);
}
.breadcrumb-sep {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  opacity: 0.8;
}
.breadcrumb-sep i {
  font-size: 11px;
}

.topbar-title h1 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  margin: 0;
  color: var(--text-primary);
}
.topbar-title p { font-size: 12px; color: var(--text-secondary); margin: 4px 0 0; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 16px; }

.pwa-install-btn {
  white-space: nowrap;
}

.pwa-install-btn[hidden] {
  display: none !important;
}

.icon-btn {
  position: relative;
  color: var(--text-secondary);
  font-size: 18px;
  padding: 4px;
  border-radius: 7px;
  transition: color 0.12s ease, background 0.12s ease;
}
.icon-btn:hover { color: var(--text-primary); background: var(--bg-card-soft); }

.icon-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--coral-600);
  position: absolute; top: -1px; right: -1px;
}

.content {
  padding: 0 28px 32px;
  animation: fadeUp 0.22s var(--ease-out) both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =====================================================
   TOASTS (sistema de notificaciones)
   ===================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: 0 6px 24px rgba(14,22,38,0.13), 0 0 0 1px rgba(14,22,38,0.05);
  font-size: 13px;
  min-width: 240px;
  max-width: 340px;
  pointer-events: all;
  border-left: 3px solid transparent;
}

.toast i { font-size: 16px; flex-shrink: 0; }
.toast > span { flex: 1; }

.toast-success { border-left-color: var(--teal-600); }
.toast-success i { color: var(--teal-600); }
.toast-error   { border-left-color: var(--coral-600); }
.toast-error i { color: var(--coral-600); }
.toast-warning { border-left-color: var(--amber-600); }
.toast-warning i { color: var(--amber-600); }

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 5px;
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.12s ease, background 0.12s ease;
}
.toast-close:hover { color: var(--text-primary); background: var(--bg-card-soft); }

/* Alpine transition helpers para toasts */
.toast-enter   { transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out); }
.toast-enter-start { opacity: 0; transform: translateY(12px) scale(0.97); }
.toast-enter-end   { opacity: 1; transform: translateY(0) scale(1); }
.toast-leave   { transition: opacity 0.15s var(--ease-in), transform 0.15s var(--ease-in); }
.toast-leave-start { opacity: 1; transform: translateY(0) scale(1); }
.toast-leave-end   { opacity: 0; transform: translateY(8px) scale(0.97); }

/* x-cloak: ocultar elementos Alpine antes de que inicialice */
[x-cloak] { display: none !important; }

/* =====================================================
   ALERTS (inline, para login y páginas sin sidebar)
   ===================================================== */

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 18px;
}
.alert-success { background: var(--teal-50); color: var(--teal-800); }
.alert-error   { background: var(--coral-50); color: var(--coral-800); }
.alert i { font-size: 16px; }

/* =====================================================
   CARDS / MÉTRICAS
   ===================================================== */

.card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.18s ease;
}

.card:hover { box-shadow: var(--shadow-card-hover); }

.card-soft { background: var(--bg-card-soft); box-shadow: none; }
.card-soft:hover { box-shadow: 0 2px 8px rgba(14,22,38,0.07); }

.card-dark {
  background: var(--bg-sidebar);
  border-radius: var(--radius-xl);
  padding: 20px 22px;
  box-shadow: var(--shadow-hero);
  color: var(--text-on-dark);
}

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.metric-grid.cols-1 { grid-template-columns: 1fr; }
.metric-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.metric-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

.dash-top    { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-bottom { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }

.metric-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  cursor: default;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.metric-card.tone-coral { background: var(--coral-50); box-shadow: none; }
.metric-card.tone-amber { background: var(--amber-50); box-shadow: none; }
.metric-card.tone-teal  { background: var(--teal-50);  box-shadow: none; }

.metric-card.tone-coral:hover,
.metric-card.tone-amber:hover,
.metric-card.tone-teal:hover { box-shadow: 0 4px 14px rgba(14,22,38,0.08); }

.metric-value {
  font-family: var(--font-sans);
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.metric-card.tone-coral .metric-value { color: var(--coral-800); }
.metric-card.tone-amber .metric-value { color: var(--amber-800); }

.metric-label { font-size: 11px; color: var(--text-secondary); margin: 5px 0 0; }
.metric-card.tone-coral .metric-label { color: var(--coral-700); }
.metric-card.tone-amber .metric-label { color: var(--amber-700); }

/* Variante destacada: para resaltar el número más importante (ej: saldo de IVA a pagar) */
.metric-card.is-featured { padding: 22px 24px; }
.metric-card.is-featured .metric-value { font-size: 40px; }
.metric-card.is-featured .metric-label { font-size: 13px; margin-top: 7px; }

/* =====================================================
   FILTRO DE PERÍODO (dashboard)
   ===================================================== */
.period-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.period-toggle {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.period-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.period-pill i { font-size: 15px; }
.period-pill input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.period-pill:hover { color: var(--text-primary); }
.period-pill.is-active {
  background: var(--bg-sidebar);
  color: var(--text-on-dark);
}
.period-select {
  width: auto !important;
  min-width: 120px;
  height: 40px;
}
.period-range {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.period-range i { font-size: 14px; }

/* =====================================================
   KPI CARDS (dashboard)
   ===================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-soft);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}
.kpi-card-coral { background: var(--coral-50); border-color: transparent; box-shadow: none; }
.kpi-card-amber { background: var(--amber-50); border-color: transparent; box-shadow: none; }
.kpi-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
}
.kpi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  flex-shrink: 0;
}
.kpi-icon i { font-size: 17px; }
.kpi-icon-teal  { background: var(--teal-50);  color: var(--teal-700); }
.kpi-icon-green { background: var(--green-50); color: var(--green-700); }
.kpi-icon-blue  { background: var(--blue-50);  color: var(--blue-700); }
.kpi-icon-amber { background: var(--amber-50); color: var(--amber-700); }
.kpi-icon-coral { background: var(--coral-50); color: var(--coral-700); }
.kpi-card-coral .kpi-icon-coral,
.kpi-card-amber .kpi-icon-amber { background: rgba(255,255,255,0.55); }
.kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  line-height: 1.3;
}
.kpi-value {
  font-family: var(--font-sans);
  font-size: 27px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.1;
}
.kpi-cur { font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: 0; }
.kpi-card-coral .kpi-value { color: var(--coral-800); }
.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin: 5px 0 0;
}
.kpi-sub-alert { color: var(--coral-700); font-weight: 600; }

@media (max-width: 880px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .period-range { margin-left: 0; width: 100%; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card { padding: 13px 14px; }
  .kpi-value { font-size: 23px; }
  .period-toggle, .period-select { flex: 1; }
}

/* =====================================================
   FISCAL CARD (IVA + IRPF dashboard)
   ===================================================== */

.fiscal-card { margin-bottom: 16px; }

.fiscal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 12px;
}
.fiscal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 2px;
}
.fiscal-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  margin: 0;
}
.fiscal-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--teal-700);
  background: var(--teal-50);
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.fiscal-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.fiscal-block {
  background: var(--bg-card-soft);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border: 1px solid var(--border-soft);
}
.fiscal-block-irpf {
  background: var(--amber-50);
  border-color: transparent;
}
.fiscal-block-label {
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 6px;
}
.fiscal-block-irpf .fiscal-block-label { color: var(--amber-700); }
.fiscal-block-amount {
  font-family: var(--font-sans);
  font-size: 21px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
.fiscal-block-detail {
  font-size: 11px;
  color: var(--text-secondary);
  margin: 0;
}
.fiscal-block-irpf .fiscal-block-detail { color: var(--amber-700); opacity: 0.8; }
.fiscal-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.fiscal-mini-item {
  padding-top: 10px;
  border-top: 1px solid rgba(14,22,38,0.08);
}
.fiscal-mini-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.fiscal-mini-item strong {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.fiscal-block-irpf .fiscal-mini-item {
  border-top-color: rgba(186,117,23,0.18);
}
.fiscal-block-irpf .fiscal-mini-label,
.fiscal-block-irpf .fiscal-mini-item strong {
  color: var(--amber-800);
}

/* Conciliación estimado vs pagado a DGI */
.fiscal-recon {
  background: var(--bg-card-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 12px;
}
.fiscal-recon-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.fiscal-recon-head > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}
.fiscal-recon-head i { font-size: 15px; color: var(--text-secondary); }
.fiscal-recon-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px 14px;
}
.fiscal-recon-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fiscal-recon-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.fiscal-recon-val {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.fiscal-recon-val.is-debt { color: var(--coral-700); }
.fiscal-recon-val.is-ok   { color: var(--teal-700); }
@media (max-width: 760px) {
  .fiscal-recon-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 480px) {
  .fiscal-recon-grid { grid-template-columns: 1fr 1fr; }
}

.fiscal-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}
.fiscal-disclaimer i { font-size: 13px; flex-shrink: 0; margin-top: 1px; }

/* =====================================================
   DASHBOARD REFINADO
   ===================================================== */

.status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-radius: var(--radius-xl);
  margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(216,90,48,0.16), rgba(250,236,231,0.92));
  border: 1px solid rgba(216,90,48,0.18);
}
.status-banner-copy {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.status-banner-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.62);
  color: var(--coral-700);
  flex-shrink: 0;
}
.status-banner-icon i { font-size: 20px; }
.status-banner-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 2px;
}
.status-banner-subtitle {
  font-size: 12px;
  color: var(--coral-700);
  margin: 0;
}
.status-banner-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--coral-700);
  white-space: nowrap;
}

.dashboard-priority {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.95fr);
  gap: 16px;
  margin-bottom: 16px;
}
.dashboard-priority-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.dashboard-hero {
  padding: 24px 24px 22px;
}
.dashboard-hero-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}
.dashboard-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-on-dark-faint);
  margin: 0 0 6px;
}
.dashboard-title {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--text-on-dark);
  margin: 0;
}
.dashboard-subtitle {
  font-size: 12px;
  color: var(--text-on-dark-muted);
  margin: 6px 0 0;
}
.dashboard-hero-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-on-dark);
  white-space: nowrap;
}
.dashboard-signal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.dashboard-signal {
  padding: 14px 14px 12px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
}
.dashboard-signal-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-on-dark);
  margin: 0 0 4px;
}
.dashboard-signal-label {
  font-size: 11px;
  color: var(--text-on-dark-muted);
  margin: 0;
  line-height: 1.35;
}

/* Número principal del panel (Por cobrar) */
.dashboard-hero-money {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-on-dark);
  margin: 4px 0 0;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

/* Señales clickeables con feedback y tinte según severidad */
a.dashboard-signal {
  display: block;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
a.dashboard-signal:hover {
  background: rgba(255,255,255,0.11);
  transform: translateY(-1px);
}
.dashboard-signal.is-alert {
  background: rgba(216,90,48,0.16);
  border-color: rgba(216,90,48,0.4);
}
.dashboard-signal.is-alert .dashboard-signal-value { color: #F0A88C; }
.dashboard-signal.is-warn {
  background: rgba(239,159,39,0.14);
  border-color: rgba(239,159,39,0.36);
}
.dashboard-signal.is-warn .dashboard-signal-value { color: #F2C079; }

/* Tarjeta de gráfico (dark) */
.chart-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.chart-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-on-dark);
  margin: 0;
}
.chart-card-sub {
  font-size: 12px;
  color: var(--text-on-dark-muted);
  margin: 4px 0 0;
}
.chart-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-on-dark-muted);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 5px 11px;
  white-space: nowrap;
}

/* =====================================================
   DASHBOARD · HERO DE FACTURACIÓN (dark)
   ===================================================== */
.facturacion-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.facturacion-hero-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-on-dark-faint);
  margin: 0 0 8px;
}
.facturacion-hero-value {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-on-dark);
  margin: 0;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.facturacion-hero-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.fac-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-on-dark);
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 8px;
  padding: 6px 11px;
  font-variant-numeric: tabular-nums;
}
.fac-pill-cur {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-on-dark-muted);
}
.fac-pill-total {
  background: transparent;
  border-style: dashed;
  color: var(--text-on-dark-muted);
  font-weight: 500;
}
.fac-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.fac-pill-blanco .fac-pill-dot { background: #5DCAA5; }
.fac-pill-negro .fac-pill-dot { background: #EF9F27; }
.fac-pill-blanco { border-color: rgba(93,202,165,0.35); }
.fac-pill-negro { border-color: rgba(239,159,39,0.35); }
.facturacion-hero-aside {
  display: flex;
  gap: 10px;
}
.facturacion-hero-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  min-width: 104px;
}
.facturacion-hero-stat-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-on-dark-faint);
}
.facturacion-hero-stat strong {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-on-dark);
  font-variant-numeric: tabular-nums;
}
.facturacion-hero-chartlabel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-on-dark-faint);
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 12px;
  margin-bottom: 4px;
}
.facturacion-hero-legend {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.fac-legend {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: var(--text-on-dark-muted);
}
.fac-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.fac-legend-blanco .fac-legend-dot { background: #5DCAA5; }
.fac-legend-negro .fac-legend-dot { background: #EF9F27; }
.fac-legend-prom { color: var(--text-on-dark-faint); }

/* =====================================================
   DASHBOARD · KPIs PRIMARIOS (trío)
   ===================================================== */
.kpi-trio {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.kpi-cell {
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
a.kpi-cell:hover { transform: translateY(-2px); box-shadow: var(--shadow-card-hover); }
.kpi-cell-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}
.kpi-cell-label i { font-size: 15px; }
.kpi-cell-value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi-cell-value.is-negative { color: var(--coral-700); }
.kpi-cell-meta { font-size: 11.5px; color: var(--text-muted); }
/* Tonos según estado */
.kpi-cell-accent { background: var(--teal-50); border-color: transparent; }
.kpi-cell-accent .kpi-cell-value { color: var(--teal-800); }
.kpi-cell-accent .kpi-cell-label { color: var(--teal-700); }
.kpi-cell-coral { background: var(--coral-50); border-color: transparent; }
.kpi-cell-coral .kpi-cell-value { color: var(--coral-800); }
.kpi-cell-coral .kpi-cell-label { color: var(--coral-700); }

/* =====================================================
   DASHBOARD · ALERTAS (próximos a vencer)
   ===================================================== */
.dashboard-alert-card { margin-bottom: 16px; }
.alert-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 22px;
}
.alert-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
  text-decoration: none;
}
.alert-row:hover { background: var(--bg-card-soft); margin: 0 -8px; padding: 10px 8px; border-radius: 6px; }
.alert-row:last-child { border-bottom: none; }

/* =====================================================
   DASHBOARD · TIRA OPERATIVA COMPACTA (secundaria)
   ===================================================== */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}
.stat-strip-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 18px;
  background: var(--bg-card);
  text-decoration: none;
  transition: background 0.14s ease;
}
.stat-strip-item:hover { background: var(--bg-card-soft); }
.stat-strip-item strong {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-strip-item span { font-size: 11.5px; color: var(--text-secondary); }
.stat-strip-item.is-alert strong { color: var(--coral-700); }
.stat-strip-item.is-warn strong { color: var(--amber-700); }

.dashboard-summary-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.dashboard-summary-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 18px 18px 16px;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-card);
}
.dashboard-summary-card.is-accent {
  background: linear-gradient(135deg, rgba(225,245,238,0.95), rgba(255,253,248,0.95));
}
.dashboard-summary-card.is-warm {
  background: linear-gradient(135deg, rgba(250,238,218,0.95), rgba(255,253,248,0.95));
}
.dashboard-summary-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 8px;
}
.dashboard-summary-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  margin: 0;
}
.dashboard-summary-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 6px 0 0;
}

.dashboard-overview-card,
.dashboard-status-card {
  margin-bottom: 16px;
}
.dashboard-overview-grid,
.dashboard-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.dashboard-overview-item,
.dashboard-status-item {
  padding: 18px 18px 16px;
  background: var(--bg-card);
  border-right: 1px solid var(--border-soft);
}
.dashboard-overview-item:last-child,
.dashboard-status-item:last-child {
  border-right: none;
}
.dashboard-overview-label,
.dashboard-status-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 8px;
}
.dashboard-overview-value,
.dashboard-status-value {
  font-size: 31px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin: 0;
}
.dashboard-overview-value.is-negative {
  color: var(--coral-800);
}
.dashboard-overview-meta,
.dashboard-status-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 8px 0 0;
  line-height: 1.45;
}
.dashboard-status-item.is-alert {
  background: linear-gradient(135deg, rgba(250,236,231,0.92), rgba(255,253,248,0.96));
}
.dashboard-status-item.is-alert .dashboard-status-value {
  color: var(--coral-800);
}
.dashboard-status-item.is-warn {
  background: linear-gradient(135deg, rgba(250,238,218,0.92), rgba(255,253,248,0.96));
}
.dashboard-status-item.is-warn .dashboard-status-value {
  color: var(--amber-800);
}

.dashboard-secondary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.dashboard-secondary-grid-tight {
  margin-bottom: 18px;
}
.chart-card-hero {
  padding: 22px 24px;
}
.dashboard-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.dashboard-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.dashboard-panel-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 4px 0 0;
}

/* =====================================================
   CONFIGURACIÓN
   ===================================================== */

.config-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) 380px;
  gap: 18px;
  align-items: start;
}
.config-form-stack {
  display: grid;
  gap: 14px;
}
.config-section {
  display: grid;
  gap: 16px;
}
.config-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}
.config-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.config-section-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 4px 0 0;
}
.config-inline-card {
  padding: 12px 14px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  background: var(--bg-card-soft);
}
.config-value-inline {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 4px;
}
.config-value-inline strong {
  font-size: 24px;
  line-height: 1;
}
.config-color-field {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}
.config-color-field input[type="color"] {
  width: 46px;
  height: 38px;
  border: 1px solid var(--border-card);
  border-radius: 7px;
  padding: 2px;
  background: var(--bg-card);
}
.config-field-xs { max-width: 160px; }
.config-field-sm { max-width: 220px; }
.config-preview-panel {
  position: sticky;
  top: 20px;
}
.config-preview-caption {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 0 10px;
}

/* =====================================================
   BADGES (pills)
   ===================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.badge-rojo  { background: var(--coral-50); color: var(--coral-700); }
.badge-ambar { background: var(--amber-50); color: var(--amber-700); }
.badge-verde { background: var(--teal-50);  color: var(--teal-700); }
.badge-azul  { background: var(--blue-50);  color: var(--blue-700); }
.badge-gris  { background: var(--gray-50);  color: var(--gray-700); }

/* =====================================================
   LISTAS
   ===================================================== */

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-soft);
  gap: 12px;
  transition: background 0.1s ease;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--bg-card-soft); margin: 0 -8px; padding: 11px 8px; border-radius: 6px; }

.list-row-left { display: flex; align-items: center; gap: 11px; min-width: 0; }

.list-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 15px;
}

.list-title { font-size: 13px; color: var(--text-primary); margin: 0; }
.list-subtitle { font-size: 11px; color: var(--text-secondary); margin: 2px 0 0; }
.list-link { font-size: 11px; color: var(--text-secondary); display: flex; align-items: center; gap: 3px; }

/* =====================================================
   FORMULARIOS
   ===================================================== */

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control:hover { border-color: #C5C0B3; }
.form-control:focus {
  outline: none;
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(14, 22, 38, 0.07);
}
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* =====================================================
   BOTONES
   ===================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  background: var(--bg-sidebar);
  color: var(--text-on-dark);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease, background-color 0.12s ease;
  cursor: pointer;
  letter-spacing: 0.01em;
}
.btn:hover {
  opacity: 0.88;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(14, 22, 38, 0.2);
}
.btn:active {
  transform: translateY(0) scale(0.98);
  box-shadow: none;
  opacity: 1;
}

.btn i { font-size: 15px; }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-card);
}
.btn-secondary:hover { box-shadow: 0 2px 8px rgba(14, 22, 38, 0.1); background: var(--bg-card-soft); }

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

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

.btn-icon-only {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-icon-only i {
  font-size: 19px;
  line-height: 1;
}

.btn-row { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

.conversion-card {
  width: 100%;
}

.conversion-summary {
  width: 100%;
}

.conversion-summary-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin: 0 0 8px;
}

.conversion-summary-note {
  max-width: 58ch;
}

/* =====================================================
   TABLAS
   ===================================================== */

.table-wrap {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}
.listing-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.listing-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-card);
  background: rgba(255, 253, 248, 0.72);
  color: var(--text-secondary);
  transition: all 0.14s ease;
}
.listing-tab strong {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
}
.listing-tab:hover {
  color: var(--text-primary);
  border-color: rgba(14, 22, 38, 0.14);
  background: var(--bg-card);
}
.listing-tab.is-active {
  color: var(--text-primary);
  border-color: rgba(14, 22, 38, 0.16);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
}
.filters-bar .form-control { width: auto; min-width: 140px; }
.filters-bar input[type=text] { min-width: 200px; }
[data-listing-root] {
  position: relative;
  transition: opacity 0.18s ease;
}
[data-listing-root].is-loading {
  opacity: 0.58;
  pointer-events: none;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data-table th {
  text-align: left;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.table-sort-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.1s;
}
.table-sort-link:hover { color: var(--text-primary); }
.table-sort-link i {
  font-size: 12px;
  color: var(--text-muted);
  transition: color 0.1s;
}
.table-sort-link.active { color: var(--text-primary); font-weight: 600; }
.table-sort-link.active i { color: var(--text-secondary); }
table.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-primary);
  vertical-align: middle;
}
.bulk-actions-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-card-soft);
}
.bulk-actions-bar-secondary {
  border-top: 1px solid rgba(14,22,38,0.04);
}
.bulk-actions-info {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.bulk-actions-controls {
  display: flex;
  gap: 8px;
  align-items: stretch;
  flex-wrap: wrap;
}
.bulk-actions-controls .form-control {
  width: auto;
  min-width: 180px;
  height: 40px;
}
.bulk-actions-controls .btn-icon-only { align-self: stretch; height: 40px; }
.bulk-actions-bar-secondary .bulk-actions-controls .form-control {
  flex: 1 1 180px;
  min-width: 0;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr { transition: background 0.1s ease; }
table.data-table tr:hover td { background: var(--bg-card-soft); }

.table-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

.table-actions a, .table-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 18px;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
  background: none;
  border: none;
  line-height: 1;
  transition: background 0.12s ease, color 0.12s ease;
}
.table-actions a:hover, .table-actions button:hover { background: var(--bg-card-soft); color: var(--text-primary); }

.table-actions .action-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  font-size: 12px;
  line-height: 1;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.table-actions .action-chip i { font-size: 14px; }
.table-actions .action-chip:hover { background: var(--bg-card-soft); border-color: var(--border-card); }
.table-actions .action-chip.action-chip-primary { background: var(--bg-card-soft); border-color: rgba(14,22,38,0.1); }

.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-secondary);
}
.empty-state i { font-size: 36px; color: var(--text-muted); margin-bottom: 12px; display: block; }
.empty-state p { margin: 0; }

/* =====================================================
   PAGINACIÓN
   ===================================================== */

.pagination { display: flex; gap: 5px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-card);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.pagination a:hover { background: var(--bg-card-soft); }
.pagination .current { background: var(--bg-sidebar); color: var(--text-on-dark); border-color: var(--bg-sidebar); }

/* =====================================================
   LOGIN
   ===================================================== */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-page);
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-hero);
  padding: 44px 40px;
  width: 100%;
  max-width: 380px;
  animation: fadeUp 0.28s var(--ease-out) both;
}

.login-brand { display: flex; flex-direction: column; align-items: center; margin-bottom: 30px; }
.login-logo { height: 72px; width: auto; max-width: 240px; margin-bottom: 18px; display: block; }
.login-brand-mark { width: 52px; height: 52px; border-radius: 14px; font-size: 26px; margin-bottom: 14px; }
.login-brand h1 { font-family: var(--font-serif); font-size: 21px; margin: 0; }
.login-brand p { font-size: 12px; color: var(--text-secondary); margin: 5px 0 0; }
.pwa-install-btn-login { width: 100%; margin-top: 14px; justify-content: center; }

/* =====================================================
   WHATSAPP BUTTON
   ===================================================== */

.wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--teal-700);
  background: var(--teal-50);
  padding: 6px 11px;
  border-radius: 999px;
  border: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  cursor: pointer;
}
.wa-btn:hover { opacity: 0.85; transform: translateY(-1px); }

/* =====================================================
   RESPONSIVE
   ===================================================== */

/* =====================================================
   RESPONSIVE — 880px: sidebar overlay + adaptaciones generales
   ===================================================== */
@media (max-width: 880px) {
  /* Sidebar overlay */
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    width: 240px !important;
    padding: 20px 14px !important;
    transition: transform 0.22s var(--ease-out);
    z-index: 900;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .nav-count,
  .sidebar.collapsed .nav-section-title,
  .sidebar.collapsed .user-info,
  .sidebar.collapsed .user-logout {
    opacity: 1 !important; max-width: 140px !important; max-height: 22px !important;
    margin: revert !important; pointer-events: auto !important; transform: none !important;
  }
  .sidebar.collapsed .nav-item { justify-content: flex-start !important; padding: 9px 10px !important; }
  .sidebar.collapsed .nav-item::after { display: none; }
  .sidebar-toggle { display: none; }
  .mobile-menu-btn { display: flex; }
  .topbar-brand { display: flex; }

  /* Topbar sticky en mobile */
  .topbar {
    padding: 11px 16px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-page);
    border-bottom: 1px solid var(--border-card);
  }
  /* El título toma el espacio flexible y trunca para no desbordar */
  .topbar-title { flex: 1; min-width: 0; }
  .topbar-title h1 {
    font-size: 19px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .content { padding: 0 16px 36px; animation: none; }
  .card { padding: 14px 16px; }
  .topbar-actions { gap: 10px; }
  .pwa-install-btn { padding-left: 10px; padding-right: 10px; }

  /* Grids */
  .metric-grid,
  .metric-grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .dash-top, .dash-bottom { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .dashboard-priority,
  .dashboard-secondary-grid { grid-template-columns: 1fr; }
  .dashboard-priority-compact { grid-template-columns: 1fr; }
  .dashboard-signal-grid { grid-template-columns: 1fr; }
  .dashboard-overview-grid,
  .dashboard-status-grid,
  .fiscal-split { grid-template-columns: 1fr 1fr; }

  /* Rediseño dashboard */
  .kpi-trio { grid-template-columns: 1fr; }
  .alert-grid { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .facturacion-hero-aside { width: 100%; }
  .facturacion-hero-stat { flex: 1; }

  /* Config: colapsa la columna de preview */
  .config-layout { grid-template-columns: 1fr !important; gap: 14px; }
  .config-preview-panel { position: static !important; }

  /* Filtros */
  .filters-bar .form-control { min-width: 0; }
  .filters-bar input[type=text] { flex: 1 1 160px; min-width: 0; }

  /* Tabla horizontal scroll como fallback antes de 640px */
  table.data-table { display: block; overflow-x: auto; white-space: nowrap; }

  /* Toasts */
  .toast-container { right: 12px; bottom: 12px; left: 12px; }
  .toast { min-width: 0; max-width: 100%; }
}

/* =====================================================
   RESPONSIVE — 640px: tablas → tarjetas, filtros apilados
   ===================================================== */
@media (max-width: 640px) {
  .content { padding: 0 13px 40px; }
  .card { padding: 13px 15px; }
  .topbar { padding: 11px 13px; }
  .topbar-title h1 { font-size: 18px; }
  .topbar-title p { font-size: 11px; margin-top: 2px; }

  /* ---- TABLAS → TARJETAS ---- */
  /* Elimina el wrapper card (las filas llevan su propio estilo) */
  .table-wrap {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
  }

  table.data-table { display: block; overflow-x: visible; white-space: normal; }
  table.data-table thead { display: none; }
  table.data-table tbody { display: flex; flex-direction: column; gap: 10px; }

  table.data-table tr {
    display: block;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-card);
    box-shadow: 0 1px 4px rgba(14,22,38,0.06);
    overflow: hidden;
  }
  table.data-table tr:hover td { background: transparent; }

  /* Fila de título de tarjeta (primera celda con datos) */
  table.data-table td:first-child {
    background: var(--bg-card-soft);
    font-weight: 500;
    font-size: 14px;
    padding: 11px 14px;
  }
  table.data-table td:first-child::before { display: none; }

  table.data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border-soft);
    white-space: normal;
    word-break: break-word;
    font-size: 13px;
    min-height: 42px;
    gap: 10px;
  }
  table.data-table td:last-child {
    border-bottom: none;
    justify-content: flex-end;
    padding: 8px 12px;
    min-height: 0;
  }
  /* Etiqueta de columna */
  table.data-table td[data-label]::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
    white-space: nowrap;
    max-width: 40%;
  }
  /* Columna de acciones: sin etiqueta, alineada a la derecha */
  table.data-table td:not([data-label]) { justify-content: flex-end; min-height: 0; }
  table.data-table td:not([data-label])::before { display: none; }
  /* Botones de acción más grandes para touch */
  table.data-table .table-actions a,
  table.data-table .table-actions button { padding: 8px; font-size: 16px; border-radius: 9px; }

  /* ---- FILTROS APILADOS ---- */
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 14px;
  }
  .listing-tabs {
    flex-direction: column;
    gap: 7px;
  }
  .listing-tab {
    width: 100%;
    justify-content: space-between;
  }
  .filters-bar form[data-live-search] {
    flex-direction: column !important;
    align-items: stretch;
    width: 100%;
    gap: 8px;
  }
  .filters-bar form[data-live-search] input[type=text],
  .filters-bar form[data-live-search] select { width: 100% !important; min-width: 0; font-size: 15px; }
  .filters-bar form[data-live-search] button[type=submit] { width: 100%; justify-content: center; }
  /* Tabs de período/estado: que envuelvan en vez de cortarse */
  .period-toggle {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
  }
  .period-pill {
    flex: 1 1 auto;
    justify-content: center;
  }
  .period-select { width: 100% !important; min-width: 0; }
  .filters-bar form[data-live-search] .btn-icon-only { width: 100%; justify-content: center; }
  .filters-bar > .btn,
  .filters-bar > a.btn { width: 100%; justify-content: center; text-align: center; }
  .status-banner {
    flex-direction: column;
    align-items: flex-start;
  }
  .status-banner-link { white-space: normal; }
  .dashboard-hero { padding: 20px 18px; }
  .dashboard-title { font-size: 19px; }
  .dashboard-overview-item,
  .dashboard-status-item {
    border-right: none;
    border-bottom: 1px solid var(--border-soft);
  }
  .dashboard-overview-item:nth-last-child(-n+2),
  .dashboard-status-item:nth-last-child(-n+2) {
    border-bottom: none;
  }

  /* ---- PAGINACIÓN COMPACTA ---- */
  .pagination { gap: 3px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }
  .pagination a, .pagination span {
    min-width: 36px; height: 36px;
    font-size: 13px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* ---- MÉTRICAS ---- */
  .metric-value { font-size: 24px; }
  .metric-card.is-featured { padding: 18px 18px; }
  .metric-card.is-featured .metric-value { font-size: 30px; }
  .fiscal-split { grid-template-columns: 1fr 1fr; }

  /* ---- FORMULARIOS ---- */
  .btn-row { flex-direction: column; gap: 8px; }
  .btn-row .btn { width: 100%; justify-content: center; }
  .bulk-actions-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .bulk-actions-controls { flex-direction: column; align-items: stretch; gap: 8px; }
  .bulk-actions-controls .form-control,
  .bulk-actions-controls .btn { width: 100%; }

  /* ---- CUSTOM SELECT en mobile ---- */
  .cs-options { max-height: 180px; }

  /* ---- CARDS de dashboard (list-row) ---- */
  .list-row { gap: 8px; }

  .conversion-summary-meta {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .conversion-summary-note {
    max-width: none;
    font-size: 12px;
    line-height: 1.6;
  }
}

/* =====================================================
   RESPONSIVE — 480px: teléfonos pequeños
   ===================================================== */
@media (max-width: 480px) {
  .metric-grid,
  .metric-grid.cols-2,
  .metric-grid.cols-3 { grid-template-columns: 1fr; }
  .card { padding: 12px 13px; border-radius: var(--radius-lg); }
  .topbar-title h1 { font-size: 17px; }
  .topbar-title p { display: none; }
  .dashboard-summary-value,
  .dashboard-signal-value,
  .dashboard-overview-value,
  .dashboard-status-value { font-size: 24px; }
  .dashboard-overview-grid,
  .dashboard-status-grid,
  .fiscal-split,
  .fiscal-mini-grid { grid-template-columns: 1fr; }
  .dashboard-overview-item,
  .dashboard-status-item {
    border-bottom: 1px solid var(--border-soft);
  }
  .dashboard-overview-item:last-child,
  .dashboard-status-item:last-child {
    border-bottom: none;
  }
}

/* =====================================================
   TOGGLE SWITCH — checkbox con appearance:none
   ===================================================== */

.toggle-group {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

/* El propio checkbox se convierte en el toggle visualmente */
input[type="checkbox"].toggle-switch {
  -webkit-appearance: none;
  appearance: none;
  width: 42px;
  min-width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--border-card);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  margin-top: 1px;
  border: none;
  outline: none;
  transition: background 0.25s var(--ease-out), box-shadow 0.18s ease;
}

input[type="checkbox"].toggle-switch::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2), 0 1px 2px rgba(0,0,0,0.1);
  transition: transform 0.25s var(--ease-out), box-shadow 0.18s ease;
}

input[type="checkbox"].toggle-switch:checked {
  background: var(--teal-600);
}

input[type="checkbox"].toggle-switch:checked::before {
  transform: translateX(18px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

input[type="checkbox"].toggle-switch:hover {
  box-shadow: 0 0 0 4px rgba(14,22,38,0.07);
}

input[type="checkbox"].toggle-switch:focus-visible {
  box-shadow: 0 0 0 3px rgba(14,22,38,0.16);
}

/* Label del toggle — override de .form-group label */
.toggle-group label {
  margin-bottom: 0;
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  cursor: pointer;
  line-height: 1.4;
  display: inline;
}

.toggle-switch-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 3px;
  line-height: 1.45;
}

/* =====================================================
   CHECKBOX — casilla de marca (todos los que no son toggle)
   ===================================================== */

input[type="checkbox"]:not(.toggle-switch) {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--border-card);
  background: var(--bg-card);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  vertical-align: middle;
  margin: 0;
  display: inline-block;
  transition: background 0.15s var(--ease-out), border-color 0.15s var(--ease-out), box-shadow 0.18s ease;
}

input[type="checkbox"]:not(.toggle-switch)::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 12px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.14s var(--ease-out), transform 0.14s var(--ease-out);
}

input[type="checkbox"]:not(.toggle-switch):hover {
  border-color: #C5C0B3;
  background: var(--bg-card-soft);
}

input[type="checkbox"]:not(.toggle-switch):checked {
  background: var(--teal-600);
  border-color: var(--teal-600);
}

input[type="checkbox"]:not(.toggle-switch):checked::before {
  opacity: 1;
  transform: scale(1);
}

input[type="checkbox"]:not(.toggle-switch):checked:hover {
  background: var(--teal-700);
  border-color: var(--teal-700);
}

/* Estado parcial (select-all con selección incompleta) */
input[type="checkbox"]:not(.toggle-switch):indeterminate {
  background: var(--teal-600);
  border-color: var(--teal-600);
}

input[type="checkbox"]:not(.toggle-switch):indeterminate::before {
  opacity: 1;
  transform: scale(1);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3.5' stroke-linecap='round'%3E%3Cline x1='6' y1='12' x2='18' y2='12'/%3E%3C/svg%3E");
}

input[type="checkbox"]:not(.toggle-switch):focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(15,110,86,0.18);
}

/* Casilla con etiqueta al lado (opción inline) */
.checkbox-option {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  line-height: 1.4;
}

/* =====================================================
   SELECT — flecha personalizada + mejor look
   ===================================================== */

select.form-control {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238B8779' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 14px 14px;
  padding-right: 36px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.12s ease;
}

select.form-control:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%230E1626' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

select.form-control:not(:focus):hover {
  background-color: var(--bg-card-soft);
  border-color: #C5C0B3;
}

/* =====================================================
   DATE FIELD — wrapper para flatpickr
   ===================================================== */

.date-field {
  position: relative;
}

/* Icono de calendario decorativo */
.date-field::after {
  content: '';
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238B8779' stroke-width='1.8' 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");
  background-repeat: no-repeat;
  background-size: contain;
  pointer-events: none;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.date-field:focus-within::after { opacity: 0.45; }

/* Estilos para el input alternativo que crea flatpickr (altInput) */
.date-field .flatpickr-alt-input,
.date-field input[type="date"] {
  width: 100%;
  padding: 9px 36px 9px 12px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.12s ease;
  box-sizing: border-box;
}

.date-field .flatpickr-alt-input:hover,
.date-field input[type="date"]:not(:focus):hover {
  background: var(--bg-card-soft);
  border-color: #C5C0B3;
}

.date-field .flatpickr-alt-input:focus,
.date-field input[type="date"]:focus {
  outline: none;
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(14,22,38,0.07);
}

/* =====================================================
   FORM ENHANCEMENTS — microdetalles
   ===================================================== */

.form-group label {
  transition: color 0.15s ease;
}

.form-group:focus-within > label:first-child {
  color: var(--text-primary);
}

input.form-control:not(:focus):hover,
textarea.form-control:not(:focus):hover {
  background: var(--bg-card-soft);
  border-color: #C5C0B3;
}

/* Divisor visual entre secciones del formulario */
.form-divider {
  border-top: 1px solid var(--border-soft);
  padding-top: 18px;
  margin-top: 6px;
}

/* =====================================================
   CONFIRM MODAL
   ===================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14,22,38,0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 64px rgba(14,22,38,0.18), 0 0 0 1px rgba(14,22,38,0.05);
  padding: 28px 28px 24px;
  max-width: 380px;
  width: 100%;
  animation: modalBoxIn 0.22s var(--ease-out) both;
}

@keyframes modalBoxIn {
  from { opacity: 0; transform: scale(0.94) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}

.modal-icon-wrap.is-danger  { background: var(--coral-50);     color: var(--coral-700); }
.modal-icon-wrap.is-default { background: var(--bg-card-soft); color: var(--text-secondary); }

.modal-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0 0 6px;
}

.modal-body {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 22px;
  line-height: 1.65;
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* =====================================================
   CUSTOM SELECT — dropdown premium con Alpine.js
   ===================================================== */

.custom-select { position: relative; width: 100%; }

/* Botón cerrado */
.cs-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px 9px 12px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  line-height: 1.5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.12s ease;
}

.cs-btn:hover { background: var(--bg-card-soft); border-color: #C5C0B3; }

.cs-btn:focus,
.cs-btn.open {
  outline: none;
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(14,22,38,0.07);
}

/* Contenido interno con ícono */
.cs-btn-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.cs-btn-inner > i {
  font-size: 15px;
  color: var(--text-secondary);
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  transition: color 0.15s ease;
}

.cs-btn.open .cs-btn-inner > i { color: var(--text-primary); }

.cs-btn-label,
.cs-btn-inner > span:not(.cs-placeholder) {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cs-placeholder { color: var(--text-muted); flex: 1; }

/* Chevron animado */
.cs-chevron {
  font-size: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.22s var(--ease-out), color 0.15s ease;
}

.cs-chevron.rotated { transform: rotate(180deg); color: var(--text-primary); }

/* Menú */
.cs-menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  min-width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(14,22,38,0.15), 0 2px 10px rgba(14,22,38,0.07);
  z-index: 200;
  overflow: hidden;
}

/* Buscador */
.cs-search-row {
  padding: 8px 8px 5px;
  border-bottom: 1px solid var(--border-soft);
}

.cs-search {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--bg-card-soft);
  font-size: 12px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

.cs-search:focus { border-color: var(--text-primary); }

/* Lista */
.cs-options {
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
}

.cs-options::-webkit-scrollbar { width: 4px; }
.cs-options::-webkit-scrollbar-track { background: transparent; }
.cs-options::-webkit-scrollbar-thumb { background: var(--border-card); border-radius: 99px; }

.cs-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s ease;
}

.cs-option:hover { background: var(--bg-card-soft); }

.cs-option.cs-selected { background: var(--bg-card-soft); font-weight: 500; }

.cs-option > i {
  font-size: 15px;
  color: var(--text-secondary);
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}

.cs-option.cs-selected > i.cs-icon { color: var(--text-primary); }

.cs-option-label { flex: 1; min-width: 0; }

.cs-check { font-size: 13px; color: var(--teal-600); flex-shrink: 0; }

.cs-empty { padding: 14px 10px; font-size: 12px; color: var(--text-muted); text-align: center; }

/* Transiciones de apertura */
.cs-enter       { transition: opacity 0.16s ease, transform 0.16s var(--ease-out); }
.cs-enter-start { opacity: 0; transform: translateY(-6px); }
.cs-enter-end   { opacity: 1; transform: translateY(0); }
.cs-leave       { transition: opacity 0.1s ease, transform 0.1s ease; }
.cs-leave-start { opacity: 1; transform: translateY(0); }
.cs-leave-end   { opacity: 0; transform: translateY(-4px); }

/* Transiciones Alpine para el overlay */
.overlay-enter       { transition: opacity 0.18s ease; }
.overlay-enter-start { opacity: 0; }
.overlay-enter-end   { opacity: 1; }
.overlay-leave       { transition: opacity 0.15s ease; }
.overlay-leave-start { opacity: 1; }
.overlay-leave-end   { opacity: 0; }

/* =====================================================
   RIPPLE — microanimación en botones
   ===================================================== */

@keyframes ripple {
  from { opacity: 1; transform: scale(0); }
  to   { opacity: 0; transform: scale(1); }
}

/* =====================================================
   FLATPICKR — tema personalizado (beige + dark sidebar)
   ===================================================== */

.flatpickr-calendar {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-card) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: 0 12px 40px rgba(14,22,38,0.16), 0 2px 8px rgba(14,22,38,0.08) !important;
  font-family: var(--font-sans) !important;
  font-size: 13px !important;
  color: var(--text-primary) !important;
  padding: 10px !important;
  width: 296px !important;
  margin-top: 4px;
}

/* Quita las flechitas de tooltip */
.flatpickr-calendar::before,
.flatpickr-calendar::after { display: none !important; }

.flatpickr-months { padding: 2px 2px 6px; }
.flatpickr-month  { background: transparent !important; color: var(--text-primary) !important; height: 36px; }

.flatpickr-current-month {
  font-family: var(--font-serif) !important;
  font-size: 14px !important;
  color: var(--text-primary) !important;
  padding-top: 6px !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
  background: transparent !important;
  color: var(--text-primary) !important;
  font-family: var(--font-serif) !important;
  font-weight: 500;
  border: none;
  padding: 0 4px 0 0;
  -webkit-appearance: none;
  appearance: none;
}

.flatpickr-current-month input.cur-year {
  background: transparent !important;
  color: var(--text-primary) !important;
  font-family: var(--font-sans) !important;
  font-weight: 400;
  -webkit-appearance: none;
  -moz-appearance: textfield;
  appearance: none;
}
.flatpickr-current-month input.cur-year::-webkit-outer-spin-button,
.flatpickr-current-month input.cur-year::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.flatpickr-prev-month,
.flatpickr-next-month {
  padding: 7px 9px !important;
  color: var(--text-secondary) !important;
  fill: var(--text-secondary) !important;
  border-radius: var(--radius-sm);
  transition: background 0.12s ease, color 0.12s ease !important;
  top: 6px !important;
}
.flatpickr-prev-month:hover,
.flatpickr-next-month:hover {
  background: var(--bg-card-soft) !important;
  color: var(--text-primary) !important;
  fill: var(--text-primary) !important;
}
.flatpickr-prev-month svg,
.flatpickr-next-month svg { fill: inherit !important; }

/* Hace que el grid de días ocupe el ancho disponible del calendario
   en lugar del 307.875px hardcodeado por Flatpickr */
.flatpickr-rContainer        { width: 100% !important; }
.flatpickr-weekdays,
.flatpickr-weekdaycontainer  { width: 100% !important; }
.flatpickr-days              { width: 100% !important; }
.dayContainer                { min-width: 0 !important; max-width: 100% !important; width: 100% !important; }

.flatpickr-weekdays { background: transparent !important; }
.flatpickr-weekday {
  background: transparent !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
}

.dayContainer { padding: 0 !important; }

.flatpickr-day {
  color: var(--text-primary) !important;
  border-radius: var(--radius-sm) !important;
  height: 34px !important;
  line-height: 34px !important;
  font-size: 13px !important;
  border: 1px solid transparent !important;
  margin: 1px 0 !important;
  transition: background 0.1s ease, color 0.1s ease !important;
}

.flatpickr-day:hover {
  background: var(--bg-card-soft) !important;
  border-color: var(--border-card) !important;
  color: var(--text-primary) !important;
}

.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--bg-sidebar) !important;
  border-color: var(--bg-sidebar) !important;
  color: var(--text-on-dark) !important;
  font-weight: 500 !important;
}

.flatpickr-day.today {
  border-color: var(--teal-600) !important;
  color: var(--teal-700) !important;
  font-weight: 600 !important;
}

.flatpickr-day.today:hover {
  background: var(--teal-50) !important;
  border-color: var(--teal-600) !important;
  color: var(--teal-700) !important;
}

.flatpickr-day.today.selected {
  background: var(--bg-sidebar) !important;
  border-color: var(--bg-sidebar) !important;
  color: var(--text-on-dark) !important;
}

.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
  color: var(--text-muted) !important;
  opacity: 0.45 !important;
}

.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover {
  color: var(--text-muted) !important;
  opacity: 0.3 !important;
}

.numInputWrapper:hover { background: transparent !important; }
.numInputWrapper span  { border-color: var(--border-soft) !important; }

/* Input principal de flatpickr (original, oculto cuando hay altInput) */
.flatpickr-input[readonly] { cursor: pointer; }
