/* Cambio Tool design: Cambio blue and magenta (from the cambiotool.com theme),
   spaced-capital headings, thin rules. Light and dark for the web; PDFs use print.css (light only). */
:root {
  --brand: #465496;           /* Cambio blue */
  --brand-dark: #36427a;
  --brand-tint: #eef0f8;
  --accent: #B1377F;          /* Cambio magenta */
  --accent-dark: #8f2b66;
  --accent-ink: #B1377F;      /* magenta text: 5.2:1 on white */
  --ink: #100E17;
  --bg: #ffffff;
  --surface: #ffffff;
  --row-alt: #f4f5fa;
  --text: #100E17;
  --muted: #5d5d6b;
  --rule: #e3e3ea;
  --header-bg: #ffffff;
  --header-text: #100E17;
  --table-head-bg: #465496;
  --table-head-text: #ffffff;
  --link: #465496;
  --heading: #36427a;
  --danger: #b3261e;
  --ok: #2f7d4f;
  --font-head: Arial, "Helvetica Neue", Helvetica, sans-serif;
  --font-body: Calibri, Carlito, "Segoe UI", system-ui, -apple-system, sans-serif;
  --measure: 46rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #100E17; --surface: #18161f; --row-alt: #1d1b26; --text: #ecebf2; --muted: #a9a8b6; --rule: #2f2d3a;
    --header-bg: #18161f; --header-text: #ecebf2; --table-head-bg: #36427a; --brand-tint: #232842;
    --accent-ink: #e07ab4; --link: #9aa6dc; --heading: #ecebf2;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #100E17; --surface: #18161f; --row-alt: #1d1b26; --text: #ecebf2; --muted: #a9a8b6; --rule: #2f2d3a;
  --header-bg: #18161f; --header-text: #ecebf2; --table-head-bg: #36427a; --brand-tint: #232842;
  --accent-ink: #e07ab4; --link: #9aa6dc; --heading: #ecebf2;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 1.0625rem; line-height: 1.6;
}
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--accent-ink); }

.wrap { max-width: 72rem; margin: 0 auto; padding: 0 16px; }
.prose { max-width: var(--measure); }

/* Header / footer */
.site-header { background: var(--header-bg); color: var(--header-text); border-bottom: 3px solid var(--brand); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.75rem; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--link); text-decoration: none; font-family: var(--font-head); font-weight: 700; letter-spacing: .18em; text-transform: uppercase; font-size: .95rem; }
.brand img { width: 28px; height: 28px; }
.brand span { color: var(--accent-ink); }
.site-nav { display: flex; gap: 1.25rem; flex-wrap: wrap; font-family: var(--font-head); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--link); }
.site-footer { margin-top: 4rem; border-top: 1px solid var(--rule); color: var(--muted); font-size: .9rem; }
.site-footer .wrap { padding-top: 1.5rem; padding-bottom: 2.5rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

main { padding: 2.5rem 0; }

/* Headings: Arial, spaced capitals, thin rules */
h1, h2, h3, .eyebrow {
  font-family: var(--font-head); text-transform: uppercase; letter-spacing: .14em; font-weight: 700; line-height: 1.3;
}
h1 { color: var(--heading); font-size: clamp(1.35rem, 3.2vw, 1.85rem); margin: 0 0 .5rem; letter-spacing: .12em; }
h2 { font-size: 1rem; margin: 2.5rem 0 1rem; padding-bottom: .5rem; border-bottom: 1px solid var(--rule); }
h3 { font-size: .85rem; margin: 1.75rem 0 .75rem; }
.eyebrow { font-size: .72rem; color: var(--accent-ink); margin: 0 0 .5rem; }
.lede { color: var(--muted); margin: 0 0 2rem; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

/* Numbered clauses: magenta numbers */
.clause-num { color: var(--accent-ink); font-weight: 700; font-family: var(--font-head); margin-right: .35em; }

/* Tables: blue header, alternating light rows, magenta closing rule */
.table-wrap { overflow-x: auto; margin: 1.25rem 0 1.75rem; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .97rem; border-bottom: 2px solid var(--accent); }
th, td { text-align: left; vertical-align: top; padding: .6rem .75rem; }
thead th { background: var(--table-head-bg); color: var(--table-head-text); font-family: var(--font-head); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; }
tbody tr:nth-child(even) { background: var(--row-alt); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Buttons and forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: var(--font-head); font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  padding: .8rem 1.25rem; border-radius: 2px; border: 1px solid var(--ink); cursor: pointer; text-decoration: none;
  background: var(--brand); border-color: var(--brand); color: #fff; min-height: 44px;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--rule); }
.btn-ghost:hover { border-color: var(--brand); color: var(--text); background: var(--brand-tint); }
.inline-form { display: inline; margin: 0; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; letter-spacing: inherit; text-transform: inherit; }
.link-button:hover { color: var(--accent); }

.card { background: var(--surface); border: 1px solid var(--rule); border-top: 3px solid var(--accent); padding: 1.75rem; max-width: 28rem; }
.alert { border-left: 3px solid var(--danger); background: var(--row-alt); padding: .85rem 1rem; margin: 0 0 1.25rem; }
.muted { color: var(--muted); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 600px) {
  body { font-size: 1rem; }
  main { padding: 1.75rem 0; }
  .card { padding: 1.25rem; }
}

/* ── Web fonts (fallbacks when Arial/Calibri are not installed) ── */
@font-face { font-family: "Carlito"; src: url("/static/fonts/Carlito-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Carlito"; src: url("/static/fonts/Carlito-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Carlito"; src: url("/static/fonts/Carlito-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Arimo"; src: url("/static/fonts/Arimo-Variable.ttf") format("truetype"); font-weight: 400 700; font-display: swap; }
:root { --font-head: Arial, Arimo, "Helvetica Neue", Helvetica, sans-serif; }

.prose.wide { max-width: 60rem; }
.nowrap { white-space: nowrap; }
.notice { border-left: 3px solid var(--accent); background: var(--row-alt); padding: .75rem 1rem; margin: 1rem 0; }
.hash { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .75rem; color: var(--muted); word-break: break-all; margin-top: 3rem; }

/* ── Legal pages ── */
.legal-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem 3rem; }
.legal-head { max-width: var(--measure); }
.legal-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; padding: 1rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); color: var(--muted); }
.legal-meta strong { color: var(--text); }
.legal-meta .btn { margin-left: auto; }
.legal-body { max-width: var(--measure); min-width: 0; }
.legal-body p.clause { margin: 0 0 1rem; }
.legal-body h2 { scroll-margin-top: 1rem; }
.legal-body h2 .clause-num, .legal-body h3 .clause-num { margin-right: .5em; }
.toc { font-size: .95rem; }
.toc details { border: 1px solid var(--rule); padding: .75rem 1rem; margin-bottom: 1rem; }
.toc summary { cursor: pointer; font-family: var(--font-head); font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.toc ol, .toc ul { list-style: none; padding: 0; margin: .75rem 0 0; }
.toc li { margin: .35rem 0; line-height: 1.35; }
.toc a { color: var(--text); text-decoration: none; }
.toc a:hover, .toc a[aria-current="page"] { color: var(--accent-ink); }
@media (min-width: 64rem) {
  .legal-layout { grid-template-columns: 16rem minmax(0, 1fr); }
  .legal-head { grid-column: 1 / -1; }
  .toc { grid-row: 2; position: sticky; top: 1rem; align-self: start; max-height: calc(100vh - 2rem); overflow-y: auto; }
  .toc details { border: 0; border-left: 2px solid var(--accent); padding: 0 0 0 1rem; }
}
@media (max-width: 600px) { .legal-meta .btn { margin-left: 0; width: 100%; } }

.doc-list { display: grid; gap: 1rem; margin-top: 2rem; }
.doc-card { display: grid; gap: .25rem; padding: 1.25rem 1.5rem; border: 1px solid var(--rule); border-left: 3px solid var(--accent); text-decoration: none; color: var(--text); }
.doc-card:hover { border-color: var(--accent); color: var(--text); }
.doc-card .eyebrow { margin: 0; }
.doc-card-title { font-family: var(--font-head); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

/* ── Admin ── */
.admin-nav { display: flex; gap: .25rem 1.5rem; flex-wrap: wrap; margin: 0 0 2rem; padding-bottom: .75rem; border-bottom: 1px solid var(--rule);
  font-family: var(--font-head); font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; }
.admin-nav a { color: var(--muted); text-decoration: none; padding: .25rem 0; }
.admin-nav a[aria-current="page"], .admin-nav a:hover { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; margin: 1.25rem 0; }
label { display: block; font-weight: 700; margin: 0 0 .3rem; }
.field { margin: 0 0 1.1rem; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .9rem; }
input[type="text"], input[type="email"], input[type="date"], input[type="number"], select, textarea {
  width: 100%; max-width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 2px; padding: .6rem .7rem; min-height: 44px;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 35%, transparent); }
textarea.markdown { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .88rem; line-height: 1.5; min-height: 60vh; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; }
.check input { margin-top: .3rem; width: 1.1rem; height: 1.1rem; accent-color: var(--accent); flex: none; }
.grid-2 { display: grid; gap: 0 1.25rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
fieldset { border: 1px solid var(--rule); padding: 1rem 1.25rem .25rem; margin: 0 0 1.5rem; min-width: 0; }
legend { font-family: var(--font-head); font-size: .75rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; padding: 0 .4rem; }
.flash { border-left: 3px solid var(--ok); background: var(--row-alt); padding: .75rem 1rem; margin: 0 0 1.25rem; }
.alert ul { margin: .25rem 0 0; padding-left: 1.25rem; }
.tag { display: inline-block; font-family: var(--font-head); font-size: .65rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  padding: .15rem .45rem; border: 1px solid var(--rule); border-radius: 2px; color: var(--muted); }
.tag-accent { border-color: var(--accent); color: var(--accent-ink); }
.preview { border: 1px solid var(--rule); padding: 1.5rem; margin: 1rem 0 2rem; max-height: 70vh; overflow: auto; }
.preview > h1 { margin-top: 0; }

/* Diff */
.diff { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; line-height: 1.45; border: 1px solid var(--rule); max-height: 70vh; overflow: auto; margin: 1rem 0 2rem; }
.diff div { padding: 0 .75rem; white-space: pre-wrap; word-break: break-word; }
.diff .add { background: color-mix(in srgb, #2e7d32 16%, transparent); }
.diff .del { background: color-mix(in srgb, #b3261e 16%, transparent); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text) 40%, transparent); }
.diff .ctx { color: var(--muted); }
.diff .gap { color: var(--muted); background: var(--row-alt); font-style: italic; }
.diff .paired.del { text-decoration: none; }
.diff mark { color: inherit; border-radius: 2px; padding: 0 1px; }
.diff .add mark { background: color-mix(in srgb, #2e7d32 45%, transparent); }
.diff .del mark { background: color-mix(in srgb, #b3261e 45%, transparent); text-decoration: line-through; }
.diff .add::before { content: "+ "; } .diff .del::before { content: "− "; } .diff .ctx::before { content: "  "; }
pre.json { font-size: .75rem; white-space: pre-wrap; word-break: break-word; max-height: 20rem; overflow: auto; background: var(--row-alt); padding: .5rem; }

/* ── Order Forms ── */
.title-row { display: flex; align-items: center; gap: .5rem 1rem; flex-wrap: wrap; justify-content: space-between; }
.title-row h1 { margin: 0; }
.status { display: inline-block; font-family: var(--font-head); font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  padding: .25rem .6rem; border-radius: 999px; background: var(--brand-tint); color: var(--link); white-space: nowrap; }
.status-viewed, .status-sent { background: var(--brand-tint); color: var(--link); }
.status-customer_signed { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-ink); }
.status-executed { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.status-voided, .status-expired { background: var(--row-alt); color: var(--muted); }
.status-draft { background: var(--row-alt); color: var(--text); }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 1.5rem; }
.filters a { text-decoration: none; color: var(--muted); border: 1px solid var(--rule); border-radius: 999px; padding: .3rem .8rem; font-size: .9rem; }
.filters a[aria-current="page"], .filters a:hover { color: var(--link); border-color: var(--brand); }
.filters .count { color: var(--muted); margin-left: .2rem; }
.btn-small { min-height: 36px; padding: .5rem .9rem; font-size: .7rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.label { display: block; font-weight: 700; margin: 0 0 .3rem; }
.radio-row { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.radio { display: inline-flex; align-items: center; gap: .45rem; font-weight: 400; margin: 0; min-height: 36px; }
.radio input { width: 1.1rem; height: 1.1rem; accent-color: var(--brand); }
.plain { margin: .55rem 0 0; }
.small { font-size: .88rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.error-text { color: var(--danger); }
.tbc { color: var(--muted); font-style: italic; }
.choice { white-space: nowrap; margin-right: 1rem; }

.builder-grid, .review-grid { display: grid; gap: 1.5rem 2.5rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 64rem) {
  .builder-grid, .review-grid { grid-template-columns: minmax(0, 1fr) 21rem; }
  .builder-side, .review-side { position: sticky; top: 1rem; }
}
.review-side { order: -1; }
@media (min-width: 64rem) { .review-side { order: 0; } }
.input-table input { min-height: 40px; }
.input-table td { padding: .35rem; }
details.special { border: 1px solid var(--rule); padding: .75rem 1rem; margin: 1.5rem 0; }
details.special summary { cursor: pointer; font-weight: 700; }
details.special textarea { margin-top: .75rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .9rem; }

.pricing-card { border: 1px solid var(--rule); border-top: 3px solid var(--brand); padding: 1.25rem; background: var(--surface); }
.pricing-card h2 { margin-top: 0; }
.price-lines, .price-totals { margin: 0; }
.price-lines > div, .price-totals > div { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--rule); }
.price-lines > div[hidden], .price-totals > div[hidden] { display: none; }
.price-lines dt, .price-totals dt { margin: 0; }
.price-lines dd, .price-totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.price-totals { margin-top: .75rem; }
.price-totals .total { font-weight: 700; }
.price-totals > div:last-child { border-bottom: 2px solid var(--accent); }
.unit { color: var(--muted); font-size: .85rem; }

.link-box { border: 1px solid var(--brand); background: var(--brand-tint); padding: 1rem; margin: 1rem 0; }
.link-box p { margin: 0 0 .5rem; }
.link-box input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
.summary-grid { display: grid; gap: 0 2.5rem; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); }
dl.kv { margin: 0; }
dl.kv > div { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--rule); }
dl.kv dt { color: var(--muted); margin: 0; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) { dl.kv > div { grid-template-columns: 1fr; gap: .1rem; } }
.void-form { max-width: 32rem; }
.order-doc table.signatures td { height: 2.5rem; }

.review-head { max-width: 52rem; }
.freq-options { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
.freq-option { display: flex; gap: .65rem; align-items: center; border: 1px solid var(--rule); padding: .85rem 1rem; cursor: pointer; font-weight: 400; margin: 0; min-height: 56px; }
.freq-option:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); }
.freq-option input { width: 1.2rem; height: 1.2rem; accent-color: var(--brand); flex: none; }
.order-doc-wrap { margin-top: 2.5rem; }
.order-doc { max-width: 52rem; }
.sign-box { margin-top: 2.5rem; border: 1px solid var(--rule); border-top: 3px solid var(--accent); padding: 1.25rem 1.5rem; max-width: 52rem; }
.sign-box h2 { margin-top: 0; }
.sign-box .check { margin-bottom: .75rem; }
[data-add-row] { margin-bottom: 1.5rem; }
