/* Design system. Colours come from brand.json as CSS variables (injected in <head>).
   Concept: the subsurface cross-section. Ink = deep ground, paper = surveyed ground,
   accent = locate-paint yellow (the US utility marking colour for petroleum and gas),
   water = groundwater blue, soil = strata brown. Swap brand.json to rebrand. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation: none !important; transition: none !important; } }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.6; font-feature-settings: "tnum" 0; }
img, svg { max-width: 100%; display: block; }
a { color: var(--water); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
h1, h2, h3, h4 { font-family: var(--font-display); font-stretch: 112%; line-height: 1.08; margin: 0 0 .5em; letter-spacing: -0.01em; font-weight: 700; text-wrap: balance; }
h1 { font-size: clamp(2.3rem, 4.6vw, 4.1rem); font-stretch: 118%; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: clamp(1.8rem, 3.4vw, 2.75rem); }
h3 { font-size: 1.3rem; font-stretch: 112%; }
h4 { font-size: 1.05rem; }
p { margin: 0 0 1em; max-width: 68ch; }
.lede { font-size: 1.2rem; line-height: 1.55; color: var(--ink); max-width: 56ch; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; }
.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 640px) { .wrap { padding: 0 16px; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 20px; border-radius: 6px; border: 2px solid var(--ink); background: var(--ink); color: #fff; font: 600 .98rem/1.2 var(--font-body); text-decoration: none; cursor: pointer; transition: background .15s, color .15s, transform .1s; }
.btn:hover { background: #000; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: #5BB8F5; color: var(--accent-ink); border-color: #5BB8F5; }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: #fff; }
.btn-light { background: transparent; border-color: rgba(255,255,255,.5); color: #fff; }
.btn-light:hover { background: #fff; color: var(--ink); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .875rem; }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--water); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* forms */
label { display: block; font-weight: 600; font-size: .92rem; margin: 0 0 6px; }
.field { margin-bottom: 18px; }
.hint { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.err { font-size: .875rem; color: var(--danger); margin-top: 4px; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], input[type=url], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); font: 400 1rem/1.4 var(--font-body); }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin-bottom: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--ink); flex: none; }
fieldset { border: 0; padding: 0; margin: 0 0 28px; }
legend { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; margin-bottom: 4px; padding: 0; }

/* flash */
.flash { padding: 12px 16px; border-radius: 6px; margin: 12px 0; border-left: 4px solid var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }
.flash.error { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.flash.key { border-color: var(--accent); font-family: ui-monospace, monospace; word-break: break-all; }

/* tags: classification is shown with text AND shape, never colour alone */
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); white-space: nowrap; line-height: 1.4; }
.tag::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; flex: none; }
.tag.procurement { border-color: var(--ink); background: var(--ink); color: #fff; }
.tag.procurement::before { background: var(--accent); border-radius: 50%; }
.tag.service_need { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.tag.service_need::before { background: var(--warn); transform: rotate(45deg); }
.tag.lead::before { background: transparent; border: 1.5px solid var(--muted); border-radius: 50%; }
.tag.hist { border-style: dashed; color: var(--muted); }
.tag.hist::before { display: none; }
.tag.closed { color: var(--muted); }
.tag.closed::before { display: none; }
.tag.plain::before { display: none; }

/* score meter */
.score { display: inline-grid; place-items: center; min-width: 44px; height: 44px; border-radius: 6px; font: 800 1.05rem/1 var(--font-display); font-variant-numeric: tabular-nums; border: 2px solid var(--ink); background: var(--surface); }
.score.hi { background: var(--accent); border-color: var(--accent); }
.score.lo { color: var(--muted); border-color: var(--line); }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .82rem; background: var(--paper); position: sticky; top: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }

/* status dot for sources */
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .85rem; }
.status::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.status.ok::before { background: var(--ok); }
.status.failing::before { background: var(--danger); border-radius: 2px; }
.status.stale::before, .status.awaiting_credentials::before { background: var(--warn); transform: rotate(45deg); border-radius: 1px; }
.status.never_run::before, .status.disabled::before { background: transparent; border: 2px solid var(--muted); }

.error-page { min-height: 60vh; display: grid; place-content: center; text-align: left; padding: 48px 16px; }
