/* ============================================================
   Client Onboarding — Design System
   ============================================================ */

:root {
  /* Palette — warm, earthy, premium */
  --bg:           #F7F4EE;
  --bg-elev:      #FFFFFF;
  --ink:          #1C1E1A;
  --ink-2:        #3C3F38;
  --ink-3:        #6B6E66;
  --ink-4:        #9FA29A;
  --line:         #E6E1D6;
  --line-2:       #EFEAE0;
  --accent:       #2E4A2A;     /* deep forest */
  --accent-2:     #3D6336;
  --accent-soft:  #E8EFE4;
  --gold:         #B48A3C;
  --danger:       #B3261E;
  --success:      #2E7D32;

  /* Type */
  --font-serif: 'Fraunces', ui-serif, Georgia, serif;
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Shape */
  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 22px;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(28,30,26,.04), 0 1px 3px rgba(28,30,26,.04);
  --shadow:    0 6px 20px -8px rgba(28,30,26,.12), 0 2px 6px rgba(28,30,26,.05);
  --shadow-lg: 0 24px 60px -20px rgba(28,30,26,.22), 0 10px 30px -10px rgba(28,30,26,.12);

  /* Motion */
  --ease: cubic-bezier(.2,.8,.2,1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; letter-spacing: -.015em; color: var(--ink); }
h1 { font-size: clamp(1.9rem, 3.2vw, 2.6rem); line-height: 1.1; margin: 0 0 .5em; }
h2 { font-size: 1.55rem; line-height: 1.2; margin: 0 0 .4em; }
h3 { font-size: 1.1rem; margin: 0 0 .3em; font-family: var(--font-sans); font-weight: 600; letter-spacing: 0; }
p  { margin: 0 0 1em; color: var(--ink-2); }
em { font-style: italic; color: var(--accent); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; z-index: 100; }

/* ============================================================
   Welcome & Success
   ============================================================ */

.welcome, .success {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  background:
    radial-gradient(1200px 600px at 80% -10%, #EEF2E7 0%, transparent 60%),
    radial-gradient(1000px 500px at -10% 110%, #F3EEE0 0%, transparent 60%),
    var(--bg);
}

.welcome__card, .success__card {
  max-width: 640px;
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(2rem, 4vw, 3.25rem);
  box-shadow: var(--shadow-lg);
  animation: rise .7s var(--ease) both;
}

.welcome__kicker {
  font-size: .78rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 1rem;
}
.welcome__title { font-size: clamp(2.1rem, 4vw, 3rem); }
.welcome__body  { font-size: 1.05rem; color: var(--ink-2); max-width: 52ch; }
.welcome__points {
  list-style: none; padding: 0; margin: 1.5rem 0 2rem;
  display: grid; gap: .6rem;
}
.welcome__points li {
  position: relative; padding-left: 1.6rem; color: var(--ink-2); font-size: .97rem;
}
.welcome__points li::before {
  content: "✓"; position: absolute; left: 0; top: 0;
  color: var(--accent); font-weight: 700;
}
.welcome__resume { margin-top: 1rem; }

.success__card { text-align: center; }
.success__check {
  width: 72px; height: 72px; margin: 0 auto 1.25rem;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 2rem; font-weight: 700;
}

/* ============================================================
   App Shell
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #FBF9F3;
  border-right: 1px solid var(--line);
  padding: 1.75rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex; align-items: center; gap: .75rem;
  padding: 0 .5rem 1.5rem;
  margin-bottom: .5rem;
  border-bottom: 1px solid var(--line);
}
.brand__mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 1.1rem;
}
.brand__name { font-family: var(--font-serif); font-weight: 600; font-size: 1.05rem; }
.brand__sub  { font-size: .78rem; color: var(--ink-3); }

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
  margin: 0 -.25rem;
  display: flex; flex-direction: column; gap: .15rem;
}
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }

.nav__item {
  all: unset;
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem .75rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: .9rem;
  color: var(--ink-2);
  transition: background .18s var(--ease), color .18s var(--ease);
  position: relative;
}
.nav__item:hover { background: var(--line-2); }
.nav__item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav__item.is-active .nav__num { background: var(--accent); color: #fff; }

.nav__num {
  flex: 0 0 22px; height: 22px;
  border-radius: 999px;
  background: var(--line);
  color: var(--ink-3);
  font-size: .72rem; font-weight: 600;
  display: grid; place-items: center;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.nav__item.is-complete .nav__num {
  background: var(--accent);
  color: #fff;
}
.nav__item.is-complete .nav__num::before { content: "✓"; }
.nav__item.is-complete .nav__num-text { display: none; }

.nav__label { flex: 1; }

.sidebar__foot {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  font-size: .78rem; color: var(--ink-3);
}
.save-state::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 999px;
  background: var(--success); margin-right: .4rem; vertical-align: middle;
}

.linkbtn {
  all: unset;
  color: var(--ink-3);
  font-size: .78rem;
  cursor: pointer;
  border-bottom: 1px dashed var(--ink-4);
}
.linkbtn:hover { color: var(--accent); border-color: var(--accent); }

/* ============================================================
   Main / Content
   ============================================================ */

.main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  padding: 1.5rem clamp(1.5rem, 4vw, 3rem) 1rem;
  display: flex; align-items: center; gap: 2rem;
  border-bottom: 1px solid var(--line-2);
  background: var(--bg);
}
.progress { flex: 1; max-width: 520px; }
.progress__track {
  height: 6px; border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.progress__fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width .6s var(--ease);
}
.progress__label { margin-top: .45rem; font-size: .78rem; color: var(--ink-3); }
.progress__label span { color: var(--ink); font-weight: 600; }

.topbar__meta {
  font-size: .78rem; color: var(--ink-3);
  text-align: right;
}

.content {
  flex: 1;
  padding: clamp(1.75rem, 4vw, 3rem) clamp(1.5rem, 4vw, 3rem) 3rem;
  max-width: 880px;
  width: 100%;
}

.section {
  animation: rise .5s var(--ease) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.section__kicker {
  display: inline-block;
  font-size: .75rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent);
  padding: .35rem .7rem;
  background: var(--accent-soft);
  border-radius: 999px;
  margin-bottom: 1rem;
}
.section__intro { font-size: 1.02rem; color: var(--ink-2); max-width: 62ch; margin-bottom: 2rem; }

/* ============================================================
   Form elements
   ============================================================ */

.field {
  margin-bottom: 1.4rem;
}
.field__label {
  display: block;
  font-weight: 600; font-size: .9rem;
  color: var(--ink);
  margin-bottom: .4rem;
}
.field__hint {
  font-size: .82rem; color: var(--ink-3); margin-bottom: .5rem;
}
.field__row {
  display: grid; gap: 1rem;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 720px) { .field__row { grid-template-columns: 1fr; } }

.input, .textarea, .select {
  width: 100%;
  font-family: inherit;
  font-size: .97rem;
  color: var(--ink);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
  appearance: none;
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%236B6E66' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.input::placeholder, .textarea::placeholder { color: var(--ink-4); }

.input:hover, .textarea:hover, .select:hover { border-color: #D6CFBF; }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(46,74,42,.10);
}

/* Repeatable: Status / Management Preference / Notes */
.block {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.4rem 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.block:hover { border-color: #D6CFBF; }
.block--filled { border-color: #C9D6C2; background: #FCFCF8; }

.block__body {
  transition: opacity .25s var(--ease), max-height .3s var(--ease);
}

.block__foot {
  display: flex; align-items: center; gap: .9rem;
  margin-top: 1rem;
  padding-top: .9rem;
  border-top: 1px dashed var(--line-2);
}
.block__toggle {
  all: unset;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 500;
  color: var(--ink-3);
  padding: .35rem .7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  transition: color .15s var(--ease), border-color .15s var(--ease), background .15s var(--ease);
}
.block__toggle:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.block__toggle:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(46,74,42,.18); }
.block__flag {
  font-size: .75rem;
  color: var(--ink-4);
  font-style: italic;
}

/* Unknown / collapsed state */
.block--unknown {
  background: #F4F2EC;
  border-color: var(--line-2);
  border-style: dashed;
}
.block--unknown .block__head { opacity: .55; }
.block--unknown .block__title { color: var(--ink-3); }
.block--unknown .block__body {
  display: none;
}
.block--unknown .block__badge { color: var(--ink-4); }
.block--unknown .block__toggle {
  color: var(--accent);
  border-color: var(--accent);
  background: #fff;
}

.block__head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 1rem;
}
.block__title {
  font-family: var(--font-sans);
  font-size: 1.02rem; font-weight: 600;
  color: var(--ink);
}
.block__badge {
  font-size: .72rem; color: var(--ink-3);
  font-weight: 500;
}
.block__badge--done { color: var(--success); font-weight: 600; }
.block__badge--done::before { content: "✓ "; }

/* Account access block variant */
.access-grid {
  display: grid; gap: 1rem;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 720px) { .access-grid { grid-template-columns: 1fr; } }

/* ============================================================
   Review
   ============================================================ */

.review {
  display: grid; gap: 1rem;
}
.review__group {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
}
.review__group h3 {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 1rem; margin-bottom: .75rem;
}
.review__edit {
  font-size: .8rem; color: var(--accent);
  background: none; border: none; cursor: pointer; font-family: inherit;
}
.review__edit:hover { text-decoration: underline; }
.review__row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1rem;
  padding: .5rem 0;
  border-top: 1px dashed var(--line-2);
  font-size: .9rem;
}
.review__row:first-of-type { border-top: none; }
.review__row dt { color: var(--ink-3); }
.review__row dd { margin: 0; color: var(--ink); white-space: pre-wrap; }
.review__row dd.is-empty { color: var(--ink-4); font-style: italic; }

@media (max-width: 600px) {
  .review__row { grid-template-columns: 1fr; gap: .15rem; }
}

/* ============================================================
   Buttons & Footer
   ============================================================ */

.btn {
  font-family: inherit;
  font-size: .95rem;
  font-weight: 600;
  border-radius: 999px;
  padding: .85rem 1.5rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .12s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease), color .18s var(--ease);
  display: inline-flex; align-items: center; gap: .5rem;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(46,74,42,.22); }
.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
}
.btn--primary:hover { background: var(--accent-2); transform: translateY(-1px); }
.btn--primary:disabled {
  background: var(--line); color: var(--ink-4); cursor: not-allowed;
  transform: none; box-shadow: none;
}
.btn--ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--line);
}
.btn--ghost:hover { background: var(--line-2); color: var(--ink); }
.btn--lg { padding: 1rem 1.8rem; font-size: 1rem; }

.footer {
  padding: 1.25rem clamp(1.5rem, 4vw, 3rem);
  border-top: 1px solid var(--line-2);
  background: var(--bg-elev);
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  position: sticky; bottom: 0;
}
.footer__hint { font-size: .82rem; color: var(--ink-3); flex: 1; text-align: center; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .nav {
    flex-direction: row;
    overflow-x: auto;
    padding: .5rem 0 0;
  }
  .nav__item { flex: 0 0 auto; padding: .5rem .75rem; }
  .nav__label { max-width: 120px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
  .sidebar__foot { display: none; }
}

/* --- Boot spinner shown while hydrating from API --- */
.boot-spinner {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  font-size: 1rem;
  background: var(--bg);
  z-index: 1000;
}

/* --- Fatal error screen (invalid link / network failure) --- */
.fatal-screen {
  max-width: 480px;
  margin: 10vh auto;
  padding: clamp(2rem, 4vw, 3rem);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: rise .7s var(--ease) both;
}
.fatal-screen h2 {
  font-size: clamp(1.4rem, 2.5vw, 1.8rem);
  margin: 0 0 .75rem;
  color: var(--ink);
}
.fatal-screen p {
  color: var(--ink-2);
  margin: 0 0 1.5rem;
  font-size: 1rem;
}

/* --- Inline submit error message (appears in footer) --- */
.submit-error {
  color: #b42318;
  font-size: .88rem;
  margin-top: .5rem;
  text-align: center;
  flex-basis: 100%;
}
