/* CityPilot Building Code portal: citypilot.ca type and brand blue on a light reading surface. */
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url('../fonts/outfit-latin-var.woff2') format('woff2');
}

:root {
  --ink: #0f172a;
  --body: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --surface: #ffffff;
  --page: #f8fafc;
  --bar: #0a0a0b;
  --brand: #2563eb;
  --brand-soft: #dbeafe;
  --teal: #3f8ea3;
  --pass: #15803d;   --pass-bg: #dcfce7;
  --fail: #b91c1c;   --fail-bg: #fee2e2;
  --warn: #a16207;   --warn-bg: #fef3c7;
  --idle: #475569;   --idle-bg: #f1f5f9;
  --radius: 10px;
  --font: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--body);
  background: var(--page);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--brand); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { color: var(--ink); line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 .6rem; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.25rem; margin-top: 1.8rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8rem; }
.muted { color: var(--muted); }
.lead { font-size: 1.1rem; color: var(--body); }
.skip { position: absolute; left: -999px; top: 0; background: var(--brand); color: #fff; padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; top: 1rem; }
code, .mono { font-family: var(--mono); font-size: .9em; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  background: var(--bar); color: #e2e8f0;
  padding: .7rem 1.5rem;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; letter-spacing: -0.01em; }
.brand span { color: #60a5fa; font-weight: 500; }
.nav { display: flex; gap: .3rem; }
.nav a { color: #cbd5e1; text-decoration: none; padding: .3rem .7rem; border-radius: 6px; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav a.on { color: #fff; background: rgba(96,165,250,.18); }
.account { margin-left: auto; display: flex; gap: .8rem; align-items: center; font-size: .9rem; }
.account a, .account button.link { color: #cbd5e1; }
.foot { color: var(--muted); font-size: .8rem; padding: 1rem 1.5rem; border-top: 1px solid var(--line); background: var(--surface); }

/* Pages */
.page { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem 3rem; }
.page.narrow { max-width: 760px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.tile {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; text-decoration: none; color: var(--body);
}
.tile:hover { border-color: var(--brand); }
.tile strong { display: block; color: var(--ink); font-size: 1.1rem; margin-bottom: .3rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin: 1rem 0; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.stats dt { color: var(--muted); font-size: .8rem; }
.stats dd { margin: 0; color: var(--ink); font-size: 1.4rem; font-weight: 700; }
.status-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.2rem; }

/* Badges and chips */
.badge {
  display: inline-block; font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px;
  background: var(--idle-bg); color: var(--idle); white-space: nowrap;
}
.s-implemented, .b-pass { background: var(--pass-bg); color: var(--pass); }
.s-changed { background: var(--notassessed-bg, #fff4d6); color: var(--notassessed, #7a5600); }
.s-gateof { background: var(--brand-soft); color: var(--brand); }
.s-notmodelable, .b-notassessed { background: var(--warn-bg); color: var(--warn); }
.s-deferred, .s-unaccounted, .b-fail { background: var(--fail-bg); color: var(--fail); }
.b-advisory, .b-suppressed { background: var(--idle-bg); color: var(--idle); }
.chip {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; padding: .15rem .55rem;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--body);
  cursor: pointer; text-decoration: none; font-family: inherit;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .n { color: var(--muted); font-size: .75rem; }
.chip.on .n { color: #dbeafe; }

/* Forms */
label { font-weight: 500; color: var(--ink); }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: .45rem .65rem; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.btn {
  display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 8px; padding: .5rem 1rem; border: 1px solid var(--brand); background: var(--brand); color: #fff;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--surface); color: var(--brand); }
.btn.danger { background: var(--fail); border-color: var(--fail); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-decoration: underline; }
.field { margin-bottom: 1rem; }
.field .hint { color: var(--muted); font-size: .85rem; }
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; }
.alert { border-radius: 8px; padding: .7rem 1rem; margin-bottom: 1rem; background: var(--brand-soft); color: var(--ink); }
.alert.error { background: var(--fail-bg); color: var(--fail); }
.alert.ok { background: var(--pass-bg); color: var(--pass); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.validation { color: var(--fail); font-size: .85rem; }

/* Printed code */
.printed { color: var(--ink); }
.printed .line { margin: 0 0 .35rem; }
.printed .sentence { border-left: 3px solid transparent; padding-left: .5rem; margin-left: -.8rem; }
.printed .sentence.hl { border-left-color: var(--brand); background: #eff6ff; }
.printed-table { overflow-x: auto; margin: .6rem 0 1rem; }
.printed-table table { border-collapse: collapse; font-size: .85rem; }
.printed-table th, .printed-table td { border: 1px solid var(--line-strong); padding: .3rem .5rem; vertical-align: top; text-align: left; }
.printed-table th { background: var(--idle-bg); color: var(--ink); }
.printed img { max-width: 100%; height: auto; }

/* Search */
.search-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr) minmax(0, 0.9fr); gap: 0; height: calc(100vh - 52px - 46px); }
.search-shell > * { overflow: auto; }
.pane { padding: 1rem; border-right: 1px solid var(--line); background: var(--surface); }
.pane.middle { background: var(--page); }
.pane.right { border-right: 0; }
.toolbar { display: grid; gap: .6rem; padding: 1rem 1rem .6rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.toolbar .row { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.toolbar .row > span { color: var(--muted); font-size: .8rem; margin-right: .2rem; }
.facts-pane h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 1rem 0 .4rem; }
.fact-row { display: flex; justify-content: space-between; gap: .5rem; width: 100%; text-align: left; background: none; border: 0; padding: .25rem .4rem; border-radius: 6px; font: inherit; font-size: .85rem; color: var(--body); cursor: pointer; }
.fact-row:hover { background: var(--idle-bg); }
.fact-row.on { background: var(--brand-soft); color: var(--ink); font-weight: 600; }
.fact-row .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.summary { padding: .6rem 1rem; color: var(--muted); font-size: .9rem; }
.article-head { padding: .8rem 1rem .2rem; color: var(--ink); font-weight: 700; }
.article-head .id { color: var(--muted); font-weight: 500; margin-right: .4rem; }
.card {
  margin: .4rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .75rem .9rem; cursor: pointer;
}
.card:hover { border-color: var(--line-strong); }
.card.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.card-head { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; margin-bottom: .3rem; }
.card-head .id { font-weight: 700; color: var(--ink); }
.card-text { color: var(--ink); font-size: .92rem; }
.card-text .line { margin: 0 0 .2rem; }
.card .reason { font-size: .85rem; color: var(--muted); margin-top: .4rem; }
.rules { margin-top: .5rem; border-top: 1px dashed var(--line); padding-top: .4rem; font-size: .85rem; }
.rule { margin: .25rem 0; }
.rule .req { font-weight: 600; color: var(--ink); }
.rule .gate { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .5rem; }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: center; padding: 1rem; }
.empty { padding: 2rem 1rem; color: var(--muted); text-align: center; }
.source-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }

/* Tables of data (lists, reports, admin) */
table.data { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .9rem; }
table.data th, table.data td { border-bottom: 1px solid var(--line); padding: .5rem .6rem; text-align: left; vertical-align: top; }
table.data th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
table.data tr.tightest td { background: #fffbeb; }

@media (max-width: 1000px) {
  .search-shell { grid-template-columns: 1fr; height: auto; }
  .search-shell > * { overflow: visible; }
  .pane { border-right: 0; border-bottom: 1px solid var(--line); }
}

@media print {
  .topbar, .foot, .no-print { display: none !important; }
  body { background: #fff; }
  .page { max-width: none; padding: 0; }
}

/* Multi-select dropdowns (Search toolbar) */
details.multi { position: relative; }
details.multi > summary {
  list-style: none; cursor: pointer; font-size: .85rem; padding: .3rem .7rem; border: 1px solid var(--line-strong);
  border-radius: 8px; background: var(--surface); color: var(--ink);
}
details.multi > summary::-webkit-details-marker { display: none; }
details.multi > summary::after { content: " ▾"; color: var(--muted); }
details.multi > summary[data-count]:not([data-count=""])::before {
  content: attr(data-count); background: var(--brand); color: #fff; border-radius: 999px; font-size: .7rem;
  padding: 0 .4rem; margin-right: .35rem;
}
details.multi .menu {
  position: absolute; z-index: 5; top: calc(100% + 4px); left: 0; width: 320px; max-height: 360px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: .4rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
}
details.multi .menu label { display: flex; gap: .45rem; align-items: baseline; font-weight: 400; font-size: .85rem; padding: .2rem .3rem; border-radius: 4px; }
details.multi .menu label:hover { background: var(--idle-bg); }
details.multi .menu .n { color: var(--muted); margin-left: auto; font-size: .75rem; }
.toggle { display: inline-flex; gap: .35rem; align-items: center; font-size: .85rem; font-weight: 400; }
.small { font-size: .82rem; }
body.full .foot { display: none; }
body.full .search-shell { height: calc(100vh - 52px); }

/* Accounts */
form.inline { display: inline; margin: 0; }
.btn.small-btn { padding: .25rem .7rem; font-size: .85rem; }
.flash { max-width: 760px; margin: 1rem auto 0; padding: .6rem 1rem; border-radius: 8px; background: var(--pass-bg); color: var(--pass); }
.auth-page { max-width: 440px; margin: 0 auto; padding: 2.5rem 1.5rem 3rem; }
.auth-page h1 { font-size: 1.6rem; }
.auth-links { margin-top: 1rem; font-size: .9rem; display: flex; flex-direction: column; gap: .3rem; }
.code-input { font-size: 1.6rem !important; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.admin-actions { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.admin-actions input[type=text] { width: 9rem; padding: .25rem .45rem; font-size: .8rem; }
.admin-actions select { width: auto; padding: .25rem .45rem; font-size: .8rem; }
.admin-actions .btn { padding: .25rem .6rem; font-size: .8rem; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin: 1rem 0; }
.filters > * { width: auto; }

/* Analysis: start, form, report */
.element-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .4rem; margin: .6rem 0 1.2rem; }
.element-choice { display: flex; gap: .45rem; align-items: baseline; font-weight: 400; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.element-choice .n { margin-left: auto; color: var(--muted); font-size: .75rem; }
.analysis-bar { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; padding: .7rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 4; }
.title-input { max-width: 420px; font-weight: 600; }
.analysis-actions { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.analysis-actions details.multi .menu { left: auto; right: 0; }
.analysis-body { display: grid; grid-template-columns: 200px minmax(0, 1fr) auto; gap: 1.2rem; padding: 1rem 1.5rem 3rem; align-items: start; }
.block-nav { position: sticky; top: 70px; display: flex; flex-direction: column; gap: .2rem; font-size: .9rem; }
.block-nav a { text-decoration: none; color: var(--body); padding: .2rem .4rem; border-radius: 6px; display: flex; justify-content: space-between; }
.block-nav a:hover { background: var(--idle-bg); }
.block-nav .n { color: var(--muted); }
.block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1rem; scroll-margin-top: 70px; }
.block-head { display: flex; gap: .8rem; align-items: baseline; }
.instance { border: 1px solid var(--line); border-radius: 8px; margin: .6rem 0; }
.instance > summary { display: flex; gap: .6rem; align-items: center; padding: .5rem .7rem; cursor: pointer; background: var(--page); border-radius: 8px; }
.instance-label { max-width: 320px; font-weight: 600; }
.danger-link { color: var(--fail); margin-left: auto; font-size: .85rem; }
.instance-body { padding: .4rem .7rem .7rem; }
fieldset.group { border: 0; padding: 0; margin: .6rem 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .6rem 1rem; }
fieldset.group legend { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .3rem; }
.q label { font-size: .88rem; display: block; margin-bottom: .15rem; }
.q .unit { color: var(--muted); font-weight: 400; }
.q-input { display: flex; gap: .4rem; align-items: center; }
.q-input > span { flex: 1; }
.q-cites { margin-top: .2rem; display: flex; gap: .25rem; flex-wrap: wrap; }
.q-cites .chip { font-size: .7rem; padding: .05rem .4rem; }
.q .mark { width: .6rem; height: .6rem; border-radius: 50%; flex: none; }
.q.is-fail input, .q.is-fail select { border-color: var(--fail); background: #fff7f7; }
.q.is-fail .mark { background: var(--fail); }
.q.is-pass .mark { background: var(--pass); }
.q.is-open input, .q.is-open select { border-color: var(--warn); }
/* The form's sections (PLAN_FORM_QUESTIONS.md §4.5): What it is → … → Doesn't apply. */
.sec { border: 0; padding: 0; margin: .7rem 0; }
.sec > legend, .sec > summary { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .3rem; }
details.sec > summary { cursor: pointer; }
.sec-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .6rem 1rem; }
.s-whatitis .sec-body, .sec-body.pointers { grid-template-columns: 1fr; max-width: 560px; }
.s-doesnotapply .sec-body, .s-later .sec-body { opacity: .75; padding-top: .4rem; }
.subgroup { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: .3rem; }
.subgroup > summary { cursor: pointer; font-size: .88rem; font-weight: 600; }
.subgroup-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .6rem 1rem; padding: .4rem 0; }
.route { max-width: 560px; }
.identity { display: grid; gap: .6rem; max-width: 560px; margin: .4rem 0 .2rem; }
.identity-q > label { font-weight: 600; }
.identity-q .pair { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.set-facts { display: grid; gap: .3rem; margin: .3rem 0 0 1.2rem; }
.set-facts .q label { color: var(--muted); }
.set-facts .q-cites { display: none; }
.ask-first .pointer, .pointers .pointer { font-size: .88rem; }
.pointer.is-answered { color: var(--muted); }
.q.is-stale { opacity: .7; }
.q-note { margin: .15rem 0 0; }
.block-nav .n.warn { color: var(--warn); }
.link-set { display: flex; flex-wrap: wrap; gap: .3rem .8rem; }
.check-panel { width: 340px; position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.drawer { width: min(760px, 92vw); max-height: 85vh; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 1rem 1.4rem; }
.drawer::backdrop { background: rgba(15, 23, 42, .35); }
.report-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.report-counts { display: flex; gap: .4rem; flex-wrap: wrap; margin: .8rem 0; }
.report .missing li { margin: .2rem 0; }
.report .tabs { display: flex; gap: .4rem; margin: 1.4rem 0 .6rem; }
.report h3 { margin-top: 1.2rem; }
.report-section { margin-top: 1.4rem; }
.report-section > summary { cursor: pointer; }
.report-section > summary h2 { display: inline; font-size: 1.1rem; }
.report .gaps { columns: 2; font-size: .9rem; }
.locked { margin-top: 1rem; }
@media (max-width: 1000px) {
  .analysis-body { grid-template-columns: 1fr; }
  .block-nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .check-panel { width: auto; position: static; }
}
@media print {
  .report-view[hidden] { display: block !important; }
}

/* Printed page pane (Search) */
.tabs { display: flex; gap: .4rem; margin: .8rem 0; }
.page-view { margin: 0; }
.page-frame { position: relative; }
.page-view img { width: 100%; height: auto; border: 1px solid var(--line); display: block; }
.page-box { position: absolute; border: 2px solid var(--brand); background: rgba(37, 99, 235, .08); border-radius: 3px; pointer-events: none; }
