:root {
  color-scheme: light;
  --ink: #1d2733;
  --muted: #5f6b78;
  --paper: #f4f5f7;
  --card: #ffffff;
  --line: #dfe3e8;
  --navy: #1e3a5f;
  --blue: #4a97c9;
  --approve: #1f7a3a;
  --approve-soft: #e7f4ea;
  --warn-soft: #fdf3dc;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
}
a { color: var(--navy); }
img { max-width: 100%; height: auto; }
h1, h2 { line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 0 0 0.75rem; }

/* Top bar with the wordmark */
.bar { background: #fff; border-bottom: 1px solid var(--line); }
.bar-inner { max-width: 60rem; margin: 0 auto; padding: 0.75rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.bar-home { display: flex; align-items: center; gap: 1rem; text-decoration: none; color: inherit; }
.bar-logo { width: 152px; height: auto; display: block; }
.bar-name { font-weight: 650; color: var(--navy); }
.bar-company { display: flex; flex-direction: column; }
.bar-license { font-size: 0.82rem; font-weight: 600; color: var(--ink); }
.staff-nav { display: flex; gap: 0.25rem 1rem; flex-wrap: wrap; margin-left: auto; font-size: 0.95rem; }
.staff-nav a { text-decoration: none; padding: 0.25rem 0; }
.staff-nav a:hover { text-decoration: underline; }

/* Customer documents */
.doc { max-width: 52rem; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
.doc-card, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 1.25rem;
  margin: 0 0 1rem;
}
.doc-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(14rem, 18rem); gap: 1.5rem; margin-bottom: 1.25rem; }
.doc-kicker { margin: 0; color: var(--muted); font-size: 0.9rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.doc-title { font-size: 1.6rem; font-weight: 750; color: var(--navy); margin: 0.35rem 0 0.75rem; }
.doc-label { margin: 0; font-size: 0.8rem; color: var(--muted); }
.doc-address { margin: 0.15rem 0 0; }
.doc-facts { margin: 0; border-left: 1px solid var(--line); padding-left: 1.25rem; }
.doc-facts div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.45rem 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.doc-facts dt { color: var(--muted); }
.doc-facts dd { margin: 0; text-align: right; }
.pill { display: inline-block; border-radius: 999px; padding: 0.05rem 0.6rem; font-size: 0.78rem; font-weight: 600; background: #eef1f4; color: var(--ink); white-space: nowrap; }
.pill-awaiting-response, .pill-sent, .pill-viewed { background: var(--warn-soft); color: #7a5600; }
.pill-approved, .pill-paid, .pill-completed { background: var(--approve-soft); color: var(--approve); }
.pill-declined, .pill-expired { background: #fbe9e9; color: #9b1c1c; }
.pill-optional { background: #e8f1f8; color: #245b85; font-size: 0.72rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; vertical-align: top; }
.num { text-align: right; white-space: nowrap; }
.lines th { font-size: 0.85rem; font-weight: 700; padding: 0.6rem 0.5rem; border-bottom: 2px solid var(--line); }
.lines td { padding: 0.9rem 0.5rem; border-bottom: 1px solid var(--line); }
.lines th:first-child, .lines td:first-child { padding-left: 0; }
.lines th:last-child, .lines td:last-child { padding-right: 0; }
.item-name { margin: 0; font-weight: 700; }
.item-desc { white-space: pre-line; margin-top: 0.4rem; font-size: 0.9rem; color: #33404d; max-width: 34rem; }
.optional-pick { margin: 0.75rem 0 0; font-weight: 600; }
tr.is-excluded .amount { color: var(--muted); text-decoration: line-through; }
.doc-totals { margin: 1rem 0 0 auto; max-width: 20rem; }
.doc-totals div { display: flex; justify-content: space-between; padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.doc-totals .grand { font-size: 1.2rem; font-weight: 750; border-bottom: 0; }
.prose { white-space: pre-line; margin: 0; font-size: 0.95rem; }
.reviews { display: grid; gap: 1rem; }
.review { margin: 0; padding: 0 0 1rem; border-bottom: 1px solid var(--line); }
.review:last-child { border-bottom: 0; padding-bottom: 0; }
.review blockquote { margin: 0.25rem 0 0.4rem; white-space: pre-line; }
.review figcaption { font-weight: 650; font-size: 0.92rem; }
.iema-card summary { cursor: pointer; font-size: 0.92rem; }
.iema-card[open] summary { margin-bottom: 0.5rem; }
.table-scroll { overflow-x: auto; }
.has-problem td { background: #fdf3dc; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.sheet-photo { display: block; width: 100%; border-radius: 0.4rem; margin: 0 0 0.75rem; }
.stars { margin: 0; color: #e7a400; letter-spacing: 0.1em; }
.stars .pill { letter-spacing: normal; }
.done { border-color: #b9dfc3; background: #f6fbf7; }
.preview-note { background: var(--warn-soft); border-radius: 0.5rem; padding: 0.6rem 0.9rem; }
.doc-footer { max-width: 52rem; margin: 0 auto; padding: 0 1rem 2rem; color: var(--muted); font-size: 0.85rem; text-align: center; }
.doc-footer a { color: var(--muted); }

/* Approval */
.approve label { display: block; margin: 0.9rem 0 0.35rem; font-weight: 600; }
.approve .check { font-weight: 400; }
canvas.signature { width: 100%; height: 180px; background: #fff; border: 1px solid #b8c0c9; border-radius: 0.5rem; touch-action: none; display: block; }
.approve-button {
  width: 100%;
  min-height: 3.25rem;
  margin-top: 1rem;
  background: var(--approve);
  color: #fff;
  font-size: 1.125rem;
  font-weight: 650;
  border: 0;
  border-radius: 0.5rem;
}
.pay-choices { border: 1px solid var(--line); border-radius: 0.5rem; padding: 0.5rem 0.9rem 0.75rem; margin: 1rem 0 0; }
.pay-choices legend { font-weight: 650; padding: 0 0.3rem; }
.approve .pay-choice { margin: 0.6rem 0 0; font-weight: 400; }
.decline { text-align: center; margin: 0 0 1.5rem; }
.link-button { background: none; border: 0; color: var(--muted); text-decoration: underline; font: inherit; min-height: 2.75rem; cursor: pointer; }

/* Staff pages */
.staff { max-width: 60rem; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
.staff > h1 { font-size: 1.5rem; color: var(--navy); margin: 0.25rem 0 1rem; }
.meta { color: var(--muted); margin: 0.25rem 0; font-size: 0.9rem; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 1rem; }
.list th { font-size: 0.8rem; color: var(--muted); font-weight: 650; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--line); }
.list td { padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--line); }
.list th:first-child, .list td:first-child { padding-left: 0; }
.list th:last-child, .list td:last-child { padding-right: 0; }
.totals { margin: 0.75rem 0 0; }
.totals div { display: flex; justify-content: space-between; padding: 0.2rem 0; }
.totals .grand { font-size: 1.2rem; font-weight: 700; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.nav { margin: 0 0 1rem; }
label { display: block; margin: 0.75rem 0; }
.check { display: flex; gap: 0.6rem; align-items: flex-start; }
input[type="text"], input[type="email"], input[type="number"], input[type="date"], input[type="file"], input:not([type]), select, textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.7rem;
  font: inherit;
  border: 1px solid #b8c0c9;
  border-radius: 0.45rem;
  background: #fff;
  color: var(--ink);
}
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; margin-top: 0.2rem; flex: none; }
textarea { min-height: 5rem; }
.qty-input { max-width: 6rem; }
button, .button, .approve-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  background: var(--navy);
  color: #fff;
  border: 0;
  border-radius: 0.45rem;
  padding: 0.55rem 1rem;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
button.approve, .approve-link { background: var(--approve); }
button.secondary, .button.secondary { background: #fff; color: var(--ink); border: 1px solid #b8c0c9; }
.inline-form { display: inline; }
.builder-desc { white-space: pre-line; color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; }
.builder td { padding: 0.6rem 0.4rem; border-bottom: 1px solid var(--line); }
.builder th { font-size: 0.8rem; color: var(--muted); padding: 0.4rem; border-bottom: 1px solid var(--line); }
.fee-note { background: var(--warn-soft); border-radius: 0.45rem; padding: 0.5rem 0.75rem; }
.review-admin { display: grid; gap: 0.75rem; }
.review-admin .review { padding: 0.75rem; border: 1px solid var(--line); border-radius: 0.5rem; }
.review-admin .on-quote { border-color: #b9dfc3; background: #f6fbf7; }
.review-admin .is-hidden { opacity: 0.6; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }

@media (max-width: 640px) {
  .bar-logo { width: 120px; }
  .bar-name { font-size: 0.95rem; }
  .doc { padding: 0.75rem 0.75rem 1.5rem; }
  .doc-card, .card { padding: 1rem; }
  .doc-head { grid-template-columns: 1fr; gap: 0.75rem; }
  .doc-facts { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); }
  .doc-title { font-size: 1.35rem; }
  .lines thead { display: none; }
  .lines, .lines tbody, .lines tr { display: block; width: 100%; }
  .lines tr { border-bottom: 1px solid var(--line); padding: 0.9rem 0; }
  .lines td { display: block; border: 0; padding: 0; }
  .lines td.num { display: flex; justify-content: space-between; padding: 0.15rem 0; font-size: 0.95rem; }
  .lines td.num::before { content: attr(data-label); color: var(--muted); }
  .lines td.amount { font-weight: 700; }
  .lines td.item { padding-bottom: 0.5rem; }
  .doc-totals { max-width: none; }
  .staff-nav { margin-left: 0; width: 100%; }
  .grid-2 { grid-template-columns: 1fr; }
  .list td, .list th { font-size: 0.92rem; }
}