:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-soft: #f9faf7;
  --ink: #182220;
  --muted: #6a7470;
  --line: #d9dfd8;
  --rail: #202724;
  --rail-soft: #2b3530;
  --accent: #3f6f5a;
  --accent-dark: #294d3e;
  --gold: #a77a32;
  --danger: #a8464d;
  --success: #35705b;
  --shadow: 0 18px 48px rgba(24, 34, 32, 0.12);
  --radius: 8px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(63, 111, 90, 0.10), transparent 36%),
    linear-gradient(180deg, #fcfdfb, var(--bg));
  color: var(--ink);
}

button,
textarea,
a {
  font: inherit;
}

a { color: inherit; }

.close-shell {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  min-height: 100vh;
}

.firm-rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(63, 111, 90, 0.20), transparent 35%),
    var(--rail);
  color: #f7fbf6;
}

.back-link {
  width: fit-content;
  color: #c6dfd2;
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
}

.firm-brand {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  align-items: center;
}

.firm-brand > span {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: #f7fbf6;
  color: var(--rail);
  font-weight: 950;
}

.firm-brand strong,
.firm-brand small {
  display: block;
}

.firm-brand strong {
  line-height: 1.12;
}

.firm-brand small {
  margin-top: 4px;
  color: #cbd7d1;
}

nav {
  display: grid;
  gap: 8px;
}

nav a {
  border-radius: var(--radius);
  padding: 10px 12px;
  color: #d9e2dd;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

nav a.active,
nav a:hover {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
}

.boundary-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(255, 255, 255, 0.08);
}

.boundary-card b {
  display: block;
  margin-bottom: 7px;
}

.boundary-card p {
  margin: 0;
  color: #d9e1dc;
  font-size: 13px;
  line-height: 1.5;
}

.close-workspace {
  min-width: 0;
  padding: 26px;
}

.close-header,
.runway,
.metric-strip,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.close-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 18px 20px;
  margin-bottom: 16px;
}

.label {
  margin: 0 0 7px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 { font-size: clamp(1.62rem, 3vw, 2.72rem); }

h2 {
  font-size: clamp(1.24rem, 2vw, 1.68rem);
  line-height: 1.08;
}

.header-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}

.header-links a,
.source-tabs button,
.review-actions button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
  text-decoration: none;
}

.header-links a {
  padding: 9px 11px;
  color: var(--accent-dark);
  font-size: 13px;
}

.runway {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: stretch;
  padding: 22px;
  margin-bottom: 16px;
  background:
    linear-gradient(115deg, rgba(63, 111, 90, 0.12), transparent 42%),
    linear-gradient(90deg, #fff, #f9faf7);
}

.runway-copy {
  position: relative;
  padding-left: 22px;
}

.ledger-rule {
  position: absolute;
  left: 0;
  top: 4px;
  width: 9px;
  height: 104px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), var(--gold));
}

.runway-copy p {
  max-width: 760px;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.run-card {
  display: grid;
  gap: 12px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--panel-soft);
}

.run-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.run-meta strong { color: var(--accent-dark); }

#run-workflow {
  min-height: 46px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
}

#run-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
  overflow: hidden;
}

.metric-strip div {
  padding: 15px 18px;
  border-right: 1px solid var(--line);
}

.metric-strip div:last-child { border-right: 0; }

.metric-strip b,
.metric-strip span {
  display: block;
}

.metric-strip b {
  color: var(--accent-dark);
  font-size: 25px;
}

.metric-strip span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.close-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(370px, 0.9fr);
  grid-template-areas:
    "source review"
    "queue review"
    "proof proof";
  gap: 16px;
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}

.chip {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 9px;
  background: #e8f1ec;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.source-panel { grid-area: source; }

.queue-panel { grid-area: queue; }

.review-panel {
  grid-area: review;
  position: sticky;
  top: 18px;
}

.proof-panel { grid-area: proof; }

.source-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.source-tabs button {
  padding: 8px 10px;
  color: var(--muted);
}

.source-tabs button.active {
  border-color: rgba(63, 111, 90, 0.40);
  background: #e8f1ec;
  color: var(--accent-dark);
}

.source-view {
  min-height: 342px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: auto;
}

.source-text {
  margin: 0;
  padding: 14px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.58;
  white-space: pre-wrap;
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  background: #edf4ef;
  color: var(--accent-dark);
  font-size: 12px;
}

.close-list {
  display: grid;
  gap: 9px;
}

.close-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}

.close-item:hover,
.close-item.active {
  border-color: rgba(63, 111, 90, 0.42);
  background: #f7faf8;
}

.close-item b,
.close-item span,
.close-item small {
  display: block;
}

.close-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.close-item small {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 7px;
  background: #e8f1ec;
  color: var(--accent-dark);
  font-weight: 900;
}

.close-item[data-status="partner review"] small {
  background: #fff0d8;
  color: var(--gold);
}

.close-item[data-status="exception"] small,
.close-item[data-status="needs support"] small,
.close-item[data-status="edited"] small {
  background: #ffe7e9;
  color: var(--danger);
}

.close-item[data-status="reviewed"] small,
.close-item[data-status="ready"] small {
  background: #e0f3e8;
  color: var(--success);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--panel-soft);
  color: var(--muted);
  line-height: 1.55;
}

.review-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

textarea {
  width: 100%;
  min-height: 126px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  background: #fff;
  color: var(--ink);
  line-height: 1.5;
}

textarea[readonly] {
  background: #f9faf7;
}

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

.review-actions button {
  min-height: 42px;
  padding: 8px;
}

.review-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.76;
}

.review-actions button[data-action="review"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.review-actions button[data-action="review"]:disabled {
  background: #e0f3e8;
  color: var(--success);
}

.review-actions button[data-action="escalate"] {
  color: var(--gold);
}

.review-actions button[data-action="escalate"]:disabled {
  color: var(--muted);
}

.proof-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.proof-list li {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 12px;
}

.proof-list b,
.proof-list span {
  display: block;
}

.proof-list b {
  margin-bottom: 6px;
  color: var(--accent-dark);
  font-size: 12px;
  text-transform: uppercase;
}

.proof-list span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.52;
}

@media (max-width: 1120px) {
  .close-shell {
    grid-template-columns: 1fr;
  }

  .firm-rail {
    position: static;
    height: auto;
  }

  .runway,
  .close-grid {
    grid-template-columns: 1fr;
  }

  .close-grid {
    grid-template-areas:
      "source"
      "queue"
      "review"
      "proof";
  }

  .review-panel {
    position: static;
  }
}

@media (max-width: 680px) {
  .close-workspace,
  .firm-rail {
    padding: 16px;
  }

  .close-header,
  .panel-head {
    display: grid;
  }

  .header-links {
    justify-content: start;
  }

  .metric-strip,
  .proof-list,
  .review-actions {
    grid-template-columns: 1fr;
  }

  .metric-strip div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric-strip div:last-child { border-bottom: 0; }
}
