/* ==========================================================================
   Journal Ménière · app.css : coquille applicative et composants
   ========================================================================== */

.app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

/* ---------- Barre supérieure ---------- */
.topbar {
  position: sticky; top: 0; z-index: 45;
  display: flex; align-items: center; gap: var(--sp-3);
  height: var(--topbar-h); padding-inline: clamp(10px, 2vw, 18px);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar .brand { margin-right: auto; }
.topbar-actions { display: flex; align-items: center; gap: var(--sp-2); }
.nav-toggle { display: none; }

/* ---------- Coquille ---------- */
.shell { flex: 1; display: flex; align-items: flex-start; width: 100%; }
.sidenav {
  position: sticky; top: var(--topbar-h);
  width: var(--sidenav-w); flex: none;
  height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  padding: var(--sp-4) var(--sp-3);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: var(--sp-4);
}
.nav-list { list-style: none; padding: 0; display: grid; gap: 2px; }
.nav-list a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--text-2); text-decoration: none; font-size: .93rem; font-weight: 500;
  transition: background-color .13s ease, color .13s ease;
}
.nav-list a svg { width: 19px; height: 19px; flex: none; opacity: .85; }
.nav-list a:hover { background: var(--surface-2); color: var(--text); }
.nav-list a.active { background: var(--primary-soft); color: var(--primary-soft-ink); font-weight: 650; }
.nav-list a.active svg { opacity: 1; }
.nav-foot { margin-top: auto; display: grid; gap: 6px; padding: var(--sp-3) 12px 0; border-top: 1px solid var(--border); }
.nav-mini { font-size: .82rem; color: var(--muted); text-decoration: none; }
.nav-mini:hover { color: var(--primary); }
.nav-version { font-size: .74rem; color: var(--muted); opacity: .7; }
.nav-scrim { position: fixed; inset: 0; background: rgba(4, 12, 20, .48); z-index: 44; }

.view { flex: 1; min-width: 0; outline: none; padding: clamp(16px, 3vw, 32px) clamp(14px, 3vw, 34px) calc(var(--sp-8) + env(safe-area-inset-bottom)); }
.view-in { max-width: var(--content); margin-inline: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); }

/* ---------- Barre d'onglets mobile ---------- */
.tabbar { display: none; }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .sidenav {
    position: fixed; top: 0; left: 0; z-index: 46;
    height: 100dvh; width: 264px; background: var(--surface);
    box-shadow: var(--shadow-3); transform: translateX(-102%);
    transition: transform .22s ease; padding-top: calc(var(--sp-4) + env(safe-area-inset-top));
  }
  .app.nav-open .sidenav { transform: translateX(0); }
  .view { padding-bottom: calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(12px); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: var(--tabbar-h); color: var(--muted); text-decoration: none; font-size: .68rem; font-weight: 600;
  }
  .tabbar a svg { width: 21px; height: 21px; }
  .tabbar a.active { color: var(--primary); }
}
@media (max-width: 420px) {
  .topbar .brand-name { display: none; }
}

/* ---------- Titres de vue ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-3); }
.page-head h1 { font-size: clamp(1.5rem, 1.2rem + 1.1vw, 2rem); }
.page-head .sub { color: var(--muted); font-size: .92rem; margin-top: 2px; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.input[type="date"], .input[type="time"] { max-width: 190px; }

/* ---------- Cartes ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-5); box-shadow: var(--shadow-1);
}
.card-tight { padding: var(--sp-4); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card-head h2, .card-head h3 { font-size: 1.05rem; letter-spacing: -.01em; }
.card-head .hint { font-size: .82rem; color: var(--muted); font-weight: 400; }
.card-note { font-size: .84rem; color: var(--muted); margin-top: var(--sp-3); }
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(155px, 100%), 1fr)); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.row-between { justify-content: space-between; }
.spacer { flex: 1; }

/* ---------- Statistiques ---------- */
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--sp-4); display: grid; gap: 3px; box-shadow: var(--shadow-1);
}
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }
.stat-value { font-size: 1.72rem; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-value small { font-size: .82rem; font-weight: 500; color: var(--muted); margin-left: 3px; }
.stat-sub { font-size: .8rem; color: var(--muted); }
.trend { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; font-weight: 650; border-radius: var(--r-full); padding: 2px 8px; }
.trend-up { background: var(--danger-soft); color: var(--danger); }
.trend-down { background: var(--ok-soft); color: var(--ok); }
.trend-flat { background: var(--surface-2); color: var(--muted); }
.trend-good-up { background: var(--ok-soft); color: var(--ok); }
.trend-bad-down { background: var(--danger-soft); color: var(--danger); }

/* ---------- Badges / puces ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--r-full); font-size: .77rem; font-weight: 650; background: var(--surface-2); color: var(--text-2); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--primary-soft-ink); }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--muted); }

.callout { border-radius: var(--r-md); padding: var(--sp-4); font-size: .9rem; border: 1px solid; display: flex; gap: var(--sp-3); }
.callout p + p { margin-top: var(--sp-2); }
.callout-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 35%, transparent); color: var(--text-2); }
.callout-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 38%, transparent); color: var(--text-2); }
.callout-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 38%, transparent); color: var(--text-2); }
.callout-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--text-2); }
.callout strong { color: var(--text); }
.callout-ico { width: 20px; height: 20px; flex: none; margin-top: 2px; }

.empty { text-align: center; padding: var(--sp-7) var(--sp-4); color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: var(--sp-2); }
.empty p { max-width: 46ch; margin-inline: auto; font-size: .93rem; }
.empty .btn { margin-top: var(--sp-4); }

/* ==========================================================================
   Contrôles de formulaire
   ========================================================================== */
.field { display: grid; gap: 6px; }
.field-label { font-size: .88rem; font-weight: 650; color: var(--text); }
.field-help { font-size: .79rem; color: var(--muted); }
.field-row { display: flex; align-items: center; gap: var(--sp-3); }

.input, .select, .textarea {
  width: 100%; padding: 10px 13px; min-height: 44px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  transition: border-color .14s ease, box-shadow .14s ease;
  font-size: .95rem;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 38px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 19px) 50%, calc(100% - 13px) 50%;
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; cursor: pointer; }
.input-sm { min-height: 36px; padding: 6px 10px; font-size: .88rem; }
.input-num { max-width: 130px; font-variant-numeric: tabular-nums; }
input[type="date"], input[type="time"] { min-width: 0; }

/* ---------- Curseur (échelle 0-10) ---------- */
.scale { display: grid; gap: 7px; padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); }
.scale:last-child { border-bottom: none; }
.scale-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.scale-title { font-size: .93rem; font-weight: 650; }
.scale-title .q { color: var(--muted); font-weight: 400; font-size: .82rem; margin-left: 6px; }
.scale-out { display: flex; align-items: baseline; gap: 7px; flex: none; }
.scale-num { font-size: 1.16rem; font-weight: 750; font-variant-numeric: tabular-nums; min-width: 2.4ch; text-align: right; }
.scale-word { font-size: .79rem; color: var(--muted); text-align: right; min-width: 8ch; }
.range { --pct: 0%; -webkit-appearance: none; appearance: none; width: 100%; height: 26px; background: transparent; cursor: pointer; }
.range::-webkit-slider-runnable-track {
  height: 8px; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--rng, var(--primary)) var(--pct), var(--surface-3) var(--pct));
}
.range::-moz-range-track { height: 8px; border-radius: var(--r-full); background: var(--surface-3); }
.range::-moz-range-progress { height: 8px; border-radius: var(--r-full); background: var(--rng, var(--primary)); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 24px; height: 24px; margin-top: -8px;
  border-radius: 50%; background: var(--surface); border: 3px solid var(--rng, var(--primary));
  box-shadow: var(--shadow-2); transition: transform .1s ease;
}
.range::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 3px solid var(--rng, var(--primary)); box-shadow: var(--shadow-2); }
.range:active::-webkit-slider-thumb { transform: scale(1.12); }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 45%, transparent); }
.range:focus-visible { outline: none; }
.scale-ticks { display: flex; justify-content: space-between; font-size: .7rem; color: var(--muted); padding-inline: 3px; }
.scale-unset .scale-num, .scale-unset .scale-word { opacity: .4; }

/* ---------- Segments, puces, interrupteurs ---------- */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-full); padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button {
  padding: 7px 15px; border-radius: var(--r-full); font-size: .86rem; font-weight: 600;
  color: var(--muted); transition: background-color .13s ease, color .13s ease; min-height: 34px;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; min-height: 36px; border-radius: var(--r-full);
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: .86rem; font-weight: 550; color: var(--text-2);
  transition: all .13s ease;
}
.chip:hover { border-color: var(--primary); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-soft-ink); font-weight: 650; }
.chip[aria-pressed="true"]::before { content: "✓"; font-weight: 800; }
.chip-add { border-style: dashed; color: var(--muted); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); }
.switch-row:last-child { border-bottom: none; }
.switch-text { display: grid; gap: 2px; }
.switch-text b { font-size: .93rem; font-weight: 650; }
.switch-text span { font-size: .81rem; color: var(--muted); }
.switch { position: relative; width: 48px; height: 28px; flex: none; border-radius: var(--r-full); background: var(--surface-3); border: 1px solid var(--border-strong); transition: background-color .16s ease, border-color .16s ease; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-1); transition: transform .16s ease; }
.switch[aria-checked="true"] { background: var(--primary); border-color: var(--primary); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

.checkline { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; cursor: pointer; }
.checkline input[type="checkbox"] { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--primary); flex: none; cursor: pointer; }
.checkline span { font-size: .92rem; }
.checkline small { display: block; font-size: .79rem; color: var(--muted); }

/* ---------- Sections repliables ---------- */
.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-1); overflow: hidden; }
.section + .section { margin-top: var(--sp-4); }
.section-head {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  padding: var(--sp-4) var(--sp-5); text-align: left; cursor: pointer;
}
.section-head:hover { background: var(--surface-2); }
.section-ico { width: 34px; height: 34px; border-radius: var(--r-sm); background: var(--primary-soft); color: var(--primary-soft-ink); display: grid; place-items: center; flex: none; }
.section-ico svg { width: 19px; height: 19px; }
.section-title { flex: 1; min-width: 0; }
.section-title b { display: block; font-size: .98rem; font-weight: 700; }
.section-title span { font-size: .8rem; color: var(--muted); }
.section-chev { width: 18px; height: 18px; color: var(--muted); transition: transform .18s ease; flex: none; }
.section[open] .section-chev, .section.open .section-chev { transform: rotate(180deg); }
.section-body { padding: 0 var(--sp-5) var(--sp-5); }
.section-body > .scale:first-child { padding-top: 0; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 520px; }
table.data th, table.data td { padding: 10px 13px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; background: var(--surface-2); position: sticky; top: 0; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.wrap { white-space: normal; min-width: 200px; }
table.data .row-btn { color: var(--primary); font-weight: 600; font-size: .84rem; }

/* ---------- Graphiques ---------- */
.chart-box { width: 100%; overflow-x: auto; }
.chart-box svg { width: 100%; height: auto; display: block; min-width: 320px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-3); font-size: .81rem; color: var(--text-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 11px; height: 11px; border-radius: 3px; display: block; }
.axis-line { stroke: var(--border); stroke-width: 1; }
.axis-text { fill: var(--muted); font-size: 10.5px; font-family: var(--font-sans); }
.grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; opacity: .75; }
.chart-title { fill: var(--text-2); font-size: 11.5px; font-weight: 600; font-family: var(--font-sans); }
.pt-hit { cursor: pointer; }

/* ---------- Calendrier heatmap ---------- */
.heat { display: grid; gap: 3px; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); overflow-x: auto; padding-bottom: 4px; }
.heat-cell { width: 14px; height: 14px; border-radius: 3px; background: var(--sev-0); border: 1px solid transparent; cursor: pointer; }
.heat-cell:hover { border-color: var(--text); }
.heat-cell.s1 { background: var(--sev-1); } .heat-cell.s2 { background: var(--sev-2); }
.heat-cell.s3 { background: var(--sev-3); } .heat-cell.s4 { background: var(--sev-4); } .heat-cell.s5 { background: var(--sev-5); }
.heat-cell.empty { background: transparent; border: 1px dashed var(--border); cursor: default; }
.heat-cell.future { visibility: hidden; }
.heat-scale { display: flex; align-items: center; gap: 5px; font-size: .76rem; color: var(--muted); margin-top: var(--sp-3); }
.heat-scale i { width: 13px; height: 13px; border-radius: 3px; display: block; }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; max-width: 520px; margin-inline: auto; }
.month-grid .dow { text-align: center; font-size: .7rem; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.mday { aspect-ratio: 1; border-radius: var(--r-xs); border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; font-size: .8rem; font-variant-numeric: tabular-nums; cursor: pointer; position: relative; color: var(--text-2); }
.mday:hover { border-color: var(--primary); }
.mday.blank { border: none; background: none; cursor: default; }
.mday.today { outline: 2px solid var(--primary); outline-offset: -2px; font-weight: 750; }
.mday.filled { color: var(--text); font-weight: 600; }
.mday.s1 { background: var(--sev-1); } .mday.s2 { background: var(--sev-2); }
.mday.s3 { background: var(--sev-3); } .mday.s4 { background: var(--sev-4); color: #fff; } .mday.s5 { background: var(--sev-5); color: #fff; }
.mday .crisis-dot { position: absolute; bottom: 3px; width: 5px; height: 5px; border-radius: 50%; background: var(--danger); }
.mday.s4 .crisis-dot, .mday.s5 .crisis-dot { background: #fff; }

/* ---------- Analyses / observations ---------- */
.insight { display: grid; gap: 8px; padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); border-left: 4px solid var(--muted); }
.insight + .insight { margin-top: var(--sp-3); }
.insight.lvl-strong { border-left-color: var(--danger); }
.insight.lvl-moderate { border-left-color: var(--warn); }
.insight.lvl-weak { border-left-color: var(--info); }
.insight.lvl-good { border-left-color: var(--ok); }
.insight-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.insight-title { font-size: .98rem; font-weight: 700; flex: 1; min-width: 200px; }
.insight-text { font-size: .9rem; color: var(--text-2); }
.insight-meta { display: flex; flex-wrap: wrap; gap: var(--sp-3); font-size: .77rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.insight-bar { height: 6px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.insight-bar i { display: block; height: 100%; border-radius: inherit; background: var(--primary); }

/* ---------- Chronomètre de crise ---------- */
.crisis-live { display: grid; gap: var(--sp-4); text-align: center; padding: var(--sp-5); border-radius: var(--r-md); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }
.crisis-timer { font-size: clamp(2.4rem, 1.6rem + 4vw, 3.6rem); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.04em; color: var(--danger); line-height: 1; }
.crisis-banner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); padding: 11px var(--sp-4); border-radius: var(--r-sm); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); font-size: .9rem; font-weight: 600; }

/* ---------- Liste de jours / historique ---------- */
.daylist { display: grid; gap: var(--sp-2); }
.dayrow {
  display: grid; grid-template-columns: 118px 1fr auto; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); text-decoration: none; color: inherit; transition: border-color .13s ease, transform .08s ease;
}
.dayrow:hover { border-color: var(--primary); color: inherit; }
.dayrow-date { font-size: .84rem; font-weight: 650; color: var(--text-2); }
.dayrow-date small { display: block; font-size: .73rem; color: var(--muted); font-weight: 500; }
.dayrow-bars { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.mini-metric { display: inline-flex; align-items: center; gap: 5px; font-size: .77rem; color: var(--muted); background: var(--surface-2); padding: 3px 8px; border-radius: var(--r-full); }
.mini-metric b { color: var(--text); font-variant-numeric: tabular-nums; }
.dayrow-sev { width: 10px; height: 34px; border-radius: var(--r-full); background: var(--sev-0); flex: none; }
.dayrow-sev.s1 { background: var(--sev-1); } .dayrow-sev.s2 { background: var(--sev-2); }
.dayrow-sev.s3 { background: var(--sev-3); } .dayrow-sev.s4 { background: var(--sev-4); } .dayrow-sev.s5 { background: var(--sev-5); }
@media (max-width: 620px) { .dayrow { grid-template-columns: 96px 1fr auto; } }

/* ---------- Médicaments ---------- */
.med-item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); }
.med-item + .med-item { margin-top: var(--sp-2); }
.med-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); flex: none; }
.med-info { flex: 1; min-width: 0; }
.med-info b { font-size: .94rem; display: block; }
.med-info span { display: block; font-size: .8rem; color: var(--muted); }
.med-actions { display: flex; gap: 4px; }
.med-inactive { opacity: .55; }

/* ---------- Modales ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(4, 12, 20, .55); backdrop-filter: blur(3px); display: grid; place-items: center; padding: var(--sp-4); animation: fadein .16s ease; }
@keyframes fadein { from { opacity: 0; } }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3); width: min(560px, 100%); max-height: min(86vh, 860px);
  display: flex; flex-direction: column; animation: pop .18s ease;
}
.modal-lg { width: min(880px, 100%); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 1.08rem; flex: 1; }
.modal-body { padding: var(--sp-5); overflow-y: auto; display: grid; gap: var(--sp-4); }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ---------- Notifications ---------- */
.toasts { position: fixed; z-index: 120; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
@media (max-width: 860px) { .toasts { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--r-sm); font-size: .9rem; font-weight: 550;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-3);
  animation: toastin .2s ease;
}
@keyframes toastin { from { opacity: 0; transform: translateY(12px); } }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .2s ease; }
.toast-ok { background: var(--ok); color: #fff; }
.toast-err { background: var(--danger); color: #fff; }

/* ---------- Onboarding ---------- */
.onb { max-width: 620px; margin-inline: auto; display: grid; gap: var(--sp-5); }
.onb-steps { display: flex; gap: 6px; }
.onb-steps i { flex: 1; height: 4px; border-radius: var(--r-full); background: var(--surface-3); }
.onb-steps i.on { background: var(--primary); }
.onb h2 { font-size: 1.5rem; }
.onb .lead { font-size: 1rem; }

/* ---------- Rapport ---------- */
.report-preview {
  --border: #d6dee4; --border-strong: #b9c6cf; --muted: #5b6b78;
  --text: #16212b; --text-2: #33505c; --surface: #fff; --surface-2: #f2f6f8; --surface-3: #e6edf1;
  background: #fff; color: #111; border-radius: var(--r-md); border: 1px solid var(--border); padding: clamp(16px, 3vw, 34px); box-shadow: var(--shadow-2); }
.report-preview h1, .report-preview h2, .report-preview h3, .report-preview p, .report-preview td, .report-preview th, .report-preview li { color: #16212b; }
.report-preview h1 { font-size: 1.5rem; margin-bottom: 4px; }
.report-preview .rp-sub { color: #5b6b78; font-size: .85rem; }
.report-preview hr { border-top: 1px solid #d6dee4; }
.report-preview .rp-table { overflow-x: auto; margin-top: 10px; }
.report-preview table { width: 100%; border-collapse: collapse; font-size: .82rem; min-width: 460px; }
.report-preview th, .report-preview td { border: 1px solid #d6dee4; padding: 6px 9px; text-align: left; }
.report-preview th { background: #eef3f6; font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; }
.report-preview .rp-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 14px 0; }
.report-preview .rp-kpi { border: 1px solid #d6dee4; border-radius: 8px; padding: 10px 12px; }
.report-preview .rp-kpi b { display: block; font-size: 1.3rem; }
.report-preview .rp-kpi span { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #5b6b78; }

/* ---------- Divers ---------- */
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.tnum { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); } .mt-5 { margin-top: var(--sp-5); }
.demo-banner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); padding: 10px var(--sp-4); border-radius: var(--r-sm); background: var(--accent-soft); color: var(--text-2); font-size: .86rem; border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-sm); }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
