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

:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-muted: #f0efeb;
  --border: #e1e0dc;
  --text: #111111;
  --text-secondary: #5f6368;
  --text-muted: #8a8b8d;
  --accent: #3d4046;
  --olive-dark: #3a3e29;
  --olive-deep: #555940;
  --olive: #717353;
  --olive-sage: #a8ad88;
  --olive-pale: #d1d4bd;
  --olive-mist: #eff0e7;
  --copper: #b86a45;
  --risk: #8a3324;
  --success: var(--olive);
  --info: var(--olive-deep);
  --warning: var(--copper);
  --border-strong: color-mix(in oklab, var(--border) 55%, var(--text-muted));
  --border-subtle: color-mix(in oklab, var(--border) 50%, var(--bg));
  --accent-deep: color-mix(in oklab, var(--accent) 75%, black);
  --copper-light: color-mix(in oklab, var(--copper) 58%, white);
  --shadow-card: 0 1px 2px rgba(17, 17, 17, .04), 0 8px 24px -8px rgba(17, 17, 17, .08);
  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Manrope", "Inter", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Menlo", monospace;

  /* Совместимость компонентов с новой закрытой палитрой. */
  --forest-950: var(--text);
  --forest-800: var(--olive-deep);
  --forest-700: var(--olive);
  --forest-500: var(--olive-sage);
  --sage-300: var(--olive-pale);
  --sage-100: var(--olive-mist);
  --milk: var(--bg);
  --paper: var(--surface);
  --graphite: var(--text);
  --muted: var(--text-secondary);
  --line: var(--border);
  --danger: var(--risk);
  --blue: var(--olive-deep);
  --shadow: var(--shadow-card);
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 14px;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.58;
  -webkit-font-smoothing: antialiased;
}

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

button,
a,
select,
input {
  min-height: 44px;
}

button { cursor: pointer; }

a { color: inherit; }

h1,
h2,
h3,
p,
ul,
ol,
blockquote,
dl { margin-top: 0; }

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -.02em;
}

h1 { font-size: clamp(2.2rem, 6vw, 4.25rem); line-height: 1.02; letter-spacing: -.03em; }
h2 { font-size: clamp(1.45rem, 3vw, 2.25rem); line-height: 1.08; }
h3 { font-size: 1.18rem; line-height: 1.2; }

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  transform: translateY(-150%);
}

.skip-link:focus { transform: none; }

:focus-visible {
  outline: 3px solid color-mix(in oklab, var(--olive) 46%, transparent);
  outline-offset: 3px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  color: var(--text-muted);
  font: 600 .74rem/1.2 var(--font-sans);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.eyebrow::before {
  width: 24px;
  height: 1px;
  background: currentColor;
  opacity: .6;
  content: "";
}

.lead {
  max-width: 760px;
  color: var(--text-secondary);
  font-size: clamp(1rem, 1.8vw, 1.22rem);
}

.muted { color: var(--text-secondary); }

.wordmark {
  display: flex;
  min-height: 0;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand-symbol {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
}

.wordmark-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
  line-height: 1.1;
}

.wordmark-copy strong {
  color: currentColor;
  font: 600 15px/1.15 var(--font-display);
  letter-spacing: -.015em;
  white-space: nowrap;
}

.wordmark-copy small {
  color: var(--text-muted);
  font: 500 10px/1.1 var(--font-mono);
  letter-spacing: 0;
  white-space: nowrap;
}

.wordmark-light { color: var(--surface-muted); }

.primary-button,
.secondary-button,
.decision-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 11px 17px;
  border: 0;
  border-radius: 12px;
  font-weight: 750;
  text-decoration: none;
}

.primary-button {
  background: var(--accent);
  color: var(--surface);
  box-shadow: var(--shadow-card);
}

.primary-button:hover { background: var(--accent-deep); }

.secondary-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.compact {
  min-height: 40px;
  padding: 8px 13px;
  font-size: .83rem;
}

.text-button {
  min-height: 40px;
  padding: 7px 8px;
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, currentColor 35%, transparent);
  text-underline-offset: 4px;
}

/* Login */

.login-page {
  display: grid;
  background-color: var(--text);
  background-image: radial-gradient(circle at 1px 1px, rgba(240, 239, 235, .08) 1px, transparent 0);
  background-size: 24px 24px;
}

.login-shell {
  width: min(1240px, calc(100% - 28px));
  min-height: 100vh;
  margin: auto;
  display: grid;
  align-items: center;
  gap: 32px;
  padding: 28px 0;
}

.login-brand {
  padding: 24px 6px;
  color: var(--surface-muted);
}

.login-brand .wordmark { margin-bottom: clamp(54px, 12vw, 110px); }

.login-brand h1 {
  max-width: 820px;
  margin-bottom: 24px;
}

.login-brand .lead { color: var(--olive-pale); }

.brand-formula {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 34px;
  color: var(--olive-pale);
  font-weight: 500;
}

.brand-formula i {
  color: var(--copper);
  font-style: normal;
}

.login-card {
  width: min(100%, 520px);
  justify-self: center;
  padding: clamp(24px, 5vw, 42px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.login-card h2 { margin-bottom: 10px; }

.preview-badge {
  width: max-content;
  margin-bottom: 30px;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--olive-mist);
  color: var(--olive-deep);
  font: 600 .68rem/1 var(--font-sans);
  letter-spacing: .07em;
  text-transform: uppercase;
}

.demo-login {
  display: grid;
  gap: 12px;
  margin-top: 26px;
}

.role-card {
  width: 100%;
  min-height: 82px;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}

.role-card:hover {
  border-color: var(--olive-sage);
  box-shadow: var(--shadow-card);
  transform: translateY(-2px);
}

.role-card > span:last-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.role-card small { color: var(--muted); }

.role-icon,
.avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--olive-deep);
  color: var(--surface);
  font-weight: 600;
}

.role-icon { width: 48px; height: 48px; }
.role-icon-client { background: var(--copper); }

.security-note {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: .76rem;
}

.real-login {
  display: grid;
  gap: 15px;
  margin-top: 24px;
}

label { display: grid; gap: 6px; }

label > span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
}

input,
select { padding: 10px 12px; }
textarea { min-height: 92px; padding: 12px; resize: vertical; }

.form-error {
  min-height: 1.3em;
  margin-bottom: 0;
  color: var(--danger);
  font-size: .82rem;
}

/* Shared app shell */

.portal-topbar {
  position: relative;
  z-index: 20;
  background: var(--text);
  color: var(--surface-muted);
}

.topbar-inner {
  width: min(1280px, calc(100% - 28px));
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 28px;
  margin: auto;
}

.top-nav {
  display: flex;
  gap: 5px;
  margin-right: auto;
}

.top-nav a {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 9px;
  color: var(--olive-pale);
  font-size: .84rem;
  font-weight: 700;
  text-decoration: none;
}

.top-nav a:hover { background: color-mix(in oklab, var(--surface) 9%, transparent); color: var(--surface); }

.user-panel {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 40px;
  height: 40px;
  background: var(--copper);
  font-size: .78rem;
}

.user-copy { display: grid; line-height: 1.15; }
.user-copy strong { font-size: .8rem; }
.user-copy small { margin-top: 4px; color: var(--text-muted); font-size: .66rem; }

.app-shell,
.document-shell {
  width: min(1280px, calc(100% - 28px));
  margin: auto;
  padding: 34px 0 76px;
}

.project-hero {
  display: grid;
  gap: 22px;
  align-items: stretch;
}

.project-hero > div,
.next-gate-card {
  padding: clamp(24px, 5vw, 48px);
  border-radius: var(--radius-xl);
}

.project-hero > div {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.project-hero h1 {
  max-width: 850px;
  margin-bottom: 18px;
  color: var(--forest-950);
}

.next-gate-card {
  background: var(--olive-dark);
  color: var(--surface-muted);
}

.next-gate-card h2 { margin-bottom: 22px; }
.next-gate-card > p:last-child { margin-bottom: 0; color: var(--olive-pale); font-size: .78rem; }

.current-state {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.current-state span {
  min-width: min(100%, 235px);
  display: grid;
  gap: 4px;
  padding: 13px 15px;
  border-radius: 12px;
  background: var(--olive-mist);
}

.current-state small { color: var(--muted); }
.current-state strong { color: var(--forest-950); }

.metrics-grid,
.waiting-grid,
.triple-grid {
  display: grid;
  gap: 12px;
}

.metrics-grid { margin: 14px 0; }

.metric-card,
.waiting-grid article,
.content-card,
.document-card {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.metric-card > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 800;
}

.metric-card p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: .78rem;
}

.progress-track {
  height: 9px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--olive-mist);
}

.progress-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--olive);
}

.waiting-grid { margin-bottom: 60px; }

.waiting-grid article {
  display: grid;
  gap: 7px;
}

.waiting-grid span {
  color: var(--muted);
  font: 600 .7rem/1.2 var(--font-sans);
  letter-spacing: .07em;
  text-transform: uppercase;
}

.waiting-grid strong { font-size: .9rem; }
.waiting-grid .risk {
  border-color: color-mix(in oklab, var(--risk) 34%, var(--border));
  background: color-mix(in oklab, var(--risk) 6%, var(--surface));
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin: 52px 0 20px;
}

.section-heading h2 { margin-bottom: 0; }
.section-heading > p { max-width: 420px; margin-bottom: 0; color: var(--muted); text-align: right; }

.vertical-route {
  position: relative;
  display: grid;
  gap: 14px;
}

.vertical-route::before {
  position: absolute;
  top: 40px;
  bottom: 40px;
  left: 25px;
  width: 2px;
  background: var(--line);
  content: "";
}

.route-stage {
  position: relative;
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 13px;
}

.route-marker {
  z-index: 1;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  margin-top: 22px;
  border: 5px solid var(--bg);
  border-radius: 50%;
  background: var(--olive-pale);
  color: var(--text);
  font: 500 1rem/1 var(--font-mono);
}

.route-card {
  min-width: 0;
  padding: clamp(20px, 3vw, 30px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.route-card-head,
.stage-title-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.route-card h3 { margin-bottom: 8px; font-size: clamp(1.35rem, 2.4vw, 1.8rem); }
.route-card > p { color: var(--muted); }

.stage-index,
.document-kind {
  color: var(--muted);
  font: 600 .66rem/1 var(--font-sans);
  letter-spacing: .07em;
  text-transform: uppercase;
}

.status-pill,
.comment-status {
  height: max-content;
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: .7rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-in-progress .route-marker,
.status-in-progress .status-pill { background: var(--copper); color: var(--surface); }
.status-passed .route-marker,
.status-passed .status-pill { background: var(--olive); color: var(--surface); }
.status-passed-with-gaps .route-marker,
.status-passed-with-gaps .status-pill { background: var(--olive-deep); color: var(--surface); }
.status-blocked .route-marker,
.status-blocked .status-pill { background: var(--risk); color: var(--surface); }

.route-meta {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}

.route-meta span {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: .82rem;
}

.route-meta strong {
  color: var(--forest-700);
  font-size: .66rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.arrow-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--forest-700);
  font-weight: 800;
  text-decoration: none;
}

.arrow-link:hover span { transform: translateX(3px); }
.arrow-link span { transition: transform .2s ease; }

.portal-note {
  display: grid;
  gap: 20px;
  margin-top: 28px;
  padding: clamp(24px, 4vw, 38px);
  border-radius: var(--radius-xl);
  background: var(--text);
  color: var(--surface-muted);
}

.portal-note h2 { margin-bottom: 0; }
.portal-note > p { margin-bottom: 0; color: var(--text-muted); }

.empty-state {
  padding: 60px 0;
  text-align: center;
}

.brand-footer {
  margin: 42px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  color: color-mix(in oklab, var(--text-muted) 60%, var(--bg));
  font: 500 .7rem/1.45 var(--font-sans);
}

/* Stage */

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: .78rem;
}

.breadcrumbs a { color: var(--forest-700); font-weight: 750; }

.stage-nav {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  padding: 8px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in oklab, var(--bg) 93%, transparent);
  backdrop-filter: blur(12px);
}

.stage-nav a {
  min-width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
}

.stage-nav a span {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  background: var(--olive-mist);
  font-weight: 600;
}

.stage-nav a.active {
  background: var(--text);
  color: var(--surface);
}

.stage-nav a.active span { background: var(--copper); }

.stage-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: clamp(18px, 4vw, 38px);
  padding: clamp(24px, 5vw, 48px);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stage-hero h1 {
  max-width: 850px;
  margin-bottom: 16px;
  color: var(--forest-950);
}

.stage-code-large {
  width: clamp(62px, 10vw, 104px);
  height: clamp(62px, 10vw, 104px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--olive-pale);
  color: var(--text);
  font: 500 clamp(1.4rem, 4vw, 2.3rem)/1 var(--font-mono);
}

.stage-hero.status-in-progress .stage-code-large { background: var(--copper); color: var(--surface); }
.stage-hero.status-passed-with-gaps .stage-code-large { background: var(--olive-deep); color: var(--surface); }

.ckp-card {
  display: grid;
  gap: 5px;
  margin-top: 24px;
  padding: 15px 17px;
  border-left: 4px solid var(--copper);
  border-radius: 0 12px 12px 0;
  background: var(--olive-mist);
}

.ckp-card span { color: var(--muted); font-size: .7rem; font-weight: 750; text-transform: uppercase; }
.ckp-card strong { color: var(--forest-950); }

.stage-layout {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}

.stage-content { min-width: 0; display: grid; gap: 14px; }
.content-card h2 { margin-bottom: 16px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips span {
  padding: 8px 10px;
  border: 1px solid var(--olive-pale);
  border-radius: 999px;
  background: var(--surface);
  color: var(--olive-deep);
  font-size: .78rem;
  font-weight: 500;
}

.content-card ul,
.content-card ol {
  margin-bottom: 0;
  padding-left: 20px;
}

.content-card li { margin: 7px 0; }
.content-card.warning {
  background: color-mix(in oklab, var(--copper) 7%, var(--surface));
  border-color: color-mix(in oklab, var(--copper) 34%, var(--border));
}
.check-list li::marker { color: var(--forest-700); }

.result-card {
  background: var(--text);
  color: var(--surface-muted);
}

.result-card li { color: var(--surface-muted); }

.decision-line {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,.15);
}

.decision-line strong { color: var(--copper-light); }

.documents-section { margin-top: 18px; }
.compact-heading { margin-top: 0; }

.document-list { display: grid; gap: 10px; }

.document-card {
  display: grid;
  gap: 16px;
}

.document-card h3 { margin: 7px 0; font-size: 1.2rem; }
.document-card p { margin-bottom: 0; color: var(--muted); font-size: .8rem; }

.document-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  color: var(--muted);
  font-size: .78rem;
}

.stage-aside { min-width: 0; display: grid; align-content: start; gap: 12px; }

.gate-card,
.aside-note {
  padding: 24px;
  border-radius: var(--radius-lg);
}

.gate-card {
  background: var(--olive-dark);
  color: var(--surface-muted);
}

.gate-card h2 { font-size: 1.45rem; }
.gate-card dl { margin-bottom: 0; }
.gate-card dl div { display: grid; gap: 3px; padding: 11px 0; border-top: 1px solid rgba(255,255,255,.16); }
.gate-card dt { color: var(--olive-pale); font-size: .7rem; }
.gate-card dd { margin: 0; font-weight: 750; }

.aside-note {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.aside-note p { margin: 8px 0 0; color: var(--muted); font-size: .82rem; }

/* Document and comments */

.document-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: end;
  margin-bottom: 20px;
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.document-toolbar h1 {
  margin-bottom: 9px;
  font-size: clamp(2rem, 4.4vw, 3.8rem);
  color: var(--forest-950);
}

.document-toolbar p { margin-bottom: 0; color: var(--muted); }
.version-select { width: min(100%, 270px); flex: 0 0 auto; }

.document-layout {
  display: grid;
  gap: 16px;
  align-items: start;
}

.published-document {
  min-width: 0;
  padding: clamp(20px, 4vw, 46px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.document-notice {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 36px;
  padding: 12px 14px;
  border-radius: 11px;
  background: var(--olive-mist);
  color: var(--muted);
  font-size: .76rem;
}

.document-notice span { color: var(--forest-700); font-weight: 800; }
.document-notice p { margin-bottom: 0; }

.document-section {
  position: relative;
  padding: 10px 0 34px;
  border-bottom: 1px solid var(--line);
}

.document-section + .document-section { padding-top: 34px; }

.document-section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.document-section h2 {
  max-width: 720px;
  margin-bottom: 18px;
  color: var(--forest-950);
}

.section-comment-button {
  min-width: max-content;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--accent);
  font-size: .7rem;
  font-weight: 750;
}

.document-prose {
  max-width: 780px;
  color: var(--text-secondary);
  font-size: 1.02rem;
  line-height: 1.72;
}

.document-prose li { margin: 8px 0; }

.document-decision {
  margin-top: 36px;
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--text);
  color: var(--surface-muted);
}

.document-decision h2 { max-width: 720px; }

.decision-current,
.decision-empty {
  margin: 18px 0;
  padding: 13px 15px;
  border-radius: 11px;
  background: color-mix(in oklab, var(--surface) 9%, transparent);
}

.decision-current { display: grid; gap: 4px; }
.decision-current strong { color: var(--copper-light); }
.decision-current span { color: var(--olive-pale); font-size: .76rem; }
.decision-empty { color: var(--olive-pale); }

.decision-buttons { display: flex; flex-wrap: wrap; gap: 9px; }
.decision-button.approve { background: var(--olive-pale); color: var(--text); }
.decision-button.changes { background: var(--copper); color: var(--surface); }

.comments-panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.comments-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.comments-panel-head h2 { margin-bottom: 0; }

.comment-count {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: var(--olive-deep);
  color: var(--surface);
  font-weight: 600;
}

.version-toggle {
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 8px;
  margin: 18px 0;
  color: var(--muted);
  font-size: .78rem;
}

.version-toggle input { width: 18px; min-height: 18px; height: 18px; }

.comment-form {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
  padding: 14px;
  border-radius: 14px;
  background: var(--olive-mist);
}

.selection-preview {
  padding: 11px;
  border-left: 3px solid var(--copper);
  border-radius: 0 9px 9px 0;
  background: var(--surface);
}

.selection-preview > span {
  color: var(--copper);
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.selection-preview blockquote {
  margin: 7px 0 2px;
  color: var(--text);
  font-size: .78rem;
}

.comments-list { display: grid; gap: 10px; }

.comment-thread {
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.comment-thread.status-resolved { opacity: .72; }

.comment-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.comment-head > div { display: grid; gap: 3px; }
.comment-head strong { font-size: .82rem; }
.comment-head span { color: var(--muted); font-size: .66rem; }

.comment-thread.status-open .comment-status {
  background: color-mix(in oklab, var(--copper) 11%, var(--surface));
  color: var(--copper);
}
.comment-thread.status-answered .comment-status { background: var(--olive-mist); color: var(--olive-deep); }
.comment-thread.status-resolved .comment-status { background: var(--surface-muted); color: var(--olive); }

.comment-thread blockquote {
  margin: 13px 0;
  padding: 10px 11px;
  border-left: 3px solid var(--copper);
  background: var(--olive-mist);
  color: var(--muted);
  font-size: .74rem;
}

.comment-anchor {
  margin-bottom: 6px;
  color: var(--forest-700);
  font-size: .66rem;
  font-weight: 800;
}

.comment-body { margin-bottom: 14px; font-size: .85rem; }

.comment-replies {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.comment-reply {
  padding: 11px;
  border-radius: 10px;
  background: var(--surface-muted);
}

.comment-reply > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  font-size: .7rem;
}

.comment-reply span { color: var(--muted); }
.comment-reply p { margin-bottom: 0; font-size: .78rem; }

.reply-form {
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.reply-form textarea { min-height: 64px; font-size: .78rem; }
.comment-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }

.empty-comments {
  padding: 24px 10px;
  color: var(--muted);
  text-align: center;
}

.empty-comments p { margin: 6px 0 0; font-size: .78rem; }

@media (min-width: 760px) {
  .login-shell { grid-template-columns: minmax(0, 1.3fr) minmax(390px, .7fr); }
  .project-hero { grid-template-columns: minmax(0, 1.5fr) minmax(300px, .5fr); }
  .metrics-grid,
  .waiting-grid,
  .triple-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .route-meta { grid-template-columns: minmax(0, 1.6fr) minmax(0, .6fr); }
  .portal-note { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); align-items: end; }
  .document-card { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
}

@media (min-width: 980px) {
  .stage-layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .stage-aside { position: sticky; top: 90px; }
  .document-layout { grid-template-columns: minmax(0, 1fr) 390px; }
  .comments-panel { position: sticky; top: 18px; max-height: calc(100vh - 36px); overflow-y: auto; }
}

@media (max-width: 760px) {
  h1 { font-size: clamp(2.25rem, 13vw, 4rem); }
  .login-brand { padding-top: 10px; }
  .login-brand .wordmark { margin-bottom: 46px; }
  .login-card { border-radius: 22px; }
  .topbar-inner { min-height: 66px; gap: 8px; }
  .portal-topbar .brand-symbol { width: 28px; height: 28px; }
  .portal-topbar .wordmark-copy strong { font-size: 13px; }
  .portal-topbar .wordmark-copy small { display: none; }
  .top-nav { display: none; }
  .user-copy { display: none; }
  .user-panel { margin-left: auto; }
  .portal-topbar .avatar { width: 34px; height: 34px; }
  .portal-topbar .text-button { min-height: 40px; padding-inline: 4px; font-size: .78rem; }
  .app-shell,
  .document-shell { width: min(100% - 18px, 1280px); padding-top: 18px; }
  .project-hero > div,
  .next-gate-card { padding: 22px 18px; }
  .section-heading { display: block; }
  .section-heading > p { margin-top: 10px; text-align: left; }
  .route-stage { grid-template-columns: 39px 1fr; gap: 6px; }
  .vertical-route::before { left: 18px; }
  .route-marker { width: 38px; height: 38px; margin-top: 22px; border-width: 3px; font-size: .8rem; }
  .route-card { padding: 18px 14px; }
  .route-card-head,
  .stage-title-row { display: block; }
  .status-pill { margin: 6px 0 10px; }
  .stage-hero { grid-template-columns: 1fr; padding: 22px 17px; }
  .stage-code-large { width: 58px; height: 58px; }
  .stage-nav { margin-inline: -9px; border-radius: 0; }
  .stage-nav a small { display: none; }
  .triple-grid { grid-template-columns: 1fr; }
  .decision-line { grid-template-columns: 1fr; }
  .document-toolbar { display: grid; padding: 18px; }
  .version-select { width: 100%; }
  .published-document,
  .comments-panel { padding: 17px 14px; border-radius: 18px; }
  .document-notice,
  .document-section-head { display: grid; }
  .section-comment-button { min-width: 0; width: 100%; }
  .document-decision { padding: 18px 14px; }
  .decision-buttons { display: grid; }
  .comment-head { display: grid; }
  .comment-status { width: max-content; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

@media print {
  .portal-topbar,
  .stage-nav,
  .comments-panel,
  .section-comment-button,
  .decision-buttons { display: none !important; }
  body { background: white; }
  .document-shell,
  .app-shell { width: 100%; padding: 0; }
  .published-document { border: 0; box-shadow: none; }
}
