@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/dmsans-latinext.woff2') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C4,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/dmsans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Acme';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/acme-400.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root {
  --c-dark: #1E40AF;
  --c-dark-2: #172F86;
  --c-bright: #22C55E;
  --c-bright-2: #16A34A;
  --c-bg: #ffffff;
  --c-card: #ffffff;
  --c-ink: #121a2b;
  --c-muted: #5c6672;
  --c-border: #e1e6ee;
  --c-danger: #c0392b;
  --c-danger-bg: #fdecea;
  --c-warning-bg: #fff7e0;
  --c-warning-ink: #8a6500;
  --c-shadow: 0 8px 24px rgba(30, 64, 175, 0.1);
  --nav-pill: rgba(30, 64, 175, 0.12);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --nav-h: 64px;
  --header-h: 56px;
  --icon-cutout: var(--c-card);
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: 'Acme', 'DM Sans', -apple-system, sans-serif;
  color-scheme: light;
}

:root:not([data-theme="light"]) {
  @media (prefers-color-scheme: dark) {
    --c-dark: #6E8EE8;
    --c-dark-2: #8FA8EE;
    --c-bright: #4ADE80;
    --c-bright-2: #6EE7A0;
    --c-bg: #0d1420;
    --c-card: #161f30;
    --c-ink: #eaf0fa;
    --c-muted: #9aa7bb;
    --c-border: #263247;
    --c-danger: #ff6b5e;
    --c-danger-bg: #3a1f1c;
    --c-warning-bg: #352c14;
    --c-warning-ink: #f0c558;
    --c-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    --nav-pill: rgba(110, 142, 232, 0.18);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --c-dark: #6E8EE8;
  --c-dark-2: #8FA8EE;
  --c-bright: #4ADE80;
  --c-bright-2: #6EE7A0;
  --c-bg: #0d1420;
  --c-card: #161f30;
  --c-ink: #eaf0fa;
  --c-muted: #9aa7bb;
  --c-border: #263247;
  --c-danger: #ff6b5e;
  --c-danger-bg: #3a1f1c;
  --c-warning-bg: #352c14;
  --c-warning-ink: #f0c558;
  --c-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --nav-pill: rgba(110, 142, 232, 0.18);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
svg { width: 22px; height: 22px; flex-shrink: 0; }

.ic svg, .action-btn .ic svg, .mtype svg, .empty-state svg {
  filter: drop-shadow(0 1px 1px rgba(18, 26, 43, 0.16));
}
.quick-item.solid svg { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.22)); }
.ic svg *, .action-btn .ic svg *, .nav-ic svg *, .quick-item.solid svg * {
  stroke-width: 2.4;
}
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  background: var(--c-bg);
  color: var(--c-ink);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  transition: background-color 0.25s ease, color 0.25s ease;
}
h1, h2, h3, h4 { margin: 0 0 4px; line-height: 1.25; font-weight: 400; font-family: var(--font-display); letter-spacing: 0.2px; }
p { margin: 0 0 8px; color: var(--c-muted); font-size: 15px; }
a { color: var(--c-dark); text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; display: block; }
.inline-ic { width: 18px; height: 18px; vertical-align: -3px; margin-right: 4px; }

.app-shell {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  position: relative;
  padding-bottom: calc(var(--nav-h) + 12px);
  background: var(--c-bg);
}

/* ---------- Header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--header-h);
  padding: 0 12px;
  background: var(--c-card);
  border-bottom: 1px solid var(--c-border);
}
.topbar .logo-mini { width: 34px; height: 34px; border-radius: 9px; object-fit: contain; background: #fff; flex-shrink: 0; }
.title-block { flex: 1; min-width: 0; line-height: 1.2; }
.topbar .title { font-family: var(--font-display); font-weight: 400; font-size: 16px; color: var(--c-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-sub { font-size: 12px; color: var(--c-muted); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: none; background: var(--c-bg); color: var(--c-dark);
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.2s ease;
}
.icon-btn:active { transform: scale(0.9); }
.icon-btn svg { width: 21px; height: 21px; }
.back-btn { background: none; border: none; color: var(--c-dark); display: flex; align-items: center; gap: 4px; font-weight: 700; padding: 8px 4px; cursor: pointer; transition: opacity 0.15s ease; }
.back-btn:active { opacity: 0.6; }
.back-btn svg { width: 23px; height: 23px; }

/* ---------- Views ---------- */
.view { display: none; padding: 12px 12px 8px; animation: viewIn 0.22s cubic-bezier(.22,1,.36,1); }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px) scale(0.99);} to { opacity: 1; transform: none; } }

/* ---------- Actions rapides (appeler / WhatsApp / itinéraire) ---------- */
.action-row {
  display: flex; justify-content: space-around; align-items: flex-start;
  background: var(--c-card); border: 1px solid var(--c-border); border-radius: 18px;
  padding: 16px 8px; margin: 8px 0 12px; box-shadow: var(--c-shadow);
}
.action-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--c-ink); transition: transform 0.15s ease; }
.action-btn:active { transform: scale(0.94); }
.action-btn .ic { width: 46px; height: 46px; border-radius: 16px; display: flex; align-items: center; justify-content: center; }
.action-btn .ic svg { width: 21px; height: 21px; }
.action-btn span { font-size: 12px; font-weight: 700; }

.menu-caption { text-align: center; color: var(--c-muted); font-size: 14px; margin: 4px 0 12px; font-weight: 400; }

/* ---------- Grille de services (tuiles pleine couleur) ---------- */
.quick-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.quick-item.solid {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: none; border-radius: 14px; padding: 20px 8px; min-height: 108px; text-align: center; cursor: pointer;
  box-shadow: 0 8px 18px rgba(30,64,175,0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.quick-item.solid:active { transform: scale(0.96); }
.quick-item.solid svg { width: 28px; height: 28px; color: #fff; margin-bottom: 8px; flex-shrink: 0; }
.quick-item.solid span { color: #fff; font-size: 14px; font-weight: 700; line-height: 1.2; }
.solid-1 { background: linear-gradient(155deg, #2b56d6, #1E40AF); }
.solid-2 { background: linear-gradient(155deg, #15927f, #0e6e60); }
.solid-3 { background: linear-gradient(155deg, #2a9456, #1c6f3f); }
.solid-4 { background: linear-gradient(155deg, #3a6fe0, #2954bd); }
.solid-5 { background: linear-gradient(155deg, #12a97a, #0c7d5a); }
.solid-6 { background: linear-gradient(155deg, #1E40AF, #172F86); }
.solid-urgence { background: linear-gradient(155deg, #d9534f, #b3412b); }
@media (hover: hover) {
  .quick-item.solid:hover { box-shadow: 0 10px 24px rgba(30,64,175,0.28); }
}

/* ---------- Section headers ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 20px 0 8px; }
.section-head h2 { font-size: 17px; color: var(--c-dark); }
.section-head a.link-more { font-size: 14px; font-weight: 700; text-decoration: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: var(--radius-md); padding: 12px; margin-bottom: 12px;
  box-shadow: var(--c-shadow);
}
.card.flat { box-shadow: none; }
.row-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: var(--radius-md); padding: 12px; margin-bottom: 8px;
  cursor: pointer; box-shadow: var(--c-shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.2s ease;
}
.row-card:active { transform: scale(0.98); }
.row-card .ic { flex-shrink: 0; width: 50px; height: 50px; border-radius: 14px; display: flex; align-items: center; justify-content: center; }
.row-card .ic svg { width: 25px; height: 25px; }
.row-card .txt { flex: 1; min-width: 0; }
.row-card .txt b { display: block; font-size: 15px; }
.row-card .txt span { font-size: 14px; color: var(--c-muted); }
.row-card .chev { color: var(--c-muted); flex-shrink: 0; }
.row-card .chev svg { width: 18px; height: 18px; }
@media (hover: hover) {
  .row-card:hover { box-shadow: 0 10px 28px rgba(30,64,175,0.16); }
}

.tint-green { background: linear-gradient(135deg, #e3f9ea, #bdeeca); color: var(--c-bright-2); }
.tint-blue { background: linear-gradient(135deg, #eaf0fc, #cfdcfa); color: var(--c-dark); }
.tint-pink { background: linear-gradient(135deg, #fdeef4, #fad4e3); color: #b4316b; }
.tint-amber { background: linear-gradient(135deg, #fef6e4, #fbe6b8); color: #a9740c; }
.tint-purple { background: linear-gradient(135deg, #f1edfc, #ddd2f7); color: #6a3fc2; }
.tint-red { background: linear-gradient(135deg, #fdeceb, #f8d3cf); color: var(--c-danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 12px 16px; border-radius: 999px;
  font-weight: 700; font-size: 15px; border: none; cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, background-color 0.2s ease;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 19px; height: 19px; }
.btn-primary { background: var(--c-dark); color: #fff; }
.btn-primary:active { background: var(--c-dark-2); }
.btn-whatsapp { background: #25D366; color: #06371a; }
.btn-outline { background: transparent; color: var(--c-dark); border: 1.5px solid var(--c-dark); }
.btn-ghost { background: var(--c-bg); color: var(--c-ink); }
.btn-sm { padding: 8px 12px; font-size: 14px; width: auto; }
.btn-danger-ghost { background: var(--c-danger-bg); color: var(--c-danger); }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
@media (hover: hover) {
  .btn:hover { filter: brightness(1.05); }
}

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 14px; font-weight: 700; color: var(--c-ink); margin-bottom: 4px; }
.field .hint { font-size: 12px; color: var(--c-muted); margin-top: 4px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--c-border); background: var(--c-card);
  border-radius: var(--radius-sm); padding: 12px 12px; font-size: 15px; color: var(--c-ink);
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--c-bright); box-shadow: 0 0 0 3px rgba(34,197,94,0.18); }
.field textarea { resize: vertical; min-height: 76px; }
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 16px; border-radius: 99px; border: 1.5px solid var(--c-border);
  background: var(--c-card); font-size: 14px; font-weight: 700; cursor: pointer; color: var(--c-ink);
  transition: transform 0.15s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.chip:active { transform: scale(0.95); }
.chip.active { background: var(--c-dark); border-color: var(--c-dark); color: #fff; }
.imc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.imc-result { padding: 12px 12px; border-radius: var(--radius-md); font-size: 14px; font-weight: 700; text-align: center; transition: all 0.2s ease; }
.imc-result.cat-normal { background: #e3f9ea; color: var(--c-bright-2); }
.imc-result.cat-under, .imc-result.cat-over { background: var(--c-warning-bg); color: var(--c-warning-ink); }
.imc-result.cat-obese { background: var(--c-danger-bg); color: var(--c-danger); }
.imc-result small { display: block; font-weight: 400; font-size: 12px; margin-top: 3px; opacity: 0.85; }

/* ---------- Alerts / banners ---------- */
.banner { display: flex; gap: 12px; padding: 12px 12px; border-radius: var(--radius-md); margin-bottom: 12px; font-size: 14px; }
.banner.warning { background: var(--c-warning-bg); color: var(--c-warning-ink); }
.banner.info { background: #e9f0fd; color: var(--c-dark); }
.banner.success { background: #e3f9ea; color: var(--c-bright-2); }
.banner svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }

/* ---------- Legal / privacy footer note ---------- */
.legal-note { font-size: 12px; color: var(--c-muted); background: var(--c-bg); border: 1px dashed var(--c-border); border-radius: var(--radius-sm); padding: 8px 12px; margin-top: 16px; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: var(--nav-h); max-width: 560px; margin: 0 auto;
  background: var(--c-card); border-top: 1px solid var(--c-border);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; border: none; background: none; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; color: var(--c-muted);
  font-size: 12px; font-weight: 700; cursor: pointer; padding-top: 4px;
  transition: color 0.2s ease, transform 0.15s ease;
}
.nav-btn:active { transform: scale(0.92); }
.nav-btn svg { width: 22px; height: 22px; }
.nav-ic {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 28px; border-radius: 14px;
  transition: background-color 0.2s ease;
}
.nav-btn.active { color: var(--c-dark); }
.nav-btn.active .nav-ic { background: var(--nav-pill); }

/* ---------- FAQ accordion ---------- */
.faq-item { border-bottom: 1px solid var(--c-border); }
.faq-q { width: 100%; text-align: left; background: none; border: none; padding: 16px 2px; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; cursor: pointer; color: var(--c-ink); }
.faq-q svg { width: 18px; height: 18px; flex-shrink: 0; transition: transform 0.2s ease; color: var(--c-dark); }
.faq-item.open .faq-q svg { transform: rotate(180deg); }
.faq-a { max-height: 0; overflow: hidden; font-size: 14px; color: var(--c-muted); transition: max-height 0.25s ease, padding 0.25s ease; }
.faq-item.open .faq-a { max-height: 300px; padding-bottom: 16px; }

/* ---------- Measures (tension/glycémie) ---------- */
.del-btn { border: none; background: none; color: var(--c-muted); cursor: pointer; padding: 4px; transition: color 0.15s ease, transform 0.15s ease; }
.del-btn:active { transform: scale(0.9); color: var(--c-danger); }
.del-btn svg { width: 19px; height: 19px; }
.measure-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--c-border); }
.measure-row:last-child { border-bottom: none; }
.measure-row .mtype { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.measure-row .mtype svg { width: 21px; height: 21px; }
.measure-row .mval { font-weight: 700; font-size: 15px; }
.measure-row .mdate { font-size: 12px; color: var(--c-muted); }
.measure-row .mnote { font-size: 14px; color: var(--c-muted); }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 32px 8px; color: var(--c-muted); }
.empty-state svg { width: 64px; height: 64px; opacity: 0.5; margin-bottom: 8px; }
.empty-state p { font-size: 14px; margin: 0; }

/* ---------- Map ---------- */
.map-frame { width: 100%; height: 190px; border: none; border-radius: var(--radius-md); margin-bottom: 8px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px); transform: translate(-50%, 20px) scale(0.95);
  background: var(--c-ink); color: var(--c-bg); padding: 12px 20px; border-radius: 99px;
  font-size: 14px; font-weight: 700; z-index: 50; opacity: 0; pointer-events: none;
  transition: opacity 0.25s cubic-bezier(.22,1,.36,1), transform 0.25s cubic-bezier(.22,1,.36,1);
  max-width: 85%; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}
#toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* ---------- Modal (install instructions) ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,10,20,0.55); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; visibility: hidden; transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}
.modal-backdrop.show { opacity: 1; visibility: visible; transition: opacity 0.25s ease; }
.modal-sheet {
  background: var(--c-card); width: 100%; max-width: 560px; border-radius: 24px 24px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 80vh; overflow-y: auto;
  transform: translateY(24px); transition: transform 0.28s cubic-bezier(.22,1,.36,1);
  font-size: 15px;
}
.modal-backdrop.show .modal-sheet { transform: translateY(0); }
.modal-sheet .handle { width: 40px; height: 4px; border-radius: 99px; background: var(--c-border); margin: 0 auto 12px; }

/* ---------- Segmented tabs (within a view) ---------- */
.segmented { display: flex; background: var(--c-bg); border-radius: 99px; padding: 4px; margin-bottom: 16px; border: 1px solid var(--c-border); }
.segmented button { flex: 1; border: none; background: none; padding: 8px 4px; border-radius: 99px; font-size: 14px; font-weight: 700; color: var(--c-muted); cursor: pointer; transition: background-color 0.2s ease, color 0.2s ease; }
.segmented button.active { background: var(--c-dark); color: #fff; }

/* ---------- Profile ---------- */
.avatar-circle { width: 66px; height: 66px; border-radius: 50%; background: var(--c-dark); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 25px; margin: 0 auto 8px; font-family: var(--font-display); }

/* ---------- Membres (famille) ---------- */
.member-switcher { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; -webkit-overflow-scrolling: touch; }
.member-chip {
  flex: 0 0 auto; padding: 8px 16px; border-radius: 99px; border: 1.5px solid var(--c-border);
  background: var(--c-card); font-size: 14px; font-weight: 700; cursor: pointer; color: var(--c-ink);
  white-space: nowrap; transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.member-chip.active { background: var(--c-dark); border-color: var(--c-dark); color: #fff; }
.member-chip--add { color: var(--c-dark); border-style: dashed; }

/* ---------- Listes dynamiques (traitements) ---------- */
.dynamic-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.dynamic-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 6px; align-items: center; }
.dynamic-row input { margin: 0; }
@media (max-width: 460px) {
  .dynamic-row { grid-template-columns: 1fr 1fr; }
  .dynamic-row .del-btn { grid-column: span 2; justify-self: end; }
}

/* ---------- Graphique d'évolution ---------- */
.chart-svg { width: 100%; height: 120px; display: block; }
.chart-caption { font-size: 12px; color: var(--c-muted); margin: 0 0 6px; display: flex; align-items: center; gap: 4px; }
.chart-caption .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- Carte d'urgence ---------- */
.urgence-card p { color: var(--c-ink); font-size: 14px; margin-bottom: 6px; }
.urgence-card ul { color: var(--c-ink); font-size: 14px; }

.hidden { display: none !important; }

@media (min-width: 560px) {
  .bottom-nav { border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: 0 -4px 20px rgba(0,0,0,0.08); }
}

/* ---------- Impression (carte d'urgence) ---------- */
@media print {
  .topbar, .bottom-nav, #toast, .modal-backdrop { display: none !important; }
  .app-shell { padding-bottom: 0; max-width: 100%; }
  .view:not(#view-urgence-card) { display: none !important; }
  #view-urgence-card { display: block !important; padding: 0; }
  #view-urgence-card .btn-row { display: none !important; }
  .urgence-card { box-shadow: none; border: 1px solid #333; }
}
