/* ============================================================
   SIH - Suivi Hypotension Intracranienne
   Design Medical - Propre, Elegant, Accessible
   ============================================================ */

:root {
  /* Doux et chaleureux : bleu apaisant + fond creme */
  --sih-primary:       #3D6E89;     /* bleu profond doux */
  --sih-primary-light: #5B95B0;     /* bleu clair */
  --sih-primary-pale:  #E6EFF4;     /* bleu tres pale */
  --sih-secondary:     #6B9080;     /* vert sauge */
  --sih-secondary-pale:#E2EDE7;
  --sih-accent:        #D4A574;     /* terracotta doux */
  --sih-danger:        #B85C5C;     /* corail */
  --sih-danger-pale:   #F5E1E1;
  --sih-warning:       #D4A574;     /* peche */
  --sih-warning-pale:  #FAEFDF;
  --sih-success:       #6B9080;
  --sih-success-pale:  #E2EDE7;
  --sih-bg:            #FAF8F4;     /* creme tres pale */
  --sih-card:          #FFFFFF;
  --sih-text:          #2C3E50;     /* gris-bleu profond */
  --sih-text-muted:    #8B9AAA;     /* gris-bleu doux */
  --sih-border:        #E8E2D8;     /* beige tres pale */
  --sih-border-light:  #F0EBE0;
  --sih-sidebar-width: 240px;
  --sih-shadow:        0 1px 3px rgba(60,80,100,.06), 0 4px 16px rgba(60,80,100,.05);
  --sih-shadow-hover:  0 4px 12px rgba(60,80,100,.10), 0 8px 24px rgba(60,80,100,.06);
  --sih-radius:        14px;
  --sih-radius-sm:     10px;
}

.hidden { display: none !important; }

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--sih-bg);
  color: var(--sih-text);
  font-size: 15px;
  line-height: 1.6;
  margin: 0;
  padding: 0 !important;
}

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

/* ---- Layout ---- */
.sih-wrapper { display: flex; min-height: 100vh; }

.sih-sidebar {
  width: var(--sih-sidebar-width);
  background: #ffffff;
  color: var(--sih-text);
  border-right: 1px solid var(--sih-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
  overflow-y: auto;
}

.sih-main {
  margin-left: var(--sih-sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sih-topbar {
  background: var(--sih-card);
  border-bottom: 1px solid var(--sih-border-light);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.sih-content { padding: 2rem; flex: 1; max-width: 1400px; width: 100%; }

/* ---- Global health appreciation badge (clinician dashboard) ---- */
.sih-health-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .35rem .85rem; border-radius: 50px; font-size: .8rem; font-weight: 600;
  white-space: nowrap;
}
.sih-health-badge::before { content: ''; width: 8px; height: 8px; border-radius: 50%; }
.sih-health-good    { background: var(--sih-success-pale); color: #4A6B5A; }
.sih-health-good::before    { background: var(--sih-success); }
.sih-health-moderate{ background: var(--sih-warning-pale); color: #8B6431; }
.sih-health-moderate::before{ background: var(--sih-warning); }
.sih-health-severe  { background: var(--sih-danger-pale); color: #8B4242; }
.sih-health-severe::before  { background: var(--sih-danger); }
.sih-health-na      { background: #F0EBE0; color: var(--sih-text-muted); }
.sih-health-na::before      { background: var(--sih-text-muted); }

/* ---- Sidebar (epuree, blanche) ---- */
.sih-logo { padding: 1.75rem 1.25rem 1.25rem; border-bottom: 1px solid var(--sih-border-light); text-align: center; }
.sih-logo h1 { font-size: 1rem; font-weight: 600; margin: 0; color: var(--sih-primary); letter-spacing: .2px; }
.sih-logo p  { font-size: .75rem; color: var(--sih-text-muted); margin: .25rem 0 0; }

.sih-nav { padding: 1rem .5rem; flex: 1; }
.sih-nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: 1.2px; color: var(--sih-text-muted); padding: .85rem .75rem .35rem; font-weight: 600; }

.sih-nav a {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem .85rem;
  color: var(--sih-text); font-size: .9rem; font-weight: 500;
  border-radius: var(--sih-radius-sm);
  margin: 2px 0;
  transition: all .15s;
}
.sih-nav a:hover { background: var(--sih-bg); color: var(--sih-primary); text-decoration: none; }
.sih-nav a.active { background: var(--sih-primary-pale); color: var(--sih-primary); font-weight: 600; }
.sih-nav a svg { flex-shrink: 0; width: 18px; height: 18px; opacity: .85; }

.sih-nav-footer { padding: 1rem; border-top: 1px solid var(--sih-border-light); }
.sih-nav-footer a { display: flex; align-items: center; gap: .55rem; color: var(--sih-text-muted); font-size: .82rem; padding: .5rem .75rem; border-radius: var(--sih-radius-sm); }
.sih-nav-footer a:hover { background: var(--sih-bg); color: var(--sih-text); text-decoration: none; }

/* ---- Cards ---- */
.sih-card { background: var(--sih-card); border-radius: var(--sih-radius); box-shadow: var(--sih-shadow); border: 1px solid var(--sih-border-light); transition: box-shadow .2s; }
.sih-card-header { padding: 1.25rem 1.75rem; border-bottom: 1px solid var(--sih-border-light); display: flex; align-items: center; justify-content: space-between; }
.sih-card-header h2, .sih-card-header h3 { margin: 0; font-size: 1.05rem; font-weight: 600; color: var(--sih-text); letter-spacing: .1px; }
.sih-card-body { padding: 1.5rem 1.75rem; }

/* ---- Stat cards ---- */
.sih-stat { background: var(--sih-card); border-radius: var(--sih-radius); box-shadow: var(--sih-shadow); border: 1px solid var(--sih-border); padding: 1.25rem; display: flex; align-items: flex-start; gap: 1rem; }
.sih-stat-icon { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sih-stat-icon.blue   { background: var(--sih-primary-pale); color: var(--sih-primary); }
.sih-stat-icon.green  { background: var(--sih-secondary-pale); color: var(--sih-secondary); }
.sih-stat-icon.orange { background: #FEF3E8; color: var(--sih-accent); }
.sih-stat-icon.red    { background: #FDEDEC; color: var(--sih-danger); }
.sih-stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.sih-stat-label { font-size: .8rem; color: var(--sih-text-muted); margin-top: .2rem; }

/* ---- Badges ---- */
.sih-badge { display: inline-block; padding: .2rem .65rem; border-radius: 50px; font-size: .75rem; font-weight: 600; }
.sih-badge-success { background: var(--sih-secondary-pale); color: var(--sih-secondary); }
.sih-badge-warning { background: #FEF3E8; color: var(--sih-accent); }
.sih-badge-danger  { background: #FDEDEC; color: var(--sih-danger); }
.sih-badge-neutral { background: #EEF2F7; color: var(--sih-text-muted); }
.sih-badge-primary { background: var(--sih-primary-pale); color: var(--sih-primary); }

/* ---- Buttons ---- */
.sih-btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .65rem 1.25rem; border-radius: var(--sih-radius-sm); font-size: .9rem; font-weight: 500; cursor: pointer; border: none; transition: all .15s; text-decoration: none; line-height: 1.2; }
.sih-btn-primary    { background: var(--sih-primary); color: #fff; }
.sih-btn-primary:hover { background: #2F5970; color: #fff; text-decoration: none; box-shadow: 0 2px 8px rgba(60,110,137,.25); }
.sih-btn-secondary  { background: var(--sih-primary-pale); color: var(--sih-primary); }
.sih-btn-secondary:hover { background: #D5E4ED; color: var(--sih-primary); text-decoration: none; }
.sih-btn-success    { background: var(--sih-secondary); color: #fff; }
.sih-btn-success:hover { background: #56776A; color: #fff; text-decoration: none; box-shadow: 0 2px 8px rgba(107,144,128,.25); }
.sih-btn-danger     { background: var(--sih-danger); color: #fff; }
.sih-btn-outline    { background: transparent; border: 1.5px solid var(--sih-border); color: var(--sih-text); }
.sih-btn-outline:hover { border-color: var(--sih-primary); color: var(--sih-primary); background: var(--sih-bg); text-decoration: none; }
.sih-btn-sm { padding: .4rem .85rem; font-size: .82rem; }
.sih-btn-lg { padding: .85rem 1.75rem; font-size: 1rem; }

/* ---- Forms ---- */
.sih-form-group { margin-bottom: 1.25rem; }
.sih-label { display: block; font-size: .875rem; font-weight: 500; color: var(--sih-text); margin-bottom: .4rem; }
.sih-input, .sih-select, .sih-textarea { width: 100%; padding: .625rem .875rem; border: 1.5px solid var(--sih-border); border-radius: 8px; font-size: .875rem; color: var(--sih-text); background: #fff; transition: border-color .15s, box-shadow .15s; font-family: inherit; }
.sih-input:focus, .sih-select:focus, .sih-textarea:focus { outline: none; border-color: var(--sih-primary-light); box-shadow: 0 0 0 3px rgba(46,134,193,.15); }
.sih-textarea { resize: vertical; min-height: 100px; }

/* ---- Radio groups (questionnaires) ---- */
.sih-radio-group { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.sih-radio-btn input[type=radio] { display: none; }
.sih-radio-btn label { display: inline-flex; align-items: center; justify-content: center; padding: .5rem .85rem; border-radius: 8px; border: 1.5px solid var(--sih-border); cursor: pointer; font-size: .83rem; transition: all .15s; min-width: 70px; text-align: center; line-height: 1.3; }
.sih-radio-btn input[type=radio]:checked + label { background: var(--sih-primary); border-color: var(--sih-primary); color: #fff; font-weight: 600; }
.sih-radio-btn label:hover { border-color: var(--sih-primary-light); color: var(--sih-primary); }

/* ---- Questionnaire blocks ---- */
.sih-question-block { padding: 1.25rem 0; border-bottom: 1px solid var(--sih-border); }
.sih-question-block:last-child { border-bottom: none; }
.sih-question-text { font-size: .925rem; font-weight: 500; margin-bottom: .75rem; line-height: 1.5; display: flex; align-items: flex-start; gap: .5rem; }
.sih-question-num { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; background: var(--sih-primary-pale); color: var(--sih-primary); border-radius: 50%; font-size: .75rem; font-weight: 700; flex-shrink: 0; margin-top: .1rem; }

/* ---- Table layout for THI/DHI ---- */
.sih-q-table { width: 100%; border-collapse: collapse; }
.sih-q-table thead th { background: var(--sih-primary-pale); color: var(--sih-primary); padding: .6rem 1rem; font-size: .8rem; text-align: center; }
.sih-q-table thead th:first-child { text-align: left; }
.sih-q-table td { padding: .6rem 1rem; border-bottom: 1px solid var(--sih-border); font-size: .875rem; }
.sih-q-table tr:hover td { background: var(--sih-bg); }
.sih-q-table .q-options { text-align: center; }
.sih-q-table .q-options label { cursor: pointer; margin: 0 .4rem; font-size: .85rem; }
.sih-q-table .q-options input[type=radio] { accent-color: var(--sih-primary); margin-right: .2rem; }

/* ---- EVA Slider ---- */
.sih-slider-container { padding: .5rem 0; }
.sih-slider { -webkit-appearance: none; width: 100%; height: 8px; border-radius: 4px; background: var(--sih-border); outline: none; }
.sih-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: var(--sih-primary); cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.sih-slider::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: var(--sih-primary); cursor: pointer; border: none; }
.sih-slider-labels { display: flex; justify-content: space-between; font-size: .75rem; color: var(--sih-text-muted); margin-top: .35rem; }
.sih-slider-value { font-size: 2.5rem; font-weight: 700; color: var(--sih-primary); text-align: center; line-height: 1; }

/* ---- Progress ---- */
.sih-progress { height: 8px; background: var(--sih-border); border-radius: 4px; overflow: hidden; }
.sih-progress-bar { height: 100%; background: linear-gradient(90deg, var(--sih-primary-light), var(--sih-secondary)); border-radius: 4px; transition: width .4s ease; }

/* ---- Tables ---- */
.sih-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.sih-table th { text-align: left; padding: .75rem 1rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; color: var(--sih-text-muted); border-bottom: 2px solid var(--sih-border); }
.sih-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--sih-border); }
.sih-table tr:hover td { background: var(--sih-bg); }
.sih-table-container { overflow-x: auto; }

/* ---- Alerts / Flashes ---- */
.sih-alert { padding: .875rem 1rem; border-radius: 8px; margin-bottom: 1rem; display: flex; align-items: flex-start; gap: .75rem; font-size: .875rem; }
.sih-alert-success { background: var(--sih-secondary-pale); color: #0d5726; border-left: 4px solid var(--sih-success); }
.sih-alert-warning { background: #FEF3E8; color: #7D4B00; border-left: 4px solid var(--sih-warning); }
.sih-alert-danger  { background: #FDEDEC; color: #7B241C; border-left: 4px solid var(--sih-danger); }
.sih-alert-info    { background: var(--sih-primary-pale); color: var(--sih-primary); border-left: 4px solid var(--sih-primary-light); }

/* ---- Scores ---- */
.sih-score-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.sih-score-item { background: var(--sih-bg); border-radius: 8px; padding: .875rem; text-align: center; border: 1px solid var(--sih-border); }
.sih-score-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .5px; color: var(--sih-text-muted); margin-bottom: .3rem; }
.sih-score-value { font-size: 1.5rem; font-weight: 700; color: var(--sih-primary); }
.sih-score-value.good    { color: var(--sih-success); }
.sih-score-value.warning { color: var(--sih-warning); }
.sih-score-value.bad     { color: var(--sih-danger); }

/* ---- Patient & Clinician Login (blue background, centered card) ---- */
.sih-login-wrapper {
  min-height: 100vh;
  min-width:100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sih-primary);
  /*padding: 2rem 1rem;*/
}
.sih-login-pane {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.sih-login-box {
  background: #fff;
  width: 100%;
  max-width: 480px;
  padding: 2.75rem 2.25rem;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .15);
}
.sih-login-logo { margin-bottom: 2rem; text-align: center; }
.sih-login-logo h1 { font-size: 1.6rem; font-weight: 700; color: var(--sih-text); margin: 0 0 .4rem; letter-spacing: -.01em; }
.sih-login-logo p  { font-size: .95rem; color: var(--sih-text-muted); margin: 0; }
@media (max-width: 600px) {
  /*.sih-login-wrapper { padding: 1rem; }
  .sih-login-box { padding: 2rem 1.5rem; }*/
}
.sih-code-input { font-size: 1.8rem; font-weight: 700; text-align: center; letter-spacing: .3rem; text-transform: uppercase; font-family: 'Courier New', monospace; border: 2.5px solid var(--sih-border); border-radius: 12px; padding: 1rem; width: 100%; color: var(--sih-primary); }
.sih-code-input:focus { outline: none; border-color: var(--sih-primary-light); box-shadow: 0 0 0 4px rgba(46,134,193,.2); }

/* ---- Charts ---- */
.sih-chart-container { position: relative; width: 100%; height: 340px; }

/* ---- Page header ---- */
.sih-page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.sih-page-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.sih-page-header p  { font-size: .875rem; color: var(--sih-text-muted); margin: .25rem 0 0; }
.sih-page-header-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---- Grid helpers ---- */
.sih-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.sih-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.sih-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

/* ---- Report ---- */
.sih-report-section { margin-bottom: 2rem; }
.sih-report-section h3 { color: var(--sih-primary); border-bottom: 2px solid var(--sih-primary-pale); padding-bottom: .5rem; font-size: 1.05rem; }
.sih-report-interp { background: var(--sih-bg); padding: 1rem 1.25rem; border-radius: 8px; font-size: .9rem; line-height: 1.7; border-left: 3px solid var(--sih-primary-light); }

/* ---- Questionnaire step indicator ---- */
.sih-steps { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.sih-step { width: 10px; height: 10px; border-radius: 50%; background: var(--sih-border); }
.sih-step.done  { background: var(--sih-success); }
.sih-step.active { background: var(--sih-primary-light); }

/* ============================================================
   Responsive — sidebar drawer + backdrop
   ≤ 768px : tablet / mobile (sidebar coulissante)
   ≤ 480px : mobile compact (logo réduit, topbar épurée)
   ============================================================ */

/* Backdrop derrière la sidebar mobile */
.sih-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 45, .45);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
  z-index: 90;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sih-backdrop.visible { opacity: 1; visibility: visible; }
body.sidebar-open { overflow: hidden; }

/* Hamburger : caché sur desktop, visible en mobile */
.sih-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: .5rem;
  border-radius: 8px;
  color: var(--sih-text);
  transition: background .15s ease, transform .15s ease;
}
.sih-hamburger:hover { background: var(--sih-primary-pale); }
.sih-hamburger:active { transform: scale(.95); }

/* Transition douce sur la sidebar */
.sih-sidebar { transition: transform .3s cubic-bezier(.4, 0, .2, 1); }
@media (prefers-reduced-motion: reduce) {
  .sih-sidebar, .sih-backdrop { transition: none; }
}

/* Tablettes & mobiles */
@media (max-width: 768px) {
  .sih-sidebar {
    transform: translateX(-100%);
    width: min(280px, 85vw);
    box-shadow: 0 10px 40px rgba(0, 0, 0, .15);
  }
  .sih-sidebar.mobile-open { transform: translateX(0); }

  .sih-main { margin-left: 0; }
  .sih-content { padding: 1rem; }

  .sih-topbar {
    padding: .75rem 1rem;
    gap: .75rem;
  }
  .sih-topbar > span:last-child { display: none; }

  .sih-hamburger { display: inline-flex; }

  .sih-grid-2, .sih-grid-3, .sih-grid-4 { grid-template-columns: 1fr; }
  .sih-score-grid { grid-template-columns: repeat(2, 1fr); }

  .sih-page-header { flex-direction: column; align-items: stretch; }
  .sih-page-header-actions { width: 100%; }
  .sih-page-header-actions .sih-btn { flex: 1; justify-content: center; }

  /* Symptom history table — scroll horizontal */
  .sih-table-wrapper,
  .sih-table-container,
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sih-table { font-size: .875rem; min-width: 480px; }

  /* Questionnaire tables (THI/DHI/SF36) → stacked card layout */
  .sih-q-table thead { display: none; }
  .sih-q-table tr {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .875rem 0;
    border-bottom: 1px solid var(--sih-border);
    border-top: none;
  }
  .sih-q-table td {
    display: block;
    padding: 0;
    border: none;
    font-size: .875rem;
  }
  .sih-q-table td:first-child {
    flex: 0 0 100%;
    font-weight: 500;
    line-height: 1.5;
    padding-bottom: .25rem;
  }
  .sih-q-table td.q-options {
    flex: 1 1 auto;
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    align-items: center;
    justify-content: center;
    padding: 0;
  }
  .sih-q-table .q-options label {
    display: flex;
    align-items: center;
    gap: .3rem;
    padding: .45rem .65rem;
    border: 1.5px solid var(--sih-border);
    border-radius: 8px;
    cursor: pointer;
    font-size: .82rem;
    white-space: nowrap;
    background: #fff;
    min-height: 40px;
    line-height: 1.3;
  }
  .sih-q-table .q-options input[type=radio] {
    accent-color: var(--sih-primary);
    width: 16px; height: 16px;
    flex-shrink: 0;
    cursor: pointer;
    margin: 0;
  }
  .sih-q-table .q-options label:has(input:checked) {
    background: var(--sih-primary-pale);
    border-color: var(--sih-primary-light);
    color: var(--sih-primary);
    font-weight: 600;
  }

  .sih-card-body { padding: 1rem; }
  .sih-card-header { padding: .85rem 1rem; }

  /* Chart container — hauteur explicite pour maintainAspectRatio:false */
  .sih-chart-container { height: 260px; }

  /* Patient mode — overrides pour mobile */
  .patient-mode .sih-content { padding: 1rem; }
  .patient-mode .sih-card-body { padding: 1.25rem; }
  .patient-mode .sih-card-header { padding: 1rem 1.25rem; }
  .patient-mode .sih-radio-btn label { padding: .6rem .9rem; font-size: .9rem; }
  .patient-mode .sih-question-block { padding: 1rem 0; }
}

/* Mobile compact */
@media (max-width: 480px) {
  .sih-content { padding: .75rem; }
  .sih-topbar { padding: .6rem .75rem; }
  .sih-topbar > span:first-of-type { font-size: .9rem; }
  .sih-score-grid { grid-template-columns: 1fr; }
  .sih-logo h1 { font-size: 1.1rem; }
  .sih-logo img { height: 36px !important; }
}

/* Desktop : sidebar toujours visible, backdrop & hamburger masqués */
@media (min-width: 769px) {
  .sih-sidebar { transform: translateX(0) !important; }
  .sih-main { margin-left: var(--sih-sidebar-width) !important; }
  .sih-backdrop { display: none !important; }
  .sih-hamburger { display: none !important; }
}

/* ---- Utilities ---- */
.mb-0 { margin-bottom: 0 !important; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.text-muted { color: var(--sih-text-muted); }
.text-center { text-align: center; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.w-100 { width: 100%; }

@media print {
  .sih-sidebar, .sih-topbar, .no-print { display: none !important; }
  .sih-main { margin-left: 0; }
  .sih-content { padding: 0; }
  body { background: white; font-size: 12px; }
  .sih-card { box-shadow: none; border: 1px solid #ddd; }
}

/* ── Inline score classes for dashboard table ─────────────────── */
.sih-score-bad  { color: var(--sih-danger); font-weight: 700; }
.sih-score-warn { color: var(--sih-warning, #E67E22); font-weight: 600; }
.sih-score-ok   { color: var(--sih-success); font-weight: 600; }

/* ── Patient mode : confort de lecture (patient agee/douloureux) ── */
.patient-mode { font-size: 17px; line-height: 1.7; }
.patient-mode .sih-content { max-width: 1100px; padding: 2.5rem; }
.patient-mode h1 { font-size: 1.7rem; letter-spacing: -.01em; }
.patient-mode h2 { font-size: 1.35rem; }
.patient-mode .sih-card { border-radius: 18px; padding: .25rem 0; }
.patient-mode .sih-card-body { padding: 2rem; }
.patient-mode .sih-card-header { padding: 1.25rem 2rem; }
.patient-mode .sih-btn {
  font-size: 1rem; padding: .9rem 1.6rem; min-height: 48px;
  border-radius: 12px;
}
.patient-mode .sih-btn-lg {
  font-size: 1.1rem; padding: 1rem 2rem; min-height: 54px;
}
.patient-mode .sih-nav a {
  font-size: 1rem; padding: .85rem 1rem; min-height: 48px;
}
.patient-mode .sih-input, .patient-mode .sih-select, .patient-mode .sih-textarea {
  font-size: 1.05rem; padding: .85rem 1rem; min-height: 48px;
}
.patient-mode label { font-size: 1rem; }
.patient-mode .sih-question-block { padding: 1.5rem; margin-bottom: 1.25rem; }
.patient-mode .sih-question-text { font-size: 1.05rem; line-height: 1.6; }
.patient-mode .sih-radio-btn label {
  padding: .75rem 1.1rem; min-height: 44px; font-size: .95rem;
}
.patient-mode .sih-slider { height: 10px; }
.patient-mode .sih-slider::-webkit-slider-thumb {
  width: 32px; height: 32px;
}
.patient-mode .sih-slider::-moz-range-thumb {
  width: 32px; height: 32px;
}
.patient-mode .sih-alert { font-size: 1rem; padding: 1.25rem 1.5rem; }
/* ── Mobile — consolidation des overrides ──────────────────────── */
@media (max-width: 768px) {
  /* Patient mode — confort de lecture adapté mobile */
  .patient-mode { font-size: 16px; }
  .patient-mode .sih-content { padding: 1rem; max-width: 100%; }
  .patient-mode .sih-card-body { padding: 1.25rem; }
  .patient-mode .sih-card-header { padding: 1rem 1.25rem; }
  .patient-mode .sih-question-block { padding: 1rem 0; margin-bottom: .75rem; }
  .patient-mode .sih-radio-btn label { padding: .65rem .9rem; min-height: 44px; font-size: .9rem; }

  /* Stats et grids */
  .sih-grid-4 { grid-template-columns: 1fr 1fr; }
  .sih-stat { padding: .875rem; }
  .sih-stat-value { font-size: 1.25rem; }

  /* Formulaires */
  .sih-questionnaire-row { min-height: 52px; }
  .sih-form-group label { font-size: .9rem; }
  .sih-input, .sih-select, .sih-textarea { font-size: 16px; } /* prevent iOS zoom */
}
@media (max-width: 480px) {
  .sih-grid-2, .sih-grid-4 { grid-template-columns: 1fr; }
  .sih-score-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.3rem; }
}

/* ── Fiches ressources (design Olivia Portalier) ──────────────── */
.fiche-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}
.fiche-tile {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: .35rem;
  padding: 1.5rem 1.4rem 1.4rem;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,.04);
  text-decoration: none;
  color: inherit;
  min-height: 180px;
  transition: transform .15s ease, box-shadow .15s ease;
  position: relative;
  overflow: hidden;
}
.fiche-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(0,0,0,.10);
  text-decoration: none;
}
.fiche-tile-num {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  opacity: .85;
}
.fiche-tile-title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}
.fiche-tile-summary {
  font-size: .82rem;
  line-height: 1.45;
  opacity: .85;
  margin: .25rem 0 0;
}
.fiche-tile-icon {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255,255,255,.65);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Fiche detail page */
.fiche-page {
  --c-bg: #F5E1D5;
  --c-fg: #A8633A;
  max-width: 920px;
  margin: 0 auto;
  color: #2a2a2a;
}
.fiche-back {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .88rem;
  color: var(--c-fg);
  text-decoration: none;
  margin-bottom: 1.5rem;
  font-weight: 500;
}
.fiche-back:hover { text-decoration: underline; }

.fiche-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
  padding-bottom: 1.5rem;
}
.fiche-head-text { flex: 1; min-width: 0; }
.fiche-eyebrow {
  font-size: .72rem;
  letter-spacing: .14em;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--c-fg);
  margin: 0 0 .65rem;
}
.fiche-h1 {
  font-size: 2.1rem;
  font-weight: 800;
  margin: 0 0 1rem;
  line-height: 1.15;
  color: #1f1f1f;
  letter-spacing: -.01em;
}
.fiche-lede {
  font-size: 1rem;
  line-height: 1.55;
  color: #555;
  margin: 0;
  max-width: 660px;
}
.fiche-head-icon {
  flex-shrink: 0;
  width: 92px;
  height: 92px;
  border-radius: 20px;
  background: var(--c-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-fg);
}
.fiche-rule {
  border: none;
  height: 3px;
  background: var(--c-fg);
  opacity: .55;
  border-radius: 2px;
  margin: 0 0 2rem;
}

.fiche-section { margin: 2rem 0; }
.fiche-section-title {
  font-size: .72rem;
  letter-spacing: .14em;
  font-weight: 700;
  text-transform: uppercase;
  color: #999;
  margin: 0 0 1.1rem;
}

.fiche-theory {
  position: relative;
  padding: .15rem 0 .15rem 1.1rem;
  border-left: 3px solid var(--c-fg);
  margin: 1rem 0;
}
.fiche-theory h3 {
  margin: 0 0 .25rem;
  color: var(--c-fg);
  font-size: .92rem;
  font-weight: 700;
}
.fiche-theory p {
  margin: 0;
  font-size: .9rem;
  line-height: 1.55;
  color: #555;
}

.fiche-tips {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: tip;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.fiche-tips li {
  counter-increment: tip;
  position: relative;
  padding: .9rem 1.15rem .9rem 3.25rem;
  background: var(--c-bg);
  border-radius: 10px;
  font-size: .92rem;
  line-height: 1.5;
  color: #3a3a3a;
}
.fiche-tips li::before {
  content: counter(tip);
  position: absolute;
  left: .85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: var(--c-fg);
  color: #fff;
  font-weight: 700;
  font-size: .78rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fiche-tips li strong { color: #2a2a2a; font-weight: 700; }

.fiche-callout {
  background: var(--c-bg);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin: 1.25rem 0;
}
.fiche-callout-title {
  font-weight: 700;
  color: var(--c-fg);
  margin: 0 0 .5rem;
  font-size: 1rem;
  text-align: center;
}
.fiche-callout-sub {
  margin: 0 0 1rem;
  font-size: .82rem;
  text-align: center;
  color: #777;
}
.fiche-callout p { margin: .5rem 0; font-size: .9rem; line-height: 1.55; }

/* Specific blocks */
.fiche-protocol {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--c-bg);
  border-radius: 14px;
  padding: 1.5rem;
  margin: 1.5rem 0;
}
.fiche-protocol-badge {
  flex-shrink: 0;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: rgba(255,255,255,.6);
  border: 2px solid var(--c-fg);
  color: var(--c-fg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.fiche-protocol-badge .num { font-size: 1.4rem; letter-spacing: .05em; }
.fiche-protocol-badge .lbl { font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; opacity: .9; }
.fiche-protocol-body { flex: 1; }
.fiche-protocol-body h3 { margin: 0 0 .5rem; color: var(--c-fg); font-size: 1rem; font-weight: 700; }
.fiche-protocol-tags { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0 .85rem; }
.fiche-protocol-tag {
  background: rgba(255,255,255,.55);
  border: 1px solid var(--c-fg);
  color: var(--c-fg);
  padding: .15rem .65rem;
  border-radius: 12px;
  font-size: .75rem;
  font-weight: 600;
}
.fiche-protocol-body p { margin: 0; font-size: .88rem; line-height: 1.5; color: #555; }

.fiche-techniques {
  background: var(--c-bg);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  margin: 1rem 0;
}
.fiche-techniques-title {
  text-align: center;
  font-weight: 700;
  color: var(--c-fg);
  margin: 0 0 1rem;
  font-size: 1rem;
}
.fiche-techniques-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.fiche-technique {
  background: rgba(255,255,255,.55);
  border-radius: 10px;
  padding: .85rem 1rem;
}
.fiche-technique .timing {
  font-size: .72rem;
  color: var(--c-fg);
  font-weight: 600;
  margin: 0 0 .25rem;
}
.fiche-technique .name {
  font-weight: 700;
  font-size: .95rem;
  margin: 0 0 .35rem;
  color: #2a2a2a;
}
.fiche-technique p { margin: 0; font-size: .82rem; line-height: 1.45; color: #555; }

.fiche-table-cognitive {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1rem 0;
  font-size: .85rem;
  background: var(--c-bg);
  border-radius: 10px;
  overflow: hidden;
}
.fiche-table-cognitive th {
  background: rgba(255,255,255,.4);
  color: var(--c-fg);
  text-align: left;
  padding: .65rem .85rem;
  font-weight: 600;
  font-size: .8rem;
}
.fiche-table-cognitive td {
  padding: 1.4rem .85rem;
  border-top: 1px solid rgba(255,255,255,.6);
}

.fiche-emergency {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e8e2d8;
}
.fiche-emergency-box {
  border-radius: 10px;
  padding: .9rem 1.15rem;
  font-size: .85rem;
  line-height: 1.5;
  border: 1px solid;
}
.fiche-emergency-box strong {
  display: block;
  font-size: .88rem;
  margin-bottom: .25rem;
}
.fiche-emergency-box.danger {
  background: #FBE9E7;
  border-color: #F0CFC7;
  color: #8B2E1F;
}
.fiche-emergency-box.warning {
  background: #FFF3E0;
  border-color: #F2DCB5;
  color: #8B5A1F;
}

.fiche-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e8e2d8;
}
.fiche-foot-author strong {
  display: block;
  color: var(--c-fg);
  font-size: .92rem;
}
.fiche-foot-author span {
  display: block;
  font-size: .78rem;
  color: #888;
}
.fiche-foot-num {
  font-size: .78rem;
  color: #999;
  font-weight: 500;
}

.fiche-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.fiche-print-btn {
  background: transparent;
  border: 1px solid var(--c-fg);
  color: var(--c-fg);
  padding: .45rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  transition: background .15s;
}
.fiche-print-btn:hover { background: var(--c-bg); }

@media print {
  .no-print { display: none !important; }
  .sih-sidebar, .sih-topbar { display: none !important; }
  .sih-content { padding: 0 !important; }
  .fiche-page { max-width: 100%; }
}

@media (max-width: 720px) {
  .fiche-head { flex-direction: column-reverse; gap: 1rem; }
  .fiche-head-icon { width: 64px; height: 64px; border-radius: 16px; }
  .fiche-h1 { font-size: 1.55rem; }
  .fiche-techniques-grid { grid-template-columns: 1fr; }
  .fiche-protocol { flex-direction: column; text-align: center; }
}
