/* ===================== DiabCare Theme ===================== */
:root {
  --teal-900: #063a36;
  --teal-700: #0f6b62;
  --teal-600: #0f9d8c;
  --teal-500: #16b8a3;
  --teal-400: #4fd6c0;
  --coral: #ff6b6b;
  --coral-dark: #e05555;
  --amber: #ffb648;
  --ink: #16302e;
  --ink-soft: #5b7573;
  --bg-app: #f4faf9;
  --card-bg: #ffffff;
  --border-soft: #e3f0ee;
  --shadow-card: 0 10px 24px -14px rgba(6, 58, 54, 0.25);
  --shadow-btn: 0 10px 20px -8px rgba(15, 157, 140, 0.55);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-heading: 'Poppins', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg-app);
}

button, input {
  font-family: inherit;
}

/* ---------- App shell: fixed-width on mobile, fluid full-bleed from tablet up ---------- */
.app-backdrop {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: stretch;
  background: radial-gradient(circle at 20% 0%, #d7f4ee 0%, #eef8f6 45%, #f4faf9 100%);
}

.app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-app);
  position: relative;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Tablet and up: stop boxing the app into a fixed-width "phone card" and
   let it use the full width of the screen, with content reflowing fluidly. */
@media (min-width: 560px) {
  .app-backdrop { padding: 0; }
  .app-shell {
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
    overflow-y: visible;
  }

  .auth-card { max-width: 460px; margin: -48px auto 0; }
  .otp-body { max-width: 460px; margin: 0 auto; }

  .home-content { padding: 18px clamp(18px, 4vw, 48px) 90px; }
  .feature-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }
  .stats-row { gap: 14px; }
}

/* ---------- Screens ---------- */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 100%;
  animation: fadeIn .35s ease;
}
.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===================== Landing ===================== */
.landing-hero {
  background: linear-gradient(160deg, var(--teal-700) 0%, var(--teal-600) 55%, var(--teal-400) 100%);
  padding: 56px 24px 72px;
  text-align: center;
  color: #fff;
  border-radius: 0 0 36px 36px;
  position: relative;
}
.landing-hero::after {
  content: "";
  position: absolute;
  inset: auto 0 -1px 0;
  height: 40px;
}
.brand-logo {
  display: block;
  width: 100%;
  max-width: 260px;
  aspect-ratio: 2.2 / 1;
  object-fit: cover;
  object-position: center;
  margin: 0 auto 16px;
  background: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 32px -14px rgba(0, 0, 0, 0.4);
}
.brand-tagline {
  margin: 0;
  font-size: 14px;
  opacity: .92;
}

.auth-card {
  background: var(--card-bg);
  margin: -48px 18px 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px 20px 24px;
  position: relative;
  z-index: 2;
}

.tabs {
  display: flex;
  background: var(--border-soft);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 20px;
}
.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 0;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .25s ease;
}
.tab-btn.active {
  background: var(--teal-600);
  color: #fff;
  box-shadow: var(--shadow-btn);
}

.tab-panel { display: none; flex-direction: column; }
.tab-panel.active { display: flex; }

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.input-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 4px 14px;
  background: #fbfffe;
  transition: border-color .2s ease;
}
.input-wrap:focus-within {
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(22,184,163,0.15);
}
.input-prefix {
  font-size: 16px;
  margin-right: 8px;
}
.input-wrap input {
  border: none;
  outline: none;
  background: transparent;
  padding: 12px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  width: 100%;
  letter-spacing: .5px;
}

.field-error {
  color: var(--coral-dark);
  font-size: 12.5px;
  font-weight: 500;
  min-height: 16px;
  margin: 6px 2px 0;
}

.notice-box {
  display: flex;
  gap: 10px;
  background: #fff7ea;
  border: 1px solid #ffe4b5;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 14px 0 20px;
}
.notice-box p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: #7a5a15;
}
.notice-icon { font-size: 16px; }

/* ===================== Buttons ===================== */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.btn-primary {
  background: linear-gradient(135deg, var(--teal-600), var(--teal-500));
  color: #fff;
  box-shadow: var(--shadow-btn);
}
.btn-primary:disabled {
  opacity: .55;
  box-shadow: none;
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: var(--teal-700);
  margin-top: 8px;
}
.btn-ghost:disabled { color: var(--ink-soft); cursor: not-allowed; }
.btn-danger {
  background: linear-gradient(135deg, var(--coral), var(--coral-dark));
  color: #fff;
  box-shadow: 0 10px 20px -8px rgba(224,85,85,0.55);
}

/* ===================== OTP screen ===================== */
.topbar-plain {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 14px;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--border-soft);
  color: var(--ink);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.topbar-title {
  font-weight: 700;
  font-family: var(--font-heading);
  font-size: 16px;
}

.otp-body {
  flex: 1;
  padding: 20px 26px 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.otp-icon { font-size: 46px; margin-bottom: 6px; }
.otp-heading {
  font-family: var(--font-heading);
  font-size: 20px;
  margin: 4px 0 6px;
}
.otp-sub {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 0 0 26px;
}

.otp-inputs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 6px;
  width: 100%;
}
.otp-box {
  width: 44px;
  height: 54px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: #fbfffe;
  outline: none;
  color: var(--ink);
}
.otp-box:focus {
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(22,184,163,0.15);
}

.otp-body .btn { margin-top: 18px; }
#resendTimer { color: var(--ink-soft); font-weight: 500; }

/* ===================== Home ===================== */
.home-topbar {
  background: linear-gradient(135deg, var(--teal-700), var(--teal-600));
  color: #fff;
  padding: 18px 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 0 0 26px 26px;
}
.home-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.home-app-name {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 17px;
}
.home-greeting {
  font-size: 12px;
  opacity: .9;
}
.home-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.unsub-btn {
  border: 1.5px solid rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  opacity: .9;
}
.unsub-btn:active { transform: scale(0.96); }
.logout-btn {
  border: 1.5px solid rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.16);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.logout-btn:active { transform: scale(0.96); }

.home-content {
  flex: 1;
  padding: 18px 18px 90px;
  overflow-y: auto;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: -30px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 14px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.stat-icon { font-size: 18px; }
.stat-value { font-family: var(--font-heading); font-weight: 700; font-size: 15px; }
.stat-label { font-size: 10.5px; color: var(--ink-soft); }

/* ===================== Glucose zone meter ===================== */
.glucose-meter {
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 16px 16px 14px;
  margin-bottom: 16px;
}
.glucose-meter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.glucose-meter-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.glucose-meter-value {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 16px;
  color: var(--ink);
  transition: color .3s ease;
}
.glucose-meter-value.zone-danger { color: #b3271b; }
.glucose-meter-value.zone-caution { color: #a8730f; }
.glucose-meter-value.zone-ok { color: var(--teal-700); }

.glucose-meter-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  /* 1-16 mmol/L scale: Low / Normal / Good / Slightly High / High / Very High */
  background: linear-gradient(
    to right,
    #ff6b6b 0%, #ff6b6b 20%,
    #16b8a3 20%, #16b8a3 40%,
    #4fd6c0 40%, #4fd6c0 50%,
    #ffb648 50%, #ffb648 60%,
    #ff8a3d 60%, #ff8a3d 93.3%,
    #b3271b 93.3%, #b3271b 100%
  );
  margin-bottom: 6px;
}
.glucose-meter-marker {
  position: absolute;
  top: 50%;
  left: 30%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--ink-soft);
  box-shadow: 0 2px 6px rgba(6, 58, 54, 0.3);
  transform: translate(-50%, -50%);
  transition: left .4s ease, border-color .3s ease;
}
.glucose-meter-marker.zone-danger { border-color: #b3271b; }
.glucose-meter-marker.zone-caution { border-color: #a8730f; }
.glucose-meter-marker.zone-ok { border-color: var(--teal-700); }

.glucose-meter-scale {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  color: var(--ink-soft);
  font-weight: 700;
  letter-spacing: .2px;
  margin-bottom: 8px;
}
.glucose-meter-msg {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 500;
}
.glucose-meter-msg.zone-danger { color: #b3271b; font-weight: 600; }
.glucose-meter-msg.zone-caution { color: #a8730f; font-weight: 600; }
.glucose-meter-msg.zone-ok { color: var(--teal-700); font-weight: 600; }

.section-heading {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--ink);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.feature-card {
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 6px 14px -10px rgba(6,58,54,0.2);
  transition: transform .15s ease, box-shadow .15s ease;
}
.feature-card:active { transform: scale(0.95); }
.feature-icon {
  font-size: 22px;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===================== Bottom nav ===================== */
.bottom-nav {
  position: sticky;
  bottom: 0;
  display: flex;
  background: var(--card-bg);
  border-top: 1px solid var(--border-soft);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 18px -14px rgba(6,58,54,0.3);
}
.nav-btn {
  flex: 1;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 6px 0;
  cursor: pointer;
}
.nav-btn span { font-size: 17px; }
.nav-btn.active { color: var(--teal-600); }

/* ===================== Modal ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 40, 37, 0.45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }

.modal-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 82vh;
  background: var(--card-bg);
  border-radius: 24px 24px 0 0;
  padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  animation: slideUp .3s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-title {
  font-family: var(--font-heading);
  font-size: 17px;
  margin: 0;
}
.modal-body {
  overflow-y: auto;
}

/* Shared modal content bits */
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 14px;
  outline: none;
  background: #fbfffe;
  color: var(--ink);
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(22,184,163,0.15);
}
.chip-group { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--border-soft);
  background: #fbfffe;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}
.chip.active {
  background: var(--teal-600);
  border-color: var(--teal-600);
  color: #fff;
}

.entry-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.entry-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fbfffe;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.entry-main { display: flex; flex-direction: column; }
.entry-title { font-size: 13.5px; font-weight: 700; }
.entry-sub { font-size: 11.5px; color: var(--ink-soft); }
.entry-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--border-soft);
  color: var(--teal-700);
  white-space: nowrap;
}
.entry-tag.warn { background: #fff1f0; color: #b3271b; }
.entry-tag.caution { background: #fff7ea; color: #a8730f; }
.empty-state {
  text-align: center;
  color: var(--ink-soft);
  font-size: 12.5px;
  padding: 18px 0 4px;
}

.tip-card {
  background: linear-gradient(135deg, var(--teal-600), var(--teal-400));
  color: #fff;
  border-radius: var(--radius-md);
  padding: 20px;
  font-size: 14px;
  line-height: 1.6;
  font-weight: 500;
}

.water-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 6px 0 16px;
}
.water-circle-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  background: var(--teal-600);
  box-shadow: var(--shadow-btn);
}
.water-count { font-family: var(--font-heading); font-size: 26px; font-weight: 800; }
.progress-track {
  height: 10px;
  border-radius: 999px;
  background: var(--border-soft);
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal-500), var(--teal-400));
  border-radius: 999px;
  transition: width .3s ease;
}

/* ===================== Confirm dialog ===================== */
#confirmOverlay { align-items: center; }
.confirm-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 26px 22px;
  width: 90%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 30px 60px -20px rgba(6,58,54,0.4);
}
.confirm-icon { font-size: 36px; margin-bottom: 6px; }
.confirm-card h3 { font-family: var(--font-heading); margin: 0 0 8px; font-size: 17px; }
.confirm-card p { font-size: 13px; color: var(--ink-soft); margin: 0 0 20px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; margin: 0; }

/* ===================== Toast ===================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 14px 30px -10px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: all .3s ease;
  z-index: 100;
  max-width: 90%;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ===================== Small screens polish ===================== */
@media (max-width: 340px) {
  .otp-box { width: 38px; height: 48px; font-size: 19px; }
  .feature-icon { width: 38px; height: 38px; font-size: 19px; }
}

/* ===================== Desktop / laptop layout (>=1024px) =====================
   Above this width the app stops behaving like a narrow phone card floating
   in the middle of the page and switches to a real desktop layout: a split
   hero/auth panel for the landing screen, and a sidebar-nav dashboard for
   the home screen. */
@media (min-width: 1024px) {
  /* ---- Landing screen: split hero / auth panel ---- */
  #screen-landing.active {
    display: grid;
    grid-template-columns: minmax(360px, 1fr) minmax(420px, 480px);
    align-items: stretch;
    min-height: 100vh;
    min-height: 100dvh;
  }
  #screen-landing .landing-hero {
    grid-column: 1;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
  }
  #screen-landing .brand-logo { max-width: 380px; }
  #screen-landing .brand-tagline { font-size: 17px; max-width: 320px; }
  #screen-landing .auth-card {
    grid-column: 2;
    align-self: center;
    margin: 0;
    width: 100%;
    max-width: 420px;
    justify-self: center;
    padding: 36px 32px 32px;
  }

  /* ---- OTP screen: centered card, not edge-to-edge ---- */
  #screen-otp.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 40px 24px;
  }
  #screen-otp .topbar-plain { width: 100%; max-width: 460px; }
  #screen-otp .otp-body {
    width: 100%;
    max-width: 460px;
    flex: none;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 44px 40px 40px;
    margin-top: 16px;
  }

  /* ---- Home screen: sidebar dashboard ---- */
  #screen-home.active {
    display: grid;
    grid-template-columns: 232px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: "topbar topbar" "nav content";
    min-height: 100vh;
    min-height: 100dvh;
  }
  #screen-home .home-topbar {
    grid-area: topbar;
    border-radius: 0;
    padding: 20px 32px;
    box-shadow: 0 4px 16px -10px rgba(6, 58, 54, 0.35);
  }
  #screen-home .home-app-name { font-size: 19px; }
  #screen-home .home-greeting { font-size: 13px; }
  #screen-home .unsub-btn { font-size: 11.5px; padding: 7px 14px; }
  #screen-home .logout-btn { font-size: 14.5px; padding: 11px 20px; }
  #screen-home .bottom-nav {
    grid-area: nav;
    position: sticky;
    top: 0;
    align-self: start;
    min-height: 100%;
    flex-direction: column;
    justify-content: flex-start;
    gap: 6px;
    padding: 24px 12px;
    border-top: none;
    border-right: 1px solid var(--border-soft);
    box-shadow: none;
  }
  #screen-home .nav-btn {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
  }
  #screen-home .nav-btn span { font-size: 18px; }
  #screen-home .nav-btn.active { background: var(--border-soft); }
  #screen-home .nav-btn:hover { background: var(--border-soft); color: var(--teal-700); }
  #screen-home .home-content {
    grid-area: content;
    padding: 28px clamp(24px, 3vw, 56px) 48px;
  }

  #screen-home .section-heading { font-size: 18px; margin: 28px 0 18px; }

  /* KPI-style stat tiles: fixed comfortable width, icon-left layout, left-aligned row
     instead of 3 cards stretched edge-to-edge across the whole screen. */
  #screen-home .stats-row {
    grid-template-columns: repeat(3, minmax(0, 240px));
    justify-content: start;
    margin-top: 0;
    gap: 18px;
  }
  #screen-home .stat-card {
    display: grid;
    grid-template-columns: 48px 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 14px;
    text-align: left;
    padding: 16px 18px;
    transition: transform .15s ease, box-shadow .15s ease;
  }
  #screen-home .stat-card:hover { transform: translateY(-2px); box-shadow: 0 14px 26px -14px rgba(6, 58, 54, 0.3); }
  #screen-home .stat-icon {
    grid-row: 1 / span 2;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
  }
  #screen-home .stat-value { grid-column: 2; grid-row: 1; font-size: 20px; }
  #screen-home .stat-label { grid-column: 2; grid-row: 2; font-size: 12px; }

  /* Feature grid: fixed comfortable card size that reflows into more columns
     as the screen widens, rather than stretching cards edge-to-edge. */
  #screen-home .feature-grid {
    grid-template-columns: repeat(auto-fill, minmax(152px, 168px));
    justify-content: start;
    gap: 18px;
  }
  #screen-home .feature-card { padding: 24px 10px; }
  #screen-home .feature-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 26px -14px rgba(6, 58, 54, 0.3);
    border-color: var(--teal-400);
  }
  #screen-home .feature-icon { width: 48px; height: 48px; font-size: 24px; }

  /* ---- Modals: centered dialog instead of a bottom sheet ---- */
  .modal-overlay { align-items: center; }
  .modal-sheet {
    width: auto;
    min-width: 420px;
    max-width: 560px;
    max-height: 80vh;
    border-radius: var(--radius-lg);
    padding: 24px 28px 28px;
    animation: fadeIn .25s ease;
  }
}
