﻿/* ============================================================
   PORTAL.CSS — LinkSend
   Sistema unificado de estilos
   ============================================================ */

:root {
  /* TEMA CLARO (Default) */
  --bg-page: #ffffff;
  --bg-surface: #fafafa;
  --bg-elevated: #ffffff;
  
  --text-primary: #0a0a0a;
  --text-secondary: #525252;
  --text-muted: #a3a3a3;
  
  --border-light: #e5e5e5;
  --border-medium: #d4d4d4;

  --estado-activa: #16a34a;
  --estado-activa-bg: #f0fdf4;
  --estado-gracia: #ca8a04;
  --estado-gracia-bg: #fefce8;
  --estado-vencida: #dc2626;
  --estado-vencida-bg: #fef2f2;
  --estado-suspendida: #737373;
  --estado-suspendida-bg: #f5f5f5;

  --accent: #171717;
  --accent-hover: #404040;

  --font-sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --space-1: 4px; --space-2: 8px; --space-3: 12px;
  --space-4: 16px; --space-5: 24px; --space-6: 32px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1);
  --shadow-xl: 0 10px 40px rgba(0,0,0,0.12);

  --t-fast: .15s ease;
  --t-base: .25s ease;

  --sidebar-width: 240px;
  --topbar-height: 64px;
}

/* ============================================================
   MODO OSCURO — Enterprise & Sobrio
   ============================================================ */
[data-theme="dark"] {
  --bg-page: #0a0a0a;
  --bg-surface: #121212;
  --bg-elevated: #171717;
  
  --text-primary: #ededed;
  --text-secondary: #a1a1aa;
  --text-muted: #52525b;
  
  --border-light: #27272a;
  --border-medium: #3f3f46;

  --accent: #fafafa;
  --accent-hover: #e5e5e5;

  --estado-activa-bg: rgba(22, 163, 74, 0.15);
  --estado-gracia-bg: rgba(202, 138, 4, 0.15);
  --estado-vencida-bg: rgba(220, 38, 38, 0.15);
  --estado-suspendida-bg: rgba(115, 115, 115, 0.15);

  --shadow-xl: 0 10px 40px rgba(0,0,0,0.4);
}

/* Ajustes específicos para que se vea Pro en oscuro */
[data-theme="dark"] .billing-hero {
    background: #000000;
    border: 1px solid var(--border-light);
}
[data-theme="dark"] .billing-kpi,
[data-theme="dark"] .chart-container,
[data-theme="dark"] .section-card,
[data-theme="dark"] .top-clinica-item,
[data-theme="dark"] .estado-item,
[data-theme="dark"] .modal-content {
    background: var(--bg-elevated);
    border-color: var(--border-light);
}
[data-theme="dark"] .billing-kpi.danger {
    background: linear-gradient(135deg, #171717 0%, rgba(220, 38, 38, 0.08) 100%);
    border-color: rgba(220, 38, 38, 0.3);
}
[data-theme="dark"] .aging-bar {
    background: #27272a;
}
[data-theme="dark"] .table-clean thead th {
    background: #121212;
    border-bottom-color: var(--border-light);
}
[data-theme="dark"] .table-clean tbody td {
    border-bottom-color: var(--border-light);
}
[data-theme="dark"] .table-clean tbody tr:hover {
    background: #1a1a1a;
}
[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #1a1a1a 25%, #27272a 50%, #1a1a1a 75%);
    background-size: 200% 100%;
}
[data-theme="dark"] .btn-primary-clean {
    background: #ffffff;
    color: #0a0a0a;
}
[data-theme="dark"] .btn-primary-clean:hover {
    background: #e5e5e5;
    color: #0a0a0a;
}
[data-theme="dark"] .btn-ver-todos:hover {
    background: #ffffff;
    color: #0a0a0a;
    border-color: #ffffff;
}
[data-theme="dark"] .form-control-clean:focus,
[data-theme="dark"] .form-select-clean:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

/* ============================================================
   RESET + BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  margin: 0;
  padding: 0;
  transition: background-color 0.3s ease, color 0.3s ease;
}
a { color: var(--accent); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; display: block; }
button { font-family: inherit; cursor: pointer; border: 0; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ============================================================
   UTILIDADES
   ============================================================ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.mt-1 { margin-top: var(--space-1); } .mt-2 { margin-top: var(--space-2); } .mt-3 { margin-top: var(--space-3); } .mt-4 { margin-top: var(--space-4); }
.mb-1 { margin-bottom: var(--space-1); } .mb-2 { margin-bottom: var(--space-2); } .mb-3 { margin-bottom: var(--space-3); } .mb-4 { margin-bottom: var(--space-4); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); }

/* ============================================================
   APP SHELL (SIDEBAR + TOPBAR)
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

/* ---------- SIDEBAR ---------- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-light);
  display: flex; flex-direction: column;
  z-index: 1040;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.sidebar-brand { padding: 18px 18px 14px; border-bottom: 1px solid var(--border-light); }
.sidebar-brand-link { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text-primary); }
.sidebar-brand-icon {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--bg-page);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
}
.sidebar-brand-text { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.02em; }

.sidebar-nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.sidebar-section-label {
  font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted); font-weight: 700; padding: 8px 10px 6px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  font-size: 0.84rem; font-weight: 500;
  color: var(--text-secondary); text-decoration: none;
  transition: all 0.15s ease; margin-bottom: 2px;
}
.sidebar-link i { font-size: 1rem; opacity: 0.75; width: 18px; text-align: center; }
.sidebar-link:hover { background: var(--bg-surface); color: var(--text-primary); }
.sidebar-link.active { background: var(--bg-surface); color: var(--text-primary); font-weight: 600; }
.sidebar-link.active i { opacity: 1; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border-light); }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 1039; }
/* ---------- TOPBAR ---------- */
.topbar-app {
  position: sticky; top: 0;
  height: var(--topbar-height);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; z-index: 1030; gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.topbar-icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: none; background: transparent; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1.05rem; transition: all 0.15s ease;
  position: relative; text-decoration: none;
}
.topbar-icon-btn:hover { background: var(--bg-surface); color: var(--text-primary); }

.topbar-dot {
  position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--estado-vencida); border: 1.5px solid var(--bg-elevated);
}
.topbar-breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--text-muted); min-width: 0; }
.topbar-breadcrumb i { font-size: 0.65rem; opacity: 0.6; }
.topbar-breadcrumb-home { font-weight: 600; color: var(--text-secondary); }
.topbar-breadcrumb-current { color: var(--text-primary); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 4px 4px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.15s; margin-left: 6px;
}
.topbar-user:hover { background: var(--bg-surface); }
.topbar-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 0.8rem;
}
.topbar-user-info { display: none; }
@media (min-width: 1024px) { .topbar-user-info { display: block; } }
.topbar-user-name { font-size: 0.78rem; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.topbar-user-role { font-size: 0.64rem; color: var(--text-muted); }
.topbar-user-chev { font-size: 0.7rem; color: var(--text-muted); }

/* ---------- MAIN ---------- */
.app-main { flex: 1; margin-left: var(--sidebar-width); min-width: 0; display: flex; flex-direction: column; }
.app-content { flex: 1; }

/* ============================================================
   LAYOUT DE CONTENIDO
   ============================================================ */
.page-container { max-width: 1400px; margin: 0 auto; padding: 28px 24px 40px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; flex-wrap: wrap; gap: 16px; }
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.03em; margin: 0; }
.page-subtitle { font-size: 0.85rem; color: var(--text-muted); margin: 4px 0 0; }
.section-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }

/* ============================================================
   KPI GRID
   ============================================================ */
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 28px; }
.kpi-card { background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius-md); padding: 16px 18px; transition: border-color 0.15s; }
.kpi-card:hover { border-color: var(--border-medium); }
.kpi-label { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; margin-bottom: 8px; }
.kpi-value { font-size: 1.55rem; font-weight: 700; color: var(--text-primary); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.kpi-value.activa { color: var(--estado-activa); } .kpi-value.gracia { color: var(--estado-gracia); }
.kpi-value.vencida { color: var(--estado-vencida); } .kpi-value.suspendida { color: var(--estado-suspendida); }
.kpi-value.mrr { color: var(--estado-activa); } .kpi-value.ingreso { color: var(--estado-gracia); }
.kpi-sub { font-size: 0.65rem; color: var(--text-muted); margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.kpi-variacion { font-size: 0.62rem; padding: 2px 6px; border-radius: 4px; font-weight: 700; display: inline-block; }
.kpi-variacion.up { background: var(--estado-activa-bg); color: var(--estado-activa); }
.kpi-variacion.down { background: var(--estado-vencida-bg); color: var(--estado-vencida); }
.kpi-grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ============================================================
   TABLA
   ============================================================ */
.table-clean { width: 100%; border-collapse: collapse; }
.table-clean thead th { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 700; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border-light); background: var(--bg-surface); white-space: nowrap; }
.table-clean tbody td { padding: 12px; border-bottom: 1px solid var(--border-light); font-size: 0.8rem; color: var(--text-secondary); vertical-align: middle; }
.table-clean tbody tr:last-child td { border-bottom: none; }
.table-clean tbody tr:hover { background: var(--bg-surface); }

/* ============================================================
   BADGES
   ============================================================ */
.badge-clean { display: inline-flex; align-items: center; gap: 4px; font-size: 0.68rem; padding: 3px 9px; border-radius: 20px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.badge-clean.success { background: var(--estado-activa-bg); color: var(--estado-activa); }
.badge-clean.warning { background: var(--estado-gracia-bg); color: var(--estado-gracia); }
.badge-clean.danger { background: var(--estado-vencida-bg); color: var(--estado-vencida); }
.badge-clean.secondary { background: var(--bg-surface); color: var(--text-secondary); }
.badge-clean.info { background: #eff6ff; color: #2563eb; }
.badge-clean.dark { background: #0a0a0a; color: white; }

/* ============================================================
   BOTONES
   ============================================================ */
.btn-primary-clean { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; background: var(--accent); color: var(--bg-page); border: none; border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: background 0.15s; font-family: var(--font-sans); text-decoration: none; }
.btn-primary-clean:hover { background: var(--accent-hover); color: var(--bg-page); }
.btn-primary-clean:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary-clean { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border-light); border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 500; cursor: pointer; transition: all 0.15s; font-family: var(--font-sans); text-decoration: none; }
.btn-secondary-clean:hover { background: var(--bg-surface); color: var(--text-secondary); }

.btn-icon-clean { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: var(--radius-sm); border: 1px solid var(--border-light); background: var(--bg-elevated); color: var(--text-secondary); cursor: pointer; transition: all 0.15s; font-size: 0.8rem; padding: 0; }
.btn-icon-clean:hover { background: var(--bg-surface); border-color: var(--border-medium); }
.btn-icon-clean.danger:hover { background: var(--estado-vencida-bg); color: var(--estado-vencida); border-color: var(--estado-vencida); }

.btn-new { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; background: var(--accent); color: var(--bg-page); border: none; border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: background 0.15s; white-space: nowrap; font-family: var(--font-sans); }
.btn-new:hover { background: var(--accent-hover); }

/* ============================================================
   SECTION CARD
   ============================================================ */
.section-card { background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius-md); overflow: hidden; margin-bottom: 20px; }
.section-card-header { padding: 16px 20px; border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.section-card-header-title { display: flex; align-items: center; gap: 10px; }
.section-card-header-title h3 { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); margin: 0; letter-spacing: -0.01em; }
.section-card-header-title i { color: var(--text-secondary); font-size: 0.95rem; }
.section-card-badge { font-size: 0.68rem; padding: 3px 10px; background: var(--bg-surface); border-radius: 20px; color: var(--text-secondary); font-weight: 600; }
.section-card-body { padding: 20px; }
.section-card-body.p-0 { padding: 0; }

/* ============================================================
   CHART CONTAINER
   ============================================================ */
.chart-container { background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius-md); padding: 18px 20px; margin-bottom: 16px; height: 100%; display: flex; flex-direction: column; }
.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.chart-title { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.chart-badge { font-size: 0.62rem; padding: 3px 8px; background: var(--bg-surface); border-radius: 4px; color: var(--text-secondary); font-weight: 600; }

/* ============================================================
   INFO GRID
   ============================================================ */
.info-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.info-item { padding: 12px 14px; background: var(--bg-surface); border-radius: var(--radius-sm); border: 1px solid var(--border-light); }
.info-item-label { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 700; margin-bottom: 4px; }
.info-item-value { font-size: 0.85rem; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.info-item-value.success { color: var(--estado-activa); }
.info-item-value.danger { color: var(--estado-vencida); }

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-label-clean { font-size: 0.68rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 5px; display: block; }
.form-control-clean, .form-select-clean { width: 100%; font-family: var(--font-sans); font-size: 0.85rem; border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 8px 12px; color: var(--text-primary); background: var(--bg-elevated); transition: border-color 0.15s, box-shadow 0.15s; }
.form-control-clean:focus, .form-select-clean:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(23, 23, 23, 0.06); }
.form-control-clean::placeholder { color: var(--text-muted); }
.form-hint { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }

.input-group-clean { display: flex; align-items: stretch; }
.input-group-clean .input-group-text-clean { display: flex; align-items: center; padding: 0 12px; background: var(--bg-surface); border: 1px solid var(--border-light); border-right: none; border-radius: var(--radius-sm) 0 0 var(--radius-sm); font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.input-group-clean .form-control-clean { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.form-switch-clean { display: flex; align-items: center; gap: 8px; }
.form-switch-clean input[type="checkbox"] { width: 36px; height: 20px; cursor: pointer; accent-color: var(--accent); }
.form-actions { display: flex; justify-content: flex-end; padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--border-light); }

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container-custom { position: fixed; top: 80px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; max-width: 400px; width: calc(100% - 40px); pointer-events: none; }
.toast-custom { pointer-events: auto; background: var(--bg-elevated); border-radius: var(--radius-md); padding: 16px 20px; box-shadow: var(--shadow-xl); border-left: 3px solid var(--accent); display: flex; align-items: flex-start; gap: 12px; animation: toastSlideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards; position: relative; overflow: hidden; }
.toast-custom::after { content: ''; position: absolute; bottom: 0; left: 0; height: 2px; width: 100%; background: var(--accent); animation: toastProgress 5s linear forwards; }
.toast-custom.toast-success { border-left-color: var(--estado-activa); }
.toast-custom.toast-success::after { background: var(--estado-activa); }
.toast-custom.toast-danger { border-left-color: var(--estado-vencida); }
.toast-custom.toast-danger::after { background: var(--estado-vencida); }
.toast-custom.toast-warning { border-left-color: var(--estado-gracia); }
.toast-custom.toast-warning::after { background: var(--estado-gracia); }
.toast-custom.toast-info { border-left-color: var(--accent); }

.toast-icon-wrap { width: 32px; height: 32px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 1rem; background: var(--bg-surface); }
.toast-body-custom { flex: 1; min-width: 0; }
.toast-title-custom { font-weight: 700; font-size: 0.82rem; color: var(--text-primary); margin-bottom: 3px; }
.toast-message-custom { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.5; word-wrap: break-word; }
.toast-close-custom { background: none; border: none; font-size: 0.9rem; color: var(--text-muted); cursor: pointer; padding: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: color 0.15s; }
.toast-close-custom:hover { color: var(--text-primary); }

@keyframes toastSlideIn { from { opacity: 0; transform: translateX(100%) scale(0.96); } to { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes toastProgress { from { width: 100%; } to { width: 0%; } }
.toast-custom.toast-exit { animation: toastSlideOut 0.25s ease forwards; }
@keyframes toastSlideOut { to { opacity: 0; transform: translateX(100%) scale(0.96); } }

/* ============================================================
   MODALES
   ============================================================ */
.modal-content { border: 1px solid var(--border-light); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-elevated); }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border-light); background: var(--bg-surface); }
.modal-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.01em; }
.modal-body { padding: 22px; max-height: calc(100vh - 220px); overflow-y: auto; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border-light); background: var(--bg-surface); }

/* ---------- LOGOUT MODAL ---------- */
.logout-modal-content { border: 1px solid var(--border-light); border-radius: var(--radius-lg); }
.logout-modal-body { padding: 32px 24px; }
.logout-modal-icon-wrap { margin-bottom: 16px; }
.logout-modal-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--bg-surface); display: flex; align-items: center; justify-content: center; margin: 0 auto; }
.logout-modal-icon i { font-size: 1.5rem; color: var(--text-secondary); }
.logout-modal-title { font-weight: 700; font-size: 1rem; margin-bottom: 8px; color: var(--text-primary); }
.logout-modal-text { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 24px; }

/* ============================================================
   HEALTH BAR
   ============================================================ */
.health-bar { width: 60px; height: 6px; background: var(--bg-surface); border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 6px; }
.health-bar-fill { height: 100%; border-radius: 3px; }
.health-bar-fill.verde { background: var(--estado-activa); }
.health-bar-fill.amarillo { background: var(--estado-gracia); }
.health-bar-fill.rojo { background: var(--estado-vencida); }
/* ============================================================
   BILLING DASHBOARD — panel.php (v2)
   ============================================================ */

/* ---------- SKELETON (loading) ---------- */
.skeleton { background: linear-gradient(90deg, #f0f0f0 25%, #e5e5e5 50%, #f0f0f0 75%); background-size: 200% 100%; animation: billingShimmer 1.5s infinite; border-radius: 4px; height: 12px; }
@keyframes billingShimmer { to { background-position: -200% 0; } }
.skeleton-text-lg { height: 36px; width: 60%; }
.skeleton-text-md { height: 22px; width: 45%; }
.skeleton-text-sm { height: 12px; width: 70%; }

/* ---------- HERO MRR (protagonista) ---------- */
.billing-hero {
    background: linear-gradient(135deg, #0a0a0a 0%, #262626 100%);
    color: #ffffff;
    border-radius: var(--radius-lg);
    padding: 32px 36px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}
.billing-hero::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 340px;
    height: 340px;
    background: radial-gradient(circle, rgba(255,255,255,0.06) 0%, transparent 70%);
    pointer-events: none;
}
.billing-hero-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: rgba(255,255,255,0.6);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.billing-hero-value {
    font-size: 2.8rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}
.billing-hero-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.7);
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}
.billing-hero .kpi-variacion.up { background: rgba(22, 163, 74, 0.18); color: #4ade80; }
.billing-hero .kpi-variacion.down { background: rgba(220, 38, 38, 0.18); color: #f87171; }

/* ---------- 3 KPIs SECUNDARIOS ---------- */
.billing-kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.billing-kpi {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    transition: border-color 0.15s;
}
.billing-kpi:hover { border-color: var(--border-medium); }
.billing-kpi.danger {
    border-color: #fecaca;
    background: linear-gradient(135deg, #ffffff 0%, #fef2f2 100%);
}
[data-theme="dark"] .billing-kpi.danger {
    background: linear-gradient(135deg, #171717 0%, rgba(220, 38, 38, 0.08) 100%);
    border-color: rgba(220, 38, 38, 0.3);
}
.billing-kpi-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 8px;
}
.billing-kpi-value {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}
.billing-kpi.danger .billing-kpi-value { color: var(--estado-vencida); }
.billing-kpi-value.success { color: var(--estado-activa); }
.billing-kpi-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.billing-kpi-meta .kpi-variacion {
    font-size: 0.62rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
}

/* ---------- AGING LIST (cartera por antigüedad) ---------- */
.aging-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.aging-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.aging-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.78rem;
}
.aging-label {
    min-width: 130px;
    font-weight: 600;
    color: var(--text-secondary);
}
.aging-monto {
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    min-width: 100px;
    text-align: right;
}
.aging-pct {
    font-size: 0.7rem;
    color: var(--text-muted);
    min-width: 50px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.aging-bar {
    height: 6px;
    background: var(--bg-surface);
    border-radius: 3px;
    overflow: hidden;
    margin-left: 142px;
    margin-right: 62px;
}
.aging-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}
.aging-bar-fill.verde    { background: var(--estado-activa); }
.aging-bar-fill.amarillo { background: var(--estado-gracia); }
.aging-bar-fill.naranja  { background: #ea580c; }
.aging-bar-fill.rojo     { background: var(--estado-vencida); }
.aging-meta {
    font-size: 0.66rem;
    color: var(--text-muted);
    margin-left: 142px;
}

/* ---------- ESTADOS LISTA (clínicas) ---------- */
.estado-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.estado-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    border: 1px solid var(--border-light);
    background: var(--bg-elevated);
}
.estado-item:hover { background: var(--bg-surface); }
.estado-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.estado-label {
    flex: 1;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.estado-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* ---------- TOP CLÍNICAS ---------- */
.top-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.top-clinica-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: var(--bg-elevated);
    transition: background 0.15s;
}
.top-clinica-item:hover { background: var(--bg-surface); }
.top-clinica-rank {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: white;
    flex-shrink: 0;
}
.top-clinica-rank.r1 { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.top-clinica-rank.r2 { background: linear-gradient(135deg, #94a3b8, #64748b); }
.top-clinica-rank.r3 { background: linear-gradient(135deg, #d97706, #92400e); }
.top-clinica-rank.r4,
.top-clinica-rank.r5 { background: linear-gradient(135deg, #9ca3af, #6b7280); }
.top-clinica-info { flex: 1; min-width: 0; }
.top-clinica-nombre {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.top-clinica-pagos {
    font-size: 0.68rem;
    color: var(--text-muted);
}
.top-clinica-monto {
    font-weight: 700;
    color: var(--estado-activa);
    font-size: 0.88rem;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* ---------- TABLA ÚLTIMOS PAGOS ---------- */
.table-date {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    color: var(--text-muted);
}
.table-clinica {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.82rem;
}
.table-monto {
    font-weight: 700;
    color: var(--estado-activa);
    font-variant-numeric: tabular-nums;
}
.badge-method {
    font-size: 0.68rem;
    padding: 3px 8px;
    background: var(--bg-surface);
    border-radius: 4px;
    color: var(--text-secondary);
    font-weight: 600;
}
.badge-estado-pago {
    font-size: 0.68rem;
    padding: 3px 9px;
    background: var(--estado-activa-bg);
    color: var(--estado-activa);
    border-radius: 20px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.btn-ver-todos {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--border-light);
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s;
}
.btn-ver-todos:hover {
    background: var(--accent);
    color: var(--bg-page);
    border-color: var(--accent);
}

/* ---------- EMPTY STATE ---------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    padding: 40px 20px;
    text-align: center;
}
.empty-state i {
    font-size: 2.5rem;
    opacity: 0.3;
    margin-bottom: 12px;
}
.empty-state p {
    font-size: 0.82rem;
    margin: 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .info-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop.is-open { display: block; }
  .app-main { margin-left: 0; }
  .topbar-breadcrumb-home { display: none; }
  .topbar-breadcrumb i:first-of-type { display: none; }
}

@media (max-width: 992px) {
    .billing-hero { padding: 24px 26px; }
    .billing-hero-value { font-size: 2.2rem; }
    .billing-kpi-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .page-container { padding: 20px 16px 32px; }
  .topbar-app { padding: 0 16px; }
  .table-clean thead th,
  .table-clean tbody td { padding: 8px 6px; font-size: 0.75rem; }
  .info-grid { grid-template-columns: 1fr 1fr; }
  .section-card-body { padding: 16px; }
  
  .billing-hero-value { font-size: 1.9rem; }
  .aging-bar { margin-left: 0; margin-right: 0; }
  .aging-meta { margin-left: 0; }
  .aging-row { flex-wrap: wrap; }
  .aging-label { min-width: 100%; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 1.25rem; }
  .page-title { font-size: 1.25rem; }
  .info-grid { grid-template-columns: 1fr; }
  .kpi-grid-4 { grid-template-columns: 1fr; }
  .toast-container-custom {
    top: 72px; right: 12px; left: 12px;
    max-width: none; width: auto;
  }
  .topbar-app { padding: 0 12px; }
  .topbar-user-info { display: none; }
  
  .billing-hero { padding: 20px 20px; }
  .billing-hero-value { font-size: 1.7rem; }
  .aging-monto { min-width: auto; }
}
