/* InterAsset app components. Colours and sizes come from tokens.css only. */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: var(--fs-13);
  line-height: var(--lh-body);
  color: var(--ink-2);
  background: var(--surface-2);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--blue-600); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: var(--lh-tight); color: var(--ink); }
:focus { outline: none; }
:focus-visible { box-shadow: var(--focus); border-radius: var(--r-sm); }

.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon--sm { width: 16px; height: 16px; }

/* ---- App frame --------------------------------------------------------- */
.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) auto minmax(0, 1fr);
  grid-template-areas: "top top" "banner banner" "side main";
}

/* ---- Top bar ----------------------------------------------------------- */
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 30;
}
.brand { display: inline-flex; align-items: center; flex: none; }
.brand__logo { height: 32px; width: auto; display: block; }

.search { position: relative; flex: 0 1 520px; margin: 0 auto; }
.search__icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search__input {
  width: 100%; height: 40px;
  padding: 0 16px 0 42px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  color: var(--ink);
  font-size: var(--fs-13);
  -webkit-appearance: none; appearance: none;
}
.search__input::placeholder { color: var(--muted); }
.search__input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search__input:focus-visible { border-radius: var(--r-pill); }
.search__results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-card); padding: 6px; z-index: 40; max-height: 320px; overflow: auto;
}
.search__hint { padding: 10px 12px; color: var(--muted); font-size: var(--fs-125); }
.search__item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-md); color: var(--ink); cursor: pointer; }
.search__item:hover, .search__item[aria-selected="true"] { background: var(--surface-2); }
.search__item-id { font-weight: 600; font-variant-numeric: tabular-nums; }
.search__item-meta { color: var(--muted); font-size: var(--fs-12); margin-left: auto; }

.topbar__right { display: flex; align-items: center; gap: 12px; flex: none; }
.iconbtn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-md); color: var(--ink-2);
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.iconbtn--plain { width: 32px; height: 32px; }
.user { display: inline-flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: var(--r-md); }
.user:hover { background: var(--surface-2); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--navy-900); color: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-12); font-weight: 600; letter-spacing: 0.02em;
}
.user__text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.user__name { font-size: var(--fs-125); font-weight: 600; color: var(--ink); }
.user__role { font-size: var(--fs-11); color: var(--muted); }
.user__chev { color: var(--muted); }

/* ---- Banner ------------------------------------------------------------ */
.banner {
  grid-area: banner;
  height: var(--banner-h);
  display: flex; align-items: center; justify-content: center;
  padding: 0 16px;
  background: var(--amber-100); color: var(--amber-600);
  font-size: var(--fs-125); font-weight: 500;
  border-bottom: 1px solid var(--line);
}
.banner--error { background: var(--red-100); color: var(--red-600); }

/* ---- Sidebar ----------------------------------------------------------- */
.sidebar {
  grid-area: side;
  background: var(--navy-900);
  padding: 10px 8px;
  display: flex; flex-direction: column; gap: 2px;
  overflow: hidden;
}
.nav__item {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 7px;
  border-radius: var(--r-md);
  color: var(--surface); opacity: 0.9;
  font-size: var(--fs-125); font-weight: 500; white-space: nowrap; letter-spacing: -0.005em;
  transition: background var(--t-fast);
}
.nav__item .icon { width: 18px; height: 18px; }
.nav__item:hover { background: var(--navy-700); opacity: 1; }
.nav__item.is-active { background: var(--navy-800); opacity: 1; }
.nav__item.is-active::before {
  content: ""; position: absolute; left: -8px; top: 7px; bottom: 7px; width: 3px;
  background: var(--blue-600); border-radius: 0 2px 2px 0;
}
.nav__item:focus-visible { box-shadow: 0 0 0 2px var(--navy-900), 0 0 0 4px var(--blue-600); }

/* ---- Main and views ---------------------------------------------------- */
.main { grid-area: main; position: relative; min-width: 0; min-height: 0; background: var(--surface-2); }
.view { position: absolute; inset: 0; }
.view--page { display: flex; align-items: center; justify-content: center; padding: 24px; }
.map { position: absolute; inset: 0; background: var(--bm-land); }
.map .maplibregl-canvas:focus-visible { box-shadow: none; }

/* ---- Map overlays ------------------------------------------------------ */
.map-ui { position: absolute; z-index: 5; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.map-ui--tl { top: var(--map-inset); left: var(--map-inset); }

.filtercard {
  display: flex; gap: 14px;
  padding: 10px 12px 11px;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.field { display: flex; flex-direction: column; gap: 4px; width: 118px; }
.field--wide { width: 168px; }
.field__label { font-size: var(--fs-11); font-weight: 500; color: var(--muted); line-height: 1.2; }
.field__select { position: relative; display: block; }
.select {
  width: 100%; height: 32px;
  padding: 0 26px 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
  font-size: var(--fs-125); font-weight: 500;
  -webkit-appearance: none; appearance: none;
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
}
.select:hover { border-color: var(--c-boundary); }
.field__chev { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

.mapctl { display: flex; flex-direction: column; gap: 8px; }
.mapctl__group { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-card); overflow: hidden; }
.mapctl__btn {
  width: var(--control-size); height: var(--control-size);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink); border-radius: 0;
}
.mapctl__btn + .mapctl__btn { border-top: 1px solid var(--line); }
.mapctl__btn:hover { background: var(--surface-2); }
.mapctl__btn:focus-visible { box-shadow: inset var(--focus); border-radius: var(--r-md); }

.legend {
  position: absolute; z-index: 5; left: var(--map-inset); bottom: var(--map-inset);
  min-width: 148px;
  padding: 10px 14px 10px 12px;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; gap: 9px;
  font-variant-numeric: tabular-nums;
}
.legend__row { display: flex; align-items: center; gap: 10px; font-size: var(--fs-125); color: var(--ink-2); line-height: 1.2; }
.legend__swatch { flex: none; width: 14px; height: 10px; display: inline-flex; align-items: center; justify-content: center; }
.legend__swatch--dot::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--swatch); }
.legend__swatch--bar::before { content: ""; width: 14px; height: 3px; border-radius: 2px; background: var(--swatch); }
.legend__swatch--dash::before { content: ""; width: 14px; height: 0; border-top: 2px dashed var(--swatch); }
.legend__swatch--fill::before { content: ""; width: 14px; height: 10px; border-radius: 2px; background: var(--swatch); }
.legend__swatch--hatch::before { content: ""; width: 14px; height: 10px; border-radius: 2px; background: repeating-linear-gradient(135deg, #B8C2D1 0 2px, #FFFFFF 2px 5px); border: 1px solid #B8C2D1; box-sizing: border-box; }
.legend__note { font-size: var(--fs-11); color: var(--muted); margin-top: 2px; }
.legend__group + .legend__group { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.legend__swatch--ring::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--swatch); box-sizing: border-box; }
.legend__title { font-size: var(--fs-11); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }
.legend__ramp { height: 8px; border-radius: 4px; background: var(--ramp); margin: 2px 0; }
.legend__ramp-labels { display: flex; justify-content: space-between; font-size: var(--fs-11); color: var(--muted); font-variant-numeric: tabular-nums; }
.legend__size { flex: none; width: 16px; display: inline-flex; align-items: center; justify-content: center; }
.legend__size::before { content: ""; width: var(--d); height: var(--d); border-radius: 50%; background: var(--swatch); }

.modes {
  position: absolute; z-index: 5; top: var(--map-inset); right: var(--map-inset);
  display: flex; height: 34px; padding: 3px; gap: 2px;
  background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-card);
}
.modes__btn {
  padding: 0 11px; border-radius: 6px; font-size: var(--fs-12); font-weight: 600; color: var(--muted); white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.modes__btn:hover { color: var(--ink); background: var(--surface-2); }
.modes__btn.is-active { background: var(--navy-800); color: var(--surface); }
.modes__btn:focus-visible { box-shadow: var(--focus); border-radius: 6px; }

.hovertip {
  position: absolute; z-index: 6;
  padding: 5px 9px; background: var(--navy-800); color: var(--surface);
  border-radius: var(--r-md); font-size: var(--fs-12); font-weight: 500; white-space: nowrap;
  transform: translate(12px, 12px); pointer-events: none; box-shadow: var(--shadow-card);
}
.search__dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--swatch); }
.search__item-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.tierc { margin: 14px 4px 4px; color: var(--ink-2); font-size: var(--fs-13); line-height: 1.5; }

.pintip {
  position: absolute; z-index: 6;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px 6px 8px;
  background: var(--navy-800); color: var(--surface);
  border-radius: var(--r-md); font-size: var(--fs-125); font-weight: 500;
  box-shadow: var(--shadow-card);
  transform: translate(-50%, calc(-100% - 12px));
  pointer-events: none; white-space: nowrap;
}
.pintip::after {
  content: ""; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 10px;
  background: var(--navy-800); transform: translateX(-50%) rotate(45deg); border-radius: 2px;
}

.maplibregl-ctrl-bottom-right { z-index: 4; }
.maplibregl-ctrl.maplibregl-ctrl-attrib {
  font-family: var(--font); font-size: var(--fs-11); color: var(--muted);
  background-color: var(--surface); border-radius: var(--r-sm) 0 0 0; padding: 2px 8px;
}
.maplibregl-ctrl-attrib a { color: var(--muted); }
.maplibregl-ctrl-attrib a:hover { color: var(--ink); }

/* ---- Right panel ------------------------------------------------------- */
.panel {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 10;
  width: var(--panel-w); max-width: 100%;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-panel);
  transform: translateX(100%);
  transition: transform var(--t-panel);
  visibility: hidden;
  font-variant-numeric: tabular-nums;
}
.panel.is-open { transform: translateX(0); visibility: visible; }
.panel__header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 56px; padding: 0 12px 0 18px; flex: none;
  border-bottom: 1px solid var(--line);
}
.panel__title { font-size: var(--fs-15); font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel__body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px; }
.panel__footer {
  flex: none; display: flex; gap: 10px; padding: 12px;
  background: var(--surface); border-top: 1px solid var(--line);
}
.panel__footer .btn { flex: 1 1 0; }

/* ---- Panel content ------------------------------------------------------ */
.summary {
  display: flex; gap: 14px; padding: 14px;
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
}
.summary__thumb {
  flex: none; width: 64px; height: 64px; border-radius: var(--r-md);
  background: var(--blue-100); display: flex; align-items: center; justify-content: center;
}
.summary__thumb img { width: 64px; height: 64px; display: block; border-radius: var(--r-md); }
.summary__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.summary__type { font-size: var(--fs-14); font-weight: 600; color: var(--ink); line-height: 1.25; }
.summary__status { display: flex; }
.kv { display: grid; grid-template-columns: 84px minmax(0, 1fr); column-gap: 12px; row-gap: 6px; margin-top: 4px; font-size: var(--fs-13); }
.kv__k { color: var(--muted); }
.kv__v { color: var(--ink); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.kv__v .row__value { overflow-wrap: anywhere; }

.tabs { display: flex; gap: 4px; margin: 14px 0 0; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1 1 0; height: 38px; padding: 0 4px;
  font-size: var(--fs-13); font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 0;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); font-weight: 600; border-bottom-color: var(--blue-600); }
.tab:focus-visible { border-radius: var(--r-sm); }
.tab__body { padding-top: 6px; }
.tab__empty { margin: 16px 4px; color: var(--muted); font-size: var(--fs-13); }

.rows { display: flex; flex-direction: column; }
.rows__group { padding: 4px 0; }
.rows__group + .rows__group { border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: 10px;
  min-height: 34px; padding: 0 4px;
  font-size: var(--fs-13); color: var(--ink); width: 100%; text-align: left;
}
.row__icon { color: var(--muted); }
.row__label { color: var(--muted); flex: 1 1 auto; min-width: 0; }
.row__label--stack { display: flex; flex-direction: column; line-height: 1.25; color: var(--ink); font-weight: 500; }
.row__sub { color: var(--muted); font-weight: 400; font-size: var(--fs-12); margin-top: 2px; }
.row__cell { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; flex: 0 1 auto; text-align: right; max-width: 60%; }
.row__value { font-variant-numeric: tabular-nums; }
.row__absent { color: var(--muted); font-style: italic; }
.row__aside { color: var(--muted); font-size: var(--fs-12); font-variant-numeric: tabular-nums; }
.row__chev { color: var(--muted); }
.row--wo { min-height: 46px; padding: 4px; }
.row--link { border-radius: var(--r-md); cursor: pointer; }
.row--link:hover { background: var(--surface-2); }

.badge {
  display: inline-flex; align-items: center; height: 18px; padding: 0 7px;
  border-radius: var(--r-pill); font-size: 10.5px; font-weight: 600; line-height: 1; cursor: help;
}
.badge--estimate { background: var(--amber-100); color: var(--amber-600); }

.sources { margin: 14px 4px 4px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-12); }
.sources__label { color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; font-size: var(--fs-11); }
.sources__link { color: var(--ink-2); line-height: 1.4; }
.sources__link:hover { color: var(--blue-600); }
.sources__link--extra { color: var(--muted); }

.timeline { list-style: none; margin: 8px 4px; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.timeline__item { position: relative; display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-13); }
.timeline__item::before { content: ""; position: absolute; left: -20px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue-600); border: 2px solid var(--surface); box-sizing: content-box; }
.timeline__date { color: var(--muted); font-size: var(--fs-12); font-variant-numeric: tabular-nums; }
.timeline__event { color: var(--ink); font-weight: 500; }

.table { width: 100%; border-collapse: collapse; font-size: var(--fs-13); margin-top: 8px; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: var(--fs-12); padding: 6px 4px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px 4px; border-bottom: 1px solid var(--line); color: var(--ink); }

.docs { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.docs__item { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-radius: var(--r-md); }
.docs__item:hover { background: var(--surface-2); }
.docs__icon { color: var(--blue-600); width: 20px; height: 20px; }
.docs__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.docs__name { color: var(--ink); font-weight: 500; font-size: var(--fs-13); }
.docs__meta { color: var(--muted); font-size: var(--fs-12); }
.docs__open { height: 32px; }

/* ---- Assets page ------------------------------------------------------------ */
.view--assets { display: flex; flex-direction: column; padding: 20px 24px; gap: 14px; overflow: hidden; }
.assets__header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.assets__title { font-size: var(--fs-16); font-weight: 600; }
.assets__count { margin: 2px 0 0; color: var(--muted); font-size: var(--fs-13); font-variant-numeric: tabular-nums; }
.assets__filters { display: flex; gap: 14px; padding: 10px 12px 11px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-card); }
.assets__search { padding: 0 10px; }
.assets__search::placeholder { color: var(--muted); font-weight: 400; }
.assets__body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.table__wrap { flex: 1 1 auto; min-height: 0; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.table--assets { margin: 0; }
.table--assets th { position: sticky; top: 0; background: var(--surface); z-index: 1; padding: 0; }
.table__sort { width: 100%; text-align: left; padding: 10px 12px; font-size: var(--fs-12); font-weight: 600; color: var(--muted); border-radius: 0; white-space: nowrap; }
.table__sort:hover { color: var(--ink); background: var(--surface-2); }
.table__row { cursor: pointer; }
.table__row:hover, .table__row:focus-visible { background: var(--surface-2); box-shadow: none; }
.table--assets { table-layout: fixed; min-width: 960px; }
.table--assets td { padding: 8px 10px; white-space: nowrap; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; }
.table--assets col.col-asset_id { width: 150px; }
.table--assets col.col-class { width: 130px; }
.table--assets col.col-municipality { width: 200px; }
.table--assets col.col-status { width: 110px; }
.table--assets col.col-condition { width: 110px; }
.table--assets col.col-replacement_value { width: 190px; }
.table__cell--asset_id { font-weight: 600; font-variant-numeric: tabular-nums; }
.table__cell--replacement_value, th[aria-sort] .table__sort--right { text-align: right; }
.table__cell--replacement_value .badge { margin-right: 6px; }
.table__num { font-variant-numeric: tabular-nums; }
.assets__empty { align-self: center; margin: auto; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; }
.pager__btn { height: 34px; padding: 0 12px; }
.pager__label { color: var(--muted); font-size: var(--fs-13); font-variant-numeric: tabular-nums; min-width: 110px; text-align: center; }

/* ---- Static pages (sources, record) --------------------------------------- */
/* ---- Full record page (route #record=<id>) ------------------------------ */
.view--report { overflow: auto; padding: 24px; }
.report { max-width: 760px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 28px 32px 32px; display: flex; flex-direction: column; gap: 20px; }
.report__actions { display: flex; gap: 8px; justify-content: flex-end; }
.report__header { display: flex; gap: 16px; align-items: flex-start; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.report__mark { width: 40px; height: 40px; border-radius: var(--r-md); flex: none; }
.report__head { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.report__eyebrow { font-size: var(--fs-11); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.report__title { font-size: 22px; font-weight: 700; color: var(--ink); margin: 0; line-height: 1.2; }
.report__name { font-size: var(--fs-14); color: var(--ink-2); }
.report__chips { display: flex; gap: 6px; margin-top: 4px; }
.report__thumb-icon { width: 64px; height: 64px; border-radius: var(--r-md); background: var(--blue-100); flex: none; }
.report__map { width: 100%; max-width: 640px; height: 320px; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); background: var(--bm-land); }
.report__map .maplibregl-canvas { border-radius: var(--r-md); }
.report__h2 { font-size: var(--fs-15); font-weight: 600; color: var(--ink); margin: 0 0 8px; }
.report__table { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
.report__table thead th { text-align: left; color: var(--muted); font-weight: 500; font-size: var(--fs-12); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.report__table tbody th, .report__table tbody td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
.report__table tbody th { font-weight: 500; color: var(--muted); width: 32%; }
.report__table tbody td:nth-child(2) { color: var(--ink); width: 36%; }
.report__table tbody td:nth-child(3) { color: var(--ink-2); font-size: var(--fs-12); }
.report__group th { background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: var(--fs-12); text-transform: uppercase; letter-spacing: 0.05em; padding: 8px; }
.report__basis-text { color: var(--muted); }
.report__footer { border-top: 1px solid var(--line); padding-top: 12px; font-size: var(--fs-12); color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.report__statements { margin: 0; padding-left: 18px; line-height: 1.6; }
.report .sources { margin: 0; padding: 0; }
.report .sources__label { display: none; }

@media print {
  @page { size: letter portrait; margin: 14mm; }
  html, body, .app, .main { height: auto !important; overflow: visible !important; display: block !important; background: #FFFFFF !important; }
  .topbar, .sidebar, .banner, .report__actions, .view:not(#view-record), .popover { display: none !important; }
  .view--report { position: static !important; padding: 0 !important; overflow: visible !important; }
  .report { max-width: none; border: 0; border-radius: 0; padding: 0; }
  .report__section { break-inside: avoid; }
  .report__section + .report__section { break-before: page; }
  .report__map { break-inside: avoid; }
  .badge--estimate { border: 1px solid var(--amber-600); }
  a { color: inherit; text-decoration: none; }
}

/* ---- Static pages (sources.html) ----------------------------------------- */
.page { background: var(--surface-2); overflow: auto; }
.page__main--wide { max-width: 880px; }
.page__foot { margin: 0; color: var(--muted); font-size: var(--fs-12); }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 20px; }
.note__title { font-size: var(--fs-14); font-weight: 600; margin: 0 0 6px; }
.note p { margin: 0; color: var(--ink-2); font-size: var(--fs-13); line-height: 1.6; max-width: 80ch; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; width: 100%; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.card[data-status="unused"] { opacity: 0.72; }
.card__title { font-size: var(--fs-14); font-weight: 600; margin: 0; line-height: 1.3; }
.card__meta { margin: 0; color: var(--ink-2); font-size: var(--fs-13); }
.card__status { margin: 2px 0 0; font-size: var(--fs-12); font-weight: 600; color: var(--blue-700); }
.card[data-status="unused"] .card__status { color: var(--muted); }
.card__statement { margin: 4px 0 0; font-size: var(--fs-12); color: var(--ink); }
.card__note, .card__facts { margin: 2px 0 0; font-size: var(--fs-12); color: var(--muted); line-height: 1.5; }
.card__link { font-size: var(--fs-12); color: var(--blue-600); overflow-wrap: anywhere; margin-top: 4px; }
.page__main { max-width: 720px; margin: 0 auto; padding: 40px 24px 64px; display: flex; flex-direction: column; gap: 16px; align-items: flex-start; }
.page__title { font-size: 24px; font-weight: 700; margin-top: 8px; }
.page__lead { margin: 0; color: var(--ink-2); font-size: var(--fs-14); max-width: 60ch; }
.page__list { margin: 0; padding-left: 20px; color: var(--ink-2); font-size: var(--fs-13); line-height: 1.7; }

/* ---- Buttons and chips ------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: var(--r-md);
  font-size: var(--fs-13); font-weight: 600; white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.btn--primary { background: var(--blue-600); color: var(--surface); }
.btn--primary:hover { background: var(--blue-700); }
.btn--secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn--secondary:hover { background: var(--surface-2); }
.btn--ghost { color: var(--blue-600); padding: 0 8px; }
.btn--ghost:hover { background: var(--blue-100); }
.btn:focus-visible { border-radius: var(--r-md); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.chip--unknown, .chip--abandoned { background: var(--grey-chip-bg); color: var(--grey-chip-fg); }

.chip {
  display: inline-flex; align-items: center; height: 22px; padding: 0 10px;
  border-radius: var(--r-pill); font-size: 11.5px; font-weight: 600; line-height: 1;
  background: var(--grey-chip-bg); color: var(--grey-chip-fg);
}
.chip--good, .chip--in_service, .chip--very_good { background: var(--green-100); color: var(--green-600); }
.chip--fair { background: var(--amber-100); color: var(--amber-600); }
.chip--poor, .chip--very_poor { background: var(--red-100); color: var(--red-600); }
.chip--planned { background: var(--blue-100); color: var(--blue-700); }

/* ---- Empty states ------------------------------------------------------ */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; max-width: 400px; }
.empty__icon {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--blue-100); color: var(--blue-600);
  display: inline-flex; align-items: center; justify-content: center; margin-bottom: 4px;
}
.empty__icon .icon { width: 22px; height: 22px; }
.empty__title { font-size: var(--fs-16); font-weight: 600; }
.empty__text { margin: 0; color: var(--muted); font-size: var(--fs-13); }

/* ---- Popover ----------------------------------------------------------- */
.popover {
  position: fixed; z-index: 50;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 200px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.popover__title { font-size: var(--fs-125); font-weight: 600; color: var(--ink); }
.popover__text { font-size: var(--fs-12); color: var(--muted); }

/* ---- Mobile hooks: inert on desktop -------------------------------------- */
.topbar__search-toggle, .filters-toggle, .filtercard__head, .legend-toggle, .panel__handle { display: none; }

/* ---- Mobile (P6, spec section 3): media queries only, desktop untouched ---- */
@media (max-width: 767px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--topbar-h) auto minmax(0, 1fr) 56px; grid-template-areas: "top" "banner" "main" "side"; }

  /* Top bar: mark, search icon that expands the field, avatar. */
  .topbar { padding: 0 10px 0 12px; gap: 8px; }
  .search { display: none; }
  .topbar.is-searching .search { display: block; flex: 1 1 auto; }
  .topbar.is-searching .brand, .topbar.is-searching .topbar__search-toggle, .topbar.is-searching #btn-bell, .topbar.is-searching .user { display: none; }
  .topbar__search-toggle { display: inline-flex; }
  .user__text, .user__chev { display: none; }
  .user { padding: 2px; }

  /* Sidebar becomes a bottom tab bar with the five icons. */
  .sidebar { grid-area: side; flex-direction: row; justify-content: space-around; align-items: stretch; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); gap: 0; border-top: 1px solid var(--navy-700); }
  .nav__item { flex: 1 1 0; flex-direction: column; justify-content: center; gap: 2px; height: auto; padding: 4px 2px; font-size: 10px; letter-spacing: 0; border-radius: var(--r-md); }
  .nav__item .icon { width: 20px; height: 20px; }
  .nav__item.is-active::before { left: 12px; right: 12px; top: 0; bottom: auto; width: auto; height: 2px; border-radius: 0 0 2px 2px; }

  /* Filter card becomes a Filters button that opens a sheet. */
  .view--map { overflow: hidden; }
  .map-ui--tl { top: var(--map-inset); left: var(--map-inset); right: var(--map-inset); pointer-events: none; z-index: 12; }
  .map-ui--tl > * { pointer-events: auto; }
  .filters-toggle { display: inline-flex; height: 36px; padding: 0 12px; font-size: var(--fs-125); box-shadow: var(--shadow-card); border: 0; }
  .filtercard { display: none; position: fixed; left: 0; right: 0; bottom: 56px; z-index: 12; flex-direction: column; gap: 10px; padding: 8px 16px 18px; border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-panel); }
  .filtercard.is-open { display: flex; }
  .filtercard__head { display: flex; align-items: center; justify-content: space-between; height: 40px; }
  .filtercard__title { font-size: var(--fs-15); font-weight: 600; color: var(--ink); }
  .field, .field--wide { width: 100%; }
  .mapctl { position: absolute; right: 0; top: 0; flex-direction: row; gap: 6px; }
  .mapctl__group { flex-direction: row; }
  .mapctl__btn { width: 36px; height: 36px; }

  /* Modes: a scrollable strip under the top bar on the right. */
  .modes { top: calc(var(--map-inset) + 46px); left: var(--map-inset); right: var(--map-inset); max-width: none; overflow-x: auto; scrollbar-width: none; }
  .modes::-webkit-scrollbar { display: none; }
  .modes__btn { padding: 0 10px; }

  /* Legend collapses to a button. */
  /* Legend button sits beside Filters at the top so it stays reachable while the sheet is open; the card drops down. */
  .legend-toggle { display: inline-flex; position: absolute; z-index: 12; left: calc(var(--map-inset) + 104px); top: var(--map-inset); height: 36px; padding: 0 12px; font-size: var(--fs-125); box-shadow: var(--shadow-card); border: 0; }
  .legend { display: none; z-index: 12; top: calc(var(--map-inset) + 44px); bottom: auto; max-width: calc(100vw - 24px); max-height: 55vh; overflow: auto; }
  .legend.is-open:not([hidden]) { display: flex; }
  .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib { font-size: 10px; max-width: 60vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* Attribution stays visible above the sheet (peek, half); at full no map is visible. */
  body.panel-open[data-sheet="peek"] .maplibregl-ctrl-bottom-right { bottom: calc(min(300px, 42%) + 2px); }
  body.panel-open[data-sheet="half"] .maplibregl-ctrl-bottom-right { bottom: calc(50% + 2px); }
  body.panel-open[data-sheet="full"] .maplibregl-ctrl-bottom-right { display: none; }

  /* Right panel becomes a bottom sheet with peek, half and full snap points. */
  /* The sheet is sized by its top edge (never translated), so it always ends at the map's bottom edge above the tab bar. */
  .panel { top: 100%; left: 0; right: 0; bottom: 0; width: auto; max-width: none; border-left: 0; border-top: 1px solid var(--line); border-radius: var(--r-lg) var(--r-lg) 0 0; transform: none; transition: top var(--t-panel); }
  .panel.is-open { transform: none; }
  .panel.is-open[data-snap="peek"] { top: calc(100% - min(300px, 42%)); }
  .panel.is-open[data-snap="half"] { top: 50%; }
  .panel.is-open[data-snap="full"] { top: 0; }
  .panel__handle { display: flex; justify-content: center; padding: 8px 0 2px; touch-action: none; cursor: grab; }
  .panel__handle span { width: 40px; height: 4px; border-radius: 2px; background: var(--line); }
  .panel__header { height: 48px; padding: 0 8px 0 16px; touch-action: none; }
  .panel__footer { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .pintip { max-width: 70vw; }
  .hovertip { display: none; }

  /* Assets page and record page. */
  .assets__header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .assets__filters { flex-wrap: wrap; }
  .view--report { padding: 12px; }
  .report { padding: 18px 16px 24px; }
  .report__header { flex-wrap: wrap; }
  .report__map { height: 220px; }
}
