/* ==========================================================================
   MT MANAGER - MT SOCIAL MEDIA RD
   Sistema de Diseño: Azul Royal, Celeste, Blanco y Gris
   ========================================================================== */

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

:root {
  /* Paleta Corporativa Oficial MT Social Media RD (Extraída del Logo) */
  --brand-navy: #230169;
  --brand-navy-dark: #15003f;
  --brand-navy-darker: #0b0024;
  --brand-cyan: #0099c3;
  --brand-cyan-light: #2ec4ed;
  --brand-cyan-subtle: rgba(0, 153, 195, 0.12);
  --brand-lilac: #7960a0;
  --brand-gradient: linear-gradient(135deg, #230169 0%, #0099c3 100%);
  --brand-gradient-hover: linear-gradient(135deg, #1a014e 0%, #0081a5 100%);

  /* Compatibilidad y Tokens UI */
  --navy-darker: var(--brand-navy-darker);
  --navy-dark: var(--brand-navy-dark);
  --navy-card: #1c0942;
  --royal-blue: var(--brand-navy);
  --royal-light: #371175;
  --royal-accent: var(--brand-cyan);
  --cyan-vibrant: var(--brand-cyan);
  --cyan-light: var(--brand-cyan-light);
  --cyan-subtle: var(--brand-cyan-subtle);

  /* Fondos y Neutros */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-surface: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: var(--brand-cyan);

  /* Tipografía */
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-white: #ffffff;

  /* Estados Financieros */
  --status-success: #10b981;
  --status-success-bg: rgba(16, 185, 129, 0.12);
  --status-warning: #f59e0b;
  --status-warning-bg: rgba(245, 158, 11, 0.12);
  --status-danger: #ef4444;
  --status-danger-bg: rgba(239, 68, 68, 0.12);
  --status-info: #0284c7;
  --status-info-bg: rgba(2, 132, 199, 0.12);

  /* Sombras y Elevaciones */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  --sidebar-width: 270px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

/* Reset y Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==========================================================================
   PORTAL DE AUTENTICACIÓN / LOGIN SEGURO
   ========================================================================== */
html.auth-locked .app-container {
  display: none !important;
}

html.auth-locked .auth-portal {
  display: flex !important;
}

.auth-portal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 99999;
  background: radial-gradient(circle at 50% 15%, #1f0159 0%, #0d0024 60%, #050012 100%);
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 20px;
  padding: 36px 30px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 40px rgba(0, 153, 195, 0.15);
  color: white;
  animation: authFadeIn 0.4s ease-out;
}

@keyframes authFadeIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-shake {
  animation: authShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes authShake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

.auth-header {
  text-align: center;
  margin-bottom: 26px;
}

.auth-brand-logo {
  margin-bottom: 14px;
}

.auth-logo-img {
  max-width: 220px;
  height: auto;
  max-height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 4px 16px rgba(0, 153, 195, 0.4));
}

.auth-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(0, 153, 195, 0.15);
  border: 1px solid rgba(0, 153, 195, 0.35);
  color: var(--cyan-light);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.auth-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
  color: #ffffff;
}

.auth-subtitle {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.4;
}

.auth-error-alert {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.auth-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-icon {
  position: absolute;
  left: 14px;
  color: #94a3b8;
  font-size: 14px;
}

.auth-input {
  padding-left: 40px !important;
  background: rgba(255, 255, 255, 0.07) !important;
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  color: #ffffff !important;
  font-size: 14px !important;
  border-radius: var(--radius-md) !important;
  height: 44px;
  transition: var(--transition);
}

.auth-input:focus {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: var(--cyan-light) !important;
  box-shadow: 0 0 0 3px rgba(0, 153, 195, 0.25) !important;
}

.auth-input::placeholder {
  color: #64748b;
}

.auth-toggle-pwd {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 15px;
  cursor: pointer;
  padding: 6px;
  transition: var(--transition);
}

.auth-toggle-pwd:hover {
  color: var(--cyan-light);
}

.auth-options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.auth-remember-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: #cbd5e1;
  cursor: pointer;
  user-select: none;
}

.auth-remember-label input[type="checkbox"] {
  accent-color: var(--brand-cyan);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.auth-submit-btn {
  width: 100%;
  height: 46px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, #0099c3 0%, #2563eb 100%);
  border: none;
  box-shadow: 0 6px 20px rgba(0, 153, 195, 0.35);
  cursor: pointer;
  transition: var(--transition);
}

.auth-submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0, 153, 195, 0.5);
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #64748b;
}

/* Fila de Usuario en Sidebar Footer */
.sidebar-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
}

.sidebar-user-info i {
  color: var(--cyan-light);
  font-size: 15px;
}

.btn-logout {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-logout:hover {
  background: #ef4444;
  color: white;
  border-color: #dc2626;
}

/* Layout General */
.app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
  position: relative;
}

/* ==========================================================================
   SIDEBAR CORPORATIVO
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #120033 0%, #1c0250 50%, #0b0024 100%);
  color: var(--text-white);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 4px 0 24px rgba(18, 0, 51, 0.35);
  transition: var(--transition);
}

.sidebar-header {
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.02);
  position: relative;
}

.sidebar-close-btn {
  display: none;
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
  z-index: 10;
}

.sidebar-close-btn:hover {
  background: rgba(239, 68, 68, 0.85);
  border-color: #ef4444;
  color: #ffffff;
}

/* Backdrop para Drawer Móvil */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.68);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

body.sidebar-open-locked {
  overflow: hidden !important;
}

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

.sidebar-brand-img {
  width: 100%;
  max-width: 220px;
  height: auto;
  max-height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 3px 12px rgba(0, 153, 195, 0.25));
  transition: var(--transition);
}

.sidebar-brand-img:hover {
  transform: scale(1.02);
}

.brand-info h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: white;
  line-height: 1.2;
}

.brand-info span {
  font-size: 11px;
  color: var(--cyan-light);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  padding: 12px 14px 6px;
  opacity: 0.7;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius-md);
  margin-bottom: 3px;
  transition: var(--transition);
}

.nav-item i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  color: #94a3b8;
  transition: var(--transition);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: white;
}

.nav-item:hover i {
  color: var(--cyan-light);
  transform: translateX(2px);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(35, 1, 105, 0.65) 0%, rgba(0, 153, 195, 0.22) 100%);
  color: white;
  font-weight: 600;
  border-left: 3px solid var(--brand-cyan);
}

.nav-item.active i {
  color: var(--brand-cyan-light);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
}

.monthly-portfolio-badge {
  background: rgba(255, 255, 255, 0.05);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.monthly-portfolio-badge span {
  font-size: 10.5px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
}

.monthly-portfolio-badge strong {
  font-size: 17px;
  color: var(--cyan-light);
  font-weight: 700;
  display: block;
  margin-top: 2px;
}

/* ==========================================================================
   ÁREA DE CONTENIDO PRINCIPAL
   ========================================================================== */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

.top-navbar {
  height: 68px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.top-nav-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-main);
  cursor: pointer;
}

.page-title-header {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy-dark);
}

.cloud-sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  transition: var(--transition);
  cursor: pointer;
  user-select: none;
}

.cloud-sync-badge.synced {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.cloud-sync-badge.syncing {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.cloud-sync-badge.error {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

@media (max-width: 600px) {
  .cloud-sync-badge .sync-lbl {
    display: none;
  }
  .cloud-sync-badge {
    padding: 4px 7px;
  }
}

.top-nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.content-body {
  padding: 32px;
  flex: 1;
}

/* ==========================================================================
   BOTONES Y CONTROLES UI
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1.2;
}

.btn-primary {
  background: var(--brand-gradient);
  color: white;
  box-shadow: 0 2px 8px rgba(35, 1, 105, 0.28);
}

.btn-primary:hover {
  background: var(--brand-gradient-hover);
  box-shadow: 0 4px 14px rgba(35, 1, 105, 0.4);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: white;
}

.btn-success:hover {
  background: #047857;
  transform: translateY(-1px);
}

.btn-outline-primary {
  background: transparent;
  border-color: var(--royal-accent);
  color: var(--royal-blue);
}

.btn-outline-primary:hover {
  background: var(--royal-blue);
  color: white;
}

.btn-outline-secondary {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}

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

.btn-danger {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  color: white;
  border-color: #dc2626;
}

.btn-danger:hover {
  background: #b91c1c;
  transform: translateY(-1px);
}

.btn-warning {
  background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  color: white;
  border-color: #d97706;
}

.btn-warning:hover {
  background: #b45309;
  transform: translateY(-1px);
}

.btn-outline-danger {
  background: transparent;
  border-color: #fca5a5;
  color: #dc2626;
}

.btn-outline-danger:hover {
  background: #fee2e2;
  border-color: #dc2626;
  color: #b91c1c;
}

.btn-outline-warning {
  background: transparent;
  border-color: #fde68a;
  color: #d97706;
}

.btn-outline-warning:hover {
  background: #fef3c7;
  border-color: #d97706;
  color: #b45309;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: white;
  transition: var(--transition);
}

.btn-xs:hover {
  background: var(--bg-surface);
  border-color: var(--royal-blue);
  color: var(--royal-blue);
}

.btn-icon {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: white;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  color: var(--royal-blue);
  border-color: var(--royal-accent);
  background: var(--bg-surface);
}

.btn-icon-danger {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 68, 68, 0.2);
  background: var(--status-danger-bg);
  color: var(--status-danger);
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon-danger:hover {
  background: var(--status-danger);
  color: white;
}

/* ==========================================================================
   TARJETAS Y METRICS GRID
   ========================================================================== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 24px;
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
}

.card-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy-dark);
}

.card-body {
  padding: 24px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.metric-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: #cbd5e1;
}

.metric-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--royal-blue);
}

.metric-card.accent-cyan::before { background: var(--cyan-vibrant); }
.metric-card.accent-green::before { background: var(--status-success); }
.metric-card.accent-amber::before { background: var(--status-warning); }
.metric-card.accent-red::before { background: var(--status-danger); }

.metric-lbl {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
}

.metric-val {
  font-size: 24px;
  font-weight: 800;
  color: var(--navy-dark);
  margin: 6px 0 4px;
  display: block;
  letter-spacing: -0.5px;
}

.metric-sub {
  font-size: 12px;
  color: var(--text-light);
}

/* ==========================================================================
   TABLAS Y FILAS
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background: #f8fafc;
  padding: 13px 18px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13.5px;
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background-color: #f8fafc;
}

.table-row-danger {
  background-color: rgba(239, 68, 68, 0.03);
}

.table-row-danger:hover {
  background-color: rgba(239, 68, 68, 0.06) !important;
}

/* ==========================================================================
   BADGES Y ESTADOS
   ========================================================================== */
.badge-status, .badge, [class*="badge-"] {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-success { background: var(--status-success-bg); color: var(--status-success); }
.badge-warning { background: var(--status-warning-bg); color: var(--status-warning); }
.badge-danger { background: var(--status-danger-bg); color: var(--status-danger); }
.badge-info { background: var(--status-info-bg); color: var(--status-info); }
.badge-secondary { background: #e2e8f0; color: #475569; }

.badge-status.pagado { background: var(--status-success-bg); color: var(--status-success); }
.badge-status.abono { background: var(--status-warning-bg); color: #d97706; }
.badge-status.atrasado { background: var(--status-danger-bg); color: var(--status-danger); }
.badge-status.pendiente { background: rgba(59, 130, 246, 0.1); color: var(--royal-blue); }

.badge-status.completado { background: var(--status-success-bg); color: var(--status-success); }
.badge-status.en_proceso { background: rgba(6, 182, 212, 0.12); color: #0284c7; }

.badge-ncf {
  font-family: 'JetBrains Mono', monospace;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: var(--navy-dark);
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
}

/* ==========================================================================
   TARJETAS DE CLIENTES GRID
   ========================================================================== */
.client-tabs-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.client-tab-btn {
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.client-tab-btn.active {
  background: var(--royal-blue);
  color: white;
  box-shadow: 0 2px 6px rgba(29, 78, 216, 0.25);
}

.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.client-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  overflow: hidden;
}

.client-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
  transform: translateY(-2px);
}

.client-card-header {
  padding: 20px 20px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid #f1f5f9;
}

.client-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--brand-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 4px 10px rgba(35, 1, 105, 0.25);
  flex-shrink: 0;
}

.client-avatar.lg {
  width: 64px;
  height: 64px;
  font-size: 22px;
}

.client-header-info {
  flex: 1;
  min-width: 0;
}

.client-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy-dark);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-name:hover {
  color: var(--royal-blue);
}

.client-type-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--royal-accent);
}

.client-type-tag.ocasional {
  color: #8b5cf6;
}

.client-card-body {
  padding: 16px 20px;
  flex: 1;
}

.client-info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.client-info-row i {
  width: 16px;
  color: #94a3b8;
  font-size: 13px;
}

.client-financial-box {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 12px;
  margin: 14px 0 10px;
  display: flex;
  justify-content: space-between;
}

.fin-stat {
  display: flex;
  flex-direction: column;
}

.fin-lbl {
  font-size: 10.5px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-light);
}

.fin-val {
  font-size: 14.5px;
  font-weight: 700;
  margin-top: 2px;
}

.client-status-banner {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.client-card-footer {
  padding: 12px 20px;
  background: #f8fafc;
  border-top: 1px solid #f1f5f9;
  display: flex;
  gap: 8px;
}

.client-card-footer button {
  flex: 1;
}

/* ==========================================================================
   ALERTAS DE VENCIMIENTO (COBROS)
   ========================================================================== */
.due-alerts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.due-alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: white;
  transition: var(--transition);
}

.due-alert-item:hover {
  border-color: #cbd5e1;
}

.due-alert-item.alert-danger-row {
  border-left: 4px solid var(--status-danger);
  background: rgba(239, 68, 68, 0.02);
}

.due-alert-item.alert-warning-row {
  border-left: 4px solid var(--status-warning);
  background: rgba(245, 158, 11, 0.02);
}

.due-alert-item.alert-info-row {
  border-left: 4px solid var(--status-info);
}

.due-alert-info strong {
  font-size: 14px;
  color: var(--navy-dark);
}

.due-alert-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.due-alert-amount {
  text-align: right;
}

.due-alert-amount .amount-val {
  font-size: 15px;
  font-weight: 700;
  display: block;
  margin-bottom: 2px;
}

/* ==========================================================================
   COMPROBANTES FISCALES NCF CARDS
   ========================================================================== */
.ncf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.ncf-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.ncf-card.ncf-warning {
  border-color: var(--status-warning);
  background: rgba(245, 158, 11, 0.02);
}

.ncf-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.ncf-code-badge {
  background: var(--navy-dark);
  color: white;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
}

.ncf-card-header h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy-dark);
}

.ncf-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.4;
  min-height: 35px;
}

.ncf-metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--bg-surface);
  padding: 12px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  text-align: center;
}

.ncf-stat-lbl {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-light);
  display: block;
}

.ncf-stat-val {
  font-size: 13.5px;
  font-weight: 700;
  display: block;
  margin-top: 2px;
}

.ncf-progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan-vibrant), var(--royal-blue));
  border-radius: 4px;
}

.ncf-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.ncf-card-footer button {
  width: 100%;
}

/* ==========================================================================
   FORMULARIOS Y MODALES
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-backdrop.active {
  display: flex;
}

.modal-dialog {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-dialog.lg {
  max-width: 900px;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy-dark);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-light);
  cursor: pointer;
  transition: var(--transition);
}

.modal-close-btn:hover {
  color: var(--status-danger);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: #f8fafc;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy-dark);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  color: var(--text-main);
  background: white;
  transition: var(--transition);
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--royal-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

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

.invoice-item-row, .quote-item-row {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #f8fafc;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  border: 1px solid var(--border-color);
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.flex-3 { flex: 3; }
.flex-auto { flex: 0 0 auto; }

.item-subtotal-display {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-weight: 700;
  color: var(--navy-dark);
}

.totals-preview-box {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 16px;
  border: 1px solid var(--border-color);
}

.totals-preview-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 13.5px;
}

.totals-preview-row.grand-total {
  border-top: 1px solid var(--border-color);
  padding-top: 8px;
  margin-top: 8px;
  font-size: 16px;
  font-weight: 800;
  color: var(--royal-blue);
}

/* ==========================================================================
   DOCUMENTO OFICIAL LISTO PARA IMPRIMIR / PDF
   ========================================================================== */
.print-document {
  background: white;
  padding: 36px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  color: #1e293b;
  font-size: 13px;
  max-width: 820px;
  margin: 0 auto;
}

.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 24px;
  border-bottom: 3px solid var(--brand-navy);
  margin-bottom: 24px;
}

.doc-brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.doc-logo-img {
  max-width: 190px;
  max-height: 68px;
  height: auto;
  object-fit: contain;
}

.doc-logo-mark {
  width: 54px;
  height: 54px;
  background: var(--brand-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: white;
}

.doc-company-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--navy-dark);
  letter-spacing: -0.5px;
}

.doc-company-sub {
  font-size: 12px;
  color: var(--royal-blue);
  font-weight: 600;
  margin-bottom: 6px;
}

.doc-company-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

.doc-meta-box {
  text-align: right;
}

.doc-type-badge {
  display: inline-block;
  background: var(--royal-blue);
  color: white;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 4px;
  letter-spacing: 1px;
}

.doc-type-badge.quote-badge {
  background: #0891b2;
}

.doc-number {
  font-size: 20px;
  font-weight: 800;
  color: var(--navy-dark);
  margin: 6px 0;
  font-family: 'JetBrains Mono', monospace;
}

.doc-date-row {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.doc-ncf-box {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
  text-align: right;
}

.ncf-lbl {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  display: block;
}

.ncf-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 800;
  color: var(--royal-blue);
  display: block;
}

.ncf-desc {
  font-size: 10px;
  color: #64748b;
  display: block;
}

.doc-client-card {
  display: flex;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 18px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.client-box-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 4px;
}

.client-box-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--navy-dark);
  margin-bottom: 6px;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.doc-table th {
  background: #f1f5f9;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--navy-dark);
  border-bottom: 2px solid var(--border-color);
}

.doc-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  font-size: 12.5px;
}

.doc-footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.doc-banking-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
}

.doc-banking-box h4 {
  font-size: 12.5px;
  color: var(--navy-dark);
  margin-bottom: 8px;
}

.account-num {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--royal-blue);
}

.banking-notes {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.doc-totals-box {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 13px;
}

.total-row.grand-total {
  border-top: 2px solid var(--royal-blue);
  padding-top: 10px;
  margin-top: 10px;
  font-size: 16px;
  font-weight: 800;
  color: var(--royal-blue);
}

.doc-legal-notes {
  border-top: 1px dashed var(--border-color);
  padding-top: 14px;
  margin-top: 14px;
  font-size: 11px;
  color: var(--text-muted);
}

.doc-signature-row {
  display: flex;
  justify-content: space-around;
  margin-top: 48px;
}

.signature-line {
  border-top: 1px solid #94a3b8;
  width: 220px;
  text-align: center;
  padding-top: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Cotización - Ítems con Alcance y Detalles */
.quote-item-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  transition: var(--transition);
}

.quote-item-card:hover {
  border-color: var(--brand-cyan);
  box-shadow: 0 4px 12px rgba(0, 153, 195, 0.08);
}

.quote-item-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.quote-item-bottom {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
}

.flash-highlight {
  animation: flashHighlight 1.2s ease-out;
}

@keyframes flashHighlight {
  0% { background-color: rgba(0, 153, 195, 0.25); }
  100% { background-color: #ffffff; }
}

/* Documento Oficial de Cotización - Detalles de Servicio */
.doc-service-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--navy-dark);
}

.doc-item-details-box {
  margin-top: 6px;
  padding: 8px 12px;
  background: #f8fafc;
  border-left: 3px solid var(--brand-cyan);
  border-radius: 4px;
  font-size: 11px;
  color: #334155;
  line-height: 1.45;
}

.doc-details-paragraph {
  margin-bottom: 6px;
}

.doc-details-section-title {
  font-weight: 800;
  font-size: 10.5px;
  color: var(--navy-dark);
  margin-top: 6px;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.doc-details-bullets {
  margin: 2px 0 6px 18px;
  padding: 0;
}

.doc-details-bullets li {
  margin-bottom: 2px;
}

/* Condiciones Generales de Contratación */
.doc-contract-terms-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 14px;
}

.doc-terms-header-title {
  font-size: 10.5px;
  font-weight: 800;
  color: var(--navy-dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  border-bottom: 1px solid #cbd5e1;
  padding-bottom: 3px;
}

.doc-contract-terms-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 12px;
}

.doc-contract-term-item {
  font-size: 9.5px;
  color: #475569;
  line-height: 1.35;
  display: flex;
  gap: 4px;
}

.term-index {
  font-weight: 700;
  color: var(--royal-blue);
  flex-shrink: 0;
}

.term-content {
  flex: 1;
}

.doc-slogan-bar {
  font-size: 11px;
  color: var(--royal-blue);
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   TOASTS Y NOTIFICACIONES
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--navy-dark);
  border-left: 4px solid var(--royal-blue);
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 280px;
}

.toast-success { border-left-color: var(--status-success); }
.toast-success i { color: var(--status-success); }
.toast-error { border-left-color: var(--status-danger); }
.toast-error i { color: var(--status-danger); }
.toast-warning { border-left-color: var(--status-warning); }
.toast-warning i { color: var(--status-warning); }
.toast-info { border-left-color: var(--cyan-vibrant); }
.toast-info i { color: var(--cyan-vibrant); }

.toast.fade-out {
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.3s ease;
}

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

/* ==========================================================================
   UTILIDADES
   ========================================================================== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-mono { font-family: 'JetBrains Mono', monospace; }
.text-primary { color: var(--royal-blue); }
.text-success { color: var(--status-success); }
.text-danger { color: var(--status-danger); }
.text-info { color: var(--status-info); }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.block { display: block; }
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-4 { gap: 16px; }

.action-buttons-group {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.search-filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
}

.search-input-wrapper i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
}

.search-input-wrapper input {
  padding-left: 38px;
}

/* Panel de Creación Rápida de Cliente en Facturas y Cotizaciones */
.quick-client-panel {
  background: #f8fafc;
  border: 1.5px solid #0099c3;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 18, 46, 0.08);
  animation: fadeIn 0.2s ease-out;
}

.quick-type-card {
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  padding: 8px 12px;
  border-radius: 6px;
  transition: all 0.2s ease;
  user-select: none;
}

.quick-type-card:hover {
  border-color: #0047bb;
  background: #f0f7ff;
}

.quick-type-card.active {
  border-color: #0047bb !important;
  background: #eef4ff !important;
  box-shadow: 0 0 0 1px #0047bb;
}

/* ==========================================================================
   ESTILOS DE IMPRESIÓN Y DESCARGA A PDF (@media print)
   ========================================================================== */
@media print {
  @page {
    size: letter portrait;
    margin: 0 !important; /* Elimina automáticamente la fecha, título y URL que agrega Chrome */
  }

  *, *:before, *:after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    box-sizing: border-box !important;
  }

  html {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  body {
    display: block !important;
    position: static !important;
    background: #ffffff !important;
    color: #0f172a !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    font-size: 11pt !important;
    line-height: 1.45 !important;
    overflow: visible !important;
  }

  /* Ocultar ABSOLUTAMENTE TODA la estructura de la web app para evitar que expanda el ancho a 100vw */
  .app-container,
  aside,
  header,
  main,
  nav,
  .sidebar,
  .top-navbar,
  .main-wrapper,
  .content-body,
  .view-section,
  .toast-container,
  .modal-header,
  .modal-footer,
  .btn,
  .btn-sm,
  .btn-xs,
  .btn-icon,
  .modal-close-btn,
  .client-detail-actions,
  .search-filter-bar,
  .monthly-portfolio-badge,
  .modal-backdrop:not(.active) {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    position: absolute !important;
    overflow: hidden !important;
  }

  /* El modal activo toma el 100% del ancho del papel sin fondos oscuros ni límites de 900px */
  .modal-backdrop.active,
  #invoicePreviewModal.active,
  #quotePreviewModal.active,
  #receiptModal.active,
  #accountStatementModal.active {
    position: static !important;
    display: block !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    overflow: visible !important;
    z-index: auto !important;
  }

  .modal-backdrop.active .modal-dialog,
  .modal-dialog,
  .modal-dialog.lg,
  #invoicePreviewModal .modal-dialog,
  #quotePreviewModal .modal-dialog,
  #receiptModal .modal-dialog,
  #accountStatementModal .modal-dialog {
    display: block !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    animation: none !important;
    transform: none !important;
    overflow: visible !important;
  }

  .modal-backdrop.active .modal-body,
  .modal-body,
  #invoicePreviewContent,
  #quotePreviewContent,
  #receiptModalContent,
  #accountStatementContent {
    display: block !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    max-height: none !important;
  }

  /* Documento oficial ajustado al 100% de la página sin cabeceras del navegador */
  .print-document,
  #printableInvoice,
  #printableQuote,
  #printableReceipt,
  #printableAccountStatement {
    display: block !important;
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 12mm 14mm 12mm 14mm !important;
    border: none !important;
    box-shadow: none !important;
    background: #ffffff !important;
    page-break-after: avoid;
    break-after: avoid;
  }

  /* Encabezado expandido a todo el ancho */
  .doc-header {
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    margin-bottom: 14px !important;
    padding-bottom: 12px !important;
    border-bottom: 3px solid #00122e !important;
  }

  .doc-brand {
    display: flex !important;
    align-items: center !important;
    gap: 16px !important;
  }

  .doc-logo-img {
    max-width: 195px !important;
    max-height: 64px !important;
    object-fit: contain !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .doc-company-name {
    font-size: 19px !important;
    font-weight: 800 !important;
    color: #00122e !important;
    letter-spacing: -0.5px !important;
  }

  .doc-company-sub {
    font-size: 11.5px !important;
    color: #0047bb !important;
    font-weight: 600 !important;
    margin-bottom: 4px !important;
  }

  .doc-company-meta {
    font-size: 10.5px !important;
    color: #475569 !important;
    line-height: 1.4 !important;
  }

  .doc-meta-box {
    text-align: right !important;
  }

  .doc-type-badge {
    display: inline-block !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    background-color: #0047bb !important;
    color: #ffffff !important;
    padding: 4px 12px !important;
    border-radius: 4px !important;
    font-size: 11.5px !important;
    font-weight: 800 !important;
    letter-spacing: 0.5px !important;
  }

  .doc-type-badge.quote-badge {
    background-color: #0891b2 !important;
    color: #ffffff !important;
  }

  .doc-number {
    font-size: 21px !important;
    font-weight: 800 !important;
    color: #00122e !important;
    margin: 4px 0 !important;
    font-family: 'JetBrains Mono', monospace !important;
  }

  .doc-date-row {
    font-size: 11px !important;
    color: #475569 !important;
    margin-bottom: 2px !important;
  }

  .quote-status-tag {
    margin-top: 4px !important;
    font-size: 10px !important;
    font-weight: 700 !important;
  }

  /* Tarjeta de Información del Cliente a todo el ancho */
  .doc-client-card {
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    padding: 12px 18px !important;
    margin-bottom: 14px !important;
    border-radius: 6px !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .client-box-title {
    font-size: 10px !important;
    font-weight: 700 !important;
    color: #64748b !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    margin-bottom: 3px !important;
    display: block !important;
  }

  .client-box-name {
    font-size: 16px !important;
    font-weight: 800 !important;
    color: #00122e !important;
    margin-bottom: 4px !important;
  }

  /* Tabla de Servicios a todo el ancho */
  .doc-table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-bottom: 14px !important;
    table-layout: auto !important;
  }

  .doc-table th {
    background: #f1f5f9 !important;
    color: #00122e !important;
    padding: 9px 12px !important;
    border-bottom: 2px solid #cbd5e1 !important;
    font-size: 10.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .doc-table td {
    padding: 10px 12px !important;
    border-bottom: 1px solid #e2e8f0 !important;
    font-size: 11.5px !important;
    vertical-align: top !important;
  }

  .doc-table tr {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .doc-service-title {
    font-size: 13px !important;
    font-weight: 700 !important;
    color: #00122e !important;
  }

  .doc-item-details-box {
    background: #f8fafc !important;
    border-left: 3px solid #0099c3 !important;
    padding: 8px 12px !important;
    margin-top: 5px !important;
    font-size: 10.5px !important;
    line-height: 1.45 !important;
    color: #334155 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .doc-details-paragraph {
    margin-bottom: 4px !important;
  }

  .doc-details-section-title {
    font-weight: 800 !important;
    font-size: 10px !important;
    color: #00122e !important;
    margin-top: 5px !important;
    margin-bottom: 2px !important;
    text-transform: uppercase !important;
  }

  .doc-details-bullets {
    margin: 2px 0 4px 16px !important;
  }

  .doc-details-bullets li {
    margin-bottom: 2px !important;
  }

  /* Grid de Cuentas Bancarias y Totales */
  .doc-footer-grid {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1.35fr 1fr !important;
    gap: 16px !important;
    margin-bottom: 12px !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .doc-banking-box {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    padding: 12px 14px !important;
    border-radius: 6px !important;
    font-size: 11px !important;
    line-height: 1.45 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .doc-banking-box h4 {
    font-size: 11.5px !important;
    font-weight: 700 !important;
    color: #00122e !important;
    margin-bottom: 6px !important;
  }

  .doc-totals-box {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    padding: 12px 16px !important;
    border-radius: 6px !important;
  }

  .total-row {
    display: flex !important;
    justify-content: space-between !important;
    font-size: 12px !important;
    margin-bottom: 5px !important;
  }

  .total-row.grand-total {
    border-top: 2px solid #0047bb !important;
    color: #0047bb !important;
    font-size: 15px !important;
    font-weight: 800 !important;
    padding-top: 7px !important;
    margin-top: 7px !important;
  }

  /* Observaciones */
  .doc-legal-notes {
    border-top: 1px dashed #cbd5e1 !important;
    padding-top: 8px !important;
    margin-top: 8px !important;
    font-size: 10.5px !important;
    color: #475569 !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* Condiciones Contractuales en 2 columnas balanceadas */
  .doc-contract-terms-card {
    width: 100% !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 6px !important;
    padding: 8px 12px !important;
    margin-top: 8px !important;
    page-break-inside: avoid;
    break-inside: avoid;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .doc-terms-header-title {
    font-size: 10px !important;
    font-weight: 800 !important;
    color: #00122e !important;
    margin-bottom: 5px !important;
    border-bottom: 1px solid #cbd5e1 !important;
    padding-bottom: 2px !important;
    text-transform: uppercase !important;
  }

  .doc-contract-terms-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 3px 12px !important;
  }

  .doc-contract-term-item {
    font-size: 8.5px !important;
    line-height: 1.25 !important;
    color: #475569 !important;
  }

  .term-index {
    font-weight: 700 !important;
    color: #0047bb !important;
  }

  /* Slogan y Firmas de Aceptación a ambos extremos */
  .doc-slogan-bar {
    font-size: 10px !important;
    margin: 10px 0 6px 0 !important;
    color: #0047bb !important;
  }

  .doc-signature-row {
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
    margin-top: 26px !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .signature-line {
    border-top: 1px solid #64748b !important;
    width: 210px !important;
    text-align: center !important;
    padding-top: 4px !important;
    font-size: 10px !important;
    color: #334155 !important;
  }
}

/* ==========================================================================
   RECIBOS OFICIALES Y ESTADOS DE CUENTA
   ========================================================================== */
.receipt-header-badge {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border: 1px solid #10b981;
  border-radius: 4px;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.stamp-badge {
  display: inline-block;
  padding: 8px 18px;
  border: 3px double;
  border-radius: 8px;
  font-weight: 900;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  transform: rotate(-3deg);
  margin-top: 10px;
}

.stamp-badge.paid {
  border-color: #10b981;
  color: #059669;
  background: rgba(16, 185, 129, 0.08);
}

.stamp-badge.partial {
  border-color: #3b82f6;
  color: #1d4ed8;
  background: rgba(59, 130, 246, 0.08);
}

.statement-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.statement-stat-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 10px 14px;
  border-radius: 6px;
}

.statement-stat-lbl {
  font-size: 10.5px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  display: block;
}

.statement-stat-val {
  font-size: 15px;
  font-weight: 800;
  display: block;
  margin-top: 2px;
}

.btn-success {
  background: #10b981;
  color: #ffffff;
  border: 1px solid #059669;
}

.btn-success:hover {
  background: #059669;
  color: #ffffff;
}

.btn-outline-success {
  background: transparent;
  color: #059669;
  border: 1px solid #10b981;
}

.btn-outline-success:hover {
  background: #10b981;
  color: #ffffff;
}

/* Ficha Detallada del Cliente */
.client-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.client-detail-title {
  flex: 1;
  min-width: 220px;
}

.client-detail-title h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--navy-dark);
  margin-bottom: 4px;
}

.client-detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==========================================================================
   SISTEMA DE DISEÑO RESPONSIVO (PC, TABLETS Y MÓVILES)
   ========================================================================== */

/* Animación de apertura suave para modales móviles (Bottom Sheet) */
@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- 1. PANTALLAS GRANDES Y LAPTOPS (Hasta 1100px) --- */
@media (max-width: 1100px) {
  .statement-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- 2. TABLETS & IPAD (Hasta 992px) --- */
@media (max-width: 992px) {
  /* Sidebar Drawer Desplegable */
  .sidebar {
    position: fixed;
    left: -320px;
    top: 0;
    bottom: 0;
    width: 285px;
    max-width: 85vw;
    height: 100vh;
    z-index: 2200;
    box-shadow: 12px 0 35px rgba(10, 0, 30, 0.5);
    transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-close-btn {
    display: inline-flex;
  }

  /* Botón hamburguesa en barra superior */
  .mobile-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.05);
    border: 1px solid rgba(15, 23, 42, 0.08);
    font-size: 17px;
    color: var(--navy-dark);
    cursor: pointer;
    transition: var(--transition);
  }

  .mobile-toggle:hover {
    background: rgba(0, 153, 195, 0.12);
    color: var(--brand-cyan);
    border-color: rgba(0, 153, 195, 0.3);
  }

  .main-wrapper {
    width: 100%;
    min-width: 0;
  }

  .top-navbar {
    padding: 0 20px;
  }

  .content-body {
    padding: 22px 18px;
  }

  /* Grids adaptables para Tablet */
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .grid-cols-2, .grid-cols-3 {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .doc-footer-grid {
    grid-template-columns: 1fr;
  }

  /* Tablas con desplazamiento suave táctil */
  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: none;
  }
}

/* --- 3. TABLETS PEQUEÑAS Y SMARTPHONES (Hasta 768px) --- */
@media (max-width: 768px) {
  .top-navbar {
    height: 60px;
    padding: 0 14px;
  }

  .top-nav-left {
    gap: 10px;
    min-width: 0;
    flex: 1;
  }

  .page-title-header {
    font-size: 14.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 190px;
  }

  .top-nav-right {
    gap: 8px;
    flex-shrink: 0;
  }

  .top-nav-right .btn {
    padding: 7px 11px;
    font-size: 12px;
  }

  .content-body {
    padding: 16px 12px;
  }

  /* Cabeceras de vista: apilado ordenado */
  .view-section > .flex.justify-between.items-center,
  .view-section > .flex.justify-between {
    flex-direction: column;
    align-items: stretch !important;
    gap: 12px;
    margin-bottom: 16px;
  }

  .view-section > .flex.justify-between > .flex.gap-2,
  .view-section > .flex.justify-between.items-center > .flex.gap-2 {
    flex-wrap: wrap;
    width: 100%;
    gap: 8px;
  }

  .view-section > .flex.justify-between > .flex.gap-2 .btn,
  .view-section > .flex.justify-between.items-center > .flex.gap-2 .btn {
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
    font-size: 13px;
    padding: 9px 12px;
  }

  /* Buscadores y filtros móviles */
  .search-filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 16px;
  }

  .search-filter-bar > div {
    width: 100% !important;
  }

  .search-filter-bar .form-control {
    width: 100%;
  }

  /* Tabs de Clientes Fijos vs Ocasionales */
  .client-tabs-bar {
    flex-direction: column;
    gap: 8px;
  }

  .client-tab-btn {
    width: 100%;
    text-align: center;
    justify-content: center;
    padding: 10px;
  }

  /* Grid de Tarjetas de Clientes */
  .clients-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  /* Ficha del Cliente */
  .client-detail-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .client-detail-actions {
    width: 100%;
    justify-content: stretch;
  }

  .client-detail-actions .btn {
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
  }

  /* Tablas de datos en móvil */
  .table-responsive {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: white;
  }

  .data-table {
    min-width: 660px;
  }

  .data-table th, .data-table td {
    padding: 10px 12px;
    font-size: 13px;
  }

  /* MODALES EN MÓVIL: Estilo Bottom Sheet Táctil */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .modal-dialog,
  .modal-dialog.lg {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 94vh;
    border-radius: 20px 20px 0 0;
    margin: 0;
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .modal-header {
    padding: 16px 18px;
  }

  .modal-header h3 {
    font-size: 15px;
  }

  .modal-body {
    padding: 16px 14px;
    -webkit-overflow-scrolling: touch;
  }

  /* Pie de modales con botones apilados accesibles */
  .modal-footer {
    flex-direction: column-reverse;
    align-items: stretch !important;
    padding: 14px 16px;
    gap: 8px;
  }

  .modal-footer > div,
  .modal-footer .flex {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .modal-footer .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
    font-size: 13.5px;
  }

  /* Filas de ítems en Emisión de Facturas y Cotizaciones */
  .invoice-item-row,
  .quote-item-row {
    flex-wrap: wrap;
    position: relative;
    padding: 12px 14px;
    gap: 8px;
  }

  .invoice-item-row .flex-3,
  .quote-item-row .flex-3 {
    flex: 1 1 100%;
    padding-right: 38px;
    margin-bottom: 0;
  }

  .invoice-item-row .flex-1,
  .quote-item-row .flex-1 {
    flex: 1 1 28%;
    margin-bottom: 0;
  }

  .invoice-item-row .flex-2,
  .quote-item-row .flex-2 {
    flex: 1 1 35%;
    margin-bottom: 0;
  }

  .invoice-item-row .item-subtotal-display,
  .quote-item-row .item-subtotal-display {
    flex: 1 1 auto;
    justify-content: flex-start;
    padding: 6px 0;
    font-size: 13px;
    margin-bottom: 0;
  }

  .invoice-item-row .flex-auto,
  .quote-item-row .flex-auto {
    position: absolute;
    top: 10px;
    right: 10px;
    margin-bottom: 0;
  }

  /* Visor de Documentos Oficiales en Móvil */
  #invoicePreviewContent,
  #quotePreviewContent,
  #receiptModal .modal-body,
  #accountStatementModal .modal-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 6px;
  }

  .print-document {
    min-width: 620px;
    padding: 20px 16px;
    margin: 0 auto;
  }
}

/* --- 4. SMARTPHONES ESTÁNDAR (Hasta 480px) --- */
@media (max-width: 480px) {
  /* En celulares pequeños ocultamos el texto largo del botón del header dejando icono limpio */
  .top-navbar .nav-btn-text {
    display: none;
  }

  .top-nav-right .btn {
    padding: 8px 12px;
    font-size: 13px;
    min-height: 38px;
  }

  .top-nav-right .btn i {
    font-size: 14px;
    margin: 0;
  }

  .page-title-header {
    max-width: 145px;
    font-size: 14px;
  }

  /* Tarjetas de Métricas en columna individual */
  .metrics-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .statement-summary-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  /* Botones de acción de vistas en ancho completo */
  .view-section > .flex.justify-between > .flex.gap-2 .btn,
  .view-section > .flex.justify-between.items-center > .flex.gap-2 .btn {
    flex: 1 1 100%;
  }

  .client-detail-actions .btn {
    flex: 1 1 100%;
  }

  /* Toast en móvil adaptado al ancho inferior */
  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 16px;
    width: auto;
    max-width: none;
  }

  .toast {
    width: 100%;
  }

  /* Controles de formulario optimizados para evitar autozoom en navegadores móviles */
  .form-control {
    font-size: 15px;
    padding: 10px 12px;
  }

  .btn {
    min-height: 42px;
  }
}

/* --- 5. SMARTPHONES MUY COMPACTOS (Hasta 360px) --- */
@media (max-width: 360px) {
  .page-title-header {
    max-width: 110px;
    font-size: 13px;
  }

  .top-nav-right {
    gap: 4px;
  }

  .top-nav-right .btn {
    padding: 7px 9px;
  }
}


