:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --ink: #1b2526;
  --muted: #5d6b6c;
  --line: #dde3e2;
  --brand: #0f3d3e;
  --brand-ink: #ffffff;
  --accent: #e8a33d;
  --green: #1d7a45;
  --green-bg: #e7f4ec;
  --amber: #8a5a00;
  --amber-bg: #fdf1dc;
  --red: #b3261e;
  --red-bg: #fbe9e7;
  --gray-bg: #eceff0;
  --radius: 12px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  /* Opt out of browser auto-dark modes: the signature pad and PDFs assume dark ink on white. */
  color-scheme: only light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0.2em 0 0.6em; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
h2 { font-size: 1.1rem; margin: 0 0 0.5em; }
img { max-width: 100%; }

.top { background: var(--brand); color: var(--brand-ink); display: flex; align-items: center; justify-content: space-between; padding: 0.7rem 16px; gap: 1rem; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.brand { color: inherit; text-decoration: none; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; font-size: 1.05rem; }
.top nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.top nav a, .top .linkish { color: #d8ecea; text-decoration: none; font-size: 0.95rem; }
.top nav a:hover, .top .linkish:hover { color: #fff; }
.top nav form { margin: 0; }

.wrap { max-width: 760px; margin: 0 auto; padding: 18px 16px 40px; }
.foot { max-width: 760px; margin: 0 auto; padding: 0 16px 32px; color: var(--muted); font-size: 0.8rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card.slim { padding: 10px 14px; }
.card.narrow { max-width: 440px; margin: 24px auto; }
details.card > summary { cursor: pointer; }
details.card[open] > summary { margin-bottom: 12px; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row form { margin: 0; }
.spread { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 0.92rem; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.82rem; }
input, select, textarea { font: inherit; font-weight: 400; padding: 11px 12px; border: 1px solid #c3cccb; border-radius: 9px; background: #fff; color: var(--ink); width: 100%; min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--brand); }
input[disabled] { background: var(--gray-bg); color: var(--muted); }
textarea { resize: vertical; }
fieldset { border: 0; padding: 0; margin: 0; }
fieldset[hidden] { display: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; padding: 10px 16px; min-height: 44px; border-radius: 10px; border: 1px solid #b9c4c3; background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: #155455; }
.btn.big { padding: 14px 20px; font-size: 1.05rem; width: 100%; }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: 0.9rem; }
.btn.danger-outline { color: var(--red); border-color: #e3b7b3; }
.btn[disabled] { opacity: 0.6; cursor: wait; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-decoration: underline; }
.icon-btn { border: 0; background: rgba(0, 0, 0, 0.6); color: #fff; width: 28px; height: 28px; border-radius: 50%; font-size: 18px; line-height: 1; cursor: pointer; }

.flash { background: var(--green-bg); color: var(--green); border: 1px solid #bfe2cc; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }
.errors { background: var(--red-bg); color: var(--red); border: 1px solid #f0c4bf; padding: 8px 14px; border-radius: 10px; }
.errors ul { margin: 0; padding-left: 18px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, Consolas, monospace; word-break: break-all; }
.empty { color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; }
.crumbs { margin: 0 0 4px; font-size: 0.88rem; color: var(--muted); }
.crumbs a { color: var(--muted); }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.page-head h1 { margin: 0; }
.page-head .btn.big { width: auto; }
@media (max-width: 520px) { .page-head .btn.big { width: 100%; } }

.badge { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; letter-spacing: 0.02em; vertical-align: middle; }
.badge.gray { background: var(--gray-bg); color: var(--muted); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.stats.two { grid-template-columns: repeat(2, 1fr); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; }
.stat span { font-size: 0.8rem; color: var(--muted); }
.stat strong { font-size: 1.3rem; }
.stat em { font-style: normal; font-size: 0.78rem; color: var(--muted); }
@media (max-width: 520px) { .stats { grid-template-columns: 1fr 1fr; } .stats .stat:first-child { grid-column: span 2; } }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.tabs a { padding: 7px 13px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: 0.9rem; white-space: nowrap; }
.tabs a.on { background: var(--brand); color: #fff; border-color: var(--brand); }

.co-list, .list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.co-card, .list-row { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: inherit; }
.co-card:hover, .list-row:hover { border-color: var(--brand); }
.co-card-top { display: flex; justify-content: space-between; align-items: center; }
.num { font-family: ui-monospace, Consolas, monospace; font-size: 0.82rem; color: var(--muted); }
.co-title { font-weight: 600; margin: 4px 0; }
.co-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 0.88rem; }
.co-meta strong { color: var(--ink); }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.right { text-align: right; display: flex; flex-direction: column; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.section-head h2 { margin: 0; }
.dictate-wrap { position: relative; }
.dictate-wrap .dictate { position: absolute; right: 8px; bottom: 8px; }
.dictate.listening { background: var(--red); color: #fff; border-color: var(--red); }
.file-drop { border: 2px dashed #b9c4c3; border-radius: var(--radius); padding: 18px; text-align: center; cursor: pointer; color: var(--brand); }
.file-drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-drop:focus-within { outline: 2px solid var(--accent); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.photo-grid:empty { display: none; }
.photo-grid figure { margin: 0; position: relative; }
.photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; display: block; background: var(--gray-bg); }
.photo-grid figure .icon-btn { position: absolute; top: 6px; right: 6px; }

.item-head, .item-row { display: grid; grid-template-columns: 110px 1fr 70px 120px 32px; gap: 8px; align-items: center; }
.item-head { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
#items { display: flex; flex-direction: column; gap: 8px; }
.item-row .icon-btn { background: var(--gray-bg); color: var(--muted); }
.price-wrap { position: relative; }
.price-wrap span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.price-wrap input { padding-left: 22px; }
@media (max-width: 600px) {
  .item-head { display: none; }
  .item-row { grid-template-columns: 1.25fr 60px 1fr 32px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .item-row select { padding-left: 8px; padding-right: 4px; }
  .item-row .item-desc { grid-column: 1 / -1; grid-row: 1; }
}
.total-line { display: flex; justify-content: space-between; align-items: baseline; border-top: 2px solid var(--ink); padding-top: 10px; font-weight: 600; }
.total-line strong { font-size: 1.5rem; }

table.items { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
table.items th { text-align: left; font-size: 0.78rem; color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 4px; }
table.items td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.items .num { text-align: right; white-space: nowrap; font-family: inherit; font-size: inherit; color: inherit; }
table.items tfoot td { font-weight: 700; font-size: 1.1rem; border-bottom: 0; border-top: 2px solid var(--ink); }
.kind { display: inline-block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: var(--muted); background: var(--gray-bg); padding: 1px 6px; border-radius: 4px; margin-right: 4px; }
.co-heading { font-size: 1.25rem; margin: 0; }

.share .copy-row { display: flex; gap: 8px; }
.share-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.share-buttons .btn:last-child { grid-column: 1 / -1; }
.approved-box { border-color: #bfe2cc; background: var(--green-bg); }
.declined-box { border-color: #f0c4bf; background: var(--red-bg); }
.signature { background: #fff; border: 1px solid var(--line); border-radius: 8px; max-width: 300px; }
blockquote { margin: 0; padding: 8px 12px; border-left: 3px solid var(--red); background: #fff; border-radius: 6px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }
.timeline { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }

.from { margin-bottom: 12px; }
.from .biz { font-size: 1.3rem; font-weight: 700; }
.biz-logo { display: block; max-width: 200px; max-height: 72px; object-fit: contain; margin: 4px 0 10px; }
.powered { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0 0 6px; font-weight: 600; }
.powered[hidden] { display: none; }
.sign-card { border: 2px solid var(--brand); }
.sig-head { display: flex; justify-content: space-between; font-weight: 600; font-size: 0.92rem; margin-bottom: 4px; }
.sig-pad { width: 100%; height: 130px; border: 1px solid #b9c4c3; border-radius: 9px; background: #fff; touch-action: none; display: block; }
.sig-hint { margin: 4px 0 0; font-size: 0.82rem; color: var(--muted); }
/* Approve stays in the page flow (not sticky) so it never covers the signature box or checkbox. */
#approve-btn { box-shadow: 0 6px 18px rgba(15, 61, 62, 0.28); }
.invalid { outline: 2px solid var(--red); outline-offset: 4px; border-radius: 10px; }
.check { padding: 6px 2px; scroll-margin: 120px; }
.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; }
.check input { width: 22px; height: 22px; min-height: 0; flex: none; margin-top: 2px; }

.hero { padding: 24px 0 8px; }
.hero h1 { font-size: 2rem; line-height: 1.15; }
.lead { font-size: 1.1rem; color: var(--muted); }
.steps { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 16px 36px; display: flex; flex-direction: column; gap: 8px; }
