:root {
  --bg: #f6f4ee;
  --surface: #fffcf4;
  --surface-2: #f0ece2;
  --ink: #19211d;
  --muted: #62706a;
  --line: #d9d2c3;
  --green: #1f7a4f;
  --green-soft: #e5f3eb;
  --blue: #255f91;
  --blue-soft: #e5eef7;
  --amber: #9a650e;
  --amber-soft: #fff2d8;
  --red: #a33a32;
  --red-soft: #f8e4e0;
  --shadow: 0 18px 60px rgba(25, 33, 29, 0.08);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
}

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

button {
  cursor: pointer;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: -80px;
  z-index: 20;
  padding: 10px 12px;
  color: #fff;
  background: var(--ink);
  border-radius: 6px;
}

.skip-link:focus {
  top: 16px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 12px 24px;
  background: rgba(246, 244, 238, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #fff;
  background: var(--ink);
  border-radius: 8px;
  font-weight: 800;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1rem, 1.8vw, 1.4rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 2.4vw, 2.25rem);
  line-height: 1.12;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.topbar-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.workspace {
  display: grid;
  grid-template-columns: 208px minmax(0, 1fr);
  min-height: calc(100vh - 76px);
}

.rail {
  position: sticky;
  top: 76px;
  align-self: start;
  height: calc(100vh - 76px);
  padding: 18px 12px;
  overflow: auto;
  background: #ebe6da;
  border-right: 1px solid var(--line);
}

.rail-tab {
  display: flex;
  width: 100%;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  text-align: left;
}

.rail-tab:hover,
.rail-tab:focus-visible {
  background: rgba(255, 252, 244, 0.72);
  border-color: var(--line);
}

.rail-tab.active {
  color: #fff;
  background: var(--ink);
}

.content {
  min-width: 0;
  padding: 28px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.gate-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.gate-card {
  display: grid;
  gap: 12px;
  min-height: 174px;
  padding: 16px;
}

.gate-card h3 {
  font-size: 0.98rem;
}

.gate-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.gate-card .gate-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.gate-progress {
  height: 7px;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 999px;
}

.gate-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--amber);
}

.gate-card.ready .gate-progress span {
  background: var(--green);
}

.gate-card.stop .gate-progress span {
  background: var(--red);
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  margin-bottom: 18px;
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.mini-badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  white-space: nowrap;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.mini-badge {
  color: var(--muted);
  background: var(--surface-2);
}

.status-pill {
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid rgba(154, 101, 14, 0.28);
}

.status-pill.ready {
  color: var(--green);
  background: var(--green-soft);
  border-color: rgba(31, 122, 79, 0.28);
}

.status-pill.stop {
  color: var(--red);
  background: var(--red-soft);
  border-color: rgba(163, 58, 50, 0.28);
}

.status-pill.review {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: rgba(37, 95, 145, 0.28);
}

.fact-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.fact-list div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
}

.fact-list dt {
  color: var(--muted);
  font-weight: 800;
}

.fact-list dd {
  margin: 0;
  min-width: 0;
  line-height: 1.45;
}

code {
  padding: 2px 5px;
  overflow-wrap: anywhere;
  color: #453515;
  background: #f1e4be;
  border-radius: 4px;
  font-size: 0.92em;
}

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

.hash-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  min-width: 0;
  padding: 10px;
  background: var(--surface-2);
  border-radius: 7px;
}

.hash-row strong,
.hash-row span,
.hash-row code {
  overflow-wrap: anywhere;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.source-link,
.version-row {
  display: grid;
  gap: 8px;
  padding: 12px;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 8px;
}

.source-link {
  min-height: 116px;
}

.source-link span,
.version-row span {
  color: var(--muted);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

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

.version-row {
  grid-template-columns: 190px minmax(0, 1fr) auto;
  align-items: center;
}

.version-row.current {
  background: var(--green-soft);
  border-color: rgba(31, 122, 79, 0.24);
}

.version-row code {
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.check-list,
.proof-list {
  display: grid;
  gap: 12px;
}

.check-item,
.proof-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 8px;
}

.check-item.checked,
.proof-item.pass {
  background: var(--green-soft);
  border-color: rgba(31, 122, 79, 0.2);
}

.proof-item.stop {
  background: var(--red-soft);
  border-color: rgba(163, 58, 50, 0.2);
}

.check-item input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--green);
}

.check-main {
  min-width: 0;
}

.check-main strong,
.proof-main strong {
  display: block;
  margin-bottom: 4px;
}

.check-main p,
.proof-main p,
.inline-control p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.note-input,
.field input,
.summary-text {
  width: 100%;
  color: var(--ink);
  background: #fffef9;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.note-input {
  min-height: 38px;
  margin-top: 10px;
  padding: 8px 10px;
}

.proof-main {
  min-width: 0;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 3px;
  margin-top: 10px;
  padding: 3px;
  background: #ddd6c9;
  border-radius: 7px;
}

.segmented button {
  min-height: 32px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 5px;
}

.segmented button.active {
  color: #fff;
  background: var(--ink);
}

.stop-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  color: #563128;
}

.warning-panel {
  background: #fff7ea;
}

.inline-control {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  display: block;
  width: 52px;
  height: 30px;
  padding: 3px;
  background: #cfc7b8;
  border-radius: 999px;
}

.switch span::before {
  display: block;
  width: 24px;
  height: 24px;
  content: "";
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(25, 33, 29, 0.18);
  transition: transform 0.16s ease;
}

.switch input:checked + span {
  background: var(--blue);
}

.switch input:checked + span::before {
  transform: translateX(22px);
}

.reviewer-table {
  display: grid;
  gap: 12px;
}

.reviewer-row {
  display: grid;
  grid-template-columns: minmax(190px, 0.7fr) minmax(0, 1.3fr) 180px;
  gap: 12px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 8px;
}

.reviewer-row.ready {
  background: var(--green-soft);
  border-color: rgba(31, 122, 79, 0.2);
}

.reviewer-row.stop {
  background: var(--red-soft);
  border-color: rgba(163, 58, 50, 0.2);
}

.reviewer-id {
  display: grid;
  align-content: start;
  gap: 4px;
  min-width: 0;
}

.reviewer-id span,
.reviewer-id a {
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.criteria-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.criteria-grid label {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  color: #3c4943;
  font-size: 0.86rem;
  line-height: 1.25;
}

.criteria-grid input {
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
  accent-color: var(--green);
}

.decision-select,
.field input {
  min-height: 38px;
  padding: 0 10px;
  background: #fffef9;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.radio-stack {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.radio-stack legend {
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 800;
}

.radio-stack label {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 10px;
  background: var(--surface-2);
  border-radius: 7px;
}

.radio-stack input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-weight: 800;
}

.language-box {
  padding: 12px;
  background: var(--green-soft);
  border: 1px solid rgba(31, 122, 79, 0.18);
  border-radius: 8px;
}

.language-box + .language-box {
  margin-top: 10px;
}

.language-box p {
  margin: 5px 0 0;
  line-height: 1.45;
}

.language-box.blocked {
  color: #563128;
  background: var(--red-soft);
  border-color: rgba(163, 58, 50, 0.18);
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 7px;
  font-weight: 800;
}

.primary-button,
.icon-button {
  color: #fff;
  background: var(--ink);
  border: 1px solid var(--ink);
}

.secondary-button {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}

.secondary-button.danger {
  color: var(--red);
  border-color: rgba(163, 58, 50, 0.35);
}

.primary-button:hover,
.icon-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.summary-text {
  min-height: 520px;
  padding: 16px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
  line-height: 1.5;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  color: #fff;
  pointer-events: none;
  visibility: hidden;
  background: var(--ink);
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.16s ease, visibility 0.16s ease;
}

.toast.show {
  visibility: visible;
  opacity: 1;
}

@media (max-width: 1100px) {
  .status-grid,
  .source-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-layout {
    grid-template-columns: 1fr;
  }

  .reviewer-row {
    grid-template-columns: 1fr;
  }

  .version-row {
    grid-template-columns: 1fr;
  }
}

/* Tone refresh: match the main dashboard without the old green/khaki cast. */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef2ff;
  --ink: #151826;
  --muted: #657085;
  --line: #d8deec;
  --green: #3157d5;
  --green-soft: rgba(49, 87, 213, 0.12);
  --blue: #0f7bb8;
  --blue-soft: rgba(15, 123, 184, 0.11);
  --amber: #d89216;
  --amber-soft: rgba(216, 146, 22, 0.14);
  --red: #df5b43;
  --red-soft: rgba(223, 91, 67, 0.11);
  --shadow: 0 18px 60px rgba(21, 24, 38, 0.09);
}

body {
  background:
    linear-gradient(180deg, rgba(49, 87, 213, 0.07), transparent 300px),
    linear-gradient(115deg, rgba(255, 107, 74, 0.08), transparent 45%),
    var(--bg);
}

.topbar {
  background: rgba(248, 250, 252, 0.94);
}

.brand-mark {
  background: linear-gradient(135deg, #3157d5, #ff6b4a);
}

.rail {
  background: #e8ecf7;
}

.rail-tab.active,
.primary-button,
.icon-button,
.segmented button.active {
  background: #151826;
  color: #ffffff;
}

.status-pill.ready {
  color: #3157d5;
  background: rgba(49, 87, 213, 0.10);
  border-color: rgba(49, 87, 213, 0.24);
}

.status-pill.review {
  color: #0f7bb8;
  background: rgba(15, 123, 184, 0.11);
  border-color: rgba(15, 123, 184, 0.24);
}

.status-pill.stop {
  color: #df5b43;
  background: rgba(223, 91, 67, 0.11);
  border-color: rgba(223, 91, 67, 0.24);
}

.gate-card.ready .gate-progress span,
.check-item.checked,
.proof-item.pass,
.reviewer-row.ready,
.language-box {
  background: rgba(49, 87, 213, 0.10);
  border-color: rgba(49, 87, 213, 0.22);
}

.gate-card.stop .gate-progress span,
.proof-item.stop,
.reviewer-row.stop,
.language-box.blocked {
  background: rgba(223, 91, 67, 0.11);
  border-color: rgba(223, 91, 67, 0.22);
}

.gate-progress span {
  background: #d89216;
}

code {
  color: #7a4d00;
  background: rgba(216, 146, 22, 0.14);
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .workspace {
    display: block;
  }

  .rail {
    position: sticky;
    top: 0;
    z-index: 9;
    display: flex;
    gap: 8px;
    height: auto;
    padding: 10px 12px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .rail-tab {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
  }

  .content {
    padding: 16px;
  }

  .page-title {
    display: grid;
  }

  .status-grid,
  .source-grid {
    grid-template-columns: 1fr;
  }

  .fact-list div {
    grid-template-columns: 1fr;
  }

  .criteria-grid {
    grid-template-columns: 1fr;
  }

  .segmented {
    grid-template-columns: 1fr;
    width: 100%;
  }
}
