:root {
  --bg: #e8f0f8;
  --bg2: #d4e4f0;
  --surface: #ffffff;
  --primary: #0a3d62;
  --primary-light: #1a6091;
  --accent: #00b4d8;
  --accent2: #e63946;
  --text: #1a2533;
  --muted: #6b7c93;
  --border: #c5d8eb;
  --success: #2ecc71;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(10,61,98,0.12);
  --shadow-lg: 0 8px 40px rgba(10,61,98,0.20);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'DM Sans', sans-serif; background: linear-gradient(160deg, #d2e7f4 0%, #e6f1f9 40%, #eff5fa 100%); background-attachment: fixed; color: var(--text); min-height: 100vh; scroll-behavior: smooth; }

/* ─── LOGIN ─── */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0a3d62 0%, #1a6091 50%, #00b4d8 100%);
  position: relative; overflow: hidden;
}
#login-screen::before {
  content: ''; position: absolute; width: 600px; height: 600px; border-radius: 50%;
  background: rgba(255,255,255,0.04); top: -200px; right: -150px;
}
#login-screen::after {
  content: ''; position: absolute; width: 400px; height: 400px; border-radius: 50%;
  background: rgba(255,255,255,0.06); bottom: -100px; left: -100px;
}
/* ── LOGIN (mobile-first: columnas apiladas) ── */
.login-card {
  background: white; border-radius: 24px;
  width: calc(100% - 32px); max-width: 460px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.22), 0 0 0 1px rgba(255,255,255,0.08);
  position: relative; z-index: 1;
  display: flex; flex-direction: column; overflow: hidden;
}
/* Panel izquierdo – banner compacto en móvil (solo logo centrado) */
.login-left {
  display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 0;
  padding: 22px 24px;
  background: linear-gradient(135deg, #0a3d62 0%, #0d6eaa 55%, #00b4d8 100%);
  position: relative; overflow: hidden; flex-shrink: 0;
}
.login-left::before {
  content: ''; position: absolute; width: 200px; height: 200px; border-radius: 50%;
  background: rgba(255,255,255,0.05); top: -70px; right: -40px; pointer-events: none;
}
.login-left::after {
  content: ''; position: absolute; width: 130px; height: 130px; border-radius: 50%;
  background: rgba(255,255,255,0.06); bottom: -50px; left: 10px; pointer-events: none;
}
.login-left-logo { position: relative; z-index: 1; flex-shrink: 0; }
.login-left-logo img { height: 86px; object-fit: contain; display: block;
  filter: brightness(0) invert(1); opacity: 0.95; }
/* Texto oculto en móvil — visible solo en desktop */
.login-left-text { display: none; }
.login-left-title {
  font-family: 'DM Serif Display', serif; font-size: 15px;
  color: white; line-height: 1.3; margin-bottom: 4px;
}
.login-left-sub { font-size: 11.5px; color: rgba(255,255,255,0.82); line-height: 1.55; }
.login-divider { display: none; }
/* Panel derecho – formulario */
.login-right { padding: 30px 26px 26px; display: flex; flex-direction: column; }
/* Cabecera del formulario */
.login-form-header { margin-bottom: 22px; }
.login-form-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.login-form-sub { font-size: 13px; color: var(--muted); }
/* Título portal en columna derecha (desktop) */
.login-portal-title {
  font-family: 'DM Serif Display', serif;
  font-size: 14px; font-weight: 600; color: var(--primary);
  letter-spacing: 0.3px; margin-bottom: 16px;
  padding-bottom: 12px; border-bottom: 1.5px solid #e8ecf5;
}
/* Título portal en banner móvil (oculto en desktop) */
.login-left-mobile-title {
  display: block;
  font-size: 12px; font-weight: 700; color: rgba(255,255,255,0.92);
  letter-spacing: 0.4px; position: relative; z-index: 1;
}
/* Nota pie del formulario */
.login-footer-note { text-align:center; margin-top:18px; font-size:11px;
  color:var(--muted); opacity:0.75; letter-spacing:0.2px; }

/* Desktop ≥900px: layout horizontal */
@media (min-width: 900px) {
  .login-card {
    max-width: 820px; flex-direction: row;
    border-radius: 28px; width: 100%;
  }
  .login-left {
    flex-direction: column; align-items: center; justify-content: center;
    flex: 1; padding: 52px 44px; gap: 0;
  }
  .login-left::before { width: 300px; height: 300px; top: -100px; right: -80px; }
  .login-left::after  { width: 200px; height: 200px; bottom: -60px; left: -40px; }
  .login-left-logo { margin-bottom: 22px; flex-shrink: 0; }
  .login-left-logo img { height: 156px; }
  .login-left-text { display: flex; flex-direction: column; align-items: center; text-align: center; flex: 0; position: relative; z-index: 1; }
  .login-left-mobile-title { display: none; }
  .login-portal-title { font-size: 15px; display: block; }
  .login-left-title { font-size: 22px; margin-bottom: 10px; }
  .login-left-sub { font-size: 13px; }
  .login-divider { display: block; width: 1px; background: #dde4ef; flex-shrink: 0; }
  .login-right { flex: 1; padding: 52px 48px; justify-content: center; }
  .login-form-title { font-size: 22px; }
}
    .form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.form-group input {
  width: 100%; padding: 13px 16px; border: 1.5px solid var(--border); border-radius: 10px;
  font-family: 'DM Sans', sans-serif; font-size: 14px; color: var(--text);
  background: #fafbfc; transition: border-color 0.2s, box-shadow 0.2s; outline: none;
}
.form-group input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,180,216,0.12); background: white; }
.btn-primary {
  width: 100%; padding: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white; border: none; border-radius: 10px;
  font-family: 'DM Sans', sans-serif; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; margin-top: 8px;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(10,61,98,0.30); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.error-msg {
  background: #fff0f1; border: 1px solid #ffc0c5; color: var(--accent2);
  padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-top: 14px; display: none;
}

/* ─── APP ─── */
#app-screen { display: none; min-height: 100vh; flex-direction: column; }
header {
  background: linear-gradient(135deg, #0a3d62 0%, #0f5180 60%, #1a6091 100%);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  padding: 0 32px; height: 72px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 20px rgba(10,61,98,0.3);
}
.header-logo { display: flex; align-items: center; gap: 10px; }
.header-logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.header-logo-text { font-family: 'DM Serif Display', serif; font-size: 18px; color: white; }
.header-right { display: flex; align-items: center; gap: 16px; }
.user-badge {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.15); padding: 6px 12px 6px 8px;
  border-radius: 20px; font-size: 13px; font-weight: 500; color: white;
  border: 1px solid rgba(255,255,255,0.2);
}
.user-avatar {
  width: 26px; height: 26px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: white; font-size: 11px; font-weight: 600;
}
.btn-logout {
  background: rgba(255,255,255,0.1); border: 1.5px solid rgba(255,255,255,0.25); color: white;
  padding: 7px 14px; border-radius: 8px;
  font-family: 'DM Sans', sans-serif; font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.btn-logout:hover { background: rgba(230,57,70,0.3); border-color: #e63946; color: white; }

/* ─── TABS ─── */
.tabs { background: white; border-bottom: 1px solid var(--border); padding: 0 32px; display: flex; gap: 2px; box-shadow: 0 1px 4px rgba(10,61,98,0.05); }
.tab {
  padding: 15px 22px; font-size: 13.5px; font-weight: 500; color: var(--muted);
  border: none; background: none; cursor: pointer; position: relative;
  transition: color 0.2s; font-family: 'DM Sans', sans-serif; white-space: nowrap;
}
.tab:hover { color: var(--primary-light); }
.tab.active { color: var(--primary); font-weight: 600; }
.tab.active::after {
  content: ''; position: absolute; bottom: -1px; left: 12px; right: 12px;
  height: 3px; background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px 3px 0 0;
}
.tab-panel { display: none; padding: 32px; flex: 1; }
.tab-panel.active { display: block; }

/* ─── ESTUDIOS ─── */
.page-title { font-family: 'DM Serif Display', serif; font-size: 28px; background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; margin-bottom: 4px; }
.page-sub { font-size: 14px; color: var(--muted); margin-bottom: 28px; }
.estudios-grid { display: flex; flex-direction: column; gap: 10px; }

/* ─── TARJETA DE ESTUDIO ─── */
.estudio-card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(10,61,98,0.07);
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid rgba(197,216,235,0.7);
  border-left: 4px solid var(--accent);
  display: flex; align-items: center; gap: 20px; padding: 18px 22px;
  position: relative; overflow: hidden;
}
.estudio-card::before {
  content: ''; position: absolute; top: 0; right: 0;
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0,180,216,0.04) 0%, transparent 70%);
  pointer-events: none;
}
.estudio-card:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(10,61,98,0.13); border-left-color: var(--primary); }

/* Color lateral por tipo */
.estudio-card[data-tipo="ecografia"]   { border-left-color: #00b4d8; }
.estudio-card[data-tipo="rayos_x"]     { border-left-color: #27ae60; }
.estudio-card[data-tipo="cardiologia"] { border-left-color: #e63946; }
.estudio-card[data-tipo="audiometria"] { border-left-color: #f39c12; }
.estudio-card[data-tipo="espirometria"]{ border-left-color: #8e44ad; }
.estudio-card[data-tipo="otro"]        { border-left-color: #e67e22; }

.estudio-icon { width: 56px; height: 56px; flex-shrink: 0; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 26px; }
.estudio-icon.eco   { background: linear-gradient(135deg,#e0f7ff,#b8eeff); }
.estudio-icon.rx    { background: linear-gradient(135deg,#e8f8ef,#c6f0d8); }
.estudio-icon.otro  { background: linear-gradient(135deg,#fff3e0,#fde4b0); }
.estudio-icon.cardio{ background: linear-gradient(135deg,#fde8f0,#fbc8d9); }
.estudio-icon.audio { background: linear-gradient(135deg,#fdf5e8,#fce7c0); }
.estudio-icon.espiro{ background: linear-gradient(135deg,#f0eafd,#ddd0f8); }

.estudio-body { flex: 1; min-width: 0; }

/* Tipo badge — pill con punto de color */
.estudio-tipo {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.7px;
  padding: 3px 10px 3px 7px; border-radius: 20px; margin-bottom: 6px;
}
.estudio-tipo::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  background: currentColor; opacity: 0.7;
}
.tipo-ecografia   { background: #e0f7ff; color: #007aa8; }
.tipo-rayos_x     { background: #e8f8ef; color: #1a7a45; }
.tipo-otro        { background: #fff3e0; color: #b56a00; }
.tipo-cardiologia { background: #fde8f0; color: #a0184a; }
.tipo-ekg         { background: #fde8f0; color: #a0184a; }
.tipo-mapa        { background: #ede8fd; color: #5b21b6; }
.tipo-audiometria { background: #fdf5e8; color: #92400e; }
.tipo-espirometria{ background: #f0eafd; color: #6b21a8; }

.estudio-nombre { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 4px; letter-spacing: -0.2px; }
.estudio-fecha  { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.estudio-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn-sm {
  flex: 1; min-width: 80px; padding: 9px 14px; border-radius: 10px;
  font-size: 12px; font-weight: 600; cursor: pointer; border: none;
  transition: all 0.18s; font-family: 'DM Sans', sans-serif;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.btn-sm:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-ver     { background: #f0f6fb; color: var(--primary); border: 1.5px solid #d4e8f5; }
.btn-ver:hover { background: #dce9f7; border-color: var(--primary-light); box-shadow: 0 2px 8px rgba(10,61,98,0.12); }
.btn-dl      { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: white; }
.btn-dl:hover { box-shadow: 0 4px 14px rgba(10,61,98,0.32); transform: translateY(-1px); }
.btn-informe { background: linear-gradient(135deg, #1fa355, #2ecc71); color: white; }
.btn-informe:hover { box-shadow: 0 4px 14px rgba(31,163,85,0.35); transform: translateY(-1px); }
.btn-eliminar-img { background: #fff5f5; color: #c0392b; border: 1.5px solid #ffd5d5; }
.btn-eliminar-img:hover { background: #ffe0e0; box-shadow: 0 2px 8px rgba(192,57,43,0.15); }
.btn-mini-edit { background: #f0f6fb; color: var(--primary); border: 1.5px solid #d4e8f5; border-radius: 8px; padding: 6px 14px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: 'DM Sans',sans-serif; transition: all 0.15s; }
.btn-mini-edit:hover { background: #dce9f7; border-color: var(--accent); }

.status-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px; }
.status-listo     { background: #e4f7ed; color: #14803c; }
.status-pendiente { background: #fff3e0; color: #b56a00; }
.btn-danger-full { width: 100%; padding: 11px; background: linear-gradient(135deg, #c0392b, #e74c3c); color: white; border: none; border-radius: 10px; font-family: "DM Sans", sans-serif; font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 12px; transition: all 0.15s; }
.btn-danger-full:hover { box-shadow: 0 4px 16px rgba(192,57,43,0.38); transform: translateY(-1px); }

/* ─── PROGRESS BAR ─── */
.progress-wrap { margin-top: 14px; display: none; }
.progress-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: flex; justify-content: space-between; }
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 3px; transition: width 0.3s; width: 0%; }

/* ─── EMPTY STATE ─── */
.empty-state { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty-icon { font-size: 56px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 8px; }

/* ─── ADMIN ─── */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 860px) { .admin-grid { grid-template-columns: 1fr; } }
.admin-card { background: white; border-radius: 16px; padding: 28px; box-shadow: 0 2px 12px rgba(10,61,98,0.07); border: 1px solid rgba(197,216,235,0.7); transition: box-shadow 0.2s; }
.admin-card-title {
  font-size: 16px; font-weight: 600; color: var(--primary);
  margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group-admin { margin-bottom: 16px; }
.form-group-admin label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px; }
.form-group-admin input,
.form-group-admin select {
  width: 100%; padding: 10px 13px; border: 1.5px solid var(--border); border-radius: 8px;
  font-family: 'DM Sans', sans-serif; font-size: 13px; color: var(--text);
  background: #fafbfc; outline: none; transition: border-color 0.2s;
}
.form-group-admin input:focus,
.form-group-admin select:focus { border-color: var(--accent); background: white; }
.file-drop {
  border: 2px dashed var(--border); border-radius: 10px; padding: 24px;
  text-align: center; cursor: pointer; transition: all 0.2s; position: relative;
}
.file-drop:hover { border-color: var(--accent); background: #f0fbff; }
.file-drop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-drop-icon { font-size: 28px; margin-bottom: 6px; }
.file-drop-text { font-size: 13px; color: var(--muted); }
.file-drop-text strong { color: var(--primary); }
.btn-admin {
  width: 100%; padding: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white; border: none; border-radius: 9px;
  font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; margin-top: 8px;
}
.btn-admin:hover { box-shadow: 0 4px 16px rgba(10,61,98,0.3); transform: translateY(-1px); }
.btn-admin:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.paciente-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 9px;
  margin-bottom: 8px; background: #fafbfc; transition: background 0.15s;
}
.paciente-item:hover { background: #f0f5fb; }
.paciente-info { display: flex; align-items: center; gap: 10px; }
.paciente-av {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: white; font-size: 12px; font-weight: 700;
}
.paciente-nombre { font-size: 13px; font-weight: 600; color: var(--text); }
.paciente-email  { font-size: 11px; color: var(--muted); }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5,20,40,0.88);
  display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #0d1f33; border-radius: 18px; max-width: 860px; width: 100%; max-height: 90vh;
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
}
.modal-header {
  padding: 16px 22px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.modal-title { color: white; font-size: 15px; font-weight: 600; }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: rgba(255,255,255,0.1); color: white; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center; transition: background 0.15s;
}
.modal-close:hover { background: rgba(255,255,255,0.2); }
.modal-body { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; padding: 20px; background: #060f1a; }
.modal-body img { max-width: 100%; max-height: 65vh; border-radius: 8px; }
.modal-footer { padding: 14px 22px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid rgba(255,255,255,0.08); }
.btn-modal { padding: 9px 18px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; font-family: 'DM Sans', sans-serif; display: flex; align-items: center; gap: 6px; transition: all 0.15s; }
.btn-modal-dl    { background: var(--accent); color: white; }
.btn-modal-dl:hover { background: #0096b4; }
.btn-modal-close { background: rgba(255,255,255,0.1); color: white; }
.btn-modal-close:hover { background: rgba(255,255,255,0.18); }

/* ─── TOAST ─── */
.toast {
  position: fixed; bottom: 28px; right: 28px;
  background: #0d2b44; color: white; padding: 13px 20px 13px 16px;
  border-radius: 12px; font-size: 13px; font-weight: 500;
  box-shadow: 0 8px 32px rgba(10,61,98,0.35);
  transform: translateY(100px) scale(0.95); opacity: 0;
  transition: all 0.35s cubic-bezier(0.34,1.3,0.64,1);
  z-index: 9999; max-width: 340px;
  border-left: 4px solid var(--accent);
}
.toast.show { transform: translateY(0) scale(1); opacity: 1; }
.toast.success { background: #0f3d22; border-left-color: #2ecc71; }
.toast.error   { background: #3d0f14; border-left-color: #e63946; }

.spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; margin-right: 5px; }
@keyframes spin { to { transform: rotate(360deg); } }

#paciente-resultados .pac-item {
  padding: 10px 14px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--border); transition: background 0.15s;
  display: flex; align-items: center; gap: 10px;
}
#paciente-resultados .pac-item:last-child { border-bottom: none; }
#paciente-resultados .pac-item:hover { background: #f0f5fb; }
#paciente-resultados .pac-item .pac-av {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: white; font-size: 11px; font-weight: 700; flex-shrink: 0;
}
#paciente-resultados .pac-item .pac-nombre { font-weight: 600; color: var(--text); }
#paciente-resultados .pac-item .pac-cedula { font-size: 11px; color: var(--muted); }
#paciente-resultados .pac-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }
.btn-mini { padding: 5px 10px; font-size: 11px; font-weight: 600; border-radius: 6px; cursor: pointer; border: none; font-family: 'DM Sans', sans-serif; transition: all 0.15s; }
.btn-mini-edit { background: #e8f0fb; color: var(--primary); border: 1px solid #c5d8f0; }
.btn-mini-edit:hover { background: #d0e4f7; }
.modal-edit-overlay {
  position: fixed; inset: 0; background: rgba(5,20,40,0.7);
  display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.modal-edit-overlay.open { display: flex; }
.modal-edit-box {
  background: white; border-radius: 18px; width: 100%; max-width: 480px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.2); overflow: hidden;
  display: flex; flex-direction: column; max-height: 92vh;
}
.modal-edit-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  padding: 20px 24px; display: flex; align-items: center; justify-content: space-between;
}
.modal-edit-header h3 { color: white; font-size: 16px; margin: 0; }
.modal-edit-close { background: rgba(255,255,255,0.2); border: none; color: white; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.modal-edit-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-edit-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-shrink: 0; background: white; }
.btn-save { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: white; border: none; padding: 10px 20px; border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-cancel-edit { background: var(--bg); color: var(--muted); border: 1.5px solid var(--border); padding: 10px 20px; border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 13px; cursor: pointer; }

.admin-pac-card {
  background: white; border: 1px solid rgba(197,216,235,0.7); border-radius: 14px;
  border-left: 4px solid var(--accent);
  padding: 16px 20px; display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; transition: all 0.2s; gap: 12px;
}
.admin-pac-card:hover { box-shadow: 0 6px 28px rgba(10,61,98,0.13); border-left-color: var(--primary); transform: translateY(-1px); }
.admin-pac-card .pac-info { display: flex; align-items: center; gap: 12px; }
.admin-pac-card .pac-av {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  color: white; font-size: 14px; font-weight: 700; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(10,61,98,0.2);
}
.admin-pac-card .pac-nombre { font-size: 14px; font-weight: 700; color: var(--text); }
.admin-pac-card .pac-cedula { font-size: 12px; color: var(--muted); }
.admin-pac-actions { display: flex; gap: 8px; }
.file-tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px; font-size: 12px; color: var(--text);
}

/* Gallery nav arrows */
#modal-prev, #modal-next {
  display: none;
  align-items: center; justify-content: center;
  transition: background 0.2s;
}
#modal-prev:hover, #modal-next:hover { background: rgba(0,180,216,0.6) !important; }
#modal-thumbs img:hover { opacity: 1 !important; transform: scale(1.05); }
/* Keyboard hint */

.btn-zip-estudio   { background: linear-gradient(135deg,#0a3d62,#1a6091); color:white; border:none; }
.btn-zip-estudio:hover { box-shadow: 0 4px 12px rgba(10,61,98,0.35); transform:translateY(-1px); }
.btn-share-email   { background: linear-gradient(135deg,#0077b6,#00b4d8); color:white; border:none; }
.btn-share-email:hover { box-shadow: 0 4px 12px rgba(0,119,182,0.35); transform:translateY(-1px); }
.btn-share-wa      { background: linear-gradient(135deg,#128c7e,#25d366); color:white; border:none; }
.btn-share-wa:hover { box-shadow: 0 4px 12px rgba(18,140,126,0.35); transform:translateY(-1px); }
/* Share email modal */
.share-modal-overlay {
  position:fixed; inset:0; background:rgba(5,20,40,0.75);
  display:none; align-items:center; justify-content:center; z-index:1000; padding:20px;
}
.share-modal-overlay.open { display:flex; }
.share-modal-box {
  background:white; border-radius:18px; width:100%; max-width:460px;
  box-shadow:0 24px 60px rgba(0,0,0,0.2); overflow:hidden;
}
.share-modal-header {
  background:linear-gradient(135deg,#0077b6,#00b4d8);
  padding:20px 24px; display:flex; align-items:center; justify-content:space-between;
}
.share-modal-header h3 { color:white; font-size:16px; margin:0; }
.share-modal-close { background:rgba(255,255,255,0.2); border:none; color:white; width:30px; height:30px; border-radius:8px; cursor:pointer; font-size:14px; }
.share-modal-body { padding:24px; }
.share-modal-footer { padding:14px 24px; border-top:1px solid var(--border); display:flex; gap:10px; justify-content:flex-end; }
@media (max-width: 768px) {
  .login-card { margin: 16px; max-width: 460px; flex-direction: column; border-radius: 20px; }
  .login-right { padding: 26px 22px 22px; }
  .login-left-logo img { height: 86px; }
  .login-left { padding: 18px 20px; }
  header { padding: 0 14px; height: 58px; }
  .header-logo-text { font-size: 15px; }
  .tabs { padding: 0 12px; overflow-x: auto; }
  .tab { padding: 12px 14px; font-size: 13px; white-space: nowrap; }
  .tab-panel { padding: 16px 12px; }
  .form-row { grid-template-columns: 1fr; }
  .estudios-grid { grid-template-columns: 1fr; }
  .estudio-card { padding: 12px 14px; gap: 12px; }
  .estudio-icon { width: 44px; height: 44px; font-size: 20px; }
  .estudio-nombre { font-size: 13px; }
  .estudio-actions { gap: 4px; }
  .btn-sm { padding: 7px 10px; font-size: 11px; }
  .admin-grid { grid-template-columns: 1fr; }
  .admin-card { padding: 18px 16px; }
  .page-title { font-size: 22px; }
  .modal-box { margin: 10px; border-radius: 12px; }
  .modal-edit-box { margin: 10px; max-width: 100%; }
  .login-portal-title { display: none; }
  .admin-pac-card { flex-direction: column; align-items: flex-start; gap: 10px; }
  .admin-pac-actions { width: 100%; justify-content: flex-start; }
  header .user-badge span { display: none; }
}
@media (max-width: 400px) {
  .login-card { margin: 8px; max-width: calc(100% - 16px); flex-direction: column; border-radius: 16px; }
  .login-right { padding: 22px 18px 20px; }
  .login-left { padding: 14px 16px; }
  .login-left-logo img { height: 75px; }
  .login-form-title { font-size: 18px; }
  .btn-sm { padding: 6px 8px; font-size: 10px; }
}

/* ── Skeleton loading ── */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #e8ecef 25%, #f4f6f7 50%, #e8ecef 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
}
.skeleton-card {
  background: white;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.skeleton-line { height: 12px; margin-bottom: 10px; }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 65%; }
.skeleton-line.long { width: 90%; }

/* ── FadeInUp cards ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.estudio-card { animation: fadeInUp 0.3s ease both; }

/* ── Stats bar ── */
.admin-stats-bar {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px;
}
.stat-card {
  flex: 1; min-width: 100px;
  background: white; border: 1px solid rgba(197,216,235,0.7);
  border-radius: 14px; padding: 16px 20px;
  box-shadow: 0 2px 12px rgba(10,61,98,0.07);
  text-align: center; transition: transform 0.2s, box-shadow 0.2s;
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 14px 14px 0 0;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(10,61,98,0.13); }
.stat-card .stat-num {
  font-size: 30px; font-weight: 800;
  color: var(--primary); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-card .stat-lbl {
  font-size: 11px; color: var(--muted);
  font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; margin-top: 6px;
}

/* ── Welcome card ── */
#pac-welcome-card {
  background: linear-gradient(135deg, #0a3d62 0%, #0d6eaa 60%, #00b4d8 100%);
  border-radius: 20px; padding: 26px 28px; margin-bottom: 22px;
  color: white; display: none; position: relative; overflow: hidden;
}
#pac-welcome-card::before {
  content: '';
  position: absolute; top: -60px; right: -60px;
  width: 220px; height: 220px; border-radius: 50%;
  background: rgba(255,255,255,0.06);
  pointer-events: none;
}
#pac-welcome-card::after {
  content: '';
  position: absolute; bottom: -40px; left: 30%;
  width: 160px; height: 160px; border-radius: 50%;
  background: rgba(255,255,255,0.04);
  pointer-events: none;
}
#pac-welcome-card .welcome-name {
  font-size: 21px; font-weight: 800; margin-bottom: 4px;
  font-family: 'DM Serif Display', serif; letter-spacing: -0.3px;
}
#pac-welcome-card .welcome-sub {
  font-size: 13px; opacity: 0.8; font-weight: 400;
}
#pac-welcome-card .welcome-stats {
  display: flex; gap: 0; margin-top: 18px;
  padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.2);
}
#pac-welcome-card .welcome-stat {
  flex: 1; text-align: center; position: relative;
}
#pac-welcome-card .welcome-stat + .welcome-stat::before {
  content: ''; position: absolute; left: 0; top: 10%; height: 80%;
  width: 1px; background: rgba(255,255,255,0.2);
}
#pac-welcome-card .welcome-stat .num {
  font-size: 26px; font-weight: 800; display: block;
  font-variant-numeric: tabular-nums; line-height: 1;
}
#pac-welcome-card .welcome-stat .lbl {
  font-size: 11px; opacity: 0.75; margin-top: 4px;
  text-transform: uppercase; letter-spacing: 0.5px; display: block;
}

/* -- Desktop responsive -- */
@media (min-width: 1100px) {
  .tab-panel { padding: 28px 40px; }
  .tabs { padding: 0 56px; }
  .estudios-grid { display: flex; flex-direction: column; gap: 14px; }
  .estudio-card { padding: 22px 32px; gap: 26px; border-radius: 16px; }
  .estudio-icon { width: 66px; height: 66px; font-size: 30px; border-radius: 16px; flex-shrink: 0; }
  .estudio-nombre { font-size: 16px; }
  .btn-sm { padding: 10px 16px; font-size: 13px; }
  .page-title { font-size: 34px; }
  .admin-stats-bar { gap: 18px; }
  .stat-card { padding: 20px 32px; border-radius: 16px; }
  .stat-card .stat-num { font-size: 34px; }
  .stat-card .stat-lbl { font-size: 12px; margin-top: 6px; }
  #pac-welcome-card { padding: 28px 36px; border-radius: 20px; }
  #pac-welcome-card .welcome-name { font-size: 24px; }
  #pac-welcome-card .welcome-sub { font-size: 15px; }
  #pac-welcome-card .welcome-stats { gap: 36px; margin-top: 18px; }
  #pac-welcome-card .welcome-stat .num { font-size: 28px; }
  #pac-welcome-card .welcome-stat .lbl { font-size: 13px; }
  .admin-pac-card { padding: 18px 28px; }
  .skeleton-card { padding: 28px; }
  header { padding: 0 56px; height: 74px; }
  .header-logo-text { font-size: 20px; }
}
@media (min-width: 1500px) {
  .tab-panel { padding: 32px 48px; }
  .tabs { padding: 0 48px; }
  .estudio-card { padding: 24px 36px; gap: 30px; }
  .estudio-icon { width: 72px; height: 72px; font-size: 34px; }
  .estudio-nombre { font-size: 17px; }
  .page-title { font-size: 38px; }
  .stat-card .stat-num { font-size: 38px; }
}

/* ── Mobile responsive fixes ── */
@media (max-width: 520px) {
  .estudio-actions { flex-direction: column !important; }
  .estudio-actions .btn-sm { width: 100%; justify-content: center; }
  .admin-stats-bar { gap: 8px; }
  .stat-card { padding: 10px 12px; }
  .stat-card .stat-num { font-size: 20px; }
  #pac-welcome-card { padding: 16px; }
  #pac-welcome-card .welcome-name { font-size: 17px; }
  #pac-welcome-card .welcome-stats { gap: 12px; }
}

/* ─── REPORTES ─── */
.rep-section { background:white; border-radius:16px; padding:24px 28px; border:1px solid rgba(197,216,235,0.7); box-shadow:0 2px 12px rgba(10,61,98,0.07); margin-bottom:20px; }
.rep-section-title { font-size:14px; font-weight:700; color:var(--primary); text-transform:uppercase; letter-spacing:0.5px; margin-bottom:16px; padding-bottom:12px; border-bottom:1px solid var(--border); display:flex; align-items:center; gap:8px; }
.rep-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:14px; margin-bottom:20px; }
.rep-card {
  background: linear-gradient(135deg, #f8fbff, #eef4fb);
  border: 1.5px solid rgba(197,216,235,0.8);
  border-radius: 14px; padding: 18px 20px;
  cursor: pointer; transition: all 0.2s;
  position: relative; overflow: hidden;
}
.rep-card:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(10,61,98,0.14); border-color: var(--accent); }
.rep-card.selected { border-color: var(--primary); background: linear-gradient(135deg,#e8f4ff,#d8ecfc); box-shadow: 0 4px 18px rgba(10,61,98,0.18); }
.rep-card::after { content:''; position:absolute; top:0; left:0; right:0; height:3px; border-radius:14px 14px 0 0; background:linear-gradient(90deg,var(--primary),var(--accent)); opacity:0; transition:opacity 0.2s; }
.rep-card.selected::after, .rep-card:hover::after { opacity:1; }
.rep-card-icon { font-size:28px; margin-bottom:8px; }
.rep-card-title { font-size:14px; font-weight:700; color:var(--text); margin-bottom:4px; }
.rep-card-desc { font-size:12px; color:var(--muted); line-height:1.5; }
.rep-check { position:absolute; top:12px; right:12px; width:22px; height:22px; border-radius:50%; background:var(--primary); color:white; display:none; align-items:center; justify-content:center; font-size:13px; }
.rep-card.selected .rep-check { display:flex; }
.rep-filters { display:flex; gap:12px; flex-wrap:wrap; align-items:flex-end; margin-bottom:20px; }
.rep-filter-group { display:flex; flex-direction:column; gap:6px; }
.rep-filter-group label { font-size:11px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:0.4px; }
.rep-filter-group input, .rep-filter-group select {
  padding:9px 13px; border:1.5px solid var(--border); border-radius:9px;
  font-family:'DM Sans',sans-serif; font-size:13px; color:var(--text);
  background:#fafbfc; outline:none; transition:border-color 0.2s;
}
.rep-filter-group input:focus, .rep-filter-group select:focus { border-color:var(--accent); background:white; }
.rep-btn-group { display:flex; gap:10px; flex-wrap:wrap; }
.btn-rep-excel { background:linear-gradient(135deg,#1a7a45,#27ae60); color:white; border:none; padding:11px 20px; border-radius:10px; font-family:'DM Sans',sans-serif; font-size:13px; font-weight:700; cursor:pointer; display:flex; align-items:center; gap:7px; transition:all 0.18s; }
.btn-rep-excel:hover { box-shadow:0 4px 16px rgba(27,120,60,0.38); transform:translateY(-1px); }
.btn-rep-excel:disabled { opacity:0.5; cursor:not-allowed; transform:none; }
.btn-rep-pdf   { background:linear-gradient(135deg,#c0392b,#e74c3c); color:white; border:none; padding:11px 20px; border-radius:10px; font-family:'DM Sans',sans-serif; font-size:13px; font-weight:700; cursor:pointer; display:flex; align-items:center; gap:7px; transition:all 0.18s; }
.btn-rep-pdf:hover { box-shadow:0 4px 16px rgba(192,57,43,0.38); transform:translateY(-1px); }
.btn-rep-pdf:disabled { opacity:0.5; cursor:not-allowed; transform:none; }
.btn-rep-preview { background:linear-gradient(135deg,var(--primary),var(--primary-light)); color:white; border:none; padding:11px 20px; border-radius:10px; font-family:'DM Sans',sans-serif; font-size:13px; font-weight:700; cursor:pointer; display:flex; align-items:center; gap:7px; transition:all 0.18s; }
.btn-rep-preview:hover { box-shadow:0 4px 16px rgba(10,61,98,0.38); transform:translateY(-1px); }
#rep-preview-area { display:none; margin-top:20px; }
#rep-preview-area .rep-table-wrap { overflow-x:auto; border-radius:12px; border:1px solid var(--border); box-shadow:0 2px 10px rgba(10,61,98,0.06); }
#rep-preview-area table { width:100%; border-collapse:collapse; font-size:12.5px; }
#rep-preview-area thead th { background:linear-gradient(135deg,var(--primary),var(--primary-light)); color:white; padding:11px 14px; text-align:left; font-weight:700; font-size:11px; text-transform:uppercase; letter-spacing:0.5px; white-space:nowrap; }
#rep-preview-area tbody tr { border-bottom:1px solid #edf1f7; transition:background 0.12s; }
#rep-preview-area tbody tr:hover { background:#f4f8fd; }
#rep-preview-area tbody td { padding:10px 14px; color:var(--text); vertical-align:middle; }
.rep-badge { display:inline-flex; align-items:center; padding:3px 9px; border-radius:20px; font-size:11px; font-weight:700; }
.rep-badge-green { background:#e4f7ed; color:#14803c; }
.rep-badge-orange { background:#fff3e0; color:#b56a00; }
.rep-badge-blue { background:#e0f7ff; color:#007aa8; }
.rep-badge-red { background:#fde8f0; color:#a0184a; }
.rep-badge-gray { background:#f0f0f0; color:#4a4a4a; }
.rep-count-badge { display:inline-block; background:var(--primary); color:white; border-radius:12px; padding:2px 9px; font-size:11px; font-weight:700; margin-left:8px; }
.rep-empty { text-align:center; padding:40px; color:var(--muted); font-size:13px; }
@media (max-width:768px) {
  .rep-grid { grid-template-columns:1fr 1fr; }
  .rep-filters { flex-direction:column; }
  .rep-btn-group { flex-direction:column; }
  .btn-rep-excel, .btn-rep-pdf, .btn-rep-preview { width:100%; justify-content:center; }
}
@media (max-width:520px) { .rep-grid { grid-template-columns:1fr; } }
