:root {
  color-scheme: light;
  --ink: #17231d;
  --muted: #66736c;
  --line: #dde3df;
  --paper: #ffffff;
  --wash: #f3f6f4;
  --green: #164f36;
  --green-2: #287252;
  --gold: #bd8f45;
  --danger: #9f352d;
  --shadow: 0 18px 42px rgba(24, 49, 37, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #edf2ef 0, #f8faf8 300px, #f4f6f5 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: var(--green-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 36px;
  min-height: 74px;
  padding: 0 4vw;
  color: white;
  background: rgba(18, 58, 40, 0.97);
  border-bottom: 3px solid var(--gold);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: baseline; gap: 10px; color: white; letter-spacing: .04em; }
.brand:hover { text-decoration: none; }
.brand span { font-weight: 800; letter-spacing: .16em; }
.brand strong { font-size: .9rem; font-weight: 500; opacity: .75; }
.topbar nav { display: flex; gap: 8px; }
.topbar nav a { color: white; padding: 10px 13px; border-radius: 8px; font-size: .93rem; }
.topbar nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.logout-form { margin: 0; }
.text-button { border: 0; color: white; background: transparent; cursor: pointer; font: inherit; opacity: .78; }
.text-button:hover { opacity: 1; }

.page { width: min(1440px, 92vw); margin: 0 auto; padding: 42px 0 70px; }
.hero, .page-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 28px;
}
.page-title.compact { align-items: center; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.1rem, 4vw, 3.7rem); line-height: 1.02; font-weight: 500; }
h2 { margin-bottom: 5px; font-size: 1.22rem; }
h3 { margin-bottom: 8px; font-size: 1rem; }
.hero p, .page-title p, .panel-head p { margin-bottom: 0; color: var(--muted); }
.eyebrow { margin-bottom: 10px; color: var(--green-2); font-size: .73rem; font-weight: 800; letter-spacing: .17em; }
.read-only { padding: 9px 13px; border: 1px solid #aac0b4; border-radius: 999px; color: var(--green); background: rgba(255,255,255,.6); font-size: .72rem; font-weight: 800; letter-spacing: .12em; white-space: nowrap; }
.sandbox-badge { padding: 9px 13px; border: 1px solid #e0c38a; border-radius: 999px; color: #79561c; background: #fff6e5; font-size: .72rem; font-weight: 800; letter-spacing: .1em; white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.button-link { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 10px 15px; border: 1px solid #aebcb4; border-radius: 9px; color: var(--green); background: white; font-size: .86rem; font-weight: 750; }
.button-link:hover { background: var(--wash); text-decoration: none; }
.button-link.primary { color: white; border-color: var(--green); background: var(--green); }
.button-link.primary:hover { background: #0f412c; }
.title-actions { display: flex; align-items: center; gap: 14px; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.cards article { min-height: 145px; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.82); box-shadow: var(--shadow); }
.cards article span { display: block; color: var(--muted); font-size: .82rem; }
.cards article > strong { display: block; margin: 12px 0 8px; font-family: Georgia, serif; font-size: 2.25rem; font-weight: 500; }
.cards article small { color: var(--muted); }
.compact-cards article { min-height: 125px; }

.panel { margin-bottom: 22px; padding: 25px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 20px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { padding: 11px 12px; color: var(--muted); border-bottom: 1px solid var(--line); text-align: left; font-size: .72rem; letter-spacing: .07em; text-transform: uppercase; }
td { padding: 15px 12px; border-bottom: 1px solid #edf0ee; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td small, td a + small, td strong + small { display: block; margin-top: 5px; color: var(--muted); font-size: .78rem; }

.status { display: inline-block; padding: 5px 9px; border-radius: 999px; background: #edf1ef; color: #46534c; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.status-approved, .status-completed, .status-ready_for_scope { background: #dceee5; color: #195b3e; }
.status-needs_information, .status-candidate, .status-draft, .status-sandbox_draft { background: #fff1d9; color: #825b18; }
.status-failed, .status-void, .status-rejected { background: #f9dfdd; color: #8c302a; }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 180px; padding: 30px; color: var(--muted); text-align: center; border: 1px dashed #cbd5cf; border-radius: 12px; background: var(--wash); }
.empty strong { color: var(--ink); font-size: 1.05rem; }
.empty.large { min-height: 50vh; }
.back { display: inline-block; margin-bottom: 22px; }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.facts div { min-height: 88px; padding: 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts div:nth-child(3n) { border-right: 0; }
.facts dt { margin-bottom: 7px; color: var(--muted); font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.facts dd { margin: 0; line-height: 1.45; }

.version-head { display: flex; align-items: center; gap: 20px; margin-bottom: 20px; padding: 18px; border-radius: 12px; background: var(--wash); }
.version-head > div:first-child { display: flex; flex-direction: column; flex: 1; }
.version-head span { color: var(--muted); font-size: .77rem; }
.version-head .total { text-align: right; }
.version-head .total strong { display: block; margin-top: 4px; font-family: Georgia, serif; font-size: 1.6rem; }
.split { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.split > div { padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.split ul { margin: 0; padding-left: 20px; color: var(--muted); }
.muted { color: var(--muted); }

.source-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.source-grid article { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--wash); }
.source-grid h3 { margin-top: 14px; }
.source-grid p, .source-grid small { color: var(--muted); }

.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { display: flex; justify-content: space-between; gap: 20px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline li div { display: flex; gap: 10px; align-items: baseline; }
.timeline span, .timeline time { color: var(--muted); font-size: .8rem; }

.login-shell { display: grid; min-height: calc(100vh - 140px); place-items: center; }
.login-card { width: min(460px, 94vw); padding: 44px; border: 1px solid var(--line); border-top: 5px solid var(--gold); border-radius: 16px; background: var(--paper); box-shadow: 0 24px 80px rgba(18, 58, 40, .14); }
.login-card h1 { font-size: 2.7rem; }
.login-card > p { color: var(--muted); line-height: 1.55; }
.login-form { display: grid; gap: 18px; margin-top: 28px; }
label { display: grid; gap: 8px; color: var(--muted); font-size: .83rem; font-weight: 700; }
input, select, textarea { width: 100%; padding: 13px 14px; border: 1px solid #bdc8c1; border-radius: 9px; color: var(--ink); background: white; font: inherit; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(40,114,82,.15); border-color: var(--green-2); }
input[readonly] { color: #5d6962; background: #f2f4f3; }
button.primary { padding: 13px 18px; border: 0; border-radius: 9px; color: white; background: var(--green); font: inherit; font-weight: 750; cursor: pointer; }
button.primary:hover { background: #0f412c; }
.alert { margin: 20px 0; padding: 12px 14px; border-radius: 9px; }
.alert.danger { color: #7c2924; background: #f9e5e3; border: 1px solid #efc6c2; }
.alert.warning { color: #73531c; background: #fff5df; border: 1px solid #efd8a7; }
.form-panel { display: grid; gap: 22px; }
.form-grid { display: grid; gap: 18px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-section { padding-top: 22px; border-top: 1px solid var(--line); }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.form-footer p { margin: 0; color: var(--muted); font-size: .84rem; }
fieldset { margin: 0; padding: 17px; border: 1px solid var(--line); border-radius: 11px; }
legend { padding: 0 7px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.checkbox-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 600; }
label.check input { width: 18px; height: 18px; margin: 0; padding: 0; }
.line-check { white-space: nowrap; }
.draft-table { min-width: 1120px; }
.draft-table td:nth-child(1) { min-width: 170px; }
.draft-table td:nth-child(2) { min-width: 270px; }
.draft-table td:nth-child(3) { width: 120px; }
.compact-input { min-width: 100px; }
.fine-print { margin: 22px 0 0 !important; font-size: .78rem; }

footer { padding: 0 4vw 35px; color: var(--muted); text-align: center; font-size: .76rem; }

@media (max-width: 980px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .facts div:nth-child(3n) { border-right: 1px solid var(--line); }
  .facts div:nth-child(2n) { border-right: 0; }
  .source-grid, .split { grid-template-columns: 1fr; }
  .form-grid.three, .form-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .topbar { grid-template-columns: 1fr auto; gap: 12px; padding: 12px 4vw; }
  .topbar nav { grid-column: 1 / -1; overflow-x: auto; }
  .topbar nav a { padding-left: 0; padding-right: 18px; white-space: nowrap; }
  .page { width: 94vw; padding-top: 28px; }
  .hero, .page-title, .panel-head { align-items: flex-start; flex-direction: column; }
  .cards { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; }
  .facts div { border-right: 0 !important; }
  .version-head { align-items: flex-start; flex-direction: column; }
  .version-head .total { text-align: left; }
  .title-actions, .form-footer { align-items: stretch; flex-direction: column; }
  .actions { justify-content: flex-start; }
  .form-grid.two, .form-grid.three, .form-grid.four, .checkbox-grid { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .login-card { padding: 30px 24px; }
}
