/* ─────────────────────────────────────────────────────────────────────────
   NorthStar Patient App — mobile-first design system
   Brand tokens mirror the NorthStar OS (navy / gold / cream) so the patient
   app feels of-a-piece, while living in its own independently deployable shell.
   ───────────────────────────────────────────────────────────────────────── */
:root {
  --navy: #0F1B2D; --navy-2: #16273F; --navy-3: #1c2f4a;
  --gold: #C9A96E; --gold-2: #e0c896; --gold-deep: #8a6b30;
  --cream: #F7F5F1; --bg: #F2EFE8; --surface: #fff;
  --border: #E5E1D8; --text: #1A1A1A; --text-2: #6B6B6B; --text-3: #9a9a9a;
  --green: #4CAF8A; --green-deep: #2f7a5c; --amber: #C99A3E; --red: #B5524A;
  --shadow: 0 8px 30px rgba(15,27,45,0.10);
  --radius: 16px; --radius-sm: 10px;
  --tab-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  line-height: 1.45; -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ── Phone frame ──────────────────────────────────────────────────────────
   Mobile-first: on a phone the app is full-bleed; on desktop it sits in a
   centered phone-width frame so testers see the real mobile layout.          */
#app-frame {
  max-width: 460px; margin: 0 auto; min-height: 100vh;
  background: var(--surface); position: relative;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
@media (min-width: 480px) {
  body { padding: 24px 0; }
  #app-frame { min-height: calc(100vh - 48px); border-radius: 22px; overflow: hidden; }
}

/* ── Login / identity ─────────────────────────────────────────────────────*/
#login {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 40px 26px;
  background: linear-gradient(165deg, var(--navy), var(--navy-3));
  color: var(--cream); min-height: 100vh;
}
.login-mark { font-size: 40px; text-align: center; }
.login-brand {
  text-align: center; font-size: 12px; font-weight: 700; letter-spacing: 2px;
  text-transform: uppercase; color: var(--gold); margin-top: 10px;
}
.login-title { text-align: center; font-size: 26px; font-weight: 600; margin-top: 14px; }
.login-sub {
  text-align: center; font-size: 14px; color: rgba(247,245,241,0.65);
  margin-top: 8px; line-height: 1.5;
}
.login-section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: rgba(247,245,241,0.45); margin: 34px 0 12px;
}
.identity-card {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: rgba(255,255,255,0.06); border: 0.5px solid rgba(255,255,255,0.14);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px;
  color: var(--cream); text-align: left; transition: background .15s;
}
.identity-card:active { background: rgba(255,255,255,0.12); }
.identity-avatar {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  background: var(--gold); color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
}
.identity-name { font-size: 16px; font-weight: 600; }
.identity-q { font-size: 12.5px; color: rgba(247,245,241,0.6); margin-top: 2px; }
.identity-go { margin-left: auto; color: var(--gold); font-size: 20px; }
.login-form { margin-top: 6px; }
.login-input {
  width: 100%; padding: 14px 16px; border-radius: var(--radius-sm);
  border: 0.5px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.05);
  color: var(--cream); font-size: 15px; margin-bottom: 10px;
}
.login-input::placeholder { color: rgba(247,245,241,0.4); }
.login-btn {
  width: 100%; padding: 15px; border: none; border-radius: var(--radius-sm);
  background: var(--gold); color: var(--navy); font-size: 15px; font-weight: 700;
}
.login-note {
  font-size: 11px; color: rgba(247,245,241,0.4); text-align: center;
  margin-top: 22px; line-height: 1.5;
}

/* ── Top bar ──────────────────────────────────────────────────────────────*/
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 0.5px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 5;
}
.topbar-brand { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--gold); }
.topbar-greet { font-size: 17px; font-weight: 600; margin-top: 1px; }
.topbar-avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--navy);
  color: var(--gold); display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; border: none;
}

/* ── Scrollable content + views ───────────────────────────────────────────*/
#content { flex: 1; overflow-y: auto; padding: 18px 18px calc(var(--tab-h) + 24px); }
.view { display: none; animation: fade .2s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.view-title { font-size: 22px; font-weight: 700; margin-bottom: 2px; }
.view-sub { font-size: 13px; color: var(--text-2); margin-bottom: 16px; }

/* ── Cards ────────────────────────────────────────────────────────────────*/
.card {
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-3); font-weight: 700; margin: 22px 0 10px;
}

/* ── Hero (answer to the patient's question) ──────────────────────────────*/
.hero {
  background: linear-gradient(160deg, var(--navy), var(--navy-3));
  border-radius: var(--radius); padding: 22px 20px; margin-bottom: 16px; color: var(--cream);
}
.hero-q { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: rgba(247,245,241,0.5); }
.hero-q b { color: var(--gold); font-weight: 600; }
.hero-answer { font-size: 15.5px; line-height: 1.55; margin-top: 10px; }

/* ── Score rings ──────────────────────────────────────────────────────────*/
.score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 6px; }
.score-card {
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 16px 14px; text-align: center;
}
.score-card.tap { cursor: pointer; }
.ring { width: 104px; height: 104px; margin: 2px auto 8px; }
.ring-track { fill: none; stroke: rgba(15,27,45,0.08); stroke-width: 9; }
.ring-fill { fill: none; stroke-width: 9; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 1s ease; }
.ring-num { font-size: 26px; font-weight: 700; fill: var(--navy); }
.ring-den { font-size: 10px; fill: var(--text-3); }
.score-name { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.score-band { font-size: 11px; font-weight: 700; margin-top: 4px; }
.score-trend { font-size: 10.5px; color: var(--text-2); margin-top: 3px; }
.band-Building { color: var(--amber); }
.band-Steady { color: var(--green-deep); }
.band-Strong { color: var(--green-deep); }

/* score detail pillars */
.pillar { margin-bottom: 12px; }
.pillar-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; }
.pillar-val { color: var(--navy); }
.pillar-bar { height: 7px; background: rgba(15,27,45,0.07); border-radius: 4px; overflow: hidden; margin: 5px 0 4px; }
.pillar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--gold), var(--gold-2)); }
.pillar-note { font-size: 11.5px; color: var(--text-2); }

/* ── Test result accordion ────────────────────────────────────────────────*/
.test {
  border: 0.5px solid var(--border); border-radius: var(--radius);
  margin-bottom: 12px; overflow: hidden; background: var(--surface);
}
.test-head { display: flex; align-items: center; gap: 12px; padding: 15px 16px; }
.test-ic {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.test-titles { flex: 1; }
.test-name { font-size: 14.5px; font-weight: 600; }
.test-headline { font-size: 12px; color: var(--text-2); margin-top: 2px; line-height: 1.35; }
.test-chev { color: var(--text-3); font-size: 14px; transition: transform .2s; }
.test.open .test-chev { transform: rotate(180deg); }
.test-body { display: none; padding: 0 16px 16px; }
.test.open .test-body { display: block; }
.test-metrics { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.metric { flex: 1; min-width: 90px; background: var(--bg); border-radius: var(--radius-sm); padding: 10px 12px; }
.metric-val { font-size: 16px; font-weight: 700; color: var(--navy); }
.metric-label { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.metric-context { font-size: 10.5px; color: var(--text-3); margin-top: 1px; }
.test-blk { margin-bottom: 10px; }
.test-blk-h { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--gold-deep); }
.test-blk-t { font-size: 13px; color: var(--text); line-height: 1.5; margin-top: 2px; }

/* ── Plan (nutrition / activity) ──────────────────────────────────────────*/
.plan-summary { font-size: 14.5px; font-weight: 600; line-height: 1.45; }
.plan-why { font-size: 12.5px; color: var(--gold-deep); font-style: italic; margin-top: 6px; }
.target-row, .week-row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 0.5px solid var(--border); }
.target-row:last-child, .week-row:last-child { border-bottom: none; }
.target-label { font-size: 13.5px; font-weight: 600; flex-shrink: 0; min-width: 96px; }
.target-val { font-size: 13.5px; font-weight: 700; color: var(--navy); }
.target-note { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.week-day {
  font-size: 11px; font-weight: 700; color: var(--gold-deep); flex-shrink: 0;
  min-width: 74px; text-transform: uppercase; letter-spacing: .3px; padding-top: 2px;
}
.week-focus { font-size: 13.5px; font-weight: 600; }
.week-detail { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chip { font-size: 12px; background: var(--bg); border-radius: 20px; padding: 7px 13px; color: var(--text); }
.list-clean { list-style: none; }
.list-clean li { font-size: 13px; padding: 7px 0 7px 22px; position: relative; color: var(--text); border-bottom: 0.5px solid var(--border); }
.list-clean li:last-child { border-bottom: none; }
.list-clean li::before { content: "✓"; position: absolute; left: 0; color: var(--green); font-weight: 700; }
.guardrail li::before { content: "!"; color: var(--amber); }

/* ── Goals / habits ───────────────────────────────────────────────────────*/
.goal { margin-bottom: 16px; }
.goal:last-child { margin-bottom: 0; }
.goal-top { display: flex; justify-content: space-between; align-items: baseline; }
.goal-label { font-size: 14px; font-weight: 600; }
.goal-streak { font-size: 12px; color: var(--gold-deep); font-weight: 600; }
.goal-meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-2); margin: 6px 0 5px; }
.goal-bar { height: 9px; background: rgba(15,27,45,0.07); border-radius: 5px; overflow: hidden; }
.goal-fill { height: 100%; border-radius: 5px; background: var(--green); transition: width .8s ease; }

/* ── Timeline ─────────────────────────────────────────────────────────────*/
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; left: -26px; top: 2px; width: 16px; height: 16px; border-radius: 50%; border: 3px solid var(--surface); background: var(--gold); }
.tl-dot.milestone { background: var(--navy); }
.tl-dot.win { background: var(--green); }
.tl-date { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .3px; }
.tl-title { font-size: 14px; font-weight: 600; margin-top: 2px; }
.tl-detail { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }

/* ── Visit summary ────────────────────────────────────────────────────────*/
.visit-head { font-size: 15px; font-weight: 600; line-height: 1.45; }
.visit-meta { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.visit-next {
  background: var(--bg); border-radius: var(--radius-sm); padding: 13px 15px; margin-top: 6px;
  font-size: 13px; display: flex; gap: 10px; align-items: flex-start;
}

/* ── Integrations ─────────────────────────────────────────────────────────*/
.integration { display: flex; align-items: center; gap: 13px; padding: 13px 0; border-bottom: 0.5px solid var(--border); }
.integration:last-child { border-bottom: none; }
.integration-ic {
  width: 40px; height: 40px; border-radius: 11px; background: var(--bg); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.integration-name { font-size: 14px; font-weight: 600; }
.integration-detail { font-size: 12px; color: var(--text-2); margin-top: 1px; }
.integration-btn {
  margin-left: auto; border: 0.5px solid var(--navy); background: var(--surface);
  color: var(--navy); font-size: 12.5px; font-weight: 600; padding: 8px 14px; border-radius: 20px;
}
.integration-btn.connected { background: rgba(76,175,138,0.14); color: var(--green-deep); border-color: transparent; }
.integration-btn.soon { color: var(--text-3); border-color: var(--border); pointer-events: none; }

/* ── Disclaimer / footer ──────────────────────────────────────────────────*/
.disclaimer {
  display: flex; gap: 9px; align-items: flex-start; background: var(--bg);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 8px;
  font-size: 11.5px; color: var(--text-2); line-height: 1.5;
}

/* ── Early-preview footer (rendered at the bottom of every view) ───────────*/
.preview-footer { margin-top: 18px; padding-top: 14px; border-top: 0.5px solid var(--border); }
.preview-warn {
  display: flex; gap: 8px; align-items: flex-start;
  background: rgba(201,154,62,0.12); border: 0.5px solid rgba(201,154,62,0.3);
  border-radius: var(--radius-sm); padding: 11px 13px;
  font-size: 12px; font-weight: 600; color: var(--gold-deep); line-height: 1.45;
}
.preview-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 12px;
}
.preview-version { font-size: 11px; font-weight: 700; letter-spacing: .3px; color: var(--text-3); text-transform: uppercase; }
.feedback-link {
  font-size: 12.5px; font-weight: 600; color: var(--navy);
  text-decoration: none; border: 0.5px solid var(--navy);
  border-radius: 20px; padding: 7px 14px; white-space: nowrap;
}
.feedback-link:active { background: var(--bg); }
.preview-edu { font-size: 11px; color: var(--text-3); line-height: 1.5; margin-top: 12px; }

/* ── Early-preview badge (top bar + login) ─────────────────────────────────*/
.preview-badge {
  display: inline-block; font-size: 9px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; vertical-align: middle; margin-left: 6px;
  color: var(--gold-deep); background: rgba(201,169,110,0.18);
  border-radius: 9px; padding: 2px 7px;
}

/* ── Login: disclaimer, version, feedback ──────────────────────────────────*/
.login-disclaimer {
  margin-top: 16px; font-size: 12.5px; line-height: 1.5; color: var(--cream);
  background: rgba(201,154,62,0.16); border: 0.5px solid rgba(201,169,110,0.35);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.login-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 18px; flex-wrap: wrap;
}
.login-footer .feedback-link { color: var(--gold); border-color: rgba(201,169,110,0.5); }
.login-version { font-size: 10.5px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; color: rgba(247,245,241,0.4); }
.empty { font-size: 13px; color: var(--text-2); background: var(--bg); border-radius: var(--radius-sm); padding: 20px; text-align: center; }
.pending {
  font-size: 12px; color: var(--text-2); background: var(--bg);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 4px;
}

/* ── Today view extras ────────────────────────────────────────────────────*/
.focus-card {
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; color: var(--cream);
}
.focus-h { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--gold); font-weight: 700; margin-bottom: 10px; }
.focus-row { display: flex; gap: 11px; align-items: flex-start; padding: 7px 0; font-size: 13.5px; }
.focus-row .ic { font-size: 16px; flex-shrink: 0; }
.focus-row .lbl { display: block; font-size: 11px; color: rgba(247,245,241,0.5); }
.focus-encourage { margin-top: 10px; padding-top: 10px; border-top: 0.5px solid rgba(247,245,241,0.15); font-size: 13px; color: var(--gold); font-style: italic; }

/* ── Bottom tab bar ───────────────────────────────────────────────────────*/
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 460px; margin: 0 auto;
  height: var(--tab-h); display: flex; background: var(--surface);
  border-top: 0.5px solid var(--border); z-index: 10;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab {
  flex: 1; border: none; background: none; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  font-size: 10.5px; color: var(--text-3); padding: 8px 0;
}
.tab .tab-ic { font-size: 19px; }
.tab.active { color: var(--gold-deep); font-weight: 700; }
