/* The Owner's File
   Palette from the build itself: Colorbond-style greys on a concrete ground,
   and one accent, the fluoro pink of survey marking paint. Pink means one
   thing everywhere: "look here" (a page reference, or something to check). */

@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo-latin.woff") format("woff");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  --ground: #eceeeb;     /* concrete */
  --paper: #ffffff;
  --ink: #2f3133;        /* Monument-like charcoal */
  --muted: #646668;      /* Basalt */
  --rule: #c4c7c2;       /* Shale */
  --mark: #d6006f;       /* survey marking paint, darkened for text contrast */
  --mark-wash: #fde6f1;
  --ok: #2f6b4e;
  --radius: 4px;
  --measure: 72ch;
  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 420 1rem/1.55 var(--font);
  font-stretch: 100%;
}

/* Type scale: condensed and heavier for headings, like a drawing's title block. */
h1, h2, h3 {
  font-stretch: 72%;
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.005em;
  margin: 0;
}
h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3.25rem); }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.2rem; }
p { margin: 0; max-width: var(--measure); }
.num, td.num { font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.quiet { color: var(--muted); }

a { color: inherit; text-underline-offset: 0.18em; }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 2px; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 0.5rem; background: var(--paper); padding: 0.5rem 0.75rem; z-index: 10; }

/* ---- bar ---------------------------------------------------------------- */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem clamp(1rem, 4vw, 2.5rem);
  background: var(--ink); color: var(--ground);
}
.brand { font-stretch: 72%; font-weight: 700; font-size: 1.15rem; text-decoration: none; }
#account { display: flex; align-items: center; gap: 1rem; font-size: 0.9rem; }
#account .who { color: #b9bcb8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }

main { padding: clamp(1.25rem, 4vw, 3rem) clamp(1rem, 4vw, 2.5rem) 4rem; max-width: 76rem; margin: 0 auto; outline: none; }

/* ---- controls ----------------------------------------------------------- */
button, .button {
  font: inherit; font-weight: 560; font-size: 0.95rem;
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 1rem; min-height: 2.5rem;
  border: 1.5px solid var(--ink); border-radius: var(--radius);
  background: var(--ink); color: var(--paper);
  cursor: pointer; text-decoration: none;
}
button.secondary, .button.secondary { background: transparent; color: var(--ink); }
button.plain { background: transparent; color: var(--ink); border-color: transparent; padding-inline: 0.5rem; text-decoration: underline; }
button:disabled { opacity: 0.5; cursor: progress; }
.bar button.plain { color: var(--ground); }

input, select {
  font: inherit; color: var(--ink);
  padding: 0.5rem 0.65rem; min-height: 2.5rem;
  border: 1.5px solid var(--rule); border-radius: var(--radius); background: var(--paper);
}
input:focus-visible, select:focus-visible { outline-offset: 0; }
label { display: grid; gap: 0.3rem; font-weight: 560; font-size: 0.95rem; }
.field-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; }

/* ---- the page tag: every extracted figure points to its source page ------ */
.src {
  display: inline-flex; align-items: center;
  font: inherit; font-size: 0.78rem; font-weight: 640; line-height: 1;
  padding: 0.3rem 0.5rem; margin-left: 0.45rem; min-height: 0;
  color: var(--mark); background: var(--paper);
  border: 1.5px solid var(--mark); border-left-width: 5px; border-radius: 2px;
  text-decoration: none; cursor: pointer; vertical-align: 0.12em;
  font-variant-numeric: tabular-nums;
}
.src:hover, .src:focus-visible { background: var(--mark); color: var(--paper); }
button.src { min-height: 0; }

/* ---- home (signed out) ---------------------------------------------------- */
.home { display: grid; gap: 2.5rem; padding-block: clamp(1rem, 6vw, 4rem); }
.home .intro { display: grid; gap: 1.75rem; }
@media (min-width: 64rem) {
  .home { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); column-gap: 4rem; }
  .home .specimen { align-self: end; margin-bottom: 0.5rem; }
  .home .points { grid-column: 1 / -1; }
}
.home h1 { font-size: clamp(2.4rem, 1.2rem + 5vw, 5rem); font-stretch: 66%; max-width: 15ch; }
.home .lede { font-size: 1.15rem; max-width: 52ch; }
.home .actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.specimen {
  background: var(--paper); border-left: 4px solid var(--ink);
  padding: 1.25rem 1.5rem; max-width: 34rem; display: grid; gap: 0.6rem;
}
.specimen .line { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.specimen .line span:first-child { color: var(--muted); }
.home .points { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); max-width: 60rem; }
.home .points h3 { margin-bottom: 0.3rem; }

/* ---- projects ------------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.75rem; }
.list { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--ink); }
.list li { border-bottom: 1px solid var(--rule); }
.list a.row { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem 0.25rem; text-decoration: none; }
.list a.row:hover strong { text-decoration: underline; }
.panel { background: var(--paper); padding: 1.25rem; border-radius: var(--radius); margin-top: 2rem; display: grid; gap: 1rem; max-width: 40rem; }

/* ---- project tabs ---------------------------------------------------------- */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1.5px solid var(--ink); margin: 1.25rem 0 1.75rem; overflow-x: auto; }
.tabs a {
  padding: 0.6rem 1rem; text-decoration: none; font-weight: 560; white-space: nowrap;
  border: 1.5px solid transparent; border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0;
}
.tabs a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.count { display: inline-block; min-width: 1.4rem; margin-left: 0.35rem; padding: 0 0.35rem; border-radius: 1rem; background: var(--mark); color: var(--paper); font-size: 0.78rem; text-align: center; }

/* ---- documents -------------------------------------------------------------- */
.drop {
  display: grid; place-items: center; gap: 0.5rem; text-align: center;
  padding: 2rem 1rem; border: 2px dashed var(--rule); border-radius: var(--radius); background: var(--paper);
}
.drop.over { border-color: var(--mark); background: var(--mark-wash); }
.status { font-size: 0.85rem; font-weight: 600; }
.status.review { color: var(--mark); }
.status.done { color: var(--ok); }
.status.failed { color: var(--mark); }

/* ---- tables (review, payments) -------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--paper); }
th, td { text-align: left; padding: 0.7rem 0.75rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: 0.85rem; font-weight: 600; color: var(--muted); border-bottom: 1.5px solid var(--ink); }
td.num, th.num { text-align: right; }
td.seq { color: var(--muted); width: 2.5rem; }
tr.flagged td { background: var(--mark-wash); }
.flag { display: block; color: var(--mark); font-size: 0.85rem; font-weight: 560; margin-top: 0.3rem; }
.row-actions { display: flex; gap: 0.25rem; justify-content: flex-end; flex-wrap: wrap; }
.row-actions button { min-height: 2.1rem; padding: 0.3rem 0.7rem; font-size: 0.88rem; }
td input { width: 100%; min-width: 6rem; }
td.num input { text-align: right; }

.contract-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: baseline; margin: 2rem 0 0.75rem; }
.contract-head:first-child { margin-top: 0; }
.sum { font-size: 1.35rem; font-weight: 650; }

/* ---- payments ---------------------------------------------------------------- */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0; border-top: 1.5px solid var(--ink); margin-bottom: 2.5rem; }
.figure { padding: 1rem 1.25rem 1rem 0; }
.figure + .figure { padding-left: 1.25rem; border-left: 1px solid var(--rule); }
.figure dt { color: var(--muted); font-size: 0.9rem; }
.figure dd { margin: 0.2rem 0 0; font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.3rem); font-stretch: 80%; font-weight: 650; font-variant-numeric: tabular-nums; }
.figure.balance dd { font-stretch: 72%; }
.reached { color: var(--ok); font-weight: 600; }

.empty { background: var(--paper); padding: 2rem 1.5rem; border-radius: var(--radius); display: grid; gap: 0.75rem; justify-items: start; }

/* ---- small layout helpers (no inline styles: the CSP forbids them) -------- */
.grow { flex: 1 1 18rem; }
.doc-row { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem 0.25rem; flex-wrap: wrap; }
.doc-status { display: flex; align-items: center; gap: 0.5rem; }
.list.spaced { margin-top: 2rem; }
.intro-note { margin-bottom: 1.5rem; }
caption { text-align: left; padding: 0.5rem 0; }
.breakdown { margin: -1.5rem 0 2rem; }
.table-title { margin-bottom: 0.75rem; }
.row-actions.start { justify-content: flex-start; }

/* ---- toast ------------------------------------------------------------------ */
#toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 0.7rem 1rem; border-radius: var(--radius);
  max-width: min(36rem, calc(100vw - 2rem)); opacity: 0; pointer-events: none; transition: opacity 160ms;
}
#toast.show { opacity: 1; }
#toast.error { background: var(--mark); }

@media (max-width: 40rem) {
  .figure + .figure { border-left: 0; padding-left: 0; border-top: 1px solid var(--rule); }
  .row-actions { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Stage tables stack on narrow screens: name across the top, share and
   amount beneath, actions last, so nothing scrolls sideways. */
@media (max-width: 40rem) {
  table.stack thead { position: absolute; left: -9999px; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; }
  table.stack tr {
    display: grid; grid-template-columns: 1.75rem 1fr auto; gap: 0.35rem 0.75rem;
    padding: 0.9rem 0.75rem; border-bottom: 1px solid var(--rule);
  }
  table.stack td { border: 0; padding: 0; }
  table.stack td.seq { grid-row: span 3; text-align: left; }
  table.stack td:nth-child(2) { grid-column: 2 / 4; }
  table.stack td:nth-child(3) { grid-column: 2; text-align: left; }
  table.stack td:nth-child(4) { grid-column: 3; }
  table.stack td:nth-child(5) { grid-column: 2 / 4; margin-top: 0.35rem; }
  table.stack caption { display: block; padding-inline: 0.75rem; }
}
