:root {
  --paper: #f3ecdf;
  --paper-2: #faf6ee;
  --ink: #1e1a14;
  --muted: #6d6458;
  --line: #ddcfc0;
  --navy: #1e3a5f;
  --red: #9d2c2c;
  --red-bg: #f8e4dc;
  --amber: #8a5a12;
  --amber-bg: #f8efd8;
  --green: #1d6b45;
  --green-bg: #e4f2ea;
  --blue: #234f84;
  --blue-bg: #e3ecf7;
  --violet: #5a3d8a;
  --violet-bg: #ece6f6;
  --hl: rgba(255, 196, 0, 0.38);
  --shadow: 0 18px 40px rgba(48, 32, 12, 0.08);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
kbd { font-family: inherit; font-size: 11px; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: 4px; opacity: 0.8; }
h1 { font-family: Palatino, "Iowan Old Style", serif; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.kicker { letter-spacing: 0.16em; text-transform: uppercase; font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }
.pad { padding: 16px; }

/* ----------------------------------------------------------------- rail */

.rail {
  width: 236px; flex: none; padding: 22px 16px; background: #1e1a14; color: #f3ecdf;
  display: flex; flex-direction: column; gap: 10px; min-height: 100vh; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.brand strong { display: block; font-family: Palatino, "Iowan Old Style", serif; font-size: 28px; font-weight: 600; letter-spacing: -0.03em; }
.brand em { display: block; font-style: normal; color: #c8b8a2; font-size: 13px; }
.mark { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid #c8b8a2; border-radius: 50%; font-family: Palatino, serif; font-size: 16px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button {
  display: flex; justify-content: space-between; align-items: center; border: 0; background: transparent; color: #f3ecdf;
  border-radius: 10px; padding: 10px 12px; text-align: left; font-size: 15px;
}
.nav button.active { background: #3a3128; }
.count { background: #f3ecdf; color: #1e1a14; border-radius: 999px; font-size: 12px; padding: 0 7px; min-width: 20px; text-align: center; }
.count:empty { display: none; }
.rail-label { margin: 14px 0 4px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: #c8b8a2; }
.who { display: flex; flex-direction: column; gap: 6px; }
.who input, .who select { background: #2c251d; border: 1px solid #4b4035; color: #f3ecdf; border-radius: 8px; padding: 7px 8px; width: 100%; }
.who small { color: #c8b8a2; font-size: 12px; }
.rail .quiet { border: 1px solid #8d7b66; background: transparent; color: #f3ecdf; border-radius: 999px; padding: 9px 12px; text-align: left; margin-top: 8px; }
.privacy { margin: auto 0 0; padding-top: 12px; border-top: 1px solid #3a3128; color: #c8b8a2; font-size: 12px; line-height: 1.45; }

main { flex: 1; min-width: 0; padding: 22px; }

/* ----------------------------------------------------------------- shared */

button.primary, .intake button, .bar button, .modal button, .card button, .empty button, .btn {
  background: var(--navy); color: white; border: 0; border-radius: 999px; padding: 10px 16px; text-decoration: none; display: inline-block; font-size: 14px;
}
.ghost, .btn.ghost { background: transparent !important; color: var(--ink) !important; border: 1px solid var(--line) !important; }
.btn.disabled { opacity: 0.45; pointer-events: none; }
button.tiny, .tiny { padding: 4px 10px !important; font-size: 12px !important; border-radius: 999px; background: var(--navy); color: white; border: 0; }
button.tiny.ghost { background: white !important; }
.pill { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 12px; white-space: nowrap; font-weight: 600; }
.s-docs_pending { background: var(--amber-bg); color: var(--amber); }
.s-to_check { background: var(--red-bg); color: var(--red); }
.s-query { background: var(--violet-bg); color: var(--violet); }
.s-checklist_sent { background: var(--blue-bg); color: var(--blue); }
.s-ready { background: var(--green-bg); color: var(--green); }
.s-uploaded { background: #ebe6de; color: var(--muted); }
.docs { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.doc { font-size: 12px; border-radius: 6px; padding: 2px 6px; white-space: nowrap; }
.doc.in { background: var(--green-bg); color: var(--green); }
.doc.missing { background: var(--red-bg); color: var(--red); font-weight: 600; }
.doc.later { background: #ebe6de; color: var(--muted); font-style: italic; }
.doc.awaited { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
.banner { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-radius: 12px; padding: 9px 12px; margin: 0; font-size: 14px; }
.banner.bad { background: var(--red-bg); color: var(--red); }
.banner.warn { background: var(--amber-bg); color: var(--amber); }
.banner.ok { background: var(--green-bg); color: var(--green); }
.banner.query { background: var(--violet-bg); color: var(--violet); }
.banner.revision { background: #fff3c4; color: #5d4500; }
.banner.demo { background: white; border: 1px dashed var(--line); color: var(--muted); }
.banner .sb { display: inline-flex; gap: 6px; align-items: center; }
.banner .sb input { width: 140px; padding: 4px 8px; }
.empty { color: var(--muted); padding: 18px; background: var(--paper-2); border: 1px dashed var(--line); border-radius: 14px; }
.empty p { margin: 0 0 12px; }

/* ----------------------------------------------------------------- inbox */

.inbox { display: flex; flex-direction: column; gap: 14px; }
.inbox-head { display: flex; gap: 20px; justify-content: space-between; align-items: stretch; }
.inbox-head h1 { font-size: 44px; }
.sub { margin: 6px 0 0; color: var(--muted); }
.intake {
  max-width: 460px; border: 1.5px dashed #b7a48e; border-radius: 18px; background: var(--paper-2); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.intake span { font-size: 13px; color: var(--muted); line-height: 1.4; }
.intake.hot { background: #efe2cc; border-color: var(--navy); }
.intake.busy { opacity: 0.7; }
.intake-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.intake select { background: white; border: 1px solid var(--line); border-radius: 999px; padding: 8px 10px; }
.status-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.status-tabs button { border: 1px solid var(--line); background: white; border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.status-tabs button span { color: var(--muted); margin-left: 4px; }
.status-tabs button.active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
table.jobs { width: 100%; border-collapse: separate; border-spacing: 0; background: white; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
table.jobs th { text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; background: var(--paper-2); border-bottom: 1px solid var(--line); }
table.jobs td { padding: 11px 12px; border-bottom: 1px solid #f0e6d8; vertical-align: middle; font-size: 14px; }
table.jobs tr[data-open] { cursor: pointer; }
table.jobs tr[data-open]:hover td, table.jobs tr[data-open]:focus td { background: #fbf6ec; }
table.jobs td small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
table.jobs tr:last-child td { border-bottom: 0; }
td.cut { font-weight: 600; white-space: nowrap; }
.cut.soon { color: var(--amber); }
.cut.overdue { color: var(--red); }
td.next.bad { color: var(--red); font-weight: 600; }

/* ----------------------------------------------------------------- job */

.job { height: calc(100vh - 44px); display: flex; flex-direction: column; gap: 10px; }
.job-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.job-title h1 { font-size: 26px; line-height: 1.15; }
.job-title h1 span { color: var(--muted); font-weight: 400; }
.job-title h1 .cut { color: var(--muted); }
.job-title h1 .cut.soon { color: var(--amber); font-weight: 600; }
.job-title h1 .cut.overdue { color: var(--red); font-weight: 600; }
.back { border: 0; background: none; color: var(--muted); padding: 0; margin-bottom: 4px; font-size: 13px; }
.docs-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; font-size: 13px; color: var(--muted); }
.cutoff-edit { display: inline-flex; gap: 6px; align-items: center; margin-left: 10px; }
.cutoff-edit input { width: auto; padding: 3px 6px; font-size: 12px; }
.later { margin: 4px 0 0; font-size: 12px; color: var(--muted); font-style: italic; }
.job-state { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.counter { border: 0; border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 14px; }
.counter.bad { background: var(--red); color: white; }
.counter.ok { background: var(--green-bg); color: var(--green); }
.banners { display: flex; flex-direction: column; gap: 6px; }
.split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(320px, 0.95fr) minmax(460px, 1.25fr); gap: 12px; }
.pane { background: var(--paper-2); border: 1px solid var(--line); border-radius: 16px; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.tabs { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); overflow: auto; flex: none; }
.tabs button { border: 0; background: transparent; border-radius: 999px; padding: 6px 10px; color: var(--muted); white-space: nowrap; font-size: 13px; }
.tabs button.active { background: var(--navy); color: white; }
.tabs button.replaced { text-decoration: line-through; opacity: 0.7; }
.tabs button.replaced.active { text-decoration: line-through; opacity: 1; }
.tabs .tab-add { margin-left: auto; border: 1px dashed var(--line); color: var(--ink); }
.where { padding: 6px 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); min-height: 30px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; flex: none; }
.where .also { display: inline-flex; gap: 4px; align-items: center; }
.preview { flex: 1; min-height: 0; overflow: auto; background: #e7dccb; }
.doc-view { padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.page { position: relative; background: white; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); width: 100%; }
.page img { width: 100%; height: 100%; display: block; }
.page .hl { position: absolute; background: var(--hl); outline: 2px solid #e0a800; border-radius: 2px; pointer-events: none; transition: all 0.15s ease; }
.open-original { margin: 0; font-size: 12px; text-align: center; }
.open-original a { color: var(--navy); }
.sheet { overflow: auto; background: white; }
.sheet table { border-collapse: collapse; font-size: 12px; }
.sheet th { background: #f1ebe0; color: var(--muted); font-weight: 400; padding: 3px 6px; border: 1px solid var(--line); position: sticky; top: 0; }
.sheet tr th:first-child { position: sticky; left: 0; }
.sheet td { border: 1px solid var(--line); padding: 4px 6px; white-space: nowrap; }
.sheet td.hl-cell { background: var(--hl); outline: 2px solid #e0a800; }

.pane.work { display: block; overflow: auto; padding: 12px 14px; }
.section { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
.section small, .tofix h3 small { letter-spacing: 0; text-transform: none; font-weight: 400; margin-left: 6px; }
.tofix { background: var(--red-bg); border-radius: 12px; padding: 10px 12px; }
.tofix.clear { background: var(--green-bg); }
.tofix h3 { margin: 0 0 6px; font-size: 15px; color: var(--red); }
.tofix.clear h3 { color: var(--green); }
.tofix.clear p { margin: 0; font-size: 13px; }
.fix { border-top: 1px solid rgba(157, 44, 44, 0.15); padding: 7px 0; }
.fix:first-of-type { border-top: 0; }
.fix.current .fix-go { text-decoration: underline; }
.fix-go, .note-go { border: 0; background: none; padding: 0; font-weight: 600; text-align: left; color: inherit; }
.fix-go { color: var(--red); }
.fix p, .note p { margin: 3px 0 4px; font-size: 13px; }
.fix-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 10px; }
label.field { display: flex; flex-direction: column; gap: 3px; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
label.field.inline { text-transform: none; letter-spacing: 0; font-size: 13px; }
input, select.template, textarea {
  background: white; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; width: 100%;
  text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink);
}
input.num { text-align: right; font-variant-numeric: tabular-nums; }
input:focus, textarea:focus { outline: 2px solid var(--navy); outline-offset: -1px; }
.bad > input { background: var(--red-bg); border-color: #e3b2a8; }
.warn > input { background: var(--amber-bg); border-color: #ead7a4; }
.src { display: none; font-size: 11px; color: var(--muted); text-transform: none; letter-spacing: 0; line-height: 1.3; }
.src:empty { display: none !important; }
label.field .src { display: block; }
td.bad .src, td.warn .src, td.focused .src { display: block; }
.focused > input { box-shadow: 0 0 0 2px #e0a800; }
.grid-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: white; }
table.lines { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 980px; }
table.lines th { text-align: left; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #faf6ee; }
table.lines th.num { text-align: right; }
table.lines td { padding: 4px; border-bottom: 1px solid #f0e6d8; vertical-align: top; }
table.lines td.ln { color: var(--muted); padding-top: 10px; text-align: center; }
table.lines td:nth-child(2) { min-width: 250px; }
table.lines td.num .src { text-align: right; }
.hsn-note { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); line-height: 1.3; }
.notes { margin-top: 4px; display: flex; flex-direction: column; gap: 8px; }
.notes > .section { margin-bottom: 0; }
.note { background: var(--amber-bg); border-radius: 12px; padding: 9px 12px; }
.note-go { color: var(--amber); }
.notes > button { align-self: flex-start; }
.record { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 10px; }
.record summary { cursor: pointer; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.record summary small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.record ol { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.record li { font-size: 13px; padding-left: 10px; border-left: 3px solid var(--line); }
.record li small { display: block; color: var(--muted); font-size: 12px; }
.record li.k-approve { border-color: var(--green); }
.record li.k-send_back, .record li.k-system { border-color: var(--red); }
.record li.k-query { border-color: var(--violet); }
.record li.k-revision { border-color: #e0a800; }
.record li.k-checklist { border-color: var(--blue); }
.bar { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: white; border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; flex: none; }
.bar-note { font-size: 13px; color: var(--muted); }
.bar-actions { display: flex; gap: 6px; align-items: center; }
select.template { width: auto; }

/* ----------------------------------------------------------------- dialogs */

.modal-back { position: fixed; inset: 0; background: rgba(30, 26, 20, 0.45); display: grid; place-items: center; padding: 20px; z-index: 20; }
.modal { background: var(--paper-2); border-radius: 18px; padding: 20px 22px; width: min(640px, 100%); max-height: calc(100vh - 40px); overflow: auto; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.modal h2 { font-family: Palatino, serif; margin: 0; font-size: 24px; }
.modal h3 { margin: 6px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.modal p { margin: 0; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; align-self: flex-start; background: white; }
.seg button { background: transparent !important; color: var(--ink) !important; border: 0; border-radius: 999px; padding: 5px 14px !important; }
.seg button.active { background: var(--navy) !important; color: white !important; }
.points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.points label { display: flex; gap: 8px; align-items: flex-start; }
.points input { width: auto; margin-top: 3px; }
.figures { font-variant-numeric: tabular-nums; font-weight: 600; }
table.mini { border-collapse: collapse; font-size: 13px; width: 100%; background: white; border-radius: 8px; }
table.mini th, table.mini td { border-bottom: 1px solid var(--line); padding: 5px 6px; text-align: left; }
table.mini .num { text-align: right; font-variant-numeric: tabular-nums; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.changes { margin: 0; padding-left: 18px; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.changes small { color: var(--muted); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: white; padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 30; max-width: calc(100vw - 40px); box-shadow: var(--shadow); }
.toast.bad { background: var(--red); }

/* ----------------------------------------------------------------- approvals */

.approvals { max-width: 760px; display: flex; flex-direction: column; gap: 12px; }
.approvals h1 { font-size: 40px; }
.approvals h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin: 14px 0 0; }
.approvals h2 span { background: white; border-radius: 999px; padding: 0 8px; margin-left: 4px; }
.card { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.card header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.card header small { display: block; color: var(--muted); margin-top: 2px; }
.card p { margin: 0; font-size: 14px; }
.card h3 { margin: 4px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.card-actions { display: flex; gap: 8px; }
.card-actions button { flex: 1; padding: 12px; font-size: 16px; }
.sendback { display: flex; flex-direction: column; gap: 8px; }
.revision-line { background: #fff3c4; border-radius: 8px; padding: 6px 8px; font-size: 13px !important; }
blockquote { margin: 0; padding: 8px 10px; background: var(--violet-bg); border-radius: 10px; font-size: 14px; }

/* ----------------------------------------------------------------- narrow screens */

@media (max-width: 1100px) {
  .fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(280px, 0.8fr) minmax(400px, 1.2fr); }
}

@media (max-width: 760px) {
  body { display: block; }
  .rail { width: auto; min-height: 0; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 14px; gap: 8px; }
  .brand { margin: 0; }
  .brand strong { font-size: 22px; }
  .mark { width: 34px; height: 34px; }
  .nav, .rail .quiet, .privacy, .rail-label { display: none; }
  .who { flex-direction: row; flex: 1; justify-content: flex-end; gap: 6px; }
  .who input { max-width: 120px; }
  .who select { max-width: 140px; }
  .who small { display: none; }
  main { padding: 14px; }
  .approvals h1 { font-size: 30px; }
  .card-actions button { padding: 14px; }
  .path, .reads { grid-template-columns: 1fr; }
  .hero h1 { font-size: 40px; }
  .site-bar, .site, .site-foot { width: min(1080px, calc(100% - 28px)); }
  .drop-actions { flex-direction: column; align-items: flex-start; }
}

body.home { display: block; background: var(--paper); color: var(--ink); }
.site-bar, .site, .site-foot { width: min(1080px, calc(100% - 48px)); margin: 0 auto; }
.site-bar { display: flex; justify-content: space-between; align-items: center; padding: 22px 0; }
.site-bar .brand { color: inherit; text-decoration: none; margin: 0; }
.site-bar .brand strong { font-size: 28px; }
a.enter {
  background: var(--navy); color: white; text-decoration: none;
  border-radius: 999px; padding: 12px 16px; white-space: nowrap;
}
.hero { padding: 28px 0 12px; max-width: 44rem; }
.hero h1 { font-size: 64px; }
.path { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 36px 0; }
.path article, .reads div {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 18px; padding: 18px;
}
.path h2 {
  font-family: Palatino, "Iowan Old Style", serif; font-size: 26px; font-weight: 600;
  line-height: 1.1; margin: 0 0 8px; letter-spacing: -0.02em;
}
.path p, .reads p { margin: 0; line-height: 1.45; }
.reads { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 36px; }
.site-foot { padding: 8px 0 28px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.site-foot p { margin: 0; max-width: 40rem; }
