/* ── MAVI – Meu Assistente Virtual – Styles ── */

:root {
  --bg: #F0F4FF;
  --bg-card: #FFFFFF;
  --text: #1a1a2e;
  --text-muted: #8E99A4;
  --border: #E2E8F0;
  --primary: #2563EB;
  --primary-hover: #1d4ed8;
  --primary-light: #93c5fd;
  --danger: #EF4444;
  --warning: #F59E0B;
  --success: #10b981;
  --nav-bg: #FFFFFF;
  --nav-active: #2563EB;
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  height: 100%;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
}

body {
  font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
  min-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: var(--safe-top);
  padding-bottom: calc(56px + var(--safe-bottom));
}

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

/* ── Navbar ── */
.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  padding-top: calc(0.75rem + var(--safe-top));
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.nav-brand a { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.nav-links { display: flex; gap: 1rem; align-items: center; }
/* Gear icon in header (mobile) */
.nav-actions { display: none; align-items: center; gap: 0.5rem; }
.nav-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.nav-icon-btn:hover { background: var(--bg); color: var(--text); text-decoration: none; }

/* ── Container ── */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

/* ── Buttons ── */
.btn, .btn-sm {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.15s;
  min-height: 44px;
  min-width: 44px;
}
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; min-height: 36px; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; }
.btn-outline:hover { background: var(--bg); }
.btn-full { width: 100%; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.25rem; font-weight: 600; font-size: 0.875rem; }
input[type="text"], input[type="password"], input[type="email"], select, textarea {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px; /* prevents iOS zoom */
  width: 100%;
  min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.input-full { flex: 1; }
.input-search { min-width: 200px; }
.form-row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.inline-form { display: flex; gap: 0.5rem; align-items: center; }
.select-status { width: auto; min-width: 140px; }

/* ── Alerts ── */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.alert-error { background: #f8d7da; color: #842029; border: 1px solid #f5c2c7; }

/* ── Login ── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding-bottom: 0; }
.login-card {
  background: var(--bg-card);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 400px;
  margin: 1rem;
}
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.brand-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 1rem;
  background: linear-gradient(135deg, #2563EB, #1d4ed8);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: 2px;
}
.login-card h1 { font-size: 1.25rem; margin-bottom: 0.25rem; }
.subtitle { color: var(--text-muted); margin-bottom: 1.5rem; }
.legal-notice { color: var(--text-muted); font-size: 0.75rem; margin-top: 1.5rem; text-align: center; }

/* ── Inbox: Greeting header ── */
.inbox-greeting {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}
.greeting-text {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}
.greeting-doctor {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.doctor-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563EB, #1d4ed8);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}
.greeting-actions {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}
.greeting-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.greeting-icon-btn:hover { background: var(--border); color: var(--text); text-decoration: none; }

/* ── Inbox: Search ── */
.inbox-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.search-wrapper {
  flex: 1;
  position: relative;
}
.search-wrapper .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-wrapper input {
  width: 100%;
  padding: 0.6rem 0.75rem 0.6rem 2.5rem;
  border: 1px solid var(--border);
  border-radius: 24px;
  font-size: 0.9rem;
  background: var(--bg-card);
  min-height: 44px;
}
.search-wrapper input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.search-clear {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  text-decoration: none;
  flex-shrink: 0;
}
.search-clear:hover { background: #ccc; text-decoration: none; }

/* ── Inbox: Section header ── */
.inbox-section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
}
.section-title { font-weight: 700; font-size: 1.1rem; }
.section-link { font-size: 0.85rem; color: var(--primary); }

/* ── Inbox: Pill tabs ── */
.inbox-pills {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  overflow-x: auto;
}
.inbox-pill {
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all 0.15s;
}
.inbox-pill:hover { text-decoration: none; border-color: var(--primary); color: var(--primary); }
.inbox-pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ── Inbox: Cards ── */
.inbox-cards { display: flex; flex-direction: column; gap: 0.5rem; }
.inbox-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: opacity 0.3s, transform 0.3s;
}
.inbox-card-urgent { border-left: 4px solid #ef4444; }
.inbox-card-link {
  display: flex;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  text-decoration: none;
  color: var(--text);
  align-items: flex-start;
}
.inbox-card-link:hover { text-decoration: none; background: var(--bg); }
.inbox-card-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.35rem;
}
.inbox-card-body { flex: 1; min-width: 0; }
.inbox-card-row1 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}
.inbox-card-patient {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inbox-card-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.inbox-card-row2 { margin-bottom: 0.2rem; }
.inbox-card-cat {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
}
.inbox-card-title {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inbox-card-actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
  padding: 0 1rem 0.65rem;
}
.inbox-action-btn {
  padding: 0.3rem 0.85rem;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s;
}
.inbox-action-resolve {
  background: var(--primary);
  color: white;
}
.inbox-action-resolve:hover { background: var(--primary-hover); }
.inbox-action-reopen {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.inbox-action-exam {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}
.inbox-action-exam:hover { background: #dbeafe; text-decoration: none; }

/* Legacy stats/filters (kept for backward compat) */
.stats-bar { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.stat {
  background: var(--bg-card);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  min-width: 80px;
}
.stat-number { display: block; font-size: 1.25rem; font-weight: 700; }
.stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }
.stat-alert { border: 2px solid var(--danger); }
.stat-alert .stat-number { color: var(--danger); }
.filters-bar {
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
  padding: 1rem; background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 1rem;
}
.filters-bar select { width: auto; min-width: 120px; }

/* ── Table ── */
.table { width: 100%; border-collapse: collapse; background: var(--bg-card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th { background: var(--bg); padding: 0.75rem; text-align: left; font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); border-bottom: 2px solid var(--border); }
.table td { padding: 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:hover { background: var(--bg); }

/* ── Task row states ── */
.sla-breach { background: #fff3cd !important; }
.sla-breach:hover { background: #ffe69c !important; }
.task-row { border-left: 4px solid transparent; }
.task-row.cat-EXAME { border-left-color: #3b82f6; }
.task-row.cat-RELATORIO { border-left-color: #8b5cf6; }
.task-row.cat-CONSULTA { border-left-color: #22c55e; }
.task-row.cat-OUTROS { border-left-color: #9ca3af; }
.task-row.cat-DUVIDA { border-left-color: #ef4444; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-ALTA { background: #FDE8E7; color: #F61A0A; }
.badge-MEDIA { background: #FFF7D6; color: #997500; }
.badge-BAIXA { background: #DCFCE7; color: #166534; }
/* Category color coding */
.badge-cat { background: #EEEDF5; color: #191B47; }
.badge-cat-EXAME { background: #DBEAFE; color: #2563EB; }
.badge-cat-RELATORIO { background: #E0E7FF; color: #4338ca; }
.badge-cat-CONSULTA { background: #DCFCE7; color: #166534; }
.badge-cat-OUTROS { background: #F3F2F8; color: #A0A0A0; }
.badge-cat-DUVIDA { background: #FDE8E7; color: #F61A0A; }
.badge-status-PENDENTE { background: #fff3cd; color: #664d03; }
.badge-status-EM_ANALISE { background: #cff4fc; color: #055160; }
.badge-status-AGUARDANDO_PACIENTE { background: #e2d9f3; color: #432874; }
.badge-status-RESPONDIDO { background: #d1e7dd; color: #0f5132; }
.badge-status-RESOLVIDO { background: #d3d3d4; color: #41464b; }

/* Mode badges */
.mode-badge-bot { background: #d1e7dd; color: #0f5132; }
.mode-badge-waiting_human { background: #fff3cd; color: #664d03; }
.mode-badge-human { background: #cff4fc; color: #055160; }

/* ── Page header ── */
.page-header { margin-bottom: 1.5rem; display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.page-header h1 { flex: 1; font-size: 1.25rem; }
.text-muted { color: var(--text-muted); }

/* ── Conversation layout ── */
.convo-layout { display: grid; grid-template-columns: 1fr 380px; gap: 1.5rem; }

.messages-panel, .tasks-panel {
  background: var(--bg-card);
  padding: 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.messages-panel h2, .tasks-panel h2 { font-size: 1rem; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }

/* ── WhatsApp-style Chat ── */
.chat-panel {
  background: #f1f5f9;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.messages-panel.chat-panel {
  padding: 0;
}
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 70vh;
  overflow-y: auto;
  padding: 1rem 0.75rem;
  background: #f1f5f9;
  -webkit-overflow-scrolling: touch;
}

.chat-bubble {
  display: flex;
  max-width: 85%;
}
.chat-inbound {
  align-self: flex-start;
}
.chat-outbound {
  align-self: flex-end;
}
.chat-bubble-content {
  padding: 0.5rem 0.65rem 0.25rem;
  border-radius: 8px;
  position: relative;
  box-shadow: 0 1px 1px rgba(0,0,0,0.1);
  word-break: break-word;
}
.chat-inbound .chat-bubble-content {
  background: #ffffff;
  border-top-left-radius: 0;
}
.chat-outbound .chat-bubble-content {
  background: #DBEAFE;
  border-top-right-radius: 0;
}
.chat-text {
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: pre-wrap;
}
.chat-time {
  font-size: 0.65rem;
  color: #999;
  text-align: right;
  margin-top: 0.15rem;
}
.chat-attachment a {
  font-size: 0.85rem;
  color: var(--primary);
}

/* ── Chat send form ── */
.chat-send-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #f0f0f0;
  align-items: center;
  border-top: 1px solid #ddd;
}
.chat-send-form input {
  flex: 1;
  border: none;
  border-radius: 20px;
  padding: 0.6rem 1rem;
  font-size: 16px;
  background: white;
  min-height: 44px;
}
.chat-send-form input:focus { outline: none; box-shadow: 0 0 0 2px var(--primary); }
.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.chat-send-btn:hover { background: var(--primary-hover); }

/* Legacy message styles (for old format fallback) */
.message-list { display: flex; flex-direction: column; gap: 0.75rem; max-height: 600px; overflow-y: auto; }
.message {
  padding: 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.message-inbound { background: #e3f2fd; border-color: #90caf9; }
.message-outbound { background: #e8f5e9; border-color: #a5d6a7; }
.message-meta { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.25rem; font-size: 0.75rem; color: var(--text-muted); }
.message-dir { font-weight: 600; }
.message-body { font-size: 0.9rem; white-space: pre-wrap; word-break: break-word; }
.attachment-link { margin-top: 0.5rem; }

/* ── Task cards ── */
.task-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}
.task-card-header { margin-bottom: 0.5rem; }
.task-card-meta { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.note-form { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.note { padding: 0.5rem; background: #f8f9fa; border-radius: 4px; margin-bottom: 0.5rem; font-size: 0.85rem; }
.note-meta { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.25rem; }

/* ── Task detail ── */
.task-detail { background: var(--bg-card); padding: 1.5rem; border-radius: var(--radius); box-shadow: var(--shadow); }
.task-detail-header { margin-bottom: 1rem; }
.task-detail-header h1 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.task-badges { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.info-item label { font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); display: block; }
.info-item span { font-weight: 600; }
.task-actions { margin-bottom: 1.5rem; }
.task-actions h2 { font-size: 1rem; margin-bottom: 0.75rem; }
.actions-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.task-notes-section { margin-bottom: 1.5rem; }
.task-notes-section h2 { font-size: 1rem; margin-bottom: 0.75rem; }
.task-messages-section h2 { font-size: 1rem; margin-bottom: 0.75rem; }
.messages-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; flex-wrap: wrap; gap: 0.5rem; }
.messages-header h2 { margin-bottom: 0; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ── Create task ── */
.create-task-section { margin-top: 1rem; }
.create-task-section summary { cursor: pointer; }
.create-task-form { margin-top: 0.75rem; }

/* ── Summary box (prontuário) ── */
.summary-box {
  background: #f0fdf4;
  border: 2px solid #86efac;
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}
.summary-compact { padding: 0.75rem; margin-top: 0.5rem; }
.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.summary-header h2 { font-size: 1rem; margin: 0; color: #166534; }
.summary-header strong { color: #166534; font-size: 0.85rem; }
.summary-content {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 0.75rem;
  background: white;
  border-radius: 4px;
  border: 1px solid #bbf7d0;
  color: #14532d;
}
.btn-copy {
  background: #166534;
  color: white;
  border: none;
  padding: 0.3rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.15s;
}
.btn-copy:hover { background: #15803d; }
.btn-copied { background: #059669 !important; }

/* ── Handoff controls ── */
.handoff-controls { display: flex; gap: 0.5rem; align-items: center; }
.mode-bot { color: var(--success); }
.mode-waiting_human { color: var(--warning); }
.mode-human { color: var(--primary); }

/* ── Send message form (legacy) ── */
.send-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ── Email forward ── */
.email-forward-section { margin-bottom: 1.5rem; }
.email-forward-form { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.btn-email {
  background: var(--primary);
  color: white;
  border: 1px solid var(--primary);
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.15s;
  min-height: 44px;
}
.btn-email:hover { background: var(--primary-hover); }
.email-hint { font-size: 0.8rem; color: var(--text-muted); }
.email-sent-badge {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: #d1e7dd;
  color: #0f5132;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
}

/* ── Settings ── */
.settings-form { max-width: 800px; }
.settings-section {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.settings-section h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.section-hint { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1rem; }
.field-hint { display: block; color: var(--text-muted); font-size: 0.75rem; margin-top: 0.25rem; }
.template-list { display: flex; flex-direction: column; gap: 1rem; }
.template-list textarea {
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
}
.settings-actions {
  margin-top: 0.5rem;
  margin-bottom: 2rem;
}
.btn-lg { padding: 0.75rem 2rem; font-size: 1rem; }
.alert-success {
  background: #d1e7dd;
  color: #0f5132;
  border: 1px solid #badbcc;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

/* ── Admin ── */
.nav-admin { font-weight: 600; color: var(--danger); }
.row-inactive { opacity: 0.5; }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #bb2d3b; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
legend { font-weight: 700; font-size: 0.9rem; padding: 0 0.5rem; }
input[type="checkbox"] { width: auto; margin-right: 0.5rem; }

/* ── Chat list (WhatsApp-style) ── */
.chat-list {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.chat-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background 0.1s;
}
.chat-list-item:hover { background: var(--bg); text-decoration: none; }
.chat-list-item:last-child { border-bottom: none; }
.chat-list-item-waiting { background: #fffbeb; }
.chat-list-item-waiting:hover { background: #fef3c7; }
.chat-list-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563EB, #1d4ed8);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.chat-list-content {
  flex: 1;
  min-width: 0;
}
.chat-list-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.15rem;
}
.chat-list-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-list-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 0.5rem;
}
.chat-list-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.chat-list-preview {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* ── Inbox Tabs (legacy) ── */

/* ── HTMX feedback toast ── */
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator { opacity: 1; }

/* ── Footer ── */
.footer { text-align: center; padding: 2rem 1rem; color: var(--text-muted); }

/* ── Bottom Navigation ── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #FFFFFF;
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0;
  color: #8E99A4;
  font-size: 0.65rem;
  font-weight: 600;
  text-decoration: none;
  flex: 1;
  min-height: 56px;
  transition: color 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.bottom-nav-item i { margin-bottom: 0.15rem; font-size: 1.3rem; }
.bottom-nav-item svg { margin-bottom: 0.1rem; width: 20px; height: 20px; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item:hover { text-decoration: none; color: var(--primary); }

/* ── Offline banner ── */
.offline-banner {
  background: #fff3cd;
  color: #664d03;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  position: sticky;
  top: 52px;
  z-index: 99;
}

/* ── Install banner ── */
.install-banner {
  position: fixed;
  bottom: 68px;
  left: 1rem;
  right: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  z-index: 201;
  font-size: 0.9rem;
}
.install-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* Hide install banner when running as installed PWA */
@media (display-mode: standalone) {
  .install-banner { display: none !important; }
}

/* ── Mobile cards (legacy) ── */
.mobile-only { display: none; }


/* ── Stats grid (new design system) ── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.stat-card {
  background: #04074A;
  color: white;
  border-radius: 12px;
  padding: 0.77rem 0.7rem;
}
.stat-card-pending {
  background: #B91C1C;
}
.stat-card-resolved {
  background: #166534;
}
.stat-card-number {
  font-size: 1.22rem;
  font-weight: 700;
}
.stat-card-label {
  font-size: 0.65rem;
  opacity: 0.85;
}
.stat-card-icon {
  font-size: 0.9rem;
}

/* ── MAVI banner ── */
.mavi-banner {
  width: 100%;
  max-height: 120px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  margin: 0 auto 0.75rem;
  display: block;
  mix-blend-mode: multiply;
}

/* ── Dot navigation ── */
.dot-nav {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.dot-nav-item {
  width: 12px;
  height: 6px;
  border-radius: 3px;
  background: var(--primary-light);
  text-decoration: none;
  display: inline-block;
  transition: background 0.2s;
}
.dot-nav-item:hover {
  background: var(--primary);
  text-decoration: none;
}
.dot-nav-item.active {
  background: var(--primary);
}

/* ══════════════════════════════════════════════
   RESPONSIVE — Mobile first overrides
   ══════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Show bottom nav, hide top nav links */
  .bottom-nav { display: flex; }
  .nav-links { display: none; }
  .navbar { display: none; }

  /* Container tighter on mobile */
  .container { padding: 1rem 0.75rem; }

  /* Conversation: stack layout */
  .convo-layout { grid-template-columns: 1fr; }

  /* Page header: wrap nicer */
  .page-header { gap: 0.5rem; }
  .page-header h1 { font-size: 1.1rem; flex-basis: 100%; }

  /* Stats bar: smaller */
  .stats-bar { gap: 0.5rem; }
  .stat { padding: 0.4rem 0.75rem; min-width: 70px; }
  .stat-number { font-size: 1.1rem; }

  /* Filters: stack vertically */
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filters-bar select,
  .filters-bar .input-search { width: 100%; min-width: unset; }
  .filters-bar .btn { width: 100%; text-align: center; }

  /* Task detail: tighter padding */
  .task-detail { padding: 1rem; }
  .info-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .actions-row { flex-direction: column; }
  .inline-form { flex-wrap: wrap; }

  /* Chat messages: take more height on mobile */
  .chat-messages { max-height: 60vh; }

  /* Settings grid: single column */
  .settings-grid { grid-template-columns: 1fr; }

  /* Footer: hide on mobile (bottom nav handles it) */
  .footer { display: none; }

  /* Install banner above bottom nav */
  .install-banner { bottom: calc(60px + var(--safe-bottom) + 0.5rem); }
}

@media (max-width: 480px) {
  .stat { min-width: 60px; padding: 0.35rem 0.5rem; }
  .stat-number { font-size: 1rem; }
  .stat-label { font-size: 0.6rem; }

  .chat-bubble { max-width: 90%; }

  .info-grid { grid-template-columns: 1fr; }
}

/* ===== RECEITA RAPIDA WIZARD ===== */
.rr-wizard-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 0;
  margin-bottom: 8px;
}
.rr-step-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 24px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.rr-step-indicator.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}
.rr-step-indicator.completed {
  background: var(--success);
  color: #fff;
}
.rr-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255,255,255,0.2);
}
.rr-step-label {
  display: none;
}
@media (min-width: 480px) {
  .rr-step-label { display: inline; }
}
.rr-step-divider {
  width: 24px;
  height: 2px;
  background: var(--border);
}

/* ── Step Panels ── */
.rr-step-panel {
  display: none;
  animation: rr-fadeIn 0.3s ease;
}
.rr-step-panel.active {
  display: block;
}
@keyframes rr-fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Patient Search & Cards (Step 1) ── */
.rr-patient-search {
  position: relative;
  margin-bottom: 12px;
}
.rr-patient-search input {
  width: 100%;
  padding: 12px 16px 12px 40px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  background: var(--bg-card);
  transition: border-color 0.2s;
}
.rr-patient-search input:focus {
  border-color: var(--primary);
  outline: none;
}
.rr-patient-search .fa-search {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.rr-patient-list {
  max-height: 400px;
  overflow-y: auto;
}
.rr-patient-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.rr-patient-card:hover {
  border-color: var(--primary);
  background: #EFF6FF;
}
.rr-patient-card.selected {
  border-color: var(--primary);
  background: #DBEAFE;
}
.rr-patient-avatar, .rr-patient-avatar-sm {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #DBEAFE;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}
.rr-patient-avatar-sm {
  width: 36px;
  height: 36px;
  font-size: 14px;
}
.rr-patient-card strong {
  display: block;
  font-size: 15px;
}
.rr-patient-card .text-muted {
  font-size: 13px;
}

/* ── Patient Header (Step 2 top) ── */
.rr-patient-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.rr-patient-header .btn-text {
  margin-left: auto;
}

/* ── Step 2 Layout (main + sidebar) ── */
.rr-step2-layout {
  display: flex;
  gap: 12px;
}
.rr-step2-main {
  flex: 1;
  min-width: 0;
}
.rr-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
}
.rr-sidebar-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
}
.rr-sidebar-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.rr-sidebar-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
/* Mobile: hide sidebar, show tabs */
@media (max-width: 768px) {
  .rr-sidebar { display: none; }
  .rr-doc-tabs { display: flex !important; }
}
@media (min-width: 769px) {
  .rr-doc-tabs { display: none !important; }
}

/* ── Document Type Tabs (mobile) ── */
.rr-doc-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}
.rr-doc-tab {
  padding: 8px 16px;
  border-radius: 24px;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.rr-doc-tab:not(.active) {
  background: var(--bg);
  color: var(--text-muted);
}
.rr-doc-tab-menu {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rr-doc-content {
  display: none;
}
.rr-doc-content.active {
  display: block;
}

/* ── Drug Search Area (Nuvie style) ── */
.rr-drug-search-wrapper {
  position: relative;
  margin-bottom: 16px;
}
.rr-drug-search {
  width: 100%;
  padding: 12px 40px 12px 16px;
  border: 2px solid #F5A0A0; /* coral/pink border like Nuvie */
  border-radius: var(--radius);
  font-size: 16px;
  background: var(--bg-card);
  transition: border-color 0.2s;
}
.rr-drug-search:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.rr-search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* ── Autocomplete Dropdown (Nuvie style with icons) ── */
/* Override/enhance the existing .ac-list items for Nuvie style */
.ac-list .ac-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
}
.ac-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #DBEAFE;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}
.ac-item-info {
  flex: 1;
  min-width: 0;
}
.ac-item-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  line-height: 1.3;
}
.ac-item-ingredient {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
.ac-badge-destaque {
  display: inline-block;
  padding: 2px 8px;
  background: #FEF9C3;
  color: #854D0E;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 4px;
}
/* Highlight match text */
.ac-highlight {
  background: #FEF08A;
  border-radius: 2px;
  padding: 0 1px;
}

/* ── Medication Cards ── */
.rr-toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.rr-section-label {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 600;
}
.rr-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}
.rr-toggle input[type="checkbox"] {
  width: 40px;
  height: 22px;
  appearance: none;
  -webkit-appearance: none;
  background: #D1D5DB;
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.rr-toggle input[type="checkbox"]::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
}
.rr-toggle input[type="checkbox"]:checked {
  background: var(--primary);
}
.rr-toggle input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}

#med-cards-container {
  margin-top: 8px;
}
.rr-med-card {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border-left: 4px solid #F97316; /* orange left border like Nuvie */
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  position: relative;
}
.rr-med-number {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  min-width: 20px;
}
.rr-med-info {
  flex: 1;
  min-width: 0;
}
.rr-med-info strong {
  font-size: 15px;
  display: block;
  margin-bottom: 4px;
}
.rr-med-form {
  font-weight: 400;
  color: var(--text-muted);
}
.rr-med-instructions {
  font-size: 14px;
  color: var(--text-muted);
  margin: 4px 0;
}
.rr-med-quantity {
  font-size: 13px;
  color: var(--text-muted);
}
.rr-med-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.rr-med-actions button {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: all 0.15s;
}
.rr-med-actions button:first-child {
  color: var(--text);
}
.rr-med-actions button:first-child:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.rr-med-actions button:last-child {
  color: var(--danger);
}
.rr-med-actions button:last-child:hover {
  border-color: var(--danger);
  background: #FEF2F2;
}

.rr-add-obs-btn {
  display: block;
  width: 100%;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  text-align: center;
  margin-top: 12px;
  transition: all 0.15s;
}
.rr-add-obs-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.rr-obs-textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  resize: vertical;
  margin-top: 8px;
}

/* ── Modal Styles ── */
.rr-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: rr-fadeIn 0.2s;
}
@media (min-width: 769px) {
  .rr-modal-overlay {
    align-items: center;
  }
}
.rr-modal-content {
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: rr-slideUp 0.3s ease;
}
@media (min-width: 769px) {
  .rr-modal-content {
    border-radius: var(--radius);
  }
}
@keyframes rr-slideUp {
  from { transform: translateY(100px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.rr-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.rr-modal-header h3 {
  margin: 0;
  font-size: 18px;
}
.rr-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rr-modal-body {
  padding: 20px;
}
.rr-modal-body .form-group {
  margin-bottom: 16px;
}
.rr-modal-body label {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 600;
}
.rr-modal-footer {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.rr-modal-footer button {
  flex: 1;
}

/* ── Posology History ── */
.rr-posology-history {
  margin-bottom: 16px;
}
.rr-posology-history label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.rr-history-item {
  padding: 8px 12px;
  background: #F9FAFB;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.rr-history-item:hover {
  background: #DBEAFE;
  border-color: var(--primary);
}
.rr-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}

/* ── Bottom Action Bar ── */
.rr-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}
@media (max-width: 768px) {
  .rr-bottom-bar {
    bottom: 56px; /* above mobile bottom-nav */
  }
}
.rr-btn-back, .rr-btn-next {
  flex: 1;
  padding: 14px 20px;
  border-radius: 28px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s;
  border: 2px solid var(--border);
}
.rr-btn-back {
  background: var(--bg-card);
  color: var(--text);
}
.rr-btn-back:hover {
  border-color: var(--text-muted);
}
.rr-btn-next {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.rr-btn-next:hover {
  background: var(--primary-hover);
}
.rr-btn-next:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Step 3 — Send & Sign ── */
.rr-send-header {
  margin-bottom: 20px;
}
.rr-send-header p {
  font-size: 16px;
}
.rr-send-fields {
  margin-bottom: 24px;
}
.rr-phone-input {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.rr-phone-prefix {
  padding: 10px 12px;
  background: var(--bg);
  font-size: 14px;
  border-right: 1px solid var(--border);
  white-space: nowrap;
}
.rr-phone-input input {
  flex: 1;
  border: none;
  padding: 10px 12px;
  font-size: 16px;
  outline: none;
}

.rr-sign-section {
  background: #F0FDF4;
  border: 1px solid #86EFAC;
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 20px;
}
.rr-sign-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: #DCFCE7;
  color: #166534;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}
.rr-sign-details {
  margin-bottom: 12px;
  font-size: 14px;
}
.rr-sign-section-disabled {
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.rr-summary {
  background: #FFF1F2;
  border: 1px solid #FECDD3;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  overflow: hidden;
}
.rr-summary-header {
  padding: 12px 16px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.rr-summary-token {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}
.rr-summary-body {
  padding: 0 16px 16px;
  font-size: 14px;
}
.rr-summary-med {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.rr-summary-med:last-child {
  border-bottom: none;
}
.rr-summary-med-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #DBEAFE;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
}

/* ── Input Styles for Wizard ── */
.rr-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  background: var(--bg-card);
  transition: border-color 0.2s;
  min-height: 44px;
}
.rr-input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
select.rr-input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ── Exam Search & Cards (Solicitacao de Exames) ── */
.rr-exam-search-wrapper {
  position: relative;
  margin-bottom: 12px;
}
.rr-exam-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 250px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow);
  display: none;
}
.rr-exam-dropdown.active {
  display: block;
}
.rr-exam-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.rr-exam-item:hover {
  background: #EFF6FF;
}
.rr-exam-item:last-child {
  border-bottom: none;
}
.rr-exam-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.rr-exam-card button {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 14px;
}

/* ── Responsive & Spacing for Wizard Container ── */
/* Add padding at bottom of page for fixed bottom bar */
.rr-wizard-container {
  padding-bottom: 100px; /* space for fixed bottom bar */
}
@media (max-width: 768px) {
  .rr-wizard-container {
    padding-bottom: 140px; /* bottom bar + mobile nav */
  }
}

/* Recent documents section at bottom */
.rr-docs-section {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.rr-doc-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.rr-doc-card-info {
  flex: 1;
}
.rr-doc-card-info strong {
  display: block;
  font-size: 14px;
}
.rr-doc-card-info small {
  color: var(--text-muted);
  font-size: 12px;
}
.rr-doc-card-actions {
  display: flex;
  gap: 8px;
}
.badge-signed {
  padding: 2px 8px;
  background: #DCFCE7;
  color: #166534;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.badge-unsigned {
  padding: 2px 8px;
  background: #FEF3C7;
  color: #92400E;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

/* Success/error alerts */
.rr-alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
}
.rr-alert-success {
  background: #F0FDF4;
  color: #166534;
  border: 1px solid #86EFAC;
}
.rr-alert-error {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
}
