:root {
  --c-dark: #076533;
  --c-dark-2: #054d27;
  --c-bright: #7db926;
  --c-bright-2: #649617;
  --c-bg: #f3faf0;
  --c-card: #ffffff;
  --c-ink: #122117;
  --c-muted: #5c6e62;
  --c-border: #e1ece0;
  --c-danger: #c0392b;
  --c-danger-bg: #fdecea;
  --c-warning-bg: #fff7e0;
  --c-warning-ink: #8a6500;
  --c-shadow: 0 8px 24px rgba(7, 101, 51, 0.1);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --nav-h: 64px;
  --header-h: 56px;
  color-scheme: light;
}

:root:not([data-theme="light"]) {
  @media (prefers-color-scheme: dark) {
    --c-dark: #3fae5c;
    --c-dark-2: #2e8c46;
    --c-bright: #8fd23a;
    --c-bright-2: #7bb52d;
    --c-bg: #0d1710;
    --c-card: #152218;
    --c-ink: #eaf3ea;
    --c-muted: #9fb3a4;
    --c-border: #243429;
    --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);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --c-dark: #3fae5c;
  --c-dark-2: #2e8c46;
  --c-bright: #8fd23a;
  --c-bright-2: #7bb52d;
  --c-bg: #0d1710;
  --c-card: #152218;
  --c-ink: #eaf3ea;
  --c-muted: #9fb3a4;
  --c-border: #243429;
  --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);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
svg { width: 20px; height: 20px; flex-shrink: 0; }
body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  background: var(--c-bg);
  color: var(--c-ink);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
h1, h2, h3, h4 { margin: 0 0 6px; line-height: 1.25; }
p { margin: 0 0 10px; color: var(--c-muted); }
a { color: var(--c-dark); }
button { font-family: inherit; }
img { max-width: 100%; display: block; }

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

/* ---------- Header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--header-h);
  padding: 0 14px;
  background: var(--c-card);
  border-bottom: 1px solid var(--c-border);
}
.topbar .logo-mini { width: 30px; height: 30px; border-radius: 8px; object-fit: contain; background: #fff; }
.topbar .title { font-weight: 700; font-size: 15px; color: var(--c-dark); flex: 1; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: none; background: var(--c-bg); color: var(--c-dark);
  cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }
.back-btn { background: none; border: none; color: var(--c-dark); display: flex; align-items: center; gap: 4px; font-weight: 600; padding: 6px 2px; cursor: pointer; }
.back-btn svg { width: 20px; height: 20px; }
.hero-cta svg { width: 18px; height: 18px; }

/* ---------- Views ---------- */
.view { display: none; padding: 14px 14px 10px; animation: fadeIn 0.18s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none; } }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  background: linear-gradient(145deg, var(--c-dark) 0%, var(--c-dark-2) 100%);
  border-radius: var(--radius-lg);
  padding: 20px 18px 54px;
  color: #fff;
  overflow: hidden;
  margin-bottom: -36px;
}
.hero-blob { position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; opacity: 0.25; }
.hero-top { display: flex; align-items: center; gap: 12px; }
.hero-logo { width: 46px; height: 46px; border-radius: 12px; background: #fff; padding: 4px; }
.hero h1 { font-size: 18px; margin: 0; }
.hero .sub { color: #dff3df; font-size: 12.5px; margin: 2px 0 0; }
.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 12px; padding: 6px 12px; border-radius: 99px;
  background: rgba(255,255,255,0.14); font-size: 12.5px; font-weight: 600;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #9BE38B; }
.status-badge.closed .status-dot { background: #f1a3a3; }
.hero-cta {
  margin-top: 16px; width: 100%; border: none; border-radius: var(--radius-md);
  background: var(--c-bright); color: #0d2b0f; font-weight: 700; font-size: 15px;
  padding: 13px 16px; display: flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}

/* ---------- Quick actions row (floating over hero) ---------- */
.quick-row {
  position: relative;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin: 0 0 18px;
  padding-top: 40px;
}
.quick-item {
  background: var(--c-card); border-radius: var(--radius-md);
  box-shadow: var(--c-shadow); padding: 12px 8px; text-align: center;
  border: 1px solid var(--c-border);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer;
}
.quick-item .ic { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.quick-item .ic svg { width: 18px; height: 18px; }
.quick-item span { font-size: 11.5px; font-weight: 600; color: var(--c-ink); }

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

/* ---------- Cards ---------- */
.card {
  background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: var(--radius-md); padding: 14px; 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: 13px 14px; margin-bottom: 10px;
  cursor: pointer; box-shadow: var(--c-shadow);
}
.row-card .ic { flex-shrink: 0; width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.row-card .ic svg { width: 20px; height: 20px; }
.row-card .txt { flex: 1; min-width: 0; }
.row-card .txt b { display: block; font-size: 14px; }
.row-card .txt span { font-size: 12px; color: var(--c-muted); }
.row-card .chev { color: var(--c-muted); flex-shrink: 0; }
.row-card .chev svg { width: 16px; height: 16px; }

.tint-green { background: #e7f6e2; color: var(--c-dark); }
.tint-blue { background: #e4f1fb; color: #1670a8; }
.tint-pink { background: #fbe7ef; color: #b4316b; }
.tint-amber { background: #fdf2dc; color: #a9740c; }
.tint-purple { background: #ece6fb; color: #6a3fc2; }
.tint-red { background: var(--c-danger-bg); color: var(--c-danger); }

/* ---------- Grid for services ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Tip cards (home carousel) ---------- */
.tip-scroll { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; margin: 0 -14px; padding-left: 14px; padding-right: 14px; scroll-snap-type: x mandatory; }
.tip-card { min-width: 72%; scroll-snap-align: start; background: var(--c-card); border: 1px solid var(--c-border); border-radius: var(--radius-md); padding: 14px; box-shadow: var(--c-shadow); }
.tip-card .ic { width: 34px; height: 34px; border-radius: 10px; margin-bottom: 8px; display: flex; align-items: center; justify-content: center; }
.tip-card h4 { font-size: 13.5px; }
.tip-card p { font-size: 12.5px; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 13px 16px; border-radius: var(--radius-md);
  font-weight: 700; font-size: 14.5px; border: none; cursor: pointer;
  text-decoration: none;
}
.btn svg { width: 17px; height: 17px; }
.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: 9px 12px; font-size: 13px; 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; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--c-ink); margin-bottom: 6px; }
.field .hint { font-size: 11.5px; 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: 11px 12px; font-size: 14px; color: var(--c-ink);
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--c-bright); }
.field textarea { resize: vertical; min-height: 70px; }
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 14px; border-radius: 99px; border: 1.5px solid var(--c-border);
  background: var(--c-card); font-size: 13px; font-weight: 600; cursor: pointer; color: var(--c-ink);
}
.chip.active { background: var(--c-dark); border-color: var(--c-dark); color: #fff; }
.time-chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }

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

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

/* ---------- 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: 3px; color: var(--c-muted);
  font-size: 10.5px; font-weight: 600; cursor: pointer; padding-top: 6px;
}
.nav-btn svg { width: 21px; height: 21px; }
.nav-btn.active { color: var(--c-dark); }

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

/* ---------- Insurance chips ---------- */
.insurance-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.insurance-chip { background: var(--c-card); border: 1px solid var(--c-border); border-radius: 99px; padding: 8px 13px; font-size: 12px; font-weight: 700; color: var(--c-dark); }

/* ---------- Reminders list ---------- */
.reminder-card { background: var(--c-card); border: 1px solid var(--c-border); border-radius: var(--radius-md); padding: 14px; margin-bottom: 10px; box-shadow: var(--c-shadow); }
.reminder-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.reminder-head b { font-size: 14.5px; }
.reminder-head .dosage { font-size: 12px; color: var(--c-muted); }
.times-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 10px; }
.time-pill { background: var(--c-bg); border: 1px solid var(--c-border); border-radius: 99px; padding: 4px 10px; font-size: 12px; font-weight: 700; color: var(--c-dark); }
.del-btn { border: none; background: none; color: var(--c-muted); cursor: pointer; padding: 4px; }
.del-btn svg { width: 16px; height: 16px; }

/* ---------- Measures (tension/glycemie) ---------- */
.measure-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--c-border); }
.measure-row:last-child { border-bottom: none; }
.measure-row .mtype { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.measure-row .mval { font-weight: 700; font-size: 14px; }
.measure-row .mdate { font-size: 11.5px; color: var(--c-muted); }
.measure-row .mnote { font-size: 12px; color: var(--c-muted); }

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

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

/* ---------- Rating badge ---------- */
.rating-badge { display: inline-flex; align-items: center; gap: 6px; background: var(--c-card); border: 1px solid var(--c-border); border-radius: 99px; padding: 7px 13px; font-size: 12.5px; font-weight: 700; }
.rating-badge svg { width: 14px; height: 14px; color: #f5a623; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px); transform: translate(-50%, 20px);
  background: var(--c-ink); color: var(--c-bg); padding: 11px 18px; border-radius: 99px;
  font-size: 13px; font-weight: 600; z-index: 50; opacity: 0; pointer-events: none;
  transition: all 0.25s ease; 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); }

/* ---------- Modal (install / share instructions) ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(5,15,8,0.55); z-index: 60; display: none; align-items: flex-end; justify-content: center; }
.modal-backdrop.show { display: flex; }
.modal-sheet { background: var(--c-card); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 20px 18px calc(22px + env(safe-area-inset-bottom)); max-height: 80vh; overflow-y: auto; }
.modal-sheet .handle { width: 38px; height: 4px; border-radius: 99px; background: var(--c-border); margin: 0 auto 14px; }

/* ---------- 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: 9px 6px; border-radius: 99px; font-size: 12.5px; font-weight: 700; color: var(--c-muted); cursor: pointer; }
.segmented button.active { background: var(--c-dark); color: #fff; }

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

.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); }
}
