@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@600;700;800&display=swap');

:root {
  --ink: #143a5a;
  --muted: #6b8298;
  --paper: #f5f9ff;
  --surface: #ffffff;
  --line: #dce8f5;
  --sage: #6f9fe8;
  --sage-dark: #2f6fed;
  --sage-pale: #eaf3ff;
  --coral: #e88770;
  --coral-pale: #fff0ea;
  --yellow: #f2c75c;
  --yellow-pale: #fff6d8;
  --shadow: 0 18px 45px rgba(20, 58, 90, .10);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 92% -5%, #dcecff 0, transparent 30rem), var(--paper); }
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(47, 111, 237, .34); outline-offset: 2px; }
.shell { width: min(1160px, 100%); margin: 0 auto; padding: 26px 28px 50px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 34px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 15px; color: #fff; background: var(--sage-dark); font-size: 22px; box-shadow: 0 8px 16px rgba(47, 111, 237, .22); }
.brand-title { font-family: Manrope, sans-serif; font-weight: 800; letter-spacing: -.05em; font-size: 18px; line-height: 1.05; }
.brand-subtitle { margin-top: 4px; color: var(--muted); font-size: 11px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.language { display: flex; gap: 2px; padding: 4px; background: #edf4fc; border-radius: 12px; }
.language button { padding: 7px 9px; color: var(--muted); background: transparent; border-radius: 9px; font-size: 12px; }
.language button.active { color: var(--ink); background: white; box-shadow: 0 2px 8px rgba(35, 45, 40, .07); }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 5px 10px 5px 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; font-size: 13px; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: #eaf3ff; color: #2f6fed; font-weight: 700; }
.hero { position: relative; overflow: hidden; display: flex; justify-content: space-between; align-items: center; gap: 30px; min-height: 190px; padding: 34px 38px; background: var(--sage-dark); color: white; border-radius: 28px; box-shadow: var(--shadow); }
.hero::after { content: ''; position: absolute; width: 300px; height: 300px; right: -85px; bottom: -150px; border: 1px solid rgba(255,255,255,.16); border-radius: 50%; box-shadow: 0 0 0 34px rgba(255,255,255,.04), 0 0 0 68px rgba(255,255,255,.035); }
.eyebrow { margin: 0 0 10px; color: rgba(255,255,255,.67); font-size: 12px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: Manrope, sans-serif; letter-spacing: -.045em; }
.hero h1 { margin-bottom: 9px; font-size: clamp(26px, 3vw, 40px); line-height: 1.05; }
.hero-date { margin: 0; color: rgba(255,255,255,.75); font-size: 14px; }
.hero-summary { position: relative; z-index: 1; display: flex; gap: 30px; padding-right: 30px; }
.summary-number { display: block; font-family: Manrope, sans-serif; font-size: 34px; line-height: 1; }
.summary-label { display: block; margin-top: 7px; color: rgba(255,255,255,.66); font-size: 12px; }
.content-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 22px; margin-top: 22px; }
.panel { padding: 24px; background: rgba(255,255,255,.88); border: 1px solid rgba(220,232,245,.92); border-radius: 22px; box-shadow: 0 8px 24px rgba(20, 58, 90, .035); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.panel-heading-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.panel-heading h2 { margin: 0; font-size: 19px; }
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 10px 15px; border-radius: 12px; font-size: 13px; font-weight: 600; transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: white; background: var(--sage-dark); box-shadow: 0 8px 14px rgba(47, 111, 237, .18); }
.button-soft { color: var(--sage-dark); background: var(--sage-pale); }
.button-plain { min-height: auto; padding: 7px 0; color: var(--muted); background: transparent; }
.button-danger { color: #a94d3a; background: var(--coral-pale); }
.med-list { display: grid; gap: 10px; }
.med-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 15px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.med-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.med-icon { display: grid; place-items: center; flex: 0 0 auto; width: 35px; height: 35px; border-radius: 11px; background: var(--yellow-pale); color: #a17b14; }
.med-name { margin: 0; font-weight: 600; font-size: 14px; }
.med-dose { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.med-actions { display: flex; align-items: center; gap: 9px; }
.status { display: inline-flex; align-items: center; gap: 5px; padding: 6px 8px; border-radius: 8px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.status.taken { color: #4d765d; background: var(--sage-pale); }
.status.missed { color: #a94d3a; background: var(--coral-pale); }
.status.observed { color: #9a7313; background: var(--yellow-pale); }
.quick-actions { display: grid; gap: 11px; }
.quick-card { display: flex; align-items: center; gap: 13px; width: 100%; padding: 14px; color: var(--ink); text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; }
.quick-card:hover { border-color: var(--sage); background: #f8fbff; }
.quick-card-primary { color: white; background: var(--sage-dark); border-color: var(--sage-dark); }
.quick-card-primary:hover { color: white; background: #245dcc; border-color: #245dcc; }
.quick-card-primary .quick-icon { color: white; background: rgba(255,255,255,.14); }
.quick-card-primary .quick-copy { color: rgba(255,255,255,.72); }
.quick-icon { display: grid; place-items: center; flex: 0 0 auto; width: 39px; height: 39px; border-radius: 12px; color: var(--sage-dark); background: var(--sage-pale); font-size: 18px; }
.quick-icon.coral { color: #b65e4b; background: var(--coral-pale); }
.quick-title { margin: 0; font-weight: 600; font-size: 13px; }
.quick-copy { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.timeline-panel { margin-top: 22px; }
.timeline { display: grid; gap: 0; }
.timeline-item { position: relative; display: grid; grid-template-columns: 62px 18px 1fr auto; gap: 12px; align-items: start; min-height: 72px; }
.timeline-item::before { content: ''; position: absolute; top: 17px; bottom: -7px; left: 70px; border-left: 1px dashed #d4dbd4; }
.timeline-item:last-child::before { display: none; }
.timeline-time-actions { display: grid; justify-items: center; gap: 2px; width: 62px; }
.timeline-time { padding-top: 2px; color: var(--muted); font-size: 11px; text-align: center; }
.timeline-dot { position: relative; z-index: 1; width: 18px; height: 18px; border: 4px solid var(--surface); border-radius: 50%; background: var(--sage); box-shadow: 0 0 0 1px #a9c7ef; }
.timeline-dot.episode { background: var(--coral); box-shadow: 0 0 0 1px #eab2a4; }
.timeline-content { padding-bottom: 20px; }
.timeline-title { margin: 0; font-size: 13px; font-weight: 600; }
.timeline-detail { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.timeline-delete { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; color: #abb4ad; background: transparent; border-radius: 8px; font-size: 16px; line-height: 1; }
.timeline-delete:hover { color: #a94d3a; background: var(--coral-pale); }
.empty { padding: 22px 12px; color: var(--muted); font-size: 13px; text-align: center; border: 1px dashed #d7ddd5; border-radius: 14px; }
.add-med-form { display: grid; grid-template-columns: 1fr 110px auto; gap: 8px; margin-top: 16px; }
.input, .select, .textarea { width: 100%; padding: 11px 12px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 11px; font-size: 13px; }
.textarea { min-height: 82px; resize: vertical; }
.field { display: grid; gap: 7px; }
.field label { color: var(--muted); font-size: 11px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.modal-backdrop { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(25, 34, 29, .35); backdrop-filter: blur(4px); }
.modal { width: min(500px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 25px; background: var(--surface); border-radius: 22px; box-shadow: 0 25px 70px rgba(25, 34, 29, .2); }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.modal-heading h2 { margin: 0; font-size: 21px; }
.modal-heading p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.close { width: 32px; height: 32px; color: var(--muted); background: #edf4fc; border-radius: 10px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.notice { padding: 10px 12px; color: #8f4c3c; background: var(--coral-pale); border-radius: 10px; font-size: 12px; }
.patient-panel { margin-top: 22px; }
.patient-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.share-list { display: grid; gap: 9px; }
.share-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; }
.share-row strong, .share-row small { display: block; }
.share-row strong { font-size: 13px; font-weight: 600; }
.share-row small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.share-empty { padding: 13px; text-align: left; }
.invite-ready { display: grid; gap: 12px; }
.modal-copy { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.invite-ready .modal-actions { margin-top: 0; }
.invite-ready a { text-decoration: none; }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(440px, 100%); padding: 34px; background: rgba(255,253,248,.92); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); }
.auth-card .brand { margin-bottom: 35px; }
.auth-card h1 { margin-bottom: 8px; font-size: 28px; }
.auth-card .lead { margin-bottom: 24px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.auth-form { display: grid; gap: 14px; }
.auth-form .button { width: 100%; margin-top: 4px; }
.check-field { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; color: var(--muted); font-size: 12px; cursor: pointer; }
.check-field input { width: 15px; height: 15px; margin: 0; accent-color: var(--sage-dark); }
.check-field small { grid-column: 2; color: var(--muted); font-size: 11px; }
.auth-switch { margin: 20px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.auth-switch button { color: var(--sage-dark); background: transparent; font-weight: 700; }
.bio-box { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.bio-box p { margin: 0 0 10px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.offline-bar { position: fixed; z-index: 15; right: 18px; bottom: 18px; padding: 9px 12px; color: #8f4c3c; background: var(--coral-pale); border: 1px solid #f1c8bd; border-radius: 11px; font-size: 11px; box-shadow: var(--shadow); }
.app-screen { display: block; }
.mobile-only { display: none !important; }
.screen-log .content-grid { margin-top: 22px; }
.screen-log .quick-log-panel { grid-column: 2; }
.screen-log .medication-panel { grid-column: 1; grid-row: 1; }
.screen-more .settings-grid { grid-template-columns: 1.35fr 1fr; }
.screen-more .patient-panel { margin-top: 0; }
.screen-history .timeline-panel { margin-top: 22px; }
.screen-heading h1 { margin-bottom: 7px; font-size: 28px; }
.screen-heading > p:last-child { color: var(--muted); font-size: 12px; }
.mobile-eyebrow { color: var(--muted); }
.mobile-language { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.bottom-nav { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.print-only { display: none; }
@media (max-width: 720px) {
  /* iOS/WKWebView zooms focused form controls smaller than 16px. Keep the
     controls at the platform's no-auto-zoom size, especially on sign-in. */
  .input, .select, .textarea { font-size: 16px; }
  .shell { padding: 18px 16px calc(112px + env(safe-area-inset-bottom)); }
  .topbar { margin-bottom: 24px; }
  .topbar .language, .desktop-signout { display: none; }
  .brand-mark { width: 38px; height: 38px; border-radius: 13px; font-size: 19px; }
  .brand-title { font-size: 16px; }
  .user-chip { padding: 3px; border: 0; background: transparent; }
  .user-chip span { display: none; }
  .app-screen { display: none; }
  .app-screen.active { display: block; }
  .mobile-only { display: block !important; }
  .hero { display: block; min-height: auto; padding: 4px 0 0; color: var(--ink); background: transparent; border-radius: 0; box-shadow: none; overflow: visible; }
  .hero::after { display: none; }
  .hero .eyebrow { margin-bottom: 8px; color: var(--muted); }
  .hero h1 { margin-bottom: 8px; font-size: 31px; }
  .hero-date { color: var(--muted); }
  .hero-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 23px; padding: 0; }
  .hero-summary > div { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 17px; }
  .summary-number { color: var(--ink); font-size: 28px; }
  .summary-label { color: var(--muted); }
  .content-grid { grid-template-columns: 1fr; gap: 16px; margin-top: 16px; }
  .panel { padding: 19px; border-radius: 18px; }
  .home-actions { margin-top: 16px; }
  .home-recent { margin-top: 16px; }
  .home-recent .timeline-item:nth-child(n+3) { display: none; }
  .screen-heading { margin-bottom: 17px; }
  .screen-heading h1 { margin-bottom: 6px; font-size: 28px; }
  .screen-log .content-grid, .screen-more .settings-grid { display: grid; grid-template-columns: 1fr; margin-top: 0; }
  .screen-log .quick-log-panel, .screen-log .medication-panel { grid-column: auto; grid-row: auto; }
  .screen-more .patient-panel { margin-top: 0; }
  .screen-history .timeline-panel { margin-top: 0; }
  .quick-log-panel .panel-heading { margin-bottom: 12px; }
  .quick-actions { gap: 10px; }
  .quick-card { min-height: 66px; }
  .mobile-language { display: flex !important; justify-content: flex-start; }
  .mobile-language .language { display: flex; }
  .timeline-panel { margin-top: 16px; }
  .patient-panel { margin-top: 16px; }
  .panel-heading-actions { justify-content: flex-start; }
  .add-med-form { grid-template-columns: 1fr 100px; }
  .add-med-form .button { grid-column: 1 / -1; }
  .bottom-nav { position: fixed; z-index: 18; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); left: 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 9px 6px 8px; background: rgba(255, 255, 255, .96); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 14px 36px rgba(20, 58, 90, .16); backdrop-filter: blur(14px); }
  .bottom-nav-item { display: grid; place-items: center; gap: 3px; min-width: 0; min-height: 48px; padding: 4px 2px; color: var(--muted); background: transparent; border-radius: 14px; font-size: 9px; font-weight: 700; }
  .bottom-nav-item.active { color: var(--sage-dark); background: var(--sage-pale); }
  .bottom-nav-icon { display: grid; place-items: center; min-height: 22px; font-size: 17px; line-height: 1; }
  .offline-bar { right: 16px; bottom: calc(92px + env(safe-area-inset-bottom)); }
}
@media (max-width: 440px) {
  .brand-subtitle { display: none; }
  .top-actions { gap: 5px; }
  .language button { padding: 6px 7px; }
  .hero h1 { font-size: 28px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
}
@media print {
  body { background: white; }
  .shell { width: 100%; padding: 0; }
  .topbar, .hero, .quick-actions, .quick-log-panel, .add-med-form, .panel-heading button, .timeline-delete, .offline-bar, .bottom-nav, .screen-home, .screen-more { display: none !important; }
  .screen-log, .screen-history { display: block !important; }
  .content-grid { display: block; margin: 0; }
  .panel { padding: 0; border: 0; box-shadow: none; }
  .med-card { break-inside: avoid; }
  .timeline-panel { margin-top: 30px; }
  .print-only { display: block; }
  .print-only h1 { margin-bottom: 5px; }
  .print-only p { color: #555; font-size: 12px; }
}
