:root {
  --green: #5e7461;
  --forest: #3a4a3c;
  --ink: #1a1a1a;
  --gray: #b3b3b3;
  --paper: #ffffff;
  --mist: #f3f5f3;
  --line: #dfe4df;
  --muted: #5f6a60;
  --sage: #a9b8aa;
  --warn-bg: #fbf3df; --warn-ink: #6d5414;
  --bad-bg: #f8e6e4;  --bad-ink: #8a2a20;
  --font: "Nexa", "Montserrat", "Futura", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-weight: 400; color: var(--ink); background: var(--mist); line-height: 1.5; font-size: 15px; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Chrome ---------- */
.top { background: var(--forest); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px clamp(16px, 4vw, 40px); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 28px; height: 28px; color: #fff; }
.wordmark { font-size: 22px; letter-spacing: .2px; }
.wordmark .ops { font-weight: 700; } .wordmark .terra { font-weight: 900; }
.product { font-weight: 300; font-size: 14px; padding-left: 12px; margin-left: 2px; border-left: 1px solid rgba(255,255,255,.35); }
.who { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.who .role { font-size: 12px; font-weight: 700; background: var(--green); padding: 3px 10px; border-radius: 20px; }
.who button { font: inherit; font-size: 13px; color: #fff; background: none; border: 1px solid rgba(255,255,255,.4); border-radius: 6px; padding: 5px 10px; cursor: pointer; }

nav { background: var(--paper); border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; padding: 0 clamp(8px, 3vw, 32px); }
.navgroup { display: flex; align-items: stretch; }
.navgroup + .navgroup { border-left: 1px solid var(--line); margin-left: 8px; padding-left: 8px; }
.navgroup .gl { align-self: center; font-size: 12px; color: var(--muted); padding: 0 8px; }
nav button { font: inherit; font-size: 14px; font-weight: 500; color: var(--muted); background: none; border: 0; border-bottom: 3px solid transparent; padding: 14px 12px 11px; cursor: pointer; }
nav button:hover { color: var(--forest); }
nav button[aria-current="page"] { color: var(--forest); border-bottom-color: var(--green); font-weight: 700; }
.count { display: inline-block; min-width: 20px; text-align: center; background: var(--green); color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 6px; margin-left: 4px; }

main { max-width: 1000px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 32px) 80px; }
.boot { color: var(--muted); }
h1 { font-weight: 900; font-size: clamp(24px, 3.2vw, 32px); line-height: 1.15; color: var(--ink); margin: 0 0 6px; letter-spacing: -.3px; }
h2 { font-weight: 700; font-size: 18px; color: var(--forest); margin: 32px 0 12px; }
h3 { font-weight: 700; font-size: 15px; color: var(--forest); margin: 0 0 8px; }
.lede { color: var(--muted); margin: 0 0 24px; max-width: 68ch; }
.meta { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Cycle timeline (the slide, live) ---------- */
.tl { list-style: none; margin: 0 0 32px; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); position: relative; }
.tl::before { content: ""; position: absolute; left: 10%; right: 10%; top: 54px; height: 4px; background: var(--sage); border-radius: 2px; }
.tl-step { display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; padding: 0 6px; }
.tl-date { font-weight: 700; font-size: 14px; background: #e7e9e4; color: var(--forest); border-radius: 18px; padding: 6px 16px; white-space: nowrap; }
.tl-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--mist); border: 4px solid var(--green); margin: 12px 0 10px; position: relative; z-index: 1; }
.tl-label { font-weight: 700; font-size: 14px; color: var(--ink); line-height: 1.25; }
.tl-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.tl-step.past .tl-dot { background: var(--green); }
.tl-step.past .tl-date { background: transparent; color: var(--muted); }
.tl-step.next .tl-date { background: var(--forest); color: #fff; }
.tl-step.next .tl-dot { background: var(--forest); border-color: var(--forest); box-shadow: 0 0 0 5px rgba(58,74,60,.18); }
@media (max-width: 720px) {
  .tl { grid-template-columns: 1fr; gap: 14px; }
  .tl::before { left: 21px; right: auto; top: 10px; bottom: 10px; width: 4px; height: auto; }
  .tl-step { display: grid; grid-template-columns: 46px 1fr; grid-template-rows: auto auto auto; text-align: left; align-items: center; padding: 0; }
  .tl-dot { grid-row: 1 / span 3; margin: 0 0 0 10px; }
  .tl-date { justify-self: start; padding: 3px 12px; font-size: 13px; }
  .tl-label { margin-top: 4px; }
}

/* ---------- Review stage stepper ---------- */
.stepper { list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-wrap: wrap; gap: 0; counter-reset: s; }
.stepper li { counter-increment: s; flex: 1 1 0; min-width: 110px; font-size: 13px; color: var(--muted); padding: 10px 12px 10px 0; border-top: 4px solid var(--line); }
.stepper li::before { content: counter(s) "  "; font-weight: 700; }
.stepper li.done { border-top-color: var(--green); color: var(--forest); }
.stepper li.current { border-top-color: var(--forest); color: var(--ink); font-weight: 700; }

/* ---------- Surfaces ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: clamp(16px, 3vw, 26px); margin-bottom: 18px; }
.panel.quiet { background: #f8faf8; }
.notice { border-left: 4px solid var(--green); background: #eef2ee; padding: 12px 16px; border-radius: 0 8px 8px 0; margin: 0 0 18px; font-size: 14px; }
.notice.warn { border-color: #c9a227; background: var(--warn-bg); color: var(--warn-ink); }
.notice.bad { border-color: #b4483a; background: var(--bad-bg); color: var(--bad-ink); }
.notice b { font-weight: 700; }
.values { background: var(--forest); color: #fff; border-radius: 10px; padding: 16px 20px; margin-bottom: 18px; font-size: 14px; }
.values strong { font-weight: 700; margin-right: 6px; }
.values .v { display: inline-block; background: rgba(255,255,255,.14); padding: 3px 11px; border-radius: 20px; margin: 4px 6px 0 0; }
.values p { margin: 8px 0 0; font-weight: 300; }

/* ---------- Forms ---------- */
label { display: block; font-size: 14px; font-weight: 500; color: var(--forest); margin: 0 0 6px; }
.q { margin: 0 0 22px; }
.q label { font-weight: 700; color: var(--ink); }
.q .n { color: var(--green); margin-right: 6px; }
input[type=text], input[type=date], input[type=number], select, textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink); background: #fff; border: 1px solid #cfd6cf; border-radius: 8px; padding: 10px 12px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
textarea:disabled, input:disabled, select:disabled { background: #f4f5f4; color: #3b3f3b; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); margin: 12px 0; }
.check input { width: auto; margin: 0; }
.btn { font: inherit; font-weight: 700; font-size: 14px; background: var(--green); color: #fff; border: 1px solid var(--green); border-radius: 8px; padding: 10px 18px; cursor: pointer; }
.btn:hover { background: var(--forest); border-color: var(--forest); }
.btn.secondary { background: #fff; color: var(--forest); border-color: var(--green); }
.btn.secondary:hover { background: #eef2ee; }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn.ghost:hover { color: var(--ink); border-color: var(--gray); }
.btn.sm { padding: 6px 12px; font-size: 13px; font-weight: 500; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.savestate { font-size: 13px; color: var(--muted); }
.savestate.err { color: var(--bad-ink); font-weight: 500; }
.progress { height: 8px; background: #e6eae6; border-radius: 4px; overflow: hidden; margin: 6px 0 20px; }
.progress span { display: block; height: 100%; background: var(--green); }

/* ---------- Tables ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 700; color: var(--forest); font-size: 13px; border-bottom: 2px solid var(--green); padding: 8px 10px; white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td .sub { display: block; font-size: 12.5px; color: var(--muted); }
.chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.s0 { background: #ecedeb; color: #555; }
.s1 { background: #fbf0cf; color: #6d5414; }
.s2 { background: #dde6f2; color: #2c4a74; }
.s3 { background: #d9eadb; color: #2d5e33; }
.s4 { background: var(--forest); color: #fff; }
.tally { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0 0 14px; font-size: 14px; color: var(--muted); }
.tally b { color: var(--ink); font-weight: 900; font-size: 18px; margin-right: 4px; }

/* ---------- Review editor ---------- */
.ref details { border-top: 1px solid var(--line); padding: 12px 0; }
.ref details:first-child { border-top: 0; padding-top: 0; }
.ref summary { cursor: pointer; font-weight: 700; color: var(--forest); }
.ref .qa { margin: 12px 0 0; }
.ref .qa dt { font-weight: 700; font-size: 14px; }
.ref .qa dd { margin: 2px 0 12px; white-space: pre-wrap; font-size: 14px; }
.empty { color: var(--muted); font-style: italic; }
.fb { border-left: 3px solid var(--sage); padding: 4px 0 4px 14px; margin: 12px 0; }
.fb .who-line { font-size: 13px; color: var(--muted); }
.fb .who-line b { color: var(--forest); font-weight: 700; }
.fb .body { white-space: pre-wrap; font-size: 14px; margin-top: 2px; }
.goal { border-top: 1px solid var(--line); padding: 14px 0; }
.goal:first-of-type { border-top: 0; }
.history { list-style: none; padding: 0; margin: 0; font-size: 13.5px; }
.history li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.history .note { display: block; color: var(--muted); white-space: pre-wrap; margin-top: 2px; }
.sec { margin-bottom: 22px; }
.sec .read { white-space: pre-wrap; background: #f8faf8; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; min-height: 44px; }
.notebox { border: 1px solid #c9a227; background: var(--warn-bg); border-radius: 8px; padding: 14px; margin-top: 12px; }
.tpl-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.tpl-row .i { color: var(--muted); text-align: center; font-size: 13px; }
.tpl-row .ctl { display: flex; gap: 6px; }
.back { font: inherit; background: none; border: 0; color: var(--green); font-weight: 700; cursor: pointer; padding: 0; margin-bottom: 14px; }

/* ---------- Printout ---------- */
.doc { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: clamp(20px, 5vw, 48px); }
.doc .head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; border-bottom: 3px solid var(--green); padding-bottom: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.doc .head .wordmark { color: var(--forest); font-size: 26px; }
.doc .facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 6px 20px; font-size: 14px; margin-bottom: 18px; }
.doc .facts span { display: block; font-size: 12px; color: var(--muted); }
.doc h2 { border-bottom: 1px solid var(--sage); padding-bottom: 4px; margin-top: 28px; }
.doc .qa dt { font-weight: 700; font-size: 14px; margin-top: 12px; }
.doc .qa dd { margin: 2px 0 0; white-space: pre-wrap; font-size: 14px; }
.sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 48px; font-size: 13px; color: var(--muted); }
.sign div { border-top: 1px solid var(--ink); padding-top: 6px; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(10px); background: var(--forest); color: #fff; padding: 12px 20px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 10; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--bad-ink); }

.signin { max-width: 460px; margin: 10vh auto; text-align: left; }
.signin h1 { margin-bottom: 10px; }

@media print {
  body { background: #fff; font-size: 12pt; }
  .no-print, nav, .top, #toast { display: none !important; }
  main { max-width: none; padding: 0; }
  .doc { border: 0; padding: 0; }
  .values { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc h2 { break-after: avoid; }
  .doc .qa dd, .fb { break-inside: avoid; }
}
.actions .back { margin: 0 8px 0 0; }
@media (max-width: 720px) { .navgroup + .navgroup { border-left: 0; margin-left: 0; padding-left: 0; } }
