@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Manrope:wght@400;500;600&display=swap");

:root {
  --bg: #f2f6f5;
  --panel: #ffffff;
  --ink: #1f2c2d;
  --muted: #5b7073;
  --line: #d2dfde;
  --primary: #116d63;
  --primary-soft: #e6f5f2;
  --warn: #7b2f2f;
  --shadow: 0 14px 32px rgba(13, 55, 51, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 10%, #d2efe7, transparent 36%),
    radial-gradient(circle at 90% 0%, #f2dfbb, transparent 30%),
    var(--bg);
  color: var(--ink);
  font-family: "Manrope", sans-serif;
}

h1,
h2,
h3,
h4,
.brand-mark {
  font-family: "Space Grotesk", sans-serif;
  margin: 0;
}

.app {
  width: min(980px, calc(100vw - 1.2rem));
  margin: 1rem auto 2rem;
  display: grid;
  gap: 0.8rem;
}

.top-brand {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
}

.top-brand h1 {
  font-size: 1.25rem;
}

.top-brand p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.runtime-badge {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  border: 1px solid #cfe0dc;
  background: #f3faf8;
  color: #2d615b;
  font-size: 0.74rem;
  letter-spacing: 0.01em;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.95rem;
  box-shadow: var(--shadow);
}

.panel.center {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 0.55rem;
  min-height: 260px;
}

.splash-panel {
  min-height: 260px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 0.4rem;
}

.brand-mark {
  font-size: 2rem;
  letter-spacing: 0.04em;
}

.status {
  border: 1px solid #c8ded7;
  background: #eef8f5;
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font-size: 0.86rem;
}

.status.error {
  border-color: #edc1c1;
  background: #fdeeee;
  color: var(--warn);
}

.muted {
  color: var(--muted);
  margin: 0.35rem 0 0.7rem;
  font-size: 0.9rem;
}

.stack-form {
  display: grid;
  gap: 0.65rem;
}

.grid {
  display: grid;
  gap: 0.6rem;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.84rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid #bfd2cf;
  border-radius: 10px;
  padding: 0.55rem 0.62rem;
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #6ea49d;
  box-shadow: 0 0 0 3px rgba(17, 109, 99, 0.15);
}

textarea {
  resize: vertical;
}

button {
  border: none;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  filter: brightness(0.98);
}

.primary {
  background: linear-gradient(140deg, #116d63, #169886);
  color: #f7fffc;
}

.secondary {
  background: #e6f3f0;
  color: #275754;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.hidden {
  display: none;
}

.goal-fieldset {
  border: 1px solid #d6e2df;
  border-radius: 10px;
  margin: 0;
  padding: 0.6rem;
  display: grid;
  gap: 0.45rem;
}

.goal-fieldset legend {
  padding: 0 0.35rem;
  font-size: 0.83rem;
  color: var(--muted);
}

.goal-mode-group {
  border: 1px solid #d6e2df;
  border-radius: 10px;
  padding: 0.6rem;
  display: grid;
  gap: 0.45rem;
  background: #f7fcfa;
}

.goal-mode-title {
  font-size: 0.83rem;
  color: var(--muted);
  font-weight: 600;
}

.goal-mode-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.84rem;
  font-weight: 600;
}

.goal-mode-option input[type="radio"] {
  margin: 0.05rem 0 0;
}

.goal-option {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.45rem;
  border: 1px solid #deebe8;
  border-radius: 10px;
  background: #fbfefd;
}

.goal-option input[type="checkbox"] {
  margin-top: 0.2rem;
  flex: 0 0 auto;
}

.goal-option-body {
  display: grid;
  gap: 0.2rem;
}

.goal-option-title {
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.2;
}

.goal-option-copy {
  font-size: 0.79rem;
  font-weight: 500;
  color: #4f676a;
  line-height: 1.35;
}

.goal-option.disabled {
  opacity: 0.7;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.48rem 0.35rem;
  border-bottom: 1px solid #e2ecea;
  font-size: 0.84rem;
}

td input[readonly] {
  background: #f4f8f7;
  color: #4d6668;
}

.row-hint {
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: #4e6d70;
}

.parse-row-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin: 0.55rem 0 0.45rem;
  flex-wrap: wrap;
}

.parse-filter-group {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.parse-filter-chip {
  border: 1px solid #c8dbd7;
  background: #f8fbfa;
  color: #2f6264;
  border-radius: 999px;
  padding: 0.24rem 0.62rem;
  font-size: 0.78rem;
  line-height: 1.2;
}

.parse-filter-chip.active {
  background: #e6f2ef;
  border-color: #9fc8bf;
  color: #184f50;
  font-weight: 600;
}

.parse-row-review {
  background: #fff7ef;
}

.parse-row-review td {
  border-bottom-color: #f0d8bc;
}

.parse-row-auto {
  background: #f8fcfb;
}

.parse-panel-row td {
  background: #eef7f5;
  color: #2c5d5a;
  font-weight: 700;
  border-bottom-color: #cfe0dc;
}

.parse-row-details td {
  background: #fcfffe;
  border-bottom-color: #e2ecea;
  padding-top: 0.28rem;
  padding-bottom: 0.34rem;
}

.row-detail-pill {
  display: inline-block;
  margin-right: 0.34rem;
  margin-bottom: 0.2rem;
  border: 1px solid #d2e5e1;
  background: #f5fbf9;
  color: #335f62;
  border-radius: 999px;
  padding: 0.14rem 0.46rem;
  font-size: 0.72rem;
}

.hidden-filter-row {
  display: none;
}

th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #507074;
}

.summary-box {
  border: 1px solid #d3e4df;
  border-radius: 10px;
  background: #f7fcfa;
  padding: 0.7rem;
}

/* D.7 Phase 4 cycle-header — bridge templating surface.
 * Light-first warm-stone background per brand-rules v9.0; terracotta accent
 * only on the eyebrow chip; deep-ink for the hero claim.
 * Renderer-escaped slot strings are slotted as innerHTML; no surface escape.
 */
.cycle-header {
  margin: 0 0 0.75rem 0;
  padding: 1rem;
  background: var(--color-primitive-warm-stone, #f2efeb);
  border: 1px solid #e6e1d8;
  border-left: 3px solid var(--color-primitive-terracotta, #c2704e);
  border-radius: 10px;
  display: grid;
  gap: 0.4rem;
}

.cycle-header:empty {
  display: none;
}

.cycle-header__eyebrow {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-primitive-terracotta, #c2704e);
  font-weight: 600;
}

.cycle-header__hero {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.35;
  color: var(--color-primitive-deep-ink, #0f1a2a);
  font-weight: 600;
}

.cycle-header__value {
  font-size: 0.92rem;
  color: var(--color-primitive-deep-ink, #0f1a2a);
  font-variant-numeric: tabular-nums;
}

.cycle-header__bridge {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--color-primitive-deep-ink, #0f1a2a);
}

.cycle-header__trend {
  font-size: 0.78rem;
  color: var(--color-primitive-slate-teal, #5a7f7e);
  font-style: italic;
}

.cycle-header__sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--color-primitive-warm-grey, #8a8a87);
  font-style: italic;
}

.subtle-card {
  margin: 0.7rem 0;
  border: 1px dashed #bfd7d0;
  border-radius: 10px;
  background: #f3faf8;
  padding: 0.6rem;
  font-size: 0.83rem;
  color: #2e595a;
}

.parse-blocker {
  margin-top: 0.6rem;
  border: 1px solid #e7c2c2;
  border-radius: 10px;
  background: #fff4f4;
  color: #7b2f2f;
  padding: 0.55rem;
}

.parse-blocker button {
  margin-top: 0.45rem;
}

/* Dashboard fetch error-state (ADR-0038) — calm, capability-honest notice +
 * retry affordance for the Today composite surface (dashboardUi.js).
 * Restrained + light-first per brand: a soft informational tint, NOT the
 * alarming red of .parse-blocker. */
.dashboard-error-state {
  margin: 0.7rem 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--primary-soft);
  padding: 0.85rem;
  color: var(--ink);
}

.dashboard-error-state__body {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

.dashboard-error-state__retry {
  border: 1px solid var(--primary);
  background: var(--panel);
  color: var(--primary);
}

.stack-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.6rem;
}

.card {
  border: 1px solid #d4e5df;
  border-radius: 10px;
  background: #fbfffd;
  padding: 0.65rem;
}

.card h4 {
  margin: 0;
  font-size: 0.95rem;
}

.card p {
  margin: 0.4rem 0 0;
  color: #3b5d60;
  font-size: 0.85rem;
}

.card .chip-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.45rem;
}

.chip {
  border: 1px solid #c6dfd8;
  background: var(--primary-soft);
  color: #1e6058;
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  font-size: 0.74rem;
}

.wellbeing-scale {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.45rem;
}

.wellbeing-scale label {
  border: 1px solid #c9d9d6;
  background: #f8fcfb;
  border-radius: 10px;
  padding: 0.5rem;
  text-align: center;
  gap: 0.25rem;
}

.dashboard-head {
  margin-bottom: 0.55rem;
}

.measure-grid {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.7rem;
}

.measure-stat-row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0.55rem;
}

.measure-card-title {
  margin: 0 0 0.3rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #4f7173;
}

.measure-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.45rem;
}

.measure-list p {
  margin: 0;
}

.trend-point-table td,
.trend-point-table th {
  font-size: 0.78rem;
}

/* App-shell persistent tab-bar (Brief 28 / Q-0020). Promoted out of
   #screen-dashboard to a screen-level 3-tab core loop. Tokens-only — colors via
   the app-shell vars, geometry via brand tokens.css. NOTE: the `hidden`
   attribute needs an explicit display:none here because `display: grid` below
   would otherwise override the UA hidden rule. */
.app-tab-bar {
  position: sticky;
  bottom: var(--spacing-3);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--spacing-2);
  background: var(--primary-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: var(--spacing-1);
  z-index: var(--z-sticky);
}

.app-tab-bar[hidden] {
  display: none;
}

.app-tab {
  background: transparent;
  color: var(--muted);
}

.app-tab.active {
  background: var(--panel);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Header profile affordance → Settings/Inputs (Q-0020 §2: not a daily nav
   destination). Floated top-right of the brand header; shown only on core-loop
   screens (toggled with the `hidden` attribute by applyTabChrome). */
.header-profile {
  position: absolute;
  top: var(--spacing-3);
  right: var(--spacing-4);
  padding: var(--spacing-1) var(--spacing-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--font-size-sm);
}

.header-profile[hidden] {
  display: none;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 3px solid #c4dfd9;
  border-top-color: #158170;
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 760px) {
  .grid.two {
    grid-template-columns: 1fr;
  }

  .measure-stat-row {
    flex-direction: column;
  }

  .wellbeing-scale {
    grid-template-columns: repeat(5, minmax(44px, 1fr));
  }
}
