@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,400,0,0&display=swap');

/* ==========================================
   BRIGADASALUD — DESIGN TOKENS
   ========================================== */
:root {
  --color-primary: #1565C0;
  --color-primary-hover: #0D47A1;
  --color-primary-light: #E3F2FD;

  --color-secondary: #43A047;
  --color-secondary-hover: #2E7D32;
  --color-secondary-light: #E8F5E9;

  --color-accent: #42A5F5;
  --color-accent-light: #E1F5FE;

  --color-success: #22C55E;
  --color-success-light: #DCFCE7;
  --color-error: #EF4444;
  --color-error-light: #FEE2E2;
  --color-warning: #F59E0B;
  --color-warning-light: #FEF3C7;
  --color-info: #3B82F6;
  --color-info-light: #DBEAFE;

  --color-background: #F8FAFC;
  --color-surface: #FFFFFF;
  --color-border: #E2E8F0;
  --color-disabled: #CBD5E1;
  --color-disabled-text: #94A3B8;
  --color-text-main: #263238;
  --color-text-muted: #607D8B;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-h1: clamp(1.75rem, 4vw, 2.25rem);
  --font-size-h2: clamp(1.5rem, 3.5vw, 1.875rem);
  --font-size-h3: clamp(1.25rem, 3vw, 1.5rem);
  --font-size-h4: clamp(1.1rem, 2.5vw, 1.25rem);
  --font-size-body: 1rem;
  --font-size-small: 0.875rem;
  --font-size-caption: 0.75rem;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-xxl: 48px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(21, 101, 192, 0.08);
  --shadow-lg: 0 10px 30px rgba(21, 101, 192, 0.12);

  --sidebar-width: 260px;
  --topbar-height: 56px;
  --bottomnav-height: 64px;
  --transition: 0.2s ease;
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-body);
  background: var(--color-background);
  color: var(--color-text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: var(--font-size-h1); font-weight: 700; }
h2 { font-size: var(--font-size-h2); font-weight: 600; }
h3 { font-size: var(--font-size-h3); font-weight: 600; }
h4 { font-size: var(--font-size-h4); font-weight: 500; }

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover { color: var(--color-primary-hover); }

.material-symbols-rounded {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  vertical-align: middle;
}

/* ==========================================
   APP LAYOUT — SIDEBAR + TOPBAR
   ========================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-primary);
  font-weight: 700;
  font-size: var(--font-size-h4);
}

.sidebar-brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(255,255,255,0.7);
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.12);
}

.sidebar-brand .material-symbols-rounded {
  font-size: 28px;
  color: var(--color-secondary);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md) var(--space-sm);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-md);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: var(--font-size-small);
  transition: all var(--transition);
  margin-bottom: 2px;
}

.sidebar-link:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
  text-decoration: none;
}

.sidebar-link.is-active {
  background: var(--color-primary);
  color: var(--color-surface);
}

.sidebar-link.is-active .material-symbols-rounded { color: inherit; }

.sidebar-section-label {
  padding: var(--space-md) var(--space-md) var(--space-xs);
  font-size: var(--font-size-caption);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.sidebar-link--logout {
  margin-top: auto;
  color: var(--color-error);
}

.sidebar-link--logout:hover {
  background: var(--color-error-light);
  color: var(--color-error);
}

.sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--color-border);
}

.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 0 var(--space-lg);
  z-index: 100;
}

.topbar-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.topbar-search > .material-symbols-rounded {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--color-text-muted);
}

.topbar-search input {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-md) 0 40px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: var(--font-size-small);
  background: var(--color-background);
  outline: none;
}

.topbar-search input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.global-search-results {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xs);
  max-height: 70vh;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 400;
}

.topbar-search.is-open .global-search-results {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.search-result-group + .search-result-group { margin-top: var(--space-xs); }

.search-result-group-label {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-text-main);
}

.search-result-item:hover { background: var(--color-background); }

.search-result-item .material-symbols-rounded {
  font-size: 20px;
  color: var(--color-primary);
  flex-shrink: 0;
}

.search-result-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.search-result-item-text strong {
  font-size: var(--font-size-small);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-item-text span {
  font-size: var(--font-size-caption);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-empty {
  padding: var(--space-md);
  text-align: center;
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-left: auto;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-caption);
  font-weight: 600;
}

.connection-status--online {
  background: var(--color-success-light);
  color: #15803D;
}

.connection-status--offline {
  background: var(--color-error-light);
  color: var(--color-error);
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: background var(--transition);
}

.icon-btn:hover { background: var(--color-background); color: var(--color-primary); }

.icon-btn .badge-count {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--color-error);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar {
  border-radius: var(--radius-full);
  object-fit: cover;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.avatar-sm { width: 32px; height: 32px; font-size: var(--font-size-caption); }
.avatar-md { width: 48px; height: 48px; font-size: var(--font-size-small); }
.avatar-lg { width: 80px; height: 80px; font-size: var(--font-size-h3); }

/* ==========================================
   MENÚ DE USUARIO (topbar)
   ========================================== */
.user-menu { position: relative; }

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  padding: 4px;
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--color-text-muted);
}

.user-menu-trigger:hover { background: var(--color-background); }

.user-menu-caret {
  font-size: 18px;
  transition: transform var(--transition);
}

.user-menu.is-open .user-menu-caret { transform: rotate(180deg); }

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 260px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-sm);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 400;
}

.user-menu.is-open .user-menu-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-menu-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm) var(--space-sm);
}

.user-menu-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.user-menu-identity strong {
  font-size: var(--font-size-small);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu-identity span {
  font-size: var(--font-size-caption);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.user-menu-divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-xs) 0;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  font-size: var(--font-size-small);
  color: var(--color-text-main);
  text-decoration: none;
}

.user-menu-item .material-symbols-rounded { font-size: 20px; color: var(--color-text-muted); }

.user-menu-item:hover { background: var(--color-background); }

.user-menu-item--danger { color: var(--color-error); }
.user-menu-item--danger .material-symbols-rounded { color: var(--color-error); }

.page-content {
  flex: 1;
  padding: var(--space-lg);
  max-width: 1400px;
}

.page-header {
  margin-bottom: var(--space-lg);
}

.page-header h1 { margin-bottom: var(--space-xs); }
.page-subtitle { color: var(--color-text-muted); font-size: var(--font-size-small); }

@media (max-width: 1023px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.is-open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 150;
    opacity: 0;
    transition: opacity var(--transition-slow);
  }
  .sidebar-overlay.is-visible { display: block; opacity: 1; }

  /* Reserva espacio para que el bottom-nav fijo (y el FAB, cuando existe) no tapen
     el contenido final de listas/paginación al hacer scroll hasta abajo. */
  .page-content {
    padding-bottom: calc(var(--bottomnav-height) + var(--space-xl) * 2);
  }

  /* En móvil el buscador comparte la topbar con la insignia de conexión, la campana
     y el avatar, así que el input le queda muy angosto. El desplegable de resultados
     no puede heredar ese ancho o el texto queda ilegible: se ancla a toda la pantalla. */
  .global-search-results {
    position: fixed;
    left: var(--space-md);
    right: var(--space-md);
    top: calc(var(--topbar-height) + 8px);
  }

  /* La insignia "Conectado" con su texto le quita casi todo el ancho al buscador en
     pantallas angostas (ver captura del usuario): en móvil se deja solo el punto de
     estado, mucho más compacto, y el buscador recupera espacio real para escribir. */
  .topbar { padding: 0 var(--space-md); gap: var(--space-sm); }
  .topbar-actions { gap: var(--space-xs); }
  #connection-text { display: none; }
  .connection-status { padding: 8px; }
  .topbar-search input { padding-right: var(--space-sm); }
}

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: 44px;
  padding: var(--space-sm) var(--space-lg);
  font-family: inherit;
  font-size: var(--font-size-small);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-surface);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  color: var(--color-surface);
  text-decoration: none;
}

.btn-secondary {
  background: var(--color-secondary);
  color: var(--color-surface);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-secondary-hover);
  color: var(--color-surface);
  text-decoration: none;
}

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

.btn-outline:hover:not(:disabled) {
  background: var(--color-primary-light);
  text-decoration: none;
}

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

.btn-ghost:hover:not(:disabled) { background: var(--color-primary-light); }

.btn:disabled {
  background: var(--color-disabled);
  color: var(--color-disabled-text);
  cursor: not-allowed;
}

.btn-sm { min-height: 36px; padding: 6px 14px; font-size: var(--font-size-caption); }
.btn-block { width: 100%; }

.fab {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-secondary);
  color: white;
  border: none;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: transform var(--transition);
  text-decoration: none;
}

.fab:hover {
  transform: scale(1.05);
  color: white;
  text-decoration: none;
}

/* ==========================================
   FORMS
   ========================================== */
.form-group { margin-bottom: var(--space-md); }

.form-label {
  display: block;
  font-size: var(--font-size-small);
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.form-control {
  width: 100%;
  min-height: 44px;
  padding: var(--space-sm) var(--space-md);
  font-family: inherit;
  font-size: var(--font-size-body);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-control::placeholder { color: var(--color-text-muted); }

textarea.form-control { min-height: 100px; resize: vertical; padding-top: var(--space-sm); }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23607D8B' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

.form-group.has-error .form-control { border-color: var(--color-error); }
.form-group.has-error .form-control:focus { box-shadow: 0 0 0 3px var(--color-error-light); }

.form-error-msg {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-caption);
  color: var(--color-error);
  margin-top: var(--space-xs);
}

.input-with-icon { position: relative; }
.input-with-icon .form-control { padding-right: 44px; }
.input-with-icon .material-symbols-rounded {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--color-text-muted);
  cursor: pointer;
  background: none;
  border: none;
}

.search-input-wrap { position: relative; }
.search-input-wrap .material-symbols-rounded {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--color-text-muted);
}

.search-input-wrap .form-control { padding-left: 40px; }

/* ==========================================
   CHIPS & BADGES
   ========================================== */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-caption);
  font-weight: 600;
  white-space: nowrap;
}

.chip-especialidad-mg { background: #E3F2FD; color: #1565C0; }
.chip-especialidad-odo { background: #F3E5F5; color: #7B1FA2; }
.chip-especialidad-ped { background: #FFF3E0; color: #E65100; }
.chip-especialidad-gin { background: #FCE4EC; color: #C2185B; }
.chip-especialidad-nut { background: #E8F5E9; color: #2E7D32; }
.chip-especialidad-otra { background: #F1F5F9; color: #475569; }

.chip-pendiente { background: var(--color-warning-light); color: #B45309; }
.chip-confirmado { background: var(--color-info-light); color: #1D4ED8; }
.chip-atendido { background: var(--color-success-light); color: #15803D; }
.chip-cancelado { background: var(--color-error-light); color: var(--color-error); }
.chip-espera { background: #F1F5F9; color: #475569; }
.chip-no-asistio { background: #F3E8FF; color: #6B21A8; }

.chip-programada { background: var(--color-info-light); color: #1D4ED8; }
.chip-en-curso { background: var(--color-warning-light); color: #B45309; }
.chip-finalizada { background: var(--color-success-light); color: #15803D; }

.chip-selectable {
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
}

.chip-selectable:hover { border-color: var(--color-primary); }
.chip-selectable.is-selected {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary);
}

/* ==========================================
   CARDS
   ========================================== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-md);
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.stat-card-value {
  font-size: var(--font-size-h2);
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
}

.stat-card-label {
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.stat-card-change {
  font-size: var(--font-size-caption);
  font-weight: 600;
  margin-top: var(--space-sm);
}

.stat-card-change.positive { color: var(--color-success); }
.stat-card-change.negative { color: var(--color-error); }

.brigada-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  transition: box-shadow var(--transition);
}

.brigada-card:hover { box-shadow: var(--shadow-md); }

.brigada-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-sm);
}

.brigada-card-title { font-size: var(--font-size-h4); font-weight: 600; }

.brigada-card-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
  margin: var(--space-sm) 0;
}

.brigada-card-meta span {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================
   TARJETA DE CAMPAÑA (listado de Campañas)
   Tratamiento tipo "ficha de evento": insignia de fecha + chips de
   especialidad, para reconocer una campaña de un vistazo sin leer texto.
   ========================================== */
.campana-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}

.campana-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--color-primary-light);
}

.campana-card-top {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}

.campana-fecha-badge {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--color-primary-light);
  color: var(--color-primary-hover);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
}

.campana-fecha-dia { font-size: 1.2rem; font-weight: 700; }
.campana-fecha-mes { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }

.campana-card--en_curso .campana-fecha-badge { background: var(--color-warning-light); color: #B45309; }
.campana-card--finalizada .campana-fecha-badge { background: var(--color-background); color: var(--color-text-muted); }
.campana-card--cancelada .campana-fecha-badge { background: var(--color-error-light); color: var(--color-error); opacity: 0.85; }

.campana-card-heading { flex: 1; min-width: 0; }
.campana-card-heading .campana-card-title { font-size: var(--font-size-h4); font-weight: 600; }

.campana-card-ubicacion {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.campana-card-ubicacion .material-symbols-rounded { font-size: 16px; flex-shrink: 0; }

.chip-vivo { display: inline-flex; align-items: center; gap: 5px; }

.punto-vivo {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulso-vivo 1.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .punto-vivo { animation: none; }
}

@keyframes pulso-vivo {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.campana-card-especialidades { display: flex; flex-wrap: wrap; gap: 6px; }

.campana-card-footer {
  margin-top: auto;
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.campana-card-capacidad {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-caption);
  color: var(--color-text-muted);
}

.campana-card-capacidad .material-symbols-rounded { font-size: 16px; }

.campana-card-acciones { display: flex; gap: 8px; }
.campana-card-acciones .btn { flex: 1; }

.filter-chip .filter-chip-count {
  margin-left: 4px;
  opacity: 0.7;
  font-size: 0.9em;
}

.medico-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  text-align: center;
}

.medico-card .avatar-md { margin: 0 auto var(--space-sm); }

.medico-card-name { font-weight: 600; margin-bottom: var(--space-xs); }

.medico-card-disponible {
  font-size: var(--font-size-caption);
  color: var(--color-success);
  font-weight: 600;
  margin: var(--space-sm) 0;
}

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

.noticia-card-img {
  height: 140px;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-accent-light));
  display: flex;
  align-items: center;
  justify-content: center;
}

.noticia-card-img .material-symbols-rounded {
  font-size: 48px;
  color: var(--color-primary);
  opacity: 0.5;
}

.noticia-card-body { padding: var(--space-md); }
.noticia-card-date { font-size: var(--font-size-caption); color: var(--color-text-muted); }
.noticia-card-title { font-weight: 600; margin: var(--space-xs) 0; }
.noticia-card-desc {
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.turno-card {
  background: var(--color-surface);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
}

.turno-code {
  font-size: var(--font-size-h1);
  font-weight: 700;
  color: var(--color-primary);
}

.turno-qr {
  width: 120px;
  height: 120px;
  margin: var(--space-md) auto;
  background: repeating-linear-gradient(45deg, #ccc, #ccc 2px, #fff 2px, #fff 8px);
  border-radius: var(--radius-sm);
}

/* ==========================================
   TABLE
   ========================================== */
.table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.data-table th,
.data-table td {
  padding: 12px var(--space-md);
  text-align: left;
  font-size: var(--font-size-small);
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  background: var(--color-background);
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: var(--font-size-caption);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table tbody tr:hover { background: var(--color-background); }
.data-table tbody tr { cursor: pointer; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
}

.pagination-btns { display: flex; gap: var(--space-sm); }

/* ==========================================
   CALENDAR
   ========================================== */
.calendar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  font-weight: 600;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
  font-size: var(--font-size-small);
}

.calendar-day-name {
  font-weight: 600;
  color: var(--color-text-muted);
  padding: var(--space-xs);
  font-size: var(--font-size-caption);
}

.calendar-day {
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  cursor: default;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calendar-day.has-event { font-weight: 700; }
.calendar-day.event-programada { background: var(--color-info-light); color: #1D4ED8; }
.calendar-day.event-en-curso { background: var(--color-warning-light); color: #B45309; }
.calendar-day.event-finalizada { background: var(--color-success-light); color: #15803D; }

/* ==========================================
   CHART (simple bar)
   ========================================== */
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: var(--space-md);
  height: 180px;
  padding: 28px 0 var(--space-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.chart-bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  min-width: 32px;
}

@media (max-width: 640px) {
  .chart-bar-item {
    flex: 0 0 56px;
    min-width: 56px;
  }
}

.chart-bar {
  width: 100%;
  max-width: 48px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--color-primary);
  transition: height var(--transition-slow);
  position: relative;
}

.chart-bar::after {
  content: attr(data-value);
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--font-size-caption);
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.chart-bar-label {
  font-size: var(--font-size-caption);
  color: var(--color-text-muted);
  text-align: center;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* ==========================================
   RESPONSIVE TABLE (Mobile)
   ========================================== */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 calc(var(--space-md) * -1);
  padding: 0 var(--space-md);
}

.table-responsive::-webkit-scrollbar { height: 6px; }
.table-responsive::-webkit-scrollbar-track { background: transparent; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--radius-full); }

@media (max-width: 640px) {
  .data-table thead { display: none; }
  .data-table tbody tr {
    display: block;
    padding: var(--space-md);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
    margin-bottom: var(--space-sm);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
  }
  .data-table tbody tr:hover { background: var(--color-surface); }
  .data-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-xs) 0;
    border-bottom: 1px solid var(--color-border);
    text-align: right;
  }
  .data-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: var(--font-size-caption);
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }
  .data-table tbody td:last-child { border-bottom: none; }
}

/* ==========================================
   ALERTS, TOAST, MODAL, PROGRESS
   ========================================== */
.alert-banner {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-warning-light);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-md);
  font-size: var(--font-size-small);
  color: #92400E;
  margin-bottom: var(--space-md);
  animation: slideDown 0.3s ease;
}

.alert-banner .material-symbols-rounded { font-size: 20px; flex-shrink: 0; }

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-120px);
  background: var(--color-text-main);
  color: white;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  font-size: var(--font-size-small);
  z-index: 3000;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  max-width: calc(100vw - var(--space-xl));
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-error); }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2500;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.modal-overlay.is-open { display: flex; opacity: 1; }

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  max-width: 440px;
  width: 100%;
  max-height: calc(100vh - var(--space-md) * 2);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.3s ease;
}

.modal-title { font-size: var(--font-size-h4); margin-bottom: var(--space-sm); }
.modal-body { color: var(--color-text-muted); font-size: var(--font-size-small); margin-bottom: var(--space-lg); }
.modal-actions { display: flex; gap: var(--space-sm); justify-content: flex-end; flex-wrap: wrap; }

.progress-bar-wrap {
  background: var(--color-border);
  border-radius: var(--radius-full);
  height: 8px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-caption);
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}

/* ==========================================
   LOGIN & AUTH PAGES
   ========================================== */
.auth-wrapper {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-background) 100%);
}

.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: var(--space-xl);
  animation: fadeIn 0.4s ease;
}

.auth-header { text-align: center; margin-bottom: var(--space-lg); }

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  color: var(--color-primary);
  margin-bottom: var(--space-md);
}

.auth-brand-logo,
.sidebar-brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.18);
  background: rgba(255,255,255,0.7);
}

.auth-brand .material-symbols-rounded { font-size: 40px; color: var(--color-secondary); }

.auth-brand-name {
  font-size: var(--font-size-h2);
  font-weight: 700;
  color: var(--color-primary);
}

.auth-title { font-size: var(--font-size-h3); margin-bottom: var(--space-xs); }
.auth-subtitle { font-size: var(--font-size-small); color: var(--color-text-muted); }

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-top: var(--space-md);
  text-align: center;
}

.auth-link { font-size: var(--font-size-small); color: var(--color-primary); }
.auth-link:hover { color: var(--color-primary-hover); }

.role-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.role-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: inherit;
  min-height: 80px;
}

.role-card:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  text-decoration: none;
  color: inherit;
  transform: translateY(-2px);
}

.role-card:active { transform: scale(0.98); }

.role-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ==========================================
   BOTTOM NAVIGATION
   ========================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottomnav-height);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.04);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  height: var(--bottomnav-height);
  color: var(--color-text-muted);
  font-size: var(--font-size-caption);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition);
  min-width: 56px;
}

.bottom-nav-item .material-symbols-rounded { font-size: 24px; transition: transform var(--transition); }

.bottom-nav-item.is-active { color: var(--color-primary); }
.bottom-nav-item.is-active .material-symbols-rounded { transform: scale(1.1); }
.bottom-nav-item:hover { color: var(--color-primary); text-decoration: none; }
.bottom-nav-item:active .material-symbols-rounded { transform: scale(0.9); }

.bottom-nav-fab {
  position: fixed;
  bottom: calc(var(--bottomnav-height) + var(--space-md));
  right: var(--space-md);
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-secondary);
  color: white;
  border: none;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
}

.bottom-nav-fab:hover {
  transform: scale(1.05) translateY(-2px);
  color: white;
  text-decoration: none;
  box-shadow: var(--shadow-lg), 0 4px 12px rgba(67, 160, 71, 0.3);
}

.bottom-nav-fab:active { transform: scale(0.95); }
.bottom-nav-fab .material-symbols-rounded { font-size: 28px; }

/* Hueco invisible del mismo ancho que un ítem real, para que el botón central
   elevado no quede pisando el ícono/etiqueta de "Pacientes". */
.bottom-nav-spacer { flex: 1; min-width: 56px; }

.bottom-nav-menu-btn {
  position: absolute;
  left: 50%;
  top: -20px;
  transform: translateX(-50%);
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: white;
  border: 4px solid var(--color-surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  z-index: 101;
}

.bottom-nav-menu-btn .material-symbols-rounded { font-size: 26px; }
.bottom-nav-menu-btn:hover { transform: translateX(-50%) scale(1.05); }
.bottom-nav-menu-btn:active { transform: translateX(-50%) scale(0.92); }

@media (min-width: 1024px) {
  .bottom-nav, .bottom-nav-fab { display: none; }
  .app-layout { padding-bottom: 0; }
}

/* ==========================================
   ANIMATIONS
   ========================================== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

.skeleton {
  background: linear-gradient(90deg, var(--color-border) 25%, var(--color-background) 50%, var(--color-border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

/* ==========================================
   UTILITIES & LAYOUT HELPERS
   ========================================== */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: var(--space-md); }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: var(--space-md); }
.grid-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-md); }

@media (min-width: 640px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr 1fr; }
}

@media (min-width: 1024px) {
  .grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.section-block { margin-bottom: var(--space-xl); }
.section-title { font-size: var(--font-size-h4); margin-bottom: var(--space-md); }

.filter-bar {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--space-xs);
}

.filter-chip {
  padding: 8px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  font-size: var(--font-size-small);
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  min-height: 40px;
}

.filter-chip:hover, .filter-chip.is-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
  transform: translateY(-1px);
}

.filter-chip:active { transform: scale(0.95); }

.detail-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-small);
  gap: var(--space-md);
}

.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--color-text-muted); flex-shrink: 0; }

.map-placeholder {
  height: 200px;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  position: relative;
  overflow: hidden;
}

.map-placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, var(--color-primary-light) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, var(--color-accent-light) 0%, transparent 50%);
  opacity: 0.5;
}

.map-placeholder .material-symbols-rounded { position: relative; z-index: 1; opacity: 0.6; }

.comunidad-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border);
  gap: var(--space-md);
}

.comunidad-item:last-child { border-bottom: none; }
.comunidad-item strong { font-size: var(--font-size-small); }

.toggle-switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--color-disabled);
  border-radius: var(--radius-full);
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider { background: var(--color-primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--color-border);
  gap: var(--space-md);
}

.setting-row:last-child { border-bottom: none; }

.empty-state {
  text-align: center;
  padding: var(--space-xxl);
  color: var(--color-text-muted);
}

.empty-state .material-symbols-rounded {
  font-size: 64px;
  opacity: 0.3;
  margin-bottom: var(--space-md);
}

/* Style guide hub */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-md);
}

@media (min-width: 640px) {
  .hub-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

.hub-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--color-text-main);
  font-weight: 600;
  font-size: var(--font-size-small);
  transition: all var(--transition);
  min-height: 120px;
  justify-content: center;
}

.hub-link:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  color: var(--color-primary);
  text-decoration: none;
  transform: translateY(-2px);
}

.hub-link .material-symbols-rounded {
  font-size: 32px;
  color: var(--color-primary);
}

/* ==========================================
   SKELETON LOADING
   ========================================== */
.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.skeleton-title {
  height: 24px;
  width: 70%;
  margin-bottom: 12px;
  border-radius: 4px;
}

/* ==========================================
   EMPTY & LOADING STATES
   ========================================== */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: var(--space-lg) auto;
}

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

/* ==========================================
   FOCUS & ACCESSIBILITY
   ========================================== */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Smooth appearance */
[data-reveal] {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

[data-reveal].revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================
   STAT GRID (dashboard) — no estaba en el hoja original, es usado por dashboard.html
   ========================================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-md);
}

/* ==========================================
   CHART CARDS (dashboard, Chart.js) — el contenedor fija una altura porque los canvas de
   Chart.js con responsive:true necesitan un padre con altura explícita, si no crecen sin
   límite en cada redibujado.
   ========================================== */
.chart-card-canvas-wrap {
  position: relative;
  height: 260px;
}

.chart-card-canvas-wrap--sm { height: 200px; }

.chart-card-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  text-align: center;
}

/* ==========================================
   MEDIA QUERIES SUMMARY
   ========================================== */
/* Mobile: default styles */
/* Tablet: min-width 640px */
/* Desktop: min-width 1024px */

/* ==========================================
   RENOVACIÓN VISUAL 2026
   Estos estilos elevan los componentes compartidos sin cambiar su estructura,
   de modo que tablas, tarjetas y formularios conserven el mismo lenguaje visual.
   ========================================== */
:root {
  --color-background: #F3F7FB;
  --color-border: #DCE6F0;
  --color-text-main: #17324D;
  --color-text-muted: #64788B;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 2px 8px rgba(24, 67, 112, 0.05);
  --shadow-md: 0 12px 30px rgba(24, 67, 112, 0.10);
  --shadow-lg: 0 24px 60px rgba(13, 71, 161, 0.16);
  --sidebar-width: 272px;
  --topbar-height: 68px;
}

body:not(.auth-page) {
  background:
    radial-gradient(circle at 85% 0%, rgba(66, 165, 245, 0.08), transparent 28rem),
    var(--color-background);
}

/* Navegación con mayor contraste y una marca más sólida. */
.sidebar {
  background: linear-gradient(180deg, #FFFFFF 0%, #F7FAFD 100%);
  border-right-color: rgba(21, 101, 192, 0.12);
  box-shadow: 8px 0 32px rgba(24, 67, 112, 0.05);
}

.sidebar-brand {
  min-height: var(--topbar-height);
  padding: 14px 20px;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
  border-bottom-color: rgba(21, 101, 192, 0.10);
}

.sidebar-brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 13px;
}

.sidebar-nav { padding: 18px 12px; }

.sidebar-link {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 11px;
  margin-bottom: 4px;
}

.sidebar-link .material-symbols-rounded {
  font-size: 21px;
  transition: transform var(--transition);
}

.sidebar-link:hover .material-symbols-rounded { transform: translateX(2px); }

.sidebar-link.is-active {
  background: linear-gradient(135deg, var(--color-primary) 0%, #1976D2 100%);
  box-shadow: 0 8px 20px rgba(21, 101, 192, 0.20);
}

.sidebar-section-label {
  color: #8A9BAD;
  letter-spacing: 0.09em;
}

.topbar {
  background: rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom-color: rgba(21, 101, 192, 0.10);
  padding: 0 28px;
}

.topbar-search { max-width: 520px; }

.topbar-search input {
  height: 44px;
  background: #F5F8FB;
  border-color: transparent;
}

.topbar-search input:focus {
  background: #FFFFFF;
  border-color: var(--color-primary);
}

.page-content {
  width: 100%;
  max-width: 1480px;
  padding: 32px clamp(20px, 3vw, 44px) 48px;
}

.page-header { margin-bottom: 28px; }

.page-header h1 {
  color: #143553;
  font-weight: 700;
  letter-spacing: -0.035em;
}

.page-subtitle { color: #708396; }
.section-block { margin-bottom: 32px; }
.section-title { color: #244863; letter-spacing: -0.02em; }

/* Botones más firmes y con estados perceptibles. */
.btn {
  border-radius: 11px;
  letter-spacing: 0.005em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, #1976D2 100%);
  box-shadow: 0 7px 16px rgba(21, 101, 192, 0.18);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(21, 101, 192, 0.24);
}

.btn-outline { background: rgba(255, 255, 255, 0.85); }

.form-label { color: #344F67; }

.form-control {
  min-height: 48px;
  border-color: #D5E0EA;
  background: #FBFDFE;
}

.form-control:hover { border-color: #B8CADB; }

/* Tarjetas con una superficie limpia, mayor aire y profundidad moderada. */
.card,
.brigada-card,
.campana-card,
.stat-card {
  border-color: rgba(21, 101, 192, 0.10);
  box-shadow: var(--shadow-sm);
}

.card {
  padding: 22px;
  background: rgba(255, 255, 255, 0.96);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-grid { gap: 20px; }

.brigada-card,
.campana-card {
  padding: 20px;
  background: linear-gradient(145deg, #FFFFFF 0%, #FBFDFF 100%);
}

.brigada-card:hover,
.campana-card:hover {
  border-color: rgba(21, 101, 192, 0.28);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.stat-grid { gap: 18px; }

.stat-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 118px;
  padding: 20px;
  overflow: hidden;
  background: linear-gradient(145deg, #FFFFFF 0%, #FAFCFE 100%);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.stat-card::after {
  content: '';
  position: absolute;
  right: -34px;
  bottom: -42px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(66, 165, 245, 0.06);
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: rgba(21, 101, 192, 0.22);
  box-shadow: var(--shadow-md);
}

.stat-card-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  border-radius: 15px;
}

.stat-card-icon .material-symbols-rounded { font-size: 25px; }
.stat-card-icon--primary { color: #1565C0; background: #E3F2FD; }
.stat-card-icon--success { color: #2E7D32; background: #E8F5E9; }
.stat-card-icon--info { color: #0277BD; background: #E1F5FE; }
.stat-card-icon--warning { color: #B45309; background: #FEF3C7; }
.stat-card-copy { position: relative; z-index: 1; min-width: 0; }

.stat-card-value {
  color: #153F65;
  font-size: clamp(1.65rem, 3vw, 2rem);
  letter-spacing: -0.04em;
}

.stat-card-label { margin-top: 3px; font-weight: 500; }

/* Tablas: contenedor elevado, cabecera más clara y filas fáciles de recorrer. */
.table-responsive,
.table-wrap {
  margin: 0;
  padding: 0;
  background: #FFFFFF;
  border: 1px solid rgba(21, 101, 192, 0.11);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.data-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 760px;
}

.data-table th,
.data-table td { padding: 15px 18px; }

.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: #49657D;
  background: #F2F7FB;
  border-bottom: 1px solid #D9E5EF;
  letter-spacing: 0.065em;
}

.data-table th:first-child { padding-left: 22px; }
.data-table td:first-child { padding-left: 22px; font-weight: 550; color: #294861; }
.data-table tbody tr { transition: background var(--transition), box-shadow var(--transition); }
.data-table tbody tr:nth-child(even) { background: #FBFDFE; }
.data-table tbody tr:hover { background: #EFF7FD; }
.data-table tbody tr:last-child td { border-bottom: 0; }

.pagination {
  border-top: 1px solid var(--color-border);
  background: #FBFDFE;
}

/* Acceso dividido: mensaje institucional a la izquierda y acción a la derecha. */
.auth-page { background: #FFFFFF; }

.auth-wrapper {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(460px, 0.95fr);
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
  background: #FFFFFF;
}

.auth-hero {
  position: relative;
  min-height: 100%;
  overflow: hidden;
  color: #FFFFFF;
  background:
    linear-gradient(145deg, rgba(8, 47, 90, 0.96), rgba(21, 101, 192, 0.92)),
    radial-gradient(circle at 25% 20%, #42A5F5, transparent 45%);
}

.auth-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.12;
  background-image:
    linear-gradient(rgba(255,255,255,.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.12) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.8), transparent 90%);
}

.auth-hero-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: clamp(32px, 5vw, 72px);
}

.auth-hero-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-hero-logo {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,.55);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(2, 28, 61, 0.25);
}

.auth-hero-message {
  width: min(680px, 100%);
  margin: auto 0;
  padding: 56px 0;
}

.auth-eyebrow {
  display: inline-flex;
  margin-bottom: 20px;
  padding: 7px 12px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: var(--radius-full);
  background: rgba(255,255,255,.10);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.auth-hero-message h2 {
  max-width: 650px;
  font-size: clamp(2.05rem, 3.5vw, 3.3rem);
  line-height: 1.1;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

.auth-hero-message > p {
  max-width: 620px;
  margin-top: 20px;
  color: rgba(255,255,255,.80);
  font-size: clamp(1rem, 1.5vw, 1.13rem);
  line-height: 1.75;
}

.auth-benefits {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
  margin-top: 28px;
}

.auth-benefits > span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,.92);
  font-size: .86rem;
  font-weight: 600;
}

.auth-benefits .material-symbols-rounded { color: #8BE29A; font-size: 20px; }
.auth-hero-footer { color: rgba(255,255,255,.58); font-size: .8rem; }

.auth-hero-decoration {
  position: absolute;
  z-index: 1;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 50%;
}

.auth-hero-decoration--one { width: 440px; height: 440px; right: -210px; top: -150px; }
.auth-hero-decoration--two { width: 260px; height: 260px; left: -120px; bottom: -90px; }

.auth-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: clamp(28px, 5vw, 72px);
  background:
    radial-gradient(circle at 100% 0%, rgba(67, 160, 71, .06), transparent 18rem),
    #FFFFFF;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  animation: fadeIn .45s ease;
}

.auth-header { margin-bottom: 32px; text-align: left; }
.auth-brand { display: none; }

.auth-welcome-label {
  display: block;
  margin-bottom: 10px;
  color: var(--color-secondary);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.auth-title {
  margin-bottom: 10px;
  color: #143553;
  font-size: clamp(1.75rem, 3vw, 2.15rem);
  letter-spacing: -0.04em;
}

.auth-subtitle { max-width: 390px; line-height: 1.65; }

.auth-input-wrap { position: relative; }
.auth-input-wrap > .material-symbols-rounded:first-child {
  position: absolute;
  z-index: 1;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: #7890A5;
  font-size: 20px;
  pointer-events: none;
}

.auth-input-wrap .form-control { padding-left: 46px; min-height: 52px; }
.input-with-icon.auth-input-wrap .form-control { padding-right: 48px; }
.input-with-icon.auth-input-wrap > button.material-symbols-rounded { right: 14px; left: auto; pointer-events: auto; }

.auth-actions { margin-top: 24px; }
.auth-submit { min-height: 52px; justify-content: space-between; padding-inline: 20px; }
.auth-submit .material-symbols-rounded { font-size: 20px; }
.auth-submit-spinner { animation: spin .8s linear infinite; }
.auth-link { font-weight: 600; }
.auth-panel-footer { margin-top: 42px; color: #93A2B1; font-size: .75rem; }

@media (max-width: 900px) {
  .auth-wrapper { grid-template-columns: 1fr; }
  .auth-hero { min-height: auto; }
  .auth-hero-content { min-height: auto; padding: 24px clamp(20px, 6vw, 48px); }
  .auth-hero-message { margin: 30px 0 8px; padding: 0; }
  .auth-hero-message h2 { font-size: clamp(1.75rem, 7vw, 2.55rem); }
  .auth-hero-message > p,
  .auth-benefits,
  .auth-hero-footer { display: none; }
  .auth-panel { padding: 40px clamp(20px, 8vw, 72px); }
  .auth-panel-footer { margin-top: 30px; }
}

@media (max-width: 640px) {
  .page-content { padding: 24px 16px calc(var(--bottomnav-height) + 64px); }
  .card { padding: 18px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stat-card { min-height: 132px; flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; }
  .stat-card-icon { width: 42px; height: 42px; flex-basis: 42px; border-radius: 13px; }
  .stat-card-value { font-size: 1.55rem; }

  .table-responsive {
    overflow: visible;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }

  .data-table { min-width: 0; }
  .data-table tbody { display: grid; gap: 12px; }
  .data-table tbody tr {
    margin: 0;
    padding: 16px;
    border: 1px solid rgba(21, 101, 192, 0.11);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
  }
  .data-table tbody tr:nth-child(even) { background: #FFFFFF; }
  .data-table tbody td { min-height: 36px; gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-card,
  .auth-submit-spinner { animation: none; }
}

/* ==========================================
   CAMPAÑAS — LISTADO OPERATIVO RESPONSIVE
   La vista usa una jerarquía propia porque una campaña combina fecha, estado,
   ubicación, capacidad y acciones que deben poder leerse de un solo vistazo.
   ========================================== */
.campanas-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 26px;
  border: 1px solid rgba(21, 101, 192, 0.10);
  border-radius: 20px;
  background:
    radial-gradient(circle at 86% 12%, rgba(66, 165, 245, 0.16), transparent 15rem),
    linear-gradient(135deg, #FFFFFF 0%, #F7FBFF 100%);
  box-shadow: var(--shadow-sm);
}

.campanas-page-heading {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.campanas-page-icon {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  display: grid;
  place-items: center;
  color: #FFFFFF;
  border-radius: 17px;
  background: linear-gradient(145deg, var(--color-primary), #2485DE);
  box-shadow: 0 10px 24px rgba(21, 101, 192, 0.22);
}

.campanas-page-icon .material-symbols-rounded { font-size: 29px; }

.page-eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--color-secondary);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.campanas-page-header h1 { margin-bottom: 2px; }
.campanas-header-action { flex: 0 0 auto; min-width: 170px; }
.campanas-header-action .material-symbols-rounded { font-size: 20px; }

.campanas-filter-bar {
  position: relative;
  gap: 6px;
  margin: 22px 0 20px;
  padding: 6px;
  width: fit-content;
  max-width: 100%;
  border: 1px solid rgba(21, 101, 192, 0.10);
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-sm);
}

.campanas-filter-bar .filter-chip {
  min-height: 38px;
  padding: 7px 15px;
  border-color: transparent;
  background: transparent;
}

.campanas-filter-bar .filter-chip:hover { transform: none; background: var(--color-primary-light); color: var(--color-primary); }

.campanas-filter-bar .filter-chip.is-active {
  color: #FFFFFF;
  background: linear-gradient(135deg, var(--color-primary), #1976D2);
  box-shadow: 0 6px 16px rgba(21, 101, 192, 0.18);
}

.campanas-filter-bar .filter-chip-count {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  margin-left: 5px;
  padding-inline: 5px;
  border-radius: var(--radius-full);
  background: rgba(96, 125, 139, 0.10);
  font-size: 0.67rem;
  opacity: 1;
}

.campanas-filter-bar .filter-chip.is-active .filter-chip-count { background: rgba(255, 255, 255, 0.18); }

.campanas-grid {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 20px;
}

.campana-card-skeleton { min-height: 350px; }

.campanas-grid .campana-card {
  --campana-accent: var(--color-primary);
  position: relative;
  min-width: 0;
  min-height: 380px;
  padding: 24px;
  gap: 16px;
  overflow: hidden;
  border-radius: 20px;
}

.campanas-grid .campana-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--campana-accent);
}

.campanas-grid .campana-card--en_curso { --campana-accent: var(--color-warning); }
.campanas-grid .campana-card--finalizada { --campana-accent: var(--color-secondary); }
.campanas-grid .campana-card--cancelada { --campana-accent: var(--color-error); }

.campanas-grid .campana-card-top {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
}

.campanas-grid .campana-fecha-badge {
  width: 64px;
  height: 72px;
  border: 1px solid rgba(21, 101, 192, 0.08);
  border-radius: 16px;
  background: linear-gradient(145deg, #EAF5FF, #DDEFFF);
}

.campanas-grid .campana-fecha-dia {
  font-size: 1.42rem;
  line-height: 1;
  letter-spacing: -0.04em;
}

.campanas-grid .campana-fecha-mes { margin-top: 2px; font-size: 0.65rem; }

.campana-fecha-anio {
  margin-top: 1px;
  font-size: 0.56rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  opacity: 0.65;
}

.campanas-grid .campana-card-heading { padding-top: 2px; }

.campana-card-kicker,
.campana-card-section-label {
  display: block;
  color: #8294A5;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.campanas-grid .campana-card-title {
  margin-top: 5px;
  color: #173A59;
  font-size: clamp(1.05rem, 1.5vw, 1.22rem);
  font-weight: 700;
  line-height: 1.32;
  letter-spacing: -0.025em;
}

.campanas-grid .campana-card-top > .chip {
  margin-top: 2px;
  border: 1px solid rgba(0, 0, 0, 0.025);
}

.campanas-grid .campana-card-ubicacion {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 58px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #E6EEF5;
  border-radius: 14px;
  background: #F8FBFD;
}

.campana-meta-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  color: var(--color-primary);
  border-radius: 10px;
  background: var(--color-primary-light);
}

.campana-meta-icon .material-symbols-rounded { font-size: 19px; }

.campanas-grid .campana-card-ubicacion > span:last-child {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.campanas-grid .campana-card-ubicacion small {
  color: #8294A5;
  font-size: 0.65rem;
  font-weight: 650;
  text-transform: uppercase;
}

.campanas-grid .campana-card-ubicacion strong {
  overflow: hidden;
  color: #415D74;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
}

.campanas-grid .campana-card-especialidades {
  align-content: flex-start;
  min-height: 30px;
  margin-top: -9px;
}

.campanas-grid .campana-card-especialidades .chip { padding: 5px 10px; }

.campanas-grid .campana-card-footer {
  gap: 14px;
  padding-top: 15px;
  border-top-color: #E4ECF3;
}

.campana-card-metricas {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.campana-card-metrica {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 9px 10px;
  border-radius: 12px;
  background: #F6F9FC;
}

.campana-card-metrica > .material-symbols-rounded {
  color: var(--campana-accent);
  font-size: 20px;
}

.campana-card-metrica > span:last-child {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.campana-card-metrica strong { color: #294A64; font-size: 0.9rem; line-height: 1.1; }

.campana-card-metrica small {
  overflow: hidden;
  color: #7A8D9E;
  font-size: 0.63rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.campanas-grid .campana-card-acciones .btn { min-height: 40px; }
.campanas-grid .campana-card-acciones .material-symbols-rounded { font-size: 17px; }

@media (min-width: 680px) {
  .campanas-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1200px) {
  .campanas-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
}

@media (max-width: 1023px) {
  .campanas-header-action { display: none; }

  .campanas-filter-bar {
    width: calc(100% + 32px);
    max-width: none;
    margin-inline: -16px;
    padding-inline: 16px;
    border-width: 1px 0;
    border-radius: 0;
    box-shadow: none;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  .campanas-filter-bar::-webkit-scrollbar { display: none; }
}

@media (max-width: 679px) {
  .campanas-page-header {
    align-items: flex-start;
    margin-inline: -4px;
    padding: 18px;
    border-radius: 18px;
  }

  .campanas-page-heading { align-items: flex-start; gap: 13px; }
  .campanas-page-icon { width: 46px; height: 46px; flex-basis: 46px; border-radius: 14px; }
  .campanas-page-icon .material-symbols-rounded { font-size: 24px; }
  .campanas-page-header h1 { font-size: clamp(1.55rem, 8vw, 1.85rem); }
  .campanas-page-header .page-subtitle { margin-top: 3px; line-height: 1.45; }

  .campanas-grid .campana-card {
    min-height: 0;
    padding: 20px;
    border-radius: 18px;
  }

  .campanas-grid .campana-card-top {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 12px;
  }

  .campanas-grid .campana-fecha-badge { width: 58px; height: 68px; }

  .campanas-grid .campana-card-top > .chip {
    grid-column: 2;
    justify-self: start;
    margin-top: -5px;
  }
}

@media (max-width: 400px) {
  .campanas-grid .campana-card-acciones { flex-direction: column; }
  .campanas-grid .campana-card-acciones .btn { width: 100%; }
}

/* ==========================================
   DESCARGA ANDROID — LOGIN Y CONFIGURACIÓN
   El QR se muestra grande en escritorio; en móvil se prioriza el enlace directo
   porque un teléfono no puede escanear cómodamente un código en su propia pantalla.
   ========================================== */
.auth-hero-logo {
  width: 68px;
  height: 68px;
  border-radius: 19px;
}

.auth-hero-brand { gap: 15px; font-size: 1.28rem; }

.auth-hero-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.auth-download[hidden] { display: none; }

.auth-download {
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(430px, 100%);
  margin-bottom: 36px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.20);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.11);
  box-shadow: 0 16px 40px rgba(3, 34, 70, 0.18);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.auth-download-qr {
  width: 132px;
  height: 132px;
  flex: 0 0 132px;
  display: grid;
  place-items: center;
  padding: 7px;
  border-radius: 13px;
  background: #FFFFFF;
  box-shadow: 0 8px 22px rgba(3, 34, 70, 0.20);
}

.auth-download-qr img { display: block; width: 100%; height: 100%; }

.auth-download-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.auth-download-platform {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
  color: #8BE29A;
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.auth-download-platform .material-symbols-rounded { font-size: 17px; }
.auth-download-copy strong { color: #FFFFFF; font-size: 0.96rem; line-height: 1.3; }
.auth-download-copy > span:not(.auth-download-platform) { margin-top: 3px; color: rgba(255,255,255,.67); font-size: 0.7rem; }

.auth-download-copy > a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 9px;
  color: #FFFFFF;
  font-size: 0.72rem;
  font-weight: 700;
  text-decoration: none;
}

.auth-download-copy > a:hover { color: #A8F0B4; }
.auth-download-copy > a .material-symbols-rounded { font-size: 16px; }

.config-app-card {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
  gap: 0;
  max-width: 920px;
  overflow: hidden;
  border: 1px solid rgba(21, 101, 192, 0.12);
  border-radius: 20px;
  background: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

.config-app-form { padding: 26px; }

.config-app-form > .config-app-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 15px;
  color: #FFFFFF;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--color-secondary), #55B95A);
  box-shadow: 0 9px 20px rgba(67, 160, 71, 0.20);
}

.config-app-icon .material-symbols-rounded { font-size: 27px; }
.config-app-form h3 { color: #21445F; font-size: 1.08rem; }
.config-app-form > div > .page-subtitle { max-width: 560px; margin: 5px 0 22px; line-height: 1.65; }
.config-app-form .form-group { margin-bottom: 14px; }

.form-help {
  display: block;
  margin-top: 7px;
  color: #7B8E9F;
  font-size: 0.72rem;
  line-height: 1.45;
}

.config-app-form .btn .material-symbols-rounded { font-size: 19px; }

.config-app-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 26px;
  border-left: 1px solid rgba(21, 101, 192, 0.10);
  background:
    radial-gradient(circle at 80% 10%, rgba(66, 165, 245, 0.16), transparent 11rem),
    #F4F9FD;
}

.config-app-preview-label {
  margin-bottom: 12px;
  color: #6C8295;
  font-size: 0.67rem;
  font-weight: 750;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.config-app-qr-frame {
  width: 190px;
  height: 190px;
  display: grid;
  place-items: center;
  padding: 10px;
  border: 1px solid #DCE8F1;
  border-radius: 17px;
  background: #FFFFFF;
  box-shadow: 0 12px 30px rgba(24, 67, 112, 0.10);
}

.config-app-qr-frame > img { width: 100%; height: 100%; }

.config-app-qr-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 135px;
  color: #8B9CAA;
  font-size: 0.72rem;
  line-height: 1.4;
  text-align: center;
}

.config-app-qr-empty[hidden] { display: none; }
.config-app-qr-empty .material-symbols-rounded { color: #A8BBCB; font-size: 52px; }

.config-app-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 13px;
  font-size: 0.76rem;
  font-weight: 700;
}

.config-app-link[hidden] { display: none; }
.config-app-link .material-symbols-rounded { font-size: 16px; }

@media (min-width: 901px) and (max-width: 1250px) {
  .auth-hero-bottom { flex-direction: column; align-items: flex-start; }
  .auth-download { width: 100%; }
}

@media (max-width: 900px) {
  .auth-hero-logo { width: 54px; height: 54px; border-radius: 16px; }
  .auth-hero-brand { font-size: 1.1rem; }
  .auth-hero-bottom { display: block; margin-top: 18px; }
  .auth-download { width: 100%; margin-bottom: 0; padding: 11px 13px; border-radius: 15px; }
  .auth-download-qr { display: none; }
  .auth-download-copy { width: 100%; }
  .auth-download-copy > span:not(.auth-download-platform) { display: none; }
  .auth-download-copy > a {
    width: 100%;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,.14);
  }
}

@media (max-width: 720px) {
  .config-app-card { grid-template-columns: 1fr; }
  .config-app-form { padding: 20px; }
  .config-app-preview { padding: 22px; border-top: 1px solid rgba(21, 101, 192, 0.10); border-left: 0; }
  .config-app-qr-frame { width: min(190px, 65vw); height: min(190px, 65vw); }
  .config-app-form .btn { width: 100%; }
}

/* ==========================================
   SISTEMA VISUAL DE MÓDULOS
   Estas piezas comparten jerarquía, espaciado y comportamiento responsive en
   todos los módulos administrativos. Así cada pantalla conserva su identidad
   sin obligar al usuario a aprender una interfaz distinta en cada sección.
   ========================================== */
.module-hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
  padding: 24px 26px;
  overflow: hidden;
  border: 1px solid rgba(21, 101, 192, 0.12);
  border-radius: 22px;
  background:
    radial-gradient(circle at 92% 12%, rgba(66, 165, 245, 0.17), transparent 13rem),
    linear-gradient(135deg, #FFFFFF 0%, #F4F9FD 100%);
  box-shadow: 0 10px 30px rgba(25, 78, 120, 0.06);
}

.module-hero::after {
  content: '';
  position: absolute;
  right: -52px;
  bottom: -72px;
  width: 180px;
  height: 180px;
  border: 1px solid rgba(21, 101, 192, 0.09);
  border-radius: 50%;
  pointer-events: none;
}

.module-hero-copy {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.module-hero-icon {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  display: grid;
  place-items: center;
  color: #FFFFFF;
  border-radius: 16px;
  background: linear-gradient(145deg, var(--color-primary), #2D87DA);
  box-shadow: 0 10px 22px rgba(21, 101, 192, 0.22);
}

.module-hero-icon--green {
  background: linear-gradient(145deg, var(--color-secondary), #5DBB63);
  box-shadow: 0 10px 22px rgba(67, 160, 71, 0.22);
}

.module-hero-icon--orange {
  background: linear-gradient(145deg, #F59E0B, #F7B63D);
  box-shadow: 0 10px 22px rgba(245, 158, 11, 0.20);
}

.module-hero-icon .material-symbols-rounded { font-size: 29px; }
.module-hero h1 { color: #123B5D; letter-spacing: -0.035em; }
.module-hero .page-subtitle { max-width: 720px; margin-top: 3px; line-height: 1.55; }
.module-hero-actions { position: relative; z-index: 1; display: flex; gap: 10px; flex-wrap: wrap; }

.module-eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--color-primary);
  font-size: 0.67rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.workflow-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.workflow-step {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid #E1EAF1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
}

.workflow-step-number {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  color: var(--color-primary);
  border-radius: 10px;
  background: var(--color-primary-light);
  font-size: 0.75rem;
  font-weight: 800;
}

.workflow-step strong { display: block; color: #294A64; font-size: 0.76rem; line-height: 1.2; }
.workflow-step small { display: block; margin-top: 2px; color: #7B8E9E; font-size: 0.66rem; line-height: 1.35; }

.module-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.module-metric {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid #E2EBF2;
  border-radius: 15px;
  background: #FFFFFF;
  box-shadow: 0 5px 16px rgba(24, 67, 112, 0.045);
}

.module-metric-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  color: var(--color-primary);
  border-radius: 12px;
  background: var(--color-primary-light);
}

.module-metric-icon .material-symbols-rounded { font-size: 21px; }
.module-metric strong { display: block; color: #1D4665; font-size: 1.12rem; line-height: 1.1; }
.module-metric span:last-child { display: block; margin-top: 3px; color: #7B8E9E; font-size: 0.69rem; }

.module-toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #E1EAF1;
  border-radius: 16px;
  background: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

.module-toolbar > * { min-width: 0; }
.module-toolbar .search-input-wrap { flex: 1; }
.module-toolbar .form-group { margin: 0; }
.module-toolbar-label { display: block; margin-bottom: 6px; color: #657B8D; font-size: 0.67rem; font-weight: 700; text-transform: uppercase; }
.module-toolbar-mobile-action { display: none; }

.data-panel {
  overflow: hidden;
  border: 1px solid #E0E9F0;
  border-radius: 18px;
  background: #FFFFFF;
  box-shadow: 0 8px 24px rgba(24, 67, 112, 0.055);
}

.data-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid #E7EEF4;
  background: #FBFDFE;
}

.data-panel-title { color: #244C69; font-size: 0.9rem; font-weight: 700; }
.data-panel-caption { margin-top: 2px; color: #8092A1; font-size: 0.69rem; }
.data-panel .table-responsive { margin: 0; padding: 0; }
.data-panel .data-table th:first-child,
.data-panel .data-table td:first-child { padding-left: 20px; }
.data-panel .data-table th:last-child,
.data-panel .data-table td:last-child { padding-right: 20px; }
.data-panel + .pagination,
.data-panel .pagination { margin-top: 0; padding: 14px 18px; border-top: 1px solid #E7EEF4; }

.table-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.table-actions .btn { min-width: 36px; }
.table-primary { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.table-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  color: var(--color-primary);
  border-radius: 11px;
  background: var(--color-primary-light);
  font-size: 0.72rem;
  font-weight: 800;
}

.form-workspace {
  display: grid;
  grid-template-columns: minmax(0, 700px) minmax(240px, 320px);
  align-items: start;
  gap: 20px;
}

.form-panel { padding: 26px; border: 1px solid #E0E9F0; border-radius: 18px; background: #FFFFFF; box-shadow: var(--shadow-sm); }
.form-section + .form-section { margin-top: 26px; padding-top: 24px; border-top: 1px solid #E6EDF3; }
.form-section-title { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; color: #244C69; font-size: 0.88rem; font-weight: 750; }
.form-section-title .material-symbols-rounded { color: var(--color-primary); font-size: 21px; }
.form-aside { position: sticky; top: calc(var(--topbar-height) + 20px); padding: 20px; border-radius: 18px; background: linear-gradient(145deg, #123F67, #1765A7); color: #FFFFFF; box-shadow: var(--shadow-md); }
.form-aside h3 { font-size: 0.96rem; }
.form-aside p { margin-top: 7px; color: rgba(255,255,255,.72); font-size: 0.73rem; line-height: 1.55; }
.form-aside-list { display: grid; gap: 12px; margin-top: 18px; }
.form-aside-item { display: flex; gap: 9px; font-size: 0.72rem; line-height: 1.4; }
.form-aside-item .material-symbols-rounded { color: #7FE08A; font-size: 19px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; padding-top: 20px; border-top: 1px solid #E6EDF3; }

.settings-nav {
  position: sticky;
  top: calc(var(--topbar-height) + 8px);
  z-index: 20;
  display: flex;
  gap: 7px;
  margin-bottom: 22px;
  padding: 7px;
  overflow-x: auto;
  border: 1px solid #E1EAF1;
  border-radius: 15px;
  background: rgba(255,255,255,.94);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.settings-nav a { flex: 0 0 auto; padding: 8px 12px; color: #5D7487; border-radius: 10px; font-size: 0.74rem; font-weight: 650; }
.settings-nav a:hover { color: var(--color-primary); background: var(--color-primary-light); }

@media (max-width: 900px) {
  .form-workspace { grid-template-columns: 1fr; }
  .form-aside { position: static; order: -1; }
}

@media (max-width: 720px) {
  .module-hero { align-items: flex-start; padding: 19px; border-radius: 18px; }
  .module-hero-copy { align-items: flex-start; gap: 12px; }
  .module-hero-icon { width: 46px; height: 46px; flex-basis: 46px; border-radius: 14px; }
  .module-hero-icon .material-symbols-rounded { font-size: 25px; }
  .module-hero h1 { font-size: clamp(1.5rem, 8vw, 1.8rem); }
  .module-hero-actions { display: none; }
  .workflow-strip { display: flex; margin-inline: -16px; padding-inline: 16px; overflow-x: auto; scrollbar-width: none; }
  .workflow-strip::-webkit-scrollbar { display: none; }
  .workflow-step { flex: 0 0 230px; }
  .module-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module-metric:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .module-toolbar { align-items: stretch; flex-direction: column; padding: 12px; }
  .module-toolbar .form-control { max-width: none !important; }
  .module-toolbar-mobile-action { display: inline-flex; width: 100%; }
  .data-panel { margin-inline: -4px; border-radius: 16px; }
  .data-panel-header { padding: 14px; }
  .data-panel .data-table tbody tr { margin: 10px; border: 1px solid #E4ECF2; }
  .data-panel .data-table tbody td { padding: 8px 0; }
  .data-panel .data-table th:first-child,
  .data-panel .data-table td:first-child,
  .data-panel .data-table th:last-child,
  .data-panel .data-table td:last-child { padding-left: 0; padding-right: 0; }
  .table-actions { width: 100%; justify-content: flex-end; }
  .form-panel { padding: 19px; }
  .form-actions { position: sticky; bottom: calc(var(--bottomnav-height) + 4px); z-index: 10; margin-inline: -19px; margin-bottom: -19px; padding: 13px 19px; background: rgba(255,255,255,.96); box-shadow: 0 -8px 22px rgba(24,67,112,.08); backdrop-filter: blur(10px); }
  .form-actions .btn { flex: 1; }
}

@media (max-width: 430px) {
  .module-metrics { grid-template-columns: 1fr; }
  .module-metric:last-child:nth-child(odd) { grid-column: auto; }
  .module-hero-copy > div { min-width: 0; }
  .module-eyebrow { font-size: 0.61rem; }
}
