/* ------------------------------------------------------------------ */
/*  Tokens                                                              */
/* ------------------------------------------------------------------ */
:root {
  --ink: #10233F;
  --ink-soft: #4A5C78;
  --paper: #EEF3F1;
  --card: #FFFFFF;
  --teal: #0E7C7B;
  --teal-deep: #0A5E5D;
  --marigold: #F2A93B;
  --marigold-deep: #D68F1F;
  --amber: #E08E1D;
  --amber-bg: #FBF0DC;
  --green: #1F9D55;
  --green-bg: #E4F5EA;
  --red: #C24444;
  --red-bg: #FBEAEA;
  --line: #DCE4E1;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.display-title, h1, h2 { font-family: 'Fraunces', Georgia, serif; }
.mono { font-family: 'IBM Plex Mono', monospace; }
button, input { font-family: inherit; }
button { cursor: pointer; }

/* ------------------------------------------------------------------ */
/*  App shell / layout                                                  */
/* ------------------------------------------------------------------ */
.app-shell { display: flex; min-height: 100vh; max-width: 480px; margin: 0 auto; box-shadow: 0 0 0 1px var(--line); }
.main-col { flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.view-container { flex: 1; }

.side-nav { display: none; }
.bottom-nav {
  position: sticky; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; padding: 8px 0;
}
body.nav-hidden .bottom-nav, body.nav-hidden .side-nav { display: none !important; }

.bottom-nav-item, .side-nav-item {
  background: none; border: none; color: var(--ink-soft);
  display: flex; align-items: center; gap: 6px; border-radius: 10px;
}
.bottom-nav-item { flex-direction: column; gap: 2px; padding: 4px 10px; font-size: 10px; font-weight: 500; }
.bottom-nav-item.active { color: var(--teal); }
.side-nav-item { padding: 10px 12px; font-size: 14px; font-weight: 500; width: 100%; text-align: left; }
.side-nav-item.active { color: var(--teal); background: rgba(14,124,123,0.08); }

@media (min-width: 768px) {
  .app-shell { max-width: none; box-shadow: none; }
  .side-nav {
    display: flex; flex-direction: column; width: 240px; flex-shrink: 0;
    background: var(--card); border-right: 1px solid var(--line);
    min-height: 100vh; padding: 24px 16px;
  }
  .side-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 28px; font-family: 'Fraunces', serif; font-weight: 600; font-size: 14px; line-height: 1.25; color: var(--ink); }
  .side-items { display: flex; flex-direction: column; gap: 4px; }
  .bottom-nav { display: none; }
  .view-container { max-width: 1024px; margin: 0 auto; width: 100%; }
}
@media (min-width: 1024px) {
  .side-nav { width: 264px; }
}

/* ------------------------------------------------------------------ */
/*  Generic building blocks                                             */
/* ------------------------------------------------------------------ */
.hidden { display: none !important; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.page-pad { padding: 20px; padding-bottom: 96px; }
@media (min-width: 768px) { .page-pad { padding: 24px 32px 64px; } }

.eyebrow-label { font-size: 11px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 10px; }
.muted { color: var(--ink-soft); }
.muted-sm { color: var(--ink-soft); font-size: 13px; }
.muted-xs { color: var(--ink-soft); font-size: 11px; }
.bold { font-weight: 600; }
.text-sm { font-size: 14px; }
.center { text-align: center; }
.capitalize { text-transform: capitalize; }
.teal-text { color: var(--teal); }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; } .mb-5 { margin-bottom: 20px; } .mb-6 { margin-bottom: 24px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.full-w { width: 100%; }
.flex-1 { flex: 1; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Buttons */
.btn { border: none; border-radius: 12px; padding: 12px 16px; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background .15s ease, transform .1s ease; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-deep); }
.btn-cta { background: var(--marigold); color: var(--ink); font-weight: 700; }
.btn-cta:hover { background: var(--marigold-deep); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: rgba(16,35,63,0.04); }
.btn[disabled], .tier-select.disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 12px; }
.btn-row-tight { display: flex; gap: 8px; }
.link-btn { background: none; border: none; color: var(--teal); font-size: 12px; font-weight: 600; }
.icon-btn { background: none; border: none; color: var(--ink); padding: 4px; border-radius: 999px; margin-right: 4px; display: flex; }

/* Badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-muted { background: rgba(16,35,63,0.06); color: var(--ink-soft); }

/* Persistent header with role switcher */
.app-header {
  position: sticky; top: 0; z-index: 30; height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: var(--ink); color: #fff;
}
.app-header-brand { font-family: 'Fraunces', serif; font-weight: 600; font-size: 14px; }
.role-select {
  background: rgba(255,255,255,0.1); color: #fff; border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 500; font-family: inherit;
}
.role-select option { color: var(--ink); }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 4px; padding: 14px 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 52px; z-index: 15; }
@media (min-width: 768px) { .topbar { padding: 16px 32px; } }
.topbar-title { font-size: 18px; font-weight: 600; margin: 0; }

/* Forms */
.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 11px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.input { width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: 14px; color: var(--ink); }
.input:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.input:disabled { background: #F3F5F4; color: var(--ink-soft); }
.check-row { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; color: var(--ink-soft); cursor: pointer; }
.check-row input { margin-top: 2px; }

/* Product card */
.product-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; }
.product-card:hover { box-shadow: 0 1px 4px rgba(16,35,63,0.06); }
.product-icon { background: rgba(14,124,123,0.08); color: var(--teal); border-radius: 10px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.product-info { flex: 1; min-width: 0; }
.product-name { font-weight: 600; font-size: 14px; margin: 0; }
.product-cat { font-size: 12px; color: var(--ink-soft); margin: 2px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-price { text-align: right; flex-shrink: 0; }
.product-price .mono { font-size: 14px; font-weight: 600; color: var(--teal); }
.muted-xs.on-page { color: var(--ink-soft); }

.stack-grid { display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 768px) { .stack-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } }
@media (min-width: 1024px) { .stack-grid { grid-template-columns: 1fr 1fr 1fr; } }

.soon-block { padding-top: 16px; }
.soon-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 1024px) { .soon-grid { grid-template-columns: repeat(4, 1fr); } }
.soon-card { padding: 12px; display: flex; flex-direction: column; gap: 8px; opacity: 0.6; }
.soon-name { font-size: 12px; font-weight: 500; }

/* Hero (home) */
.hero { padding: 32px 20px 40px; background: linear-gradient(180deg, #10233F 0%, #16345A 100%); color: #fff; }
@media (min-width: 768px) { .hero { padding: 56px 32px 56px; } }
.hero-inner { display: flex; flex-direction: column; gap: 24px; }
@media (min-width: 768px) { .hero-inner { flex-direction: row; align-items: center; gap: 40px; max-width: 1024px; margin: 0 auto; } }
.hero-copy { flex: 1; }
.hero-eyebrow { display: flex; align-items: center; gap: 8px; color: #8FD9D8; font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.08em; margin-bottom: 20px; }
.hero-title { font-size: 30px; line-height: 1.15; font-weight: 600; margin: 0 0 12px; }
@media (min-width: 768px) { .hero-title { font-size: 46px; } }
.hero-sub { font-size: 14px; color: #B9C8DC; margin: 0 0 22px; max-width: 420px; }
@media (min-width: 768px) { .hero-sub { font-size: 16px; } }
.hero-signal { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.hero-signal-label { font-size: 12px; color: #8FD9D8; }
.hero-cta { margin-top: 22px; width: 100%; }
@media (min-width: 768px) { .hero-cta { width: auto; padding-left: 28px; padding-right: 28px; } }
.hero-visual { display: none; }
@media (min-width: 768px) {
  .hero-visual { display: flex; flex: 1; justify-content: flex-end; }
  .hero-bars { display: flex; align-items: flex-end; gap: 12px; padding: 32px; border-radius: 16px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); }
  .hero-bar { width: 20px; border-radius: 6px; background: #8FD9D8; }
  .hero-bar.off { background: rgba(255,255,255,0.2); }
}

.signal-bars { display: flex; align-items: flex-end; gap: 4px; }
.signal-bar { width: 6px; background: rgba(255,255,255,0.25); border-radius: 2px; transition: background .4s ease; }
.signal-bar.on { background: #8FD9D8; }
.signal-bar.rise { transform-origin: bottom; animation: rise 0.8s ease forwards; }
@keyframes rise { from { transform: scaleY(0.2); opacity: 0.4; } to { transform: scaleY(1); opacity: 1; } }

/* Section / steps */
.section { padding: 32px 20px 0; }
@media (min-width: 768px) { .section { padding: 48px 32px 0; max-width: 1024px; margin: 0 auto; } }
.section-title { font-size: 18px; font-weight: 600; margin: 0 0 16px; }
@media (min-width: 768px) { .section-title { font-size: 22px; } }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.steps-grid { display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 768px) { .steps-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; } }
.step-card { padding: 16px; display: flex; align-items: flex-start; gap: 12px; }
@media (min-width: 768px) { .step-card { flex-direction: column; } }
.step-num { background: rgba(14,124,123,0.08); color: var(--teal); border-radius: 999px; width: 32px; height: 32px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-family: 'IBM Plex Mono', monospace; font-size: 12px; font-weight: 600; }
.step-title { font-weight: 600; font-size: 14px; margin: 0; }
.step-desc { font-size: 12px; color: var(--ink-soft); margin: 3px 0 0; }

/* Product detail */
.block-card { padding: 16px; }
.tier-row { display: flex; align-items: center; justify-content: space-between; font-size: 14px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.tier-row:last-child { border-bottom: none; }
.benefit-row { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; margin-bottom: 8px; }
.icon.green { color: var(--green); }
.icon.muted { color: var(--ink-soft); }

/* Enrollment */
.enroll-pad { max-width: 640px; }
.progress-bar { display: flex; gap: 6px; margin-bottom: 24px; }
.progress-seg { flex: 1; height: 4px; border-radius: 4px; }
.tier-list { display: flex; flex-direction: column; gap: 8px; }
.tier-select { display: flex; align-items: center; justify-content: space-between; text-align: left; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 14px; }
.tier-select.active { border-color: var(--teal); border-width: 2px; background: rgba(14,124,123,0.06); }
.health-q { padding: 14px; margin-bottom: 10px; }
.pill { padding: 6px 16px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.pill.active { background: var(--teal); border-color: var(--teal); color: #fff; }
.decision-block { text-align: center; padding: 24px 0; }
.decision-icon { border-radius: 999px; width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.decision-icon.green { background: var(--green-bg); color: var(--green); }
.decision-icon.amber { background: var(--amber-bg); color: var(--amber); }
.decision-icon.red { background: var(--red-bg); color: var(--red); }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; display: inline-block; animation: spin 0.7s linear infinite; }
.btn-ghost .spinner { border: 2px solid rgba(16,35,63,0.2); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Dashboard / policy */
.empty-state { text-align: center; padding: 48px 0; }
.policy-card { width: 100%; text-align: left; padding: 16px; }
.policy-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.stage-progress { display: flex; align-items: flex-start; width: 100%; }
.stage-step { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 60px; }
.stage-dot { width: 22px; height: 22px; border-radius: 999px; display: flex; align-items: center; justify-content: center; }
.stage-num { font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--ink-soft); }
.icon.on-dark { color: #fff; }
.stage-label { font-size: 10px; text-align: center; color: var(--ink-soft); line-height: 1.2; }
.stage-line { flex: 1; height: 2px; margin-top: -14px; }
.mini-stat { padding: 14px; }
.profile-card { padding: 20px; display: flex; align-items: center; gap: 16px; }
.avatar { background: rgba(14,124,123,0.08); color: var(--teal); border-radius: 999px; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; font-family: 'Fraunces', serif; font-size: 20px; font-weight: 600; }
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-row { display: flex; align-items: flex-start; gap: 10px; }
.history-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--teal); margin-top: 7px; flex-shrink: 0; }

/* Toast */
#toast { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 50; padding: 10px 18px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(16,35,63,0.12); font-size: 13px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
#toast.show { opacity: 1; }

.icon { display: inline-block; vertical-align: middle; }
