:root {
  --paper: #faf7f2;
  --surface: #ffffff;
  --surface-soft: #f5f1ea;
  --ink: #14171f;
  --muted: #69707d;
  --line: #e7e1d6;
  --line-strong: #d5cec2;
  --orange: #ff5a1f;
  --orange-dark: #df4811;
  --green: #0f3d2e;
  --green-soft: #e8f1ed;
  --amber: #a85a00;
  --amber-soft: #fff3df;
  --red: #a62b2b;
  --red-soft: #fff0ed;
  --shadow: 0 18px 50px rgba(20, 23, 31, .07);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, select { font: inherit; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid rgba(255,90,31,.28); outline-offset: 2px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 10;
  display: flex; flex-direction: column; padding: 29px 22px 22px;
  background: var(--green); color: #fff;
}
.brand { display: flex; flex-direction: column; gap: 5px; padding: 0 8px 28px; border-bottom: 1px solid rgba(255,255,255,.15); }
.brand { color: inherit; text-decoration: none; }
.brand-name { font-size: 1.8rem; font-weight: 300; line-height: 1; letter-spacing: -.065em; }
.brand-name sup { position: relative; top: -.72em; margin-left: 2px; color: var(--orange); font-size: .48rem; }
.brand-product { color: rgba(255,255,255,.58); font: 600 .64rem/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; text-transform: uppercase; }

nav { display: grid; gap: 7px; margin-top: 28px; }
nav button {
  width: 100%; display: flex; align-items: center; gap: 13px; padding: 12px 13px;
  border: 1px solid transparent; border-radius: 10px; background: transparent; color: rgba(255,255,255,.69);
  font-size: .91rem; text-align: left; cursor: pointer; transition: background .18s, color .18s, border-color .18s;
}
nav button:hover { background: rgba(255,255,255,.07); color: #fff; }
nav button.active { border-color: rgba(255,255,255,.12); background: rgba(255,255,255,.12); color: #fff; }
.nav-icon { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid rgba(255,255,255,.22); border-radius: 8px; font: 600 .59rem ui-monospace, monospace; }
.sidebar-foot { margin-top: auto; padding: 18px 8px 2px; border-top: 1px solid rgba(255,255,255,.15); }
.sidebar-foot p { margin: 10px 0 0; color: rgba(255,255,255,.48); font-size: .72rem; line-height: 1.6; }
.system-line { display: flex; align-items: center; gap: 8px; font-size: .74rem; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #83dfb3; box-shadow: 0 0 0 5px rgba(131,223,179,.11); }

.workspace { min-width: 0; }
.testbar { padding: 8px 28px; background: var(--ink); color: rgba(255,255,255,.68); font-size: .69rem; letter-spacing: .025em; }
.testbar span { margin-right: 9px; color: #fff; font-weight: 700; }
.testbar span::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 7px 1px 0; border-radius: 50%; background: var(--orange); }
.topbar {
  min-height: 79px; display: flex; align-items: center; gap: 25px; padding: 14px 30px;
  border-bottom: 1px solid var(--line); background: rgba(250,247,242,.94); backdrop-filter: blur(12px);
}
.topbar-title { display: flex; flex-direction: column; min-width: 180px; }
.topbar-title > span { color: var(--muted); font: 600 .61rem ui-monospace, monospace; letter-spacing: .1em; text-transform: uppercase; }
.topbar-title strong { margin-top: 3px; font-size: 1rem; }
.state-picker { min-width: 240px; display: grid; gap: 4px; margin-left: auto; }
.state-picker span { color: var(--muted); font: 600 .58rem ui-monospace, monospace; letter-spacing: .08em; text-transform: uppercase; }
.state-picker select { width: 100%; padding: 8px 34px 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: .76rem; }
.site-return { padding: 8px 10px; border-bottom: 1px solid var(--orange); color: var(--ink); font-size: .72rem; font-weight: 650; text-decoration: none; white-space: nowrap; }
.site-return:hover { color: var(--orange-dark); }
.user { display: flex; align-items: center; gap: 9px; }
.user > span:last-child { display: flex; flex-direction: column; }
.user b { font-size: .76rem; }
.user small { color: var(--muted); font: .64rem ui-monospace, monospace; }
.avatar { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 50%; background: var(--green); color: #fff; font: 700 .65rem ui-monospace, monospace; }

#view { padding: 31px clamp(24px, 3.2vw, 48px) 52px; }
#apimsg { margin: 20px clamp(24px, 3.2vw, 48px) -10px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-head h1 { margin: 5px 0 0; font-size: clamp(1.8rem, 3vw, 2.55rem); font-weight: 400; letter-spacing: -.055em; line-height: 1.05; }
.eyebrow { color: var(--orange); font: 700 .64rem ui-monospace, monospace; letter-spacing: .11em; text-transform: uppercase; }
.page-copy { max-width: 480px; margin: 0; color: var(--muted); font-size: .87rem; line-height: 1.55; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.metric { min-height: 101px; display: flex; flex-direction: column; justify-content: space-between; padding: 16px 18px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.metric strong { font-size: 1.75rem; font-weight: 400; letter-spacing: -.05em; }
.metric span { color: var(--muted); font: 600 .62rem ui-monospace, monospace; letter-spacing: .075em; text-transform: uppercase; }
.metric.attention { border-color: #f0c79c; background: var(--amber-soft); }
.metric.ready { background: var(--green); color: #fff; }
.metric.ready span { color: rgba(255,255,255,.63); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 17px 0 12px; }
.toolbar h2 { margin: 0; font-size: 1rem; }
.toggle { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .75rem; }
.toggle input { accent-color: var(--orange); }

.table-shell { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .75rem; }
th { padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface-soft); color: var(--muted); font: 700 .59rem ui-monospace, monospace; letter-spacing: .07em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; transition: background .16s; }
tr.click:hover { background: #fffaf5; }
tr.click.closed { color: var(--muted); }
tr.click td:nth-child(2) { color: var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 650; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: #505764; font-size: .62rem; line-height: 1.2; white-space: nowrap; }
.chip::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #85908a; }
.chip.warn { border-color: #ecc28f; background: var(--amber-soft); color: #75410b; }
.chip.warn::before { background: #d77a17; }
.chip.bad { border-color: #e9aaa1; background: var(--red-soft); color: var(--red); }
.chip.bad::before { background: var(--red); }
.chip.good { border-color: #bed5ca; background: var(--green-soft); color: var(--green); }
.chip.good::before { background: #2a765b; }

.review-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.review-title { display: flex; align-items: center; gap: 12px; }
.review-title h1 { margin: 0; font-size: 1.35rem; font-weight: 500; letter-spacing: -.03em; }
.review-title p { margin: 4px 0 0; color: var(--muted); font-size: .73rem; }
.grid2 { display: grid; grid-template-columns: minmax(330px, .92fr) minmax(520px, 1.35fr); gap: 18px; align-items: start; }
section, .panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
section { padding: 18px; }
section > h2 { margin: 0 0 14px; font-size: .78rem; letter-spacing: .02em; }
.preview-panel { position: sticky; top: 20px; }
.panel-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-top h2 { margin: 0; font-size: .78rem; }
.panel-meta { color: var(--muted); font: .61rem ui-monospace, monospace; }
#doc { min-height: 510px; padding: 38px 34px; overflow: auto; border: 1px solid #d9d3c9; border-radius: 8px; background: #fffdfa; box-shadow: inset 0 0 0 6px #f5f1ea; color: #2b2e34; font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.preview-note { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; color: var(--muted); font-size: .68rem; }

.banner { margin: 10px 0; padding: 12px 14px; border: 1px solid #edc99e; border-radius: 10px; background: var(--amber-soft); color: #74420f; font-size: .76rem; line-height: 1.5; }
.banner.err { border-color: #e5a49b; background: var(--red-soft); color: #872921; }
.field { display: grid; grid-template-columns: minmax(155px, .72fr) minmax(210px, 1fr) auto; gap: 12px; align-items: center; margin: 0 -4px; padding: 13px 8px; border-bottom: 1px solid var(--line); }
.field:last-of-type { border-bottom: 0; }
.field.flagged { margin: 5px -4px; border: 1px solid #edc99e; border-left: 4px solid var(--orange); border-radius: 10px; background: #fffaf3; }
.field.accepted { border-left-color: var(--green); background: #f3f8f5; }
.field.rejected { opacity: .66; background: var(--red-soft); }
.name { display: flex; flex-direction: column; gap: 3px; color: #30343c; font: 650 .67rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.name small { color: var(--muted); font: 500 .59rem/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; }
.reason { grid-column: 1/-1; margin-top: -2px; color: var(--amber); font-size: .66rem; line-height: 1.45; }
input.val { width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: .76rem; transition: border-color .15s, box-shadow .15s; }
input.val:hover { border-color: #aaa297; }
input.val:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,90,31,.1); }
input.val:disabled { background: #f2efea; color: var(--muted); }

button { padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: .69rem; font-weight: 650; cursor: pointer; transition: transform .12s, border-color .15s, background .15s, color .15s; }
button:hover:not(:disabled) { border-color: #9e9589; background: #fffaf4; transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: .42; }
.btn-primary { border-color: var(--orange); background: var(--orange); color: #fff; }
.btn-primary:hover:not(:disabled) { border-color: var(--orange-dark); background: var(--orange-dark); }
.btn-dark { border-color: var(--green); background: var(--green); color: #fff; }
.btn-danger { border-color: #d9aaa4; color: var(--red); }
.btn-back { display: inline-flex; align-items: center; padding: 8px 11px; border-color: transparent; background: transparent; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.actions .muted { flex-basis: 100%; }
.retention { margin-top: 20px; font-size: .78rem; }
.retention label { display: inline-flex; align-items: center; margin: 5px 18px 5px 0; }

.muted { color: var(--muted); font-size: .7rem; line-height: 1.5; }
.empty { padding: 56px; text-align: center; color: var(--muted); }
.picker { position: fixed; inset: 50% auto auto 50%; z-index: 99; min-width: 310px; display: grid; gap: 13px; padding: 21px; transform: translate(-50%,-50%); border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 24px 80px rgba(20,23,31,.25); }
.picker::before { content: ""; position: fixed; inset: -100vh -100vw; z-index: -1; background: rgba(20,23,31,.42); }
.picker select { padding: 9px; border: 1px solid var(--line-strong); border-radius: 8px; }
.todo { padding: 8px; border: 1px dashed #a8a1cb; border-radius: 8px; background: #f5f3ff; color: #524a87; font-size: .68rem; }
#audit { margin: 0; }
#af { width: min(420px, 100%); padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--ink); font-size: .76rem; }
.audit-subhead { margin-top: 28px; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .sidebar { padding-inline: 15px; }
  .grid2 { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
  #doc { min-height: 380px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 16px 18px; }
  .brand { padding: 0; border: 0; }
  .brand-name { font-size: 1.45rem; }
  .sidebar nav { display: flex; margin: 0; }
  .sidebar nav button { width: auto; padding: 9px; }
  .sidebar nav button span:last-child, .sidebar-foot, .brand-product { display: none; }
  .testbar { padding-inline: 18px; }
  .topbar { flex-wrap: wrap; padding: 14px 18px; }
  .topbar-title { display: none; }
  .state-picker { min-width: 0; flex: 1; margin-left: 0; }
  .site-return { order: 3; }
  .user > span:last-child { display: none; }
  #view { padding: 23px 16px 40px; }
  #apimsg { margin-inline: 16px; }
  .page-head { display: block; }
  .page-copy { margin-top: 12px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric { min-height: 88px; }
  .field { grid-template-columns: 1fr; }
  .field > span:nth-child(3) { display: flex; flex-wrap: wrap; }
  .reason { grid-column: 1; }
  #doc { min-height: 340px; padding: 28px 22px; }
}

@media (max-width: 450px) {
  .testbar { font-size: .59rem; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric { padding: 13px; }
  .metric strong { font-size: 1.45rem; }
  .user { display: none; }
  .site-return { font-size: .65rem; }
}
