/* ══════════════════════════════════════════════════════
   Todas as Hemácias Contam — Design System
   Fontes: Nunito Sans (UI) + DM Mono (valores clínicos)
   ══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;600;700;800&family=DM+Mono:wght@400;500&display=swap');

/* ── Variáveis ──────────────────────────────────────── */
:root {
  --color-primary:       #2B6CB0;
  --color-primary-dark:  #1A365D;
  --color-primary-light: #BEE3F8;
  --color-primary-hover: #2563A0;
  --color-surface:       #EDF2F7;
  --color-surface-2:     #E2E8F0;
  --color-text:          #1A202C;
  --color-text-muted:    #718096;
  --color-white:         #FFFFFF;
  --color-success:       #276749;
  --color-success-bg:    #C6F6D5;
  --color-warning:       #B7791F;
  --color-warning-bg:    #FEFCBF;
  --color-danger:        #C53030;
  --color-danger-bg:     #FED7D7;
  --color-border:        #CBD5E0;
  --color-card-open:     #3182CE;
  --color-card-progress: #DD6B20;
  --color-card-done:     #276749;
  --color-card-valid:    #718096;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow:    0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.13);
  --transition: 180ms ease;

  --font-ui:  'Nunito Sans', system-ui, sans-serif;
  --font-num: 'DM Mono', 'Courier New', monospace;
}

/* ── Reset & Base ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--color-surface);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Layout principal ──────────────────────────────── */
#app { display: flex; flex-direction: column; min-height: 100vh; }

.app-nav {
  background: var(--color-primary-dark);
  color: var(--color-white);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 0;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
  height: 60px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--color-white);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.nav-brand .brand-icon {
  width: 32px; height: 32px;
  background: var(--color-primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0;
  margin-left: 24px;
  flex: 1;
  overflow-x: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
  cursor: pointer;
}

.nav-link:hover, .nav-link.active {
  color: var(--color-white);
  background: rgba(255,255,255,0.12);
}

.nav-link.active { background: rgba(255,255,255,0.18); }

.nav-actions {
  display: flex; align-items: center; gap: 8px; margin-left: auto;
}

.nav-user {
  display: flex; align-items: center; gap: 8px;
  color: rgba(255,255,255,0.85);
  font-size: 0.85rem;
}

.nav-user .role-badge {
  font-size: 0.7rem;
  background: rgba(255,255,255,0.15);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.main-content {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

/* ── Cards ──────────────────────────────────────────── */
.card {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  border: 1px solid var(--color-border);
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
}

/* Procedure status card */
.proc-card {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  border-left: 4px solid;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow var(--transition);
}

.proc-card:hover { box-shadow: var(--shadow); }
.proc-card.status-ABERTO, .proc-card.status-EM_CURSO { border-left-color: var(--color-card-open); }
.proc-card.status-EM_CURSO { border-left-color: var(--color-card-progress); }
.proc-card.status-FINALIZADO { border-left-color: var(--color-card-done); }
.proc-card.status-VALIDADO { border-left-color: var(--color-card-valid); }
.proc-card.status-AGENDADO { border-left-color: var(--color-primary-light); }

.proc-card-info { flex: 1; min-width: 0; }
.proc-card-name { font-weight: 700; font-size: 1rem; }
.proc-card-meta { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 2px; }
.proc-card-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Status badges ──────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 0.72rem; font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-blue     { background: #EBF8FF; color: #2B6CB0; }
.badge-orange   { background: #FFFAF0; color: #C05621; }
.badge-green    { background: var(--color-success-bg); color: var(--color-success); }
.badge-gray     { background: #F7FAFC; color: var(--color-text-muted); }
.badge-red      { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-yellow   { background: var(--color-warning-bg); color: var(--color-warning); }

/* ── Botões ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
  min-height: 44px;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--color-primary); color: var(--color-white); }
.btn-primary:hover { background: var(--color-primary-hover); box-shadow: var(--shadow); }

.btn-secondary { background: var(--color-surface-2); color: var(--color-text); }
.btn-secondary:hover { background: var(--color-border); }

.btn-success { background: var(--color-success); color: var(--color-white); }
.btn-success:hover { background: #1F5130; }

.btn-danger { background: var(--color-danger); color: var(--color-white); }
.btn-danger:hover { background: #9B2C2C; }

.btn-ghost { background: transparent; color: var(--color-primary); }
.btn-ghost:hover { background: var(--color-primary-light); }

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}
.btn-outline:hover { background: var(--color-primary-light); }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; min-height: 36px; }
.btn-lg { padding: 14px 28px; font-size: 1rem; min-height: 52px; }
.btn-full { width: 100%; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ── Formulários ────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-label .req { color: var(--color-danger); margin-left: 2px; }
.form-label .opt { color: var(--color-text-muted); font-weight: 400; text-transform: none; letter-spacing: 0; }

.form-control {
  padding: 10px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--color-text);
  background: var(--color-white);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  min-height: 44px;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(43,108,176,0.15);
}

.form-control.error { border-color: var(--color-danger); }
.form-control.numeric { font-family: var(--font-num); font-size: 1rem; }

.form-hint { font-size: 0.78rem; color: var(--color-text-muted); }
.form-error { font-size: 0.78rem; color: var(--color-danger); display: none; }
.form-error.visible { display: block; }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23718096' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

textarea.form-control { min-height: 80px; resize: vertical; }

/* Password show/hide toggle */
.pass-wrap { position: relative; }
.pass-wrap .form-control { padding-right: 44px; }
.pass-toggle {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 44px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.pass-toggle:hover { color: var(--color-primary); }

/* Checkbox / Toggle */
.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  min-height: 44px;
}

.form-check input[type="checkbox"] {
  width: 18px; height: 18px;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.toggle-switch input { display: none; }

.toggle-track {
  width: 44px; height: 24px;
  background: var(--color-surface-2);
  border-radius: 12px;
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}

.toggle-track::after {
  content: '';
  width: 18px; height: 18px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 3px; left: 3px;
  transition: left var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-track {
  background: var(--color-primary);
}

.toggle-switch input:checked + .toggle-track::after {
  left: 23px;
}

/* Grid forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }

/* ── Stepper ────────────────────────────────────────── */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 28px;
  overflow-x: auto;
  padding: 4px 0;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 60px;
  cursor: pointer;
  position: relative;
}

.step::before {
  content: '';
  position: absolute;
  top: 18px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--color-border);
  z-index: 0;
}

.step:last-child::before { display: none; }

.step-dot {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--color-surface-2);
  border: 2px solid var(--color-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-muted);
  transition: all var(--transition);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.step.active .step-dot {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.step.completed .step-dot {
  background: var(--color-success);
  border-color: var(--color-success);
  color: white;
}

.step-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-align: center;
  line-height: 1.2;
}

.step.active .step-label { color: var(--color-primary); }
.step.completed .step-label { color: var(--color-success); }

/* ── Tabelas ────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

table { width: 100%; border-collapse: collapse; }
th {
  background: var(--color-surface);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-surface);
  font-size: 0.875rem;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--color-surface); }

td.numeric, th.numeric { font-family: var(--font-num); text-align: right; }

/* ── Banners / Alerts ───────────────────────────────── */
.banner {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.banner-icon { font-size: 1.1em; flex-shrink: 0; margin-top: 1px; }

.banner-warning {
  background: var(--color-warning-bg);
  border: 1px solid #FAF089;
  color: #7B341E;
}

.banner-danger {
  background: var(--color-danger-bg);
  border: 1px solid #FEB2B2;
  color: #822727;
}

.banner-success {
  background: var(--color-success-bg);
  border: 1px solid #9AE6B4;
  color: #1C4532;
}

.banner-info {
  background: #EBF8FF;
  border: 1px solid #BEE3F8;
  color: #1A365D;
}

/* ── HbS Progress bar ───────────────────────────────── */
.hbs-bar-wrapper {
  position: relative;
  height: 16px;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(to right, var(--color-success), var(--color-warning), var(--color-danger));
}

.hbs-bar-marker {
  position: absolute;
  top: 0;
  width: 3px;
  height: 100%;
  background: var(--color-primary-dark);
  border-radius: 2px;
  transition: left 0.5s ease;
}

.hbs-bar-threshold {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: white;
  opacity: 0.8;
}

.hbs-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-top: 4px;
  font-family: var(--font-num);
}

/* ── OCR Field Review ───────────────────────────────── */
.ocr-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--color-white);
}

.ocr-field.confirmed { border-color: var(--color-success); background: #F0FFF4; }
.ocr-field.needs-review { border-color: var(--color-warning); background: var(--color-warning-bg); }

.ocr-field-label { font-size: 0.78rem; color: var(--color-text-muted); font-weight: 600; flex: 1; }
.ocr-field-value { font-family: var(--font-num); font-size: 0.95rem; font-weight: 500; }
.ocr-field input { font-family: var(--font-num); width: 100px; text-align: right; }
.ocr-field-status { font-size: 0.75rem; font-weight: 700; }
.ocr-field.confirmed .ocr-field-status { color: var(--color-success); }
.ocr-field.needs-review .ocr-field-status { color: var(--color-warning); }

/* ── Camera / Photo ────────────────────────────────── */
.camera-area {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.camera-area:hover { border-color: var(--color-primary); background: var(--color-primary-light); }
.camera-area.has-photo { border-style: solid; border-color: var(--color-success); }

.camera-icon { font-size: 2.5rem; margin-bottom: 8px; }
.camera-area img { max-width: 100%; border-radius: var(--radius-sm); max-height: 300px; object-fit: contain; }

/* ── Modais ─────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex; align-items: flex-end;
  animation: fadeIn 150ms ease;
}

@media (min-width: 640px) {
  .modal-backdrop { align-items: center; justify-content: center; }
}

.modal {
  background: var(--color-white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 28px 24px 40px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 200ms ease;
}

@media (min-width: 640px) {
  .modal {
    border-radius: var(--radius-lg);
    max-width: 560px;
    padding: 28px;
    animation: scaleIn 180ms ease;
  }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title { font-size: 1.1rem; font-weight: 800; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--color-text-muted); padding: 4px; }

/* ── Page sections ──────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-primary-dark);
  letter-spacing: -0.02em;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-primary-dark);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-primary-light);
}

/* ── Metrics ────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

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

.metric-card {
  background: var(--color-white);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.metric-value {
  font-family: var(--font-num);
  font-size: 1.8rem;
  font-weight: 500;
  color: var(--color-primary-dark);
  line-height: 1;
  margin-bottom: 4px;
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── UCE table ──────────────────────────────────────── */
.uce-table { margin-top: 12px; }
.uce-row {
  display: grid;
  grid-template-columns: 1fr 1fr 80px 70px 40px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.uce-row-header { font-size: 0.72rem; font-weight: 700; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.uce-row input { font-family: var(--font-num); }

/* ── Dynamic drug list ──────────────────────────────── */
.drug-row {
  display: grid;
  grid-template-columns: 2fr 80px 80px 80px 1fr 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.drug-row-header { font-size: 0.72rem; font-weight: 700; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Access card ────────────────────────────────────── */
.access-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  background: var(--color-surface);
  position: relative;
}

.access-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.access-type-badge {
  font-size: 0.8rem; font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
}

.access-type-CVP { background: #EBF8FF; color: #2B6CB0; }
.access-type-CVC { background: #FAF5FF; color: #553C9A; }

/* ── Login screen ───────────────────────────────────── */
#screen-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 100%);
  padding: 24px;
}

.login-card {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
  border-radius: var(--radius);
  margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}

.login-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--color-primary-dark);
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.lang-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.lang-btn {
  flex: 1;
  padding: 6px;
  border: none;
  border-radius: 4px;
  background: transparent;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: all var(--transition);
}

.lang-btn.active { background: var(--color-white); color: var(--color-primary); box-shadow: var(--shadow-sm); }

/* ── Bottom action bar (mobile) ─────────────────────── */
.action-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--color-white);
  border-top: 1px solid var(--color-border);
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  z-index: 90;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
}

/* ── Breadcrumb ─────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}
.breadcrumb a { color: var(--color-primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span::before { content: '/'; margin-right: 6px; }

/* ── Chart container ────────────────────────────────── */
.chart-container {
  position: relative;
  height: 200px;
  margin: 12px 0;
}

/* ── Empty states ───────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-text-muted);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state-text { font-size: 0.9rem; }

/* ── Spinner ────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.spinner-dark {
  border-color: rgba(43,108,176,0.2);
  border-top-color: var(--color-primary);
}

/* ── Animations ─────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── Utility ────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.text-primary { color: var(--color-primary); }
.font-mono { font-family: var(--font-num); }
.font-bold { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.72rem; }
.divider { border: none; border-top: 1px solid var(--color-border); margin: 20px 0; }

/* ── Participant list ───────────────────────────────── */
.participant-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.participant-item {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.85rem;
  padding: 8px 12px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
}
.participant-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.75rem;
  flex-shrink: 0;
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 640px) {
  .main-content { padding: 16px 12px 100px; }
  .page-title { font-size: 1.25rem; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .uce-row { grid-template-columns: 1fr 1fr; }
  .uce-row .uce-delete { display: none; }
  .drug-row { grid-template-columns: 1fr 1fr; }
  .nav-links { display: none; }
  .card { padding: 16px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .stepper .step-label { display: none; }
}

/* ── Search input ───────────────────────────────────── */
.search-box {
  position: relative;
}
.search-box input { padding-left: 36px; }
.search-box::before {
  content: '🔍';
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  z-index: 1;
}

/* ── Dropdown list (patient search) ─────────────────── */
.dropdown-list {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  max-height: 240px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow);
}

.dropdown-item {
  padding: 12px 14px;
  cursor: pointer;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--color-surface);
}
.dropdown-item:hover { background: var(--color-primary-light); }
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item .patient-name { font-weight: 700; }
.dropdown-item .patient-meta { font-size: 0.75rem; color: var(--color-text-muted); }

/* ── Validation divergence table ────────────────────── */
.divergence-row { background: #FFF5F5; }
.divergence-cell { color: var(--color-danger); font-family: var(--font-num); }

/* ── Reconciliation comparison ──────────────────────── */
.reconciliation-row td:nth-child(3) { font-family: var(--font-num); font-size: 0.8rem; }
