/* =========================================
   ASESORÍA INTEGRAL - Sistema de Clientes
   Tema: Dark Navy Professional
   Fuente: Rajdhani + Exo 2
   ========================================= */

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

:root {
  /* Paleta de colores */
  --bg-primary:        #0a0f1e;
  --bg-secondary:      #0d1528;
  --bg-card:           #111c35;
  --bg-input:          #0e1930;
  --bg-header:         #0c1327;

  --border-color:      #1e3060;
  --border-focus:      #2d6bc4;
  --border-subtle:     #162448;

  --accent-blue:       #1e5fc4;
  --accent-blue-light: #2d6bc4;
  --accent-green:      #1a8a40;
  --accent-green-light:#22a84e;
  --accent-red:        #c42222;
  --accent-orange:     #d4813a;
  --accent-cyan:       #0ea8b5;

  --text-primary:      #e8eef8;
  --text-secondary:    #8fa8cc;
  --text-muted:        #4a6a98;
  --text-label:        #a0bcdc;

  --stat-blue-bg:      #0f1e3d;
  --stat-green-bg:     #0a1f10;
  --stat-red-bg:       #1f0a0a;

  /* Tipografía */
  --font-display:      'Rajdhani', sans-serif;
  --font-body:         'Exo 2', sans-serif;

  /* Espaciado */
  --radius:            6px;
  --radius-lg:         10px;
  --shadow:            0 4px 24px rgba(0,0,0,0.5);
  --shadow-focus:      0 0 0 3px rgba(46,107,196,0.3);
}

/* ─── RESET & BASE ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  background-image:
    radial-gradient(ellipse at 10% 0%, rgba(30,95,196,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 100%, rgba(14,168,181,0.05) 0%, transparent 50%);
}

/* ─── HEADER / NAVBAR ─── */
.navbar {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,0.6);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-blue);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-primary);
  text-transform: uppercase;
  line-height: 1.1;
}

.brand-text span {
  font-size: 0.62rem;
  letter-spacing: 3px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 400;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-user {
  background: rgba(30,95,196,0.15);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-user:hover { background: rgba(30,95,196,0.25); color: var(--text-primary); }

.btn-logout {
  background: transparent;
  border: 1px solid rgba(196,34,34,0.4);
  color: #e05555;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover { background: rgba(196,34,34,0.15); border-color: #c42222; }

/* ═════════════════════════════════════════
   SIDEBAR IZQUIERDO — MENÚ PRINCIPAL
   ═════════════════════════════════════════ */

.sidebar-toggle {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  background: rgba(30,95,196,0.2);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.sidebar {
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 0;
  width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 90;
  transition: width 0.25s ease, transform 0.25s ease;
  overflow: hidden;
  box-shadow: 2px 0 12px rgba(0,0,0,0.4);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-header);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(30,95,196,0.35);
}

.sidebar-title {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-title strong {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 2px;
  color: var(--text-primary);
}
.sidebar-title span {
  font-size: 0.62rem;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
  white-space: nowrap;
}
.sidebar-item:hover {
  background: rgba(30,95,196,0.12);
  color: var(--text-primary);
  border-left-color: var(--accent-blue-light);
}
.sidebar-item.active {
  background: rgba(30,95,196,0.22);
  color: #fff;
  border-left-color: var(--accent-cyan);
  box-shadow: inset 0 0 0 1px rgba(45,107,196,0.25);
}
.sidebar-item .sidebar-icon {
  width: 24px;
  font-size: 16px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-item .sidebar-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logout {
  color: #e07070 !important;
}
.sidebar-logout:hover {
  background: rgba(196,34,34,0.15) !important;
  border-left-color: #c42222 !important;
}

.sidebar-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 10px 8px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.68rem;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 0;
}

/* ─── CONTENIDO PRINCIPAL ─── */
.main-content {
  padding: 28px 28px 60px;
  transition: margin-left 0.25s ease;
  max-width: none;
}
/* Solo aplica margen cuando HAY sidebar (usuario logueado) */
body.has-sidebar .main-content {
  margin-left: 240px;
}

/* ─── ENCABEZADO DE PÁGINA ─── */
.page-header {
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.page-header h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.page-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ─── GRID DASHBOARD ─── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.dashboard-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.dashboard-card h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 1.5px;
  color: var(--text-primary);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

/* ─── ACCESOS RÁPIDOS ─── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.quick-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 14px 10px;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.quick-btn:hover {
  background: rgba(30,95,196,0.15);
  border-color: var(--border-focus);
  color: var(--text-primary);
  transform: translateY(-1px);
}
.quick-btn span { font-size: 0.75rem; letter-spacing: 0.5px; }

/* ─── GRÁFICO DE BARRAS ─── */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 120px;
}
.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 50px;
  gap: 10px;
  align-items: center;
  font-size: 0.8rem;
}
.bar-label {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track {
  background: var(--bg-input);
  border-radius: 4px;
  height: 18px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
  border-radius: 4px;
  transition: width 0.5s ease;
}
.bar-value {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
}
.chart-loading {
  text-align: center;
  color: var(--text-muted);
  padding: 30px;
  font-size: 0.85rem;
}

/* ─── BADGES ─── */
.badge-ok, .badge-ko, .badge-rol {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.badge-ok  { background: rgba(34,168,78,0.18); color: #4dd880; }
.badge-ko  { background: rgba(196,34,34,0.18); color: #ff7070; }
.badge-rol { background: rgba(30,95,196,0.2);  color: #7fb3ff; text-transform: uppercase; }

/* ─── INPUT DE BÚSQUEDA ─── */
.search-input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 7px 12px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  min-width: 220px;
  transition: border-color 0.2s;
}
.search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

/* ─── BOTONES PEQUEÑOS ─── */
.btn-sm {
  font-size: 0.75rem;
  padding: 5px 10px;
}

/* ─── Estado colapsado (solo íconos) ─── */
body.sidebar-collapsed .sidebar {
  width: 62px;
}
body.sidebar-collapsed .sidebar-title,
body.sidebar-collapsed .sidebar-text,
body.sidebar-collapsed .sidebar-footer {
  opacity: 0;
  pointer-events: none;
}
body.sidebar-collapsed .sidebar-item {
  justify-content: center;
  padding: 10px;
}
body.has-sidebar.sidebar-collapsed .main-content {
  margin-left: 62px;
}

/* ─── Responsive: sidebar ocultable en móvil ─── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  body.sidebar-collapsed .sidebar {
    transform: translateX(0);
    width: 240px;
  }
  body.sidebar-collapsed .sidebar-title,
  body.sidebar-collapsed .sidebar-text,
  body.sidebar-collapsed .sidebar-footer {
    opacity: 1;
    pointer-events: auto;
  }
  body.sidebar-collapsed .sidebar-item {
    justify-content: flex-start;
    padding: 10px 12px;
  }
  body.has-sidebar .main-content,
  body.has-sidebar.sidebar-collapsed .main-content {
    margin-left: 0;
  }
}

/* ─── ESTADÍSTICAS ─── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.2s;
}

.stat-card:hover { border-color: var(--border-focus); }

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.blue  { background: var(--stat-blue-bg);  }
.stat-icon.green { background: var(--stat-green-bg);  }
.stat-icon.red   { background: var(--stat-red-bg);    }

.stat-info strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}

.stat-info span {
  font-size: 0.7rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}

/* ─── TABS ─── */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 4px;
  width: fit-content;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 7px 18px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}

.tab-btn.active {
  background: var(--accent-blue);
  color: #fff;
}

.tab-btn:not(.active):hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }

/* ─── CARD DE FORMULARIO ─── */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.form-card-header h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.required-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.form-body { padding: 24px; }

/* ─── SECCIONES ─── */
.section {
  margin-bottom: 28px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-title::before {
  content: '';
  width: 3px;
  height: 14px;
  border-radius: 2px;
}

.section-identificacion .section-title::before { background: #e05555; }
.section-contacto       .section-title::before { background: var(--accent-orange); }
.section-seguridad      .section-title::before { background: var(--accent-blue-light); }
.section-empresa        .section-title::before { background: var(--accent-cyan); }
.section-referido       .section-title::before { background: #a855f7; }

/* ─── GRID ─── */
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3-2 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }

/* ─── CAMPOS ─── */
.field { display: flex; flex-direction: column; gap: 5px; }

.field label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-label);
}

.field label .req { color: #e05555; margin-left: 2px; }

.field input,
.field select,
.field textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.88rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  width: 100%;
}

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

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

.field input[type="date"] { color: var(--text-secondary); }

.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234a6a98' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.field select option { background: var(--bg-secondary); color: var(--text-primary); }

/* Estado especial ACTIVO */
.estado-activo {
  background: var(--accent-green) !important;
  border-color: var(--accent-green-light) !important;
  color: #fff !important;
  font-weight: 600;
  letter-spacing: 1px;
}

/* Estado especial RETIRADO */
.estado-retirado {
  background: var(--accent-red) !important;
  border-color: #e05555 !important;
  color: #fff !important;
  font-weight: 600;
  letter-spacing: 1px;
}

/* MAYÚSCULAS en todos los inputs de texto excepto correo */
.field input:not(#correo):not([type="email"]):not([type="date"]),
.field select,
.field textarea {
  text-transform: uppercase;
}

/* El correo siempre minúsculas */
.field input#correo,
.field input[type="email"] {
  text-transform: lowercase;
}

/* ─── BOTONES ACCIÓN ─── */
.form-actions {
  display: flex;
  gap: 10px;
  padding: 18px 24px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
}

.btn {
  padding: 10px 22px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
  box-shadow: 0 2px 12px rgba(30,95,196,0.4);
}
.btn-primary:hover { background: var(--accent-blue-light); box-shadow: 0 4px 18px rgba(30,95,196,0.6); transform: translateY(-1px); }

.btn-secondary {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

.btn-success {
  background: var(--accent-green);
  color: #fff;
  box-shadow: 0 2px 12px rgba(26,138,64,0.35);
}
.btn-success:hover { background: var(--accent-green-light); transform: translateY(-1px); }

/* ─── MENSAJES ─── */
.alert {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  animation: slideDown 0.3s ease;
}
.alert-success { background: rgba(26,138,64,0.15); border: 1px solid rgba(26,138,64,0.4); color: #5cd68a; }
.alert-error   { background: rgba(196,34,34,0.15); border: 1px solid rgba(196,34,34,0.4); color: #e07070; }

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

/* ─── LISTA CLIENTES ─── */
.client-list { display: none; }
.client-list.active { display: block; }

.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.table-header h3 {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

table { width: 100%; border-collapse: collapse; }

thead th {
  background: var(--bg-secondary);
  padding: 10px 14px;
  text-align: left;
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.15s;
}

tbody tr:hover { background: rgba(255,255,255,0.03); }

tbody td {
  padding: 11px 14px;
  font-size: 0.84rem;
  color: var(--text-secondary);
  vertical-align: middle;
}

tbody td:first-child { color: var(--text-primary); font-weight: 500; }

.badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.badge-active   { background: rgba(26,138,64,0.2);  color: #5cd68a; border: 1px solid rgba(26,138,64,0.3); }
.badge-inactive { background: rgba(196,34,34,0.2);  color: #e07070; border: 1px solid rgba(196,34,34,0.3); }

.btn-icon {
  width: 30px; height: 30px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: all 0.2s;
}
.btn-icon:hover { background: rgba(30,95,196,0.2); color: var(--text-primary); border-color: var(--border-focus); }
.btn-icon.danger:hover { background: rgba(196,34,34,0.2); color: #e07070; border-color: rgba(196,34,34,0.5); }

/* ─── VALIDACIÓN ─── */
.field.error input,
.field.error select { border-color: #c42222; }

.field-error-msg {
  font-size: 0.7rem;
  color: #e07070;
  display: none;
}

.field.error .field-error-msg { display: block; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — Mobile First
   xs: < 480px  (iPhone SE, teléfonos pequeños)
   sm: 480-767px (iPhone, Android)
   md: 768-1023px (iPad, tabletas)
   lg: 1024px+  (desktop)
══════════════════════════════════════════════════════════ */

/* ── Grids responsive ─────────────────────────────────── */

/* Móvil: todo en 1 columna */
@media (max-width: 767px) {
  .grid-3, .grid-3-2, .grid-2, .grid-2-1 {
    grid-template-columns: 1fr !important;
  }
  /* Campos que tienen span 2 en grid-3 vuelven a 1 col */
  .grid-3 [style*="grid-column:span 2"],
  .grid-3 [style*="grid-column: span 2"] {
    grid-column: span 1 !important;
  }
}

/* Tableta: 2 columnas */
@media (min-width: 768px) and (max-width: 1023px) {
  .grid-3, .grid-3-2 { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-2-1 { grid-template-columns: 1fr 1fr; }
}

/* ── Navbar ───────────────────────────────────────────── */
@media (max-width: 767px) {
  .navbar {
    padding: 0 14px;
    height: auto;
    min-height: 52px;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .brand-text span { display: none; }
  .brand-text h1   { font-size: 1rem; letter-spacing: 1px; }
  .brand-icon      { width: 30px; height: 30px; font-size: 15px; }
  .navbar-actions  { gap: 6px; }
  .btn-user, .btn-logout {
    font-size: 0.72rem;
    padding: 5px 10px;
  }
}

@media (max-width: 380px) {
  .brand-text h1 { font-size: 0.85rem; }
  .btn-user span { display: none; }
}

/* ── Contenido principal ──────────────────────────────── */
@media (max-width: 767px) {
  .main-content { padding: 12px 10px 40px; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .main-content { padding: 20px 16px 50px; }
}

/* ── Estadísticas ─────────────────────────────────────── */
@media (max-width: 479px) {
  .stats-row { grid-template-columns: 1fr; gap: 8px; }
}
@media (min-width: 480px) and (max-width: 767px) {
  .stats-row { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat-card { padding: 12px 10px; gap: 8px; }
  .stat-info strong { font-size: 1.4rem; }
  .stat-info span   { font-size: 0.6rem; letter-spacing: 1px; }
  .stat-icon        { width: 34px; height: 34px; font-size: 16px; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .stats-row { grid-template-columns: repeat(3, 1fr); }
}

/* ── Tabs ─────────────────────────────────────────────── */
@media (max-width: 479px) {
  .tabs { width: 100%; }
  .tab-btn { flex: 1; justify-content: center; font-size: 0.75rem; padding: 7px 8px; }
}
@media (min-width: 480px) and (max-width: 767px) {
  .tab-btn { font-size: 0.78rem; }
}

/* ── Formulario ───────────────────────────────────────── */
@media (max-width: 767px) {
  .form-body { padding: 14px 12px; }
  .form-card-header { padding: 12px 14px; flex-wrap: wrap; gap: 4px; }
  .form-card-header h2 { font-size: 0.85rem; }
  .required-note { font-size: 0.65rem; }
  .section { margin-bottom: 20px; }
  .section-title { font-size: 0.7rem; }
  .field label { font-size: 0.68rem; }
  .field input,
  .field select {
    font-size: 0.95rem; /* más grande para móvil — evita zoom en iOS */
    padding: 10px 12px;
  }
}

@media (max-width: 479px) {
  .form-body { padding: 12px 10px; }
  /* Input font-size 16px en iOS evita el zoom automático */
  .field input,
  .field select,
  .field textarea {
    font-size: 16px !important;
    -webkit-appearance: none;
    border-radius: var(--radius);
  }
}

/* ── Botones acción formulario ────────────────────────── */
@media (max-width: 767px) {
  .form-actions {
    flex-direction: column;
    padding: 14px 12px;
    gap: 8px;
  }
  .form-actions .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 0.88rem;
  }
}

/* ── Tabla lista de clientes ──────────────────────────── */
@media (max-width: 767px) {
  .table-wrap { overflow: hidden; }

  /* Scroll horizontal con indicador táctil */
  .table-wrap > div[style*="overflow-x"] {
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap > div { overflow-x: auto; }

  table { min-width: 700px; }

  thead th {
    font-size: 0.6rem;
    padding: 8px 8px;
    white-space: nowrap;
  }
  tbody td {
    font-size: 0.78rem;
    padding: 9px 8px;
  }
  .badge { font-size: 0.6rem; padding: 2px 7px; }
  .btn-icon { width: 28px; height: 28px; font-size: 13px; }

  .table-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .table-header h3 { font-size: 0.82rem; }
  .table-header .btn { font-size: 0.75rem; padding: 6px 12px; }
}

/* Tablets: tabla con scroll suave */
@media (min-width: 768px) and (max-width: 1023px) {
  .table-wrap > div { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 850px; }
}

/* ══════════════════════════════════════════════════════════
   PANEL DE LOGIN — LADO DERECHO
══════════════════════════════════════════════════════════ */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
  animation: fadeInOverlay 0.35s ease;
}

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.login-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 10, 25, 0.82);
  backdrop-filter: blur(4px);
}

.login-panel {
  position: relative;
  z-index: 1;
  width: 400px;
  max-width: 100vw;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 36px;
  box-shadow: -8px 0 48px rgba(0, 0, 0, 0.7);
  animation: slideInRight 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
  overflow-y: auto;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

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

.login-logo {
  font-size: 3rem;
  margin-bottom: 14px;
  display: block;
  filter: drop-shadow(0 0 16px rgba(30,95,196,0.7));
}

.login-header h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.login-header p {
  font-size: 0.72rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.login-header::after {
  content: '';
  display: block;
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-blue), transparent);
  margin: 16px auto 0;
  border-radius: 2px;
}

.login-form .field label {
  color: var(--text-label);
  font-size: 0.7rem;
  letter-spacing: 1.5px;
}

.input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 11px;
  font-size: 14px;
  pointer-events: none;
  opacity: 0.6;
}

.input-icon-wrap input {
  padding-left: 36px !important;
  padding-right: 40px;
}

.toggle-pass {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.5;
  padding: 4px;
  transition: opacity 0.2s;
}
.toggle-pass:hover { opacity: 1; }

.login-footer {
  margin-top: 28px;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 18px;
}

.login-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, transparent, var(--accent-blue), var(--accent-cyan), transparent);
}

/* Login responsive — móvil pantalla completa */
@media (max-width: 767px) {
  .login-overlay {
    justify-content: center;
    align-items: flex-end;
  }
  .login-panel {
    width: 100vw;
    max-height: 92vh;
    border-left: none;
    border-top: 1px solid var(--border-color);
    border-radius: 18px 18px 0 0;
    padding: 28px 22px 32px;
    animation: slideInBottom 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
  }
  .login-header { margin-bottom: 24px; }
  .login-logo   { font-size: 2.2rem; margin-bottom: 10px; }
  .login-header h2 { font-size: 1.2rem; }
  .login-panel::before { display: none; }
  /* Campos táctiles grandes en login */
  .login-form .field input {
    font-size: 16px !important;
    padding: 12px 12px 12px 38px !important;
    -webkit-appearance: none;
  }
  .login-panel .btn {
    padding: 13px !important;
    font-size: 0.92rem !important;
  }
}

@keyframes slideInBottom {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .login-panel { width: 440px; }
}

/* Badge SBS */
.badge-sbs-si { background: rgba(14,168,181,0.18); color: #2de0ed; border: 1px solid rgba(14,168,181,0.35); }
.badge-sbs-no { background: rgba(100,100,120,0.18); color: #8fa8cc; border: 1px solid rgba(100,100,120,0.3); }

/* ── Touch targets mínimos 44px (iOS HIG) ───────────────── */
@media (max-width: 1023px) {
  .btn, .btn-user, .btn-logout, .tab-btn {
    min-height: 44px;
  }
  .btn-icon {
    min-width: 36px;
    min-height: 36px;
  }
  /* Espaciado entre botones táctiles */
  .form-actions { gap: 10px; }
}

/* ── Mejoras generales para móvil ─────────────────────── */
@media (max-width: 767px) {
  /* Evitar desbordamiento horizontal */
  body { overflow-x: hidden; }

  /* Alertas */
  .alert { font-size: 0.82rem; padding: 9px 12px; }

  /* Stat cards en 3 columnas pequeñas */
  .stat-card { border-radius: var(--radius); }

  /* Sección títulos más compactos */
  .section-title { margin-bottom: 12px; padding-bottom: 6px; }

  /* Campos date más accesibles en móvil */
  input[type="date"] {
    -webkit-appearance: none;
    font-size: 16px !important;
  }

  /* Select más accesible */
  select { -webkit-appearance: none; font-size: 16px !important; }
}

/* =========================================
   LOGO SVG — ajustes para contenedores
   ========================================= */
.navbar-brand .brand-icon {
  background: transparent;
  padding: 0;
  overflow: hidden;
}
.navbar-brand .brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Variante ancha para logos panorámicos (ej. AFILIACIONES) */
.navbar-brand .brand-icon.brand-icon--wide {
  width: auto;
  height: 44px;
  aspect-ratio: auto;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}
.navbar-brand .brand-icon.brand-icon--wide img {
  width: auto;
  height: 100%;
  max-height: 44px;
  object-fit: contain;
}
@media (max-width: 767px) {
  .navbar-brand .brand-icon.brand-icon--wide {
    height: 34px;
  }
  .navbar-brand .brand-icon.brand-icon--wide img {
    max-height: 34px;
  }
}

.sidebar-logo {
  background: transparent !important;
  box-shadow: none !important;
  padding: 0;
  overflow: hidden;
}
.sidebar-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.login-logo {
  font-size: 0;
  margin: 0 auto 14px;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 16px rgba(30,95,196,0.7));
}
.login-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

