:root {
  font-family: var(--pulse-font-ui);
  color: var(--pulse-text);
  background: var(--pulse-mist);
  font-size: 16px;
  --background: var(--pulse-mist);
  --surface: var(--pulse-surface);
  --text: var(--pulse-text);
  --muted: var(--pulse-secondary-text);
  --dark: var(--pulse-forest);
  --accent: var(--pulse-dark-green);
  --accent-soft: rgba(0, 208, 132, .12);
  --border: var(--pulse-border);
  --warning: var(--pulse-warning);
  --warning-soft: var(--pulse-warning-surface);
  --danger: var(--pulse-danger);
  --danger-soft: var(--pulse-danger-surface);
  --radius: var(--pulse-radius-lg);
  --shadow: var(--pulse-shadow-subtle);
}

* { box-sizing: border-box; }
*[hidden] { display: none !important; }
html { min-height: 100%; background: var(--background); }
body { min-width: 320px; min-height: 100%; margin: 0; overflow-x: hidden; background: var(--background); }
body, button, select { font: inherit; }
a { color: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, a:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: none; box-shadow: var(--pulse-focus); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 7vw, 3rem); line-height: 1.04; letter-spacing: -.04em; }
h2 { font-size: 1.35rem; line-height: 1.2; letter-spacing: -.025em; }
h3 { font-size: 1rem; line-height: 1.35; }
p { line-height: 1.55; }

.app-shell { min-height: 100vh; padding-bottom: 86px; }
.app-shell { display: block; }
.platform-sidebar { display: none; }
.app-workspace { min-width: 0; max-width: 100%; }
.app-header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 16px; padding: 14px max(16px, env(safe-area-inset-left)) 12px max(16px, env(safe-area-inset-right)); border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--pulse-mist) 92%, transparent); backdrop-filter: blur(16px); }
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; }
.brand-copy { display: grid; gap: 4px; min-width: 0; color: var(--dark); font-size: .9rem; font-weight: 700; letter-spacing: .12em; line-height: 1; }
.brand-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-copy small { color: var(--muted); font-size: .55rem; font-weight: 500; letter-spacing: .12em; }
.brand-mobile { flex: 0 1 auto; }
.brand-sidebar { align-items: flex-start; padding: 4px 8px; }
.header-context { display: none; min-width: 0; gap: 3px; }
.header-context > span:last-child { overflow: hidden; color: var(--text); font-size: .95rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.beta-label { color: var(--accent); font-size: .68rem; font-weight: 700; letter-spacing: .12em; }
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--dark); box-shadow: var(--shadow); font-size: 1.35rem; line-height: 1; }
.icon-button:hover { border-color: var(--pulse-signal); background: var(--accent-soft); }

main { max-width: 1180px; min-height: calc(100vh - 150px); margin: 0 auto; padding: 24px 16px 32px; }
.page { display: grid; gap: 16px; }
.page-header { display: grid; gap: 16px; }
.section-heading { display: grid; gap: 8px; }
.section-heading h1 { color: var(--text); }
.eyebrow { color: var(--accent); font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.role-context { display: grid; gap: 5px; padding: 18px 8px; border-top: 1px solid rgba(0, 208, 132, .18); border-bottom: 1px solid rgba(0, 208, 132, .18); }
.role-context strong { color: var(--pulse-mist); font-size: 1.05rem; }
.role-context .muted { color: rgba(242, 247, 244, .68); font-size: .875rem; }
.role-context .eyebrow { color: var(--pulse-signal); }
.sidebar-nav { display: grid; gap: 7px; padding-top: 12px; }
.sidebar-nav a { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 12px; border-radius: var(--pulse-radius-md); color: rgba(242, 247, 244, .72); font-size: .95rem; font-weight: 500; text-decoration: none; transition: background 160ms ease, color 160ms ease; }
.sidebar-nav a:hover, .sidebar-nav a[aria-current="page"] { background: rgba(0, 208, 132, .13); color: var(--pulse-mist); }
.sidebar-nav a[aria-current="page"] { box-shadow: inset 3px 0 var(--pulse-signal); }
.sidebar-nav a[aria-disabled="true"] { cursor: default; opacity: .5; }
.sidebar-nav .nav-icon { color: var(--pulse-signal); }
.sidebar-footer { display: grid; gap: 16px; margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(0, 208, 132, .18); }
.shell-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.shell-user-copy { display: grid; min-width: 0; gap: 4px; }
.shell-user-copy strong, .shell-user-copy .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-user-copy strong { color: var(--pulse-mist); font-size: .9rem; }
.shell-user-copy .muted { color: rgba(242, 247, 244, .62); font-size: .78rem; }
.text-button { justify-self: start; min-height: 44px; padding: 8px 0; background: transparent; color: rgba(242, 247, 244, .72); font-size: .875rem; font-weight: 500; }
.text-button:hover { color: var(--pulse-signal); }

.identity-line { display: flex; align-items: center; gap: 12px; }
.identity-line > div { display: grid; gap: 3px; }
.avatar, .profile-avatar { display: grid; place-items: center; flex: 0 0 auto; background: var(--pulse-signal); color: var(--pulse-black); font-weight: 700; }
.avatar { width: 42px; height: 42px; border-radius: 50%; }
.identity-line strong { font-size: .98rem; }

.hero-card, .index-card, .panel, .profile-card, .state-card { border: 1px solid var(--border); border-radius: var(--pulse-radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.hero-card { display: grid; gap: 24px; padding: 24px; background: var(--dark); border-color: var(--dark); color: var(--pulse-mist); }
.hero-card .eyebrow { color: var(--pulse-signal); }
.hero-card .muted, .hero-description { color: rgba(242, 247, 244, .72); }
.hero-card.positive { background: var(--dark); }
.hero-card.warm { background: #24352d; }
.hero-card.neutral { background: #31443a; }
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.hero-top > div { display: grid; gap: 8px; }
.hero-top h2 { font-size: clamp(1.45rem, 5vw, 2rem); }
.hero-description { max-width: 520px; font-size: 1rem; }
.status-pill, .type-pill { display: inline-flex; align-items: center; white-space: nowrap; border-radius: var(--pulse-radius-pill); padding: 7px 11px; font-size: .75rem; font-weight: 700; }
.status-pill { background: rgba(0, 208, 132, .15); color: var(--pulse-signal); }
.progress-wrap { display: grid; gap: 9px; }
.progress-meta { display: flex; justify-content: space-between; gap: 10px; color: rgba(242, 247, 244, .72); font-size: .875rem; }
.progress-meta strong { color: var(--pulse-mist); }
.progress-track { height: 8px; overflow: hidden; border-radius: var(--pulse-radius-pill); background: rgba(242, 247, 244, .14); }
.progress-value { display: block; height: 100%; border-radius: inherit; background: var(--pulse-signal); transition: width 240ms ease; }

.index-card { display: grid; align-content: start; gap: 10px; min-height: 220px; padding: 24px; background: var(--dark); color: var(--pulse-mist); border-color: var(--dark); }
.index-card .eyebrow { color: var(--pulse-signal); }
.state-index-ring { display: grid; place-items: center; align-content: center; width: min(188px, 54vw); aspect-ratio: 1; margin: 2px 0 0; border: 2px solid var(--pulse-signal); border-radius: 50%; background: radial-gradient(circle at center, rgba(0, 208, 132, .12) 0 56%, transparent 57%); box-shadow: inset 0 0 0 10px rgba(0, 208, 132, .05); }
.state-index-ring strong { font-family: var(--pulse-font-numeric); font-size: clamp(3.5rem, 16vw, 5.75rem); line-height: .88; letter-spacing: -.08em; }
.state-index-ring .index-scale { margin-top: 8px; color: rgba(242, 247, 244, .7); font-size: .875rem; }
.state-index-ring.is-empty { width: 120px; border-color: rgba(242, 247, 244, .34); background: transparent; box-shadow: none; }
.state-index-ring.is-empty strong { font-size: 3.5rem; color: rgba(242, 247, 244, .7); }
.index-card .muted { max-width: 420px; color: rgba(242, 247, 244, .7); font-size: .875rem; }
.index-empty { background: var(--surface); color: var(--text); border-color: var(--border); }
.index-empty .eyebrow { color: var(--accent); }
.index-empty .state-index-ring { border-color: var(--border); background: var(--pulse-mist); }
.index-empty .state-index-ring strong { color: var(--muted); }
.index-empty .muted { color: var(--muted); }

.panel, .profile-card { padding: 22px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.panel-heading > div { display: grid; gap: 6px; }
.metric-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.metric-tile { display: grid; gap: 6px; min-width: 0; padding: 16px; border: 1px solid rgba(0, 116, 76, .12); border-radius: var(--pulse-radius-md); background: var(--pulse-mist); }
.metric-label { overflow: hidden; color: var(--muted); font-size: .875rem; text-overflow: ellipsis; white-space: nowrap; }
.metric-tile strong { font-family: var(--pulse-font-numeric); font-size: 1.8rem; letter-spacing: -.04em; }
.analytics-panel { display: grid; gap: 2px; }
.facts-grid { display: grid; gap: 20px; }
.fact-block { display: grid; gap: 10px; }
.fact-block h3 { color: var(--text); }
.fact-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.fact-list li { position: relative; padding-left: 18px; color: var(--text); line-height: 1.5; }
.fact-list li::before { position: absolute; top: .62em; left: 0; width: 7px; height: 7px; border-radius: 50%; background: var(--pulse-signal); content: ""; }
.scenario-block { display: grid; gap: 10px; }
.scenario-card { display: grid; gap: 4px; padding: 14px 16px; border-left: 3px solid var(--border); background: rgba(242, 247, 244, .75); }
.scenario-main { border-left-color: var(--pulse-signal); background: var(--accent-soft); }
.scenario-title { font-weight: 700; }
.observation { padding: 13px 15px; border-radius: var(--pulse-radius-sm); background: var(--pulse-mist); color: var(--text); }

.state-card { display: grid; justify-items: start; gap: 12px; padding: 30px 24px; }
.state-card h2 { margin-top: 2px; }
.state-card p { max-width: 560px; }
.state-icon, .lock-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 1.25rem; font-weight: 700; }
.state-card-error { border-color: #efc5be; background: var(--danger-soft); }
.state-card-error .state-icon { background: var(--surface); color: var(--danger); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px; border-radius: var(--pulse-radius-sm); background: var(--accent); color: var(--pulse-mist); font-weight: 700; text-decoration: none; }
.button:hover { background: var(--pulse-signal); color: var(--pulse-black); }
.locked-state { background: rgba(255, 255, 255, .55); box-shadow: none; }
.locked-panel { display: grid; justify-items: start; gap: 14px; }
.locked-panel .progress-wrap { width: 100%; margin-top: 6px; }
.locked-panel .progress-meta { color: var(--muted); }
.locked-panel .progress-meta strong { color: var(--text); }
.locked-panel .progress-track { background: var(--border); }
.locked-panel .progress-value { background: var(--pulse-signal); }

.chart-panel { display: grid; gap: 18px; }
.chart-toolbar { display: grid; gap: 14px; }
.period-switch { display: flex; flex-wrap: wrap; gap: 8px; }
.period-button, .metric-select { min-height: 44px; border: 1px solid var(--border); border-radius: var(--pulse-radius-sm); background: var(--surface); color: var(--text); font-size: .875rem; font-weight: 700; }
.period-button { padding: 8px 13px; }
.period-button:hover, .period-button.is-active { border-color: var(--pulse-signal); background: var(--accent-soft); color: var(--accent); }
.metric-select-label { display: grid; gap: 6px; max-width: 280px; }
.metric-select { width: 100%; padding: 8px 10px; font-weight: 500; }
.status-pill-light { background: var(--accent-soft); color: var(--accent); }
.chart-shell { display: grid; gap: 8px; min-width: 0; }
.chart-meta { display: flex; justify-content: space-between; gap: 10px; }
.pulse-chart { display: block; width: 100%; max-width: 100%; height: auto; min-height: 190px; overflow: hidden; }
.chart-axis { stroke: var(--border); stroke-width: 1; }
.chart-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 5; }
.chart-line { fill: none; stroke: var(--pulse-signal); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-point { fill: var(--surface); stroke: var(--pulse-signal); stroke-width: 3; }
.chart-axis-label { fill: var(--muted); font-size: 12px; }
.chart-caption { margin-top: 2px; }
.chart-loading { display: grid; min-height: 190px; place-items: center; color: var(--muted); }
.chart-error { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; border-radius: var(--pulse-radius-sm); background: var(--danger-soft); color: var(--danger); }
.chart-error p { min-width: 0; }
.chart-retry { flex: 0 0 auto; min-height: 40px; padding: 8px 12px; border: 1px solid currentColor; border-radius: var(--pulse-radius-sm); background: var(--surface); color: var(--danger); font-weight: 700; }
.chart-retry:hover { background: var(--danger); color: var(--surface); }
.chart-empty { box-shadow: none; }

.comparison-list, .point-list, .history-list { display: grid; gap: 11px; }
.comparison-card, .point-card, .history-card { border: 1px solid var(--border); border-radius: var(--pulse-radius-md); background: var(--surface); }
.comparison-card { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 16px; }
.comparison-card > div:first-child, .comparison-values { display: grid; gap: 5px; }
.comparison-values { justify-items: end; }
.comparison-values strong { font-family: var(--pulse-font-numeric); font-size: 1.45rem; }
.comparison-card > p { grid-column: 1 / -1; }
.point-card { display: grid; gap: 12px; padding: 16px; }
.point-meta, .history-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.point-metrics, .history-metrics { display: flex; flex-wrap: wrap; gap: 8px; }
.point-metric, .history-metrics span { padding: 6px 9px; border-radius: var(--pulse-radius-sm); background: var(--accent-soft); color: var(--accent); font-size: .8rem; }
.history-card { position: relative; display: grid; gap: 13px; padding: 17px 17px 17px 28px; }
.history-card::before { position: absolute; top: 21px; bottom: 21px; left: 14px; width: 2px; border-radius: var(--pulse-radius-pill); background: var(--pulse-signal); content: ""; opacity: .65; }
.history-card-header > div { display: grid; gap: 5px; }
.type-pill { background: var(--pulse-mist); color: var(--muted); }
.history-note { padding-top: 11px; border-top: 1px solid var(--border); color: var(--warning); font-size: .875rem; }
.history-count { text-align: center; }
.single-point-note { margin: -4px 0 4px; }

.profile-card { display: flex; align-items: center; gap: 16px; min-width: 0; width: 100%; }
.profile-avatar { flex: 0 0 60px; width: 60px; height: 60px; aspect-ratio: 1 / 1; border-radius: var(--pulse-radius-md); font-size: 1.55rem; }
.profile-copy { display: grid; flex: 1 1 auto; min-width: 0; gap: 6px; }
.profile-copy h2 { overflow-wrap: anywhere; }
.profile-fields { display: grid; padding: 0; overflow: hidden; }
.profile-field { display: grid; gap: 5px; padding: 17px 19px; border-bottom: 1px solid var(--border); }
.profile-field:last-child { border-bottom: 0; }
.profile-empty { box-shadow: none; }

.clients-page { align-content: start; }
.clients-list { display: grid; gap: 12px; min-width: 0; }
.client-card { display: grid; gap: 16px; min-width: 0; padding: 20px; border: 1px solid var(--border); border-radius: var(--pulse-radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.client-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; min-width: 0; }
.client-card-heading > div { display: grid; gap: 5px; min-width: 0; }
.client-card-heading h2 { overflow-wrap: anywhere; }
.client-baseline { flex: 0 0 auto; border-radius: var(--pulse-radius-pill); padding: 7px 10px; font-size: .75rem; font-weight: 700; }
.client-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.client-facts > div { display: grid; align-content: start; gap: 5px; min-width: 0; }
.client-facts strong { overflow-wrap: anywhere; font-size: .9rem; }
.client-attention { padding-top: 12px; border-top: 1px solid var(--border); }
.clients-empty { box-shadow: none; }
.clients-loading { min-height: 32vh; }

.bottom-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr); padding: 8px max(12px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-right)); border-top: 1px solid var(--border); background: rgba(255, 255, 255, .94); box-shadow: 0 -5px 20px rgba(13, 25, 21, .06); backdrop-filter: blur(12px); }
.has-clients-access .bottom-nav { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.bottom-nav a { display: grid; justify-items: center; gap: 5px; min-height: 44px; padding: 8px 3px; border-radius: var(--pulse-radius-sm); color: var(--muted); font-size: .75rem; font-weight: 500; text-decoration: none; }
.bottom-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav-icon { font-size: 1.15rem; line-height: 1; }
.skip-link { position: fixed; top: -100px; left: 15px; z-index: 30; padding: 10px 14px; border-radius: var(--pulse-radius-sm); background: var(--dark); color: var(--pulse-mist); }
.skip-link:focus { top: 15px; }
.loading-state { display: grid; min-height: 45vh; place-items: center; color: var(--muted); }

@media (min-width: 640px) {
  .app-header { padding-right: 24px; padding-left: 24px; }
  main { padding-right: 24px; padding-left: 24px; }
  .page-header { grid-template-columns: 1fr auto; align-items: end; }
  .identity-line { justify-content: end; }
  .hero-card, .panel, .profile-card, .state-card, .index-card { padding: 28px; }
  .chart-toolbar { grid-template-columns: 1fr 240px; align-items: end; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .app-header { min-height: 72px; padding: 20px 32px; }
  main { padding: 32px 32px 48px; }
  .page { gap: 24px; }
  .hero-card, .index-card, .panel, .profile-card, .state-card { padding: 28px; }
}

@media (min-width: 1024px) {
  .app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; padding-bottom: 0; }
  .platform-sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 28px 20px 22px; overflow: auto; background: var(--dark); color: var(--pulse-mist); }
  .brand-sidebar .brand-copy { color: var(--pulse-mist); font-size: 1rem; }
  .brand-sidebar .brand-copy small { color: rgba(242, 247, 244, .58); }
  .app-header { position: static; min-height: 72px; padding: 20px 32px; background: rgba(242, 247, 244, .88); }
  .brand-mobile { display: none; }
  .header-context { display: grid; }
  .app-workspace { min-width: 0; }
  main { width: 100%; padding: 32px; }
  .bottom-nav { display: none; }
  .page { gap: 20px; }
  .hero-card { grid-column: 1 / -1; }
  .metric-row { gap: 16px; }
  .index-card { max-width: 360px; }
  .chart-shell { width: 100%; max-width: 960px; }
}

@media (min-width: 1280px) {
  main { padding-right: 48px; padding-left: 48px; }
  .page { grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: start; }
  .page > .page-header, .page > .section-heading, .page > .hero-card, .page > .panel, .page > .state-card, .page > .history-list, .page > .history-count { grid-column: 1 / -1; }
  .page > .profile-card { grid-column: span 5; }
  .page > .profile-card + .profile-fields, .page > .profile-card + .profile-empty { grid-column: span 7; min-width: 0; }
  .profile-copy h2 { overflow: hidden; overflow-wrap: normal; text-overflow: ellipsis; white-space: nowrap; }
  .page > .index-card { grid-column: span 5; }
  .page > .panel:not(.analytics-panel):has(.metric-row) { grid-column: span 7; }
  .page > .analytics-panel { grid-column: 1 / -1; }
}

@media (max-width: 420px) {
  .app-header, main { padding-right: 14px; padding-left: 14px; }
  .brand-copy { font-size: .82rem; }
  .brand-copy small { font-size: .5rem; }
  .hero-card, .index-card, .panel, .profile-card, .state-card { padding: 19px; }
  .metric-row { gap: 7px; }
  .metric-tile { padding: 11px 9px; }
  .metric-label { font-size: .78rem; }
  .metric-tile strong { font-size: 1.45rem; }
  .hero-top { display: grid; }
  .hero-top .status-pill { justify-self: start; }
  .chart-meta { align-items: flex-start; flex-direction: column; gap: 3px; }
  .chart-axis-label { font-size: 11px; }
  .client-card { padding: 16px; }
  .client-card-heading { gap: 8px; }
  .client-baseline { padding: 6px 8px; font-size: .68rem; }
  .client-facts { gap: 8px; }
  .has-clients-access .bottom-nav a { font-size: .67rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}
