:root {
  --travertine: #f3eee5;
  --plaster: #faf7f1;
  --stone: #e6ddcf;
  --stone-deep: #d3c7b4;
  --hair: #d9cfbf;
  --charcoal: #2a2622;
  --ink: #3b3530;
  --muted: #776c60;
  --terracotta: #a2523a;
  --terracotta-soft: #f1e0d6;
  --olive: #5f6437;
  --olive-soft: #e6e6d3;
  --brass: #94743f;
  --brass-soft: #efe5d1;
  --ochre-soft: #f4e7c8;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--travertine);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
}
a { color: var(--terracotta); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--serif); color: var(--charcoal); font-weight: 500; margin: 0; }
h1 { font-size: 34px; line-height: 1.15; letter-spacing: -0.01em; }
h2 { font-size: 22px; line-height: 1.25; }
h3 { font-size: 18px; line-height: 1.3; }
p { margin: 0 0 12px; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow {
  font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--brass); font-weight: 600; margin-bottom: 6px;
}
.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  background: var(--charcoal); color: #d9d0c3;
  padding: 26px 0 20px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.brand { padding: 0 24px 22px; border-bottom: 1px solid #423b35; }
.brand-mark { font-family: var(--serif); font-size: 23px; color: #f3ece0; letter-spacing: 0.01em; }
.brand-sub { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: #a8987f; margin-top: 2px; }
.who { padding: 16px 24px; border-bottom: 1px solid #423b35; font-size: 13px; }
.who strong { display: block; color: #f3ece0; font-weight: 500; }
.who label { display: block; color: #a8987f; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; margin: 10px 0 4px; }
.who select {
  width: 100%; background: #36302b; border: 1px solid #4d453e; color: #efe6d8;
  padding: 7px 8px; border-radius: 3px;
}
.nav { padding: 14px 12px; flex: 1; }
.nav-group { font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: #8f8170; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 7px 12px; color: #d9d0c3;
  border-radius: 3px; font-size: 14px;
}
.nav a:hover { background: #36302b; text-decoration: none; }
.nav a.on { background: #3f3731; color: #fff; box-shadow: inset 2px 0 0 var(--brass); }
.nav .count { margin-left: auto; font-size: 11.5px; color: #c9a86f; font-variant-numeric: tabular-nums; }
.side-foot { padding: 14px 24px 0; font-size: 12px; color: #8f8170; border-top: 1px solid #423b35; }
.side-foot a { color: #c9b89c; }

.main { min-width: 0; }
.topbar {
  display: none; background: var(--charcoal); color: #efe6d8; padding: 12px 16px;
  align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20;
}
.topbar .brand-mark { font-size: 19px; }
.menu-btn { background: none; border: 1px solid #4d453e; color: #efe6d8; padding: 6px 10px; border-radius: 3px; display: flex; gap: 6px; align-items: center; }
.page { max-width: 1080px; padding: 40px 48px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; padding-bottom: 22px; border-bottom: 1px solid var(--hair); margin-bottom: 28px; flex-wrap: wrap; }
.page-head p { margin: 8px 0 0; color: var(--muted); max-width: 620px; }
.back { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 14px; color: var(--muted); }
.foot {
  max-width: 1080px; padding: 22px 48px 40px; border-top: 1px solid var(--hair);
  font-size: 12.5px; color: var(--muted); display: flex; gap: 18px; flex-wrap: wrap; justify-content: space-between;
}
.foot nav { display: flex; gap: 16px; flex-wrap: wrap; }
.foot button { background: none; border: 0; padding: 0; color: var(--terracotta); cursor: pointer; font-size: 12.5px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 15px; border-radius: 3px;
  border: 1px solid var(--charcoal); background: var(--charcoal); color: #f6f0e6; cursor: pointer;
  font-size: 14px; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: #413a34; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--charcoal); border-color: var(--stone-deep); }
.btn.ghost:hover { border-color: var(--charcoal); }
.btn.terra { background: var(--terracotta); border-color: var(--terracotta); }
.btn.terra:hover { background: #8d4530; }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Tags */
.tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 9px;
  border-radius: 2px; border: 1px solid var(--hair); background: var(--plaster); color: var(--ink); white-space: nowrap;
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.tag.open::before, .tag.pending::before { background: var(--brass); }
.tag.open, .tag.pending { background: var(--brass-soft); border-color: #e0d0ae; }
.tag.done::before { background: var(--olive); }
.tag.done { background: var(--olive-soft); border-color: #d2d3b5; }
.tag.alert::before { background: var(--terracotta); }
.tag.alert { background: var(--terracotta-soft); border-color: #e4c4b5; color: #7e3a26; }
.tag.plain::before { display: none; }

/* Stat line (not cards) */
.figures { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--charcoal); border-bottom: 1px solid var(--hair); margin-bottom: 36px; }
.figure { padding: 16px 18px 18px 0; }
.figure + .figure { padding-left: 18px; border-left: 1px solid var(--hair); }
.figure .label { font-size: 12.5px; color: var(--muted); }
.figure .value { font-family: var(--serif); font-size: 28px; color: var(--charcoal); font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 4px; }
.figure .value.neg { color: var(--terracotta); }
.figure .note { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Ledger tables */
table.ledger { width: 100%; border-collapse: collapse; font-size: 14px; }
.ledger th { text-align: left; font-weight: 500; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 8px 12px 8px 0; border-bottom: 1px solid var(--charcoal); }
.ledger td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--hair); vertical-align: top; }
.ledger td.r, .ledger th.r { text-align: right; padding-right: 0; font-variant-numeric: tabular-nums; }
.ledger tr.total td { border-top: 1px solid var(--charcoal); border-bottom: 0; font-weight: 600; }
.ledger tr.click { cursor: pointer; }
.ledger tr.click:hover td { background: var(--plaster); }
.table-wrap { overflow-x: auto; }

/* Sections */
.section { margin-bottom: 40px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 44px; }
.two.even { grid-template-columns: 1fr 1fr; }

/* List rows (tickets, approvals) */
.list { border-top: 1px solid var(--charcoal); }
.item {
  display: grid; grid-template-columns: 92px 1fr auto; gap: 16px; padding: 15px 0; border-bottom: 1px solid var(--hair);
  color: inherit; align-items: start;
}
.item:hover { text-decoration: none; background: linear-gradient(90deg, transparent, var(--plaster) 12%, var(--plaster) 88%, transparent); }
.item .ref { font-family: var(--mono); font-size: 12.5px; color: var(--muted); padding-top: 2px; }
.item .title { font-weight: 500; color: var(--charcoal); }
.item .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.item .side-r { text-align: right; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

/* Panels: plaster block with hairline, used sparingly */
.panel { background: var(--plaster); border: 1px solid var(--hair); padding: 22px 24px; }
.panel + .panel { margin-top: 18px; }
.panel.accent { border-left: 3px solid var(--terracotta); }
.panel.brass { border-left: 3px solid var(--brass); }
.panel h3 { margin-bottom: 8px; }
dl.facts { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--stone-deep); }
.timeline li { position: relative; padding: 0 0 18px 22px; }
.timeline li::before { content: ""; position: absolute; left: -4px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--travertine); border: 1px solid var(--brass); }
.timeline li.key::before { background: var(--terracotta); border-color: var(--terracotta); }
.timeline .when { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline .who-l { font-weight: 500; color: var(--charcoal); }

/* Quote comparison */
.quotes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); border-top: 1px solid var(--charcoal); }
.quote { padding: 18px 20px 20px 0; border-bottom: 1px solid var(--hair); }
.quote + .quote { padding-left: 20px; border-left: 1px solid var(--hair); }
.quote .price { font-family: var(--serif); font-size: 30px; color: var(--charcoal); font-variant-numeric: tabular-nums; }
.quote ul { margin: 10px 0 14px; padding-left: 18px; font-size: 14px; }
.bar { height: 6px; background: var(--stone); margin: 8px 0 4px; }
.bar > span { display: block; height: 100%; background: var(--olive); }
.bar.terra > span { background: var(--terracotta); }

/* Signatures */
.sigs { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--charcoal); }
.sigs li { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--hair); align-items: center; }
.sig-count { font-family: var(--serif); font-size: 42px; line-height: 1; color: var(--charcoal); }
.sig-count span { font-size: 20px; color: var(--muted); }
.script { font-family: var(--serif); font-style: italic; font-size: 19px; color: var(--charcoal); }

/* Documents */
.docs { border-top: 1px solid var(--charcoal); }
.doc { display: grid; grid-template-columns: 26px 1fr 110px 120px; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--hair); align-items: baseline; }
.doc .icon { color: var(--brass); transform: translateY(3px); }
.doc .older { grid-column: 2 / -1; font-size: 13px; color: var(--muted); }
.doc-group { font-family: var(--serif); font-size: 17px; margin: 28px 0 8px; color: var(--charcoal); }

/* Forms */
form.form { display: grid; gap: 16px; max-width: 620px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; color: var(--charcoal); }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--stone-deep); background: #fffdf9; border-radius: 2px;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--brass); outline-offset: -1px; border-color: var(--brass); }
.field textarea { min-height: 96px; resize: vertical; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 4px; accent-color: var(--olive); }
.warn { font-size: 13px; color: #7e3a26; background: var(--terracotta-soft); padding: 8px 12px; border-left: 3px solid var(--terracotta); }
.ok { font-size: 13px; color: #464a24; background: var(--olive-soft); padding: 8px 12px; border-left: 3px solid var(--olive); }

/* Guard post */
.post {
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center;
  padding: 26px 28px; background: var(--charcoal); color: #efe6d8;
}
.post h2 { color: #f6efe3; }
.post .muted { color: #b3a590; }
.post .btn { background: var(--brass); border-color: var(--brass); color: #1f1b17; font-size: 15px; padding: 11px 20px; }
.post .btn:hover { background: #a8864b; }
.post.late { box-shadow: inset 4px 0 0 var(--terracotta); }

/* Notice */
.notice { border-top: 1px solid var(--charcoal); padding: 18px 0 20px; border-bottom: 1px solid var(--hair); }
.notice + .notice { border-top: 0; }
.comments { margin-top: 14px; border-left: 2px solid var(--stone-deep); padding-left: 16px; }
.comment { margin-bottom: 12px; font-size: 14px; }
.comment .by { font-weight: 500; color: var(--charcoal); }

/* Welcome */
.welcome { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.welcome-art {
  background-color: #9b5a41;
  position: sticky; top: 0; height: 100vh; display: flex; align-items: center; justify-content: center; padding: 96px 48px; overflow: hidden;
}
/* Lime-plaster texture: fine grain plus soft cloudy variation */
.welcome-art::before, .welcome-art::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.welcome-art::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1000' height='1000'%3E%3Cfilter id='c'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.004' numOctaves='3' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .95 0 0 0 0 .8 0 0 0 0 .66 0 0 0 .5 -.12'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23c)'/%3E%3C/svg%3E");
  background-size: 1000px 1000px; opacity: .55;
}
.welcome-art::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .25 0 0 0 0 .14 0 0 0 0 .08 0 0 0 .6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .22;
}
.welcome-art svg.arch { position: relative; z-index: 1; width: min(400px, 74%); max-height: calc(100vh - 220px); height: auto; }
.welcome-art .cap {
  position: absolute; z-index: 1; left: 48px; bottom: 40px; right: 48px;
  font-family: var(--serif); font-size: 20px; color: #f4e8d4; border-top: 1px solid rgba(244,232,212,.45); padding-top: 12px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap;
}
.welcome-art .cap span { font-family: var(--sans); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: #ecd9bf; }
.mono-mark {
  position: absolute; z-index: 1; top: 36px; left: 48px; font-family: var(--serif); font-style: italic; font-size: 30px;
  color: #f4e8d4; letter-spacing: -0.12em; line-height: 1;
}
.mono-mark span { display: inline-block; transform: translateY(6px); }
.welcome-body { padding: 72px 64px; display: flex; flex-direction: column; justify-content: center; max-width: 620px; }
.welcome-body h1 { font-size: 44px; margin-bottom: 14px; }
.roles { border-top: 1px solid var(--charcoal); margin: 26px 0 18px; }
.role {
  display: grid; grid-template-columns: 1fr auto; width: 100%; text-align: left; gap: 12px; padding: 14px 0;
  border: 0; border-bottom: 1px solid var(--hair); background: none; cursor: pointer; align-items: center;
}
.role:hover { background: var(--plaster); }
.role strong { font-family: var(--serif); font-size: 19px; font-weight: 500; color: var(--charcoal); display: block; }
.role span.d { font-size: 13.5px; color: var(--muted); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--charcoal); color: #f3ece0;
  padding: 10px 18px; font-size: 14px; border-left: 3px solid var(--brass); z-index: 50; max-width: calc(100% - 32px);
}
.empty { padding: 22px 0; color: var(--muted); border-bottom: 1px solid var(--hair); }

@media (max-width: 960px) {
  .figures { grid-template-columns: 1fr 1fr; }
  .figure:nth-child(3) { padding-left: 0; border-left: 0; }
  .figure:nth-child(n+3) { border-top: 1px solid var(--hair); }
  .two, .two.even { grid-template-columns: 1fr; gap: 32px; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .topbar { display: flex; }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(30,26,22,.4); z-index: 25; }
  .page { padding: 26px 16px 48px; }
  .foot { padding: 20px 16px 36px; }
  h1 { font-size: 28px; }
  .item { grid-template-columns: 1fr; gap: 6px; }
  .item .side-r { flex-direction: row; align-items: center; justify-content: flex-start; text-align: left; }
  .doc { grid-template-columns: 22px 1fr; }
  .doc > :nth-child(3), .doc > :nth-child(4) { grid-column: 2; }
  .fields-2 { grid-template-columns: 1fr; }
  dl.facts { grid-template-columns: 1fr; gap: 2px; }
  dl.facts dd { margin-bottom: 8px; }
  .post { grid-template-columns: 1fr; padding: 22px 18px; }
  .quote + .quote { padding-left: 0; border-left: 0; }
  .welcome { grid-template-columns: 1fr; }
  .welcome-art { position: relative; height: auto; min-height: 0; padding: 72px 16px 84px; }
  .welcome-art svg.arch { max-height: none; }
  .welcome-art svg.arch { width: 170px; }
  .welcome-art .cap { left: 16px; right: 16px; bottom: 20px; font-size: 17px; }
  .mono-mark { left: 16px; top: 20px; font-size: 24px; }
  .welcome-body { padding: 36px 16px 48px; }
  .welcome-body h1 { font-size: 34px; }
}
@media (max-width: 480px) {
  .figures { grid-template-columns: 1fr; }
  .figure, .figure + .figure { padding-left: 0; border-left: 0; }
  .figure + .figure { border-top: 1px solid var(--hair); }
}

.two > *, .fields-2 > *, .item > * { min-width: 0; }
.field input, .field select { min-width: 0; }
@media (max-width: 1180px) {
  .two, .two.even { grid-template-columns: 1fr; gap: 32px; }
}

/* Permission matrix */
.perm th.c, .perm td.c { text-align: center; padding-left: 8px; padding-right: 8px; }
.perm td.c input { width: 16px; height: 16px; accent-color: var(--olive); cursor: pointer; }
.perm td.c input:disabled { cursor: not-allowed; }
.perm td.grp { font-family: var(--serif); font-size: 16px; color: var(--charcoal); padding-top: 20px; border-bottom: 1px solid var(--stone-deep); }
.perm tbody tr:hover td:not(.grp) { background: var(--plaster); }
