/*
 * BML parts (layer 3 of the design system). Built only from the roles in theme.css.
 * Every part here is shown on /design-system/. Rules for using them: docs/features/design-system.md.
 *
 * Look: calm and minimal. Solid white cards on a soft grey page.
 * Glass is kept for things that float over content: the top bar, labels on photos, the action bar.
 */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }  /* a part's own display never un-hides it */
body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  font: var(--text-md) / var(--leading-md) var(--font-body);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3 { margin: 0; font-family: var(--font-title); letter-spacing: var(--title-tracking); text-wrap: balance; }
h1 { font-size: var(--text-2xl); line-height: var(--leading-2xl); font-weight: var(--title-weight); }
h2 { font-size: var(--text-xl); line-height: var(--leading-xl); font-weight: var(--title-weight); }
h3 { font-size: var(--text-lg); line-height: var(--leading-lg); font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--action-link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus-border); outline-offset: 2px; }
.muted { color: var(--text-secondary); }
.label { font-size: var(--text-sm); line-height: var(--leading-sm); font-weight: 500; color: var(--text-secondary); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Top bar (glass: content scrolls under it) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: 0 0.5px 0 var(--border-strong);
}
.topbar__inner {
  height: 60px;
  padding: 0 var(--page-gutter);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.topbar__brand { display: flex; align-items: center; gap: var(--space-3); color: var(--text-primary); }
.topbar__brand:hover { text-decoration: none; }
.topbar__brand img { height: 24px; display: block; }
.topbar__app { font-weight: 600; font-size: var(--text-md); padding-left: var(--space-3); border-left: 1px solid var(--border-strong); }
.topbar__nav { margin-left: auto; display: flex; align-items: center; gap: var(--space-1); }
.topbar__link, .topbar__form button {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font: 500 var(--text-sm) / var(--leading-sm) var(--font-body);
  background: none;
  border: 0;
  cursor: pointer;
  transition: background var(--motion-fast), color var(--motion-fast);
}
.topbar__link:hover, .topbar__form button:hover { color: var(--text-primary); background: var(--bg-control); text-decoration: none; }
.topbar__link[aria-current="page"] { color: var(--text-primary); background: var(--bg-control); }
.topbar__form { margin: 0; }

/* ---------- Page layout: full width, only the side margin (screen rules 13 and 14) ---------- */
.page { padding: var(--space-8) var(--page-gutter) var(--space-14); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3) var(--space-4); flex-wrap: wrap; min-height: 40px; margin-bottom: var(--space-6); }
.page-head:has(.page-head__back) { align-items: flex-end; }
/* Totals beside the title ("20 homes £20k rent") sit with it, the buttons stay at the right */
.page-head > h1 + .totals, .page-head > h1 + p { margin-right: auto; }
.page-head__text { display: grid; gap: var(--space-1); min-width: 0; }
.page-head__back { font-size: var(--text-sm); font-weight: 500; }
.page-head__actions, .item-head__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
/* Buttons at the top of a page share one height: the main one is the screen's next step, last in the row */
.page-head__actions .btn, .item-head__actions .btn { height: 36px; padding: 0 var(--space-4); font-size: var(--text-sm); }
.page-head__actions .btn--plain, .item-head__actions .btn--plain { padding: 0 var(--space-2); }
/* A page head followed by an area's section row or tabs sits closer to it */
.page-head:has(+ .subnav), .page-head:has(+ .tabs) { margin-bottom: var(--space-4); }

/* An area's own screens (Maintenance: Jobs, Triage…): one underline row under the title, like a record's tabs.
   {% subnav "area" %}, common/navigation.py register_section. Filters under it are pills (.segmented) */
.subnav { display: flex; gap: var(--space-1); margin-bottom: var(--space-6); border-bottom: 1px solid var(--border-strong); overflow-x: auto; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav__item {
  display: inline-flex; align-items: center; gap: var(--space-2); flex: none;
  padding: var(--space-3) var(--space-4); margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary); font-weight: 500; white-space: nowrap;
}
.subnav__item:first-child { padding-left: 0; }
.subnav__item:hover { color: var(--text-primary); text-decoration: none; }
.subnav__item[aria-current="page"] { color: var(--text-primary); border-bottom-color: var(--action-bg); }
/* A row that scrolls sideways fades at the edge that has more (static/js/rows.js) */
.scroll-row--more-end { -webkit-mask-image: linear-gradient(to right, black calc(100% - 40px), transparent); mask-image: linear-gradient(to right, black calc(100% - 40px), transparent); }
.scroll-row--more-start { -webkit-mask-image: linear-gradient(to left, black calc(100% - 40px), transparent); mask-image: linear-gradient(to left, black calc(100% - 40px), transparent); }
.scroll-row--more-start.scroll-row--more-end { -webkit-mask-image: linear-gradient(to right, transparent, black 40px, black calc(100% - 40px), transparent); mask-image: linear-gradient(to right, transparent, black 40px, black calc(100% - 40px), transparent); }
/* Tabs inside an area's screen (Insights: Repeats, Spend…) are pills, so two underline rows never stack */
.subnav ~ .tabs > .tabs__nav { display: inline-flex; max-width: 100%; gap: 2px; padding: 3px; border: 0; border-radius: var(--radius-pill); background: var(--bg-control); }
.subnav ~ .tabs > .tabs__nav .tabs__tab { padding: 6px var(--space-4); margin: 0; border: 0; border-radius: var(--radius-pill); font-size: var(--text-sm); }
.subnav ~ .tabs > .tabs__nav .tabs__tab[aria-selected="true"] { background: var(--bg-card); }

/* "More": the actions a record needs now and then (Withdraw, Cancel job), behind one small button */
.more { position: relative; }
.more > summary { list-style: none; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-pill); background: var(--bg-control); color: var(--text-primary); cursor: pointer; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary:hover { background: var(--bg-control-hover); }
.more__menu {
  position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; display: grid; min-width: 180px; padding: var(--space-1);
  border-radius: var(--radius-md); background: var(--bg-card); box-shadow: var(--shadow-3), inset 0 0 0 1px var(--border);
}
.more__menu form { margin: 0; }
.more__menu a, .more__menu button {
  display: flex; align-items: center; width: 100%; height: 36px; padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text-primary); font: 500 var(--text-sm) / 1 var(--font-body); text-align: left; white-space: nowrap; cursor: pointer;
}
.more__menu a:hover, .more__menu button:hover { background: var(--bg-control); text-decoration: none; }
.more__menu .is-danger { color: var(--status-danger); }
.stack { display: grid; gap: var(--space-6); align-content: start; }
.stack-sm { display: grid; gap: var(--space-3); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
/* Two equal columns side by side (notes | drop zone, documents | photos). One column below 960px */
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6); align-items: start; }
.split--stretch { align-items: stretch; }
/* Wide content beside a narrower column (facts | checklist). One column below 960px */
.split--wide { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* Top of an item page (listing): main photo, what it is, the main action. Always visible above the tabs */
.item-top { display: grid; grid-template-columns: 240px minmax(0, 1fr) auto; gap: var(--space-6); align-items: start; margin-bottom: var(--space-6); }
.item-top__photo { position: relative; display: block; aspect-ratio: 4 / 3; border-radius: var(--radius-md); overflow: hidden; background: var(--bg-control); }
.item-top__photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.item-top__photo .home-card__empty { font-size: var(--text-sm); }
.item-top__count {
  position: absolute; right: var(--space-2); bottom: var(--space-2);
  padding: 3px 10px; border-radius: var(--radius-pill);
  background: var(--glass-bg); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-edge); font-size: var(--text-xs); font-weight: 600; color: var(--text-primary);
}
.item-top__info { display: grid; gap: var(--space-2); min-width: 0; }
.item-top__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; justify-content: flex-end; }
.item-top__actions .btn { height: 36px; padding: 0 var(--space-4); font-size: var(--text-sm); }

/* Tabs: long pages use tabs, not scrolling (static/js/tabs.js). Without JavaScript every panel shows */
.tabs__nav { display: flex; gap: var(--space-1); margin-bottom: var(--space-6); border-bottom: 1px solid var(--border-strong); overflow-x: auto; scrollbar-width: none; }
/* More tabs than fit: the row scrolls sideways and fades at the edge that has more (tabs.js sets the classes) */
.tabs__nav--more-end { -webkit-mask-image: linear-gradient(to right, black calc(100% - 56px), transparent); mask-image: linear-gradient(to right, black calc(100% - 56px), transparent); }
.tabs__nav--more-start { -webkit-mask-image: linear-gradient(to left, black calc(100% - 56px), transparent); mask-image: linear-gradient(to left, black calc(100% - 56px), transparent); }
.tabs__nav--more-start.tabs__nav--more-end { -webkit-mask-image: linear-gradient(to right, transparent, black 56px, black calc(100% - 56px), transparent); mask-image: linear-gradient(to right, transparent, black 56px, black calc(100% - 56px), transparent); }
.tabs:not(.tabs--js) .tabs__nav { display: none; }
.tabs:not(.tabs--js) .tabs__panel + .tabs__panel { margin-top: var(--space-6); }
.tabs__tab {
  display: inline-flex; align-items: center; gap: var(--space-2); flex: none;
  padding: var(--space-3) var(--space-4); margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary); font-weight: 500; white-space: nowrap;
}
.tabs__tab:first-child { padding-left: 0; }
.tabs__tab:hover { color: var(--text-primary); text-decoration: none; }
.tabs__tab[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--action-bg); }
.tabs__badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--status-warning-bg); color: var(--text-primary); font-size: var(--text-xs); font-weight: 600; font-variant-numeric: tabular-nums; }
.tabs__badge:empty { display: none; }
.tabs__tab .spinner { margin-top: 0; width: 12px; height: 12px; }

/* Edit in place: click a value to edit it there; saves on its own (static/js/inline-edit.js) */
.inline-edit { cursor: text; border-radius: 6px; transition: background var(--motion-fast), box-shadow var(--motion-fast); }
.inline-edit:hover { background: var(--action-tint); box-shadow: 0 0 0 4px var(--action-tint); }
.inline-edit--open, .inline-edit--open:hover { cursor: auto; background: none; box-shadow: none; }
.inline-edit--saving { opacity: 0.6; pointer-events: none; }
.inline-edit--saved::after { content: "\00a0\2713\00a0Saved"; font-size: var(--text-xs); font-weight: 500; color: var(--status-success); white-space: nowrap; }
/* "Last changed by X at hh:mm" beside a value for 5 seconds (inline-edit.js, common/concurrency.py) */
.inline-note { margin-left: var(--space-2); font-size: var(--text-xs); font-weight: 500; color: var(--text-secondary); white-space: nowrap; }
.inline-edit__empty { color: var(--text-tertiary); font-weight: 400; }
/* A notes block (prose edited in place) sits in a soft box, so an empty one reads as a place to write */
.prose.inline-edit { padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-card); }
.prose.inline-edit:hover { background: var(--bg-card); border-color: var(--border-strong); box-shadow: none; }
.prose.inline-edit--open, .prose.inline-edit--open:hover { padding: 0; border-color: transparent; background: none; }
.inline-edit__editor { display: grid; gap: var(--space-2); margin: 0; text-align: left; font-weight: 400; }
.inline-edit__editor .field input, .inline-edit__editor .field select { height: 36px; }

/* ---------- Buttons: round pills ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-5);
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--action-bg);
  color: var(--action-text);
  font: 600 var(--text-md) / 1 var(--font-body);
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--motion-fast), transform var(--motion-fast), box-shadow var(--motion-fast);
}
.btn:hover { background: var(--action-bg-hover); color: var(--action-text); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn--secondary { background: var(--bg-control); color: var(--text-primary); }
.btn--secondary:hover { background: var(--bg-control-hover); color: var(--text-primary); }
.btn--plain { background: none; color: var(--action-link); padding: 0 var(--space-2); }
.btn--plain:hover { background: var(--action-tint); color: var(--action-link); }
.btn--danger { background: none; color: var(--status-danger); }
.btn--danger:hover { background: var(--status-danger-bg); color: var(--status-danger); }
.btn--sm { height: 32px; padding: 0 var(--space-4); font-size: var(--text-sm); }
.btn--block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px var(--border);  /* a border, never a border and a shadow */
  padding: var(--space-6);
}
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.card__sub { margin-top: calc(-1 * var(--space-3)); margin-bottom: var(--space-4); }

/* ---------- Forms ---------- */
/* Fields in a grid that fills the width; a few fields stretch to share the row. One column on phones */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-4); align-items: start; }
.form-grid--wide { grid-column: 1 / -1; }
.form-grid > .btn { height: 44px; justify-self: start; }  /* a button in a row of fields lines up with the boxes, at its own size */
.form-grid > .field--check { align-self: end; }  /* a tick box lines up with the boxes beside it, not their labels */
.field { display: grid; gap: 6px; align-content: start; }
.field > label { font-size: var(--text-sm); line-height: var(--leading-sm); font-weight: 500; color: var(--text-primary); }
.field input, .field select, .field textarea {
  width: 100%;
  height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font: var(--text-md) var(--font-body);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}
.field textarea { height: auto; min-height: calc(3lh + 2 * var(--space-3) + 2px); padding: var(--space-3); line-height: var(--leading-md); resize: vertical; field-sizing: content; }  /* starts at 3 lines, grows as you type */
.field select { appearance: none; background-image: var(--select-arrow); background-position: right var(--space-3) center; background-size: 12px 12px; background-repeat: no-repeat; padding-right: var(--space-8); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--focus-border); box-shadow: 0 0 0 3px var(--focus-ring); }
.field__help { font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--text-secondary); }
.field__error { font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--status-danger); }
.field--error input, .field--error select, .field--error textarea { border-color: var(--status-danger); }
.field--check > label { display: flex; align-items: center; gap: var(--space-3); height: 44px; font-weight: 500; cursor: pointer; }
.field--check input { width: 20px; height: 20px; margin: 0; accent-color: var(--action-bg); }
input[type="file"] { height: auto; padding: 0; border: 0; font-size: var(--text-sm); color: var(--text-secondary); }
input[type="file"]::file-selector-button {
  height: 32px; margin-right: var(--space-3); padding: 0 var(--space-4);
  border: 0; border-radius: var(--radius-pill);
  background: var(--bg-control); color: var(--text-primary);
  font: 600 var(--text-sm) var(--font-body); cursor: pointer;
}
.dropzone {
  display: grid; place-items: center; gap: var(--space-3);
  padding: var(--space-6) var(--space-4);
  position: relative;
  cursor: pointer;
  color: var(--text-secondary);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  text-align: center;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--action-bg); outline: none; }
.dropzone__input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }  /* the whole zone opens the picker */
.dropzone--over { border-color: var(--action-bg); background: var(--action-tint); }
.dropzone--sending { pointer-events: none; opacity: 0.6; }  /* uploading after a drop (autosubmit) */
.dropzone__files { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-secondary); }
.dropzone__files:empty { display: none; }
.dropzone__files li { display: inline-flex; align-items: center; gap: var(--space-1); padding: var(--space-1) var(--space-1) var(--space-1) var(--space-3); border-radius: var(--radius-pill); background: var(--bg-card); color: var(--text-primary); cursor: default; }
.dropzone__files button { width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--text-secondary); font: inherit; line-height: 1; cursor: pointer; }
.dropzone__files button:hover { background: var(--bg-control); color: var(--text-primary); }

/* Address lookup (lettings/_address.html): one box, Royal Mail suggestions underneath */
.address-lookup { display: grid; gap: var(--space-2); }
.address-lookup--js .address-lookup__manual:not([data-open]) { display: none; }
.address-lookup__manual-link { justify-self: start; }
.address-lookup__box { position: relative; }
.address-lookup__list {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 320px; overflow-y: auto; margin: 0; padding: var(--space-1); list-style: none;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg-card); box-shadow: var(--shadow-3);
}
.address-lookup__option { display: flex; flex-wrap: wrap; gap: 0 var(--space-2); padding: var(--space-2) var(--space-3); border-radius: 6px; cursor: pointer; }
.address-lookup__option span { color: var(--text-secondary); }
.address-lookup__option:hover, .address-lookup__option[aria-selected="true"] { background: var(--action-tint); }
.address-lookup__option--more span::after { content: " \203A"; }
.address-lookup__none { padding: var(--space-2) var(--space-3); color: var(--text-secondary); }

/* Action bar: sticks to the bottom of the screen on long forms (glass: content scrolls under it) */
.action-bar {
  position: sticky;
  bottom: var(--space-4);
  z-index: 10;
  display: flex; gap: var(--space-2); justify-content: flex-end; flex-wrap: wrap;
  padding: var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-3), var(--glass-edge);
}

/* ---------- Rows: label on the left, value on the right (like iPhone Settings) ---------- */
.rows { margin: 0; display: grid; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); padding: var(--space-2) 0; border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; padding-top: 0; }
.row:last-child { padding-bottom: 0; }
.row dt { color: var(--text-secondary); }
.row dd { margin: 0; font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
/* Many facts: rows flow into columns that fill the width */
.rows--cols { display: block; columns: 2 300px; column-gap: var(--space-10); }
.rows--cols .row, .rows--cols .row:first-child, .rows--cols .row:last-child { break-inside: avoid; border-top: 0; border-bottom: 1px solid var(--border); padding: var(--space-2) 0; }

/* ---------- Status: coloured dot + word ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); line-height: var(--leading-sm); font-weight: 500; color: var(--text-primary); white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--status-neutral); }
.status--draft::before { background: var(--status-neutral); }
.status--ready::before { background: var(--status-warning); }
.status--live::before { background: var(--status-success); box-shadow: 0 0 0 3px var(--status-success-bg); }
.status--let::before { background: var(--status-info); }
.status--withdrawn::before { background: var(--status-danger); }

/* ---------- Segmented control (filters, view switch) ---------- */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: var(--radius-pill); background: var(--bg-control); }
.segmented > a, .segmented > button {
  padding: 6px var(--space-4);
  border: 0; border-radius: var(--radius-pill); background: none;
  color: var(--text-secondary);
  font: 500 var(--text-sm) / var(--leading-sm) var(--font-body);
  cursor: pointer;
  transition: background var(--motion-fast), color var(--motion-fast);
}
.segmented > a:hover, .segmented > button:hover { color: var(--text-primary); text-decoration: none; }
.segmented > [aria-current="page"], .segmented > [aria-pressed="true"] { background: var(--bg-card); color: var(--text-primary); }  /* a white chip on the grey track, no shadow */
.segmented__count { margin-left: 4px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }

/* ---------- Stepper: Draft → Ready → Live → Let ---------- */
.stepper { display: flex; list-style: none; margin: 0; padding: 0; gap: var(--space-2); }
.stepper__item { flex: 1; display: grid; gap: var(--space-2); font-size: var(--text-sm); line-height: var(--leading-sm); font-weight: 500; color: var(--text-tertiary); }
.stepper__item::before { content: ""; height: 4px; border-radius: var(--radius-pill); background: var(--bg-control); }
.stepper__item--done { color: var(--text-secondary); }
.stepper__item--done::before { background: var(--brand); }
.stepper__item--current { color: var(--text-primary); font-weight: 600; }
.stepper__item--current::before { background: linear-gradient(90deg, var(--brand) 50%, var(--bg-control) 50%); }

/* ---------- Banners (messages, AI status) ---------- */
.banner { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--status-info-bg); font-size: var(--text-sm); line-height: var(--leading-md); }
.banner--success { background: var(--status-success-bg); }
.banner--warning { background: var(--status-warning-bg); }
.banner--error { background: var(--status-danger-bg); }
.messages { display: grid; gap: var(--space-2); margin-bottom: var(--space-6); }

/* ---------- Property cards (list page) ---------- */
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-6); }
.home-card { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); min-width: 0; color: var(--text-primary); }
.home-card:hover { text-decoration: none; }
.home-card__media { position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius-md); overflow: hidden; background: var(--bg-control); transition: box-shadow var(--motion-fast), transform var(--motion-fast); }
.home-card:hover .home-card__media { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.home-card__media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.home-card__empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-tertiary); font-size: var(--text-sm); }
.home-card__tag {
  position: absolute; top: var(--space-3); left: var(--space-3);
  padding: 5px 10px; border-radius: var(--radius-pill);
  background: var(--glass-bg); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-edge);
}
.home-card__body { display: grid; gap: 2px; padding: 0 var(--space-1); }
.home-card__top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); min-width: 0; }
.home-card__title { font-weight: 600; font-size: var(--text-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-card__price { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.home-card__meta { font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Price ---------- */
.price { display: flex; align-items: baseline; gap: var(--space-2); }
.price__amount { font-family: var(--font-title); font-size: var(--text-2xl); line-height: var(--leading-2xl); font-weight: var(--title-weight); letter-spacing: var(--title-tracking); font-variant-numeric: tabular-nums; }

/* ---------- Lists ---------- */
.ticks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-2) var(--space-6); }
.ticks li { display: flex; gap: var(--space-2); align-items: baseline; }
.ticks li::before { content: "✓"; color: var(--action-link); font-weight: 700; }
.todo { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); font-size: var(--text-sm); line-height: var(--leading-sm); }
.todo li { display: flex; gap: var(--space-3); align-items: flex-start; }
.todo li::before { content: ""; flex: none; width: 14px; height: 14px; margin-top: 2px; border-radius: 50%; border: 1.5px solid var(--status-warning); }
.prose p + p { margin-top: var(--space-3); }
.prose { color: var(--text-primary); }

/* AI questions: a soft call-out */
.callout { padding: var(--space-4); border-radius: var(--radius-sm); background: var(--status-warning-bg); display: grid; gap: var(--space-2); font-size: var(--text-sm); line-height: var(--leading-md); }
.callout ul { margin: 0; padding-left: var(--space-5); }
.callout__items { list-style: none; display: grid; gap: var(--space-1); }
.callout ul.callout__items { padding: 0; }
.callout__items li { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); min-height: 32px; }

/* ---------- Brand parts from the tenant posters (docs/business/brand.md) ---------- */
/* Info tiles: grouped information on soft logo-colour tints. Use only where the groups help (the listing checklist) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-3); }
.tile { --tile-bg: var(--tile-1-bg); --tile-ink: var(--tile-1-ink); padding: var(--space-4); border-radius: var(--radius-md); background: var(--tile-bg); }
.tile--2 { --tile-bg: var(--tile-2-bg); --tile-ink: var(--tile-2-ink); }
.tile--3 { --tile-bg: var(--tile-3-bg); --tile-ink: var(--tile-3-ink); }
.tile--4 { --tile-bg: var(--tile-4-bg); --tile-ink: var(--tile-4-ink); }
.tile .todo li::before { border-color: var(--tile-ink); }
.tile .ticks li::before { color: var(--tile-ink); }
/* Kicker: small tracked uppercase label above a title */
.kicker { font-size: var(--label-size); line-height: var(--leading-xs); font-weight: var(--label-weight); letter-spacing: var(--label-tracking); text-transform: uppercase; color: var(--label-colour); }
/* Dark panel: a big number on dark slate */
.panel-dark { display: grid; gap: var(--space-1); padding: var(--space-5) var(--space-6); border-radius: var(--radius-md); background: var(--bg-inverse); color: var(--text-inverse); }
.panel-dark strong { font-family: var(--font-title); font-size: var(--text-2xl); line-height: var(--leading-2xl); font-weight: var(--title-weight); letter-spacing: var(--title-tracking); }
/* Document-type pill: PDFs only (common/pdf.py); shown here for reference */
.doc-pill { display: inline-block; padding: 6px var(--space-4); border-radius: var(--radius-sm); background: var(--bg-inverse); color: var(--text-inverse); font-size: var(--label-size); font-weight: var(--label-weight); letter-spacing: var(--label-tracking); text-transform: uppercase; }

/* ---------- Photo thumbnails (manage photos) ---------- */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--space-3); }
.thumb { position: relative; margin: 0; aspect-ratio: 4 / 3; border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-control); }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb__remove { position: absolute; top: var(--space-1); right: var(--space-1); opacity: 0; transition: opacity var(--motion-fast); }
.thumb__remove button { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; background: var(--glass-bg); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); color: var(--text-primary); font-size: var(--text-md); cursor: pointer; }
.thumb:hover .thumb__remove, .thumb__remove:focus-within { opacity: 1; }
/* Found online (lettings/_found.html, _suggestions.html, _found_images.html) */
.found { margin: 0; padding-left: var(--space-4); display: grid; gap: var(--space-2); }
.suggestion__actions { flex: none; gap: var(--space-1); }
.thumb--online figcaption { position: absolute; left: var(--space-1); bottom: var(--space-1); gap: var(--space-1); }
.thumb--online .btn--plain { background: var(--glass-bg); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); background: var(--bg-card); box-shadow: inset 0 0 0 1px var(--border); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-md); }
.table th { text-align: left; padding: var(--space-3) var(--space-4); font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); border-bottom: 1px solid var(--border); }
.table td { padding: 10px var(--space-4); border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--bg-subtle); }

/* ---------- Empty state, spinner ---------- */
.empty { display: grid; justify-items: center; gap: var(--space-3); padding: var(--space-10) var(--space-6); text-align: center; color: var(--text-secondary); }
.empty[hidden] { display: none; }  /* "Nothing found" under a list stays hidden until the search empties it (lists.js) */
.empty p { max-width: 42ch; color: var(--text-secondary); }
.spinner { flex: none; width: 16px; height: 16px; margin-top: 3px; border-radius: 50%; border: 2px solid var(--focus-ring); border-top-color: var(--action-bg); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.is-busy { gap: var(--space-2); cursor: progress; opacity: 1; }
.btn.is-busy .spinner { width: 12px; height: 12px; margin-top: 0; }

/* ---------- Design system page only ---------- */
.ds-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-3); }
.ds-swatch { display: grid; gap: var(--space-2); font-size: var(--text-sm); line-height: var(--leading-sm); }
.ds-swatch__fill { height: 56px; border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--border); }
.ds-swatch code { color: var(--text-secondary); font-size: var(--text-xs); }
.ds-scale { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-end; }
.ds-box { display: grid; gap: var(--space-2); justify-items: center; font-size: var(--text-xs); color: var(--text-secondary); }
.ds-box > span:first-child { display: block; width: 56px; height: 56px; background: var(--action-tint); box-shadow: inset 0 0 0 1px var(--focus-ring); }
.ds-rules { margin: 0; padding-left: var(--space-5); display: grid; gap: var(--space-2); }

/* ---------- Small screens ---------- */
@media (max-width: 960px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .item-top { grid-template-columns: 112px minmax(0, 1fr); gap: var(--space-4); }
  .item-top__actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 640px) {
  .topbar__app { display: none; }
  .segmented { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .segmented::-webkit-scrollbar { display: none; }
  .segmented > a, .segmented > button { flex: none; white-space: nowrap; }
  .page-head { align-items: flex-start; }
  .page-head__actions { width: 100%; }
  .page-head__actions--tools { width: auto; }  /* only the pin and Views: they stay beside the title */
  .page-head__actions .btn:not(.btn--plain):not(.btn--secondary):last-child { margin-left: auto; }
  .page { padding-top: var(--space-6); padding-bottom: var(--space-10); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid > .btn { justify-self: stretch; }
  .card { padding: var(--space-5); }
  h1 { font-size: var(--text-xl); line-height: var(--leading-xl); }
  .action-bar { border-radius: var(--radius-md); }
  .action-bar .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Documents: one row per file, grouped under a small category heading */
.docs { display: grid; gap: var(--space-5); }
.docs__group { display: grid; }
.docs__group h3 { font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--text-secondary); margin-bottom: var(--space-1); }
.doc { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-1) var(--space-4); padding: var(--space-3) 0; border-top: 1px solid var(--border); }
.docs__group > .doc:last-child { padding-bottom: 0; }
.doc__name { font-weight: 500; overflow-wrap: anywhere; }
.doc__name::after { content: ""; position: absolute; inset: 0; }  /* the whole row opens the file */
.doc__actions, .doc__summary, .doc__meta a { position: relative; z-index: 1; }
.doc__meta { font-size: var(--text-sm); color: var(--text-secondary); }
.doc__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; justify-content: flex-end; }
.doc__actions select { max-width: 220px; height: 32px; padding: 0 var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-pill); background: var(--bg-card); font: inherit; font-size: var(--text-sm); color: var(--text-primary); }
.doc__summary { grid-column: 1 / -1; font-size: var(--text-sm); color: var(--text-secondary); }
.doc__summary summary { cursor: pointer; color: var(--action-link); }
@media (max-width: 640px) {
  .doc { grid-template-columns: minmax(0, 1fr); }
  .doc__actions { justify-content: flex-start; }
}

/* Where an AI-filled value came from: "from TR1" under the value */
.source { display: block; font-size: var(--text-xs); font-weight: 400; color: var(--text-tertiary); }

/* Data issues list (portfolio): the choices sit at the right of each row */
.issues__actions { text-align: right; white-space: nowrap; }
.issues__actions form { display: inline-flex; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) { .issues__actions { white-space: normal; text-align: left; } .issues__actions form { justify-content: flex-start; } }

/* ---------- Sidebar: the navigation on every logged-in screen (templates/base.html, static/js/sidebar.js) ---------- */
/* Apps add their own item (common/navigation.py). Collapses to icons (remembered per browser); a drawer on phones */
.has-sidebar { --sidebar-width: 232px; padding-left: var(--sidebar-width); }
.sidebar-collapsed .has-sidebar { --sidebar-width: 68px; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 30;
  width: var(--sidebar-width);
  display: flex; flex-direction: column; gap: var(--space-4);
  padding: var(--space-3) var(--space-3) var(--space-4);
  background: var(--bg-card); box-shadow: inset -1px 0 0 var(--border);
  overflow: hidden;
}
.sidebar__brand { display: flex; align-items: center; height: 48px; padding: 0 var(--space-3); flex: none; }
.sidebar__logo { height: 24px; display: block; }
.sidebar__mark { display: none; width: 24px; height: 24px; }
.sidebar__nav { display: grid; gap: 2px; align-content: start; }
.sidebar__nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; margin: 0 calc(-1 * var(--space-1)); padding: 0 var(--space-1); }
.sidebar__group { margin: var(--space-4) 0 var(--space-1); padding: 0 var(--space-3); font-size: var(--text-xs); line-height: var(--leading-xs); font-weight: 500; color: var(--text-tertiary); }
.sidebar-collapsed .sidebar__group { height: 1px; margin: var(--space-3) var(--space-3); padding: 0; overflow: hidden; font-size: 0; background: var(--border); }
.sidebar__item {
  position: relative; display: flex; align-items: center; gap: var(--space-3);
  width: 100%; height: 36px; flex: none; padding: 0 var(--space-3);
  border: 0; border-radius: var(--radius-sm); background: none;
  color: var(--text-secondary); font: 500 var(--text-md) / 1 var(--font-body);
  text-align: left; white-space: nowrap; cursor: pointer;
  transition: background var(--motion-fast), color var(--motion-fast);
}
.sidebar__item:hover { background: var(--bg-control); color: var(--text-primary); text-decoration: none; }
.sidebar__item[aria-current="page"] { background: var(--action-tint); color: var(--text-primary); font-weight: 600; }
.sidebar__item[aria-current="page"] .icon { color: var(--action-link); }
.sidebar__item .icon { flex: none; }
.sidebar__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sidebar__badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--status-warning-bg); color: var(--text-primary); font-size: var(--text-xs); font-weight: 600; font-variant-numeric: tabular-nums; }
.sidebar-collapsed .sidebar__label, .sidebar-collapsed .sidebar__logo { display: none; }
.sidebar-collapsed .sidebar__mark { display: block; }
.sidebar-collapsed .sidebar__brand, .sidebar-collapsed .sidebar__item { justify-content: center; padding: 0; }
.sidebar-collapsed .sidebar__badge { position: absolute; top: 6px; right: 10px; min-width: 8px; width: 8px; height: 8px; padding: 0; font-size: 0; background: var(--status-warning); }
.sidebar.sidebar--sample { position: static; width: 232px; transform: none; padding: var(--space-2); border-radius: var(--radius-md); box-shadow: inset 0 0 0 1px var(--border); display: grid; gap: 2px; }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 25; background: var(--text-primary); opacity: 0.32; }
.shell { min-width: 0; }
/* Top bar's quiet icons (Help, Admin, the sidebar toggle) and the person's picture with its menu (static/js/account.js) */
.topbar__icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--text-secondary); cursor: pointer; transition: background var(--motion-fast), color var(--motion-fast); }
.topbar__icon:hover { background: var(--bg-control); color: var(--text-primary); text-decoration: none; }
.topbar__toggle { margin-left: calc(-1 * var(--space-2)); }
.topbar__toggle .icon + .icon { display: none; }                 /* the menu lines: phone only */
.sidebar-collapsed .topbar__toggle .icon:first-child { transform: scaleX(-1); }
.topbar__tools { display: flex; align-items: center; gap: var(--space-1); margin-left: auto; }
.search__key { display: flex; gap: 2px; flex: none; padding: 0; border: 0; background: none; cursor: pointer; }
.search__key kbd { min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px; background: var(--bg-card); color: var(--text-tertiary); font: 500 var(--text-xs) / 20px var(--font-sans); text-align: center; }
.search__key:hover kbd { color: var(--text-primary); }
.search:focus-within .search__key { display: none; }
@media (hover: none) { .search__key { display: none; } }

.avatar { display: inline-grid; place-items: center; flex: none; vertical-align: middle; width: var(--avatar, 32px); height: var(--avatar, 32px); overflow: hidden; border-radius: 50%; font: 600 calc(var(--avatar, 32px) * 0.38) / 1 var(--font-sans); letter-spacing: 0.01em; user-select: none; }
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.avatar--green { background: var(--green-100); color: var(--green-700); }
.avatar--blue { background: var(--blue-100); color: var(--blue-700); }
.avatar--pink { background: var(--pink-50); color: var(--pink-700); }
.avatar--slate { background: var(--grey-100); color: var(--navy-700); }
.avatar--amber { background: var(--amber-50); color: var(--amber-700); }

.account { position: relative; margin-left: var(--space-2); }
.account__button { display: grid; place-items: center; width: 40px; height: 40px; margin-right: -4px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.account__button .avatar { box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 3px var(--border-strong); transition: box-shadow var(--motion-fast); }
.account__button:hover .avatar, .account__button[aria-expanded="true"] .avatar { box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 3px var(--green-400); }
.account__menu {
  position: absolute; z-index: 45; top: calc(100% + 8px); right: -4px; width: 264px; padding: var(--space-2);
  border-radius: var(--radius-md); background: var(--bg-card); box-shadow: var(--shadow-3), inset 0 0 0 1px var(--border);
  transform-origin: top right; animation: account-in var(--motion-fast);
}
@keyframes account-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
@media (prefers-reduced-motion: reduce) { .account__menu { animation: none; } }
.account__who { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3) var(--space-3); margin-bottom: var(--space-1); border-bottom: 1px solid var(--border); }
.account__name { display: grid; min-width: 0; font-weight: 600; line-height: var(--leading-md); overflow-wrap: anywhere; }
.account__title { font-size: var(--text-sm); font-weight: 400; color: var(--text-secondary); }
.account__item { display: flex; align-items: center; gap: var(--space-3); width: 100%; height: 36px; padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-primary); font: 500 var(--text-md) / 1 var(--font-sans); text-align: left; cursor: pointer; }
.account__item .icon { color: var(--text-secondary); }
.account__item:hover, .account__item:focus-visible { background: var(--bg-control); text-decoration: none; outline: none; }
.account__item.show-sm { display: none; }
.account__out { margin: var(--space-1) 0 0; padding-top: var(--space-1); border-top: 1px solid var(--border); }
.icon { display: block; }

/* Search box in the top bar (static/js/search.js; common/search.py) */
.search { position: relative; display: flex; align-items: center; gap: var(--space-2); width: min(520px, 100%); height: 40px; padding: 0 var(--space-4); border-radius: var(--radius-pill); background: var(--bg-control); color: var(--text-secondary); }
.search:focus-within { background: var(--bg-card); box-shadow: 0 0 0 1px var(--focus-border), 0 0 0 4px var(--focus-ring); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; color: var(--text-primary); font: var(--text-md) var(--font-body); outline: none; }
.search input::-webkit-search-cancel-button { display: none; }
.search__results {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; right: 0;
  max-height: min(70vh, 560px); overflow-y: auto; padding: var(--space-2);
  border-radius: var(--radius-md); background: var(--bg-card); box-shadow: var(--shadow-3), inset 0 0 0 1px var(--border);
}
.search-group + .search-group { margin-top: var(--space-2); }
.search-group__label { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); font-weight: 600; color: var(--text-tertiary); }
.search-hit { display: flex; justify-content: space-between; gap: var(--space-4); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); color: var(--text-primary); }
.search-hit:hover, .search-hit[aria-selected="true"] { background: var(--action-tint); text-decoration: none; }
.search-hit span { color: var(--text-secondary); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search__none { padding: var(--space-2) var(--space-3); color: var(--text-secondary); }

/* ---------- Big lists (portfolio, contacts): filters, totals, compact rows, click anywhere (static/js/lists.js) ---------- */
.filters { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-bottom: var(--space-4); }
.filters select, .filters input[type="search"] {
  height: 36px; padding: 0 var(--space-4); border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  background: var(--bg-card); color: var(--text-primary); font: inherit; font-size: var(--text-sm);
}
.filters select { max-width: 220px; }
.filters__extra { display: contents; }
.filters__more { display: none; }
.filters input[type="search"] { width: 240px; }
.filters select:focus, .filters input:focus { outline: none; border-color: var(--focus-border); box-shadow: 0 0 0 3px var(--focus-ring); }
.totals { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-5); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.totals b { color: var(--text-primary); font-weight: 600; }
.table-wrap--flat { overflow: visible; }
.table--list th { position: sticky; top: 60px; z-index: 2; background: var(--bg-card); white-space: nowrap; }
.table--list td { padding: var(--space-2) var(--space-4); white-space: nowrap; }
.table--list td.wrap { white-space: normal; min-width: 220px; }
.table--list td.cut { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
.show-sm { display: none; }
.table--list th, .table--list td { padding-left: var(--space-3); padding-right: var(--space-3); }
.table .right { text-align: right; }
tr[data-href] { cursor: pointer; }
tr[data-href] a { color: inherit; }
.table__group td { padding-top: var(--space-4); background: var(--bg-subtle); font-weight: 600; }
.table__group a { color: var(--text-primary); }
.table__group .muted { font-weight: 400; margin-left: var(--space-3); }
.code { font-weight: 600; font-variant-numeric: tabular-nums; }
/* "Columns": tick which extra columns a list shows (remembered in the browser, static/js/lists.js) */
.colpick { position: relative; }
.colpick summary { list-style: none; }
.colpick summary::-webkit-details-marker { display: none; }
.colpick__menu {
  position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; display: grid; gap: var(--space-2); min-width: 160px;
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--bg-card);
  box-shadow: var(--shadow-3), inset 0 0 0 1px var(--border); font-size: var(--text-sm); white-space: nowrap;
}
.colpick__menu label { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.col-off { display: none; }
/* "Export": a small plain link on a list, never a button (common/export.py) */
.export-link { font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); white-space: nowrap; align-self: center; }
.export-link:hover { color: var(--action-link); }

/* Item pages (home, building, company, contact): a small header, then tabs */
.item-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-2) var(--space-6); margin-bottom: var(--space-5); }
.item-head__text { display: grid; gap: var(--space-1); min-width: 0; flex: 1 1 420px; }
/* The buttons line up with the title, not the bottom of a tall head (a job's stepper) */
.item-head:has(.page-head__back) > .item-head__actions { align-self: flex-start; margin-top: 22px; }
.item-head__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-4); color: var(--text-secondary); }
.item-head__figure { color: var(--text-primary); font-weight: 600; }
.item-head__photo { width: 160px; aspect-ratio: 4 / 3; border-radius: var(--radius-sm); object-fit: cover; display: block; }
.rows--3 { columns: 3 280px; }
.fact__go { margin-left: var(--space-1); font-weight: 600; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); font-size: var(--text-sm); }
.history li { display: flex; justify-content: space-between; gap: var(--space-3); }
.history time { color: var(--text-secondary); white-space: nowrap; }
.folder-read__plan { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--bg-subtle); font-size: var(--text-sm); }
.add-row { margin-top: var(--space-3); color: var(--action-link); font-weight: 500; }
.card > .add-row:first-child { margin-top: 0; }

@media (max-width: 960px) {
  .has-sidebar, .sidebar-collapsed .has-sidebar { padding-left: 0; }
  /* Closed: off-screen, hidden (no shadow on the page, its links can't be tabbed to) once it has slid out.
     Open: visible at once, so the first link can take focus */
  .sidebar { width: 264px; transform: translateX(-100%); visibility: hidden; transition: transform var(--motion-fast), visibility 0s linear 140ms; }
  .sidebar--open { transform: none; visibility: visible; box-shadow: var(--shadow-3); transition: transform var(--motion-fast), visibility 0s; }
  .sidebar-collapsed .sidebar__label, .sidebar-collapsed .sidebar__logo { display: block; }
  .sidebar-collapsed .sidebar__mark { display: none; }
  .sidebar-collapsed .sidebar__item, .sidebar-collapsed .sidebar__brand { justify-content: flex-start; padding: 0 var(--space-3); }
  .sidebar-collapsed .sidebar__badge { position: static; width: auto; min-width: 20px; height: 20px; padding: 0 6px; font-size: var(--text-xs); background: var(--status-warning-bg); }
  .topbar__toggle .icon:first-child { display: none; }
  .topbar__toggle .icon + .icon { display: block; }
  .topbar__toggle { color: var(--text-primary); }
  /* A tablet is too narrow for a full list: the table scrolls inside its frame, never the page */
  .table-wrap--flat { overflow-x: auto; }
  .table--list th { position: static; }
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .show-sm { display: block; }
  .account__item.show-sm { display: flex; }
  .account__item { height: 44px; }   /* a thumb's height */
  .topbar__inner { gap: var(--space-2); }
  .account { margin-left: 0; }
  .table--list td.wrap { min-width: 0; }
  .filters--js:not(.filters--open) .filters__extra { display: none; }
  .filters--js .filters__more { display: inline-flex; }
  .filters input[type="search"] { width: 100%; }
  .filters select { flex: 1 1 40%; max-width: none; }
  .table--list td, .table--list th { padding-left: var(--space-3); padding-right: var(--space-3); }
  .item-head__photo { display: none; }
  .page-head__actions .more__menu, .item-head__actions .more__menu, .item-top__actions .more__menu { left: 0; right: auto; }
  /* A stepper keeps its bars; only the step it's on is named, so the words never wrap */
  .stepper__item { white-space: nowrap; overflow: hidden; min-width: 0; }
  .stepper__item:not(.stepper__item--current) { color: transparent; }
  .stepper__item--current { overflow: visible; }
  /* Search hits: the detail goes on a second line rather than being cut to "London N1…" */
  .search-hit { flex-direction: column; gap: 0; }
  .search-hit span { white-space: normal; }
}
