:root {
  --bg: #f0f4f8; --sidebar-bg: #0f1f3d; --accent: #2563eb; --accent2: #1d4ed8;
  --success: #10b981; --warning: #f59e0b; --danger: #ef4444;
  --text1: #1e293b; --text2: #475569; --text3: #94a3b8;
  --border: #e2e8f0; --white: #ffffff; --card: #ffffff;
  --radius: 14px; --shadow: 0 2px 8px rgba(0,0,0,0.07);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Outfit', sans-serif; background: var(--bg); color: var(--text1); }

/* AUTH SCREEN */
#screen-auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f1f3d 0%, #1e3a6e 50%, #0f1f3d 100%);
  padding: 20px;
}
.auth-card { background: #0f1f3d; border-radius: 20px; padding: 40px 36px; width: 100%; max-width: 460px; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.auth-logo { width: 280px; height: 95px; object-fit: contain; display: block; margin: 0 auto 16px; background: #0f1f3d; border-radius: 14px; padding: 12px 20px; }
.auth-title { text-align: center; font-size: 1.5rem; font-weight: 800; color: white; margin-bottom: 4px; }
.auth-sub { text-align: center; font-size: 0.82rem; color: rgba(255,255,255,0.6); margin-bottom: 24px; text-transform: uppercase; letter-spacing: 0.5px; }
.tab-row { display: flex; background: rgba(255,255,255,0.1); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.tab-btn { flex: 1; padding: 10px; border: none; background: transparent; border-radius: 8px; font-family: 'Outfit',sans-serif; font-weight: 600; font-size: 0.88rem; cursor: pointer; color: rgba(255,255,255,0.6); transition: all 0.2s; }
.tab-btn.active { background: rgba(255,255,255,0.15); color: white; }
.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-label { display: block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: rgba(255,255,255,0.7); margin-bottom: 6px; }
.form-input { width: 100%; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: 10px; font-family: 'Outfit',sans-serif; font-size: 0.88rem; color: var(--text1); background: #f8fafc; transition: border 0.2s; }
.form-input:focus { outline: none; border-color: var(--accent); background: white; }
select.form-input { cursor: pointer; }
.auth-card .form-input { border: 1.5px solid rgba(255,255,255,0.35); color: white; background: rgba(255,255,255,0.15); font-weight: 500; caret-color: white; }
.auth-card .form-input::placeholder { color: rgba(255,255,255,0.5); }
.auth-card .form-input:focus { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.6); outline: none; }
.auth-card select.form-input { color-scheme: dark; }
.btn-primary { width: 100%; padding: 13px; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: white; border: none; border-radius: 10px; font-family: 'Outfit',sans-serif; font-size: 0.95rem; font-weight: 700; cursor: pointer; margin-top: 8px; letter-spacing: 0.3px; }
.btn-primary:hover { opacity: 0.92; }
.msg-error { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); padding: 10px 14px; border-radius: 8px; font-size: 0.82rem; font-weight: 600; margin-top: 10px; display: none; }
.msg-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; padding: 10px 14px; border-radius: 8px; font-size: 0.82rem; font-weight: 600; margin-top: 10px; display: none; }

/* CONSENT MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1000; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.active { display: flex; }
.modal-box { background: white; border-radius: 20px; max-width: 860px; width: 96%; max-height: 92vh; overflow-y: auto; padding: 28px; }
.modal-box h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 16px; color: var(--text1); }
.consent-body { font-size: 0.83rem; line-height: 1.7; color: var(--text2); max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-bottom: 16px; }
.consent-body h4 { color: var(--text1); font-size: 0.86rem; margin: 12px 0 4px; }
.consent-check { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; font-size: 0.83rem; color: var(--text2); }
.consent-check input { margin-top: 2px; cursor: pointer; }

/* PENDING SCREEN */
#screen-pending { min-height: 100vh; display: none; align-items: center; justify-content: center; background: linear-gradient(135deg, #f0f4f8, #e2e8f0); padding: 20px; }
.pending-card { background: white; border-radius: 20px; padding: 48px 36px; text-align: center; max-width: 440px; box-shadow: var(--shadow); }
.pending-icon { font-size: 3.5rem; margin-bottom: 16px; }
.pending-card h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 10px; }
.pending-card p { color: var(--text2); font-size: 0.9rem; line-height: 1.6; margin-bottom: 20px; }
.pending-contact { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px; padding: 12px 16px; font-size: 0.83rem; color: var(--accent); font-weight: 600; }
.btn-secondary { padding: 11px 22px; background: #f1f5f9; border: 1.5px solid var(--border); color: var(--text2); border-radius: 10px; font-family: 'Outfit',sans-serif; font-weight: 600; font-size: 0.85rem; cursor: pointer; margin-top: 14px; }

/* APP SCREEN */
#screen-app { display: none; min-height: 100vh; }
.layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar { width: 260px; height: 100vh; height: 100dvh; background: var(--sidebar-bg); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; z-index: 100; transition: transform 0.3s ease; overflow: hidden; }
.sidebar-header { padding: 12px 16px 10px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.08); flex-shrink: 0; }
.sidebar-logo { width: 190px; height: 56px; object-fit: contain; display: block; margin: 0 auto 6px; }
.sidebar-brand { font-size: 0.75rem; font-weight: 800; color: white; letter-spacing: 0.5px; }
.sidebar-brand-sub { font-size: 0.65rem; color: rgba(255,255,255,0.5); margin-bottom: 6px; }
.sidebar-center { background: rgba(255,255,255,0.06); border-radius: 8px; padding: 7px 10px; margin-bottom: 2px; }
.sidebar-center-name { font-size: 0.78rem; font-weight: 700; color: white; }
.sidebar-center-sub { font-size: 0.67rem; color: rgba(255,255,255,0.5); }
.sidebar-email { display: none; }
.btn-add { display: block; width: calc(100% - 24px); margin: 8px auto 2px; padding: 9px; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: white; border: none; border-radius: 10px; font-family: 'Outfit',sans-serif; font-weight: 700; font-size: 0.82rem; cursor: pointer; text-align: center; letter-spacing: 0.3px; flex-shrink: 0; }
.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 12px; -webkit-overflow-scrolling: touch; min-height: 0; }
.nav-section-label { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: rgba(255,255,255,0.3); padding: 10px 8px 4px; }
.nav-item { padding: 7px 10px; border-radius: 8px; font-size: 0.8rem; font-weight: 500; color: rgba(255,255,255,0.65); cursor: pointer; transition: all 0.15s; margin-bottom: 1px; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-item.active { background: rgba(37,99,235,0.25); color: #93c5fd; font-weight: 700; }
.sidebar-footer { padding: 10px 14px; border-top: 1px solid rgba(255,255,255,0.08); flex-shrink: 0; margin-top: auto; }
.btn-logout { width: 100%; padding: 9px; background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; border-radius: 8px; font-family: 'Outfit',sans-serif; font-size: 0.8rem; font-weight: 600; cursor: pointer; }
.btn-logout:hover { background: rgba(239,68,68,0.25); }

/* TOPBAR MOBILE */
.topbar { display: none; position: fixed; top: 0; left: 0; right: 0; height: 52px; background: var(--sidebar-bg); z-index: 90; align-items: center; padding: 0 14px; gap: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.btn-hamburger { background: none; border: none; color: white; font-size: 1.4rem; cursor: pointer; padding: 6px; line-height: 1; min-width: 36px; }
.topbar-name { font-size: 0.85rem; font-weight: 700; color: white; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 99; display: none; }
.sidebar-overlay.active { display: block; }

/* MAIN */
.main { margin-left: 260px; padding: 24px; min-height: 100vh; padding-bottom: 60px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 1.4rem; font-weight: 800; color: var(--text1); }
.search-input { padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 10px; font-family: 'Outfit',sans-serif; font-size: 0.85rem; color: var(--text1); background: white; width: 100%; margin-bottom: 14px; }
.search-input:focus { outline: none; border-color: var(--accent); }

/* STATS */
.stats-row { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-pill { flex: 1; min-width: 90px; padding: 10px 14px; border-radius: 10px; text-align: center; font-weight: 700; font-size: 0.82rem; cursor: pointer; border: 2px solid transparent; transition: all 0.15s; }
.stat-pill.al-dia { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.stat-pill.al-dia.active { background: #15803d; color: white; }
.stat-pill.proximos { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.stat-pill.proximos.active { background: #d97706; color: white; }
.stat-pill.pendientes { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.stat-pill.pendientes.active { background: #dc2626; color: white; }

/* TABLE */
.table-wrap { background: white; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead { background: linear-gradient(135deg, #0f1f3d, #1e3a6e); }
thead th { padding: 13px 16px; text-align: left; color: white; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
tbody tr { border-bottom: 1px solid #f1f5f9; transition: background 0.1s; }
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 12px 16px; font-size: 0.84rem; vertical-align: middle; }
.pill-container { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { padding: 5px 10px; border-radius: 7px; font-size: 0.73rem; font-weight: 600; cursor: pointer; line-height: 1.3; }
.pill-pendiente { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.pill-urgente { background: #dc2626; color: #ffffff; border: 1px solid #b91c1c; font-weight: 700; }
.pill-proximo { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.pill-al-dia { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.pill-cumplido { background: #f0faf4; color: #1e6b3a; border: 1px solid #a8ddb8; }
.pill-perdido { background: #fdf2f2; color: #c0392b; border: 1px solid #f5c6c6; }
.historial-container { max-height: 400px; overflow-y: auto; padding: 16px; border: 1.5px solid var(--border); border-radius: 0 0 10px 10px; }

/* FILTERS */
#filtros-container { display: none; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: 6px; margin-bottom: 16px; }
.filter-btn { padding: 8px; text-align: center; background: white; border: 1.5px solid var(--border); border-radius: 8px; font-size: 0.75rem; font-weight: 600; color: var(--text2); cursor: pointer; }
.filter-btn.active { border-color: var(--accent); color: var(--accent); background: #eff6ff; }

/* CARDS */
.section-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 16px; }
.section-card h3 { font-size: 1rem; font-weight: 800; margin-bottom: 14px; color: var(--text1); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 12px; }
.stat-card { background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; padding: 16px; text-align: center; }
.stat-card h3 { font-size: 1.8rem; font-weight: 800; margin-bottom: 4px; }
.stat-card p { font-size: 0.75rem; color: var(--text2); font-weight: 500; }

/* BADGES */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; }
.badge-active { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.badge-pending { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.badge-blocked { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ADMIN */
.admin-card { background: white; border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; margin-bottom: 10px; display: flex; align-items: flex-start; gap: 14px; }
.admin-card-info { flex: 1; }
.admin-card-info h4 { font-size: 0.9rem; font-weight: 700; margin-bottom: 3px; }
.admin-card-info p { font-size: 0.78rem; color: var(--text2); }
.admin-card-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.btn-sm { padding: 6px 12px; border-radius: 7px; font-family: 'Outfit',sans-serif; font-size: 0.75rem; font-weight: 600; cursor: pointer; border: 1.5px solid var(--border); background: #f8fafc; color: var(--text2); }
.btn-approve { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.btn-block { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.btn-extend { background: #eff6ff; color: var(--accent); border-color: #bfdbfe; }

/* MODAL PATIENT */
.modal-patient { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-patient.active { display: flex; }
.modal-content { background: white; border-radius: 16px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 20px 24px 0; }
.modal-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 0; }
.modal-tab { padding: 10px 20px; font-family: 'Outfit',sans-serif; font-size: 0.85rem; font-weight: 600; border: none; background: none; cursor: pointer; color: var(--text2); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.modal-body { padding: 20px 24px; }
.field-group { margin-bottom: 14px; }
.field-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text2); display: block; margin-bottom: 5px; }
.field-input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 9px; font-family: 'Outfit',sans-serif; font-size: 0.87rem; color: var(--text1); }
.field-input:focus { outline: none; border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-save { width: 100%; padding: 12px; background: linear-gradient(135deg,var(--accent),var(--accent2)); color: white; border: none; border-radius: 10px; font-family: 'Outfit',sans-serif; font-weight: 700; font-size: 0.9rem; cursor: pointer; margin-bottom: 8px; }
.btn-delete { width: 100%; padding: 11px; background: #fef2f2; color: var(--danger); border: 1.5px solid #fecaca; border-radius: 10px; font-family: 'Outfit',sans-serif; font-weight: 700; font-size: 0.85rem; cursor: pointer; }
.btn-close-modal { width: 100%; padding: 10px; background: #f1f5f9; border: 1.5px solid var(--border); color: var(--text2); border-radius: 10px; font-family: 'Outfit',sans-serif; font-weight: 600; font-size: 0.85rem; cursor: pointer; margin-top: 6px; }
.hito-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.hito-label { font-size: 0.84rem; font-weight: 600; }
.hito-status { font-size: 0.75rem; color: var(--text3); }
.btn-hito { padding: 6px 14px; border-radius: 7px; font-family: 'Outfit',sans-serif; font-size: 0.75rem; font-weight: 700; cursor: pointer; }
.btn-hito-ok { background: #f0fdf4; color: #15803d; border: 1.5px solid #bbf7d0; }
.btn-hito-del { background: #fef2f2; color: var(--danger); border: 1.5px solid #fecaca; }

/* REPORTES */
.card-reporte { background: white; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 12px; padding: 16px 20px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.card-reporte h3 { font-size: 0.9rem; font-weight: 700; margin-bottom: 2px; }
.card-reporte small { color: var(--text2); font-size: 0.76rem; }
.btn-eais { padding: 9px 16px; background: linear-gradient(135deg,var(--accent),var(--accent2)); color: white; border: none; border-radius: 9px; font-family: 'Outfit',sans-serif; font-size: 0.78rem; font-weight: 700; cursor: pointer; white-space: nowrap; }

/* IMPORTAR */
.drop-zone { border: 2px dashed var(--border); border-radius: 12px; padding: 40px 20px; text-align: center; cursor: pointer; transition: all 0.2s; background: #f8fafc; margin-bottom: 16px; }
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); background: #eff6ff; }
.drop-zone-icon { font-size: 2.5rem; margin-bottom: 10px; }
.drop-zone h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 6px; }
.drop-zone p { font-size: 0.8rem; color: var(--text2); }
#file-input { display: none; }
.preview-table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); margin-bottom: 14px; max-height: 300px; overflow-y: auto; }
.preview-table-wrap table thead { position: sticky; top: 0; }
.btn-import { padding: 11px 24px; background: linear-gradient(135deg,var(--success),#059669); color: white; border: none; border-radius: 10px; font-family: 'Outfit',sans-serif; font-weight: 700; font-size: 0.88rem; cursor: pointer; }
.btn-cancel { padding: 11px 24px; background: #f1f5f9; border: 1.5px solid var(--border); color: var(--text2); border-radius: 10px; font-family: 'Outfit',sans-serif; font-weight: 600; font-size: 0.85rem; cursor: pointer; }
.btn-pdf { padding: 9px 18px; background: linear-gradient(135deg,#dc2626,#b91c1c); color: white; border: none; border-radius: 9px; font-family: 'Outfit',sans-serif; font-weight: 700; font-size: 0.82rem; cursor: pointer; display: none; }

/* EXTEND MODAL */
.modal-extend { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 300; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-extend.active { display: flex; }
.modal-extend-box { background: white; border-radius: 16px; padding: 28px; max-width: 400px; width: 100%; }
.modal-extend-box h3 { font-size: 1rem; font-weight: 800; margin-bottom: 16px; }
.dias-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.btn-dias { padding: 8px 14px; border: 1.5px solid var(--border); border-radius: 8px; background: #f8fafc; font-family: 'Outfit',sans-serif; font-size: 0.8rem; font-weight: 600; color: var(--text2); cursor: pointer; }
.btn-dias.active { border-color: var(--accent); color: var(--accent); background: #eff6ff; }

/* FOOTER */
#app-footer { position: fixed; bottom: 0; left: 260px; right: 0; background: rgba(15,31,61,0.97); backdrop-filter: blur(8px); border-top: 1px solid rgba(255,255,255,0.07); padding: 7px 24px; display: flex; justify-content: space-between; align-items: center; z-index: 50; }
#app-footer span { font-size: 0.67rem; color: rgba(255,255,255,0.4); }
#app-footer a { color: rgba(255,255,255,0.5); text-decoration: none; font-weight: 600; }

/* TOUR */
#tour-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 9000; display: none; }
#tour-highlight { position: fixed; z-index: 9001; border: 3px solid #3b82f6; border-radius: 12px; box-shadow: 0 0 0 4000px rgba(0,0,0,0.65); pointer-events: none; display: none; transition: all 0.3s ease; }
#tour-box { position: fixed; z-index: 9002; background: white; border-radius: 18px; padding: 30px 32px; width: 400px; max-width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,0.35); display: none; }
#tour-box h3 { font-size: 1.15rem; font-weight: 800; margin-bottom: 12px; color: #1e293b; line-height: 1.3; }
#tour-box p { font-size: 0.9rem; color: #475569; line-height: 1.7; margin-bottom: 22px; }
#tour-progress { display: flex; gap: 6px; margin-bottom: 10px; }
#tour-step-num { font-size: 0.72rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.tour-btns { display: flex; gap: 10px; justify-content: flex-end; }
.tour-btn-skip { padding: 10px 18px; background: none; border: 1.5px solid #e2e8f0; color: #94a3b8; border-radius: 10px; font-family: 'Outfit',sans-serif; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.tour-btn-next { padding: 10px 24px; background: var(--accent); color: white; border: none; border-radius: 10px; font-family: 'Outfit',sans-serif; font-size: 0.9rem; font-weight: 700; cursor: pointer; }
.tour-btn-next:hover { background: #1d4ed8; }

/* MOBILE */
@media (max-width: 700px) {
  .sidebar { transform: translateX(-260px); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.3); }
  .topbar { display: flex; }
  .main { margin-left: 0; padding: 62px 12px 70px; }
  #app-footer { left: 0; padding: 6px 14px; }
  #app-footer span:first-child { font-size: 0.6rem; }
  .form-row { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .admin-card { flex-direction: column; }
  #screen-app .page-header { flex-direction: column; align-items: flex-start; }
  table { font-size: 0.8rem; }
  thead th { padding: 10px 10px; font-size: 0.68rem; }
  tbody td { padding: 10px 10px; }
  .pill { font-size: 0.7rem; min-width: 0; }
  .stats-row { gap: 6px; }
  .stat-pill { font-size: 0.75rem; padding: 8px 10px; min-width: 70px; }
  .modal-content { margin: 0; border-radius: 16px 16px 0 0; position: fixed; bottom: 0; left: 0; right: 0; max-width: 100%; max-height: 90vh; overflow-y: auto; }
  .modal-patient { align-items: flex-end; }
  .card-reporte { flex-direction: column; align-items: flex-start; gap: 10px; }
  .btn-eais { width: 100%; text-align: center; }
  .admin-card-actions { justify-content: flex-start; }
  .page-title { font-size: 1.1rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .auth-card { padding: 28px 20px; }
}

/* TABLET */
@media (min-width: 701px) and (max-width: 1024px) {
  .sidebar { width: 220px; }
  .main { margin-left: 220px; padding: 20px 16px 60px; }
  #app-footer { left: 220px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .admin-card { flex-direction: column; }
  .card-reporte { flex-direction: column; gap: 10px; }
}

@media (min-width: 701px) {
  .topbar { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════
   AtlasMed — Píldoras de severidad (PASO 1 v1.0)
   Agregar AL FINAL de css/styles.css
   ─────────────────────────────────────────────────────────── */

/* Píldora VENCIDA (rango actual ya pasó r.max) o ARRASTRE del rango anterior — rojo MUY intenso */
.pill.pill-vencida {
    background: linear-gradient(135deg, #7f1d1d, #991b1b);
    color: #ffffff;
    border: 1.5px solid #7f1d1d;
    box-shadow: 0 2px 8px rgba(127, 29, 29, 0.35);
    font-weight: 800;
}
.pill.pill-vencida small {
    color: #fecaca;
    font-weight: 700;
}
.pill.pill-vencida:hover {
    background: linear-gradient(135deg, #991b1b, #b91c1c);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(127, 29, 29, 0.5);
}

/* Píldora CRÍTICA (0-15 días para vencer en rango actual) — rojo intenso */
.pill.pill-critica {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    color: #ffffff;
    border: 1.5px solid #dc2626;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3);
    font-weight: 700;
}
.pill.pill-critica small {
    color: #fee2e2;
    font-weight: 600;
}
.pill.pill-critica:hover {
    background: linear-gradient(135deg, #ef4444, #f87171);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.45);
}

/* ═══════════════════════════════════════════════════════════
   AtlasMed — Píldora ABIERTA (disponible, sin urgencia)
   Agregar AL FINAL de css/styles.css
   ─────────────────────────────────────────────────────────── */
 
/* Píldora ABIERTA (prestación disponible, faltan >30d para vencer) — azul/verde suave */
.pill.pill-abierta {
    background: linear-gradient(135deg, #ecfdf5, #f0fdfa);
    color: #065f46;
    border: 1.5px solid #a7f3d0;
    box-shadow: 0 1px 3px rgba(5, 150, 105, 0.08);
    font-weight: 700;
}
.pill.pill-abierta small {
    color: #047857;
    font-weight: 600;
}
.pill.pill-abierta:hover {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.18);
}