/* =====================================================
   SOLVEN — Main Stylesheet
   Black & White Minimalist · DS Intelligence © 2026
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ───────────────────────────────── */
:root {
  --primary:          #00C853;
  --primary-dark:     #009624;
  --primary-darker:   #006400;
  --primary-light:    #e6fff0;
  --primary-xlight:   #f0fff5;
  --accent:           #00E676;
  --accent-dim:       #b3f5d0;

  --bg:               #f9fafb;
  --sidebar-bg:       #0a0a0a;
  --sidebar-hover:    rgba(255,255,255,0.06);
  --sidebar-active:   #262626;
  --card-bg:          #fff;

  --text-primary:     #0a0a0a;
  --text-secondary:   #262626;
  --text-muted:       #6b7280;
  --text-hint:        #9ca3af;

  --border:           #e2e8f0;
  --border-light:     #f1f5f9;

  --danger:           #dc2626;
  --danger-dark:      #b91c1c;
  --danger-light:     #fef2f2;
  --danger-border:    #fecaca;
  --warning:          #f59e0b;
  --warning-light:    #fffbeb;
  --warning-border:   #fde68a;
  --info:             #00E676;
  --info-light:       #e6fff0;
  --info-border:      #b3f5d0;
  --success:          #00C853;
  --success-light:    #e6fff0;
  --success-border:   #b3f5d0;

  --shadow-xs:        0 1px 2px rgba(15,23,42,0.04);
  --shadow-sm:        0 1px 4px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md:        0 4px 12px rgba(15,23,42,0.08), 0 2px 4px rgba(15,23,42,0.04);
  --shadow-lg:        0 10px 24px rgba(15,23,42,0.10), 0 4px 8px rgba(15,23,42,0.04);
  --shadow-xl:        0 20px 40px rgba(15,23,42,0.12), 0 8px 16px rgba(15,23,42,0.06);

  --radius:           10px;
  --radius-lg:        14px;
  --radius-xl:        18px;
  --radius-2xl:       24px;
  --radius-full:      9999px;

  --sidebar-width:    256px;
  --topbar-height:    64px;
  --transition:       0.18s ease;
}

/* ── Reset ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary-darker); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

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

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.logo-circle-sm {
  width: 38px;
  height: 38px;
  background: transparent;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-logo-text h2 {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.sidebar-logo-text p {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.35);
  padding: 12px 10px 4px;
  margin-top: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  color: rgba(255,255,255,0.65);
  font-size: 12.5px;
  font-weight: 400;
  border-radius: var(--radius);
  transition: all var(--transition);
  text-decoration: none;
  margin-bottom: 1px;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: rgba(255,255,255,0.9);
  text-decoration: none;
}

.nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 500;
}

/* No left border indicator */

.nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-icon svg { stroke-width: 1.5; }

.nav-link.active .nav-icon { opacity: 0.9; }
.nav-link:hover .nav-icon   { opacity: 0.85; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.07);
}

.user-avatar {
  width: 34px;
  height: 34px;
  background: #333;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info #user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.user-info #user-role {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
}

.logout-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  padding: 5px;
  border-radius: 6px;
  transition: all var(--transition);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logout-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* ── Main Content ────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ──────────────────────────────────────── */
.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-xs);
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius);
  transition: all var(--transition);
}
.sidebar-toggle:hover { background: var(--border-light); color: var(--text-primary); }
.sidebar-toggle svg { display: block; }

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
  letter-spacing: -0.01em;
}

.topbar-date {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--border-light);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.page-content {
  flex: 1;
  padding: 24px;
}

/* ── KPI Cards ───────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 1fr;
  gap: 14px;
  margin-bottom: 22px;
}

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.kpi-card::before { display: none; }

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

.kpi-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-hint);
  order: -1;
}
.kpi-icon svg { width: 18px; height: 18px; }

.kpi-icon.danger  { color: var(--danger); }
.kpi-icon.warning { color: var(--warning); }
.kpi-icon.success { color: var(--success); }
.kpi-icon.info    { color: var(--info); }

.kpi-value {
  font-size: 19px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.kpi-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Renovaciones — horizontal KPI cards */
.kpi-grid-renov {
  grid-template-columns: repeat(4, 1fr);
}
.kpi-card-h {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
}
.kpi-card-h .kpi-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
}
.kpi-card-h .kpi-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.kpi-card-h .kpi-value {
  margin-bottom: 3px;
}

/* Divisor entre grupos de KPI cards */
.kpi-section-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0 14px;
}

.kpi-trend {
  font-size: 12px;
  font-weight: 600;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }

/* ── Charts ──────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title svg { color: #6b7280; }

.card-body { padding: 20px; }

.chart-container {
  position: relative;
  height: 260px;
}

/* ── Stats Row (mora breakdown etc.) ─────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

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

.stat-card.danger .stat-card-value  { color: #dc2626; }
.stat-card.warning .stat-card-value { color: #f59e0b; }
.stat-card.success .stat-card-value { color: var(--success); }
.stat-card.info .stat-card-value    { color: var(--primary); }

/* ── Aging Cards ─────────────────────────────────── */
.aging-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.aging-card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 16px;
  text-align: center;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), transform var(--transition);
}
.aging-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.aging-card.al-dia    { border-color: #00C853; }
.aging-card.dias-1-7  { border-color: #f59e0b; }
.aging-card.dias-8-30 { border-color: #ef4444; }
.aging-card.dias-8-90 { border-color: #dc2626; }
.aging-card.mas-90    { border-color: #7f1d1d; }

.aging-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.aging-count {
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.aging-card.al-dia    .aging-count { color: #00C853; }
.aging-card.dias-1-7  .aging-count { color: #f59e0b; }
.aging-card.dias-8-30 .aging-count { color: #ef4444; }
.aging-card.dias-8-90 .aging-count { color: #dc2626; }
.aging-card.mas-90    .aging-count { color: #7f1d1d; }

.aging-monto {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ── Bottom Grid ─────────────────────────────────── */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ── Ejecutivo Cards ─────────────────────────────── */
.ejecutivos-grid { display: flex; flex-direction: column; gap: 10px; }

.ejecutivo-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  background: var(--bg);
  transition: background var(--transition), border-color var(--transition);
}
.ejecutivo-card:hover { background: #f5f5f5; border-color: #d1d5db; }

.ejecutivo-avatar {
  width: 38px;
  height: 38px;
  background: #00C853;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.ejecutivo-info { flex: 1; min-width: 0; }
.ejecutivo-info h4 { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.ejecutivo-info p  { font-size: 12px; color: var(--text-muted); }

.ejecutivo-stats { display: flex; gap: 16px; }
.stat { text-align: center; }
.stat-value { display: block; font-size: 13.5px; font-weight: 700; line-height: 1.3; }
.stat-label { font-size: 10px; color: var(--text-muted); letter-spacing: 0.03em; }

/* ── Tables ──────────────────────────────────────── */
.table-container {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
  flex-wrap: wrap;
}

.table-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-title svg { color: #6b7280; }

.table-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; flex: 1; }

.table-wrapper { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
/* Compact variant for wide tables like renovaciones */
.data-table.renov-table { font-size: 12.5px; }
.data-table.renov-table th, .data-table.renov-table td { padding: 8px 10px; }

.data-table thead tr {
  background: var(--border-light);
}

.data-table th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  white-space: nowrap;
}

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

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

.text-right  { text-align: right  !important; }
.text-center { text-align: center !important; }

/* ── Badges ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.badge-activo, .badge-pagado {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.badge-mora, .badge-atrasado {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}
.badge-liquidado {
  background: #f8fafc;
  color: #475569;
  border: 1px solid var(--border);
}
.badge-pendiente {
  background: var(--warning-light);
  color: #92400e;
  border: 1px solid var(--warning-border);
}
.badge-master {
  background: #f0fff5;
  color: #7c3aed;
  border: 1px solid #b3f5d0;
}
.badge-ejecutivo {
  background: var(--info-light);
  color: #1d4ed8;
  border: 1px solid var(--info-border);
}
.badge-warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}
.badge-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}
.badge-danger {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  letter-spacing: 0.01em;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: #00C853;
  color: #fff;
  border-color: #00C853;
  box-shadow: 0 1px 3px rgba(102,0,170,0.25);
}
.btn-primary:hover {
  background: #009624;
  border-color: #009624;
  box-shadow: 0 3px 8px rgba(102,0,170,0.35);
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); border-color: #cbd5e1; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-dark); }

.btn-outline {
  background: transparent;
  color: #00C853;
  border-color: #00C853;
}
.btn-outline:hover { background: #e6fff0; }

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

.btn-sm  { padding: 5px 12px; font-size: 12px; }
.btn-lg  { padding: 12px 24px; font-size: 15px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

/* ── Compact action buttons for table rows ───────── */
.btn-xs {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 8px; font-size: 11px; font-weight: 500;
  border-radius: 6px; border: 1px solid var(--border);
  cursor: pointer; white-space: nowrap; line-height: 1.4;
  transition: background .15s, border-color .15s;
}
.btn-xs.btn-outline { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-xs.btn-outline:hover { background: var(--bg-secondary); }
.btn-xs.btn-secondary-xs { background: var(--bg-secondary); color: var(--text-primary); border-color: var(--border); }
.btn-xs.btn-secondary-xs:hover { background: var(--border); }
.btn-xs.btn-danger-xs { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.btn-xs.btn-danger-xs:hover { background: #fee2e2; }
.btn-xs.btn-ai-xs { background: var(--primary-xlight); color: var(--primary-dark); border-color: var(--accent-dim); }
.btn-xs.btn-ai-xs:hover { background: var(--accent-dim); }
.btn-xs.btn-ai-xs--green { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.btn-xs.btn-ai-xs--green:hover { background: #dcfce7; }
.btn-xs.btn-ai-xs--blue { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
.btn-xs.btn-ai-xs--blue:hover { background: #dbeafe; }

/* ── Forms ───────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--card-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: #00C853;
  box-shadow: 0 0 0 3px rgba(102,0,170,0.12);
}

.form-input::placeholder { color: var(--text-hint); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px; }

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

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

.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

.form-hint {
  font-size: 12px;
  color: var(--text-hint);
  margin-top: 4px;
}

.form-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 14px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Calculated preview field */
.calc-field {
  background: #f0fff5;
  border-color: #b3f5d0;
  color: #00C853;
  font-weight: 700;
}

/* Input with icon */
.input-with-icon { position: relative; }
.input-with-icon .form-input { padding-right: 44px; }
.input-icon-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color var(--transition);
}
.input-icon-btn:hover { color: var(--text-primary); }

/* Search input */
.search-input {
  padding-left: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}

/* ── Modals ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  backdrop-filter: blur(2px);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(8px);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-lg   { max-width: 720px; }
.modal-xl   { max-width: 880px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 1;
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.modal-close {
  background: var(--border-light);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.modal-close:hover { background: var(--border); color: var(--text-primary); }

.modal-body { padding: 20px 24px; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--border-light);
  background: var(--bg);
  border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
  position: sticky;
  bottom: 0;
}

/* ── Alerts ──────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid;
  margin-bottom: 14px;
  display: none;
  align-items: center;
  gap: 8px;
}
.alert.show { display: flex; }

.alert-success { background: var(--success-light); border-color: var(--success-border); color: #15803d; }
.alert-error   { background: var(--danger-light);  border-color: var(--danger-border);  color: var(--danger); }
.alert-warning { background: var(--warning-light); border-color: var(--warning-border); color: #92400e; }
.alert-info    { background: var(--info-light);    border-color: var(--info-border);    color: #1d4ed8; }

/* ── Toast Notifications ─────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text-primary);
  color: #fff;
  padding: 13px 18px;
  border-radius: var(--radius-xl);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  transition: opacity 0.28s, transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast-success { background: var(--success); color: #0a0a0a; }
.toast-error   { background: var(--danger); }
.toast-warning { background: #b45309; }
.toast-info    { background: #1e40af; }

.toast-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Pagination ──────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
  background: var(--bg);
}

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.page-btn:hover { background: #e6fff0; border-color: #00C853; color: #00C853; }
.page-btn.active { background: #00C853; border-color: #00C853; color: #fff; }

.page-info {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-left: auto;
}

/* ── Loading States ──────────────────────────────── */
.spinner {
  width: 30px;
  height: 30px;
  border: 2.5px solid var(--border);
  border-top-color: #00C853;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 20px;
  gap: 14px;
  color: var(--text-muted);
  font-size: 13.5px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 20px;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13.5px;
  text-align: center;
}

.empty-icon {
  width: 48px;
  height: 48px;
  color: var(--text-hint);
  opacity: 0.7;
}

/* ── Login Page ──────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background: none;
}

.login-container { position: relative; z-index: 1; width: 100%; max-width: 420px; }

.login-card {
  background: #fff;
  border-radius: var(--radius-2xl);
  padding: 40px;
  box-shadow: 0 32px 64px rgba(0,0,0,0.28);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-circle {
  display: none;
}

.login-logo h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.login-logo p {
  font-size: 13.5px;
  color: var(--text-muted);
}

.login-form { display: flex; flex-direction: column; gap: 4px; }

.login-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-hint);
}

/* ── Utility Classes ─────────────────────────────── */
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-warning { color: var(--warning) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }
.text-sm      { font-size: 12px; }
.text-bold    { font-weight: 700; }
.fw-600       { font-weight: 600; }

.d-flex        { display: flex; }
.align-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1  { margin-top: 4px; }
.mt-2  { margin-top: 8px; }
.mt-3  { margin-top: 16px; }
.mb-3  { margin-bottom: 16px; }
.mb-4  { margin-bottom: 24px; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}

/* RA Result Box */
.ra-result {
  background: #fafafa;
  border: 1.5px solid #e5e5e5;
  border-radius: var(--radius-xl);
  padding: 16px;
  display: none;
  margin-top: 12px;
}
.ra-result.show { display: block; }
.ra-result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.ra-item { text-align: center; padding: 8px; border-radius: var(--radius); background: rgba(255,255,255,0.6); }
.ra-item-value { font-size: 18px; font-weight: 800; color: #00C853; line-height: 1.2; }
.ra-item-label { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* Pagos progress bar */
.pagos-progress { margin-top: 6px; }
.progress-bar-bg {
  height: 5px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: #00C853;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* Actions column */
.actions { display: flex; gap: 6px; align-items: center; }

/* ── Page-specific header ────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header-left h1 {
  font-size: 21px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.page-header-left p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Comparativo Panel ───────────────────────────── */
.comparativo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.comparativo-card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  text-align: center;
}

.comparativo-card .c-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 6px;
}

.comparativo-card .c-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.comparativo-card.success .c-value { color: var(--success); }
.comparativo-card.warning .c-value { color: #00E676; }
.comparativo-card.info    .c-value { color: #ef4444; }

/* ── Doc upload areas ────────────────────────────── */
.doc-upload-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 4px;
}

.doc-upload-slot {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
}

.doc-upload-slot:hover {
  border-color: #00C853;
  background: #f0fff5;
}

.doc-upload-slot .doc-icon {
  color: var(--text-hint);
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.doc-upload-slot:hover .doc-icon { color: #00C853; }

.doc-upload-slot .doc-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.doc-upload-slot .doc-hint {
  font-size: 10.5px;
  color: var(--text-hint);
  margin-top: 3px;
}

.doc-upload-slot input[type="file"] { display: none; }

/* ── Mora Detail Analysis ────────────────────────── */
.mora-analysis-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 16px;
}

.mora-analysis-card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 16px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.mora-analysis-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.mora-analysis-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.mora-analysis-row:last-child { border-bottom: none; }

.mora-analysis-row .label { color: var(--text-secondary); }
.mora-analysis-row .value { font-weight: 700; color: var(--text-primary); }
.mora-analysis-row .value.danger { color: var(--danger); }
.mora-analysis-row .value.success { color: var(--primary); }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 1200px) {
  .aging-grid     { grid-template-columns: repeat(3, 1fr); }
  .charts-grid    { grid-template-columns: 1fr; }
  .kpi-grid       { grid-template-columns: repeat(3, 1fr); }
  .stats-row      { grid-template-columns: repeat(2, 1fr); }
  .comparativo-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .bottom-grid    { grid-template-columns: 1fr; }
  .kpi-grid       { grid-template-columns: repeat(2, 1fr); }
  .aging-grid     { grid-template-columns: repeat(3, 1fr); }
  .stats-row      { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); z-index: 300; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .page-content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .aging-grid { grid-template-columns: repeat(3, 1fr); }
  .topbar-date { display: none; }
  .login-card { padding: 28px 24px; }
  .doc-upload-grid { grid-template-columns: 1fr; }
  .comparativo-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .aging-grid { grid-template-columns: 1fr 1fr; }
  .modal { margin: 0; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .modal-overlay { align-items: flex-end; }
  .stats-row { grid-template-columns: 1fr 1fr; }
}

/* ── Ajustes page ──────────────────────────────────── */
.ajustes-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}
.ajustes-tab {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: var(--radius) var(--radius) 0 0;
  transition: color .15s, border-color .15s, background .15s;
}
.ajustes-tab:hover { color: #00C853; background: #e6fff0; }
.ajustes-tab.active { color: #00C853; border-bottom-color: #00C853; font-weight: 600; }

.ajustes-panel { display: none; }
.ajustes-panel.active { display: block; }

.ajustes-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}
.ajustes-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 14px; color: var(--text); }
.toggle-desc  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-slider { background: #171717; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

.ai-mode-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.ai-mode-btn {
  flex: 1;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: all .15s;
}
.ai-mode-btn.active {
  border-color: #171717;
  color: #171717;
  background: #f5f5f5;
}
.ai-provider-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}
.ai-provider-card:hover  { border-color: #00E676; color: #00E676; }
.ai-provider-card.active { border-color: #00C853; color: #00C853; background: #e6fff0; }

.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--border);
}
.status-dot.ok     { background: var(--success); }
.status-dot.error  { background: var(--danger); }
.status-dot.warn   { background: var(--warning); }

.template-textarea {
  width: 100%;
  min-height: 72px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: border-color .15s;
}
.template-textarea:focus { outline: none; border-color: #171717; }

.template-var {
  display: inline-block;
  background: #e5e5e5;
  color: #171717;
  font-size: 11px;
  font-family: monospace;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  margin: 2px 3px 2px 0;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.feature-card {
  background: #fafafa;
  border: 1px solid #e5e5e5;
  border-radius: var(--radius-lg);
  padding: 16px;
}
.feature-card-title {
  font-size: 13px;
  font-weight: 600;
  color: #171717;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.feature-card p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}
.badge-soon {
  background: var(--warning);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  margin-left: auto;
  text-transform: uppercase;
}
.badge-idea {
  background: var(--accent-dim);
  color: var(--primary-dark);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  margin-left: auto;
  text-transform: uppercase;
}

/* ── AI Widget ─────────────────────────────────────── */
.ai-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-top: 16px;
}
.ai-widget-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.ai-widget-title {
  font-size: 13px;
  font-weight: 600;
  color: #171717;
  flex: 1;
}
.ai-widget-icon {
  width: 28px; height: 28px;
  background: #f5f5f5;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #171717;
}
.ai-widget-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
  min-height: 40px;
}
.ai-widget-body.loading { color: var(--text-muted); font-style: italic; }
.ai-widget-body.error   { color: var(--danger); }
.ai-widget-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-ai {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1.5px solid #d1d5db;
  background: #f5f5f5;
  color: #171717;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.btn-ai:hover {
  background: #171717;
  color: #fff;
}
.btn-ai:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ── WA quick-send row in mora/clientes ────────────── */
.wa-send-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.btn-wa {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1.5px solid #25d366;
  background: #f0fdf4;
  color: #166534;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.btn-wa:hover { background: #25d366; color: #fff; }

/* ── AI suggestion chips ───────────────────────────── */
.ai-suggestion-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.ai-suggestion-chip:hover {
  border-color: #171717;
  color: #171717;
  background: #f5f5f5;
}

/* ── Intelli Floating Chatbot ───────────────────────── */
.intelli-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0a0a0a;
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 12px 18px 12px 14px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,.28), 0 2px 8px rgba(0,0,0,.15);
  transition: transform .15s, box-shadow .15s, background .15s;
  user-select: none;
  letter-spacing: .01em;
}
.intelli-fab:hover {
  background: #262626;
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,0,0,.35), 0 4px 12px rgba(0,0,0,.15);
}
.intelli-fab-icon {
  width: 26px; height: 26px;
  background: rgba(255,255,255,.18);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.intelli-fab-badge {
  position: absolute;
  top: -4px; right: -4px;
  width: 10px; height: 10px;
  background: #6b7280;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}
.intelli-fab.has-unread .intelli-fab-badge { display: block; }

.intelli-panel {
  position: fixed;
  bottom: 90px;
  right: 58px;
  width: 390px;
  max-height: 520px;
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  z-index: 8999;
  overflow: hidden;
  transform: scale(.92) translateY(16px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: transform .22s cubic-bezier(.175,.885,.32,1.275), opacity .18s ease;
}
.intelli-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}
.intelli-panel-header {
  background: linear-gradient(135deg, #0a0a0a 0%, #262626 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  flex-shrink: 0;
}
.intelli-panel-header-icon {
  width: 34px; height: 34px;
  background: rgba(255,255,255,.15);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.intelli-panel-header-info { flex: 1; min-width: 0; }
.intelli-panel-header-info h3 { font-size: 15px; font-weight: 700; line-height: 1; margin-bottom: 2px; }
.intelli-panel-header-info p { font-size: 11px; opacity: .7; margin: 0; }
.intelli-panel-close,
.intelli-panel-clear {
  background: rgba(255,255,255,.12);
  border: none;
  color: #fff;
  width: 28px; height: 28px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.intelli-panel-close:hover,
.intelli-panel-clear:hover { background: rgba(255,255,255,.24); }
.intelli-panel-clear { opacity: .75; }
.intelli-panel-clear:hover { opacity: 1; }

.intelli-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 180px;
  scroll-behavior: smooth;
}
.intelli-msgs::-webkit-scrollbar { width: 4px; }
.intelli-msgs::-webkit-scrollbar-track { background: transparent; }
.intelli-msgs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.intelli-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.intelli-msg.user { flex-direction: row-reverse; }
.intelli-msg-av {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #f5f5f5;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  color: #171717;
}
.intelli-msg.user .intelli-msg-av {
  background: #0a0a0a;
  color: #fff;
}
.intelli-msg-bub {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 3px;
  padding: 8px 11px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-primary);
  max-width: calc(100% - 40px);
  word-break: break-word;
  overflow-x: auto;
}
.intelli-msg.user .intelli-msg-bub {
  background: #0a0a0a;
  color: #fff;
  border-color: #0a0a0a;
  border-radius: 12px 12px 3px 12px;
}
.intelli-msg-bub strong { font-weight: 700; }
.intelli-msg-bub em { font-style: italic; }
.intelli-msg-bub h4, .intelli-msg-bub h5 { font-size: 12px; font-weight: 700; margin: 5px 0 2px; }
.intelli-msg-bub ul, .intelli-msg-bub ol { margin: 4px 0; padding-left: 16px; }
.intelli-msg-bub li { margin-bottom: 2px; }
.intelli-msg-bub code { background: var(--border-light); border-radius: 4px; padding: 1px 4px; font-size: 11px; font-family: monospace; }
.intelli-msg-bub pre { background: var(--border-light); border-radius: 6px; padding: 7px 10px; font-size: 11px; overflow-x: auto; margin: 5px 0; }
.intelli-msg-bub div[style*="overflow-x"] { overflow-x: auto; max-width: 100%; }
.intelli-msg-bub table { border-collapse: collapse; margin: 5px 0; font-size: 11px; min-width: max-content; }
.intelli-msg-bub th, .intelli-msg-bub td { border: 1px solid var(--border); padding: 3px 8px; white-space: nowrap; text-align: right; }
.intelli-msg-bub th:first-child, .intelli-msg-bub td:first-child { text-align: left; }
.intelli-msg-bub th { background: var(--border-light); font-weight: 600; text-align: left; }
.intelli-msg-bub p { margin: 2px 0; }
.intelli-msg-bub p:first-child { margin-top: 0; }
.intelli-msg-bub p:last-child { margin-bottom: 0; }
.intelli-msg-bub a { color: var(--primary); }

.intelli-typing-bub { display: flex; align-items: center; gap: 4px; padding: 4px 0; }
.intelli-dot { width: 6px; height: 6px; background: var(--text-hint); border-radius: 50%; animation: idot .9s ease infinite; }
.intelli-dot:nth-child(2) { animation-delay: .15s; }
.intelli-dot:nth-child(3) { animation-delay: .3s; }
@keyframes idot { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

.intelli-chips-row {
  padding: 8px 12px 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  border-top: 1px solid var(--border-light);
}
.intelli-chip {
  background: #f5f5f5;
  border: 1px solid #e5e5e5;
  color: #171717;
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background .12s;
  white-space: nowrap;
}
.intelli-chip:hover { background: #e5e5e5; }

.intelli-input-row {
  padding: 10px 12px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: var(--card-bg);
}
.intelli-inp {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  color: var(--text-primary);
  background: var(--bg);
  transition: border-color .15s;
}
.intelli-inp:focus { border-color: #171717; box-shadow: 0 0 0 3px rgba(0,0,0,.08); }
.intelli-send-btn {
  width: 36px; height: 36px;
  background: #0a0a0a;
  color: #fff;
  border: none;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.intelli-send-btn:hover:not(:disabled) { background: #262626; transform: scale(1.06); }
.intelli-send-btn:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 600px) {
  .intelli-panel { width: calc(100vw - 24px); right: 12px; bottom: 80px; }
  .intelli-fab { right: 16px; bottom: 20px; }
}
