:root {
  --primary: #2C3E2D;
  --accent: #6B8E63;
  --light-green: #8BA583;
  --warm-taupe: #BAA68D;
  --muted: #5A6B5B;
  --dark: #1E2820;
  --bg-main: #F7F5F0;
  --bg-alt: #EDE8DF;
  --bg-warm: #E5DFD3;
  --card: #E8E3DA;
  --tag: #DED7CB;
  --text: #2C3E2D;
  --white: #FFFFFF;
  --red: #C0392B;
  --orange: #E67E22;
  --yellow: #F1C40F;
  --blue: #3498DB;
  --p1: #C0392B;
  --p2: #E67E22;
  --p3: #D4AC0D;
  --p4: #3498DB;
}
* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-main);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
.nav {
  background: var(--primary);
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.nav-title {
  color: var(--white);
  font-size: 18px;
  font-weight: 700;
  margin-right: 24px;
  white-space: nowrap;
}
.nav-tabs { display: flex; gap: 4px; }
.nav-tab {
  background: transparent;
  color: rgba(255,255,255,0.7);
  border: none;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: all 0.2s;
}
.nav-tab:hover { color: var(--white); background: rgba(255,255,255,0.1); }
.nav-tab.active { color: var(--primary); background: var(--bg-main); }
.screen { display: none; padding: 20px; max-width: 1200px; margin: 0 auto; }
.screen.active { display: block; }
.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--accent);
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--dark); }
.btn-accent { background: var(--accent); color: var(--white); }
.btn-accent:hover { background: #5A7D52; }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #A93226; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--accent);
}
.btn-outline:hover { background: var(--accent); color: var(--white); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
input[type="text"], input[type="number"], input[type="date"], textarea, select {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--tag);
  border-radius: 6px;
  font-size: 14px;
  background: var(--white);
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.2s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 60px; }
.card {
  background: var(--white);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--tag);
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filter-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.filter-btn.active, .filter-btn:hover { background: var(--accent); color: var(--white); }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--tag);
  border-radius: 12px;
  font-size: 11px;
  color: var(--muted);
}
.priority-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--white);
}
.priority-badge.p1 { background: var(--p1); }
.priority-badge.p2 { background: var(--p2); }
.priority-badge.p3 { background: var(--p3); color: var(--dark); }
.priority-badge.p4 { background: var(--p4); }
.vial-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.symptom-vial-chip {
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: transform 0.1s;
}
.symptom-vial-chip:hover { transform: scale(1.05); }
.symptom-vial-chip.p1 { background: #FADBD8; color: var(--p1); }
.symptom-vial-chip.p2 { background: #FDEBD0; color: #B7600A; }
.symptom-vial-chip.p3 { background: #FCF3CF; color: #7D6608; }
.symptom-vial-chip.p4 { background: #D6EAF8; color: #1A5276; }
.search-box { position: relative; margin-bottom: 16px; }
.search-box input { padding-left: 36px; font-size: 15px; height: 44px; }
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 16px;
}
.symptom-browser { margin-bottom: 20px; }
.symptom-cat-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin: 12px 0 6px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.symptom-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.symptom-chip {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--tag);
  background: var(--white);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.symptom-chip:hover { border-color: var(--accent); background: #f0f5ee; }
.symptom-chip.active { background: var(--accent); color: var(--white); border-color: var(--accent); }
.symptom-chip.hidden { display: none; }
.symptom-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 20px;
  border: none;
  background: var(--bg-alt);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
}
.symptom-back-btn:hover { background: var(--tag); }
.patient-bar {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
  align-items: end;
}
.field-group { margin-bottom: 12px; }
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 10px 14px;
  background: var(--bg-alt);
  border-radius: 8px;
  margin-bottom: 4px;
  user-select: none;
}
.collapsible-header:hover { background: var(--bg-warm); }
.collapsible-body { display: none; padding: 12px 0; }
.collapsible-body.open { display: block; }
.collapsible-arrow { transition: transform 0.2s; font-size: 12px; }
.collapsible-arrow.open { transform: rotate(90deg); }
.toggle-group { display: inline-flex; border-radius: 6px; overflow: hidden; border: 1.5px solid var(--tag); }
.toggle-opt {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--white);
  color: var(--muted);
  border: none;
  transition: all 0.2s;
}
.toggle-opt.active-fort { background: var(--accent); color: var(--white); }
.toggle-opt.active-faible { background: var(--red); color: var(--white); }
.toggle-opt.active-nonteste { background: var(--tag); color: var(--muted); }
.toggle-opt.active-oui { background: var(--accent); color: var(--white); }
.toggle-opt.active-non { background: var(--tag); color: var(--muted); }
/* Shared input style for notes */
.note-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--tag);
  border-radius: 6px;
  background: var(--white);
  color: var(--text);
  height: 32px;
}
.note-input:focus { border-color: var(--accent); outline: none; }
/* Test row */
.test-row {
  display: grid;
  grid-template-columns: 200px 180px 1fr 60px;
  gap: 8px;
  align-items: start;
  padding: 8px 12px;
  border-bottom: 1px solid var(--bg-alt);
}
.test-row:hover { background: var(--bg-alt); }
.test-row .vial-name { font-weight: 600; font-size: 13px; }
.test-row .vial-id { font-size: 11px; color: var(--muted); }
/* Combos area: tree container with vertical connector line */
.combos-area {
  width: 100%;
  margin-left: 16px;
  padding-left: 16px;
  border-left: 2px solid var(--accent);
  position: relative;
}
.combos-area:empty { border-left: none; margin-left: 0; padding-left: 0; }
/* Sub-component row (level 1) — tree branch */
.sub-combo-row {
  display: grid;
  grid-template-columns: 176px 180px 1fr 60px;
  gap: 8px;
  align-items: start;
  padding: 8px 12px 8px 16px;
  margin-top: 0;
  background: rgba(107,142,99,0.05);
  border-bottom: 1px solid rgba(107,142,99,0.12);
  font-size: 13px;
  position: relative;
}
.sub-combo-row::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 16px;
  width: 14px;
  height: 0;
  border-top: 2px solid var(--accent);
}
.sub-combo-row .sub-label { font-weight: 600; color: var(--primary); line-height: 1.4; }
.sub-combo-row .sub-id { color: var(--accent); font-size: 11px; font-weight: 700; margin-right: 4px; }
/* Level 2 wrapper: the sub-category's child area */
.sub-combo-wrapper {
  position: relative;
}
/* Vertical + horizontal connector from sub-cat row down to level2-area */
.sub-combo-wrapper .sub-connector {
  position: relative;
  margin-left: 32px;
  height: 12px;
  border-left: 2px solid var(--warm-taupe);
}
/* Level 2 area: indented from the sub-cat, with its own vertical tree line */
.sub-combo-level2-area {
  margin-left: 32px;
  padding-left: 14px;
  border-left: 2px solid var(--warm-taupe);
  position: relative;
}
.sub-combo-level2-area:empty { border-left: none; margin-left: 0; padding-left: 0; }
.sub-combo-row.level2 {
  grid-template-columns: 140px 180px 1fr 36px;
  padding-left: 14px;
  background: rgba(186,166,141,0.06);
  border-bottom: 1px solid rgba(186,166,141,0.15);
}
.sub-combo-row.level2::before {
  border-top-color: var(--warm-taupe);
  left: -14px;
  width: 12px;
}
.sub-combo-row.level2 select {
  width: 100%;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--tag);
  border-radius: 6px;
  background: var(--white);
  height: 32px;
}
.sub-combo-row.level2 .sub-id { color: var(--warm-taupe); }
/* Manual combo row — tree branch, blue */
.manual-combo-row {
  display: grid;
  grid-template-columns: 176px 180px 1fr 36px;
  gap: 8px;
  align-items: start;
  padding: 8px 12px 8px 16px;
  margin-top: 0;
  background: rgba(52,152,219,0.04);
  border-bottom: 1px solid rgba(52,152,219,0.12);
  font-size: 13px;
  position: relative;
}
.manual-combo-row::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 16px;
  width: 14px;
  height: 0;
  border-top: 2px solid var(--blue);
}
.manual-combo-row select {
  width: 100%;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--tag);
  border-radius: 6px;
  background: var(--white);
  height: 32px;
}
/* Actions column */
.sub-combo-actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.btn-add-sub-combo {
  background: transparent; border: 1px solid var(--warm-taupe); color: var(--warm-taupe);
  padding: 2px 6px; border-radius: 4px; font-size: 9px; cursor: pointer;
  white-space: nowrap;
}
.btn-add-sub-combo:hover { background: var(--warm-taupe); color: var(--white); }
/* Drag & drop */
.drag-handle {
  cursor: grab; color: var(--muted); font-size: 14px; user-select: none;
  padding: 2px 4px; opacity: 0.5; transition: opacity 0.2s;
}
.drag-handle:hover { opacity: 1; }
.drag-handle:active { cursor: grabbing; }
.draggable-item { transition: opacity 0.15s; }
.draggable-item.dragging { opacity: 0.3; }
.drag-over-top { box-shadow: 0 -2px 0 0 var(--accent) !important; }
.drag-over-bottom { box-shadow: 0 2px 0 0 var(--accent) !important; }
.btn-expand {
  background: var(--bg-alt); border: 1px solid var(--accent); color: var(--accent);
  padding: 2px 8px; border-radius: 4px; font-size: 10px; cursor: pointer;
  margin-top: 4px; transition: all 0.2s;
}
.btn-expand:hover { background: var(--accent); color: var(--white); }
.combo-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding-left: 16px;
  font-size: 12px;
}
.combo-row .combo-label { color: var(--muted); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--accent);
  background: var(--white);
  color: var(--accent);
  transition: all 0.15s;
}
.chip:hover { background: var(--accent); color: var(--white); }
.chip.added { background: var(--accent); color: var(--white); border-color: var(--accent); }
.history-layout { display: grid; grid-template-columns: 260px 1fr; gap: 20px; min-height: 70vh; }
.patient-list {
  background: var(--white);
  border-radius: 10px;
  border: 1px solid var(--tag);
  overflow-y: auto;
  max-height: 80vh;
}
.patient-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--bg-alt);
  transition: background 0.15s;
}
.patient-item:hover, .patient-item.active { background: var(--bg-alt); }
.patient-item-name { font-weight: 700; font-size: 14px; }
.patient-item-count { font-size: 11px; color: var(--muted); }
.session-card {
  background: var(--white);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--tag);
}
.session-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.result-improved {
  background: #D5F5E3;
  color: #1E8449;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.pretest-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg-alt);
}
.pretest-label { font-size: 13px; font-weight: 600; }
.dropdown-search { position: relative; }
.dropdown-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border: 1.5px solid var(--accent);
  border-radius: 0 0 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
  display: none;
}
.dropdown-list.open { display: block; }
.dropdown-item {
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--bg-alt);
}
.dropdown-item:hover { background: var(--bg-alt); }
.suggested-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
@media (max-width: 768px) {
  .patient-bar { grid-template-columns: 1fr; }
  .test-row { grid-template-columns: 1fr; gap: 4px; }
  .history-layout { grid-template-columns: 1fr; }
  .vial-grid { grid-template-columns: 1fr; }
  .nav-title { font-size: 14px; margin-right: 12px; }
  .nav-tab { padding: 6px 10px; font-size: 12px; }
}
.btn-delete {
  width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--red);
  background: transparent; color: var(--red); font-size: 12px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.2s; flex-shrink: 0;
}
.btn-delete:hover { background: var(--red); color: var(--white); }
.btn-print {
  background: var(--accent); color: var(--white); border: none; padding: 10px 20px;
  border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px; transition: background 0.2s;
}
.btn-print:hover { background: var(--primary); }
@media print {
  body { background: #fff !important; color: #000 !important; font-size: 11px; }
  .nav, .no-print, .btn, .btn-delete, .btn-print, .search-bar, .filters,
  #screen-reference, #screen-history, #screen-patients, .auth-overlay, .anamnese-toggle, .combo-row select,
  .dropdown-wrap, .chip, .btn-sm { display: none !important; }
  #screen-session { display: block !important; max-width: 100%; padding: 0; }
  .screen { display: none !important; }
  #screen-session .section { break-inside: avoid; page-break-inside: avoid; border: 1px solid #ccc; margin-bottom: 8px; padding: 8px; }
  .patient-bar { display: grid !important; grid-template-columns: 1fr 1fr 1fr; border: 2px solid #2C3E2D; padding: 8px; margin-bottom: 12px; }
  .test-row { display: grid !important; grid-template-columns: 2fr 1fr 2fr 0; gap: 4px; padding: 3px 0; border-bottom: 1px solid #ddd; font-size: 10px; }
  .toggle-group { display: none !important; }
  .test-row::after { display: none; }
  .toggle-opt { display: none !important; }
  .test-row .vial-id, .test-row .vial-name { font-size: 11px; }
  .print-result { display: inline !important; font-weight: 700; font-size: 11px; }
  .print-result.fort { color: green; }
  .print-result.faible { color: red; }
  h2, h3 { font-size: 14px; color: #2C3E2D; margin-bottom: 4px; }
  input, textarea, select { border: none !important; background: transparent !important; padding: 0 !important; font-size: 11px; }
  .section-title { background: #2C3E2D !important; color: white !important; padding: 4px 8px !important; font-size: 12px !important; }
  .combo-row { font-size: 10px; padding: 2px 0; }
  @page { margin: 1.5cm; size: A4; }
  .print-header { display: block !important; text-align: center; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid #2C3E2D; }
  .print-header h1 { font-size: 18px; color: #2C3E2D; }
  .print-header p { font-size: 11px; color: #666; }
}
.app-footer {
  background: var(--primary);
  color: rgba(255,255,255,0.6);
  text-align: center;
  padding: 20px 16px;
  font-size: 11px;
  line-height: 1.8;
  margin-top: 40px;
}
.app-footer strong { color: var(--white); font-size: 12px; }
.app-footer .footer-legal { max-width: 700px; margin: 0 auto; }
.app-footer .footer-sep { margin: 8px auto; width: 40px; border-top: 1px solid rgba(255,255,255,0.15); }
@media print { .app-footer { display: none; } }

/* ========== AUTH ========== */
.auth-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg-main);
  display: flex; align-items: center; justify-content: center;
}
.auth-card {
  background: var(--white); border-radius: 16px; padding: 40px;
  width: 100%; max-width: 400px; box-shadow: 0 8px 32px rgba(0,0,0,0.1);
  text-align: center;
}
.auth-card h1 { font-size: 24px; color: var(--primary); margin-bottom: 4px; }
.auth-card .auth-sub { font-size: 14px; color: var(--muted); margin-bottom: 24px; }
.auth-card input { margin-bottom: 12px; }
.auth-card .btn { width: 100%; justify-content: center; margin-bottom: 8px; padding: 12px; font-size: 15px; }
.auth-error { color: var(--red); font-size: 13px; margin-bottom: 12px; min-height: 18px; }
.auth-switch { font-size: 13px; color: var(--muted); margin-top: 12px; }
.auth-switch a { color: var(--accent); cursor: pointer; font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }
.auth-user-bar {
  margin-left: auto; display: flex; align-items: center; gap: 10px;
}
.auth-user-name { color: rgba(255,255,255,0.8); font-size: 13px; font-weight: 500; }
.auth-logout {
  background: rgba(255,255,255,0.15); border: none; color: var(--white);
  padding: 4px 12px; border-radius: 6px; font-size: 12px; cursor: pointer;
  font-weight: 600; transition: background 0.2s;
}
.auth-logout:hover { background: rgba(255,255,255,0.25); }

/* ========== PATIENTS ========== */
.patient-list-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; flex-wrap: wrap; gap: 12px;
}
.patient-list-header h2 { font-size: 18px; font-weight: 700; color: var(--primary); }
.patient-table { width: 100%; border-collapse: collapse; }
.patient-table th {
  text-align: left; font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 12px;
  border-bottom: 2px solid var(--accent);
}
.patient-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--tag); font-size: 14px;
  vertical-align: middle;
}
.patient-table tr { cursor: pointer; transition: background 0.15s; }
.patient-table tr:hover { background: var(--bg-alt); }
.patient-table .session-count {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--white); width: 24px; height: 24px;
  border-radius: 50%; font-size: 12px; font-weight: 700;
}
.patient-detail-back {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; color: var(--accent); font-size: 14px;
  font-weight: 600; cursor: pointer; padding: 0; margin-bottom: 16px;
}
.patient-detail-back:hover { text-decoration: underline; }
.patient-info-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
@media (max-width: 600px) { .patient-info-grid { grid-template-columns: 1fr; } }
.patient-sessions-list { margin-top: 20px; }
.patient-session-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--tag);
  cursor: pointer; transition: background 0.15s;
}
.patient-session-row:hover { background: var(--bg-alt); }
.patient-session-row .session-date { font-weight: 600; font-size: 14px; }
.patient-session-row .session-meta { font-size: 13px; color: var(--muted); }
.patient-session-row .session-status {
  font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600;
}
.patient-session-row .session-status.completed { background: #D5F5E3; color: #1E8449; }
.patient-session-row .session-status.in_progress { background: #FDEBD0; color: #B7600A; }
.modal-overlay {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: var(--white); border-radius: 12px; padding: 24px;
  width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.modal-card h3 { font-size: 18px; color: var(--primary); margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ========== PROTOCOLE EMOTION/CROYANCE WIZARD ========== */
.emo-wizard { max-width: 600px; }
.emo-wizard h3 { display: flex; align-items: center; gap: 8px; }
.emo-wizard .wizard-step { margin-bottom: 16px; }
.emo-wizard .wizard-step-title {
  font-size: 14px; font-weight: 700; color: var(--primary);
  margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--tag);
}
.emo-wizard .wizard-step-desc { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.emo-wizard .choice-grid {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px;
}
.emo-wizard .choice-btn {
  padding: 6px 14px; border: 2px solid var(--tag); border-radius: 8px;
  background: var(--white); font-size: 13px; cursor: pointer; transition: all 0.15s;
}
.emo-wizard .choice-btn:hover { border-color: var(--accent); background: #F0F7EE; }
.emo-wizard .choice-btn.selected { border-color: var(--primary); background: #D5E8D0; color: var(--primary); font-weight: 600; }
.emo-wizard .emotion-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px;
  max-height: 250px; overflow-y: auto; padding: 4px; border: 1px solid var(--tag); border-radius: 8px;
}
.emo-wizard .emotion-item {
  padding: 4px 8px; font-size: 12px; border-radius: 4px; cursor: pointer;
  border: 1px solid transparent; transition: all 0.1s;
}
.emo-wizard .emotion-item:hover { background: #F0F7EE; }
.emo-wizard .emotion-item.selected { background: #D5E8D0; border-color: var(--accent); font-weight: 600; }
.emo-wizard .emotion-group-header {
  grid-column: 1 / -1; font-size: 11px; font-weight: 700; color: var(--accent);
  padding: 4px 0; margin-top: 4px; border-bottom: 1px solid var(--tag);
}
.emo-wizard .wizard-summary {
  background: var(--bg-alt); border-radius: 8px; padding: 12px; font-size: 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.emo-wizard .wizard-summary dt { font-weight: 700; color: var(--primary); display: inline; }
.emo-wizard .wizard-summary dd { display: inline; margin: 0; margin-left: 4px; }
.emo-wizard .assoc-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px;
}
.emo-wizard .assoc-row label { min-width: 90px; font-weight: 600; color: var(--muted); font-size: 12px; }
.emo-wizard .assoc-row select, .emo-wizard .assoc-row input { flex: 1; max-width: 300px; }
.emo-tag-added {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px;
  background: #D5E8D0; border-radius: 12px; font-size: 11px; font-weight: 600; color: var(--primary);
}

/* ========== RECHERCHE GLOBALE ========== */
.global-search-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.5); display: flex; align-items: flex-start; justify-content: center;
  padding-top: 80px;
}
.global-search-card {
  background: var(--white); border-radius: 12px; width: 100%; max-width: 600px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2); overflow: hidden;
}
.global-search-input {
  width: 100%; padding: 16px 20px; font-size: 16px; border: none; outline: none;
  border-bottom: 2px solid var(--accent);
}
.global-search-results {
  max-height: 400px; overflow-y: auto; padding: 4px 0;
}
.global-search-results .gs-group {
  padding: 4px 16px; font-size: 11px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; background: var(--bg-alt);
}
.global-search-results .gs-item {
  padding: 8px 16px; cursor: pointer; display: flex; align-items: center; gap: 8px;
  font-size: 13px; border-bottom: 1px solid var(--bg-alt);
}
.global-search-results .gs-item:hover { background: #F0F7EE; }
.global-search-results .gs-id { color: var(--muted); font-size: 11px; min-width: 50px; }
.global-search-results .gs-name { font-weight: 600; }
.global-search-results .gs-meta { color: var(--muted); font-size: 11px; margin-left: auto; }
.global-search-results .gs-empty { padding: 20px; text-align: center; color: var(--muted); font-size: 13px; }
.nav-search-btn {
  background: rgba(255,255,255,0.15); border: none; color: var(--white);
  width: 32px; height: 32px; border-radius: 6px; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center; margin-left: 8px;
}
.nav-search-btn:hover { background: rgba(255,255,255,0.25); }

/* ========== TOOLTIP ALLERGIES CROISEES ========== */
.cross-cell {
  position: relative; cursor: help;
}
.cross-cell .cross-tooltip {
  display: none; position: absolute; z-index: 300;
  bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: 280px; padding: 12px 14px;
  background: var(--primary); color: var(--white);
  border-radius: 10px; font-size: 12px; line-height: 1.5;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  pointer-events: none;
}
.cross-cell .cross-tooltip::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--primary);
}
.cross-cell:hover .cross-tooltip { display: block; }
.cross-tooltip-title {
  font-weight: 700; font-size: 13px; margin-bottom: 6px;
  padding-bottom: 4px; border-bottom: 1px solid rgba(255,255,255,0.2);
  display: flex; align-items: center; gap: 6px;
}
.cross-tooltip-badge {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  background: var(--accent); font-size: 10px; font-weight: 600;
}
.cross-tooltip-body { font-size: 11px; opacity: 0.9; }

/* ========== CROISEMENT SYMPTOMES ========== */
.cross-selected-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; min-height: 0; }
.cross-selected-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px 4px 12px; border-radius: 16px;
  background: var(--accent); color: var(--white); font-size: 12px; font-weight: 600;
  user-select: none; animation: fadeIn 0.15s;
}
.cross-selected-tag .remove-tag {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.25); color: var(--white); font-size: 13px;
  cursor: pointer; line-height: 1; padding: 0; margin-left: 2px;
}
.cross-selected-tag .remove-tag:hover { background: rgba(255,255,255,0.45); }
@keyframes fadeIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
.cross-cat-select {
  width: 100%; padding: 9px 12px; border-radius: 8px; border: 1.5px solid var(--tag);
  background: var(--white); font-size: 13px; color: var(--text); cursor: pointer;
  margin-bottom: 10px; appearance: auto;
}
.cross-cat-select:focus { border-color: var(--accent); outline: none; }
.cross-symptom-selector { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.cross-chip {
  padding: 5px 14px; border-radius: 20px; border: 1.5px solid var(--tag);
  background: var(--white); color: var(--text); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.15s; user-select: none;
}
.cross-chip:hover { border-color: var(--accent); }
.cross-chip.selected { background: var(--accent); color: var(--white); border-color: var(--accent); }
.cross-no-results { font-size: 13px; color: var(--muted); font-style: italic; padding: 8px 0; }
.cross-results { margin-top: 16px; }
.cross-vial-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-bottom: 1px solid var(--tag); transition: background 0.1s;
}
.cross-vial-row:hover { background: var(--bg-alt); }
.cross-score-bar {
  height: 6px; border-radius: 3px; background: var(--accent); transition: width 0.3s;
}
.cross-score-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 24px; border-radius: 12px;
  font-size: 12px; font-weight: 700; color: var(--white); flex-shrink: 0;
}
.cross-source-tag {
  display: inline-block; padding: 1px 6px; border-radius: 8px;
  font-size: 10px; font-weight: 600; margin-right: 3px;
}
.cross-source-tag.p1 { background: #FADBD8; color: var(--p1); }
.cross-source-tag.p2 { background: #FDEBD0; color: #B7600A; }
.cross-source-tag.p3 { background: #FCF3CF; color: #7D6608; }
.cross-source-tag.p4 { background: #D6EAF8; color: #1A5276; }
.cross-apply-btn {
  margin-top: 12px; width: 100%;
}

/* ========== TIMELINE ========== */
.timeline-table { width: 100%; border-collapse: collapse; font-size: 13px; overflow-x: auto; display: block; }
.timeline-table th {
  padding: 6px 8px; text-align: center; font-size: 11px; font-weight: 700;
  color: var(--muted); border-bottom: 2px solid var(--accent); white-space: nowrap;
}
.timeline-table th:first-child { text-align: left; min-width: 140px; position: sticky; left: 0; background: var(--white); z-index: 1; }
.timeline-table td { padding: 5px 8px; text-align: center; border-bottom: 1px solid var(--tag); }
.timeline-table td:first-child {
  text-align: left; font-weight: 600; font-size: 12px; white-space: nowrap;
  position: sticky; left: 0; background: var(--white); z-index: 1;
}
.timeline-dot {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%;
  line-height: 18px; text-align: center; font-size: 9px; font-weight: 700; color: var(--white);
}
.timeline-dot.faible { background: var(--p1); }
.timeline-dot.fort { background: #27AE60; }
.timeline-dot.neutre { background: var(--tag); color: var(--muted); }
.timeline-dot.empty { background: transparent; border: 1.5px dashed var(--tag); }
.timeline-persistent {
  display: inline-block; padding: 1px 8px; border-radius: 8px; font-size: 11px; font-weight: 600;
  background: #FADBD8; color: var(--p1); margin-left: 4px;
}
.timeline-resolved {
  display: inline-block; padding: 1px 8px; border-radius: 8px; font-size: 11px; font-weight: 600;
  background: #D5F5E3; color: #1E8449; margin-left: 4px;
}
.timeline-suggestion {
  padding: 10px 14px; background: var(--bg-alt); border-radius: 8px;
  border-left: 3px solid var(--accent); margin-top: 12px; font-size: 13px;
}

/* ========== CONTRE-INDICATIONS ========== */
.ci-alert {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 8px; font-size: 11px; font-weight: 600;
  background: #FEF3E2; color: #B7600A; border: 1px solid #F5CBA7;
}
.ci-alert-banner {
  padding: 8px 14px; background: #FEF3E2; border: 1px solid #F5CBA7;
  border-radius: 8px; margin-bottom: 12px; font-size: 13px; color: #7D5A00;
}

/* ========== ONBOARDING ========== */
.onboarding-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  animation: obFadeIn 0.25s;
}
@keyframes obFadeIn { from { opacity: 0; } to { opacity: 1; } }
.onboarding-card {
  background: var(--white); border-radius: 16px; padding: 32px 28px 24px;
  max-width: 440px; width: 90%; box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  text-align: center; animation: obSlideUp 0.3s;
}
@keyframes obSlideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.onboarding-icon { font-size: 40px; margin-bottom: 12px; }
.onboarding-title { font-size: 20px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.onboarding-desc { font-size: 14px; color: var(--muted); line-height: 1.6; margin-bottom: 20px; }
.onboarding-legend { display: inline-flex; flex-direction: column; gap: 6px; text-align: left; margin-bottom: 18px; }
.onboarding-legend-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.onboarding-legend-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.onboarding-dots { display: flex; gap: 8px; justify-content: center; margin-bottom: 18px; }
.onboarding-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tag); transition: all 0.2s; }
.onboarding-dot.active { background: var(--accent); width: 20px; border-radius: 4px; }
.onboarding-actions { display: flex; gap: 10px; justify-content: center; }
.onboarding-actions .btn { min-width: 100px; }
.onboarding-skip { background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; text-decoration: underline; }
.onboarding-skip:hover { color: var(--text); }
.nav-help-btn {
  background: none; border: 1.5px solid var(--tag); border-radius: 50%; width: 28px; height: 28px;
  font-size: 14px; font-weight: 700; color: var(--muted); cursor: pointer; margin-left: 6px;
  display: inline-flex; align-items: center; justify-content: center;
}
.nav-help-btn:hover { border-color: var(--accent); color: var(--accent); }
