:root {
  --forest-950: #10251c;
  --forest-900: #173226;
  --forest-800: #214634;
  --forest-700: #2c6046;
  --forest-600: #39785a;
  --cream-50: #fbfaf6;
  --cream-100: #f5f1e7;
  --cream-200: #e9e1d0;
  --ink: #1c2923;
  --muted: #657169;
  --line: #dcded7;
  --red: #a53b35;
  --amber: #9b6815;
  --blue: #2e6683;
  --white: #fff;
  --shadow: 0 12px 35px rgba(23, 50, 38, .08);
  --radius: 16px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--cream-50); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(210, 220, 196, .4), transparent 28rem),
    var(--cream-50);
  font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--forest-700); }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .5rem; font-size: clamp(2rem, 4vw, 3.4rem); line-height: 1.02; letter-spacing: -.045em; }
h2 { margin-bottom: .75rem; font-size: 1.25rem; letter-spacing: -.02em; }
p { color: var(--muted); }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: .75rem max(1.25rem, calc((100vw - 1180px) / 2));
  color: var(--white);
  background: rgba(16, 37, 28, .97);
  box-shadow: 0 4px 18px rgba(12, 27, 20, .16);
  backdrop-filter: blur(10px);
}

.brand { display: flex; align-items: center; gap: .7rem; color: var(--white); font-weight: 750; text-decoration: none; letter-spacing: -.02em; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; color: var(--forest-950); background: #cbd7b7; font: 800 19px/1 Georgia, serif; }
.topbar nav { display: flex; align-items: center; gap: 1.15rem; }
.topbar nav > a, .nav-button { color: #e7ecdf; font: inherit; font-weight: 600; text-decoration: none; }
.topbar nav > a:hover, .nav-button:hover { color: var(--white); }
.inline-form { display: inline; margin: 0; }
.nav-button { padding: 0; border: 0; background: none; cursor: pointer; }

.page-shell { width: min(1180px, calc(100% - 2.5rem)); min-height: calc(100vh - 150px); margin: 0 auto; padding: 3.5rem 0 4rem; }
.page-heading { max-width: 780px; margin-bottom: 2rem; }
.page-heading p { max-width: 680px; font-size: 1.05rem; }
.split-heading { display: flex; align-items: flex-end; justify-content: space-between; max-width: none; gap: 2rem; }
.eyebrow { display: block; margin-bottom: .65rem; color: var(--forest-600); font-size: .74rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }

.panel {
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  border: 1px solid rgba(32, 70, 52, .11);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
}
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-heading p { margin-bottom: 0; }
.narrow-panel { max-width: 620px; }
.form-panel { padding: clamp(1.4rem, 3vw, 2.25rem); }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: .7rem 1rem;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: var(--white); background: var(--forest-700); }
.button-primary:hover { background: var(--forest-800); }
.button-secondary { color: var(--forest-800); border-color: #bdc9be; background: var(--white); }
.button-danger { color: var(--white); background: var(--red); }
.button-wide { width: 100%; }

.notice { margin-bottom: 1.5rem; padding: .9rem 1rem; border-left: 4px solid; border-radius: 8px; background: var(--white); box-shadow: 0 4px 16px rgba(20, 36, 28, .05); }
.notice-error { border-color: var(--red); color: #762a26; background: #fff4f2; }
.notice-success { border-color: var(--forest-600); color: var(--forest-800); background: #f1f8f3; }
.notice-warning { border-color: var(--amber); color: #714b0d; background: #fff7e9; }
.notice-info { border-color: var(--blue); color: #22506a; background: #eef7fb; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.four-stats { grid-template-columns: repeat(4, 1fr); }
.stat { min-height: 130px; padding: 1.35rem; border: 1px solid rgba(32, 70, 52, .1); border-radius: var(--radius); background: linear-gradient(145deg, var(--white), #f5f6ef); box-shadow: var(--shadow); }
.stat span { display: block; color: var(--muted); font-weight: 650; }
.stat strong { display: block; margin-top: .5rem; color: var(--forest-800); font: 700 2.4rem/1 Georgia, serif; }
.stat strong.stat-word { font: 750 1.55rem/1.2 Inter, sans-serif; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .85rem .75rem; border-bottom: 1px solid #e7e9e3; text-align: left; vertical-align: top; white-space: nowrap; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.table-link { color: var(--forest-700); font-weight: 800; text-decoration: none; }
.empty-cell { padding: 2rem; color: var(--muted); text-align: center; }

.status { display: inline-flex; align-items: center; gap: .35rem; padding: .32rem .58rem; border-radius: 999px; font-size: .78rem; font-weight: 800; white-space: nowrap; }
.status::before { width: 7px; height: 7px; border-radius: 50%; background: currentColor; content: ""; }
.status-queued { color: #61552c; background: #f7f0cc; }
.status-running { color: #245e77; background: #e2f1f8; }
.status-success { color: #24643f; background: #e1f3e8; }
.status-failed { color: #8a312c; background: #fae8e6; }
.status-review { color: #7d5112; background: #fff0d8; }
.status-muted { color: #646a66; background: #eceeeb; }

label, fieldset { display: grid; gap: .45rem; color: var(--ink); font-weight: 700; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: .45rem; padding: 0; font-weight: 700; }
input:not([type="checkbox"]):not([type="radio"]) { width: 100%; min-height: 46px; padding: .65rem .75rem; border: 1px solid #bdc5bf; border-radius: 9px; color: var(--ink); background: var(--white); font: inherit; }
input:focus { outline: 3px solid rgba(57, 120, 90, .18); border-color: var(--forest-600); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; margin-bottom: 1.5rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.6rem; }
.narrow-panel label + label, .narrow-panel label + button { margin-top: 1rem; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: grid; min-height: 46px; place-items: center; border: 1px solid #bdc5bf; border-radius: 9px; background: var(--white); cursor: pointer; }
.segmented input:checked + span { color: var(--white); border-color: var(--forest-700); background: var(--forest-700); }

.priority-fieldset { margin: .5rem 0 1.3rem; }
.priority-fieldset > p { margin-bottom: .8rem; font-weight: 400; }
.stand-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .65rem; }
.stand-choice { display: grid; gap: .2rem; padding: .8rem; border: 1px solid #c9cec9; border-radius: 10px; color: var(--ink); background: var(--white); text-align: left; cursor: pointer; }
.stand-choice strong { color: var(--muted); font-size: .75rem; }
.stand-choice.selected { color: var(--white); border-color: var(--forest-700); background: var(--forest-700); }
.stand-choice.selected strong { color: #dce9dd; }
.priority-summary { margin-top: .8rem; padding: .8rem; border-radius: 8px; background: var(--cream-100); font-weight: 500; }
.check-row { grid-template-columns: auto 1fr; align-items: start; margin: .85rem 0; padding: 1rem; border: 1px solid #d5d9d3; border-radius: 10px; background: #fafbf8; cursor: pointer; }
.check-row input { width: 18px; height: 18px; margin: .2rem 0 0; accent-color: var(--forest-700); }
.check-row span { display: grid; gap: .15rem; }
.check-row small { color: var(--muted); font-weight: 400; }
.consent-row { border-color: #b8c9b9; background: #f1f7f1; }

.detail-grid, .two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.detail-card dl { display: grid; grid-template-columns: minmax(140px, .7fr) 1.3fr; gap: .75rem 1rem; margin-bottom: 0; }
.detail-card dt { color: var(--muted); }
.detail-card dd { margin: 0; font-weight: 650; }
.result-state { margin-bottom: 1rem; }
.review-actions { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: 1.25rem; }
.review-actions p { width: 100%; margin-bottom: 0; }
.review-actions form { margin: 0; }
details summary { color: var(--forest-700); cursor: pointer; }
pre { max-width: 520px; overflow: auto; padding: .8rem; border-radius: 8px; background: #f1f3ef; font-size: .78rem; white-space: pre-wrap; }

.login-shell { display: grid; min-height: 68vh; grid-template-columns: 1.2fr .8fr; align-items: center; gap: clamp(2rem, 8vw, 7rem); }
.login-intro h1 { max-width: 720px; font-size: clamp(3rem, 6vw, 5.5rem); }
.login-intro p { max-width: 600px; font-size: 1.12rem; }
.login-card { width: 100%; max-width: 430px; justify-self: end; padding: 2rem; }
.login-card label + label { margin-top: 1rem; }
.login-card .button { margin-top: 1.4rem; }
.error-panel { max-width: 720px; margin: 4rem auto; text-align: center; }

footer { display: flex; justify-content: space-between; width: min(1180px, calc(100% - 2.5rem)); margin: 0 auto; padding: 1.5rem 0 2rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }

@media (max-width: 850px) {
  .topbar { position: static; align-items: flex-start; }
  .topbar nav { flex-wrap: wrap; justify-content: flex-end; gap: .65rem 1rem; }
  .brand > span:last-child { display: none; }
  .login-shell { grid-template-columns: 1fr; gap: 1.5rem; }
  .login-intro h1 { font-size: 3rem; }
  .login-card { max-width: none; justify-self: stretch; }
  .four-stats, .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stand-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid, .two-columns { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .page-shell { width: min(100% - 1.25rem, 1180px); padding-top: 2rem; }
  .topbar { padding: .7rem; }
  .topbar nav { font-size: .8rem; }
  .split-heading { align-items: flex-start; flex-direction: column; }
  .form-grid, .stats-grid, .four-stats { grid-template-columns: 1fr; }
  .stat { min-height: 100px; }
  .detail-card dl { grid-template-columns: 1fr; gap: .2rem; }
  .detail-card dd { margin-bottom: .65rem; }
  footer { width: min(100% - 1.25rem, 1180px); flex-direction: column; gap: .25rem; }
}
