:root{
  --bg: #FAF7F2;
  --paper: #FFFFFF;
  --ink: #24312E;
  --ink-soft: #5C6A64;
  --teal: #1E5F74;
  --teal-dark: #14434F;
  --teal-soft: #E3EEF1;
  --coral: #E8935A;
  --coral-dark: #C8703A;
  --coral-soft: #FCEBDD;
  --sage: #3F7D5C;
  --sage-soft: #E4F0E9;
  --line: #E4DFD3;
  --danger: #B4483A;
  --danger-soft: #F6E5E2;
  --radius: 18px;
  --shadow: 0 2px 10px rgba(36, 49, 46, 0.08);
}

*{ box-sizing: border-box; }
html{ -webkit-text-size-adjust: 100%; }

body{
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  /* Police système : lisible, déjà sur l'appareil, aucune dépendance réseau. */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 19px;
  line-height: 1.5;
}

h1, h2, h3{ color: var(--teal-dark); line-height: 1.25; margin: 0 0 6px 0; }
h1{ font-size: 28px; }
h2{ font-size: 22px; }
h3{ font-size: 19px; margin-bottom: 2px; }
p{ margin: 0 0 10px 0; }
a{ color: var(--teal); }

.topbar{
  background: var(--teal-dark);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: calc(14px + env(safe-area-inset-top));
}
.topbar h1{ color: #fff; font-size: 20px; margin: 0; flex: 1; }
.topbar .back-btn{
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  font-size: 17px;
  font-weight: 700;
  border-radius: 12px;
  padding: 8px 14px;
  min-height: 40px;
  cursor: pointer;
}

.offline-banner{
  background: #F3E4C8;
  color: #6B531F;
  text-align: center;
  font-size: 15px;
  padding: 8px 14px;
}

.wrap{ max-width: 640px; margin: 0 auto; padding: 20px 16px 60px; }

.card{
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
}
.card.next-appt{
  border-left: 6px solid var(--coral);
  background: linear-gradient(180deg, #FFF7EE 0%, #FFFFFF 65%);
}
.card.allergy{
  border-left: 6px solid var(--danger);
  background: linear-gradient(180deg, #FDF3F1 0%, #FFFFFF 65%);
}

/* --------- Gros boutons / tuiles --------- */
.person-btn{
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px;
  font-size: 26px;
  font-weight: 800;
  color: var(--teal-dark);
  cursor: pointer;
  margin-bottom: 14px;
  font-family: inherit;
  text-align: left;
}
.person-btn:active{ transform: scale(0.99); }
.person-btn .avatar{
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--teal-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; flex-shrink: 0;
}
.person-btn .arrow{ margin-left: auto; color: var(--ink-soft); font-size: 24px; }

.menu-grid{ display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.menu-tile{
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 14px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  color: var(--teal-dark);
  cursor: pointer;
  text-align: center;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.menu-tile:active{ transform: scale(0.98); }
.menu-tile .emoji{ font-size: 34px; line-height: 1; }
.menu-tile.highlight{ background: var(--coral-soft); border-color: var(--coral); }

/* --------- Boutons standards --------- */
button, .btn{
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  padding: 14px 20px;
  cursor: pointer;
  background: var(--teal);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  min-height: 52px;
  text-decoration: none;
}
button:active{ transform: scale(0.98); }
button.secondary{ background: #EDEAE2; color: var(--ink); }
button.coral{ background: var(--coral); }
button.coral:active{ background: var(--coral-dark); }
button.danger-soft{ background: var(--danger-soft); color: var(--danger); }
button.ghost{ background: transparent; color: var(--teal-dark); padding: 8px 4px; min-height: auto; font-size: 16px; }
button.block{ width: 100%; }
button.small-btn{ min-height: 40px; padding: 8px 16px; font-size: 16px; }
button:disabled{ opacity: 0.5; }

.btn-row{ display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* --------- Onglets --------- */
.tabs{ display: flex; gap: 8px; margin-bottom: 14px; }
.tabs button{
  flex: 1; background: #EDEAE2; color: var(--ink);
  min-height: 46px; font-size: 17px;
}
.tabs button.active{ background: var(--teal); color: #fff; }

/* --------- Formulaires --------- */
label{ display: block; font-weight: 700; margin: 14px 0 6px; font-size: 16px; }
input[type="text"], input[type="date"], input[type="datetime-local"], input[type="tel"],
textarea, select{
  width: 100%;
  font-family: inherit;
  font-size: 18px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus{ outline: 3px solid #BFDBE2; border-color: var(--teal); }
textarea{ min-height: 76px; resize: vertical; }
.checkbox-row{ display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.checkbox-row input{ width: 26px; height: 26px; }
.checkbox-row label{ margin: 0; font-weight: 400; }

.search-box{ margin-bottom: 12px; }
.search-box input{ font-size: 18px; }

/* --------- Listes --------- */
.list-item{ padding: 14px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child{ border-bottom: none; }
.list-item .meta{ color: var(--ink-soft); font-size: 16px; }
.list-item .actions{ margin-top: 8px; display: flex; gap: 16px; flex-wrap: wrap; }

.tag{
  display: inline-block; font-size: 13px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; margin-bottom: 6px;
}
.tag.ongoing{ background: var(--sage-soft); color: var(--sage); }
.tag.done{ background: #EDEAE2; color: var(--ink-soft); }
.tag.soon{ background: var(--coral-soft); color: var(--coral-dark); }
.tag.plus{ background: var(--sage-soft); color: var(--sage); }
.tag.minus{ background: var(--danger-soft); color: var(--danger); }

.empty{ text-align: center; color: var(--ink-soft); padding: 22px 10px; }
.small{ font-size: 15px; color: var(--ink-soft); }

.stars{ color: var(--coral-dark); letter-spacing: 2px; }

/* --------- Modal --------- */
.modal-backdrop{
  position: fixed; inset: 0; background: rgba(36,49,46,0.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal{
  background: var(--bg); width: 100%; max-width: 640px;
  max-height: 92vh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding: 22px 20px 40px;
}
@media (min-width: 700px){
  .modal-backdrop{ align-items: center; }
  .modal{ border-radius: 22px; }
}

/* --------- Fiche de consultation (impression) --------- */
.consult-sheet{
  background: #fff;
  border: 2px dashed var(--teal);
  border-radius: var(--radius);
  padding: 22px;
}
.consult-sheet h2{ margin-bottom: 4px; }
.consult-sheet h3{
  margin-top: 18px; padding-bottom: 4px;
  border-bottom: 2px solid var(--teal-soft);
}
.consult-sheet .line{ padding: 7px 0; border-bottom: 1px dotted var(--line); }
.consult-sheet .line:last-child{ border-bottom: none; }
.consult-sheet .notes-space{
  margin-top: 16px; border: 1px solid var(--line); border-radius: 10px;
  min-height: 110px; padding: 8px;
}

@media print{
  .no-print{ display: none !important; }
  body{ background: #fff; font-size: 14px; }
  .wrap{ padding: 0; max-width: 100%; }
  .card{ box-shadow: none; border: none; padding: 0; }
  .consult-sheet{ border: none; padding: 0; }
  h1{ font-size: 20px; } h2{ font-size: 17px; } h3{ font-size: 15px; }
}
