/* BuildingPermit.ca — design system
   Light is defined on :root. Dark is defined twice: once behind
   prefers-color-scheme (guarded so an explicit light choice wins) and once
   behind [data-theme="dark"] so the toggle wins in both directions. */

:root {
  --ink: #14211d;
  --muted: #65716d;
  --line: #dfe5e2;
  --line-2: #cfd9d4;
  --soft: #f3f6f4;
  --warm: #f7f2e8;
  --paper: #ffffff;
  --green: #123d32;
  --green-2: #1d5a49;
  --mint: #dcecdf;
  --mint-2: #b9d8c0;
  --gold: #c18b3f;
  --red: #a6453b;
  --red-line: #ebcdc9;
  --shadow: 0 18px 55px rgba(20, 33, 29, .08);
  --shadow-sm: 0 12px 28px rgba(20, 33, 29, .05);
  --radius: 18px;
  --header: rgba(255, 255, 255, .96);
  --hero-a: rgba(185, 216, 192, .75);
  --hero-b: #f7faf7;
  --hero-c: #ffffff;
  --guide-paper: #fffdfa;
  --table-head: #fbfcfb;
  --row-hover: #f7faf8;
  --thread-bg: #f7f9f8;
  --option-sel: #f5faf6;
  --sidebar: #10231c;
  --amber-ink: #76551d;
  --amber-bg: #f4e6c8;
  --gray-ink: #55615d;
  --gray-bg: #e8ecea;
  --red-ink: #8d382f;
  --red-bg: #f7dfdc;
  --ok: #2f8b62;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #edf5f1;
    --muted: #a9b8b1;
    --line: #2a3d35;
    --line-2: #34473e;
    --soft: #111c18;
    --warm: #19211d;
    --paper: #0c1512;
    --green: #174d3e;
    --green-2: #78cfab;
    --mint: #19372d;
    --mint-2: #285443;
    --gold: #e0aa5a;
    --red: #f08d82;
    --red-line: #5d3a35;
    --shadow: 0 18px 55px rgba(0, 0, 0, .26);
    --shadow-sm: 0 12px 28px rgba(0, 0, 0, .2);
    --header: rgba(12, 21, 18, .96);
    --hero-a: rgba(35, 98, 77, .5);
    --hero-b: #111d19;
    --hero-c: #0c1512;
    --guide-paper: #111d19;
    --table-head: #101b17;
    --row-hover: #16241f;
    --thread-bg: #111c18;
    --option-sel: #16241f;
    --sidebar: #0a1613;
    --amber-ink: #e8c98c;
    --amber-bg: #2f2716;
    --gray-ink: #b3bfba;
    --gray-bg: #1d2723;
    --red-ink: #f3a79f;
    --red-bg: #331d1a;
    --ok: #5cc294;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ink: #edf5f1;
  --muted: #a9b8b1;
  --line: #2a3d35;
  --line-2: #34473e;
  --soft: #111c18;
  --warm: #19211d;
  --paper: #0c1512;
  --green: #174d3e;
  --green-2: #78cfab;
  --mint: #19372d;
  --mint-2: #285443;
  --gold: #e0aa5a;
  --red: #f08d82;
  --red-line: #5d3a35;
  --shadow: 0 18px 55px rgba(0, 0, 0, .26);
  --shadow-sm: 0 12px 28px rgba(0, 0, 0, .2);
  --header: rgba(12, 21, 18, .96);
  --hero-a: rgba(35, 98, 77, .5);
  --hero-b: #111d19;
  --hero-c: #0c1512;
  --guide-paper: #111d19;
  --table-head: #101b17;
  --row-hover: #16241f;
  --thread-bg: #111c18;
  --option-sel: #16241f;
  --sidebar: #0a1613;
  --amber-ink: #e8c98c;
  --amber-bg: #2f2716;
  --gray-ink: #b3bfba;
  --gray-bg: #1d2723;
  --red-ink: #f3a79f;
  --red-bg: #331d1a;
  --ok: #5cc294;
  color-scheme: dark;
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid rgba(29, 90, 73, .38); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3 { text-wrap: balance; }
h1 { max-width: 800px; margin-bottom: 22px; font-size: clamp(36px, 6vw, 68px); line-height: 1.04; letter-spacing: -.05em; }
h2 { margin-bottom: 16px; font-size: clamp(27px, 4vw, 44px); line-height: 1.1; letter-spacing: -.033em; }
h3 { margin-bottom: 8px; font-size: 20px; line-height: 1.25; }
h4 { margin-bottom: 6px; font-size: 15px; }
.lead { max-width: 660px; color: var(--muted); font-size: 18px; }
.small { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.tnum { font-variant-numeric: tabular-nums; }
.container { width: min(1160px, calc(100% - 40px)); margin: 0 auto; }
.container.narrow { width: min(820px, calc(100% - 40px)); }
.container.tiny { width: min(520px, calc(100% - 32px)); }
.section { padding: 84px 0; }
.section.soft { background: var(--soft); }
.section.compact { padding: 40px 0; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 0 16px;
  color: var(--green-2); font-size: 12px; font-weight: 750;
  letter-spacing: .12em; text-transform: uppercase;
}
.eyebrow::before { content: ""; width: 22px; height: 2px; background: var(--green-2); }
.kicker-row { display: flex; gap: 16px; flex-wrap: wrap; margin: 24px 0 0; color: var(--muted); font-size: 14px; }
.kicker-row span::before { content: "✓"; margin-right: 7px; color: var(--green-2); font-weight: 800; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 12px; top: 12px; z-index: 300; padding: 10px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }

/* ------------------------------------------------------------- header */
.site-header {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  min-height: 74px; padding: 0 clamp(16px, 5vw, 64px);
  border-bottom: 1px solid var(--line);
  background: var(--header);
  backdrop-filter: blur(8px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 780; letter-spacing: -.02em; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: #fff; background: var(--green); border-radius: 9px; font-size: 15px; font-weight: 800; }
.site-nav { display: flex; align-items: center; gap: 22px; }
.site-nav a:not(.btn) { color: var(--muted); font-size: 14px; text-decoration: none; }
.site-nav a:not(.btn):hover { color: var(--ink); }
.nav-toggle { display: none; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); padding: 8px 11px; }
.secure-note { color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 46px; padding: 11px 18px;
  border: 1px solid var(--line); border-radius: 11px;
  color: var(--ink); background: var(--paper);
  font-weight: 680; text-decoration: none;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { transform: translateY(-1px); border-color: var(--line-2); }
.btn.primary { color: #fff; background: var(--green); border-color: var(--green); }
.btn.primary:hover { background: var(--green-2); border-color: var(--green-2); }
:root[data-theme="dark"] .btn.primary { color: #eafaf2; }
:root[data-theme="dark"] .btn.primary:hover { color: #06110d; }
.btn.soft { color: var(--green); background: var(--mint); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: var(--red-line); background: transparent; }
.btn.small-btn { min-height: 38px; padding: 7px 12px; border-radius: 9px; font-size: 13px; }
.btn.full { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.text-button { border: 0; background: none; padding: 0; color: var(--green-2); font-size: 13px; font-weight: 700; text-decoration: underline; }
.text-button.danger { color: var(--red); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* -------------------------------------------------------------- hero */
.hero {
  position: relative; overflow: hidden; padding: 96px 0 100px;
  background:
    radial-gradient(circle at 84% 20%, var(--hero-a), transparent 26%),
    linear-gradient(135deg, var(--hero-b) 0%, var(--hero-c) 60%);
}
.hero-grid { display: grid; grid-template-columns: 1.2fr .8fr; align-items: center; gap: 64px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 32px; }
.permit-card { position: relative; padding: 28px; background: var(--green); color: #fff; border-radius: 24px; box-shadow: var(--shadow); }
.permit-card::after { content: ""; position: absolute; inset: 16px; border: 1px solid rgba(255, 255, 255, .16); border-radius: 16px; pointer-events: none; }
.permit-card > * { position: relative; z-index: 1; }
.permit-card h3, .permit-card strong { color: #fff; }
.permit-card .small { color: rgba(255, 255, 255, .62); }
.permit-card .eyebrow { color: var(--mint-2); }
.permit-card .eyebrow::before { background: var(--mint-2); }
.success-panel strong { color: var(--green); }
:root[data-theme="dark"] .success-panel strong { color: #a9e3c9; }
.success-panel p:last-child { margin-bottom: 0; }
.callout-line { margin-bottom: 18px; }
.mt-8 { margin: 8px 0 0; }
.mt-10 { margin-top: 10px; }
details summary { cursor: pointer; padding: 6px 0; }
details[open] summary { margin-bottom: 10px; }
code { padding: 2px 6px; border-radius: 5px; background: var(--soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; overflow-wrap: anywhere; }
.permit-row { display: grid; grid-template-columns: 38px 1fr; gap: 12px; padding: 16px 0; border-bottom: 1px solid rgba(255, 255, 255, .14); }
.permit-row:last-child { border-bottom: 0; }
.permit-row div { min-width: 0; }
.step-num { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: var(--green); background: var(--mint); font-weight: 800; }
:root[data-theme="dark"] .step-num { color: #06110d; background: #a9e3c9; }

/* -------------------------------------------------------- home blocks */
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 40px; margin-bottom: 38px; }
.section-head .lead { margin-bottom: 0; }
.audience-grid, .service-grid, .steps-grid { display: grid; gap: 18px; }
.audience-grid { grid-template-columns: repeat(4, 1fr); }
.service-grid { grid-template-columns: repeat(3, 1fr); }
.steps-grid { grid-template-columns: repeat(4, 1fr); counter-reset: steps; }
.tile { padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.tile p:last-child { margin-bottom: 0; }
.tile-icon { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 24px; border-radius: 12px; color: var(--green); background: var(--mint); font-size: 18px; font-weight: 800; }
:root[data-theme="dark"] .tile-icon { color: #a9e3c9; }
.service-card { display: flex; flex-direction: column; min-height: 330px; padding: 30px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.service-card.featured { border: 2px solid var(--green-2); box-shadow: var(--shadow); }
.service-label { align-self: flex-start; margin-bottom: 18px; padding: 5px 9px; border-radius: 999px; color: var(--green); background: var(--mint); font-size: 12px; font-weight: 750; }
:root[data-theme="dark"] .service-label { color: #a9e3c9; }
.service-price { margin: 10px 0 16px; color: var(--green-2); font-size: 17px; font-weight: 750; }
.service-card ul { margin: 0 0 24px; padding-left: 19px; color: var(--muted); }
.service-card li { margin-bottom: 6px; }
.service-card .btn { margin-top: auto; }
.service-disclosure { margin-top: 24px; padding: 22px 24px; border-left: 4px solid var(--green-2); border-radius: 0 13px 13px 0; background: var(--warm); }
.service-disclosure strong { display: block; margin-bottom: 6px; }
.trust-band { display: grid; grid-template-columns: .75fr 1.25fr; gap: 34px; align-items: center; padding: 30px; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: var(--shadow); }
.trust-number { font-size: clamp(44px, 7vw, 74px); line-height: 1; letter-spacing: -.06em; color: var(--green-2); font-weight: 780; }
.trust-band h3 { font-size: 24px; }
.trust-band p:last-child { margin-bottom: 0; }
.process-step { padding: 4px 18px 4px 0; }
.process-step::before { counter-increment: steps; content: "0" counter(steps); display: block; margin-bottom: 20px; color: var(--green-2); font-size: 13px; font-weight: 800; letter-spacing: .12em; }
.comparison-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); }
.comparison-table { min-width: 520px; }
.comparison-table th { padding: 15px 20px; color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.comparison-table td { padding: 17px 20px; font-size: 15px; }
.comparison-table td:nth-child(3) { font-weight: 700; color: var(--green-2); }
.comparison-note { margin-top: 18px; padding: 17px 20px; border-radius: 12px; color: var(--muted); background: var(--warm); font-size: 13px; }
.cta { padding: 76px 0; color: #fff; background: var(--green); }
.cta .container { display: flex; align-items: center; justify-content: space-between; gap: 36px; }
.cta h2 { max-width: 650px; margin-bottom: 8px; color: #fff; }
.cta p { margin-bottom: 0; color: rgba(255, 255, 255, .72); }
.cta .btn { color: var(--green); border-color: #fff; background: #fff; }
:root[data-theme="dark"] .cta .btn { color: #06110d; }
.site-footer { padding: 34px 0; border-top: 1px solid var(--line); background: var(--paper); }
.footer-row { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.footer-row a { color: var(--muted); }
.footer-col { display: grid; gap: 6px; align-content: start; max-width: 340px; }

/* ------------------------------------------------------------- guides */
.guide-hero { padding: 68px 0 44px; background: var(--warm); }
.guide-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.guide-card { display: flex; flex-direction: column; min-height: 230px; padding: 26px; border: 1px solid var(--line); border-radius: 16px; background: var(--guide-paper); text-decoration: none; transition: transform .15s ease, box-shadow .15s ease; }
.guide-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.guide-meta { margin-bottom: 16px; color: var(--green-2); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.guide-card h3 { font-family: Georgia, "Times New Roman", serif; font-size: 23px; font-weight: 500; letter-spacing: -.02em; }
.guide-card p { color: var(--muted); }
.guide-card .read-link { margin-top: auto; color: var(--green-2); font-size: 13px; font-weight: 750; }
.article { padding: 54px 0 80px; }
.article h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(32px, 5vw, 50px); font-weight: 500; letter-spacing: -.03em; }
.article h2 { margin-top: 38px; font-size: 27px; }
.article p, .article li { color: var(--ink); font-size: 17px; line-height: 1.7; max-width: 68ch; }
.article ul, .article ol { padding-left: 22px; }
.article li { margin-bottom: 8px; }

/* ------------------------------------------------------------- intake */
.app-surface { min-height: 70vh; background: var(--soft); }
.intake-wrap { width: min(920px, calc(100% - 32px)); margin: 0 auto; padding: 46px 0 84px; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 9px; color: var(--muted); font-size: 13px; }
.progress-track { height: 7px; margin-bottom: 30px; overflow: hidden; border-radius: 99px; background: var(--mint-2); }
.progress-fill { height: 100%; width: 25%; border-radius: inherit; background: var(--green-2); transition: width .25s ease; }
.intake-card { padding: clamp(22px, 5vw, 50px); border: 1px solid var(--line); border-radius: 24px; background: var(--paper); box-shadow: var(--shadow-sm); }
.intake-card h2 { font-size: clamp(26px, 4vw, 40px); }
.js-on .intake-step { display: none; }
.js-on .intake-step.active { display: block; }
.question { margin-bottom: 26px; }
.question > label, .field-label { display: block; margin-bottom: 9px; font-weight: 700; }
.required { color: var(--red); }
.option-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.option-grid.three { grid-template-columns: repeat(3, 1fr); }
.option-card { position: relative; display: flex; align-items: flex-start; gap: 12px; min-height: 68px; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); cursor: pointer; }
.option-card:hover { border-color: var(--green-2); background: var(--option-sel); }
.option-card:has(input:checked) { border-color: var(--green-2); background: var(--option-sel); }
.option-card input { margin-top: 4px; accent-color: var(--green-2); }
.option-card strong { display: block; }
.option-card .small { display: block; margin-top: 2px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { position: relative; margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.input, .select, .textarea {
  width: 100%; min-height: 49px; padding: 12px 14px;
  color: var(--ink); border: 1px solid var(--line-2); border-radius: 10px; background: var(--paper);
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--green-2); }
.textarea { min-height: 110px; resize: vertical; }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.suggestions { display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 8; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); box-shadow: var(--shadow); }
.suggestions.show { display: block; }
.suggestion { display: block; width: 100%; padding: 11px 14px; border: 0; border-bottom: 1px solid var(--line); background: var(--paper); text-align: left; }
.suggestion:last-child { border-bottom: 0; }
.suggestion:hover { background: var(--soft); }
.intake-actions { display: flex; justify-content: space-between; gap: 12px; padding-top: 20px; margin-top: 8px; border-top: 1px solid var(--line); }
.intake-actions.end { justify-content: flex-end; }
.code-input { letter-spacing: .3em; text-align: center; font-weight: 800; font-size: 20px; }
.success-panel { padding: 26px; border-radius: 16px; background: var(--mint); }
.review-list { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 22px; border-radius: 14px; background: var(--soft); margin-bottom: 22px; }
.review-list div { min-width: 0; }
.review-list dt { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.review-list dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.check-row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 20px; }
.check-row input { margin-top: 4px; accent-color: var(--green-2); }

/* ------------------------------------------------------------ notices */
.notice { display: flex; gap: 10px; padding: 14px 17px; border-radius: 12px; margin-bottom: 20px; font-size: 14px; border: 1px solid transparent; }
.notice.success { color: var(--green); background: var(--mint); border-color: var(--mint-2); }
:root[data-theme="dark"] .notice.success { color: #a9e3c9; }
.notice.error { color: var(--red-ink); background: var(--red-bg); border-color: var(--red-line); }
.notice.info { color: var(--amber-ink); background: var(--amber-bg); }

/* -------------------------------------------------------------- cards */
.panel { border: 1px solid var(--line); border-radius: 15px; background: var(--paper); }
.panel + .panel { margin-top: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 17px; }
.panel-body { padding: 20px; }
.panel-body > :last-child { margin-bottom: 0; }
.empty-note { padding: 34px; text-align: center; color: var(--muted); font-size: 14px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; color: var(--green); background: var(--mint); font-size: 12px; font-weight: 750; white-space: nowrap; }
:root[data-theme="dark"] .badge { color: #a9e3c9; }
.badge.amber { color: var(--amber-ink); background: var(--amber-bg); }
.badge.gray { color: var(--gray-ink); background: var(--gray-bg); }
.badge.red { color: var(--red-ink); background: var(--red-bg); }

/* ------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 18px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; vertical-align: middle; }
th { color: var(--muted); background: var(--table-head); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
.row-link tbody tr:hover { background: var(--row-hover); }
.client-cell strong { display: block; font-size: 14px; }
/* Secondary lines in a cell belong under the main value, not run into it. */
td .small, .file-row .small, .contact-row .small, .project-row span { display: block; }
td .small { margin-top: 2px; }
.detail-grid.wide-left { grid-template-columns: 1.6fr .8fr; }
.project-link { color: var(--green-2); font-weight: 750; text-decoration: none; }

/* ------------------------------------------------------- client space */
.workspace-head { padding: 40px 0 30px; background: var(--soft); border-bottom: 1px solid var(--line); }
.workspace-head .container { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.detail-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; align-items: start; }
/* Grid and flex children default to min-width:auto, so one wide table or code
   block inside a column stretches the whole page. This is the fix. */
.detail-grid > *, .tpl-grid > *, .api-config > *, .stat-grid > *, .test-grid > * { min-width: 0; }
.panel, .admin-content, .admin-main { min-width: 0; }
.data-list { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.data-item dt { margin-bottom: 3px; color: var(--muted); font-size: 12px; }
.data-item dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.action-stack { display: grid; gap: 10px; }
.project-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 20px; border-bottom: 1px solid var(--line); text-decoration: none;
}
.project-row:last-child { border-bottom: 0; }
.project-row:hover { background: var(--row-hover); }
.project-row span { display: block; color: var(--muted); font-size: 13px; }
.file-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 20px; border-bottom: 1px solid var(--line); }
.file-row:last-child { border-bottom: 0; }
.file-row .file-name { min-width: 0; overflow-wrap: anywhere; }
.file-row strong { display: block; font-size: 14px; }
.file-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.callout-line { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px; border-radius: 12px; background: var(--warm); font-size: 14px; }
.callout-line strong { white-space: nowrap; }

/* ------------------------------------------------------------ uploads */
.dropzone {
  display: grid; place-items: center; gap: 8px; padding: 40px 20px; text-align: center;
  border: 2px dashed var(--line-2); border-radius: 16px; background: var(--soft);
  transition: border-color .15s ease, background .15s ease;
}
.dropzone.drag { border-color: var(--green-2); background: var(--option-sel); }
.dropzone strong { font-size: 16px; }
.dropzone .btn { margin-top: 6px; }
.upload-list { display: grid; gap: 10px; margin-top: 18px; }
.upload-item { display: grid; gap: 8px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.upload-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.upload-name { min-width: 0; font-weight: 650; font-size: 14px; overflow-wrap: anywhere; }
.upload-size { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.upload-bar { height: 6px; overflow: hidden; border-radius: 99px; background: var(--gray-bg); }
.upload-bar i { display: block; height: 100%; width: 0; background: var(--green-2); transition: width .2s ease; }
.upload-item.done .upload-bar i { background: var(--ok); }
.upload-item.error { border-color: var(--red-line); }
.upload-item.error .upload-bar i { background: var(--red); }
.upload-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upload-meta .select, .upload-meta .input { min-height: 38px; padding: 7px 10px; font-size: 13px; width: auto; min-width: 150px; }
.upload-status { color: var(--muted); font-size: 12px; }
.upload-status.ok { color: var(--ok); font-weight: 700; }
.upload-status.bad { color: var(--red); font-weight: 700; }

/* -------------------------------------------------------------- admin */
.admin-shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; background: var(--soft); }
.admin-sidebar { padding: 22px 16px; color: #fff; background: var(--sidebar); }
.admin-sidebar .brand { margin: 0 8px 30px; color: #fff; }
.admin-sidebar .brand-mark { background: var(--green-2); color: #06110d; }
.admin-nav { display: grid; gap: 4px; }
.admin-nav a {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 9px;
  color: rgba(255, 255, 255, .66); background: transparent;
  text-decoration: none; font-size: 14px; font-weight: 600;
}
.admin-nav a:hover, .admin-nav a.active { color: #fff; background: rgba(255, 255, 255, .1); }
.admin-nav .ico { width: 18px; text-align: center; opacity: .85; }
.admin-sidebar-foot { margin-top: 34px; padding: 15px 12px; border-top: 1px solid rgba(255, 255, 255, .13); color: rgba(255, 255, 255, .6); font-size: 12px; }
.admin-sidebar-foot strong { display: block; color: #fff; overflow-wrap: anywhere; }
.admin-sidebar-foot a { color: rgba(255, 255, 255, .78); }
.admin-main { min-width: 0; }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 70px; padding: 12px 28px; background: var(--paper); border-bottom: 1px solid var(--line); }
.admin-crumb { color: var(--muted); font-size: 14px; }
.admin-crumb strong { color: var(--ink); }
.admin-profile { display: flex; align-items: center; gap: 10px; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; overflow: hidden; border-radius: 50%; color: #fff; background: var(--green-2); font-size: 12px; font-weight: 800; flex: none; }
:root[data-theme="dark"] .avatar { color: #06110d; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 62px; height: 62px; font-size: 18px; }
.admin-content { padding: 28px; }
.admin-title-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.admin-title-row h1 { margin-bottom: 3px; font-size: clamp(24px, 3vw, 34px); }
.admin-title-row .small { margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.stat .value { margin: 5px 0 2px; font-size: 28px; font-weight: 780; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filters .input, .filters .select { min-height: 42px; width: auto; min-width: 190px; }
.message-thread { display: grid; gap: 12px; max-height: 320px; overflow-y: auto; padding: 18px; background: var(--thread-bg); }
.message { max-width: 84%; padding: 10px 13px; border-radius: 13px 13px 13px 4px; background: var(--paper); box-shadow: 0 3px 10px rgba(20, 33, 29, .06); font-size: 13px; overflow-wrap: anywhere; }
.message.outbound { justify-self: end; border-radius: 13px 13px 4px 13px; color: #fff; background: var(--green-2); }
:root[data-theme="dark"] .message.outbound { color: #06110d; }
.message p { margin: 0; }
.message-time { display: block; margin-top: 5px; opacity: .65; font-size: 10px; }
.timeline { display: grid; }
.timeline-item { position: relative; padding: 0 0 20px 27px; }
.timeline-item::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: -3px; width: 1px; background: var(--line); }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item:last-child::before { display: none; }
.timeline-dot { position: absolute; left: 0; top: 5px; width: 13px; height: 13px; border: 3px solid var(--paper); border-radius: 50%; background: var(--green-2); box-shadow: 0 0 0 1px var(--green-2); }
.timeline-item strong { font-size: 14px; }
.timeline-item p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { margin-bottom: 0; flex: 1 1 180px; }
.inline-form .select, .inline-form .input { min-height: 42px; }
.mini-form { display: flex; gap: 6px; align-items: center; }
.mini-form .select, .mini-form .input { min-height: 34px; padding: 5px 9px; font-size: 12px; width: auto; min-width: 130px; }
.mini-form button { min-height: 34px; padding: 5px 10px; font-size: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.contact-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.contact-row:last-child { border-bottom: 0; }
.contact-row .small { margin: 0; }
.member-card { display: flex; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.member-card:last-child { border-bottom: 0; }
.member-body { min-width: 0; flex: 1; }
.member-body p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.note-item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.note-item:last-child { border-bottom: 0; padding-bottom: 0; }
.note-item p { margin: 6px 0 0; overflow-wrap: anywhere; }
.audit-row { display: grid; grid-template-columns: 175px 1fr 160px; gap: 18px; padding: 15px 20px; border-bottom: 1px solid var(--line); align-items: start; font-size: 13px; }
.audit-row:last-child { border-bottom: 0; }
.test-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.test-item { display: grid; gap: 10px; padding: 18px; border: 1px solid var(--line); border-radius: 13px; }
.api-config { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.api-service { padding: 20px; border: 1px solid var(--line); border-radius: 13px; }
.api-service-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.status-dot.pending { background: var(--gold); }
.switch-row { display: flex; align-items: flex-start; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.switch-row input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--green-2); }
.switch-row p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.calendar-item { display: flex; align-items: center; gap: 18px; padding: 15px 20px; border-bottom: 1px solid var(--line); text-decoration: none; }
.calendar-item:last-child { border-bottom: 0; }
.calendar-item:hover { background: var(--row-hover); }
.calendar-item time { width: 190px; flex: none; color: var(--green-2); font-weight: 700; font-size: 13px; }
.calendar-item div { flex: 1; min-width: 0; }
.calendar-item span { display: block; color: var(--muted); font-size: 13px; }

/* --------------------------------------------------------------- charts */
/* One series, one hue. Geometry is set through SVG attributes, never inline
   CSS, because the page's own policy forbids inline styles. */
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-tick { fill: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart-area { fill: var(--green-2); opacity: .12; stroke: none; }
.chart-line { fill: none; stroke: var(--green-2); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--green-2); stroke: var(--paper); stroke-width: 2; }
.chart-hit { fill: transparent; }
.chart-hit:hover { fill: var(--green-2); fill-opacity: .07; }
.bar { display: inline-block; vertical-align: middle; margin-right: 8px; max-width: 150px; }
.bar-track { fill: var(--gray-bg); }
.bar-fill { fill: var(--green-2); }
.bar-value { font-variant-numeric: tabular-nums; font-weight: 650; }
.code-block {
  margin: 0 0 12px; padding: 14px; overflow-x: auto;
  border: 1px solid var(--line); border-radius: 10px; background: var(--soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.6;
}
.rule { height: 1px; margin: 0; border: 0; background: var(--line); }

/* --------------------------------------------------- email templates */
.tpl-grid { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: start; }
.tpl-list { display: grid; }
.tpl-list a { display: block; padding: 13px 18px; border-bottom: 1px solid var(--line); text-decoration: none; font-size: 14px; font-weight: 650; }
.tpl-list a:last-child { border-bottom: 0; }
.tpl-list a.active { background: var(--mint); color: var(--green); }
:root[data-theme="dark"] .tpl-list a.active { color: #a9e3c9; }
.tpl-list a:hover { background: var(--row-hover); }
.tpl-list a span { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.code-area { min-height: 340px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.6; }
.token-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.token { padding: 4px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.preview-frame { width: 100%; min-height: 460px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }

/* --------------------------------------------------------- responsive */
@media (max-width: 980px) {
  .hero-grid, .detail-grid, .detail-grid.wide-left, .tpl-grid { grid-template-columns: 1fr; }
  .audience-grid, .steps-grid { grid-template-columns: repeat(2, 1fr); }
  .service-grid { grid-template-columns: 1fr; }
  .service-card { min-height: 0; }
  .admin-shell { grid-template-columns: 74px 1fr; }
  .admin-sidebar .brand span:last-child, .admin-nav a span, .admin-sidebar-foot { display: none; }
  .admin-nav a { justify-content: center; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .guide-grid { grid-template-columns: repeat(2, 1fr); }
}

/* The public nav carries up to seven items plus a call to action, so it
   collapses well before phone widths — otherwise the links wrap into each
   other on a small laptop. */
@media (max-width: 1000px) {
  .site-header { flex-wrap: wrap; min-height: 62px; padding-top: 10px; padding-bottom: 10px; }
  .nav-toggle { display: inline-flex; }
  .site-nav { display: none; order: 3; width: 100%; flex-direction: column; align-items: stretch; gap: 4px; padding-bottom: 8px; }
  .site-nav.open { display: flex; }
  .site-nav a:not(.btn) { padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 15px; }
  .site-nav .btn { margin-top: 8px; }
}

@media (max-width: 760px) {
  .hero { padding: 60px 0 66px; }
  .hero-grid { gap: 38px; }
  .section { padding: 56px 0; }
  .section-head, .cta .container { align-items: flex-start; flex-direction: column; }
  .audience-grid, .steps-grid, .option-grid, .option-grid.three,
  .field-grid, .data-list, .test-grid, .guide-grid, .api-config,
  .trust-band, .review-list { grid-template-columns: 1fr; }
  .admin-shell { display: block; min-height: 0; }
  /* The nav becomes a scrolling strip; hidden overflow stops it widening the page. */
  .admin-sidebar { padding: 10px; overflow: hidden; }
  .admin-sidebar .brand, .admin-sidebar-foot { display: none; }
  .admin-nav { display: flex; max-width: 100%; overflow-x: auto; gap: 4px; scrollbar-width: thin; }
  .admin-nav a { width: auto; min-width: 46px; flex: 0 0 auto; }
  .admin-top { padding: 10px 14px; }
  .admin-profile .badge { display: none; }
  .admin-content { padding: 18px 14px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .audit-row { grid-template-columns: 1fr; gap: 4px; }
  .calendar-item { flex-direction: column; align-items: flex-start; gap: 6px; }
  .calendar-item time { width: auto; }
  .workspace-head .container { flex-direction: column; align-items: flex-start; }
  .file-row, .contact-row { flex-direction: column; align-items: flex-start; }
  .file-actions { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
  .btn:hover, .guide-card:hover { transform: none; }
}

/* ---- Site wording page ------------------------------------------------- */
/* A very long single form. The jump row gets you to a section and the save
   bar follows you down, so an edit at the top does not mean a 9,000-pixel
   scroll to the button. */
.jump-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.jump {
  display: inline-block; padding: 6px 12px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--paper); color: var(--muted);
  font-size: 13px; font-weight: 600; text-decoration: none;
}
.jump:hover { border-color: var(--line-2); color: var(--ink); }

.save-bar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  margin-top: 18px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 15px;
  background: var(--paper); box-shadow: 0 -6px 18px rgb(0 0 0 / 8%);
}
.save-hint { margin-left: auto; }
@media (max-width: 640px) {
  .save-hint { display: none; }
}
