/* ============================================================
   COLLECTFLOW — Sistema de Diseño Global
   Fuentes: Outfit (UI) + DM Mono (cifras/datos)
   Tema: Modo claro y oscuro vía data-theme="dark"
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* ── Variables de tema ───────────────────────────────────── */
:root {
  /* Paleta light */
  --bg-base:        #F5F6FA;
  --bg-surface:     #FFFFFF;
  --bg-elevated:    #FFFFFF;
  --bg-sidebar:     #FFFFFF;
  --bg-hover:       #F0F2F8;
  --bg-active:      #EBF0FF;

  --text-primary:   #0D1117;
  --text-secondary: #4A5568;
  --text-muted:     #8A92A6;
  --text-inverse:   #FFFFFF;

  --border-base:    #E4E8F0;
  --border-strong:  #C8CFDF;

  --accent:         #1A4FD6;
  --accent-hover:   #1440B8;
  --accent-light:   #EBF0FF;
  --accent-text:    #1A4FD6;

  --green:          #0D7A55;
  --green-bg:       #ECFDF5;
  --green-text:     #065F46;

  --amber:          #B45309;
  --amber-bg:       #FFFBEB;
  --amber-text:     #92400E;

  --red:            #B91C1C;
  --red-bg:         #FEF2F2;
  --red-text:       #991B1B;

  --blue-bg:        #EFF6FF;
  --blue-text:      #1D4ED8;

  /* Shadows */
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:      0 10px 30px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.06);

  /* Dimensiones */
  --sidebar-w:      240px;
  --sidebar-collapsed: 64px;
  --topbar-h:       60px;
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      14px;
  --radius-xl:      20px;

  /* Transiciones */
  --transition:     180ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-base:        #0B0E17;
  --bg-surface:     #121722;
  --bg-elevated:    #1A2035;
  --bg-sidebar:     #111520;
  --bg-hover:       #1E2538;
  --bg-active:      #1B2C52;

  --text-primary:   #E8EBF4;
  --text-secondary: #8D97B4;
  --text-muted:     #525C78;
  --text-inverse:   #0D1117;

  --border-base:    #1E2538;
  --border-strong:  #2A3350;

  --accent:         #4B7BFF;
  --accent-hover:   #6990FF;
  --accent-light:   #1B2C52;
  --accent-text:    #7BA4FF;

  --green:          #10B981;
  --green-bg:       #052E1C;
  --green-text:     #34D399;

  --amber:          #F59E0B;
  --amber-bg:       #2D1F00;
  --amber-text:     #FCD34D;

  --red:            #EF4444;
  --red-bg:         #2D0F0F;
  --red-text:       #FCA5A5;

  --blue-bg:        #142040;
  --blue-text:      #93C5FD;

  --shadow-sm:      0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg:      0 10px 30px rgba(0,0,0,0.5);
}

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

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
  min-height: 100vh;
}

/* Scrollbar personalizado */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Selección */
::selection { background: var(--accent-light); color: var(--accent-text); }

/* ── Tipografía ──────────────────────────────────────────── */
h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 1.3rem; font-weight: 600; letter-spacing: -0.015em; }
h3 { font-size: 1.05rem; font-weight: 500; }
h4 { font-size: 0.9rem; font-weight: 500; }

.mono { font-family: 'DM Mono', monospace; }
.text-sm  { font-size: 0.82rem; }
.text-xs  { font-size: 0.73rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.text-amber { color: var(--amber); }
.text-red   { color: var(--red); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }

/* ── Layout shell ────────────────────────────────────────── */
.cf-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.cf-sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-base);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

.cf-sidebar.collapsed { width: var(--sidebar-collapsed); }

.cf-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border-base);
  min-height: var(--topbar-h);
  flex-shrink: 0;
}

.cf-brand-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.cf-brand-icon svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; }
.cf-brand-icon:hover { transform: scale(1.07); }

.cf-brand-text { overflow: hidden; transition: opacity var(--transition), width var(--transition); }
.cf-brand-name { font-size: 0.95rem; font-weight: 600; letter-spacing: -0.01em; color: var(--text-primary); white-space: nowrap; }
.cf-brand-tagline { font-size: 0.68rem; color: var(--text-muted); white-space: nowrap; margin-top: 1px; }

.cf-sidebar.collapsed .cf-brand-text { opacity: 0; width: 0; }

/* Nav sections */
.cf-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 0; }
.cf-nav-section {
  padding: 16px 16px 4px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  transition: opacity var(--transition);
}
.cf-sidebar.collapsed .cf-nav-section { opacity: 0; }

.cf-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 0;
  border-left: 2px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  white-space: nowrap;
  position: relative;
  text-decoration: none;
}

.cf-nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.cf-nav-item.active {
  background: var(--bg-active);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}

.cf-nav-item .nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.cf-nav-item .nav-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.cf-nav-item .nav-label { transition: opacity var(--transition); white-space: nowrap; overflow: hidden; }
.cf-sidebar.collapsed .nav-label { opacity: 0; width: 0; overflow: hidden; }

.cf-nav-badge {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
  background: var(--red-bg);
  color: var(--red);
  flex-shrink: 0;
  transition: opacity var(--transition);
}
.cf-sidebar.collapsed .cf-nav-badge { opacity: 0; }

/* Tooltip en sidebar colapsado */
.cf-sidebar.collapsed .cf-nav-item:hover::after {
  content: attr(data-label);
  position: absolute;
  left: calc(var(--sidebar-collapsed) + 8px);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-base);
  z-index: 200;
  pointer-events: none;
}

/* Sidebar footer */
.cf-sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-base);
  flex-shrink: 0;
}

.cf-user-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
  overflow: hidden;
}
.cf-user-pill:hover { background: var(--bg-hover); }
.cf-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent-text);
  font-size: 0.7rem;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.cf-user-info { overflow: hidden; flex: 1; transition: opacity var(--transition); }
.cf-user-name  { font-size: 0.82rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cf-user-role  { font-size: 0.68rem; color: var(--text-muted); white-space: nowrap; }
.cf-sidebar.collapsed .cf-user-info { opacity: 0; width: 0; overflow: hidden; }

/* ── Main area ───────────────────────────────────────────── */
.cf-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}
.cf-sidebar.collapsed ~ .cf-main { margin-left: var(--sidebar-collapsed); }

/* ── Topbar ──────────────────────────────────────────────── */
.cf-topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-base);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background var(--transition);
}

.cf-topbar-toggle {
  width: 32px; height: 32px;
  border: none; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.cf-topbar-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }
.cf-topbar-toggle svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

.cf-topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--text-muted);
  flex: 1;
}
.cf-topbar-breadcrumb .active { color: var(--text-primary); font-weight: 500; }
.cf-topbar-breadcrumb .sep { font-size: 0.7rem; }

.cf-topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cf-icon-btn {
  width: 34px; height: 34px;
  border: none; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.cf-icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.cf-icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }

.cf-icon-btn .notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
}

/* ── Content area ────────────────────────────────────────── */
.cf-content {
  flex: 1;
  padding: 28px 28px 40px;
  animation: fadeInUp 0.25s ease both;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

.cf-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.cf-page-title { font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em; }
.cf-page-subtitle { font-size: 0.82rem; color: var(--text-muted); margin-top: 3px; }

/* ── KPI Cards ───────────────────────────────────────────── */
.cf-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.cf-kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  padding: 20px 20px 16px;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition), border-color var(--transition);
  animation: fadeInUp 0.3s ease both;
}
.cf-kpi-card:nth-child(1) { animation-delay: 0.05s; }
.cf-kpi-card:nth-child(2) { animation-delay: 0.10s; }
.cf-kpi-card:nth-child(3) { animation-delay: 0.15s; }
.cf-kpi-card:nth-child(4) { animation-delay: 0.20s; }
.cf-kpi-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

.cf-kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--kpi-accent, var(--accent));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.cf-kpi-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cf-kpi-label .kpi-icon { width: 16px; height: 16px; }

.cf-kpi-value {
  font-family: 'DM Mono', monospace;
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.cf-kpi-delta {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}
.cf-kpi-delta.up   { color: var(--green); }
.cf-kpi-delta.down { color: var(--red); }
.cf-kpi-delta.flat { color: var(--text-muted); }

.cf-kpi-sparkline {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 36px;
  margin-top: 14px;
}
.cf-kpi-sparkline .bar {
  flex: 1;
  border-radius: 2px 2px 0 0;
  background: var(--kpi-accent, var(--accent));
  opacity: 0.25;
  transition: opacity 0.2s;
  min-height: 4px;
}
.cf-kpi-sparkline .bar.current { opacity: 0.8; }
.cf-kpi-card:hover .cf-kpi-sparkline .bar { opacity: 0.35; }
.cf-kpi-card:hover .cf-kpi-sparkline .bar.current { opacity: 1; }

/* ── Cards genéricos ─────────────────────────────────────── */
.cf-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  transition: box-shadow var(--transition);
}

.cf-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 0;
  margin-bottom: 16px;
}

.cf-card-title { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.cf-card-subtitle { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.cf-card-body { padding: 0 20px 20px; }
.cf-card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-base);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Tablas ──────────────────────────────────────────────── */
.cf-table-wrap { overflow-x: auto; }

.cf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.cf-table th {
  padding: 10px 14px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-base);
  text-align: left;
  white-space: nowrap;
  background: var(--bg-surface);
  position: sticky;
  top: 0;
}

.cf-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-base);
  color: var(--text-primary);
  vertical-align: middle;
}

.cf-table tbody tr {
  transition: background var(--transition);
}
.cf-table tbody tr:hover { background: var(--bg-hover); }
.cf-table tbody tr:last-child td { border-bottom: none; }

.cf-table .mono { font-family: 'DM Mono', monospace; font-size: 0.82rem; }

/* ── Badges / Pills ──────────────────────────────────────── */
.cf-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.cf-badge-dot { width: 5px; height: 5px; border-radius: 50%; }

.badge-green  { background: var(--green-bg);  color: var(--green-text); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber-text); }
.badge-red    { background: var(--red-bg);    color: var(--red-text); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue-text); }
.badge-gray   { background: var(--bg-hover);  color: var(--text-muted); }

/* ── Botones ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,79,214,0.3); }
.btn-primary:active { transform: translateY(0); box-shadow: none; }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-base);
}
.btn-outline:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: var(--red-bg);
  color: var(--red-text);
  border-color: transparent;
}
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-sm { padding: 5px 11px; font-size: 0.78rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 11px 22px; font-size: 0.95rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ── Formularios ─────────────────────────────────────────── */
.cf-form-group { margin-bottom: 18px; }

.cf-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.cf-label .required { color: var(--red); margin-left: 3px; }

.cf-input, .cf-select, .cf-textarea {
  width: 100%;
  padding: 9px 13px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  appearance: none;
}

.cf-input::placeholder, .cf-textarea::placeholder { color: var(--text-muted); }

.cf-input:hover, .cf-select:hover, .cf-textarea:hover { border-color: var(--border-strong); }

.cf-input:focus, .cf-select:focus, .cf-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 79, 214, 0.15);
}

[data-theme="dark"] .cf-input:focus,
[data-theme="dark"] .cf-select:focus,
[data-theme="dark"] .cf-textarea:focus {
  box-shadow: 0 0 0 3px rgba(75, 123, 255, 0.2);
}

.cf-input.error { border-color: var(--red); }
.cf-input.error:focus { box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.15); }

.cf-field-error { font-size: 0.75rem; color: var(--red-text); margin-top: 5px; }

.cf-input-icon { position: relative; }
.cf-input-icon .icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-muted); pointer-events: none;
}
.cf-input-icon .icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.cf-input-icon .cf-input { padding-left: 38px; }

.cf-select-wrap { position: relative; }
.cf-select-wrap::after {
  content: '';
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 0; height: 0;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid var(--text-muted);
  pointer-events: none;
}
.cf-select { padding-right: 32px; cursor: pointer; }

.cf-textarea { min-height: 90px; resize: vertical; }

/* Toggle switch */
.cf-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.cf-toggle-input { display: none; }
.cf-toggle-track {
  width: 40px; height: 22px;
  background: var(--border-base);
  border-radius: 11px;
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}
.cf-toggle-track::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.cf-toggle-input:checked + .cf-toggle-track { background: var(--accent); }
.cf-toggle-input:checked + .cf-toggle-track::after { transform: translateX(18px); }
.cf-toggle-label { font-size: 0.875rem; color: var(--text-secondary); }

/* ── Barras de distribución de cartera ───────────────────── */
.cf-dist-bar { margin-bottom: 13px; }
.cf-dist-bar-header {
  display: flex; justify-content: space-between;
  font-size: 0.78rem; margin-bottom: 5px;
  color: var(--text-secondary);
}
.cf-dist-bar-header span:last-child { font-family: 'DM Mono', monospace; font-weight: 500; color: var(--text-primary); }
.cf-dist-track {
  height: 7px;
  background: var(--bg-hover);
  border-radius: 4px;
  overflow: hidden;
}
.cf-dist-fill { height: 100%; border-radius: 4px; transition: width 0.6s cubic-bezier(0.4,0,0.2,1); }

/* ── Activity feed ───────────────────────────────────────── */
.cf-activity { list-style: none; }
.cf-activity li {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-base);
  font-size: 0.82rem;
}
.cf-activity li:last-child { border-bottom: none; }
.cf-activity-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.cf-activity-icon svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.cf-activity-body { flex: 1; }
.cf-activity-text { color: var(--text-primary); line-height: 1.45; }
.cf-activity-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* ── Modal ───────────────────────────────────────────────── */
.cf-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: backdropIn 0.2s ease;
}
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }

.cf-modal {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-base);
  animation: modalIn 0.25s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.cf-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 24px 0;
}
.cf-modal-title { font-size: 1.05rem; font-weight: 600; }
.cf-modal-close {
  width: 30px; height: 30px; border: none; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
.cf-modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.cf-modal-close svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

.cf-modal-body { padding: 20px 24px; }
.cf-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-base);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── Notificaciones toast ────────────────────────────────── */
.cf-toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
}

.cf-toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 380px;
  animation: toastIn 0.3s cubic-bezier(0.4,0,0.2,1);
}
@keyframes toastIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }
.cf-toast.removing { animation: toastOut 0.3s ease forwards; }
@keyframes toastOut { to { opacity:0; transform: translateX(20px); max-height:0; padding:0; margin:0; } }

.cf-toast-icon { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.cf-toast-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.cf-toast.success .cf-toast-icon { color: var(--green); }
.cf-toast.error   .cf-toast-icon { color: var(--red); }
.cf-toast.warning .cf-toast-icon { color: var(--amber); }
.cf-toast.info    .cf-toast-icon { color: var(--accent); }

.cf-toast-message { font-size: 0.85rem; color: var(--text-primary); line-height: 1.4; flex: 1; }

/* ── Spinner ─────────────────────────────────────────────── */
.cf-spinner {
  width: 18px; height: 18px;
  border: 2.5px solid var(--border-base);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ─────────────────────────────────────────── */
.cf-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.cf-empty svg { width: 40px; height: 40px; stroke: currentColor; fill: none; stroke-width: 1.5; margin-bottom: 12px; opacity: 0.5; }
.cf-empty-title { font-size: 0.95rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.cf-empty-text  { font-size: 0.82rem; }

/* ── Paginación ──────────────────────────────────────────── */
.cf-pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  padding: 16px 0 4px;
}
.cf-page-btn {
  min-width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.cf-page-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.cf-page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.cf-page-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.cf-page-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

/* ── Tabs ────────────────────────────────────────────────── */
.cf-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-base);
  margin-bottom: 24px;
}
.cf-tab {
  padding: 10px 18px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
  background: none; border-top: none; border-left: none; border-right: none;
}
.cf-tab:hover { color: var(--text-primary); }
.cf-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Search bar ──────────────────────────────────────────── */
.cf-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  padding: 7px 13px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.cf-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 79, 214, 0.12);
}
.cf-search svg { width: 15px; height: 15px; stroke: var(--text-muted); fill: none; stroke-width: 2; stroke-linecap: round; flex-shrink: 0; }
.cf-search input {
  border: none; outline: none;
  background: transparent;
  font-family: 'Outfit', sans-serif;
  font-size: 0.875rem;
  color: var(--text-primary);
  width: 100%;
  min-width: 0;
}
.cf-search input::placeholder { color: var(--text-muted); }

/* ── Grid helpers ────────────────────────────────────────── */
.cf-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.cf-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.cf-row-gap { display: flex; flex-direction: column; gap: 16px; }
.cf-flex { display: flex; }
.cf-flex-center { display: flex; align-items: center; }
.cf-flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-6  { gap: 6px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.p-0   { padding: 0; }

/* ── Loading skeleton ────────────────────────────────────── */
.cf-skeleton {
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-base) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Responsive ──────────────────────────────────────────── */

/* Tablet landscape: sidebar colapsado por defecto */
@media (max-width: 1024px) {
  :root { --sidebar-w: var(--sidebar-collapsed); }

  .cf-sidebar {
    width: var(--sidebar-w);
    transform: translateX(0);
  }
  /* En tablet el sidebar se colapsa visualmente */
  .cf-sidebar .cf-brand-text,
  .cf-sidebar .nav-label,
  .cf-sidebar .cf-nav-section,
  .cf-sidebar .cf-nav-badge,
  .cf-sidebar .cf-user-info { opacity: 0; width: 0; overflow: hidden; }

  .cf-main { margin-left: var(--sidebar-collapsed) !important; }
  .cf-kpi-grid { grid-template-columns: repeat(2, 1fr); }

  /* Tabla: ocultar columnas menos críticas */
  .cf-table .hide-tablet { display: none; }
}

/* Mobile: sidebar como overlay */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  .cf-sidebar {
    width: var(--sidebar-w) !important;
    transform: translateX(-100%);
    transition: transform var(--transition);
    z-index: 300;
  }
  .cf-sidebar.mobile-open {
    transform: translateX(0);
    /* Restaurar textos en mobile-open */
  }
  .cf-sidebar.mobile-open .cf-brand-text,
  .cf-sidebar.mobile-open .nav-label,
  .cf-sidebar.mobile-open .cf-nav-section,
  .cf-sidebar.mobile-open .cf-nav-badge,
  .cf-sidebar.mobile-open .cf-user-info {
    opacity: 1;
    width: auto;
    overflow: visible;
  }

  .cf-main { margin-left: 0 !important; }

  /* Topbar */
  .cf-topbar { padding: 0 14px; gap: 8px; }
  .cf-topbar-breadcrumb { display: none; }

  /* Content */
  .cf-content { padding: 14px 14px 32px; }

  /* Page header: acciones debajo del título */
  .cf-page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .cf-page-header > div:last-child { width: 100%; }
  .cf-page-header .btn { width: 100%; justify-content: center; }

  /* KPI grid: 2 columnas en mobile */
  .cf-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cf-kpi-value { font-size: 1.4rem; }

  /* Grids de formulario: 1 columna */
  .cf-grid-2, .cf-grid-3 { grid-template-columns: 1fr !important; }

  /* Modales: pantalla completa en mobile */
  .cf-modal-backdrop { padding: 0; align-items: flex-end; }
  .cf-modal {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 92vh;
    overflow-y: auto;
    width: 100%;
    max-width: 100%;
    animation: modalSlideUp 0.3s cubic-bezier(0.4,0,0.2,1);
  }
  @keyframes modalSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }
  .cf-modal-header { padding: 18px 20px 0; }
  .cf-modal-body   { padding: 16px 20px; }
  .cf-modal-footer { padding: 12px 20px 20px; }

  /* Drawers: ancho completo en mobile */
  #clientDrawer,
  #accDrawer { width: 100vw !important; max-width: 100vw !important; }

  /* Tabs con scroll horizontal */
  .cf-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; padding-bottom: 1px; }
  .cf-tab  { white-space: nowrap; flex-shrink: 0; }

  /* Tabla: scroll horizontal + columnas esenciales */
  .cf-table-wrap { -webkit-overflow-scrolling: touch; }
  .cf-table .hide-mobile { display: none; }
  .cf-table th, .cf-table td { padding: 10px 10px; font-size: 0.8rem; }

  /* Paginación: más compacta */
  .cf-pagination { gap: 2px; }
  .cf-page-btn { min-width: 28px; height: 28px; font-size: 0.78rem; }

  /* Filtros: scroll horizontal */
  .cf-card .cf-card-body [style*="display:flex"][style*="gap"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    flex-wrap: nowrap;
  }

  /* Stats grids: 2 columnas */
  #teamStats,
  #clientStats,
  #trancheKpis { grid-template-columns: repeat(2, 1fr) !important; }

  /* Dashboard: tabla + panel → stacked */
  [style*="grid-template-columns:1fr 320px"] {
    grid-template-columns: 1fr !important;
  }

  /* Botones de acción en tabla: solo iconos */
  .cf-table .btn-text-hide { display: none; }
}

/* Mobile pequeño */
@media (max-width: 400px) {
  .cf-kpi-grid { grid-template-columns: 1fr; }
  .cf-kpi-value { font-size: 1.25rem; }
  #teamStats,
  #clientStats,
  #trancheKpis { grid-template-columns: 1fr !important; }
}

/* ── Utilidades de estado ────────────────────────────────── */
.hidden { display: none !important; }
.invisible { visibility: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.cursor-pointer { cursor: pointer; }
.flex-1 { flex: 1; }
