/* ============================================
   MED RANGEL v5 — Design Profissional
   Layout médico premium inspirado em
   Whitebook, UpToDate e Medscape
   ============================================ */

/* === DESIGN TOKENS === */
:root {
  /* Cores base - branco + azul marinho */
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #edf0f7;
  --border: #d0d7e5;
  --border-2: #b5bfd3;

  /* Texto - azul marinho escuro */
  --text: #0a1629;
  --text-2: #1a2e4a;
  --text-3: #4a5a75;
  --text-4: #6b7a94;

  /* Primária - AZUL MARINHO */
  --blue: #1a2e5a;
  --blue-h: #152547;
  --blue-light: #2a4a8a;
  --blue-bg: #eef1f8;
  --blue-border: #c5d0e6;
  --blue-subtle: rgba(26, 46, 90, 0.06);

  /* Severidade SOMENTE */
  --green: #047857;
  --green-bg: #e6f7ef;
  --green-border: #86e0b3;
  --green-text: #065f46;
  --green-surface: #edfcf4;

  --yellow: #b45309;
  --yellow-bg: #fef3cd;
  --yellow-border: #f5d67a;
  --yellow-text: #78350f;
  --yellow-surface: #fffbea;

  --red: #c41e1e;
  --red-bg: #fde8e8;
  --red-border: #f5a3a3;
  --red-text: #7f1d1d;
  --red-surface: #fff1f1;

  /* Accent - tudo azul marinho (sem laranja/roxo) */
  --orange: #1a2e5a;
  --orange-bg: #eef1f8;
  --orange-border: #c5d0e6;
  --purple: #1a2e5a;
  --purple-bg: #eef1f8;

  /* Layout */
  --r: 12px;
  --r-sm: 8px;
  --r-lg: 16px;
  --r-xl: 20px;
  --shadow-xs: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 2px 6px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.1), 0 2px 6px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.15);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --sidebar-w: 260px;
  --topbar-h: 56px;
  --patient-h: 64px;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === DARK MODE === */
.dark {
  --bg: #000000;
  --surface: #000000;
  --surface-2: #0a0e18;
  --surface-3: #111825;
  --border: #1e2a40;
  --border-2: #2a3a55;
  --text: #e8ecf4;
  --text-2: #c5cfe0;
  --text-3: #8a9ab5;
  --text-4: #5a6a85;
  --blue: #4a7ae0;
  --blue-h: #3a6ad0;
  --blue-bg: rgba(74, 122, 224, 0.12);
  --blue-border: rgba(74, 122, 224, 0.3);
  --blue-subtle: rgba(74, 122, 224, 0.06);
  --green: #10b981;
  --green-bg: rgba(16, 185, 129, 0.12);
  --green-border: rgba(16, 185, 129, 0.3);
  --green-text: #34d399;
  --green-surface: rgba(16, 185, 129, 0.08);
  --yellow: #f59e0b;
  --yellow-bg: rgba(245, 158, 11, 0.12);
  --yellow-border: rgba(245, 158, 11, 0.3);
  --yellow-text: #fbbf24;
  --yellow-surface: rgba(245, 158, 11, 0.08);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.12);
  --red-border: rgba(239, 68, 68, 0.3);
  --red-text: #fca5a5;
  --red-surface: rgba(239, 68, 68, 0.08);
  --orange: #4a7ae0;
  --orange-bg: rgba(74, 122, 224, 0.12);
  --orange-border: rgba(74, 122, 224, 0.3);
  --purple: #4a7ae0;
  --purple-bg: rgba(74, 122, 224, 0.12);
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 2px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
}

/* === RESET === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }
.hidden { display: none !important; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===========================
   AUTH SCREEN — Split Layout
   =========================== */
.auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Left Panel — Brand (hidden mobile, visible desktop) */
.auth-left {
  display: none;
  flex: 1;
  align-items: center;
  justify-content: center;
  background: #050a18;
  position: relative;
  border-right: 1px solid #111827;
}
.auth-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 40%, #0c1a3a 0%, #050a18 70%);
}
.auth-left-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 40px;
}
.auth-logo {
  height: 80px;
  width: auto;
  margin: 0 auto 24px;
  display: block;
}
.auth-divider {
  width: 48px;
  height: 1px;
  background: #1e293b;
  margin: 0 auto 24px;
}
.auth-tagline {
  font-size: 0.88rem;
  color: #475569;
  line-height: 1.8;
  max-width: 300px;
  margin: 0 auto 32px;
}
.auth-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
}
.auth-stat { text-align: center; }
.auth-stat-num {
  display: block;
  font-size: 1.4rem;
  font-weight: 900;
  color: #3b82f6;
  letter-spacing: -0.5px;
}
.auth-stat-label {
  display: block;
  font-size: 0.62rem;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
  font-weight: 600;
}

/* Right Panel — Form */
.auth-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #060c1a;
  padding: 40px 24px;
  min-height: 100vh;
  position: relative;
}
.auth-right::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 260px;
  background: linear-gradient(180deg, #0d1a36 0%, #060c1a 100%);
  pointer-events: none;
}
.auth-right-inner {
  width: 100%;
  max-width: 380px;
  position: relative;
  z-index: 1;
}

/* Mobile Logo + Brand */
.auth-mobile-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo-sm {
  height: 52px;
  width: auto;
  margin-bottom: 10px;
}
.auth-mobile-tagline {
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.6;
  margin-top: 8px;
}
.auth-mobile-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #111827;
}
.auth-mobile-stats .auth-stat-num {
  font-size: 1.1rem;
}
.auth-mobile-stats .auth-stat-label {
  font-size: 0.58rem;
}

/* Form Card */
.auth-form {
  background: #0a1128;
  border: 1px solid #151f38;
  border-radius: var(--r-lg);
  padding: 24px 20px;
}
.auth-form h2 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #f1f5f9;
  margin-bottom: 2px;
}
.auth-subtitle {
  font-size: 0.8rem;
  color: #64748b;
  margin-bottom: 20px;
}
.auth-field { margin-bottom: 14px; }
.auth-field label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.auth-field input {
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid #1e293b;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  color: #f1f5f9;
  background: #060c1a;
  outline: none;
  transition: all var(--transition);
}
.auth-field input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.auth-field input::placeholder { color: #3d4f63; }
.auth-pass-wrap { position: relative; }
.auth-pass-wrap input { padding-right: 44px; }
.auth-eye {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #64748b;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color var(--transition);
}
.auth-eye:hover { color: #f1f5f9; }
.auth-eye.active { color: #3b82f6; }

/* Auth Button */
.auth-btn {
  width: 100%;
  padding: 14px;
  background: #ffffff;
  color: #0a0f1a;
  border: none;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition);
  letter-spacing: -0.2px;
}
.auth-btn:hover { background: #e2e8f0; }
.auth-btn:active { transform: scale(0.98); }
.auth-btn-arrow { font-size: 1.1rem; }
.auth-btn-secondary {
  background: transparent;
  color: #94a3b8;
  border: 1.5px solid #1e293b;
}
.auth-btn-secondary:hover { background: #111d3a; color: #f1f5f9; }

.auth-switch {
  text-align: center;
  font-size: 0.82rem;
  color: #64748b;
  margin-top: 16px;
}
.auth-switch a { color: #f1f5f9; font-weight: 700; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* Paywall (dark theme) */
.paywall-info { text-align: center; margin-bottom: 24px; }
.paywall-price { margin: 20px 0; }
.price-currency { font-size: 1.1rem; font-weight: 800; color: #475569; vertical-align: top; margin-right: 2px; }
.price-value { font-size: 3.2rem; font-weight: 900; color: #3b82f6; line-height: 1; letter-spacing: -2px; }
.price-period { font-size: 0.9rem; color: #475569; font-weight: 600; }
.paywall-features { list-style: none; text-align: left; margin: 20px 0; }
.paywall-features li {
  padding: 7px 0 7px 24px;
  font-size: 0.82rem;
  color: #94a3b8;
  position: relative;
  line-height: 1.4;
}
.paywall-features li::before {
  content: '\2713';
  position: absolute;
  left: 0;
  color: #10b981;
  font-weight: 800;
  font-size: 0.9rem;
}
.pix-section { text-align: center; padding: 20px 0; border-top: 1px solid #1e293b; margin-top: 16px; }
.pix-instruction { font-size: 0.82rem; color: #94a3b8; margin-bottom: 14px; font-weight: 500; }
.pix-qr { width: 200px; height: 200px; border-radius: var(--r); border: 2px solid #1e293b; margin: 0 auto; display: block; background: #fff; padding: 8px; }
.pix-value { font-size: 0.95rem; color: #f1f5f9; margin-top: 12px; font-weight: 600; }
.pix-note { font-size: 0.72rem; color: #475569; margin-top: 8px; line-height: 1.4; }
.btn-whatsapp {
  display: block;
  width: 100%;
  padding: 12px;
  background: #25D366;
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  margin-top: 12px;
  transition: background var(--transition);
}
.btn-whatsapp:hover { background: #1da851; text-decoration: none; }
/* Paywall plans */
.paywall-plans { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.paywall-plan-btn { display: block; padding: 12px 16px; background: #0e1a32; color: #e2e8f0; border: 1.5px solid #1e293b; border-radius: var(--r-sm); font-family: var(--font); font-size: 0.88rem; font-weight: 600; text-decoration: none; text-align: center; transition: all var(--transition); cursor: pointer; }
.paywall-plan-btn:hover { background: #1a2e5a; border-color: #3b5998; color: #fff; }
.paywall-plan-btn small { font-weight: 400; opacity: 0.8; }
.paywall-plan-featured { background: #1a2e5a; border-color: #3b82f6; color: #fff; position: relative; }
.paywall-plan-featured:hover { background: #2a4a8a; border-color: #60a5fa; }
.btn-secondary {
  width: 100%;
  padding: 11px;
  background: #f8fafc;
  color: #334155;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  transition: all var(--transition);
}
.btn-secondary:hover { background: #f1f5f9; border-color: #cbd5e1; }

/* ===========================
   SIDEBAR — Premium CRM Style
   =========================== */
.sidebar {
  position: fixed;
  top: 0;
  left: -280px;
  width: var(--sidebar-w);
  height: 100vh;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border-right: 1px solid var(--border);
  z-index: 200;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.sidebar.open { left: 0; }
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.dark .sidebar {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  border-right-color: var(--border);
}
.dark .sidebar-header {
  background: transparent;
  border-bottom-color: var(--border);
}
.dark .topbar {
  background: var(--bg);
  border-bottom-color: var(--border);
}
.dark .patient-bar {
  background: var(--surface);
  border-bottom-color: var(--border);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo-img {
  max-width: 140px;
  height: auto;
}
.dark .sidebar-logo-img {
  filter: brightness(1.2);
}
.sidebar-close {
  width: 34px;
  height: 34px;
  border: none;
  background: var(--surface-2);
  color: var(--text-3);
  border-radius: var(--r-sm);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.sidebar-close:hover { background: var(--surface-3); color: var(--text); }
.sidebar-user {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-3);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 800;
  flex-shrink: 0;
  letter-spacing: -0.5px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 2px solid var(--blue-border);
  transition: all var(--transition);
}
.sidebar-user-avatar:hover { opacity: 0.85; border-color: var(--blue); }
.sidebar-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.sidebar-user-avatar-hint {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--blue);
  color: #fff;
  font-size: 0.5rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.sidebar-user-avatar:hover .sidebar-user-avatar-hint { opacity: 1; }
.sidebar-user-info {
  min-width: 0;
  flex: 1;
}
.sidebar-user strong {
  display: block;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.sidebar-footer {
  padding: 12px 12px;
  border-top: 1px solid var(--border);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: none;
  background: none;
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.84rem;
  font-weight: 500;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
  text-align: left;
  position: relative;
}
.nav-item:hover { background: var(--blue-subtle); color: var(--blue); }
.nav-item.active {
  background: transparent;
  color: var(--blue);
  font-weight: 700;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--blue);
  border-radius: 0 3px 3px 0;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.nav-item:hover svg { opacity: 1; }
.nav-item.active svg { opacity: 1; }
.nav-logout { color: var(--red); }
.nav-logout:hover { background: var(--red-bg); color: var(--red); }
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 199;
  display: none;
  transition: opacity 0.3s;
}
.sidebar-overlay.show { display: block; }

/* ===========================
   TOPBAR — Premium Bar
   =========================== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.topbar-menu {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  transition: all var(--transition);
}
.topbar-menu:hover { background: var(--surface-2); color: var(--blue); }
.topbar-menu svg { width: 20px; height: 20px; }
.topbar-brand {
  margin-left: 8px;
  flex: 1;
  display: flex;
  align-items: center;
}
.topbar-logo {
  height: 26px;
  width: auto;
}
.dark .topbar-logo {
  filter: brightness(1.2);
}
.topbar-unidade-btn {
  font-size: 0.7rem;
  font-family: var(--font);
  font-weight: 700;
  color: var(--blue);
  background: var(--blue-bg);
  border: 1px solid var(--blue-border);
  border-radius: 16px;
  padding: 5px 14px 5px 12px;
  cursor: pointer;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all var(--transition);
  display: none;
}
.topbar-unidade-btn::after {
  content: ' \25BE';
  font-size: 0.6rem;
  opacity: 0.6;
}
.topbar-unidade-btn:hover { background: var(--blue-border); color: var(--blue-h); }

/* Unit Selection Modal — Polished */
.unit-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: overlayFadeIn 0.2s ease-out;
}
@keyframes overlayFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlideIn { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
.unit-modal-overlay.hidden { display: none; }
.unit-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-xl);
  animation: modalSlideIn 0.25s ease-out;
}
.unit-modal h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}
.unit-modal p {
  font-size: 0.78rem;
  color: var(--text-3);
  margin-bottom: 20px;
}
.unit-modal-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.unit-modal-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.unit-modal-item:hover {
  border-color: var(--blue-border);
  background: var(--blue-bg);
  color: var(--blue);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.unit-modal-item::before {
  content: '\1F3E5';
  font-size: 1.1rem;
}

/* Onboarding Premium Modal */
.onboarding-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: overlayFadeIn 0.2s ease-out;
}
.onboarding-modal-overlay.hidden { display: none; }
.onboarding-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-xl);
  animation: modalSlideIn 0.25s ease-out;
}
.onboarding-modal h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}
.onboarding-modal .onboarding-modal-hint {
  font-size: 0.78rem;
  color: var(--text-3);
  margin-bottom: 20px;
  line-height: 1.5;
}
.onboarding-modal .form-group {
  margin-bottom: 16px;
}
.onboarding-modal .form-group label {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.onboarding-modal .form-group input,
.onboarding-modal .form-group textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.88rem;
  outline: none;
  transition: all var(--transition);
}
.onboarding-modal .form-group input:focus,
.onboarding-modal .form-group textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
  background: var(--surface);
}
.onboarding-modal .form-group textarea {
  min-height: 80px;
  resize: vertical;
}
.onboarding-modal .form-group .field-hint {
  font-size: 0.68rem;
  color: var(--text-4);
  margin-top: 6px;
  font-weight: 500;
}
.onboarding-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.onboarding-modal-actions .btn-modal-save {
  flex: 1;
  padding: 12px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}
.onboarding-modal-actions .btn-modal-save:hover {
  background: var(--blue-h);
  box-shadow: var(--shadow-md);
}
.onboarding-modal-actions .btn-modal-cancel {
  padding: 12px 20px;
  background: var(--surface-2);
  color: var(--text-3);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.onboarding-modal-actions .btn-modal-cancel:hover {
  background: var(--surface-3);
  color: var(--text);
}

.topbar-user {
  font-size: 0.75rem;
  color: var(--text-2);
  font-weight: 700;
  background: var(--surface-2);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.topbar-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  transition: all var(--transition);
}
.topbar-btn:hover { background: var(--surface-2); color: var(--blue); }
.topbar-btn svg { width: 18px; height: 18px; }

/* ===========================
   PATIENT BAR — Clean & Spacious
   =========================== */
.patient-bar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  z-index: 99;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.patient-inputs {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 900px;
}
.input-group { display: flex; flex-direction: column; gap: 4px; }
.input-group label {
  font-size: 0.64rem;
  font-weight: 800;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.age-group { width: 68px; flex-shrink: 0; }
.weight-group { width: 72px; flex-shrink: 0; }
.search-group { flex: 1; }
.input-with-unit { position: relative; }
.input-with-unit input { width: 100%; padding: 9px 30px 9px 12px; }
.input-with-unit .unit {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.62rem;
  color: var(--text-4);
  pointer-events: none;
  font-weight: 600;
}
.input-group input,
.input-group select,
.input-group textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.84rem;
  outline: none;
  transition: all var(--transition);
}
.input-group input::placeholder,
.input-group textarea::placeholder { color: var(--text-4); }
.search-group input {
  background: var(--surface);
  padding: 10px 14px;
  font-size: 0.86rem;
}
.search-group input:focus {
  background: var(--surface);
}
.dark .search-group input {
  background: var(--surface-3);
}
.dark .search-group input:focus {
  background: var(--surface);
}
.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.08);
}
.dark .input-group input,
.dark .input-group select,
.dark .input-group textarea {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.dark .input-group input:focus,
.dark .input-group select:focus,
.dark .input-group textarea:focus {
  border-color: var(--blue);
  background: var(--surface-3);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

/* ===========================
   MAIN CONTENT — Generous Spacing
   =========================== */
.main {
  padding-top: calc(var(--topbar-h) + var(--patient-h) + 10px);
  padding-bottom: 32px;
  min-height: 100vh;
}
.view {
  display: none;
  padding: 16px 20px;
  animation: fadeIn 0.25s ease-out;
}
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ===========================
   HOME — Premium Stats
   =========================== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 14px;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition);
  text-align: center;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.stat-number {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--blue);
  letter-spacing: -1px;
  line-height: 1;
}
.stat-label {
  font-size: 0.68rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 6px;
  font-weight: 700;
}
/* Onboarding — Premium with Progress Bar */
.onboarding-card {
  background: var(--surface);
  border: 1.5px solid var(--blue-border);
  border-radius: var(--r);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.onboarding-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.onboarding-header h3 {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--blue);
}
.onboarding-progress {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--blue);
  background: var(--blue-bg);
  padding: 3px 12px;
  border-radius: 12px;
}
.onboarding-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--surface-3);
  border-radius: 4px;
  margin-bottom: 6px;
  overflow: hidden;
}
.onboarding-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--blue-light));
  border-radius: 4px;
  transition: width 0.4s ease;
}
.onboarding-desc {
  font-size: 0.74rem;
  color: var(--text-3);
  margin-bottom: 14px;
  line-height: 1.5;
}
.onboarding-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition);
}
.onboarding-item:last-child { margin-bottom: 0; }
.onboarding-item:hover {
  background: var(--surface-2);
  border-color: var(--blue-border);
  transform: translateX(2px);
}
.onboarding-item.done {
  background: var(--green-bg);
  border-color: var(--green-border);
  opacity: 0.7;
}
.onboarding-item.done:hover { transform: none; }
.onboarding-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.72rem;
  color: transparent;
  transition: all var(--transition);
}
.onboarding-item.done .onboarding-check {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.onboarding-item-text {
  flex: 1;
}
.onboarding-item-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}
.onboarding-item.done .onboarding-item-title {
  text-decoration: line-through;
  color: var(--text-3);
}
.onboarding-item-hint {
  font-size: 0.67rem;
  color: var(--text-4);
  margin-top: 2px;
  line-height: 1.4;
}
.onboarding-item-action {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--blue);
  background: var(--blue-bg);
  border: none;
  cursor: pointer;
  padding: 5px 12px;
  border-radius: var(--r-sm);
  transition: all var(--transition);
}
.onboarding-item-action:hover { background: var(--blue-border); color: var(--blue-h); }
.onboarding-item.done .onboarding-item-action { display: none; }

.home-section-title {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.home-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Category cards — Clean with elevation */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.cat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px;
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid var(--blue);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cat-card:hover {
  border-color: var(--blue-border);
  border-left-color: var(--blue);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.cat-card:active { transform: translateY(0); }
.cat-name {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.cat-count {
  font-size: 0.7rem;
  color: var(--text-4);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ===========================
   VIEW TOP + NAV — Refined
   =========================== */
.view-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.btn-back {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: var(--surface);
  color: var(--blue);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.btn-back:hover { background: var(--blue-bg); border-color: var(--blue-border); transform: translateX(-2px); }
.view-info {
  font-size: 0.78rem;
  color: var(--text-3);
  font-weight: 700;
}
.rx-actions { display: flex; gap: 6px; }

/* ===========================
   RESULT CARDS — Clean & Minimal
   =========================== */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: none;
}
.result-card:hover {
  border-color: var(--blue-border);
  box-shadow: var(--shadow);
  transform: translateX(2px);
}
.result-card:active { transform: translateX(0); }
.sev-bar {
  width: 3px;
  height: 32px;
  border-radius: 2px;
  flex-shrink: 0;
}
.sev-bar.green { background: var(--green); }
.sev-bar.yellow { background: var(--yellow); }
.sev-bar.red { background: var(--red); }
/* Left border color by severity via adjacent sev-bar */
.result-card:has(.sev-bar.green) { border-left-color: var(--green); }
.result-card:has(.sev-bar.yellow) { border-left-color: var(--yellow); }
.result-card:has(.sev-bar.red) { border-left-color: var(--red); }
.result-info { flex: 1; min-width: 0; }
.result-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}
.result-desc {
  font-size: 0.74rem;
  color: var(--text-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 4px;
  line-height: 1.3;
}

/* ===========================
   PRESCRIPTION VIEW
   =========================== */
.rx-header-card {
  border-radius: var(--r);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}
.rx-header-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  opacity: 0.08;
  transform: translate(30%, -30%);
}
.rx-header-card.sev-green {
  background: var(--green-surface);
  border: 1.5px solid var(--green-border);
}
.rx-header-card.sev-green::after { background: var(--green); }
.rx-header-card.sev-yellow {
  background: var(--yellow-surface);
  border: 1.5px solid var(--yellow-border);
}
.rx-header-card.sev-yellow::after { background: var(--yellow); }
.rx-header-card.sev-red {
  background: var(--red-surface);
  border: 1.5px solid var(--red-border);
}
.rx-header-card.sev-red::after { background: var(--red); }

.rx-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.rx-badge.green { background: var(--green); color: #fff; }
.rx-badge.yellow { background: var(--yellow); color: #fff; }
.rx-badge.red { background: var(--red); color: #fff; }
.rx-patient-info {
  font-size: 0.7rem;
  color: var(--blue);
  font-weight: 700;
  margin: 6px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rx-title {
  font-size: 1.15rem;
  font-weight: 900;
  line-height: 1.3;
  margin-top: 6px;
  letter-spacing: -0.3px;
  color: var(--text);
}
.rx-desc {
  font-size: 0.78rem;
  color: var(--text-2);
  line-height: 1.6;
  margin-top: 6px;
}

/* Age alert */
.rx-age-alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 0.72rem;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.4;
}
.rx-age-alert.elderly {
  background: var(--yellow-bg);
  border: 1px solid var(--yellow-border);
  color: var(--yellow-text);
}
.rx-age-alert.ped {
  background: var(--blue-bg);
  border: 1px solid var(--blue-border);
  color: var(--blue);
}

/* Severity themed sections */
.sev-theme-green .rx-section-title { color: var(--green-text); }
.sev-theme-green .med-drug { color: var(--green-text); }
.sev-theme-green .med-card.primary-med { border-left-color: var(--green); background: var(--green-surface); }
.sev-theme-yellow .rx-section-title { color: var(--yellow-text); }
.sev-theme-yellow .med-drug { color: var(--yellow-text); }
.sev-theme-yellow .med-card.primary-med { border-left-color: var(--yellow); background: var(--yellow-surface); }
.sev-theme-red .rx-section-title { color: var(--red-text); }
.sev-theme-red .med-drug { color: var(--red-text); }
.sev-theme-red .med-card.primary-med { border-left-color: var(--red); background: var(--red-surface); }

/* Tabs — Clean underline style (Linear/Notion) */
.rx-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 0;
  background: transparent;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border);
}
.rx-tabs::-webkit-scrollbar { display: none; }
.rx-tab {
  padding: 10px 16px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text-4);
  font-family: var(--font);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  position: relative;
}
.rx-tab:hover { color: var(--text-2); }
.rx-tab.active {
  background: transparent;
  color: var(--blue);
  font-weight: 700;
  box-shadow: none;
}
.rx-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--blue);
  border-radius: 2px 2px 0 0;
}
.rx-tab.allergy-tab { color: var(--orange); }
.rx-tab.allergy-tab:hover { color: var(--orange); }
.rx-tab.allergy-tab.active { color: var(--orange); }
.rx-tab.allergy-tab.active::after { background: var(--orange); }
.rx-tab-content { display: none; }
.rx-tab-content.active { display: block; }

/* Sections — Refined */
.rx-section { margin-bottom: 16px; }
.rx-section-title {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}
.rx-section-title.alt { color: var(--orange); border-bottom-color: var(--orange-border); }

/* Med cards — Cleaner, more white space */
.med-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 8px;
  box-shadow: none;
  transition: all var(--transition);
}
.med-card:hover { box-shadow: var(--shadow-xs); }
.med-card.primary-med { border-left: 3px solid var(--blue); }
.med-card.alt-med { border-left: 3px solid var(--orange); background: transparent; }
.med-drug {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--blue);
  margin-bottom: 8px;
  letter-spacing: -0.2px;
}
.med-card.alt-med .med-drug { color: var(--orange); }
.med-details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 14px;
}
.med-detail {
  font-size: 0.74rem;
  color: var(--text-2);
  line-height: 1.5;
}
.med-detail strong { color: var(--text); font-weight: 700; }
.med-note {
  margin-top: 8px;
  font-size: 0.7rem;
  color: var(--text-3);
  font-style: italic;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  line-height: 1.5;
}
.med-dose-calc {
  grid-column: 1 / -1;
  padding: 5px 8px;
  background: var(--blue-bg);
  border: 1px solid var(--blue-border);
  border-radius: var(--r-sm);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--blue);
  margin-top: 4px;
}
.med-elderly-alert {
  grid-column: 1 / -1;
  padding: 5px 8px;
  background: var(--yellow-bg);
  border: 1px solid var(--yellow-border);
  border-radius: var(--r-sm);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--yellow-text);
  margin-top: 4px;
}

/* Lists */
.rx-list { list-style: none; }
.rx-list li {
  position: relative;
  padding: 4px 0 4px 14px;
  font-size: 0.76rem;
  color: var(--text-2);
  line-height: 1.45;
}
.rx-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 9px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--blue);
}
.rx-list.alarms li::before { background: var(--red); }
.rx-list.exams li::before { background: var(--purple); }
.rx-list.admit li::before { background: var(--orange); }

/* Allergy */
.allergy-selector { margin-bottom: 10px; }
.allergy-selector > label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 700;
}
.allergy-options { display: flex; flex-wrap: wrap; gap: 4px; }
.allergy-btn {
  padding: 5px 10px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-3);
  font-family: var(--font);
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}
.allergy-btn:hover { border-color: var(--orange-border); color: var(--orange); }
.allergy-btn.active { background: var(--orange); color: #fff; border-color: var(--orange); }
.allergy-meds { display: none; margin-top: 8px; }
.allergy-meds.active { display: block; }
.avoid-list {
  font-size: 0.68rem;
  color: var(--orange);
  font-weight: 700;
  margin-bottom: 8px;
  padding: 6px 10px;
  background: var(--orange-bg);
  border: 1px solid var(--orange-border);
  border-radius: var(--r-sm);
}

/* Source */
.rx-source {
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.65rem;
  color: var(--text-4);
  line-height: 1.5;
}
.rx-source strong { color: var(--text-3); }

/* CID-10 Badge */
.rx-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.rx-cid {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 800;
  background: rgba(255,255,255,0.7);
  color: var(--text-2);
  border: 1px solid var(--border);
  letter-spacing: 0.3px;
}
.dark .rx-cid {
  background: rgba(255,255,255,0.1);
  color: var(--text-2);
}

/* Anamnese / Perguntas Direcionadoras */
.anamnese-hint {
  font-size: 0.72rem;
  color: var(--text-3);
  margin-bottom: 10px;
  font-style: italic;
}
.rx-questions {
  list-style: none;
  counter-reset: q;
}
.rx-questions li {
  counter-increment: q;
  position: relative;
  padding: 10px 12px 10px 40px;
  font-size: 0.78rem;
  color: var(--text);
  line-height: 1.5;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 5px;
  transition: all var(--transition);
}
.rx-questions li:hover {
  border-color: var(--blue-border);
  background: var(--blue-bg);
}
.rx-questions li::before {
  content: counter(q);
  position: absolute;
  left: 10px;
  top: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ATB Empírico */
.atb-subtitle {
  font-size: 0.7rem;
  color: var(--text-3);
  line-height: 1.4;
  margin-bottom: 12px;
  font-style: italic;
}
.atb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: none;
  transition: all var(--transition);
}
.atb-card:hover { box-shadow: var(--shadow); }
.atb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
  flex-wrap: wrap;
  gap: 4px;
}
.atb-site {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--blue);
}
.atb-severity {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-3);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.atb-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.atb-col { min-width: 0; }
.atb-label {
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 3px;
}
.atb-value {
  font-size: 0.72rem;
  color: var(--text);
  font-weight: 600;
  line-height: 1.4;
  word-break: break-word;
}
.atb-first { color: var(--green-text); font-weight: 700; }
.atb-allergy { color: var(--orange); }
.atb-note {
  margin-top: 8px;
  font-size: 0.68rem;
  color: var(--text-3);
  font-style: italic;
  border-top: 1px dashed var(--border);
  padding-top: 6px;
  line-height: 1.4;
}

@media (min-width: 480px) {
  .atb-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Fav button */
.btn-fav.favorited svg { fill: #f59e0b; stroke: #f59e0b; }

/* ===========================
   CALCULATORS
   =========================== */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 14px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: none;
  text-align: center;
}
.calc-card:hover {
  border-color: var(--blue-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.calc-card:active { transform: translateY(0); }
.calc-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--blue-bg);
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
  border: 1.5px solid var(--blue-border);
}
.calc-card-name { font-size: 0.8rem; font-weight: 700; color: var(--text); }
.calc-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-xs);
}
.calc-section h3 {
  font-size: 0.9rem;
  font-weight: 800;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.calc-form { display: flex; flex-direction: column; gap: 10px; }
.calc-result {
  background: var(--blue-bg);
  border: 1.5px solid var(--blue-border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin-top: 10px;
}
.calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}
.calc-row:last-child { margin-bottom: 0; }
.calc-label { font-size: 0.75rem; color: var(--text-2); font-weight: 700; }
.calc-value { font-size: 0.95rem; font-weight: 900; color: var(--blue); }
.calc-value.red-val { color: var(--red) !important; }
.calc-value.yellow-val { color: var(--yellow) !important; }
.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  font-size: 0.76rem;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: color var(--transition);
}
.check-label:last-of-type { border-bottom: none; }
.check-label:hover { color: var(--text); }
.check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}

/* Vasoativas table */
.vasoactive-table { overflow-x: auto; }
.vaso-row {
  display: grid;
  grid-template-columns: 100px 1fr 1fr 52px;
  gap: 4px;
  padding: 6px 2px;
  font-size: 0.68rem;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.vaso-row:last-child { border-bottom: none; }
.vaso-header {
  font-weight: 800;
  color: var(--text);
  text-transform: uppercase;
  font-size: 0.6rem;
  letter-spacing: 0.3px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 8px 2px;
}
.vaso-drug { font-weight: 800; color: var(--blue); }

/* Pediatric table */
.ped-table { width: 100%; border-collapse: collapse; font-size: 0.68rem; }
.ped-table th {
  background: var(--blue-bg);
  color: var(--blue);
  font-weight: 800;
  padding: 7px 8px;
  text-align: left;
  border-bottom: 2px solid var(--blue-border);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.ped-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
}
.ped-table tr:hover td { background: var(--surface-2); }

/* ===========================
   ATESTADO
   =========================== */
.atestado-cfm-note {
  font-size: 0.68rem;
  color: var(--text-3);
  font-style: italic;
  margin-bottom: 12px;
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.atestado-section-title {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 16px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.atestado-section-title:first-of-type { margin-top: 0; }
.atestado-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-2);
  cursor: pointer;
  padding: 8px 0;
}
.atestado-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  margin-top: 2px;
  flex-shrink: 0;
}
.atestado-cid-section { margin-bottom: 10px; }
.atestado-cid-warning {
  font-size: 0.65rem;
  color: var(--orange);
  margin-top: 4px;
  font-weight: 600;
  line-height: 1.4;
}
.atestado-form { max-width: 560px; }
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-3);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.86rem;
  outline: none;
  transition: all var(--transition);
}
.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}
.form-group input[readonly] { background: var(--surface-2); color: var(--text-3); }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.field-hint { font-size: 0.67rem; color: var(--blue); margin-top: 4px; font-weight: 600; }
.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 14px;
  transition: all var(--transition);
  letter-spacing: -0.2px;
  box-shadow: 0 1px 3px rgba(29, 78, 216, 0.2);
}
.btn-primary:hover { background: var(--blue-h); box-shadow: 0 4px 12px rgba(29, 78, 216, 0.25); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.99) translateY(0); }
.btn-primary.btn-sm { padding: 9px; font-size: 0.82rem; }

.atestado-preview {
  margin-top: 20px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 32px 28px;
  display: none;
  font-size: 0.85rem;
  line-height: 1.7;
  color: #000;
  max-width: 210mm;
  box-shadow: var(--shadow-lg);
}
.atestado-preview.visible { display: block; }
.atestado-preview h2 {
  text-align: center;
  font-size: 1.1rem;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--blue);
  padding-bottom: 8px;
  color: #000;
  letter-spacing: 1px;
}
.atestado-preview .atestado-footer {
  border-top: 1px solid #ccc;
  padding-top: 14px;
  text-align: center;
  font-size: 0.78rem;
  color: #555;
  margin-top: 28px;
}
.btn-print {
  width: 100%;
  padding: 10px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
  transition: all var(--transition);
}
.btn-print:hover { background: #047857; }

/* ===========================
   MINHAS PRESCRICOES
   =========================== */
.btn-new-rx {
  margin-bottom: 12px;
  padding: 10px;
  font-size: 0.82rem;
}
.myrx-form { max-width: 560px; }
.myrx-section-title {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text);
  margin: 16px 0 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--border);
}
.myrx-section-hint {
  font-size: 0.68rem;
  color: var(--text-4);
  margin: -4px 0 10px;
  line-height: 1.4;
}
.myrx-title-primary { color: var(--blue) !important; border-bottom-color: var(--blue-border) !important; }
.myrx-title-alt { color: var(--orange) !important; border-bottom-color: var(--orange-border) !important; }
.myrx-med-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 10px;
  position: relative;
}
.myrx-med-item .form-row { flex-wrap: wrap; }
.myrx-med-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  background: var(--red-bg);
  color: var(--red);
  border-radius: 50%;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all var(--transition);
}
.myrx-med-remove:hover { background: var(--red); color: #fff; }
.btn-secondary {
  padding: 8px 14px;
  background: var(--surface-2);
  color: var(--blue);
  border: 1.5px solid var(--blue-border);
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-secondary:hover { background: var(--blue-bg); }
.btn-secondary.btn-sm { padding: 6px 10px; font-size: 0.72rem; }
.btn-danger {
  width: 100%;
  padding: 10px;
  background: var(--red-bg);
  color: var(--red);
  border: 1.5px solid var(--red-border);
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: all var(--transition);
}
.btn-danger:hover { background: var(--red); color: #fff; }
.myrx-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  box-shadow: none;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
}
.myrx-card:hover { box-shadow: var(--shadow); border-color: var(--blue-border); transform: translateX(2px); }
.myrx-card .sev-bar { flex-shrink: 0; }
.myrx-card-info { flex: 1; min-width: 0; }
.myrx-card-name { font-size: 0.85rem; font-weight: 700; color: var(--text); }
.myrx-card-symptom {
  font-size: 0.7rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.myrx-card-badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}
.myrx-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.myrx-card-actions button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 0.75rem;
  transition: all var(--transition);
}
.myrx-card-actions button:hover { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-border); }
.myrx-card-actions .btn-del:hover { background: var(--red-bg); color: var(--red); border-color: var(--red-border); }

/* ===========================
   MISC
   =========================== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-4);
}
.empty-state p { font-size: 0.88rem; line-height: 1.6; }
.disclaimer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
  transition: transform 0.3s;
}
.disclaimer.hidden { transform: translateY(100%); pointer-events: none; }
.disclaimer p {
  font-size: 0.68rem;
  color: var(--text-2);
  line-height: 1.4;
  margin-bottom: 6px;
}
.disclaimer strong { color: var(--red); }

/* ===========================
   TERMOS DE USO MODAL
   =========================== */
.terms-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.terms-overlay.hidden { display: none; }
.terms-modal {
  background: var(--bg);
  border-radius: 16px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.3);
  overflow: hidden;
}
.terms-header {
  padding: 24px 28px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.terms-header h2 {
  font-size: 1.25rem;
  color: var(--text-1);
  margin: 0 0 4px;
  font-weight: 700;
}
.terms-subtitle {
  font-size: 0.82rem;
  color: var(--text-3);
  margin: 0;
}
.terms-body {
  padding: 20px 28px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}
.terms-section {
  margin-bottom: 18px;
}
.terms-section h3 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 6px;
}
.terms-section p {
  font-size: 0.8rem;
  color: var(--text-2);
  line-height: 1.6;
  margin: 0 0 8px;
}
.terms-section ul {
  margin: 6px 0 0 18px;
  font-size: 0.78rem;
  color: var(--text-2);
  line-height: 1.6;
}
.terms-section li {
  margin-bottom: 4px;
}
.terms-footer {
  padding: 16px 28px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.terms-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  margin-bottom: 14px;
}
.terms-check input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--primary);
  cursor: pointer;
}
.terms-check span {
  font-size: 0.78rem;
  color: var(--text-2);
  line-height: 1.5;
}
.terms-btn {
  width: 100%;
  padding: 12px;
  font-size: 0.92rem;
  font-weight: 700;
  border-radius: 10px;
  transition: opacity 0.2s;
}
.terms-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===========================
   OFFLINE INDICATOR
   =========================== */
.offline-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  background: #f59e0b;
  color: #1a1a1a;
  text-align: center;
  padding: 6px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: transform 0.3s;
}
.offline-bar.hidden {
  transform: translateY(-100%);
  pointer-events: none;
}
.offline-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #dc2626;
  border-radius: 50%;
  margin-right: 6px;
  animation: pulse-dot 1.5s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
body.is-offline .topbar { top: 28px; }
body.is-offline .sidebar { top: 28px; }
body.is-offline .main-content { padding-top: 28px; }

/* ===========================
   DARK MODE — REFINED & COHESIVE
   =========================== */
.dark .stat-card {
  background: var(--surface);
  border-color: var(--border);
}
.dark .cat-card {
  background: var(--surface);
  border-color: var(--border);
}
.dark .result-card {
  background: var(--surface);
  border-color: var(--border);
}
.dark .med-card {
  background: var(--surface);
  border-color: var(--border);
}
.dark .med-card.alt-med {
  background: rgba(249, 115, 22, 0.06);
}
.dark .rx-tabs {
  background: transparent;
  border-color: var(--border);
}
.dark .rx-tab:hover {
  color: var(--text-2);
}
.dark .rx-header-card {
  border-color: var(--border);
}
.dark .form-group input,
.dark .form-group textarea,
.dark .form-group select {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.dark .form-group input:focus,
.dark .form-group textarea:focus {
  border-color: var(--blue);
  background: var(--surface-3);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.dark .topbar-user {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-3);
}
.dark .nav-item:hover {
  background: rgba(59, 130, 246, 0.08);
}
.dark .sidebar-user {
  background: var(--bg);
}
.dark .onboarding-card {
  border-color: rgba(59, 130, 246, 0.3);
}
.dark .onboarding-item {
  border-color: var(--border);
}
.dark .onboarding-item:hover {
  border-color: rgba(59, 130, 246, 0.3);
  background: var(--surface-2);
}
.dark .onboarding-modal {
  background: var(--surface);
  border-color: var(--border);
}
.dark .onboarding-modal .form-group input,
.dark .onboarding-modal .form-group textarea {
  background: var(--surface-2);
  border-color: var(--border);
}
.dark .onboarding-modal .form-group input:focus,
.dark .onboarding-modal .form-group textarea:focus {
  border-color: var(--blue);
  background: var(--surface-3);
}
.dark .home-section-title::after {
  background: var(--border);
}
.dark .patient-bar {
  background: var(--surface);
}
.dark .btn-primary {
  box-shadow: 0 1px 3px rgba(59, 130, 246, 0.3);
}
.dark .btn-primary:hover {
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

/* ===========================
   RESPONSIVE — TABLET
   =========================== */
@media (min-width: 480px) {
  .categories-grid,
  .calc-grid { grid-template-columns: repeat(3, 1fr); }
  .med-details { grid-template-columns: repeat(3, 1fr); }
}

/* ===========================
   RESPONSIVE — DESKTOP
   =========================== */
@media (min-width: 768px) {
  .sidebar {
    left: 0;
    box-shadow: none;
    border-right: 1px solid var(--border);
  }
  .sidebar-close { display: none; }
  .sidebar-header { justify-content: center; }
  .sidebar-overlay { display: none !important; }
  .topbar { left: var(--sidebar-w); }
  .topbar-menu { display: none; }
  .topbar-brand { display: none; }
  .patient-bar { left: var(--sidebar-w); }
  .main {
    margin-left: var(--sidebar-w);
    max-width: 100%;
    padding-left: 36px;
    padding-right: 36px;
  }
  .view {
    padding: 20px 24px;
  }
  .categories-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .calc-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .auth-screen { flex-direction: row; }
  .auth-left { display: flex; }
  .auth-mobile-logo { display: none; }
  .patient-inputs { max-width: none; }
  .stats-row { max-width: 720px; margin: 0 auto 20px; }
  .atestado-form { max-width: 680px; }
}

/* ===========================
   RESPONSIVE — WIDE DESKTOP
   =========================== */
@media (min-width: 1024px) {
  .main {
    max-width: 100%;
    padding-left: 40px;
    padding-right: 40px;
  }
  .categories-grid { grid-template-columns: repeat(4, 1fr); }
  .calc-grid { grid-template-columns: repeat(4, 1fr); }
  .med-details { grid-template-columns: repeat(4, 1fr); }
  .stats-row { max-width: 800px; }
  .atestado-form,
  .myrx-form { max-width: 720px; }
}

@media (min-width: 1280px) {
  .main {
    max-width: 100%;
    padding-left: 48px;
    padding-right: 48px;
  }
  .categories-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .stats-row { max-width: 900px; }
}

/* ===========================
   RESPONSIVE — ULTRA WIDE
   =========================== */
@media (min-width: 1600px) {
  .main {
    padding-left: 60px;
    padding-right: 60px;
  }
  .categories-grid { grid-template-columns: repeat(5, 1fr); }
  .stats-row { max-width: 1000px; }
  .calc-grid { grid-template-columns: repeat(5, 1fr); }
}

/* ===========================
   PRINT — ATESTADO A4
   =========================== */
@media print {
  @page {
    size: A4;
    margin: 20mm 15mm;
  }

  /* Esconde tudo que não é o atestado */
  .topbar, .patient-bar, .sidebar, .sidebar-overlay,
  .disclaimer, .btn-back, .rx-tabs, .rx-actions,
  .view-top, .btn-print, .btn-primary, .auth-screen,
  .stats-row, .categories-grid, .home-section-title,
  .nav-item, .sidebar-header, .sidebar-footer,
  .sidebar-user, .sidebar-nav { display: none !important; }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 12pt;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .app-wrapper { display: block !important; }
  .main { padding: 0 !important; margin: 0 !important; max-width: 100% !important; }
  .view { display: block !important; padding: 0 !important; }

  .atestado-preview {
    border: none !important;
    box-shadow: none !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    page-break-inside: avoid;
    font-size: 12pt;
    line-height: 1.8;
  }

  .atestado-preview h2 {
    font-size: 14pt;
    margin-bottom: 24pt;
    padding-bottom: 8pt;
    border-bottom: 2pt solid #000;
  }

  .atestado-preview .atestado-body {
    font-size: 12pt;
    line-height: 1.8;
    text-align: justify;
  }

  .atestado-preview .atestado-body p { margin-bottom: 12pt; }

  .atestado-preview .atestado-footer {
    margin-top: 40pt;
    padding-top: 12pt;
    font-size: 11pt;
  }

  /* Esconder views que não são atestado quando imprimindo */
  #viewHome, #viewResults, #viewPrescription,
  #viewCategory, #viewFavorites, #viewCalcList,
  #viewCalcSingle, #viewMyRx, #viewMyRxForm { display: none !important; }
  #viewAtestado { display: block !important; }
  .atestado-form > *:not(.atestado-preview) { display: none !important; }
  .atestado-preview { display: block !important; }
}
