:root {
  --ivory: #F7F5F1;
  --beige: #EFE8DF;
  --blush: #E8D1CC;
  --blush-hover: #DEC1BC;
  --gold: #C8A96B;
  --charcoal: #1E1D1B;
  --text-soft: #5F5A52;
  --text-muted: #8B7355;
  --border: #D8D1C7;
  --border-soft: #E8DFD1;

  --success: #4F7D5C;
  --warning: #C27C2C;
  --danger: #A84A4A;

  /* Surfaces */
  --surface: #ffffff;
  --surface-muted: var(--beige);

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

  /* Radius scale */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(30, 29, 27, 0.04);
  --shadow-md: 0 8px 24px rgba(30, 29, 27, 0.06);

  /* Layout */
  --page-width: 880px;
  --page-width-wide: 1040px;

  /* Type scale (fluid, capped so headings never dominate the viewport) */
  --font-size-h1: clamp(1.7rem, 1.35rem + 1.4vw, 2.2rem);
  --font-size-h2: clamp(1.3rem, 1.1rem + 0.8vw, 1.6rem);
  --font-size-h3: clamp(1.05rem, 0.95rem + 0.4vw, 1.2rem);
  --font-size-body: 15px;
  --font-size-small: 13px;
  --font-size-micro: 11px;

  /* Interactive */
  --focus-ring: 0 0 0 3px rgba(200, 169, 107, 0.35);
  --transition: 0.18s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system,
               BlinkMacSystemFont,
               "Segoe UI",
               sans-serif;

  background: var(--ivory);
  color: var(--charcoal);

  font-size: var(--font-size-body);
  line-height: 1.55;

  padding: var(--space-6);
}

.container {
  max-width: var(--page-width);
  margin: 0 auto;
}

/* A small number of pages (tables, wide grids) read better with extra room. */
.container.container-wide {
  max-width: var(--page-width-wide);
}

h1 {
  font-size: var(--font-size-h1);
  margin-bottom: var(--space-3);
  color: var(--charcoal);
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-weight: 700;
}

h2 {
  font-size: var(--font-size-h2);
  margin-bottom: var(--space-3);
  line-height: 1.2;
  font-weight: 700;
}

h3 {
  font-size: var(--font-size-h3);
  margin-bottom: var(--space-2);
  font-weight: 600;
}

p {
  margin-bottom: var(--space-3);
  color: var(--text-soft);
  line-height: 1.6;
}

p:last-child {
  margin-bottom: 0;
}

small, .meta {
  font-size: var(--font-size-small);
  color: var(--text-muted);
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-4);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.card > *:last-child {
  margin-bottom: 0;
}

/* A compact card variant for hero/welcome areas — same surface, noticeably
   less vertical padding so the top of a page doesn't dominate the viewport. */
.card-compact {
  padding: var(--space-5) var(--space-6);
}

/* Primary-emphasis card: used sparingly (one or two per page) to make the
   single most decision-relevant card visually outrank its neighbours,
   without introducing a new colour. A slightly heavier border + a thin gold
   accent edge does the job. */
.card-emphasis {
  border-color: var(--gold);
  box-shadow: var(--shadow-md);
  position: relative;
}

.card-emphasis::before {
  content: "";
  position: absolute;
  top: var(--space-4);
  bottom: var(--space-4);
  left: 0;
  width: 3px;
  border-radius: var(--radius-pill);
  background: var(--gold);
}

.card-emphasis {
  padding-left: calc(var(--space-6) + 6px);
}

/* Secondary/quiet section: lower visual weight than the primary content
   above it, without a separate colour. */
.section-quiet {
  opacity: 0.92;
}

.section-label {
  display: block;
  text-transform: uppercase;
  font-size: var(--font-size-micro);
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

input,
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-top: var(--space-2);
  margin-bottom: var(--space-4);
  font-size: 15px;
  font-family: inherit;
  background: var(--surface);
  color: var(--charcoal);
}

label {
  font-weight: 600;
  font-size: var(--font-size-small);
}

textarea {
  line-height: 1.5;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: var(--focus-ring);
}

/* The text-input rule above (width: 100%, padding, border, background) was
   being inherited by checkboxes/radios too, since it targets every <input>
   regardless of type. A checkbox rendered as a full-width padded box pushes
   its label into a narrow remaining column -- the root cause of the
   consent-required layout bug. Checkboxes/radios opt back out to their
   native sizing here; anywhere they're laid out next to a label (e.g.
   .consent-option below) controls spacing itself. */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  padding: 0;
  margin-top: 0;
  margin-bottom: 0;
  border-radius: 0;
  background: transparent;
}

/* A group of question+answer fields (Reflect, Wheel). Replaces old <br><br>
   spacer hacks with a single, consistent rhythm. */
.field-group {
  margin-bottom: var(--space-6);
}

.field-group:last-child {
  margin-bottom: 0;
}

a {
  color: var(--charcoal);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--transition), opacity var(--transition);
}

a:hover {
  color: var(--text-soft);
  opacity: .8;
}

a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

.score {
  font-size: clamp(2rem, 1.7rem + 1.2vw, 2.6rem);
  font-weight: 700;
  color: var(--charcoal);
  line-height: 1;
  margin-bottom: var(--space-2);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;

  padding: 4px 10px;
  margin-bottom: var(--space-3);

  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;

  color: var(--text-muted);

  font-size: var(--font-size-micro);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge.error {
  color: var(--danger);
  border-color: var(--danger);
}

.success {
  color: var(--success);
}

.warning {
  color: var(--warning);
}

.error {
  color: var(--danger);
}

.rating-scale {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-3);
}

.rating-scale label {
  cursor: pointer;
}

.rating-scale input {
  display: none;
}

.rating-scale span {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 38px;
  height: 38px;

  border-radius: 50%;
  border: 1px solid var(--border-soft);

  background: white;
  font-weight: 600;
  font-size: var(--font-size-small);
}

.rating-scale input:checked + span {
  background: var(--blush);
  color: var(--charcoal);
  border-color: var(--blush);
}

@media (max-width: 600px) {
  .rating-scale span {
    width: 36px;
    height: 36px;
  }
}

a.btn,
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;

  background: var(--blush);
  color: var(--charcoal);

  padding: 11px 20px;
  border-radius: var(--radius-pill);

  text-decoration: none;
  font-size: var(--font-size-small);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;

  border: 1px solid transparent;
  cursor: pointer;

  transition: background var(--transition), transform var(--transition), opacity var(--transition);
}

a.btn:hover,
button:hover,
.btn:hover {
  background: var(--blush-hover);
  color: var(--charcoal);
  transform: translateY(-1px);
  opacity: 1;
}

a.btn:focus-visible,
button:focus-visible,
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Secondary action: same shape as .btn, lower visual weight so a screen's
   primary action stands out. Used across Tracks/Journey for "other options"
   alongside a recommended choice. */
a.btn.btn-secondary,
.btn.btn-secondary {
  background: transparent;
  color: var(--charcoal);
  border: 1px solid var(--border);
}

a.btn.btn-secondary:hover,
.btn.btn-secondary:hover {
  background: var(--beige);
  color: var(--charcoal);
}

/* A plain-text "link-styled" button, used where an action needs to sit
   inline with body copy (e.g. activate/deactivate toggles in admin tables)
   without taking on the pill-button treatment. */
.btn-link {
  display: inline;
  min-height: 0;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font-weight: 600;
  text-decoration: underline;
  text-transform: none;
  letter-spacing: normal;
  font-size: inherit;
  color: var(--charcoal);
  cursor: pointer;
}

.btn-link:hover {
  background: none;
  transform: none;
  opacity: .8;
}

.growth-opportunity-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.growth-opportunity-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

/* Generic bordered row used for list-style content: reflection history
   entries, wheel history, suggested/selected actions, ranked tracks,
   option rows. Shared instead of the same border/radius/padding repeated
   as an inline style on every list item across templates. */
.list-plain {
  list-style: none;
  padding: 0;
}

.list-item {
  margin-bottom: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
}

.list-item:last-child {
  margin-bottom: 0;
}

.list-item--row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.list-item--row > .list-item-body {
  flex: 1;
  min-width: 220px;
}

.list-item-title {
  margin-top: var(--space-2);
  margin-bottom: 0;
}

/* A selectable option row (radio/checkbox + label), used on Tracks and
   Track Actions. */
.option-row {
  display: block;
  cursor: pointer;
  padding: var(--space-4);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
}

.option-row:last-child {
  margin-bottom: 0;
}

.option-row input {
  margin-right: var(--space-2);
}

/* Compact grid for secondary, "quieter" content (Now's supporting cards,
   Journey's recommended-track cards) — replaces the repeated inline
   `display:grid; grid-template-columns: repeat(auto-fit, minmax(...))`
   pattern. */
.grid-secondary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-4);
}

.grid-secondary .card {
  margin-bottom: 0;
}

/* Progress bar, used by Now and Journey for track/journey completion. */
.progress-track {
  background: var(--border-soft);
  height: 10px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin: var(--space-3) 0;
}

.progress-fill {
  background: var(--gold);
  height: 100%;
}

.auth-wrapper {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    max-width: 480px;
    width: 100%;
}

/* Checkbox + label row (consent-required page). Checkbox stays fixed-size
   and top-aligned; the label takes the rest of the row's width and wraps
   normally instead of being squeezed into a narrow column. */
.consent-option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.consent-option input[type="checkbox"] {
  flex-shrink: 0;
  margin-top: 4px;
  cursor: pointer;
}

.consent-option label {
  flex: 1;
  font-weight: normal;
  font-size: inherit;
  line-height: 1.6;
  cursor: pointer;
}

.consent-option label a {
  color: var(--charcoal);
  text-decoration: underline;
}

/* Compact metric grid (Admin). Numbers here are informational density, not
   the single hero figure a Wheel/Journey score is — so they get their own,
   smaller scale rather than reusing .score at full size. */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-5);
  margin-top: var(--space-5);
}

.metric-label {
  font-size: var(--font-size-small);
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: var(--space-1);
}

.metric-value {
  font-size: clamp(1.4rem, 1.2rem + 0.8vw, 1.8rem);
  font-weight: 700;
  color: var(--charcoal);
  line-height: 1.15;
}

/* Shared data table (Admin). Replaces per-cell inline padding/border. */
.table-wrap {
  overflow-x: auto;
  margin-top: var(--space-5);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-small);
}

.data-table th {
  text-align: left;
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-muted);
  font-size: var(--font-size-micro);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.data-table td {
  padding: var(--space-3);
  border-bottom: 1px solid #F1ECE4;
  color: var(--charcoal);
}

.data-table td.nowrap {
  white-space: nowrap;
}

@media (max-width: 768px) {
  body {
    padding: var(--space-4);
  }

  .container,
  .container.container-wide {
    max-width: 100%;
  }

  .card {
    padding: var(--space-5);
    margin-bottom: var(--space-4);
  }

  .card-emphasis {
    padding-left: calc(var(--space-5) + 6px);
  }

  .score {
    font-size: clamp(1.7rem, 1.5rem + 1vw, 2.1rem);
  }

  .auth-wrapper {
    min-height: 90vh;
    align-items: center;
  }

  .auth-card {
    max-width: 100%;
  }

  input,
  textarea,
  select,
  button,
  .btn,
  a.btn {
    width: 100%;
  }

  /* Same fix as the base checkbox/radio reset above: this mobile rule
     targets every <input> too, and would otherwise reintroduce the
     full-width checkbox bug below 768px. */
  input[type="checkbox"],
  input[type="radio"] {
    width: auto;
  }
}

@media (max-width: 480px) {
  body {
    padding: var(--space-3);
  }

  .card {
    padding: var(--space-4);
    border-radius: var(--radius-md);
  }

  .card-emphasis {
    padding-left: calc(var(--space-4) + 6px);
  }

  .badge {
    font-size: var(--font-size-micro);
    padding: 4px 9px;
  }
}

.app-header {
  margin-bottom: var(--space-7);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-soft);
}

.app-nav {
  max-width: var(--page-width-wide);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-logo {
  font-size: 17px;
  font-weight: 800;
}

.nav-links {
  display: flex;
  gap: var(--space-5);
  align-items: center;
  font-size: var(--font-size-small);
}

/* Grouped navigation — group labels are hidden on desktop, the horizontal
   row stays calm; a subtle divider separates the groups. */
.nav-group-label {
  display: none;
}

.nav-sep {
  width: 1px;
  height: 16px;
  background: var(--border-soft);
  display: inline-block;
}

/* Active page: not colour-only — an underline (desktop) / left bar (mobile). */
.nav-links a.is-active {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.menu-toggle:focus-visible,
.nav-links a:focus-visible,
.admin-nav-group a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Admin navigation — a coherent grouped component (Administration + Analytics),
   wrapping/stacking on narrow widths, no dropdowns, no JavaScript. */
.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-7);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-soft);
  font-size: var(--font-size-small);
}

.admin-nav-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-nav-label {
  text-transform: uppercase;
  font-size: var(--font-size-micro);
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.admin-nav-group a.is-active {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Profile account hub — clearly separated Danger Zone. */
.danger-zone {
  border: 1px solid #E0B4B4;
  border-radius: var(--radius-md);
  padding: var(--space-5);
}

.menu-toggle {
  display: none;
  background: transparent;
  color: var(--charcoal);
  font-size: 26px;
  padding: 0;
  min-height: 44px;
  min-width: 44px;
}

@media (max-width: 768px) {
  .app-nav {
    align-items: flex-start;
  }

  .menu-toggle {
    display: block;
    width: auto;
  }

  .nav-links {
    display: none;
    width: 100%;
    margin-top: var(--space-4);
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }

  .nav-links.active {
    display: flex;
  }

  .nav-links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  .app-nav {
    flex-wrap: wrap;
  }

  /* In the mobile drawer the groups become visible headings; the desktop
     divider is hidden and the active marker becomes a left bar. */
  .nav-group-label {
    display: block;
    text-transform: uppercase;
    font-size: var(--font-size-micro);
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-top: var(--space-3);
    margin-bottom: 2px;
  }

  .nav-sep {
    display: none;
  }

  .nav-links a.is-active {
    text-decoration: none;
    border-left: 3px solid var(--charcoal);
    padding-left: var(--space-2);
    margin-left: -11px;
  }
}

.app-footer {
  margin-top: var(--space-8);
  padding: var(--space-5) 0;
  border-top: 1px solid var(--border-soft);
}

.app-footer-inner {
  max-width: var(--page-width-wide);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.app-footer-links {
  display: flex;
  gap: var(--space-5);
  align-items: center;
}

.app-footer-inactive {
  color: var(--text-muted);
  opacity: 0.6;
  cursor: default;
}

.app-footer-meta {
  color: var(--text-muted);
  font-size: var(--font-size-small);
  margin: 0;
}

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

  a.btn:hover,
  button:hover,
  .btn:hover {
    transform: none;
  }
}
