/* ═══════════════════════════════════════════
   Vive IPS — Estilos Web Desktop
   ═══════════════════════════════════════════ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* ── Paleta marca Vive IPS (del logo oficial) ── */
  --primary:    #0088b8; /* Teal-azul del "VIVE" */
  --primary-d:  #006fa0; /* Variante oscura */
  --primary-l:  #d9f2fc; /* Fondos suaves */
  --accent:     #3ccece; /* Cyan del "I.P.S" */
  --navy:       #1e3870; /* Navy de "Servicios Domiciliarios" */
  --success:    #10b981;
  --warning:    #f59e0b;
  --danger:     #ef4444;
  --bg:         #f0f7fc; /* Fondo con tinte azul de marca */
  --card:       #ffffff;
  --text:       #0f172a;
  --sub:        #4e6a88; /* Azul-grisáceo coherente con marca */
  --border:     #cce4f5; /* Borde con tinte azul */
  --sidebar-w:  220px;
  --header-h:   64px;
  --radius:     16px;
  --shadow-sm:  0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow:     0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-md:  0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
  --shadow-lg:  0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body { font-family: 'Inter', system-ui, -apple-system, sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button { cursor: pointer; font-family: inherit; transition: all 0.2s ease; }
input, select, textarea { font-family: inherit; font-size: .95rem; transition: border-color 0.2s ease, box-shadow 0.2s ease; }

/* ─────────────────────────────────────────────
   LOGIN
───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

/* Panel izquierdo decorativo */
.login-page::before {
  content: '';
  background: linear-gradient(160deg, #006fa0 0%, #0088b8 45%, #3ccece 100%);
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 50%;
  z-index: 0;
}

.login-wrap {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 3rem 2rem;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* Branding en el lado izquierdo */
.login-brand {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  z-index: 1;
  text-align: center;
  padding: 2rem;
}
.login-brand .brand-icon { font-size: 5rem; margin-bottom: 1.2rem; }
.login-brand h1 { font-size: 2.4rem; font-weight: 800; }
.login-brand p  { font-size: 1rem; opacity: .8; margin-top: .5rem; max-width: 280px; }

.login-logo {
  width: 100%;
  max-width: 420px;
  text-align: center;
  margin-bottom: 1.2rem;
  cursor: pointer;
  user-select: none;
}
.login-logo h2 { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.login-logo p  { font-size: .9rem; color: var(--sub); margin-top: .2rem; }

.login-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  animation: fadeIn 0.4s ease-out;
}

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

.section-label { font-size: .78rem; font-weight: 700; color: var(--sub); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .9rem; }

/* Lista de roles */
.role-list { display: flex; flex-direction: column; gap: .5rem; }

.role-item {
  display: flex; align-items: center; gap: .9rem;
  width: 100%; padding: 1rem 1.2rem;
  background: #f8fafc; border: 1.5px solid transparent;
  border-radius: 12px; text-align: left; transition: all .2s ease;
  box-shadow: var(--shadow-sm);
}
.role-item:hover { background: var(--primary); border-color: var(--primary); color: white; transform: translateY(-2px); box-shadow: var(--shadow); }
.role-item:hover .role-info small { color: rgba(255,255,255,.85); }
.role-icon  { font-size: 1.3rem; flex-shrink: 0; }
.role-info  { flex: 1; }
.role-info strong { display: block; font-size: .92rem; font-weight: 600; }
.role-info small  { font-size: .78rem; color: var(--sub); }
.role-arrow { font-size: 1.3rem; color: var(--sub); }
.role-admin { border-color: #fca5a5; background: #fff5f5; }
.role-admin:hover { background: var(--danger); border-color: var(--danger); }

.divider-label {
  text-align: center; font-size: .75rem; color: var(--sub);
  border-top: 1px dashed var(--border);
  padding-top: .8rem; margin: .8rem 0 .5rem;
}

.secret-panel { margin-top: .8rem; display: flex; gap: .5rem; }
.secret-panel input {
  flex: 1; padding: .65rem 1rem; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .9rem; outline: none;
}
.secret-panel input:focus { border-color: var(--primary); }

/* Formularios login */
.back-btn { background: none; border: none; color: var(--primary); font-size: .88rem; margin-bottom: .9rem; padding: 0; display: flex; align-items: center; gap: .3rem; }
.login-card h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.2rem; }

.field-group { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field-group label { font-size: .8rem; font-weight: 600; color: var(--sub); }
.field-group input, .field-group select, .field-group textarea {
  padding: .75rem 1rem; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: .95rem; outline: none; transition: all .2s; background: white;
}
.field-group input:focus, .field-group select:focus, .field-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-l); }
.field-group textarea { resize: vertical; min-height: 80px; }

/* Botones */
.btn-primary {
  width: 100%; padding: .85rem; background: var(--primary); color: white;
  border: none; border-radius: 10px; font-size: .95rem; font-weight: 600;
  margin-top: .5rem; transition: all .2s; box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--primary-d); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-secondary {
  padding: .65rem 1.2rem; background: white; color: var(--text);
  border: 1.5px solid var(--border); border-radius: 10px; font-size: .88rem; font-weight: 600;
  transition: all .2s; box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-link {
  width: 100%; background: none; border: none; color: var(--primary);
  font-size: .9rem; font-weight: 500; padding: .6rem 0; text-align: center; display: block; margin-top: .5rem;
}
.btn-link:hover { text-decoration: underline; }
.btn-danger {
  padding: .7rem 1.4rem; background: var(--danger); color: white;
  border: none; border-radius: 10px; font-size: .9rem; font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-success {
  padding: .65rem 1.2rem; background: var(--success); color: white;
  border: none; border-radius: 10px; font-size: .88rem; font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.btn-success:hover { background: #059669; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-warning {
  padding: .65rem 1.2rem; background: var(--warning); color: white;
  border: none; border-radius: 10px; font-size: .88rem; font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.btn-warning:hover { background: #d97706; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-sm {
  padding: .35rem .8rem; border: none; border-radius: 8px;
  font-size: .78rem; font-weight: 600; cursor: pointer; transition: all .2s;
}
.btn-sm.confirm { background: #d1fae5; color: #065f46; }
.btn-sm.confirm:hover { background: #a7f3d0; }
.btn-sm.cancel  { background: #fee2e2; color: #991b1b; }
.btn-sm.cancel:hover { background: #fecaca; }

.status-msg { margin-top: 1rem; padding: .8rem 1rem; border-radius: 10px; font-size: .9rem; font-weight: 500; display: none; }
.status-msg.error   { display: block; background: #fef2f2; color: var(--danger); border: 1.5px solid #fca5a5; }
.status-msg.success { display: block; background: #f0fdf4; color: var(--success); border: 1.5px solid #6ee7b7; }
.status-msg.info    { display: block; background: #eff6ff; color: #1d4ed8; border: 1.5px solid #93c5fd; }

/* ─────────────────────────────────────────────
   APP LAYOUT
───────────────────────────────────────────── */
.app-page { display: flex; min-height: 100vh; background: var(--bg); }

/* ── Botón hamburguesa ─────────────────────────────────────── */
.sidebar-toggle {
  background: none; border: none; font-size: 1.1rem;
  cursor: pointer; color: var(--sub); padding: .32rem .52rem;
  border-radius: 8px; transition: all .15s; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.sidebar-toggle:hover { background: var(--bg); color: var(--primary); }

/* ── Sidebar colapsable ────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  transition: width .22s cubic-bezier(.4,0,.2,1); overflow: hidden;
  background: #ffffff;
  border-right: 1px solid rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  height: 100dvh;
  z-index: 100;
  box-shadow: var(--shadow-md);
  /* Mejora de rendimiento para animación mobile */
  will-change: transform;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.sidebar-logo {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: 0 1.2rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 1rem;
}
.sidebar-logo span { font-size: 1.5rem; }

.sidebar-user {
  padding: .75rem 1.2rem .9rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .7rem;
  background: var(--primary-l);
}
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); display: flex;
  align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
  color: #fff;
  box-shadow: 0 2px 6px rgba(67,56,202,.25);
}
.sidebar-name  { font-size: .84rem; font-weight: 700; line-height: 1.3; color: var(--primary); }
.sidebar-role  { font-size: .7rem; color: var(--sub); font-weight: 500; }

.sidebar-nav { flex: 1; padding: .5rem 0; overflow-y: auto; }

.nav-section-label {
  font-size: .63rem;
  font-weight: 700;
  color: var(--sub);
  text-transform: uppercase;
  letter-spacing: .09em;
  padding: .85rem 1.2rem .25rem;
  opacity: .55;
  user-select: none;
}

/* ── Grupos colapsables del sidebar ─────────────────────── */
.nav-group { margin-bottom: .15rem; }

.nav-group-hdr {
  display: flex; align-items: center; gap: .45rem;
  width: 100%; padding: .65rem 1.2rem .3rem;
  background: none; border: none; text-align: left;
  font-size: .63rem; font-weight: 700;
  color: var(--sub); text-transform: uppercase; letter-spacing: .09em;
  cursor: pointer; border-radius: 7px; transition: all .15s;
  opacity: .65;
}
.nav-group-hdr:hover { opacity: 1; background: var(--primary-l); color: var(--primary-d); }
.nav-group-lbl  { flex: 1; }
.nav-group-arr  { font-size: .6rem; transition: transform .22s ease; opacity: .7; }
.nav-group-hdr.open .nav-group-arr { transform: rotate(180deg); }

.nav-group-body { overflow: hidden; max-height: 0; transition: max-height .28s ease; }
.nav-group-body.open { max-height: 600px; }

.nav-item {
  display: flex; align-items: center; gap: .65rem;
  width: calc(100% - 1.2rem); padding: .5rem .85rem; margin: 0.1rem 0.6rem;
  background: none; border: none; text-align: left;
  font-size: .83rem; color: var(--sub); font-weight: 500;
  border-radius: 10px; transition: all .2s; cursor: pointer;
}
.nav-item:hover { background: var(--primary-l); color: var(--primary-d); transform: translateX(2px); }
.nav-item.active {
  background: var(--primary); color: white;
  font-weight: 600; box-shadow: var(--shadow-sm);
}
.nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.nav-item .nav-icon svg { width: 16px; height: 16px; stroke: currentColor; }

.nav-sub-group { padding: .1rem 0 .5rem 1rem; }
.nav-sub-item {
  display: flex; align-items: center; gap: .5rem;
  width: 100%; padding: .35rem .85rem;
  background: none; border: none; text-align: left;
  font-size: .775rem; color: var(--sub);
  border-radius: 6px; transition: all .13s; cursor: pointer;
}
.nav-sub-item:hover { background: var(--bg); color: var(--text); }
.nav-sub-item.active { background: var(--primary-l); color: var(--primary); font-weight: 600; }
.nav-sub-icon { font-size: .82rem; width: 16px; text-align: center; flex-shrink: 0; }

/* ── Dropdown de acciones ──────────────────────────────────── */
.ddw { position: relative; display: inline-block; }
.ddw-btn {
  display: flex; align-items: center; gap: .3rem;
  padding: .32rem .65rem; border: 1.5px solid var(--border);
  border-radius: 8px; background: var(--card); font-size: .82rem;
  color: var(--text); cursor: pointer; transition: all .13s; white-space: nowrap;
}
.ddw-btn:hover { border-color: var(--primary); color: var(--primary); }
.ddw-btn .ddarrow { font-size: .6rem; opacity: .6; transition: transform .15s; }
.ddw.open .ddarrow { transform: rotate(180deg); }
.ddw-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  min-width: 170px; background: var(--card);
  border: 1.5px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 1200;
  padding: .3rem 0; display: none;
}
.ddw.open .ddw-menu { display: block; }
.ddw-item {
  display: flex; align-items: center; gap: .55rem;
  width: 100%; padding: .52rem 1rem; background: none; border: none;
  font-size: .84rem; color: var(--text); text-align: left;
  cursor: pointer; transition: background .12s; white-space: nowrap;
}
.ddw-item:hover { background: var(--bg); }
.ddw-item.danger { color: var(--danger); }
.ddw-sep { height: 1px; background: var(--border); margin: .25rem 0; }
.rpt-export-btn {
  padding: .4rem .85rem; background: var(--card); border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .83rem; font-weight: 500; cursor: pointer;
  display: flex; align-items: center; gap: .35rem; color: var(--text); white-space: nowrap;
}
.rpt-export-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ── Secciones colapsables ─────────────────────────────────── */
.coll-hdr {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none; padding: .5rem 0;
}
.coll-hdr .coll-arr {
  font-size: .7rem; color: var(--sub); transition: transform .2s;
  background: var(--bg); border-radius: 50%; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.coll-hdr.open .coll-arr { transform: rotate(180deg); }
.coll-body { display: none; }
.coll-body.open { display: block; padding-top: .4rem; }

/* ── Informes: sub-tabs y filtros ──────────────────────────── */
.rpt-tab {
  padding: .45rem 1rem; border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--card); font-size: .83rem; color: var(--sub);
  cursor: pointer; transition: all .13s; font-weight: 500;
}
.rpt-tab:hover { border-color: var(--primary); color: var(--primary); }
.rpt-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }

.rpt-filters {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .75rem 1rem; background: var(--bg); border-radius: 10px;
  margin-bottom: .9rem;
}
.rpt-input {
  padding: .38rem .6rem; border: 1.5px solid var(--border); border-radius: 7px;
  font-size: .83rem; background: var(--card); color: var(--text);
}
.rpt-btn { padding: .38rem .85rem; font-size: .83rem; width: auto; }

.rpt-table-wrap { overflow-x: auto; }
.rpt-table {
  width: 100%; border-collapse: collapse; font-size: .8rem;
}
.rpt-table th {
  background: var(--primary-l); color: var(--primary);
  font-weight: 700; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .04em; padding: .5rem .7rem; text-align: left;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
.rpt-table td {
  padding: .42rem .7rem; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.rpt-table tr:hover td { background: var(--bg); }
.rpt-count { font-size: .8rem; color: var(--sub); margin-bottom: .4rem; }

.sidebar-footer {
  padding: .75rem 1.2rem;
  border-top: 1px solid var(--border);
}
.sidebar-logout {
  display: flex; align-items: center; gap: .7rem;
  width: 100%; padding: .55rem .7rem;
  background: none; border: none; border-radius: 8px;
  font-size: .84rem; color: var(--danger); cursor: pointer;
  transition: background .13s;
}
.sidebar-logout:hover { background: #fff1f2; opacity: 1; }

/* Estado colapsado del sidebar */
body.sidebar-collapsed .sidebar { width: 66px; }
body.sidebar-collapsed .app-content { margin-left: 66px; }
body.sidebar-collapsed .sidebar-logo div,
body.sidebar-collapsed .sidebar-name,
body.sidebar-collapsed .sidebar-role,
body.sidebar-collapsed .nav-section-label,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-sub-group,
body.sidebar-collapsed .nav-group-hdr { display: none !important; }
body.sidebar-collapsed .nav-group-body { max-height: none !important; overflow: visible !important; }
body.sidebar-collapsed .sidebar-logo { justify-content: center; padding: 0 .4rem; }
body.sidebar-collapsed .sidebar-user { justify-content: center; padding: .75rem .4rem; }
body.sidebar-collapsed .sidebar-avatar { margin: 0; }
body.sidebar-collapsed .nav-item {
  justify-content: center; padding: .65rem 0;
  margin: .15rem .3rem; width: calc(100% - .6rem);
}
body.sidebar-collapsed .nav-item .nav-icon { width: 20px; height: 20px; }
body.sidebar-collapsed .nav-item .nav-icon svg { width: 20px; height: 20px; }
body.sidebar-collapsed .sidebar-logout { justify-content: center; padding: .55rem 0; }
body.sidebar-collapsed .sidebar-logout .sidebar-logout-label { display: none; }

/* ── Panel de filtros avanzados ────────────────────────────── */
.filter-toggle-btn {
  display: flex; align-items: center; gap: .35rem;
  padding: .42rem .8rem; background: var(--card);
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .82rem; color: var(--sub); cursor: pointer;
  white-space: nowrap; transition: all .15s; font-weight: 500;
}
.filter-toggle-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-toggle-btn.active { border-color: var(--primary); color: var(--primary); background: var(--primary-l); }
.filter-toggle-btn .ftarrow { font-size: .58rem; transition: transform .2s; opacity: .7; }
.filter-toggle-btn.active .ftarrow { transform: rotate(180deg); }
.filter-panel {
  display: none; gap: .5rem; flex-wrap: wrap; align-items: center;
  padding: .5rem 0 .1rem; animation: slideDown .17s ease;
}
.filter-panel.open { display: flex; }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Main */
.app-content {
  margin-left: var(--sidebar-w);
  transition: margin-left .22s cubic-bezier(.4,0,.2,1);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-topbar {
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2.5rem;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}
.topbar-title { font-size: 1.1rem; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-date  { font-size: .85rem; color: var(--sub); }

.app-main { flex: 1; padding: 1.25rem 1.75rem; }

/* Views */
.view { display: none; }
.view.active { display: block; }

/* ─────────────────────────────────────────────
   COMPONENTES
───────────────────────────────────────────── */

/* Welcome banner */
.welcome-banner {
  background: linear-gradient(135deg, #006fa0 0%, #0088b8 50%, #3ccece 100%);
  color: white; border-radius: var(--radius);
  padding: 1.8rem 2.5rem;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-md);
  position: relative; overflow: hidden;
}
.welcome-banner::after {
  content: ''; position: absolute; right: -50px; top: -50px;
  width: 200px; height: 200px; background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
  border-radius: 50%; pointer-events: none;
}
.welcome-text p  { font-size: .95rem; opacity: .9; font-weight: 500; }
.welcome-text h2 { font-size: 1.7rem; font-weight: 800; margin-top: .3rem; letter-spacing: -0.02em; }
.welcome-icon    { font-size: 3.5rem; opacity: .8; transform: rotate(-5deg); }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card); border-radius: var(--radius);
  padding: 1.3rem 1.5rem; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 1rem;
}
.stat-icon  { font-size: 1.8rem; }
.stat-body  {}
.stat-num   { font-size: 1.8rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--sub); margin-top: .2rem; }

/* Section header */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.section-header h3 { font-size: 1rem; font-weight: 700; }

/* Cards */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 1.5rem; box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.03);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.card:hover { box-shadow: var(--shadow-md); }

/* Grid de contenido */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.content-grid.thirds  { grid-template-columns: 1fr 1fr 1fr; }
.content-grid.full    { grid-template-columns: 1fr; }
.col-span-2 { grid-column: span 2; }

/* Tabla de citas */
.appt-table { width: 100%; border-collapse: collapse; }
.appt-table th {
  text-align: left; font-size: .8rem; font-weight: 700;
  color: var(--sub); text-transform: uppercase; letter-spacing: .05em;
  padding: .8rem 1rem; border-bottom: 2px solid var(--border);
  background: #f8fafc;
}
.appt-table td {
  padding: .9rem 1rem; border-bottom: 1px solid var(--border);
  font-size: .9rem; vertical-align: middle; transition: background 0.15s;
}
.appt-table tr:hover td { background: #f1f5f9; }
.appt-table tr:last-child td { border-bottom: none; }

/* Priority dot */
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.green  { background: var(--success); }
.dot.yellow { background: var(--warning); }
.dot.red    { background: var(--danger); }

/* Badge de estado */
.badge {
  display: inline-block; font-size: .75rem; font-weight: 600;
  padding: .25rem .7rem; border-radius: 20px; white-space: nowrap;
  letter-spacing: 0.02em;
}
.badge-pending     { background: #fef3c7; color: #b45309; }
.badge-scheduled   { background: #e0f2fe; color: #0369a1; }
.badge-confirmed   { background: #d1fae5; color: #047857; }
.badge-in_progress { background: #fce7f3; color: #be185d; }
.badge-completed   { background: #dcfce7; color: #15803d; }
.badge-cancelled   { background: #fee2e2; color: #b91c1c; }
.badge-no_show     { background: #f1f5f9; color: #475569; }

/* Tarjeta de paciente */
.patient-row {
  display: flex; align-items: center; gap: .9rem;
  padding: .8rem 0; border-bottom: 1px solid var(--border);
}
.patient-row:last-child { border-bottom: none; }
.patient-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary-l);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.patient-info { flex: 1; }
.patient-name { font-size: .9rem; font-weight: 600; }
.patient-meta { font-size: .78rem; color: var(--sub); margin-top: .1rem; }

/* Tarjeta de usuario */
.user-row {
  display: flex; align-items: center; gap: .9rem;
  padding: .75rem 0; border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: none; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary-l);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.user-info { flex: 1; }
.user-name { font-size: .88rem; font-weight: 600; }
.user-meta { font-size: .75rem; color: var(--sub); }
.user-role-badge {
  font-size: .7rem; font-weight: 700; padding: .2rem .55rem;
  border-radius: 20px; background: var(--primary-l); color: var(--primary);
}

/* Log */
.log-row {
  display: flex; align-items: flex-start; gap: .8rem;
  padding: .7rem 0; border-bottom: 1px solid var(--border); font-size: .85rem;
}
.log-row:last-child { border-bottom: none; }
.log-dot { margin-top: .35rem; }
.log-body { flex: 1; }
.log-action { font-weight: 600; }
.log-meta   { font-size: .78rem; color: var(--sub); margin-top: .15rem; }

/* Filtros */
.filter-bar {
  display: flex; gap: .6rem; flex-wrap: wrap;
  margin-bottom: 1rem; align-items: center;
}
.filter-bar input, .filter-bar select {
  padding: .55rem .85rem; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .88rem; background: var(--card); outline: none;
  min-width: 140px;
}
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--primary); }
.filter-btn {
  padding: .55rem 1.1rem; background: var(--primary); color: white;
  border: none; border-radius: 8px; font-size: .88rem; font-weight: 600;
}

/* Search bar */
.search-bar {
  display: flex; align-items: center; gap: .6rem;
  background: var(--card); border: 1.5px solid var(--border);
  border-radius: 8px; padding: .55rem 1rem;
  margin-bottom: 1rem;
}
.search-bar:focus-within { border-color: var(--primary); }
.search-bar input { flex: 1; border: none; outline: none; font-size: .9rem; background: transparent; }

/* Perfil */
.profile-section {
  display: grid; grid-template-columns: 280px 1fr; gap: 1.5rem;
}
.profile-card {
  background: var(--card); border-radius: var(--radius);
  padding: 2rem 1.5rem; box-shadow: var(--shadow); text-align: center;
}
.profile-avatar-lg {
  width: 80px; height: 80px; border-radius: 50%; background: var(--primary-l);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; margin: 0 auto 1rem;
}
.profile-card h2 { font-size: 1.1rem; font-weight: 700; }
.profile-role    { font-size: .85rem; color: var(--sub); margin: .3rem 0 1.2rem; }

.info-list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .9rem 1.2rem; border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }
.info-label { font-size: .82rem; color: var(--sub); }
.info-value { font-size: .9rem; font-weight: 600; }

/* Perfil v2 */
.profile-card-v2 {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow-md); overflow: hidden; max-width: 500px;
}
.profile-hero { padding: 1.8rem 1.5rem 1.4rem; }
.profile-hero-inner { display: flex; align-items: center; gap: 1.1rem; }
.profile-hero-avatar {
  width: 68px; height: 68px; border-radius: 50%;
  background: rgba(255,255,255,.25); color: #fff;
  font-size: 1.9rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; border: 3px solid rgba(255,255,255,.4);
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.profile-hero-name {
  margin: 0; font-size: 1.15rem; font-weight: 800; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.profile-hero-badge {
  font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  background: rgba(255,255,255,.2); color: #fff;
  border-radius: 20px; padding: .18rem .65rem;
  display: inline-block; margin-top: .3rem;
  border: 1px solid rgba(255,255,255,.3);
}
.profile-info-grid {
  border: 1.5px solid var(--border); border-radius: 10px; overflow: hidden;
}
.profile-info-row {
  display: flex; align-items: center;
  padding: .65rem 1rem; border-bottom: 1px solid var(--border);
}
.profile-info-row:last-child { border-bottom: none; }
.profile-info-label {
  font-size: .74rem; font-weight: 700; color: var(--sub);
  text-transform: uppercase; letter-spacing: .04em; min-width: 88px; flex-shrink: 0;
}
.profile-info-value { font-size: .9rem; font-weight: 600; color: var(--text); }
.profile-action-btns { display: flex; gap: .65rem; padding: 1rem 1.5rem; }
.btn-profile-edit {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: .45rem; padding: .6rem 1rem; font-size: .85rem; font-weight: 700;
  border-radius: 9px; border: none; cursor: pointer;
  background: var(--primary); color: #fff; transition: all .15s;
}
.btn-profile-edit:hover { background: var(--primary-d); transform: translateY(-1px); }
.btn-profile-pwd {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: .45rem; padding: .6rem 1rem; font-size: .85rem; font-weight: 700;
  border-radius: 9px; cursor: pointer; transition: all .15s;
  background: var(--primary-l); color: var(--primary-d);
  border: 1.5px solid var(--border);
}
.btn-profile-pwd:hover { background: #c5e8f5; transform: translateY(-1px); }
.btn-profile-edit.active, .btn-profile-pwd.active {
  outline: 2.5px solid var(--primary); outline-offset: 2px;
}
.profile-panel {
  border-top: 1.5px solid var(--border); padding: 1.2rem 1.5rem 1.5rem;
  animation: profileSlideDown .18s ease;
}
@keyframes profileSlideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.profile-panel-title {
  font-size: .74rem; font-weight: 700; color: var(--sub);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 1rem;
}
.pwd-eye-wrap { position: relative; }
.pwd-eye-wrap .form-input { padding-right: 2.6rem; }
.pwd-eye-btn {
  position: absolute; right: .65rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--sub); padding: 0;
  display: flex; align-items: center; line-height: 1;
}
.pwd-eye-btn:hover { color: var(--primary); }
/* Campos con icono izquierdo (modales de perfil) */
.field-icon-wrap { position: relative; }
.field-icon {
  position: absolute; left: .85rem; top: 50%; transform: translateY(-50%);
  color: var(--sub); pointer-events: none; display: flex; align-items: center;
}
.field-icon-wrap input,
.field-icon-wrap .form-input { padding-left: 2.6rem !important; }
.field-icon-wrap.has-eye input,
.field-icon-wrap.has-eye .form-input { padding-right: 2.6rem !important; }
.field-icon-wrap .pwd-eye-btn { position: absolute; right: .7rem; top: 50%; transform: translateY(-50%); }
.pwd-strength-track {
  height: 4px; border-radius: 4px; background: #e5e7eb; overflow: hidden; margin-top: .4rem;
}
.pwd-strength-fill {
  height: 100%; border-radius: 4px; width: 0; transition: width .25s, background .25s;
}
.pwd-strength-label { font-size: .72rem; margin-top: .22rem; font-weight: 600; }

/* QR */
.qr-section { text-align: center; padding: 1.5rem; }
.qr-icon    { font-size: 3rem; margin-bottom: .8rem; }
.qr-input {
  width: 100%; max-width: 360px; padding: .8rem 1rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 1rem; text-align: center; outline: none; margin-bottom: 1rem;
}
.qr-input:focus { border-color: var(--primary); }
.qr-actions { display: flex; gap: .8rem; justify-content: center; }

/* Chat inline */
.chat-panel {
  display: flex; flex-direction: column;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  height: 480px;
}
.chat-messages-inner {
  flex: 1; overflow-y: auto; padding: 1rem;
  background: #ece5dd; display: flex; flex-direction: column; gap: .5rem;
}
.chat-input-row {
  display: flex; gap: .6rem; padding: .7rem;
  background: #f0f0f0; border-top: 1px solid var(--border);
}
.chat-input-row input {
  flex: 1; padding: .65rem 1rem; border: 1px solid var(--border);
  border-radius: 20px; font-size: .9rem; outline: none;
}
.chat-input-row button {
  background: var(--primary); color: white; border: none;
  border-radius: 50%; width: 38px; height: 38px; font-size: 1rem;
  flex-shrink: 0;
}
.chat-bubble { max-width: 70%; padding: .6rem .9rem; border-radius: 10px; font-size: .88rem; line-height: 1.45; word-break: break-word; }
.chat-bubble.bot  { background: white; align-self: flex-start; border-bottom-left-radius: 2px; }
.chat-bubble.user { background: #dcf8c6; align-self: flex-end; border-bottom-right-radius: 2px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 300; }
.modal-box {
  background: var(--card); border-radius: var(--radius);
  padding: 1.8rem; width: 100%; max-width: 500px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; }
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-header button { background: none; border: none; font-size: 1.4rem; color: var(--sub); }
.modal-footer { display: flex; justify-content: flex-end; gap: .7rem; margin-top: 1.2rem; }

/* Form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.form-grid .full { grid-column: span 2; }

/* Toast */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: #1a1a2e; color: white;
  padding: .7rem 1.4rem; border-radius: 8px;
  font-size: .88rem; opacity: 0; transition: opacity .25s;
  pointer-events: none; z-index: 400;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--danger); }

/* Empty */
.empty-state { text-align: center; color: var(--sub); font-size: .9rem; padding: 2.5rem 0; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

/* ─────────────────────────────────────────────
   PAGE / SECTION HEADERS
───────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-header h2 { font-size: 1.2rem; font-weight: 700; }
.page-header h3 { font-size: 1rem; font-weight: 700; }

.section-title {
  font-size: .75rem; font-weight: 700; color: var(--sub);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: .8rem; margin-top: .2rem;
}

/* ─────────────────────────────────────────────
   CARD LIST & APPOINTMENT CARDS
───────────────────────────────────────────── */
.card-list { display: flex; flex-direction: column; gap: .65rem; margin-bottom: 1rem; }

.appt-card {
  background: var(--card); border-radius: var(--radius);
  padding: 1.2rem 1.4rem; box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  transition: all 0.2s ease;
}
.appt-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.appt-card.green  { border-color: var(--success); background: #f0fdf4; }
.appt-card.yellow { border-color: var(--warning); background: #fffbeb; }
.appt-card.red    { border-color: var(--danger); background: #fef2f2; }
.appt-header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.appt-name    { font-weight: 700; font-size: 1rem; color: var(--text); }
.appt-meta    { font-size: .85rem; color: var(--sub); margin-top: .2rem; }
.appt-address { font-size: .85rem; color: var(--sub); margin-top: .3rem; display: flex; align-items: center; gap: 0.3rem; }
.appt-address::before { content: '📍'; font-size: 0.8rem; }
.appt-actions { display: flex; gap: .6rem; margin-top: .8rem; }

/* ─────────────────────────────────────────────
   ICON BUTTON
───────────────────────────────────────────── */
.btn-icon {
  padding: .5rem 1rem; background: var(--primary); color: white;
  border: none; border-radius: 10px; font-size: .9rem; font-weight: 600;
  box-shadow: var(--shadow-sm); transition: all 0.2s;
}
.btn-icon:hover { background: var(--primary-d); transform: translateY(-1px); box-shadow: var(--shadow); }

/* ─────────────────────────────────────────────
   QR SECTION
───────────────────────────────────────────── */
.qr-section { text-align: center; padding: 1rem 0; }
.qr-section p { color: var(--sub); font-size: .9rem; margin-bottom: .8rem; }

/* ─────────────────────────────────────────────
   FLOATING CHAT WIDGET
───────────────────────────────────────────── */
.chat-widget { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 200; }

.chat-toggle {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: white; border: none;
  font-size: 1.3rem; display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: var(--shadow-md); margin-left: auto;
}
.chat-toggle:hover { background: var(--primary-d); }

.chat-box {
  position: absolute; bottom: 64px; right: 0;
  width: 320px; background: var(--card); border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  display: none; flex-direction: column; overflow: hidden;
}
.chat-box.open { display: flex; }

.chat-header {
  background: var(--primary); color: white;
  padding: .75rem 1rem; display: flex; align-items: center;
  justify-content: space-between; font-weight: 600; font-size: .92rem;
}
.chat-header button { background: none; border: none; color: white; font-size: 1.1rem; cursor: pointer; }

.chat-messages {
  height: 260px; overflow-y: auto; padding: .8rem;
  background: #ece5dd; display: flex; flex-direction: column; gap: .4rem;
}

.chat-input-area {
  display: flex; gap: .5rem; padding: .6rem;
  background: #f0f2f5; border-top: 1px solid var(--border);
}
.chat-input-area input {
  flex: 1; padding: .55rem .9rem; border: 1px solid var(--border);
  border-radius: 20px; font-size: .88rem; outline: none; background: white;
}
.chat-input-area input:focus { border-color: var(--primary); }
.chat-input-area button {
  background: var(--primary); color: white; border: none;
  border-radius: 50%; width: 34px; height: 34px; font-size: .9rem;
  flex-shrink: 0; cursor: pointer;
}

/* ─────────────────────────────────────────────
   SUB-TABS (filtros de sección tipo semáforo)
───────────────────────────────────────────── */
.sub-tabs {
  display: flex; gap: .4rem; flex-wrap: wrap;
  margin: .8rem 0 1rem;
}
.sub-tab {
  padding: .38rem .95rem;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: #fff;
  color: var(--sub);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.sub-tab:hover    { border-color: var(--primary); color: var(--primary); }
.sub-tab.active   { background: var(--primary); color: #fff; border-color: var(--primary); }
.sub-tab.s-green  { border-color: var(--success); color: var(--success); }
.sub-tab.s-green.active  { background: var(--success); border-color: var(--success); color: #fff; }
.sub-tab.s-red    { border-color: var(--danger); color: var(--danger); }
.sub-tab.s-red.active    { background: var(--danger); border-color: var(--danger); color: #fff; }

/* Badges extra */
.badge-expired  { background: #fee2e2; color: #991b1b; }
.badge-vencida  { background: #fef3c7; color: #92400e; }

/* Appt-card vencida → fondo levemente rosado */
.appt-card.red .appt-name { color: var(--danger); }

/* ─────────────────────────────────────────────
   GRILLA DE DISPONIBILIDAD
───────────────────────────────────────────── */
.avail-grid { width: 100%; border-collapse: collapse; font-size: .82rem; }
.avail-grid th, .avail-grid td {
  padding: .45rem .5rem; text-align: center;
  border: 1px solid var(--border);
}
.avail-grid th { background: var(--surface); font-weight: 600; white-space: nowrap; }
.avail-time    { font-weight: 600; color: var(--sub); width: 56px; white-space: nowrap; }
.avail-cell    { border-radius: 3px; font-size: .78rem; }
.avail-free    { background: #e8f5e9; color: #2e7d32; }
.avail-busy    { background: #fff3e0; color: #e65100; }
.avail-full    { background: #ffebee; color: #c62828; font-weight: 700; }
.avail-cell.closed { background: #f5f5f5; color: #bdbdbd; }

/* Time slot select */
select.slot-select {
  width: 100%; padding: .7rem; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .95rem; background: #fff;
  appearance: none; cursor: pointer;
}
select.slot-select:focus { border-color: var(--primary); outline: none; }

/* Map button mini */
.btn-map {
  background: none; border: none; cursor: pointer;
  font-size: .9rem; padding: .1rem .25rem;
  vertical-align: middle; opacity: .7;
}
.btn-map:hover { opacity: 1; }

/* ─────────────────────────────────────────────
   DASHBOARD DINÁMICO — Resúmenes
───────────────────────────────────────────── */

/* Stats row */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.dash-stat {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,.045);
  display: flex; align-items: center; gap: .9rem;
  transition: transform .15s, box-shadow .15s;
}
.dash-stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.dash-stat.green  { border-color: rgba(16,185,129,.25); }
.dash-stat.yellow { border-color: rgba(245,158,11,.25); }
.dash-stat.red    { border-color: rgba(239,68,68,.25); }
.dash-stat.blue   { border-color: rgba(0,136,184,.2); }

.dash-stat-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; flex-shrink: 0;
}
.dash-stat.green  .dash-stat-icon { background: #e8f5e9; }
.dash-stat.yellow .dash-stat-icon { background: #fff8e1; }
.dash-stat.red    .dash-stat-icon { background: #ffebee; }
.dash-stat.blue   .dash-stat-icon { background: var(--primary-l); }

.dash-stat-num   { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.dash-stat.green  .dash-stat-num { color: var(--success); }
.dash-stat.yellow .dash-stat-num { color: var(--warning); }
.dash-stat.red    .dash-stat-num { color: var(--danger); }
.dash-stat.blue   .dash-stat-num { color: var(--primary); }

.dash-stat-label { font-size: .78rem; color: var(--sub); margin-top: .2rem; }
.dash-stat-sub   { font-size: .72rem; font-weight: 600; margin-top: .25rem; }
.dash-stat.green  .dash-stat-sub { color: var(--success); }
.dash-stat.yellow .dash-stat-sub { color: var(--warning); }
.dash-stat.red    .dash-stat-sub { color: var(--danger); }
.dash-stat.blue   .dash-stat-sub { color: var(--primary); }

/* Main grid (2 cols) */
.dash-grid {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 1rem;
}

/* Zone bar chart */
.zone-bar-row {
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem 0; border-bottom: 1px solid var(--border);
}
.zone-bar-row:last-child { border-bottom: none; }
.zone-bar-label { font-size: .82rem; font-weight: 600; width: 108px; flex-shrink: 0; }
.zone-bar-track { flex: 1; height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.zone-bar-fill  { height: 100%; border-radius: 5px; transition: width .5s ease; }
.zone-bar-count { font-size: .82rem; font-weight: 700; width: 26px; text-align: right; flex-shrink: 0; }

/* Online users */
.online-row {
  display: flex; align-items: center; gap: .8rem;
  padding: .6rem 0; border-bottom: 1px solid var(--border);
}
.online-row:last-child { border-bottom: none; }

.online-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--success); flex-shrink: 0;
  animation: pulse-online 2s infinite;
}
@keyframes pulse-online {
  0%   { box-shadow: 0 0 0 0 rgba(67,160,71,.55); }
  70%  { box-shadow: 0 0 0 7px rgba(67,160,71,0); }
  100% { box-shadow: 0 0 0 0 rgba(67,160,71,0); }
}

.online-info { flex: 1; min-width: 0; }
.online-name { font-size: .87rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-tab  { font-size: .73rem; color: var(--sub); margin-top: .1rem; }

/* Quick action buttons */
.dash-action-btn {
  width: 100%; padding: .6rem 1rem;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 8px; text-align: left; font-size: .87rem;
  font-weight: 500; color: var(--text); transition: all .15s;
}
.dash-action-btn:hover {
  background: var(--primary-l); border-color: var(--primary); color: var(--primary);
}

/* Doctor workload ranking */
.workload-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 0; border-bottom: 1px solid var(--border);
}
.workload-row:last-child { border-bottom: none; }
.workload-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-l); display: flex; align-items: center;
  justify-content: center; font-size: .95rem; flex-shrink: 0;
}
.workload-info { flex: 1; min-width: 0; }
.workload-name { font-size: .86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workload-zone { font-size: .73rem; color: var(--sub); margin-top: .1rem; }
.workload-bar-wrap { width: 72px; flex-shrink: 0; }
.workload-track { height: 5px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-top: .3rem; }

/* Zone heatmap */
.heat-table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.heat-table th {
  text-align: center; font-size: .71rem; font-weight: 700;
  color: var(--sub); text-transform: uppercase;
  padding: .4rem .25rem; border-bottom: 2px solid var(--border); white-space: nowrap;
}
.heat-table td { text-align: center; padding: .42rem .25rem; border: 1px solid var(--border); font-weight: 600; }
.heat-table .heat-zone { text-align: left; font-weight: 600; font-size: .76rem; padding-right: .4rem; white-space: nowrap; color: var(--text); }
.heat-0  { background: #f9fafb; color: #bdbdbd; }
.heat-lo { background: #e8f5e9; color: #2e7d32; }
.heat-md { background: #fff3e0; color: #e65100; }
.heat-hi { background: #ffebee; color: #c62828; }

/* Mini appointment list */
.mini-appt-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem 0; border-bottom: 1px solid var(--border);
}
.mini-appt-row:last-child { border-bottom: none; }
.mini-appt-time { font-size: .88rem; font-weight: 800; width: 42px; flex-shrink: 0; }
.mini-appt-info { flex: 1; min-width: 0; }
.mini-appt-name { font-size: .87rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-appt-meta { font-size: .73rem; color: var(--sub); margin-top: .1rem; }
.prof-label { font-size: .72rem; color: var(--sub); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .15rem; }

/* ── Topbar ── */
.topbar-right { display: flex; align-items: center; gap: 1rem; }

/* ── Bell / Alertas ── */
.bell-wrap { position: relative; }
.bell-btn { background: none; border: none; font-size: 1.25rem; padding: .28rem .5rem; border-radius: 8px; transition: background .15s; position: relative; line-height: 1; }
.bell-btn:hover { background: var(--bg); }
.bell-badge { position: absolute; top: -3px; right: -5px; background: var(--danger); color: #fff; font-size: .62rem; font-weight: 700; border-radius: 10px; padding: .08rem .32rem; min-width: 17px; text-align: center; line-height: 1.5; }
.bell-badge.yellow { background: var(--warning); color: #333; }
.alerts-panel { position: absolute; top: calc(100% + 10px); right: 0; width: 320px; max-height: 440px; overflow-y: auto; background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); z-index: 500; }
.alerts-panel-header { display: flex; align-items: center; justify-content: space-between; padding: .7rem 1rem; border-bottom: 1px solid var(--border); font-weight: 700; font-size: .88rem; position: sticky; top: 0; background: var(--card); }
.alert-item { display: flex; gap: .55rem; align-items: flex-start; padding: .55rem 1rem; border-bottom: 1px solid var(--border); font-size: .82rem; }
.alert-item:last-child { border-bottom: none; }
.alert-item.red { background: #fef8f8; }
.alert-item.yellow { background: #fffef0; }
.alert-dot { font-size: .85rem; flex-shrink: 0; margin-top: .05rem; }
.alert-msg { color: var(--text); line-height: 1.35; }
.alert-date { font-size: .7rem; color: var(--sub); margin-top: .12rem; }

/* ── Importar CSV ── */
.import-drop-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 2rem 1.5rem; text-align: center; cursor: pointer; transition: all .2s; background: #fafbff; }
.import-drop-zone:hover, .import-drop-zone.drag-over { border-color: var(--primary); background: var(--primary-l); }

/* ── Secciones del formulario ── */
.form-section-title {
  font-size: .72rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: .55rem 0 .3rem;
  margin-top: .6rem;
  border-bottom: 2px solid var(--primary-l);
  margin-bottom: .6rem;
}
label .req { color: var(--danger); font-size: .85em; }

/* ── Botones de acción rápida (resumen) ── */
.quick-action-btn {
  flex: 1;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .45rem;
  padding: 1.1rem 1rem;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: .95rem;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
}
.quick-action-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.quick-action-icon { font-size: 1.7rem; line-height: 1; }
.quick-action-label { font-size: .88rem; }

/* ── Mobile ── */
@media (max-width: 600px) {
  .topbar-date { display: none; }
  .alerts-panel { right: -70px; width: 290px; }
  .app-content { margin-left: 0; }
  .quick-action-btn { min-width: 140px; padding: .85rem .7rem; }
}

/* ═══════════════════════════════════════════
   MEJORAS VISUALES — Design Refresh
   ═══════════════════════════════════════════ */

/* ── Variables extras ── */
:root {
  --primary-xs:  #eaf6fd; /* hover state extra ligero */
  --radius-sm:   10px;
  --radius-lg:   20px;
  --transition:  all .2s cubic-bezier(.4,0,.2,1);
}

/* ── Scrollbar elegante ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Fondo general con textura sutil ── */
body.app-page-body { background: #f1f5f9; }

/* ── Sidebar mejorado con colores de marca ── */
.sidebar { box-shadow: 2px 0 24px rgba(0,136,184,.07); }
.sidebar-logo {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
}
.sidebar-user {
  background: linear-gradient(135deg, #edf8fd 0%, #d9f2fc 100%);
  border-bottom: 1px solid rgba(0,136,184,.15);
}
.sidebar-name { color: var(--primary-d); }
.sidebar-avatar {
  box-shadow: 0 2px 8px rgba(0,136,184,.3);
  background: linear-gradient(135deg, #0088b8, #3ccece);
}
.nav-item.active {
  background: linear-gradient(135deg, #0088b8 0%, #006fa0 100%);
  box-shadow: 0 3px 10px rgba(0,136,184,.3);
}
.nav-item:hover { background: #edf8fd; color: var(--primary-d); }

/* ── Topbar mejorado ── */
.app-topbar {
  background: rgba(255,255,255,.95);
  box-shadow: 0 1px 0 rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.03);
}
.topbar-title { font-size: 1.05rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.topbar-date  { font-size: .83rem; color: var(--sub); font-weight: 500; }

/* ── Cards con profundidad mejorada ── */
.card {
  border: 1px solid rgba(0,0,0,.045);
  box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.03);
  transition: var(--transition);
}
.card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  transform: translateY(-1px);
}

/* ── Stat cards ── */
.stat-card {
  border: 1px solid rgba(0,136,184,.15);
  border-radius: var(--radius);
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-num { color: var(--primary); }

/* ── Welcome banner mejorado ── */
.welcome-banner {
  background: linear-gradient(135deg, #006fa0 0%, #0088b8 45%, #3ccece 100%);
  box-shadow: 0 8px 32px rgba(0,136,184,.22);
  border-radius: var(--radius-lg);
}
.welcome-banner::before {
  content: '';
  position: absolute;
  left: -60px; top: -60px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(255,255,255,.12) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

/* ── Citas/Appointment cards ── */
.appt-card {
  border-radius: 12px;
  background: #fff;
  transition: var(--transition);
}
.appt-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.09); }
.appt-card.green  { border-color: var(--success); background: #f0fdf4; }
.appt-card.yellow { border-color: var(--warning); background: #fffbeb; }
.appt-card.red    { border-color: var(--danger); background: #fef2f2; }

/* ── Tablas mejoradas ── */
.appt-table { border-collapse: separate; border-spacing: 0; }
.appt-table thead tr th:first-child { border-radius: 10px 0 0 0; }
.appt-table thead tr th:last-child  { border-radius: 0 10px 0 0; }
.appt-table th {
  background: linear-gradient(0deg, #f1f5f9, #f8fafc);
  color: #475569;
  font-weight: 700;
  font-size: .76rem;
  letter-spacing: .05em;
  border-bottom: 2px solid var(--border);
  padding: .75rem 1rem;
}
.appt-table tr:nth-child(even) td { background: #fafbfc; }
.appt-table tr:hover td { background: #edf8fd !important; }

/* ── RPT tablas de reportes ── */
.rpt-table { border-collapse: separate; border-spacing: 0; }
.rpt-table thead tr th:first-child { border-radius: 8px 0 0 0; }
.rpt-table thead tr th:last-child  { border-radius: 0 8px 0 0; }
.rpt-table th {
  background: var(--primary-l);
  color: var(--primary);
  border-bottom: 2px solid rgba(0,136,184,.2);
}
.rpt-table tr:nth-child(even) td { background: #fafbfc; }
.rpt-table tr:hover td { background: #edf8fd !important; }

/* ── Modales mejorados ── */
.modal {
  background: rgba(15,23,42,.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: modalFadeIn .18s ease;
}
@keyframes modalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal-box {
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,.2), 0 0 0 1px rgba(0,0,0,.04);
  animation: modalSlideUp .22s cubic-bezier(.25,.46,.45,.94);
  border: 1px solid rgba(255,255,255,.8);
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.3rem;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 800; letter-spacing: -.015em; }
.modal-header button {
  background: var(--bg); border: none; width: 28px; height: 28px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: var(--sub); cursor: pointer; transition: var(--transition);
}
.modal-header button:hover { background: #fee2e2; color: var(--danger); }

/* ── Botones mejorados ── */
.btn-primary {
  background: linear-gradient(135deg, #0088b8 0%, #006fa0 100%);
  border-radius: 10px;
  letter-spacing: .01em;
  box-shadow: 0 2px 8px rgba(0,136,184,.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #006fa0 0%, #005a85 100%);
  box-shadow: 0 4px 16px rgba(0,136,184,.4);
  transform: translateY(-1px);
}
.btn-secondary {
  border-radius: 10px;
  color: #475569;
}
.btn-secondary:hover { background: #f8fafc; border-color: #94a3b8; color: var(--text); }
.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 2px 8px rgba(239,68,68,.25);
}
.btn-danger:hover { box-shadow: 0 4px 16px rgba(239,68,68,.35); transform: translateY(-1px); }
.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 2px 8px rgba(16,185,129,.25);
}

/* ── Inputs y selects mejorados ── */
.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus,
.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,136,184,.12);
  background: #f7fcff;
}
.field-group input, .field-group select, .field-group textarea {
  border-radius: 10px;
  background: #fafbfc;
}
.filter-bar input, .filter-bar select { border-radius: 9px; }

/* ── Badges mejorados ── */
.badge { border-radius: 20px; font-weight: 700; letter-spacing: .02em; }
.badge-pending     { background: #fefce8; color: #a16207; border: 1px solid #fde68a; }
.badge-completed   { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.badge-cancelled   { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.badge-confirmed   { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-in_progress { background: #fdf4ff; color: #7e22ce; border: 1px solid #e9d5ff; }

/* ── User role badges ── */
.user-role-badge { border-radius: 20px; font-weight: 700; }

/* ── Empty states mejorados ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  gap: .6rem; padding: 3rem 1rem;
  color: var(--sub); font-size: .88rem;
}
.empty-state::before {
  content: '🔍';
  font-size: 2.2rem;
  opacity: .45;
  display: block;
}

/* ── Toast mejorado ── */
.toast {
  border-radius: 12px;
  padding: .75rem 1.4rem;
  font-size: .88rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  background: #0f172a;
  display: flex; align-items: center; gap: .5rem;
}
.toast.error { background: linear-gradient(135deg, #ef4444, #dc2626); }

/* ── Sección colapsable — header mejorado ── */
.coll-hdr {
  padding: .55rem .65rem;
  border-radius: 8px;
  transition: background .15s;
}
.coll-hdr:hover { background: var(--primary-xs); }
.coll-hdr .coll-arr {
  background: var(--border);
  transition: transform .22s, background .15s;
}
.coll-hdr:hover .coll-arr { background: var(--primary-l); }
.coll-hdr.open { background: var(--primary-xs); }

/* ── Sub-tabs estilo pill ── */
.sub-tab { border-radius: 20px; padding: .38rem 1rem; font-size: .8rem; }

/* ── Filtros ── */
.filter-toggle-btn { border-radius: 20px; }

/* ── Zona panel cards ── */
.dash-stat { border-radius: 14px; }
.dash-stat.green  { background: linear-gradient(135deg, #fff, #f0fdf4); }
.dash-stat.yellow { background: linear-gradient(135deg, #fff, #fffbeb); }
.dash-stat.red    { background: linear-gradient(135deg, #fff, #fef2f2); }
.dash-stat.blue   { background: linear-gradient(135deg, #fff, #edf8fd); }

/* ── Import drop zone mejorado ── */
.import-drop-zone {
  border-radius: 16px;
  background: #fafbff;
  transition: var(--transition);
}
.import-drop-zone:hover { border-color: var(--primary); background: var(--primary-l); transform: scale(1.005); }

/* ── Separadores de sección ── */
.section-header h3 {
  display: flex; align-items: center; gap: .5rem;
  font-size: 1.02rem; letter-spacing: -.01em;
}
.section-header h3::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(to right, var(--border), transparent);
  margin-left: .5rem;
}

/* ── Page header accent ── */
.page-header h2 {
  font-size: 1.25rem; font-weight: 800;
  letter-spacing: -.02em;
}

/* ══════════════════════════════════════════════
   REDISEÑO — Limpieza visual (2026-05)
   ══════════════════════════════════════════════ */

/* Nav sidebar: grupos de sección más sutiles, sin icono emoji */
.nav-group-hdr {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--sub);
  background: none;
  border: none;
  cursor: pointer;
}
.nav-group-hdr:hover { background: transparent; color: var(--primary-d); opacity: 1; }

/* Nav items: separación más limpia */
.nav-item { gap: .65rem; }
.nav-item .nav-label { font-size: .85rem; }

/* Sub-items de zonas: más compactos */
.nav-sub-item { padding: .28rem .7rem .28rem 1.6rem; font-size: .78rem; }
.nav-sub-icon { font-size: .75rem; color: var(--sub); }

/* Page headers: línea divisora bottom */
.page-header {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.6rem;
}

/* Cards: más espacio interior, sombra más suave */
.card {
  border-radius: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.03);
}

/* Secciones colapsables: header con línea separadora */
.coll-hdr {
  border-top: 1px solid var(--border);
  border-radius: 0;
  padding: .7rem 0;
  margin-top: .2rem;
}
.coll-hdr:hover { background: transparent; }
.coll-hdr.open  { background: transparent; }

/* Empty state: sin emoji CSS — solo texto centrado */
.empty-state::before { display: none; }
.empty-state {
  padding: 2rem 1rem;
  font-size: .85rem;
}

/* Topbar: sombra más visible */
.app-topbar {
  box-shadow: 0 1px 0 var(--border), 0 2px 8px rgba(0,0,0,.04);
}

/* Tablas de la app: más legibles */
table th { font-size: .73rem; letter-spacing: .04em; text-transform: uppercase; }
table td { font-size: .85rem; }

/* Sidebar footer logout: más limpio */
.sidebar-logout {
  display: flex; align-items: center; gap: .55rem;
  width: calc(100% - 1.4rem); margin: 0 .7rem .5rem;
  padding: .6rem 1rem; border-radius: 10px;
  background: none; border: 1px solid var(--border);
  color: var(--sub); font-size: .83rem; font-weight: 500;
  cursor: pointer; transition: all .18s;
}
.sidebar-logout:hover { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }

/* WhatsApp panel */
#wsStatusArea .btn-primary { width: auto; padding: .42rem 1.1rem; font-size: .83rem; }

@media (prefers-reduced-motion: reduce) {
  .nav-item, .nav-group-hdr, .coll-hdr { transition: none; }
}

/* ── Progress bars Kenko compliance ── */
.kenko-bar-track {
  height: 7px; border-radius: 10px;
  background: var(--border); overflow: hidden;
  margin-top: .3rem;
}
.kenko-bar-fill {
  height: 100%; border-radius: 10px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.kenko-bar-fill.ok  { background: linear-gradient(90deg, #10b981, #34d399); }
.kenko-bar-fill.mid { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.kenko-bar-fill.low { background: linear-gradient(90deg, #ef4444, #f87171); }

/* ── Skeleton loading ── */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Alertas panel mejorado ── */
.alerts-panel {
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.15);
  border: 1px solid rgba(0,0,0,.06);
}
.alerts-panel-header { border-radius: 16px 16px 0 0; background: var(--card); }
.alert-item.red    { background: #fef2f2; }
.alert-item.yellow { background: #fffbeb; }

/* ── Bell badge animado ── */
.bell-badge {
  animation: badge-pop .25s cubic-bezier(.25,.46,.45,.94);
}
@keyframes badge-pop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

/* ── Nav item badge (alertas en sidebar) ── */
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .62rem;
  font-weight: 800;
  padding: .08rem .38rem;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* ── Rpt filters area ── */
.rpt-filters { border-radius: 12px; border: 1px solid var(--border); background: #f8fafc; }
.rpt-input { border-radius: 8px; background: #fff; }

/* ── Sidebar footer logout ── */
.sidebar-logout { border-radius: 10px; font-weight: 600; transition: var(--transition); }
.sidebar-logout:hover { background: #fff1f2; color: #b91c1c; }

/* ── Perfil sección card ── */
.profile-avatar-lg {
  background: linear-gradient(135deg, var(--primary-l), #b8e8f8);
  box-shadow: 0 4px 16px rgba(0,136,184,.15);
  border: 3px solid white;
}

/* ── Form section title ── */
.form-section-title {
  background: linear-gradient(to right, var(--primary-l), transparent);
  padding-left: .5rem;
  border-radius: 4px;
}

/* ── Hover highlight en filas ── */
.patient-row, .user-row, .log-row, .mini-appt-row, .online-row, .workload-row, .zone-bar-row {
  transition: background .12s;
  border-radius: 6px;
}
.patient-row:hover, .user-row:hover, .online-row:hover { background: #edf8fd; padding-left: .3rem; }

/* ── Mobile (adicional) ── */
@media (max-width: 600px) {
  .modal-box { border-radius: 14px; margin: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dash-stats  { grid-template-columns: 1fr 1fr; }
}

/* ── Focus visible — accesibilidad teclado ── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}

/* ── Semáforo: dot de prioridad en citas ── */
.appt-card.green .appt-name  { color: #047857; }
.appt-card.red   .appt-name  { color: var(--danger); }

/* ── Tabla de citas: cabecera coherente con marca ── */
.appt-table th {
  background: var(--primary-l);
  color: var(--primary);
}

/* ── Jerarquía tipográfica reforzada ── */
.dash-stat-num { font-size: 2.2rem; letter-spacing: -.03em; }
.stat-num      { font-size: 2rem;   letter-spacing: -.02em; }

.page-header h2 { font-size: 1.4rem; font-weight: 800; letter-spacing: -.025em; }

.welcome-text h2 { font-size: 2rem; letter-spacing: -.03em; }

/* ── Iconos de stats más definidos ── */
.dash-stat-icon { width: 50px; height: 50px; border-radius: 14px; font-size: 1.5rem; }
.dash-stat.green  .dash-stat-icon { background: #dcfce7; }
.dash-stat.yellow .dash-stat-icon { background: #fef9c3; }
.dash-stat.red    .dash-stat-icon { background: #ffe4e6; }
.dash-stat.blue   .dash-stat-icon { background: #d9f2fc; }

/* ── Quick-action buttons con personalidad ── */
.dash-action-btn {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-weight: 600;
  font-size: .88rem;
  color: var(--text);
  transition: var(--transition);
}
.dash-action-btn:hover {
  background: #edf8fd;
  border-color: var(--primary);
  color: var(--primary-d);
  transform: translateX(3px);
}

/* ── Línea separadora de sección más nítida ── */
.section-header {
  padding-bottom: .6rem;
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 1.2rem;
}
.section-header h3 {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.section-header h3::after { display: none; }

/* ── Logo imagen en sidebar ── */
.sidebar-logo-img {
  width: 100%;
  max-width: 210px;
  height: auto;
  object-fit: contain;
  display: block;
}
.sidebar-logo-abbr {
  display: none;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -.02em;
}
body.sidebar-collapsed .sidebar-logo-img  { display: none; }
body.sidebar-collapsed .sidebar-logo-abbr { display: block; }

/* ── Logo en login ── */
.login-brand-card {
  background: white;
  border-radius: 16px;
  padding: 1rem 1.8rem;
  margin-bottom: 1.6rem;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
}
.login-brand-logo-img {
  max-width: 240px;
  width: 100%;
  height: auto;
  display: block;
}
.login-brand-tagline {
  font-size: 1.15rem;
  font-weight: 700;
  opacity: .95;
  margin-bottom: .4rem;
}
.login-brand-sub {
  font-size: .88rem;
  opacity: .75;
  max-width: 260px;
  text-align: center;
}
.login-logo-img {
  max-width: 220px;
  width: 100%;
  height: auto;
  margin-bottom: .5rem;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* ── Footer del sidebar con color de marca ── */
.sidebar-footer { border-top-color: var(--border); }
.sidebar-logout:hover { background: #fef0f0; color: #b91c1c; }

/* ── Nav group hover con color de marca ── */
.nav-group-hdr:hover { background: #edf8fd; color: var(--primary-d); }

/* ── Stat cards con color de marca en el icono principal ── */
.stat-card .stat-icon { color: var(--primary); }

/* ── Reducción de movimiento ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ── Semáforo subtabs: pill activo más legible ── */
.sub-tab.s-green.active { color: #065f46; }
.sub-tab.s-red.active   { color: #7f1d1d; }

/* ── Formulario: textarea altura cómoda ── */
.form-grid textarea { min-height: 80px; }

/* ── Separador sutil entre secciones ── */
.view-separator {
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0;
  border: none;
}

/* ── Animación de carga (upload EPS) ── */
.upload-progress-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  padding: 1rem 0 .5rem;
}
.upload-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--primary-l);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin-upload .7s linear infinite;
}
@keyframes spin-upload {
  to { transform: rotate(360deg); }
}
.upload-progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--primary-l);
  border-radius: 99px;
  overflow: hidden;
}
.upload-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #38bdf8);
  border-radius: 99px;
  animation: progress-indeterminate 1.4s ease-in-out infinite;
  width: 40%;
}
@keyframes progress-indeterminate {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(350%); }
}
.upload-success-check {
  width: 52px; height: 52px;
  background: #dcfce7;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  animation: pop-check .35s cubic-bezier(.175,.885,.32,1.275);
}
@keyframes pop-check {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE & TABLET
   ═══════════════════════════════════════════════════════════════ */

/* Backdrop para sidebar en mobile */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 150;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-backdrop.visible { display: block; }

/* ── Tablet (≤ 1024px) ─────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 200px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid.thirds { grid-template-columns: 1fr 1fr !important; }
  .app-topbar { padding: 0 1.25rem; }
  .app-main   { padding: 1rem 1.25rem; }
  .welcome-text h2 { font-size: 1.5rem; }
}

/* ── Mobile (≤ 768px) ─────────────────────────────────────── */
@media (max-width: 768px) {

  /* Sidebar: overlay deslizable */
  .sidebar {
    width: min(272px, 85vw) !important;
    transform: translateX(-110%);
    z-index: 200;
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: none;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .sidebar.mobile-open {
    transform: translateX(0) !important;
    box-shadow: 4px 0 32px rgba(0,0,0,.22);
  }

  /* Anular estado colapsado del sidebar en mobile */
  body.sidebar-collapsed .sidebar {
    width: min(272px, 85vw) !important;
    transform: translateX(-110%);
  }
  body.sidebar-collapsed .sidebar.mobile-open {
    transform: translateX(0) !important;
  }
  /* Restaurar etiquetas dentro del sidebar al abrirlo en mobile */
  .sidebar.mobile-open .sidebar-logo div,
  .sidebar.mobile-open .sidebar-name,
  .sidebar.mobile-open .sidebar-role,
  .sidebar.mobile-open .nav-label,
  .sidebar.mobile-open .nav-group-hdr,
  .sidebar.mobile-open .nav-group-body,
  .sidebar.mobile-open .sidebar-logout-label { display: flex !important; }
  .sidebar.mobile-open .nav-group-body { max-height: 2000px !important; overflow: visible !important; }
  .sidebar.mobile-open .nav-item { justify-content: flex-start !important; gap: .7rem !important; padding: .62rem 1.2rem !important; }
  .sidebar.mobile-open .sidebar-logout { justify-content: flex-start !important; padding: .75rem 1.2rem !important; }
  .sidebar.mobile-open .sidebar-logo { justify-content: flex-start !important; padding: 0 1.2rem !important; }
  .sidebar.mobile-open .sidebar-user { justify-content: flex-start !important; padding: .75rem 1.2rem .9rem !important; }
  .sidebar.mobile-open .sidebar-avatar { margin: 0 !important; }

  /* Contenido ocupa ancho completo */
  .app-content { margin-left: 0 !important; }
  body.sidebar-collapsed .app-content { margin-left: 0 !important; }

  /* Topbar */
  .app-topbar { padding: 0 .9rem; }
  .topbar-date { display: none; }
  #topbarKenko { display: none !important; }
  .topbar-title { font-size: .95rem; }

  /* Padding general */
  .app-main { padding: .8rem .85rem; }

  /* Welcome banner */
  .welcome-banner { padding: 1.2rem 1.4rem; margin-bottom: 1.2rem; }
  .welcome-text h2 { font-size: 1.25rem; }
  .welcome-text p  { font-size: .85rem; }
  .welcome-icon    { font-size: 2.4rem; }

  /* Stats grid → 2 columnas */
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: .7rem; margin-bottom: 1rem; }
  .stat-card  { padding: 1rem 1.1rem; }
  .stat-label { font-size: .72rem; }
  .stat-value { font-size: 1.5rem; }

  /* Grids principales → 1 columna */
  .dash-grid,
  .content-grid,
  .content-grid.thirds { grid-template-columns: 1fr !important; }

  /* Cards */
  .card { border-radius: 12px; }
  .page-header { flex-wrap: wrap; gap: .5rem; }
  .page-header h2 { font-size: 1.05rem; }

  /* Tablas → scroll horizontal */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Formularios: 16px evita el zoom automático en iOS */
  input[type="text"], input[type="password"], input[type="email"],
  input[type="tel"], input[type="date"], input[type="number"],
  input[type="search"], select, textarea, .form-input {
    font-size: 16px !important;
    min-height: 44px;
  }
  select { min-height: 44px; }

  /* Botones táctiles */
  .btn-primary, .btn-secondary, .btn-icon { min-height: 44px; font-size: .88rem; }
  .nav-item { min-height: 44px; }

  /* Modales → bottom sheet */
  .modal { align-items: flex-end !important; padding: 0 !important; }
  .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 92dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 !important;
  }

  /* Grids inline de 2 columnas → apilar en mobile */
  .two-col-mobile { grid-template-columns: 1fr !important; }

  /* Filas de paciente/usuario */
  .patient-row { flex-wrap: wrap; gap: .5rem; }
  .user-row    { flex-wrap: wrap; gap: .5rem; }

  /* Quick-action buttons */
  .quick-action-btn { min-width: unset; flex: 1; min-width: 130px; }

  /* Charts — evitar desbordamiento */
  canvas { max-width: 100% !important; }

  /* Perfil editable — inputs apilados */
  #opsProfileFirstName, #opsProfileLastName,
  #adminProfileFirstName, #adminProfileLastName { width: 100%; }

  /* Filter panel */
  .filter-panel select, .filter-panel input { width: 100%; }

  /* Sidebar-toggle más grande en mobile */
  .sidebar-toggle { padding: .5rem .6rem; font-size: 1.3rem; }

  /* Dropdown menus */
  .ddw-menu { right: 0; left: auto; min-width: 180px; }

  /* Chat */
  .chat-messages { max-height: 55dvh; }
  .chat-bubble    { max-width: 88%; }
}

/* ── Teléfonos pequeños (≤ 420px) ────────────────────────── */
@media (max-width: 420px) {
  .stats-grid   { grid-template-columns: 1fr 1fr !important; gap: .45rem; }
  .stat-card    { padding: .8rem .85rem; }
  .app-main     { padding: .6rem .6rem; }
  .welcome-banner { padding: .9rem 1rem; }
  .welcome-text h2 { font-size: 1.1rem; }
  .welcome-icon   { display: none; }
  .card           { padding: .85rem; border-radius: 10px; }
  .modal-box      { max-height: 96dvh; }
  .page-header h2 { font-size: 1rem; }
  .topbar-title   { font-size: .88rem; max-width: 55vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .btn-primary, .btn-secondary { padding: .6rem 1rem; font-size: .85rem; }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE — LOGIN (index.html)
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Colapsar a una sola columna */
  .login-page {
    grid-template-columns: 1fr;
    background: linear-gradient(160deg, #006fa0 0%, #0088b8 40%, #e0f7fa 100%);
  }
  /* Ocultar degradado izquierdo fixed */
  .login-page::before { display: none; }

  /* Panel de marca oculto en mobile */
  .login-brand { display: none; }

  /* El form ocupa toda la pantalla */
  .login-wrap {
    grid-column: 1;
    padding: 2.2rem 1.2rem 2rem;
    min-height: 100dvh;
    background: transparent;
    justify-content: flex-start;
    padding-top: max(2.5rem, env(safe-area-inset-top, 1rem));
  }

  /* Logo pequeño en mobile */
  .login-logo { margin-bottom: .8rem; }
  .login-logo-img { max-width: 160px; }

  /* Card con bordes redondeados y padding reducido */
  .login-card {
    padding: 1.6rem 1.3rem;
    border-radius: 18px;
    background: rgba(255,255,255,.97);
    width: 100%;
    max-width: 100%;
  }

  /* Inputs: 16px mínimo para evitar zoom en iOS */
  .field-group input, .field-group select {
    font-size: 16px !important;
    min-height: 48px;
    padding: .75rem 1rem;
  }

  /* Botón de acción principal grande y táctil */
  .login-card .btn-primary {
    min-height: 50px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 12px;
  }
}

@media (max-width: 420px) {
  .login-wrap { padding: 1.8rem 1rem 1.5rem; }
  .login-card { padding: 1.4rem 1.1rem; border-radius: 14px; }
  .login-logo-img { max-width: 130px; }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE — ZONA PANEL (resumen — botón volver sticky)
   ═══════════════════════════════════════════════════════════════ */

/* Botón Volver siempre visible en zone panel */
.zone-panel-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  padding: .6rem 0 .6rem;
  margin: -.5rem 0 .8rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .8rem;
  flex-wrap: wrap;
}

/* Grilla 4-col del zone panel → 2×2 en mobile */
@media (max-width: 768px) {
  .zone-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .zone-panel-header { padding-top: max(.6rem, env(safe-area-inset-top, .5rem)); }
}
