:root {
  color-scheme: light;
  --font-en: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-ar: "SF Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  --bg: #f7f6f1;
  --surface: #ffffff;
  --surface-2: #eef7f7;
  --surface-3: #e7f1f4;
  --text: #14222b;
  --muted: #667782;
  --line: #dbe5e8;
  --primary: #0b7189;
  --primary-strong: #075c70;
  --secondary: #19a6a1;
  --secondary-soft: #dff5f2;
  --success: #21875a;
  --success-soft: #e2f5ea;
  --warning: #a86708;
  --warning-soft: #fff3d9;
  --danger: #c84d4d;
  --danger-soft: #fdeaea;
  --info: #2f6faf;
  --info-soft: #e6f0fb;
  --shadow-sm: 0 5px 20px rgba(24, 55, 64, .07);
  --shadow-md: 0 14px 40px rgba(21, 58, 70, .12);
  --shadow-lg: 0 24px 80px rgba(10, 43, 54, .20);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --radius-xl: 34px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --text-scale: 1;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --max-content: 1180px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d171e;
  --surface: #14232c;
  --surface-2: #172d35;
  --surface-3: #1c333d;
  --text: #f4f8f9;
  --muted: #a9bbc4;
  --line: #2b414b;
  --primary: #58c4d2;
  --primary-strong: #7bd5de;
  --secondary: #56d1c4;
  --secondary-soft: #173f3d;
  --success: #65cb91;
  --success-soft: #173c2c;
  --warning: #efba59;
  --warning-soft: #43351c;
  --danger: #ff8f8a;
  --danger-soft: #472727;
  --info: #8dbcf0;
  --info-soft: #1d344c;
  --shadow-sm: 0 6px 20px rgba(0, 0, 0, .18);
  --shadow-md: 0 16px 45px rgba(0, 0, 0, .28);
  --shadow-lg: 0 28px 90px rgba(0, 0, 0, .42);
}

:root[data-contrast="high"] {
  --text: #000;
  --muted: #252525;
  --line: #606060;
  --primary: #005b70;
  --primary-strong: #003f4f;
  --surface: #fff;
  --bg: #f5f5f5;
}

:root[data-theme="dark"][data-contrast="high"] {
  --text: #fff;
  --muted: #eee;
  --line: #aaa;
  --primary: #7ce4f0;
  --primary-strong: #b4f4fa;
  --surface: #000;
  --bg: #000;
}

* { box-sizing: border-box; }
html { font-size: calc(16px * var(--text-scale)); scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-en);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
html[dir="rtl"] body { font-family: var(--font-ar); }
button, input, select, textarea { font: inherit; }
button, [role="button"], a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: var(--primary); }
img, svg { display: block; max-width: 100%; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 70%, white); outline-offset: 3px; }

.app-shell { min-height: 100dvh; padding-bottom: calc(94px + var(--safe-bottom)); }
.app-shell.onboarding-shell { padding-bottom: 0; }
.top-safe { height: var(--safe-top); }
.app-header {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(20px) saturate(130%);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
}
.header-inner {
  max-width: var(--max-content); margin: 0 auto; min-height: 68px;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); padding: 10px 18px;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--primary), var(--secondary)); color: white;
  box-shadow: 0 9px 24px color-mix(in srgb, var(--primary) 26%, transparent);
  flex: 0 0 auto;
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-copy { min-width: 0; }
.brand-name { font-size: 1.02rem; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.brand-tagline { margin-top: 2px; color: var(--muted); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 44px; height: 44px; min-width: 44px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.icon-btn:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); }
.icon-btn:active { transform: scale(.96); }
.icon-btn svg { width: 21px; height: 21px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--secondary-soft), var(--surface-3)); color: var(--primary-strong);
  font-weight: 800; border: 2px solid var(--surface); box-shadow: var(--shadow-sm);
}

.content { max-width: var(--max-content); margin: 0 auto; padding: 22px 18px 34px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: clamp(1.55rem, 4vw, 2.15rem); line-height: 1.15; letter-spacing: -.035em; }
.page-head p { margin: 7px 0 0; color: var(--muted); line-height: 1.5; }
.eyebrow { color: var(--primary); font-weight: 800; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
html[dir="rtl"] .eyebrow { letter-spacing: 0; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.home-grid { grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); align-items: start; }
.stack { display: grid; gap: 16px; }
.section { margin-top: 28px; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title { margin: 0; font-size: 1.08rem; letter-spacing: -.02em; }
.section-link { border: 0; background: transparent; color: var(--primary); cursor: pointer; font-weight: 750; min-height: 44px; padding: 8px; }

.card {
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 18px;
}
.card.soft { background: linear-gradient(145deg, var(--surface), var(--surface-2)); }
.card.hero {
  padding: 22px; overflow: hidden; position: relative;
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 8%, var(--surface)), color-mix(in srgb, var(--secondary) 12%, var(--surface)));
}
.card.hero::after {
  content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%;
  inset-inline-end: -72px; top: -90px; background: color-mix(in srgb, var(--secondary) 18%, transparent); filter: blur(2px);
}
.card-title { font-size: .88rem; font-weight: 800; color: var(--muted); margin-bottom: 10px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

.progress-card { display: grid; grid-template-columns: 128px 1fr; align-items: center; gap: 20px; }
.progress-ring { width: 128px; height: 128px; position: relative; flex: none; }
.progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.progress-ring .track { fill: none; stroke: var(--surface-3); stroke-width: 10; }
.progress-ring .fill { fill: none; stroke: url(#progressGradient); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .55s cubic-bezier(.2,.8,.2,1); }
.progress-value { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.progress-value strong { font-size: 1.72rem; letter-spacing: -.05em; }
.progress-value span { font-size: .70rem; color: var(--muted); }
.progress-copy h2 { font-size: 1.42rem; margin: 0 0 8px; letter-spacing: -.03em; }
.progress-copy p { color: var(--muted); margin: 0; line-height: 1.5; }
.stat-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.stat-pill { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 7px 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: .8rem; }
.stat-dot { width: 9px; height: 9px; border-radius: 50%; }

.upcoming-card { position: relative; overflow: hidden; }
.upcoming-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--primary); }
html[dir="rtl"] .upcoming-card::before { inset: 0 0 0 auto; }
.med-head { display: flex; gap: 13px; align-items: center; min-width: 0; }
.med-icon {
  width: 54px; height: 54px; min-width: 54px; border-radius: 17px; display: grid; place-items: center;
  background: var(--secondary-soft); color: var(--primary-strong); font-size: 1.45rem; border: 1px solid color-mix(in srgb, var(--secondary) 20%, transparent);
}
.med-icon.large { width: 78px; height: 78px; border-radius: 24px; font-size: 2.1rem; }
.med-copy { min-width: 0; flex: 1; }
.med-name { margin: 0; font-weight: 850; font-size: 1.1rem; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.med-meta { margin-top: 5px; color: var(--muted); font-size: .84rem; line-height: 1.4; }
.time-chip { padding: 8px 11px; background: var(--surface-3); color: var(--primary-strong); border-radius: 12px; font-size: .82rem; font-weight: 850; white-space: nowrap; }
.countdown { margin: 16px 0; display: flex; align-items: center; gap: 8px; color: var(--primary); font-weight: 750; font-size: .88rem; }
.instructions { display: flex; align-items: flex-start; gap: 9px; color: var(--muted); line-height: 1.45; font-size: .87rem; }
.instructions svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--warning); }
.action-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 9px; margin-top: 18px; }

.btn {
  min-height: 48px; border: 1px solid transparent; border-radius: 15px; padding: 11px 16px;
  font-weight: 820; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .16s ease, box-shadow .18s ease, background .18s ease, opacity .18s ease;
  text-decoration: none; line-height: 1.2;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(.985); }
.btn:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.btn svg { width: 19px; height: 19px; }
.btn.primary { background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 65%, var(--secondary))); color: white; box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 20%, transparent); }
.btn.secondary { background: var(--surface-2); color: var(--primary-strong); border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.btn.success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.btn.full { width: 100%; }
.btn.small { min-height: 40px; border-radius: 12px; padding: 8px 12px; font-size: .82rem; }

.timeline { position: relative; display: grid; gap: 12px; }
.timeline::before { content: ""; position: absolute; top: 18px; bottom: 18px; inset-inline-start: 21px; width: 2px; background: var(--line); }
.timeline-item { display: grid; grid-template-columns: 44px 1fr; gap: 12px; position: relative; }
.timeline-marker { width: 44px; display: flex; justify-content: center; padding-top: 18px; z-index: 1; }
.timeline-dot { width: 14px; height: 14px; border: 3px solid var(--surface); border-radius: 50%; box-shadow: 0 0 0 2px var(--line); background: var(--muted); }
.timeline-dot.taken { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-dot.upcoming { background: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.timeline-dot.missed, .timeline-dot.late { background: var(--danger); box-shadow: 0 0 0 2px var(--danger); }
.timeline-dot.skipped { background: var(--warning); box-shadow: 0 0 0 2px var(--warning); }
.timeline-dot.snoozed { background: var(--info); box-shadow: 0 0 0 2px var(--info); }
.timeline-card { padding: 14px 15px; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: transform .17s ease, border-color .17s ease; }
.timeline-card:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--primary) 30%, var(--line)); }
.timeline-time { font-size: .78rem; font-weight: 850; color: var(--muted); white-space: nowrap; }
.timeline-body { min-width: 0; flex: 1; }
.timeline-body strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline-body small { color: var(--muted); display: block; margin-top: 4px; }

.badge { min-height: 28px; display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; font-weight: 800; font-size: .70rem; white-space: nowrap; }
.badge svg { width: 13px; height: 13px; }
.badge.taken, .badge.active { color: var(--success); background: var(--success-soft); }
.badge.upcoming { color: var(--primary); background: var(--surface-3); }
.badge.missed, .badge.late { color: var(--danger); background: var(--danger-soft); }
.badge.skipped { color: var(--warning); background: var(--warning-soft); }
.badge.snoozed { color: var(--info); background: var(--info-soft); }
.badge.paused { color: var(--muted); background: var(--surface-3); }
.badge.completed { color: var(--info); background: var(--info-soft); }
.badge.archived { color: var(--muted); background: var(--surface-3); }

.alert { border-radius: var(--radius-md); padding: 15px 16px; display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); }
.alert.warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 24%, transparent); }
.alert.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 24%, transparent); }
.alert.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 24%, transparent); }
.alert.success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 24%, transparent); }
.alert-icon { width: 34px; height: 34px; border-radius: 11px; background: color-mix(in srgb, currentColor 10%, transparent); display: grid; place-items: center; flex: none; }
.alert-icon svg { width: 19px; height: 19px; }
.alert-body { min-width: 0; flex: 1; }
.alert-title { font-weight: 850; margin-bottom: 4px; }
.alert-text { color: var(--muted); font-size: .82rem; line-height: 1.45; }
.alert-action { margin-top: 10px; }

.bottom-nav {
  position: fixed; z-index: 40; inset-inline: 0; bottom: 0;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(22px) saturate(140%);
  border-top: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
}
.bottom-nav-inner { max-width: 620px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.nav-item { min-height: 60px; border: 0; border-radius: 16px; background: transparent; cursor: pointer; color: var(--muted); display: grid; place-items: center; align-content: center; gap: 5px; font-size: .67rem; font-weight: 760; transition: background .18s ease, color .18s ease, transform .18s ease; }
.nav-item svg { width: 23px; height: 23px; }
.nav-item.active { color: var(--primary); background: var(--surface-3); }
.nav-item:active { transform: scale(.96); }
.fab {
  position: fixed; z-index: 45; inset-inline-end: max(18px, calc((100vw - var(--max-content))/2 + 18px));
  bottom: calc(84px + var(--safe-bottom)); width: 58px; height: 58px; border: 0; border-radius: 20px;
  display: grid; place-items: center; color: white; cursor: pointer;
  background: linear-gradient(145deg, var(--primary), var(--secondary));
  box-shadow: 0 16px 34px color-mix(in srgb, var(--primary) 35%, transparent); transition: transform .18s ease;
}
.fab:hover { transform: translateY(-2px) rotate(2deg); }
.fab:active { transform: scale(.95); }
.fab svg { width: 28px; height: 28px; }

.segmented { display: flex; gap: 5px; overflow-x: auto; padding: 4px; background: var(--surface-3); border-radius: 15px; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button { border: 0; background: transparent; color: var(--muted); min-height: 42px; padding: 8px 14px; border-radius: 12px; cursor: pointer; font-weight: 800; white-space: nowrap; }
.segmented button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 16px; }
.search-box { position: relative; }
.search-box svg { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: 14px; width: 20px; height: 20px; color: var(--muted); }
.search-box input { width: 100%; min-height: 48px; padding: 10px 15px 10px 44px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); color: var(--text); }
html[dir="rtl"] .search-box input { padding: 10px 44px 10px 15px; }
.medication-list { display: grid; gap: 12px; }
.medication-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 14px; padding: 15px; cursor: pointer; }
.medication-row:hover { border-color: color-mix(in srgb, var(--primary) 30%, var(--line)); }
.medication-row .med-icon { width: 50px; height: 50px; min-width: 50px; }
.med-row-meta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; color: var(--muted); font-size: .75rem; }
.chevron { width: 20px; height: 20px; color: var(--muted); }
html[dir="rtl"] .chevron { transform: scaleX(-1); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: .80rem; font-weight: 820; }
.required { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 14px;
  padding: 11px 13px; background: var(--surface); color: var(--text); transition: border-color .18s ease, box-shadow .18s ease;
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); outline: 0; box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 12%, transparent); }
.field-help { color: var(--muted); font-size: .72rem; line-height: 1.4; }
.field-error { color: var(--danger); font-size: .74rem; font-weight: 700; }
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; }
.choice {
  min-height: 70px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); color: var(--text);
  cursor: pointer; padding: 10px; display: grid; place-items: center; gap: 6px; text-align: center; font-size: .78rem; font-weight: 750;
}
.choice.active { border-color: var(--primary); background: var(--surface-2); color: var(--primary-strong); box-shadow: inset 0 0 0 1px var(--primary); }
.choice .emoji { font-size: 1.3rem; }
.time-list { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.time-token { min-height: 42px; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 7px 10px; background: var(--surface-2); font-weight: 800; }
.time-token button { width: 27px; height: 27px; border: 0; border-radius: 9px; background: var(--danger-soft); color: var(--danger); cursor: pointer; display: grid; place-items: center; }
.weekdays { display: flex; gap: 7px; flex-wrap: wrap; }
.day-chip { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); cursor: pointer; font-weight: 800; }
.day-chip.active { background: var(--primary); color: white; border-color: var(--primary); }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 15px; min-height: 58px; }
.switch-copy { min-width: 0; }
.switch-title { font-weight: 820; }
.switch-subtitle { color: var(--muted); font-size: .76rem; line-height: 1.4; margin-top: 3px; }
.switch { position: relative; width: 52px; height: 30px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track { position: absolute; inset: 0; border-radius: 999px; background: var(--line); cursor: pointer; transition: background .2s ease; }
.switch-track::after { content: ""; position: absolute; width: 24px; height: 24px; top: 3px; inset-inline-start: 3px; border-radius: 50%; background: white; box-shadow: 0 3px 8px rgba(0,0,0,.18); transition: transform .2s ease; }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(22px); }
html[dir="rtl"] .switch input:checked + .switch-track::after { transform: translateX(-22px); }

.wizard-header { display: grid; gap: 14px; margin-bottom: 20px; }
.wizard-title-row { display: flex; align-items: center; gap: 12px; }
.wizard-title-row h2 { margin: 0; font-size: 1.35rem; }
.stepper { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.step-bar { height: 5px; border-radius: 999px; background: var(--line); overflow: hidden; }
.step-bar.active { background: var(--primary); }
.step-label { color: var(--muted); font-size: .74rem; font-weight: 750; }
.wizard-actions { position: sticky; bottom: 0; z-index: 2; display: flex; justify-content: space-between; gap: 10px; padding-top: 18px; margin-top: 20px; background: linear-gradient(transparent, var(--surface) 24%); }
.review-list { display: grid; gap: 12px; }
.review-row { display: grid; grid-template-columns: minmax(120px,.7fr) 1.5fr; gap: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.review-row:last-child { border-bottom: 0; padding-bottom: 0; }
.review-label { color: var(--muted); font-size: .78rem; font-weight: 700; }
.review-value { font-weight: 760; line-height: 1.5; }

.chart-card { overflow: hidden; }
.chart-summary { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.chart-value { font-size: 2.35rem; font-weight: 900; letter-spacing: -.06em; line-height: 1; }
.chart-value small { font-size: 1rem; color: var(--muted); letter-spacing: 0; }
.bar-chart { height: 190px; display: grid; grid-template-columns: repeat(7,1fr); gap: 10px; align-items: end; padding-top: 16px; border-bottom: 1px solid var(--line); }
.bar-column { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px; }
.bar-track { width: 100%; max-width: 38px; height: 140px; background: var(--surface-3); border-radius: 10px 10px 4px 4px; display: flex; align-items: flex-end; overflow: hidden; }
.bar-fill { width: 100%; background: linear-gradient(180deg, var(--secondary), var(--primary)); border-radius: 10px 10px 4px 4px; min-height: 4px; transition: height .5s cubic-bezier(.2,.8,.2,1); }
.bar-label { color: var(--muted); font-size: .68rem; font-weight: 750; }
.legend { display: flex; gap: 15px; flex-wrap: wrap; margin-top: 18px; }
.legend-item { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .76rem; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }
.metric-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; }
.metric { padding: 15px; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; }
.metric-icon { width: 33px; height: 33px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 10px; }
.metric strong { display: block; font-size: 1.35rem; }
.metric span { color: var(--muted); font-size: .73rem; }

.settings-layout { display: grid; grid-template-columns: 270px 1fr; gap: 20px; align-items: start; }
.settings-menu { position: sticky; top: 90px; display: grid; gap: 6px; }
.settings-menu button { min-height: 48px; border: 0; border-radius: 14px; background: transparent; color: var(--muted); text-align: start; padding: 10px 12px; cursor: pointer; display: flex; align-items: center; gap: 10px; font-weight: 780; }
.settings-menu button svg { width: 20px; height: 20px; }
.settings-menu button.active { background: var(--surface-3); color: var(--primary); }
.settings-group { display: grid; gap: 12px; }
.settings-group + .settings-group { margin-top: 18px; }
.settings-group-title { font-size: .76rem; color: var(--muted); font-weight: 850; text-transform: uppercase; letter-spacing: .08em; padding-inline: 6px; }
html[dir="rtl"] .settings-group-title { letter-spacing: 0; }
.settings-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.settings-item { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.settings-item:last-child { border-bottom: 0; }
.settings-item.clickable { cursor: pointer; }
.settings-item.clickable:hover { background: var(--surface-2); }
.settings-item-main { display: flex; gap: 12px; align-items: center; min-width: 0; }
.settings-item-icon { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; background: var(--surface-3); color: var(--primary); }
.settings-item-icon svg { width: 20px; height: 20px; }
.settings-item-copy { min-width: 0; }
.settings-item-title { font-weight: 800; }
.settings-item-subtitle { color: var(--muted); font-size: .74rem; margin-top: 3px; line-height: 1.4; }
.settings-item-value { color: var(--muted); font-size: .78rem; font-weight: 700; white-space: nowrap; }

.permission-list { display: grid; gap: 10px; }
.permission-row { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.caregiver-card { display: flex; align-items: center; gap: 13px; }
.caregiver-avatar { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: var(--info-soft); color: var(--info); font-weight: 850; }
.activity-log { position: relative; display: grid; gap: 12px; }
.activity-item { display: grid; grid-template-columns: auto 1fr; gap: 11px; }
.activity-icon { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-3); color: var(--primary); }
.activity-copy { font-size: .83rem; line-height: 1.45; }
.activity-time { color: var(--muted); font-size: .7rem; margin-top: 3px; }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; background: rgba(6,20,28,.58); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 18px; animation: fadeIn .18s ease; }
.modal { width: min(100%, 620px); max-height: min(92dvh, 900px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); animation: modalIn .22s cubic-bezier(.2,.8,.2,1); }
.modal.wide { width: min(100%, 830px); }
.modal.full-reminder { width: min(100%, 540px); }
.modal-head { position: sticky; top: 0; z-index: 3; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 17px 19px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
.modal-title { margin: 0; font-size: 1.12rem; }
.modal-body { padding: 20px; }
.modal-foot { position: sticky; bottom: 0; padding: 15px 20px 20px; background: color-mix(in srgb, var(--surface) 95%, transparent); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; border-radius: 0 0 var(--radius-xl) var(--radius-xl); }
.reminder-hero { text-align: center; padding: 18px 4px 8px; }
.reminder-hero .med-icon { margin: 0 auto 18px; }
.reminder-kicker { color: var(--primary); font-weight: 850; margin-bottom: 8px; }
.reminder-name { margin: 0; font-size: clamp(1.8rem, 7vw, 2.5rem); letter-spacing: -.045em; }
.reminder-dose { margin: 8px 0 0; color: var(--muted); font-size: 1.04rem; }
.reminder-time { font-size: 2.5rem; font-weight: 900; letter-spacing: -.06em; margin: 20px 0 4px; }
.reminder-actions { display: grid; gap: 10px; margin-top: 20px; }
.snooze-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 9px; }

.toast-container { position: fixed; z-index: 200; inset-inline: 14px; bottom: calc(100px + var(--safe-bottom)); display: grid; justify-items: center; pointer-events: none; }
.toast { width: min(100%, 470px); background: color-mix(in srgb, var(--text) 92%, transparent); color: var(--bg); border-radius: 15px; padding: 13px 15px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; pointer-events: auto; animation: toastIn .24s ease; }
.toast.success { background: var(--success); color: white; }
.toast.error { background: var(--danger); color: white; }
.toast svg { width: 20px; height: 20px; flex: none; }

.empty-state { text-align: center; padding: 38px 20px; }
.empty-illustration { width: 96px; height: 96px; margin: 0 auto 18px; border-radius: 32px; display: grid; place-items: center; background: linear-gradient(145deg, var(--surface-2), var(--surface-3)); color: var(--primary); }
.empty-illustration svg { width: 48px; height: 48px; }
.empty-state h3 { margin: 0 0 8px; }
.empty-state p { max-width: 430px; margin: 0 auto; color: var(--muted); line-height: 1.55; }
.empty-state .btn { margin-top: 18px; }

.onboarding { min-height: 100dvh; display: grid; grid-template-columns: minmax(0,1.05fr) minmax(390px,.95fr); background: var(--bg); }
.onboarding-visual { min-height: 100dvh; padding: max(32px, calc(var(--safe-top) + 24px)) clamp(28px,6vw,80px) 40px; background: linear-gradient(145deg, #075d71, #0b8194 48%, #21a89d); color: white; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; }
.onboarding-visual::before, .onboarding-visual::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.09); }
.onboarding-visual::before { width: 420px; height: 420px; top: -170px; inset-inline-end: -130px; }
.onboarding-visual::after { width: 300px; height: 300px; bottom: -130px; inset-inline-start: -70px; }
.onboarding-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; font-size: 1.2rem; font-weight: 850; }
.onboarding-brand .brand-mark { background: rgba(255,255,255,.18); box-shadow: none; }
.phone-preview { position: relative; z-index: 1; width: min(100%, 390px); margin: 24px auto; background: rgba(255,255,255,.97); color: #14222b; border-radius: 40px; padding: 14px; box-shadow: 0 30px 90px rgba(0,0,0,.25); transform: rotate(-2deg); }
html[dir="rtl"] .phone-preview { transform: rotate(2deg); }
.phone-notch { width: 110px; height: 22px; margin: 0 auto 14px; background: #0d171e; border-radius: 0 0 14px 14px; }
.preview-content { padding: 8px; display: grid; gap: 11px; }
.preview-greeting { font-size: 1.25rem; font-weight: 850; }
.preview-progress { padding: 14px; border-radius: 18px; background: #edf8f8; display: flex; align-items: center; gap: 12px; }
.preview-ring { width: 64px; height: 64px; border-radius: 50%; background: conic-gradient(#0b7189 0 64%, #d9e8ea 64% 100%); display: grid; place-items: center; }
.preview-ring::after { content: "60%"; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: white; font-weight: 900; font-size: .75rem; }
.preview-med { padding: 14px; border: 1px solid #dbe5e8; border-radius: 18px; display: flex; align-items: center; gap: 11px; }
.onboarding-trust { position: relative; z-index: 1; display: flex; align-items: center; gap: 9px; font-size: .8rem; opacity: .9; }
.onboarding-panel { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: max(28px, calc(var(--safe-top) + 22px)) clamp(24px,6vw,72px) max(30px, calc(var(--safe-bottom) + 24px)); }
.onboarding-top { display: flex; justify-content: flex-end; min-height: 44px; }
.lang-selector { display: inline-flex; border: 1px solid var(--line); border-radius: 14px; padding: 3px; background: var(--surface); }
.lang-selector button { min-height: 38px; border: 0; border-radius: 11px; padding: 7px 12px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 800; }
.lang-selector button.active { background: var(--surface-3); color: var(--primary); }
.onboarding-copy { max-width: 570px; margin: auto 0; }
.onboarding-step { color: var(--primary); font-size: .78rem; font-weight: 850; margin-bottom: 18px; }
.onboarding-copy h1 { font-size: clamp(2.1rem,5vw,3.8rem); margin: 0; line-height: 1.06; letter-spacing: -.055em; }
html[dir="rtl"] .onboarding-copy h1 { letter-spacing: -.02em; line-height: 1.2; }
.onboarding-copy > p { color: var(--muted); font-size: 1.03rem; line-height: 1.75; margin: 20px 0 0; }
.feature-points { display: grid; gap: 13px; margin: 26px 0; }
.feature-point { display: flex; align-items: flex-start; gap: 11px; }
.feature-check { width: 28px; height: 28px; flex: none; border-radius: 9px; background: var(--success-soft); color: var(--success); display: grid; place-items: center; }
.feature-check svg { width: 16px; height: 16px; }
.onboarding-actions { display: grid; gap: 10px; margin-top: 26px; }
.onboarding-secondary { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; }
.text-btn { min-height: 44px; border: 0; background: transparent; color: var(--primary); font-weight: 800; cursor: pointer; padding: 8px; }
.dots { display: flex; gap: 7px; }
.dot { width: 8px; height: 8px; border-radius: 999px; background: var(--line); transition: width .2s ease, background .2s ease; }
.dot.active { width: 24px; background: var(--primary); }
.account-options { display: grid; gap: 10px; margin-top: 20px; }
.disclaimer-box { font-size: .72rem; color: var(--muted); line-height: 1.55; border-inline-start: 3px solid var(--warning); padding-inline-start: 12px; margin-top: 18px; }

.loading-screen { min-height: 100dvh; display: grid; place-items: center; background: var(--bg); }
.loading-logo { width: 84px; height: 84px; border-radius: 28px; display: grid; place-items: center; background: linear-gradient(145deg,var(--primary),var(--secondary)); color: white; box-shadow: var(--shadow-md); animation: breathe 1.6s ease-in-out infinite; }
.loading-logo svg { width: 46px; height: 46px; }
.offline-banner { position: fixed; top: var(--safe-top); inset-inline: 12px; z-index: 90; background: var(--warning-soft); color: var(--warning); border: 1px solid color-mix(in srgb,var(--warning) 30%,transparent); border-radius: 13px; padding: 10px 14px; text-align: center; font-size: .78rem; font-weight: 800; box-shadow: var(--shadow-sm); }

.success-view { text-align: center; padding: 20px 4px; }
.success-burst { width: 104px; height: 104px; margin: 0 auto 20px; border-radius: 34px; background: var(--success-soft); color: var(--success); display: grid; place-items: center; position: relative; animation: successPop .42s cubic-bezier(.2,1.4,.4,1); }
.success-burst svg { width: 55px; height: 55px; }
.success-view h2 { margin: 0 0 8px; font-size: 1.65rem; }
.success-view p { color: var(--muted); line-height: 1.55; }

.detail-hero { display: flex; align-items: center; gap: 16px; padding: 2px 0 18px; }
.detail-actions { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.detail-action { min-height: 70px; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; display: grid; place-items: center; gap: 5px; cursor: pointer; font-size: .71rem; font-weight: 780; }
.detail-action svg { width: 21px; height: 21px; color: var(--primary); }
.kv-list { display: grid; }
.kv-row { display: grid; grid-template-columns: minmax(120px,.7fr) 1.4fr; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.kv-row:last-child { border: 0; }
.kv-key { color: var(--muted); font-size: .78rem; }
.kv-value { font-weight: 750; font-size: .87rem; line-height: 1.45; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.045); } }
@keyframes successPop { from { opacity: 0; transform: scale(.55) rotate(-10deg); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .001ms !important; } }

@media (min-width: 900px) {
  .app-shell { padding-bottom: 24px; padding-inline-start: 94px; }
  .bottom-nav { width: 84px; top: 0; bottom: 0; inset-inline-start: 0; inset-inline-end: auto; padding: calc(var(--safe-top) + 92px) 8px calc(var(--safe-bottom) + 16px); border-top: 0; border-inline-end: 1px solid var(--line); display: flex; align-items: flex-start; }
  .bottom-nav-inner { grid-template-columns: 1fr; width: 100%; gap: 9px; }
  .nav-item { min-height: 64px; }
  .fab { bottom: 28px; }
  .content { padding-top: 30px; }
}

@media (max-width: 980px) {
  .grid.home-grid { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-menu { position: static; display: flex; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .settings-menu::-webkit-scrollbar { display: none; }
  .settings-menu button { white-space: nowrap; }
  .onboarding { grid-template-columns: 1fr; }
  .onboarding-visual { display: none; }
  .onboarding-panel { min-height: 100dvh; }
}

@media (max-width: 700px) {
  .content { padding: 18px 14px 28px; }
  .header-inner { padding-inline: 14px; }
  .brand-tagline { display: none; }
  .page-head { align-items: flex-start; }
  .grid.two, .grid.three, .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .progress-card { grid-template-columns: 104px 1fr; gap: 15px; }
  .progress-ring { width: 104px; height: 104px; }
  .progress-value strong { font-size: 1.42rem; }
  .progress-copy h2 { font-size: 1.17rem; }
  .action-row { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2,1fr); }
  .choice-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .review-row, .kv-row { grid-template-columns: 1fr; gap: 5px; }
  .detail-actions { grid-template-columns: repeat(2,1fr); }
  .snooze-grid { grid-template-columns: repeat(2,1fr); }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { width: 100%; max-height: 94dvh; border-radius: 28px 28px 0 0; border-bottom: 0; }
  .modal-head { border-radius: 28px 28px 0 0; }
  .modal-foot { border-radius: 0; padding-bottom: calc(18px + var(--safe-bottom)); }
}

@media (max-width: 420px) {
  .header-actions .icon-btn:first-child { display: none; }
  .progress-card { grid-template-columns: 1fr; text-align: center; }
  .progress-ring { margin: 0 auto; }
  .stat-row { justify-content: center; }
  .medication-row { grid-template-columns: auto minmax(0,1fr); }
  .medication-row > .chevron { display: none; }
  .chart-summary { align-items: flex-start; flex-direction: column; }
  .bar-chart { gap: 6px; }
}

@media print {
  :root { color-scheme: light; --bg: white; --surface: white; --text: black; --muted: #444; --line: #ccc; }
  .app-header, .bottom-nav, .fab, .no-print, .toast-container, .modal-backdrop { display: none !important; }
  .app-shell { padding: 0; }
  .content { max-width: none; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
.med-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

@media print {
  body.printing-report .app-shell { display: none !important; }
  body.printing-report .modal-backdrop { display: block !important; position: static; background: transparent; backdrop-filter: none; padding: 0; }
  body.printing-report .modal { width: 100%; max-height: none; overflow: visible; border: 0; border-radius: 0; box-shadow: none; }
  body.printing-report .modal-head,
  body.printing-report .modal-foot { display: none !important; }
  body.printing-report .modal-body { padding: 0; }
}
