/*
  Design tokens for the redesigned layout. New components below use only these;
  the older variable names further down point at them so existing rules keep
  exactly the colours they had.
*/
:root {
  /* Colour */
  --color-text: #17202a;
  --color-muted: #607085;
  --color-border: #d8dee7;
  --color-surface: #ffffff;
  --color-page: #f5f7fa;
  --color-accent: #087f73;
  --color-accent-text: #ffffff;
  --color-success: #147a3f;
  --color-danger: #b42318;
  --color-warning: #b7791f;

  /* Shape */
  --radius-control: 8px;
  --radius-card: 12px;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* Font sizes */
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 28px;

  /* The one shadow, used by the drawer and popovers */
  --shadow-drawer: 0 12px 40px rgba(23, 32, 42, 0.18);

  /* Existing names, kept working by pointing at the tokens above */
  --ink: var(--color-text);
  --muted: var(--color-muted);
  --line: var(--color-border);
  --panel: var(--color-surface);
  --page: var(--color-page);
  --teal: var(--color-accent);
  --blue: #275fba;
  --rust: #a34816;
  --gold: var(--color-warning);
  --danger: var(--color-danger);
  --ok: var(--color-success);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(8, 127, 115, 0.12), rgba(39, 95, 186, 0.08)),
    var(--page);
}

.auth-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(23, 32, 42, 0.12);
}

.auth-card h1 {
  font-size: 34px;
  line-height: 1.08;
}

.auth-copy {
  margin: 10px 0 20px;
  color: var(--muted);
  font-weight: 700;
}

.supabase-sign-in {
  display: grid;
  gap: 12px;
}

.supabase-sign-in label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.supabase-sign-in input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
}

.auth-message {
  margin: 14px 0 0;
  color: var(--ok);
  font-size: 14px;
  font-weight: 700;
}

.auth-message.auth-error {
  color: var(--danger);
}

.auth-setup-hint {
  margin: 16px 0 0;
  border: 1px solid #f4c27a;
  border-radius: 8px;
  padding: 12px;
  color: #7a3e05;
  background: #fff7ea;
  font-size: 14px;
  font-weight: 700;
}

.auth-access-hint {
  margin: 16px 0 0;
  border: 1px solid #f4a09a;
  border-radius: 8px;
  padding: 12px;
  color: #8f1f17;
  background: #fff1f0;
  font-size: 14px;
  font-weight: 700;
}

.search-panel,
.results-column,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-panel {
  padding: 18px;
}

.toolbar,
.source-layout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.mapping-view {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
}

.sources-choose {
  margin-top: var(--space-2);
}

.mapping-rows { display: grid; gap: 10px; margin-top: 14px; }
.mapping-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.mapping-row p { margin: 5px 0; font-weight: 750; }
.mapping-row small { color: var(--muted); }

/* The Batch run and Search buttons until the search card (T1.2) takes them. */
.search-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 12px;
}

.user-button-mount {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 32px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.user-button-mount .secondary-button {
  min-height: 32px;
  padding: 0 9px;
}

.eyebrow,
.section-title {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
}

.primary-button {
  min-width: 116px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--teal);
  font-weight: 750;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--ink);
  background: #fff;
  font-weight: 800;
}

.criteria-grid {
  display: grid;
  grid-template-columns: 2fr repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.history-comparison-field {
  grid-column: span 2;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
}

.history-comparison-field > span {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.history-comparison-dates {
  display: grid;
  grid-template-columns: repeat(2, minmax(125px, 1fr));
  gap: 8px;
}

.history-comparison-field p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.period-live-toggle {
  display: inline-flex;
  width: auto;
  margin-top: 8px;
}

.period-live-toggle span {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.period-live-toggle input {
  width: 16px;
  height: 16px;
}

.advanced-filters {
  border-top: 1px solid var(--line);
}

.filter-section {
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
}

.filter-heading {
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.filter-heading h2 {
  font-size: 19px;
}

.filter-heading span {
  color: var(--ink);
  font-weight: 900;
  transition: transform 0.15s;
}

/* Groups open and close on their own: a collapsed group hides everything after its heading. */
.filter-section.collapsed > :not(.filter-heading) {
  display: none;
}

.filter-section.collapsed .filter-heading {
  margin-bottom: 0;
}

.filter-section.collapsed .filter-heading span {
  transform: rotate(180deg);
}

.filter-expand-row {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) 0 0;
}

.filter-expand-row .btn {
  min-height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
}

/* A closed group shows how many of its filters are in use. */
.filter-count {
  display: inline-block;
  min-width: 20px;
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--color-accent);
  color: var(--color-accent-text);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  vertical-align: middle;
}

.filter-count.hidden,
.filter-section:not(.collapsed) .filter-count {
  display: none;
}

.exclude-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.exclude-chips:empty {
  display: none;
}

.exclude-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px 2px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-page);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 600;
}

.exclude-chip button {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--color-muted);
  font-size: 16px;
  line-height: 1;
}

.exclude-chip button:hover,
.exclude-chip button:focus-visible {
  color: var(--color-danger);
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  max-width: 920px;
}

.compact-row {
  grid-template-columns: repeat(2, minmax(180px, 230px));
}

.checkbox-grid,
.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
}

.checkbox-grid label,
.radio-row label,
.inline-check,
.mode-grid label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  color: var(--ink);
}

.checkbox-grid input,
.radio-row input,
.inline-check input,
.mode-grid input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.feature-grid {
  max-width: 1180px;
}

.inline-check {
  width: fit-content;
  margin-top: 14px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
}

.mode-grid fieldset {
  display: grid;
  gap: 8px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.mode-grid legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 11px;
  color: var(--ink);
  background: #fff;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(8, 127, 115, 0.22);
  outline-offset: 1px;
}

.source-layout {
  margin-top: 18px;
  align-items: flex-end;
}

.agency-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.agency-pill,
.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.agency-pill input,
.toggle-row input {
  width: 16px;
  height: 16px;
}

.agency-pill.disabled {
  color: var(--muted);
  background: #f6f8fb;
  border-style: dashed;
}

.verified-star {
  display: inline-block;
  margin-left: 5px;
  color: #c88719;
  font-size: 14px;
  line-height: 1;
  vertical-align: 1px;
}

.agency-pill .verified-star {
  margin-left: 3px;
}

.location-field {
  position: relative;
  min-width: 0;
}

.selected-locations {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.location-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 7px 4px 10px;
  color: #07574f;
  background: #e7f7f3;
  font-size: 12px;
  font-weight: 800;
}

.location-chip button {
  width: 19px;
  height: 19px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  color: inherit;
  background: rgba(7, 87, 79, 0.12);
  font-size: 16px;
  line-height: 1;
}

.location-help {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.location-suggestions {
  position: absolute;
  z-index: 20;
  top: 71px;
  right: 0;
  left: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.14);
  background: #fff;
}

.location-option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.location-option:last-child { border-bottom: 0; }
.location-option:hover, .location-option:focus-visible { background: #f0fbf8; }
.location-option span, .location-empty { color: var(--muted); font-size: 12px; }
.location-empty { padding: 11px 12px; }

/* Places already searched, offered back as one-click chips under the search bar. */
.recent-locations {
  grid-column: 1 / -1;
  min-width: 0;
  margin-top: 2px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.recent-locations-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.recent-locations-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.recent-locations-head .secondary-button {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.recent-location-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 118px;
  overflow-y: auto;
  margin-top: 8px;
}

.recent-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.recent-chip:hover,
.recent-chip:focus-visible {
  border-color: var(--teal);
  color: #07574f;
  background: #f0fbf8;
}

/* A chip carries its own forget button, so one term can go without the lot. */
.recent-chip-wrap {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  overflow: hidden;
}

.recent-chip-wrap .recent-chip {
  border: 0;
  border-radius: 0;
  padding-right: 7px;
  background: transparent;
}

.recent-chip-wrap:hover,
.recent-chip-wrap:focus-within {
  border-color: var(--teal);
}

.recent-chip-wrap:has(.recent-chip.added) {
  border-color: transparent;
  background: #e7f7f3;
}

.recent-chip-forget {
  border: 0;
  padding: 0 8px 0 2px;
  color: var(--muted);
  background: transparent;
  font-size: 15px;
  line-height: 1;
}

.recent-chip-forget:hover:not(:disabled),
.recent-chip-forget:focus-visible {
  color: var(--danger);
}

.recent-chip-forget:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

/* Cut the results back to one or more of the places that were searched. */
.result-locations {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.result-locations-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.result-location-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.result-location-chip span {
  color: var(--muted);
  font-weight: 700;
}

.result-location-chip:hover,
.result-location-chip:focus-visible {
  border-color: var(--teal);
}

.result-location-chip.on {
  border-color: transparent;
  color: #fff;
  background: var(--teal);
}

.result-location-chip.on span {
  color: rgba(255, 255, 255, 0.78);
}

.result-location-clear {
  border: 0;
  padding: 5px 6px;
  color: var(--blue);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  text-decoration: underline;
}

.recent-chip:disabled,
.location-chip button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.recent-chip.added {
  border-color: transparent;
  color: #07574f;
  background: #e7f7f3;
}

.recent-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.recent-locations .location-help {
  margin-top: 8px;
}

/* The same one-click treatment for keyword terms, under the keyword box. */
.recent-keywords {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.recent-keywords-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.recent-keywords-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.recent-keywords-head .secondary-button {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.recent-keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 118px;
  overflow-y: auto;
  margin-top: 8px;
}

.recent-keywords .location-help {
  margin-top: 8px;
}

/* Batch run: one queued job per location, with its own saved-search result. */
.batch-panel {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.batch-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.batch-summary {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

.batch-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}

.batch-actions .secondary-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.batch-jobs {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.batch-job {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  font-size: 13px;
}

.batch-state {
  min-width: 78px;
  border-radius: 999px;
  padding: 2px 9px;
  color: var(--muted);
  background: #eef1f6;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.batch-job.running .batch-state { color: #234a8a; background: #e6eefb; }
.batch-job.done .batch-state { color: #0d5c31; background: #e4f4ea; }
.batch-job.read .batch-state { color: #6b4a12; background: #fbf1dd; }
.batch-job.failed .batch-state { color: #8b1f17; background: #fdeae7; }

.batch-location {
  font-weight: 800;
}

.batch-note {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.batch-job .secondary-button {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.agency-error {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #f1b7aa;
  border-radius: 8px;
  padding: 0 12px;
  background: #fff4f1;
  color: #8b3125;
  font-weight: 800;
}

.secondary-button.active {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.pill-soon {
  border-radius: 999px;
  padding: 1px 7px;
  background: #eef3f8;
  color: #607085;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-sort select {
  height: 34px;
}

.status-rows {
  overflow-x: auto;
}

.status-table {
  width: 100%;
  border-collapse: collapse;
}

.status-table thead th {
  padding: 6px 11px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-table thead th:last-child {
  text-align: right;
}

.status-table tbody tr.status-row {
  border-bottom: 1px solid var(--line);
  transition: background 0.14s ease;
}

.status-table tbody tr.status-row:last-child {
  border-bottom: 0;
}

.status-table tbody tr.status-row.clickable {
  cursor: pointer;
}

.status-table tbody tr.status-row.clickable:hover {
  background: #f0fbf8;
}

.status-table tbody tr.status-row.active {
  background: #eefaf6;
}

.status-table td {
  padding: 9px 11px;
  vertical-align: middle;
}

.status-caret {
  margin-left: 4px;
  color: var(--teal);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.status-name {
  font-weight: 750;
}

.status-search {
  max-width: 460px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.status-location { min-width: 180px; }

.location-quality {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 850;
  text-transform: capitalize;
}

.location-quality.exact { color: #07574f; background: #dff6ef; }
.location-quality.normalised { color: #155da4; background: #e7f0fc; }
.location-quality.fallback, .location-quality.mixed { color: #8a4b08; background: #fff1d6; }
.location-quality.not-set, .location-quality.saved { color: #58677a; background: #edf1f5; }

.location-summary {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.link-divider { color: var(--muted); }

.status-search a {
  display: inline-block;
  max-width: 460px;
  color: var(--blue);
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.status-count {
  text-align: right;
  white-space: nowrap;
}

.status-expand-toggle {
  width: 100%;
  margin-top: 4px;
  padding: 9px 11px;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  color: var(--blue);
  font-size: 13px;
  font-weight: 750;
  text-align: center;
}

.status-expand-toggle:hover {
  background: #f0f5fc;
}

.status-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  color: #fff;
  background: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-badge.loading {
  background: var(--gold);
}

.status-badge.done {
  background: var(--ok);
}

.status-badge.error {
  background: var(--danger);
}

.status-badge.reading {
  background: var(--gold);
}

.status-state {
  min-width: 180px;
}

.status-detail {
  display: block;
  max-width: 360px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.status-detail.error {
  color: #a92d21;
}

.status-detail.reading {
  color: #8a5a00;
}

.background-note {
  color: #234a8a;
  font-weight: 700;
}

.status-retry {
  margin-left: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  color: var(--ink);
  background: #fff;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.status-retry:hover {
  background: #f0f5fc;
}

.status-detail-label {
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 12px;
  margin-top: 12px;
}

.results-column,
.detail-panel {
  min-height: 580px;
  padding: 14px;
}

.toolbar-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.toolbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sort-control span {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.sort-control select {
  width: auto;
  height: 38px;
}

.segmented {
  display: inline-grid;
  flex-shrink: 0;
  grid-auto-flow: column;
  grid-auto-columns: minmax(max-content, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  min-width: 82px;
  height: 38px;
  padding: 0 14px;
  border: 0;
  color: var(--muted);
  background: #fff;
  font-weight: 750;
  white-space: nowrap;
}

.segmented button.active {
  color: #fff;
  background: var(--blue);
}

.list-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.property-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.property-card:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
}

.card-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 0;
}

.bookmark-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #eef3f8;
  color: #607085;
  font-size: 18px;
  line-height: 1;
}

.bookmark-btn:hover {
  color: var(--gold);
}

.bookmark-btn.active {
  color: var(--gold);
}

.detail-bookmark.active {
  border-color: var(--gold);
  color: var(--gold);
}

.property-card.selected {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 127, 115, 0.16);
}

.property-card img {
  width: 100%;
  height: 172px;
  object-fit: cover;
  background: #e8edf4;
}

.property-body {
  padding: 8px 12px 12px;
}

.property-body h3 {
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 1.25;
}

.meta-row,
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.meta-row {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.price {
  color: var(--teal);
  font-size: 19px;
  font-weight: 850;
}

.badge {
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef3f8;
  color: #425267;
  font-size: 12px;
  font-weight: 750;
}

.badge.demo {
  color: #7a3a0c;
  background: #fff4df;
}

.badge.dist {
  color: #1e4620;
  background: #e6f4ea;
}

.badge.new-listing {
  color: #07574f;
  background: #d7f4eb;
}

.badge.auction-badge {
  color: #6a2c91;
  background: #f1e6fa;
}

.badge.auction-imported {
  color: #0b4a6f;
  background: #dcecf7;
}

.badge.property-match.confirmed {
  color: #1e4620;
  background: #dff6ef;
}

.badge.property-match.possible {
  color: #7a4b05;
  background: #fff1d6;
}

.property-match-detail {
  margin-top: 14px;
  border: 1px solid #cce9df;
  border-radius: 8px;
  padding: 10px;
  background: #f5fcf9;
}

.property-match-detail h4,
.property-match-detail p {
  margin: 0;
}

.property-match-detail h4 {
  font-size: 13px;
}

.property-match-detail p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.property-match-detail div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.property-match-detail a {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.empty-state {
  display: grid;
  min-height: 360px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
}

.map-view {
  margin-top: 14px;
}

.leaflet-map {
  height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  z-index: 0;
}

.map-canvas {
  position: relative;
  height: 560px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(8, 127, 115, 0.11), transparent 45%),
    linear-gradient(45deg, rgba(39, 95, 186, 0.14), transparent 55%),
    #eef4f0;
}

.map-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(23, 32, 42, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 32, 42, 0.08) 1px, transparent 1px);
  background-size: 72px 72px;
}

.map-label {
  position: absolute;
  color: rgba(23, 32, 42, 0.45);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.north {
  top: 12px;
  left: 50%;
}

.south {
  bottom: 12px;
  left: 50%;
}

.west {
  top: 50%;
  left: 12px;
}

.east {
  top: 50%;
  right: 12px;
}

.marker {
  position: absolute;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--rust);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.marker.selected {
  width: 28px;
  height: 28px;
  background: var(--teal);
}

/* Search-area centre: a crosshair ring the property markers are measured from. */
.map-center {
  position: absolute;
  width: 26px;
  height: 26px;
  transform: translate(-50%, -50%);
  border: 3px solid var(--blue);
  border-radius: 50%;
  background: rgba(39, 95, 186, 0.16);
  box-shadow: 0 0 0 2px #fff;
  pointer-events: none;
  z-index: 1;
}

.map-center::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--blue);
}

.map-hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.legend-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.detail-empty {
  display: grid;
  min-height: 220px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
}

.detail-panel img {
  width: 100%;
  height: 210px;
  border-radius: 8px;
  object-fit: cover;
  background: #e8edf4;
}

.detail-image {
  cursor: zoom-in;
}

.detail-media {
  position: relative;
}

.detail-media-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border: 0;
  border-radius: 50%;
  background: rgba(23, 32, 42, 0.55);
  color: #fff;
  font-size: 19px;
  line-height: 1;
}

.detail-media-nav:hover {
  background: rgba(23, 32, 42, 0.75);
}

.detail-media-nav.prev {
  left: 8px;
}

.detail-media-nav.next {
  right: 8px;
}

.detail-media-count {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(23, 32, 42, 0.6);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* --- image lightbox (click a photo to view it larger, with gallery nav) --- */

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: rgba(10, 14, 20, 0.85);
}

.image-lightbox.hidden {
  display: none;
}

.image-lightbox img {
  max-width: min(92vw, 1100px);
  max-height: 88vh;
  border-radius: 10px;
  object-fit: contain;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 28px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 22px;
  line-height: 1;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 28px;
  line-height: 1;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.22);
}

.lightbox-nav.hidden {
  display: none;
}

.lightbox-nav.prev {
  left: 20px;
}

.lightbox-nav.next {
  right: 20px;
}

.lightbox-count {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.detail-panel h3 {
  margin: 12px 0 8px;
  font-size: 21px;
  line-height: 1.2;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.detail-actions .secondary-button {
  flex: 1 1 auto;
}

.detail-panel a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  flex: 1 1 auto;
  border-radius: 8px;
  padding: 0 12px;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.source-body.collapsed {
  display: none;
}

/* --- Settings screen and its Sources page --------------------------------- */

.settings-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: var(--space-5);
  margin-top: var(--space-4);
  align-items: start;
}

.settings-nav {
  display: grid;
  gap: var(--space-1);
}

.settings-link {
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--color-muted);
  font-size: var(--text-md);
  font-weight: 600;
  text-align: left;
}

.settings-link:hover {
  background: rgba(8, 127, 115, 0.08);
}

.settings-link.active {
  background: rgba(8, 127, 115, 0.12);
  color: var(--color-text);
}

.settings-body {
  min-width: 0;
}

.settings-page {
  display: grid;
  gap: var(--space-3);
}

.settings-page.hidden {
  display: none;
}

.settings-page .mapping-view {
  margin-top: 0;
}

/* The search period box was written for a two-column form; here it is the
   page's own block, so it must not ask the single-column page for a second
   column (that would widen the page and scroll sideways on a phone). */
.settings-page .history-comparison-field {
  grid-column: auto;
  max-width: 480px;
}

.settings-page .history-comparison-dates {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-page .field {
  max-width: 280px;
}

.account-details {
  display: grid;
  gap: var(--space-3);
  margin: 0;
}

.account-details dt {
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

.account-details dd {
  margin: var(--space-1) 0 0;
  color: var(--color-text);
  font-size: var(--text-md);
  overflow-wrap: anywhere;
}

.source-title {
  margin: 0;
  font-size: var(--text-xl);
}

.source-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.source-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.source-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

.source-selection-toggle {
  min-height: 38px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
}

.source-summary {
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-weight: 700;
}

.source-search {
  max-width: 360px;
}

.source-body {
  margin-top: var(--space-1);
}

.source-group {
  width: 100%;
}

.source-group.hidden {
  display: none;
}

.source-group-title {
  margin: 0 0 var(--space-2);
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: 700;
}

.agency-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

#agencyList {
  flex-direction: column;
  flex-wrap: nowrap;
  gap: var(--space-4);
}

@media (max-width: 700px) {
  /* The sub-menu becomes a row of tabs that scrolls inside itself, so the
     page never scrolls sideways. */
  .settings-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
  }

  .settings-nav {
    display: flex;
    gap: var(--space-1);
    overflow-x: auto;
    border-bottom: 1px solid var(--color-border);
  }

  .settings-link {
    flex: none;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
  }

  .settings-link.active {
    background: transparent;
    border-bottom-color: var(--color-accent);
  }
}

/* --- analysis strip (price distribution) ---------------------------------- */

.analysis-strip {
  margin-top: var(--space-3);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

.analysis-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
}

.analysis-header .section-title {
  margin: 0;
}

.analysis-body {
  margin-top: 12px;
}

.analysis-chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
  margin-bottom: 12px;
}

.analysis-chart-head h3 {
  margin: 0;
  font-size: 16px;
}

.price-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.price-stats .stat {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.stat-k {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.stat-v {
  font-size: 15px;
  font-weight: 800;
}

.price-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  align-items: end;
  gap: 8px;
  height: 168px;
  padding-top: 6px;
}

.bar-col {
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: end;
  justify-items: center;
  gap: 4px;
  height: 100%;
  border: 0;
  background: none;
  padding: 0;
}

.bar-count {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.bar {
  width: 100%;
  max-width: 54px;
  min-height: 3px;
  border-radius: 6px 6px 0 0;
  background: var(--blue);
  transition:
    background 0.14s ease,
    filter 0.14s ease;
  align-self: end;
}

.bar-col.peak .bar {
  background: var(--teal);
}

.bar-col:hover .bar {
  filter: brightness(1.08);
}

.bar-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

/* --- publisher line + price change ---------------------------------------- */

.price-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.price-change {
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 800;
}

.price-change.down {
  color: #1e4620;
  background: #e6f4ea;
}

.price-change.up {
  color: #7a1c14;
  background: #fdecea;
}

.publisher {
  margin-top: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.publisher-label {
  color: var(--muted);
  font-weight: 700;
}

.publisher-via {
  color: var(--muted);
  font-weight: 600;
}

.price-history {
  margin: 14px 0 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfe;
}

.ph-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.price-history ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 5px;
}

.price-history li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.ph-date {
  color: var(--muted);
  font-weight: 700;
}

.ph-price {
  font-weight: 800;
}

.ph-diff {
  font-weight: 800;
  text-align: right;
}

.ph-diff.down {
  color: var(--ok);
}

.ph-diff.up {
  color: var(--danger);
}

.ph-diff.flat {
  color: var(--muted);
}

/* --- search history view -------------------------------------------------- */

.history-view {
  margin-top: 14px;
}

.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.history-toolbar-actions,
.history-date-form {
  display: inline-flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 8px;
}

.history-date-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.history-date-form input {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  color: var(--ink);
  background: #fff;
}

.history-period,
.history-snapshots {
  margin-top: 22px;
}

.history-period-heading h2,
.history-snapshots h2 {
  margin: 0;
  font-size: 17px;
}

.history-period-heading p {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.history-listing {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fafffe;
}

.history-listing h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.history-listing a {
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.history-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.history-list {
  display: grid;
  gap: 10px;
}

/* A grid, not space-between: every row's title then starts at the same x. */
.history-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--color-surface);
}

.history-card.selected {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(8, 127, 115, 0.13);
}

.history-select {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  padding: 6px;
}

.history-select-input {
  width: 17px;
  height: 17px;
  accent-color: var(--teal);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.history-main {
  min-width: 0;
}

/* break-word, not anywhere: "anywhere" lets the column shrink to one letter
   and then breaks the name mid-word. */
.history-main h3 {
  margin: 0 0 4px;
  font-size: 16px;
  overflow-wrap: break-word;
}

.history-main h3 .channel-badge {
  white-space: nowrap;
  vertical-align: middle;
}

.history-meta {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.history-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.history-change {
  margin: 6px 0 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.history-warning {
  color: #8b1f17;
}

/* Change by source: one row per source, one column per compared search. */
.history-compare {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
}

.history-compare h2 { margin: 0; }

.compare-scroll {
  margin-top: 10px;
  overflow-x: auto;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.compare-table th,
.compare-table td {
  border-bottom: 1px solid var(--line);
  padding: 7px 10px;
  text-align: left;
  white-space: nowrap;
}

.compare-table thead th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.compare-table .compare-count { text-align: right; }
.compare-place { display: block; text-transform: none; }
.compare-total th, .compare-total td { font-weight: 800; background: var(--page); }
.compare-row.clickable { cursor: pointer; }
.compare-row.clickable:hover, .compare-row.open { background: #f0f5fc; }
.compare-added { color: var(--ok); }
.compare-removed { color: var(--danger); }
.compare-failed { color: var(--danger); font-weight: 700; }
.compare-absent { color: var(--muted); }

.compare-table .compare-detail td {
  white-space: normal;
  background: #fafbfd;
}

.compare-group h4 { margin: 6px 0 4px; font-size: 12px; }
.compare-group ul { margin: 0 0 8px; padding-left: 18px; }
.compare-group li { margin: 2px 0; }
.compare-price { color: var(--muted); font-weight: 700; }

/* Scheduled searches: the daily times and the places. Rows reuse .batch-job. */
.schedule-lead {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.schedule-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-top: 14px;
}

.schedule-form label span {
  margin-bottom: 4px;
  font-size: 12px;
}

.schedule-form input[type="time"],
.schedule-form select {
  width: 128px;
  height: 36px;
}

.schedule-form .primary-button {
  min-height: 36px;
}

.schedule-form .schedule-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  cursor: pointer;
}

.schedule-form .schedule-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #087f73);
}

.schedule-form .schedule-check span {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.schedule-zone,
.schedule-note {
  padding-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.schedule-note.error {
  color: #8b1f17;
}

.schedule-locations-head {
  margin-top: 18px;
}

.schedule-empty {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.schedule-failed-badge {
  border: 0;
  border-radius: 999px;
  padding: 3px 10px;
  color: #fff;
  background: #a32a1f;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.schedule-failed-badge:hover {
  background: #8b1f17;
}

.schedule-failures {
  flex-basis: 100%;
  border-top: 1px dashed var(--line);
  padding-top: 6px;
}

.schedule-failures ul {
  display: grid;
  gap: 4px;
  margin: 0 0 6px;
  padding: 0;
  list-style: none;
}

.schedule-failures li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
}

.schedule-failure-reason {
  flex: 1;
  min-width: 0;
  color: #8b1f17;
}

.schedule-failure-busy {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.nightly-problems {
  margin: 6px 0 0;
  padding-left: 18px;
  color: #8b1f17;
  font-size: 12px;
}

.history-actions {
  display: inline-flex;
  gap: 8px;
  flex: 0 0 auto;
}

.history-actions .secondary-button {
  min-height: 36px;
}

.hidden {
  display: none;
}

/* Two price views make the raw portal count and grouped-home count explicit. */
.analysis-note { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.price-chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.price-distribution { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 11px; background: #fbfcfe; }
.price-distribution-head { display: grid; gap: 8px; margin-bottom: 10px; }
.price-distribution h4, .price-distribution p { margin: 0; }
.price-distribution h4 { font-size: 14px; }
.price-distribution p { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.35; }

/* Bedroom & bathroom facets above the histogram. */
.price-facets { display: grid; gap: 6px; margin-bottom: 12px; }
.price-facets:empty { display: none; }
.facet-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.facet-row-label { min-width: 74px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.facet-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.facet-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; border: 1px solid var(--line); border-radius: 999px; padding: 0 11px; background: #fff; color: var(--ink); font-size: 12px; font-weight: 700; }
.facet-chip:hover { border-color: var(--blue); background: #f2f6fc; }
.facet-chip:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.facet-chip.active { border-color: var(--blue); background: #eef3fb; color: var(--blue); font-weight: 800; }
.facet-chip-count { color: var(--muted); font-size: 11px; font-weight: 800; }
.facet-chip.active .facet-chip-count { color: var(--blue); }

/* --- rooms & price change dashboard ---------------------------------------- */

.analysis-tabs { margin-bottom: 12px; }
.analysis-tabs button { min-width: 150px; height: 34px; font-size: 13px; }

.room-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; }
.room-controls label { display: grid; gap: 3px; }
.room-controls label span { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.room-controls select { min-height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 0 9px; background: #fff; color: var(--ink); }
.room-controls .secondary-button { min-height: 40px; }

.room-quick-ranges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.room-quick-label { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.room-quick-ranges .secondary-button { min-height: 32px; padding: 0 10px; font-size: 12px; }

.room-dashboard { display: grid; gap: 12px; }
.room-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 18px; }
.room-summary-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.room-summary-actions .secondary-button { min-height: 32px; padding: 0 10px; font-size: 12px; }
.room-legend { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.room-legend .swatch { width: 12px; height: 12px; border-radius: 3px; }
.room-legend .swatch.start { background: #9db4d8; }
.room-legend .swatch.end { background: var(--blue); }
.room-legend .swatch.start + .swatch.end, .room-legend .swatch.end:not(:first-child) { margin-left: 6px; }
.room-notice { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.room-empty { border: 1px dashed var(--line); border-radius: 8px; padding: 14px; color: var(--muted); font-size: 13px; line-height: 1.45; }

.room-chart { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); align-items: end; gap: 10px; padding-top: 4px; overflow-x: auto; }
.room-col { display: grid; grid-template-rows: auto 176px auto auto; align-items: end; justify-items: center; gap: 5px; min-width: 92px; border: 1px solid transparent; border-radius: 8px; padding: 6px 4px; background: none; }
.room-col:hover { background: #f2f6fc; }
.room-col.active { border-color: var(--blue); background: #eef3fb; }
.room-col:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.room-delta { font-size: 11px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.room-delta.up { color: var(--rust); }
.room-delta.down { color: var(--ok); }
/* The padding reserves the strip a full-height bar's value label sits in, so it
   can never collide with the change text above the column. */
.room-bars { display: flex; align-items: flex-end; justify-content: center; gap: 6px; width: 100%; height: 100%; padding-top: 20px; }
.room-bar { position: relative; display: block; width: 30px; min-height: 4px; border-radius: 6px 6px 0 0; background: #9db4d8; }
.room-bar.end { background: var(--blue); }
.room-bar-value { position: absolute; top: -16px; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 11px; font-weight: 800; white-space: nowrap; }
.room-label { font-size: 12px; font-weight: 800; }
.room-sub { color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }

.room-table-wrap { overflow-x: auto; }
.room-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.room-table th, .room-table td { padding: 7px 9px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.room-table thead th { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.room-table tbody th { font-weight: 800; }
.room-table tbody tr[data-bucket] { cursor: pointer; }
.room-table tbody tr[data-bucket]:hover { background: #f4f7fc; }
.room-table tbody tr.active { background: #eef3fb; }
.room-delta-cell.up { color: var(--rust); font-weight: 800; }
.room-delta-cell.down { color: var(--ok); font-weight: 800; }

/* --- selected room group: split by the search filters ---------------------- */

.room-breakdown { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fbfcfe; }
.room-breakdown-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 16px; }
.room-breakdown-head h4 { margin: 0; font-size: 14px; }
.room-breakdown-head p { margin: 3px 0 10px; color: var(--muted); font-size: 12px; }
.breakdown-picker { min-width: 0; }
.breakdown-picker summary { color: var(--blue); font-size: 12px; font-weight: 800; cursor: pointer; }
.breakdown-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 4px 14px; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fff; }
.breakdown-option { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; }
.breakdown-option input { width: 15px; height: 15px; }
.room-price-drill { margin-bottom: 12px; }
.room-price-drill .price-distribution { background: #fff; }

/* --- price drill-down trail ------------------------------------------------ */

.price-drill { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.price-crumb { border: 0; border-radius: 6px; padding: 3px 8px; background: #eef3fb; color: var(--blue); font-size: 12px; font-weight: 800; }
.price-crumb:hover { background: #e2ebf9; }
.price-crumb-sep { color: var(--muted); font-size: 12px; }
.price-drill-up { min-height: 30px; padding: 0 10px; font-size: 12px; }
.room-breakdown-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.breakdown-group { min-width: 0; }
.breakdown-group h5 { margin: 0 0 6px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.breakdown-base { font-weight: 700; text-transform: none; opacity: 0.85; }
.breakdown-row { display: grid; grid-template-columns: minmax(0, 1fr) 56px auto; align-items: center; gap: 8px; width: 100%; border: 0; border-radius: 6px; padding: 4px 6px; background: none; color: var(--ink); font-size: 12px; text-align: left; }
.breakdown-row:not(.static):hover { background: #eef3fb; }
.breakdown-row.static { color: var(--muted); }
.breakdown-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.breakdown-bar { height: 6px; border-radius: 999px; background: #e6ecf5; overflow: hidden; }
/* A share under a percent still has to be visible, or a real count reads as none. */
.breakdown-bar span { display: block; min-width: 2px; height: 100%; border-radius: 999px; background: var(--blue); }
.breakdown-row.static .breakdown-bar span { background: #9db4d8; }
.breakdown-count { color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }

/* --- listings over time ---------------------------------------------------- */

.room-trend { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fff; }
.room-trend-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 16px; }
.room-trend-head h4 { margin: 0; font-size: 14px; }
.room-trend-head p { margin: 3px 0 10px; max-width: 62ch; color: var(--muted); font-size: 12px; }
.trend-mode button { min-width: 0; height: 32px; padding: 0 12px; font-size: 12px; }
.room-trend-plot { position: relative; }
.room-trend-svg { display: block; width: 100%; height: auto; overflow: visible; }
.trend-grid { stroke: #e6ecf5; stroke-width: 1; }
.trend-crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.trend-axis { fill: var(--muted); font-size: 12px; font-weight: 700; }
.trend-label { fill: var(--ink); font-size: 12px; font-weight: 800; }
.room-trend-tip { position: absolute; top: 4px; transform: translateX(-50%); display: grid; gap: 2px; min-width: 132px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: #fff; box-shadow: 0 6px 18px rgba(15, 25, 40, 0.12); font-size: 12px; pointer-events: none; z-index: 2; }
.room-trend-tip strong { font-size: 12px; }
.tip-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 6px; color: var(--muted); }
.tip-row b { color: var(--ink); }
.tip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--series); }
.room-trend-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.trend-legend-item { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; background: #fff; color: var(--ink); font-size: 12px; font-weight: 700; }
.trend-legend-item:hover { background: #f4f7fc; }
.trend-legend-item.off { color: var(--muted); background: #f6f8fb; }
.trend-legend-item.off .trend-swatch { background: #c7d1de; }
.trend-swatch { width: 16px; height: 3px; border-radius: 2px; background: var(--series); }
.trend-swatch.dashed { background: repeating-linear-gradient(90deg, var(--series) 0 5px, transparent 5px 8px); }
.trend-legend-item.off .trend-swatch.dashed { background: repeating-linear-gradient(90deg, #c7d1de 0 5px, transparent 5px 8px); }
.room-trend-table { margin-top: 10px; }
.room-trend-table summary { color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.room-trend-table .room-table { margin-top: 8px; }

.badge.saved-listing { color: #5b4708; background: #fdf3d4; }

/* A home a scheduled run has since seen taken: agreed, sold STC, or taken down. */
.badge.taken { color: #7a2e0e; background: #fde4d6; }
.badge.taken.removed { color: #4a4f57; background: #e6e9ee; }

/* A saved search's home whose price has moved since that search ran. */
.badge.price-moved.down { color: #1e4620; background: #e6f4ea; }
.badge.price-moved.up { color: #7a1c14; background: #fdecea; }

.property-match-detail .match-listing-actions { display: grid; gap: 8px; }
.match-listing-action { padding-top: 8px; border-top: 1px solid #dcece6; }
.match-listing-action:first-child { padding-top: 0; border-top: 0; }
.match-listing-action > div { margin-top: 6px; }
.match-listing-action .secondary-button, .match-listing-action a { min-height: 31px; padding: 5px 8px; font-size: 12px; }
.match-listing-action a { display: inline-flex; align-items: center; border-radius: 7px; color: var(--blue); background: transparent; font-weight: 800; text-decoration: none; }

/* In-app photo comparison for potential cross-platform matches. */
.match-review { position: fixed; inset: 0; z-index: 1001; display: grid; place-items: center; padding: 24px; background: rgba(10, 14, 20, 0.72); }
.match-review.hidden { display: none; }
.match-review-dialog { position: relative; width: min(980px, 100%); max-height: min(92vh, 820px); overflow: auto; border-radius: 12px; padding: 24px; background: #fff; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35); }
.match-review-close { position: absolute; top: 12px; right: 14px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #eef3f8; color: var(--ink); font-size: 23px; }
.match-review-heading { padding-right: 44px; }
.match-review-heading h2, .match-review-heading p { margin: 0; }
.match-review-heading h2 { margin-top: 4px; font-size: 21px; }
.match-review-heading > p:last-child { margin-top: 7px; color: var(--muted); line-height: 1.45; }
.match-photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.match-photo-panel { min-width: 0; margin: 0; }
.match-photo-panel > p:last-child { min-height: 38px; margin: 7px 0 0; color: var(--ink); font-size: 13px; font-weight: 700; }
.match-photo-source { margin: 0 0 6px; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.match-photo-frame { position: relative; background: #e8edf4; }
.match-photo-frame img { display: block; width: 100%; height: min(42vw, 360px); min-height: 230px; object-fit: cover; }
.match-photo-nav { position: absolute; top: 50%; width: 34px; height: 34px; transform: translateY(-50%); border: 0; border-radius: 50%; background: rgba(23, 32, 42, 0.67); color: #fff; font-size: 21px; }
.match-photo-nav.prev { left: 8px; }
.match-photo-nav.next { right: 8px; }
.match-photo-nav:disabled { opacity: 0.35; cursor: not-allowed; }
.match-photo-count { position: absolute; right: 8px; bottom: 8px; padding: 3px 7px; border-radius: 999px; background: rgba(23, 32, 42, 0.67); color: #fff; font-size: 11px; font-weight: 800; }
.match-review-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 18px; }
.match-status { color: #07574f; font-size: 13px; font-weight: 800; }

.result-filter-button {
  margin-left: 4px;
  border: 0;
  border-radius: 999px;
  padding: 4px 9px;
  background: #d7f4eb;
  color: #07574f;
  font: inherit;
  font-size: 0.58em;
  font-weight: 850;
  vertical-align: middle;
}

.result-filter-button:hover {
  background: #bcebdc;
}

@media (max-width: 700px) {
  .price-chart-grid, .match-photo-grid { grid-template-columns: 1fr; }
  .match-review-dialog { padding: 18px; }
  .match-photo-frame img { height: min(74vw, 340px); }
  .analysis-tabs { width: 100%; }
  .analysis-tabs button { min-width: 0; }
  .room-controls label { flex: 1 1 132px; }
  .room-col { grid-template-rows: auto 140px auto auto; min-width: 84px; }
}

@media (max-width: 980px) {
  .criteria-grid,
  .workspace,
  .filter-row,
  .compact-row,
  .mode-grid {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .source-layout {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button {
    width: 100%;
  }

  .detail-panel {
    min-height: auto;
  }

  .history-comparison-field {
    grid-column: auto;
  }
}

/* ---- Base components for the redesigned layout (unused until later tasks) ---- */

/* Standard button: neutral outline. Combine with .btn-primary or .btn-ghost. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--color-muted);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* The one main action on a screen, filled with the brand colour. */
.btn-primary {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-accent-text);
}

.btn-primary:hover {
  border-color: var(--color-accent);
  filter: brightness(0.92);
}

/* Quiet button with no outline, for secondary actions such as "Clear all". */
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--color-accent);
}

.btn-ghost:hover {
  border-color: transparent;
  background: rgba(8, 127, 115, 0.08);
}

/* A label stacked over a control (input, select); the control is a direct child. */
.field {
  display: grid;
  gap: var(--space-1);
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

.field input,
.field select {
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-md);
  font-weight: 400;
}

/* Removable pill for an applied filter; put a small button inside to remove it. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 28px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
}

.chip button {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--color-muted);
  line-height: 1;
}

/* Underline-style tab row. Mark the current tab with aria-selected="true". */
.tabs {
  display: flex;
  gap: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.tab {
  padding: var(--space-3) 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--color-muted);
  font-size: var(--text-md);
  font-weight: 600;
}

.tab[aria-selected="true"] {
  border-bottom-color: var(--color-accent);
  color: var(--color-text);
}

/* Segmented control, used for the Buy / Rent switch. Buttons inside; current one is aria-pressed="true". */
.seg {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-page);
}

.seg button {
  min-height: 36px;
  padding: 0 var(--space-4);
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--color-muted);
  font-size: var(--text-md);
  font-weight: 600;
}

.seg button[aria-pressed="true"] {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 1px 3px rgba(23, 32, 42, 0.14);
}

/* White rounded container for a group of content. */
.card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  background: var(--color-surface);
}

/* A small label over a big number, e.g. "Median rent" / "£1,850". Children: .metric-label, .metric-value. */
.metric {
  display: grid;
  gap: var(--space-1);
}

.metric-label {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.metric-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.1;
}

/* Right-hand side panel that slides over the page; full screen below 700px. Toggle with the "open" class. */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1002;
  display: none;
  flex-direction: column;
  width: min(420px, 100vw);
  background: var(--color-surface);
  box-shadow: var(--shadow-drawer);
  overflow-y: auto;
}

.drawer.open {
  display: flex;
}

@media (max-width: 700px) {
  .drawer {
    width: 100vw;
  }
}

/* Filters drawer: the header and footer stay put while the filter groups scroll. */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1001;
  background: rgba(23, 32, 42, 0.45);
}

.drawer-backdrop.hidden {
  display: none;
}

.drawer-header,
.drawer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
}

.drawer-header {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--color-border);
}

.drawer-footer {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  border-top: 1px solid var(--color-border);
}

.drawer-body {
  padding: 0 var(--space-4);
  border-top: 0;
}

.drawer-body .filter-row {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

/* Small floating panel anchored to a button (menus, quick filters). Position it from the parent. */
.popover {
  position: absolute;
  z-index: 1002;
  min-width: 200px;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-drawer);
}

/* .badge (small status label such as "New" or "Reduced") already exists above
   with its colour variants; the redesign reuses it rather than redefining it. */

/* Top bar: title, menu links, and the gear that opens Settings / account. */
.top-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.top-bar-title {
  margin: 0;
  font-size: var(--text-xl);
  white-space: nowrap;
}

.top-menu {
  display: flex;
  flex: 1;
  gap: var(--space-1);
}

.top-menu-link {
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--color-muted);
  font-size: var(--text-md);
  font-weight: 600;
}

.top-menu-link:hover {
  color: var(--color-text);
}

.top-menu-link.active {
  border-bottom-color: var(--color-accent);
  color: var(--color-text);
}

.top-menu-toggle {
  display: none;
}

.account-menu {
  position: relative;
}

.account-popover {
  top: 100%;
  right: 0;
  margin-top: var(--space-2);
  display: grid;
  gap: var(--space-2);
  width: max-content;
  max-width: calc(100vw - 32px);
}

.account-popover.hidden {
  display: none;
}

.account-menu-item {
  min-height: 36px;
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--color-text);
  font-size: var(--text-md);
  font-weight: 600;
  text-align: left;
}

.account-menu-item:hover,
.account-menu-item.active {
  background: var(--color-page);
}

.account-popover .user-button-mount {
  display: grid;
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
  overflow-wrap: anywhere;
}

/* Below 700px the links fold into a menu button so the bar never overflows. */
@media (max-width: 700px) {
  .top-bar {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .top-bar-title {
    flex: 1;
    min-width: 0;
    font-size: var(--text-lg);
    white-space: normal;
  }

  .top-menu-toggle {
    display: inline-flex;
  }

  .top-menu {
    display: none;
    flex-basis: 100%;
    order: 3;
    flex-direction: column;
  }

  .top-menu.open {
    display: flex;
  }

  .top-menu-link {
    text-align: left;
    border-bottom: 0;
    border-left: 2px solid transparent;
  }

  .top-menu-link.active {
    border-left-color: var(--color-accent);
  }
}

/* ---- Home search card ---- */

.home-search {
  grid-column: 1 / -1;
  display: grid;
  gap: var(--space-3);
}

.home-search .seg {
  justify-self: start;
}

/* The search card and drawer show only the controls that belong to the chosen
   mode. app.js sets data-mode on <body>; "both" needs no rule. */
body[data-mode="sale"] [data-channel="rent"],
body:not([data-mode="sale"]) [data-channel="sale"] {
  display: none;
}

/* A source that cannot answer the current mode stays listed but muted. */
.pill-rent-only {
  display: none;
}

body[data-mode="sale"] .agency-pill.rent-only {
  color: var(--muted);
  background: #f6f8fb;
  opacity: 0.7;
}

body[data-mode="sale"] .agency-pill.rent-only .pill-rent-only {
  display: inline;
}

.status-table tbody tr.status-row.rent-only,
.status-table tbody tr.status-row.unavailable {
  color: var(--muted);
}

.status-table tbody tr.status-row.rent-only .status-name,
.status-table tbody tr.status-row.unavailable .status-name {
  opacity: 0.7;
}

.status-badge.unavailable,
.status-badge.rent-only {
  background: #8a97a8;
}

.price-qualifier {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.schedule-channel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  white-space: nowrap;
}

.home-mode-note {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.home-card {
  display: grid;
  gap: var(--space-4);
}

.home-heading {
  margin: 0;
  font-size: var(--text-xl);
}

.home-row {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
}

.home-row-place {
  grid-template-columns: minmax(0, 1fr) minmax(120px, 180px);
  align-items: start;
}

.home-row-filters {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.home-row-actions {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.home-options,
.home-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.home-buttons {
  justify-content: flex-end;
}

.home-check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-md);
  white-space: nowrap;
}

.home-check input {
  width: auto;
  min-height: 0;
  margin: 0;
}

.home-count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--color-accent);
  color: var(--color-accent-text);
  font-size: var(--text-xs);
}

.home-count.hidden {
  display: none;
}

.home-row-sources {
  gap: var(--space-2);
}

.home-sources-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.home-sources-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: var(--text-md);
  cursor: pointer;
}

.home-sources-caret {
  display: inline-block;
  transition: transform 0.15s;
}

.home-sources-toggle[aria-expanded="true"] .home-sources-caret {
  transform: rotate(90deg);
}

.home-sources-panel {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

.home-sources-panel.hidden {
  display: none;
}

.home-sources-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.home-sources-tools input {
  flex: 1 1 160px;
  min-width: 0;
}

/* Groups stack downwards. `.agency-list` wraps, and a wrapping column with a
   max height starts new columns to the right instead of scrolling down. */
#cardSourceList {
  flex-direction: column;
  flex-wrap: nowrap;
  gap: var(--space-4);
  max-height: 320px;
  overflow-y: auto;
}

.price-beds-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: var(--space-3) 0 0;
  padding: var(--space-3);
  border-radius: var(--radius-control);
  border: 1px solid var(--color-border);
  font-size: var(--text-sm);
}

.price-beds-hint.hidden {
  display: none;
}

@media (max-width: 700px) {
  .home-row-place,
  .home-row-actions {
    grid-template-columns: 1fr;
  }

  .home-row-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-buttons {
    justify-content: stretch;
  }

  .home-buttons .btn {
    flex: 1;
  }
}

/* ---- Results screen: bar, tabs row, cards, detail panel ---- */

.results-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  transition: transform 0.2s ease;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
}

/* Scrolling down puts the bar away; scrolling up (or focus inside it) brings it back. */
.results-bar.is-hidden {
  transform: translateY(calc(-100% - var(--space-4)));
}

.results-bar-summary,
.results-bar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.results-bar-chip {
  max-width: 100%;
  min-height: 36px;
  padding: 0 var(--space-3);
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-page);
  color: var(--color-text);
  font-size: var(--text-md);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results-bar-chip:hover {
  border-color: var(--color-muted);
}

.results-bar-chip.hidden {
  display: none;
}

/* The period pill is a link to Settings, so it needs the chip's box without
   the underline and with its text centred. */
a.results-bar-chip {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.results-bar-note {
  color: var(--color-accent);
  font-size: var(--text-sm);
  font-weight: 600;
}

.results-toolbar {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.results-toolbar h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: var(--text-lg);
}

.results-toolbar .toolbar-controls {
  margin-left: auto;
}

.more-menu {
  position: relative;
}

.more-popover {
  top: 100%;
  right: 0;
  margin-top: var(--space-2);
  display: grid;
  gap: var(--space-1);
  width: max-content;
  max-width: calc(100vw - 32px);
}

.more-popover.hidden {
  display: none;
}

/* Sources popover: the per-source table, opened from the results bar. Below
   700px it becomes a full-width drawer instead. */
/* The popover hangs from the whole results bar, not from its button: the
   button sits mid-bar, and a table this wide anchored to it would run off the
   left edge of the screen. */
.results-toolbar {
  position: relative;
}

.sources-popover {
  top: 100%;
  left: 0;
  margin-top: var(--space-2);
  width: min(760px, 100%);
  max-height: 70vh;
  overflow: auto;
}

.sources-popover.hidden {
  display: none;
}

.sources-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.sources-close {
  display: none;
}

.sources-button.has-failures {
  border-color: var(--color-warning);
  color: var(--color-warning);
}

@media (max-width: 700px) {
  .sources-popover {
    position: fixed;
    inset: 0;
    z-index: 1002;
    width: 100vw;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .sources-close {
    display: inline-flex;
  }
}

/* The Analysis tab is a view of its own (#analysisView is shown by setView). When there are too few priced listings the strip is hidden and this note takes its place. */
.analysis-empty {
  display: none;
}

.analysis-strip.hidden + .analysis-empty {
  display: block;
  margin: var(--space-4) 0;
  color: var(--color-muted);
  font-weight: 600;
}

/* Four headline numbers above the list, map and analysis; saved and history show other data. */
.headline-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.headline-metrics.hidden,
[data-results-view="saved"] .headline-metrics {
  display: none;
}

.headline-metrics .metric {
  align-content: start;
  min-width: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
}

.headline-metrics .metric-value {
  font-size: var(--text-xl);
  overflow-wrap: anywhere;
}

@media (max-width: 700px) {
  .headline-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* The "Filtered by analysis" chip sits between the headline numbers and the list. */
.analysis-filter-row {
  margin: var(--space-3) 0 0;
}

.analysis-filter-row .chip button {
  width: auto;
  padding: 0 var(--space-1);
  color: var(--color-accent);
  font-weight: 700;
  cursor: pointer;
}

[data-results-view="analysis"] .workspace {
  grid-template-columns: minmax(0, 1fr);
}

[data-results-view="analysis"] .detail-panel {
  display: none;
}

/* Result cards: photo left at 4:3, text right, heart top right. */
.list-view {
  grid-template-columns: minmax(0, 1fr);
}

.property-card {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: start;
}

.property-card img {
  grid-column: 1;
  grid-row: 1;
  align-self: start;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
}

.property-card .bookmark-btn {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  z-index: 1;
  background: var(--color-surface);
  box-shadow: 0 1px 3px rgba(23, 32, 42, 0.18);
}

.card-main {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  padding-right: 44px;
}

.card-main .card-top-row {
  padding: var(--space-2) var(--space-3) 0;
}

.card-main .card-top-row:empty,
.card-main .badge-row:empty {
  display: none;
}

.card-main .property-body {
  padding: var(--space-2) var(--space-3) var(--space-3);
}

.card-main .price {
  font-size: var(--text-2xl);
  line-height: 1.1;
}

.card-main .property-body h3 {
  margin: var(--space-2) 0 0;
  font-size: var(--text-md);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.card-main .meta-row {
  margin: var(--space-1) 0 0;
  gap: 0;
}

.card-main .meta-row span + span::before {
  content: "·";
  margin: 0 6px;
}

.card-sources {
  margin-top: var(--space-2);
  color: var(--color-muted);
  font-size: var(--text-sm);
}

@media (max-width: 520px) {
  .property-card {
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .card-main {
    padding-right: 40px;
  }

  .card-main .price {
    font-size: var(--text-xl);
  }
}

/* Detail panel: a right-hand column from 1100px, a slide-over below it. */
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-header .eyebrow {
  margin: 0;
}

.detail-header .btn {
  min-width: 40px;
  font-size: 24px;
}

.detail-backdrop {
  z-index: 998;
}

@media (min-width: 1100px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) 380px;
    align-items: start;
  }

  /* The selected home stays in view while the list scrolls. --sticky-top is the
     bar's height when it is showing, and just a gap when it is hidden. */
  .detail-panel {
    position: sticky;
    top: var(--sticky-top, 12px);
    min-height: min(580px, calc(100vh - var(--sticky-top, 12px) - 12px));
    max-height: calc(100vh - var(--sticky-top, 12px) - 12px);
    overflow-y: auto;
    transition: top 0.2s ease;
  }

  .detail-header .btn {
    display: none;
  }

  .detail-backdrop {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .results-bar,
  .detail-panel {
    transition: none;
  }
}

@media (max-width: 1099px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    width: min(420px, 100vw);
    overflow-y: auto;
    border-radius: 0;
    box-shadow: var(--shadow-drawer);
    visibility: hidden;
    transform: translateX(100%);
    transition: transform 0.2s ease, visibility 0.2s;
  }

  .detail-panel.open {
    visibility: visible;
    transform: translateX(0);
  }
}

@media (max-width: 700px) {
  .results-toolbar {
    align-items: stretch;
    flex-direction: row;
  }

  .results-toolbar .segmented {
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    width: 100%;
  }

  .results-toolbar .segmented button {
    min-width: 0;
    padding: 0 var(--space-2);
  }

  .results-toolbar .toolbar-controls {
    flex: 1 1 100%;
    margin-left: 0;
  }

  .results-toolbar .sort-control {
    flex: 1;
    min-width: 0;
  }

  .results-toolbar .sort-control select {
    min-width: 0;
    width: 100%;
  }
}


/* --- Analysis page: one card per watched place, and a detail chart ------------ */

.analysis-page {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.analysis-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

/* .btn sets its own display, which would otherwise keep the hidden back button showing. */
.analysis-page-head .hidden {
  display: none;
}

.analysis-page-head h2 {
  margin: 0;
  font-size: var(--text-xl);
}

.analysis-page .analysis-note {
  margin: 0;
}

.analysis-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: var(--space-4);
}

.analysis-card {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
  cursor: pointer;
}

.analysis-card:hover,
.analysis-card:focus-visible {
  border-color: var(--color-muted);
}

.analysis-card.paused {
  opacity: 0.7;
}

.analysis-card-title {
  margin: 0;
  font-size: var(--text-lg);
  overflow-wrap: anywhere;
}

.analysis-card-numbers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: var(--space-3);
}

.analysis-card-numbers .metric {
  min-width: 0;
}

.analysis-card-numbers .metric-value {
  font-size: var(--text-lg);
  overflow-wrap: anywhere;
}

/* Words and dashes in a number slot ("No change", "—") are not drawn at number size. */
.analysis-card-numbers .metric-value.metric-text {
  font-size: var(--text-base, 1rem);
  font-weight: 600;
  line-height: 1.3;
}

.analysis-card-state {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.analysis-card-state.error {
  color: var(--color-danger);
}

.analysis-delta.up {
  color: var(--color-danger);
}

.analysis-delta.down {
  color: var(--color-success);
}

.analysis-chart {
  display: block;
  max-width: 100%;
  overflow: visible;
}

.analysis-chart text {
  fill: var(--color-muted);
  font-size: 11px;
}

.analysis-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
}

.analysis-legend i {
  display: inline-block;
  width: 12px;
  height: 3px;
  margin-right: var(--space-2);
  vertical-align: middle;
  border-radius: 2px;
}

.analysis-days {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.analysis-days li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--color-border);
  font-size: var(--text-md);
}

.analysis-days li span:last-child {
  color: var(--color-muted);
  text-align: right;
}

.analysis-page-body-cards {
  display: grid;
  gap: var(--space-4);
}

/* A grid item will not shrink below its table, so the yield table would push the page sideways on a phone. */
.analysis-page-body-cards > .card { min-width: 0; }

/* Yield near here: the radius picker, then the map and the sector table side by side on a wide screen. */
.analysis-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.analysis-list-nearby {
  display: block;
  margin-top: 2px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-accent);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
}

.analysis-nearby {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
}

.nearby-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.nearby-controls-label {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.nearby-summary {
  margin: 0;
  font-size: var(--text-md);
}

.nearby-summary strong {
  font-size: var(--text-xl);
}

.nearby-layout {
  display: grid;
  gap: var(--space-4);
  min-width: 0;
}

.nearby-map-wrap,
.nearby-side {
  display: grid;
  align-content: start;
  gap: var(--space-2);
  min-width: 0;
}

.nearby-map {
  height: 320px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  z-index: 0;
}

.nearby-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.nearby-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border: 1px solid rgba(23, 32, 42, 0.55);
  border-radius: 50%;
  vertical-align: -1px;
}

.nearby-small {
  color: var(--muted, #6b7580);
  opacity: 0.75;
}

.nearby-subtitle {
  margin: var(--space-2) 0 0;
  font-size: var(--text-md);
}

.nearby-homes {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.nearby-homes li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: var(--space-2);
  align-items: baseline;
}

.nearby-rank {
  color: var(--color-muted);
  font-size: var(--text-sm);
  text-align: right;
}

.nearby-home {
  display: grid;
  min-width: 0;
}

.nearby-home-name {
  overflow-wrap: anywhere;
}

.nearby-home-meta {
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.nearby-yield {
  font-weight: 600;
  white-space: nowrap;
}

@media (min-width: 1100px) {
  .nearby-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.analysis-empty {
  display: grid;
  justify-items: start;
  gap: var(--space-3);
}

/* The list view: one table per section. The columns are kept narrow (small type,
   tight padding, headers that wrap) so all of them fit a desktop screen; on a
   narrower one it scrolls sideways inside its own box, with Place frozen. */
.analysis-list-scroll {
  /* The first column stays put while the rest scrolls sideways. Its cells need
     a solid background (so what scrolls under them is hidden) and an edge. */
  --list-sticky-bg: var(--color-surface);
  --list-sticky-head-bg: var(--color-page);
  --list-sticky-edge: rgba(23, 32, 42, 0.22);
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  background: var(--color-surface);
}

/* In a dark scheme the table brings its own colours, as the heatmap does. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .analysis-list-scroll {
    --list-sticky-bg: #1b222b;
    --list-sticky-head-bg: #232c37;
    --list-sticky-edge: rgba(0, 0, 0, 0.6);
    --color-text: #e8edf3;
    --color-muted: #9fb0c3;
    --color-border: #354151;
      --color-surface: #1b222b;
    --blue: #8db4f2;
  }
}

:root[data-theme="dark"] .analysis-list-scroll {
  --list-sticky-bg: #1b222b;
  --list-sticky-head-bg: #232c37;
  --list-sticky-edge: rgba(0, 0, 0, 0.6);
  --color-text: #e8edf3;
  --color-muted: #9fb0c3;
  --color-border: #354151;
  --color-surface: #1b222b;
  --blue: #8db4f2;
}

.analysis-list {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.analysis-list th,
.analysis-list td {
  padding: 6px 5px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.analysis-list tbody tr:last-child > * {
  border-bottom: 0;
}

.analysis-list th.num,
.analysis-list td.num {
  text-align: right;
}

.analysis-list td.empty {
  color: var(--color-muted);
}

.analysis-list thead th {
  background: var(--list-sticky-head-bg);
  vertical-align: bottom;
  white-space: normal;
  line-height: 1.2;
}

/* A paused row is dimmed by its text, not by opacity: a see-through sticky
   cell would show the columns scrolling under it. */
.analysis-list tr.paused > * {
  color: var(--color-muted);
}

.analysis-list th:first-child,
.analysis-list td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--list-sticky-bg);
  box-shadow: 1px 0 0 var(--color-border), 4px 0 6px -3px var(--list-sticky-edge);
}

.analysis-list thead th:first-child {
  z-index: 2;
  background: var(--list-sticky-head-bg);
}

.analysis-list-place {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
}

.analysis-list-link {
  color: var(--blue);
}

.analysis-list-filters {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-muted);
}

.analysis-list-paused {
  color: var(--color-muted);
  font-weight: 400;
}

.analysis-sort {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: inherit;
  cursor: pointer;
}

.analysis-sort.active {
  color: var(--blue);
}

.analysis-sort-arrow {
  display: inline-block;
  min-width: 0.9em;
  font-size: 0.8em;
}

.analysis-layout button {
  min-width: 70px;
}

/* --- History and Schedule pages -------------------------------------------- */

.history-page {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.history-page-head h2 {
  margin: 0;
  font-size: var(--text-xl);
}

.history-page-head p {
  margin: var(--space-1) 0 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.history-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-3);
}

.history-filters .field {
  min-width: 140px;
}

.history-filters .history-filter-place {
  flex: 1 1 220px;
}

.history-page .history-view {
  margin-top: 0;
}

/* The watched places as a table. Below 700px each row becomes a small card
   with its column names beside the values, so nothing scrolls sideways. */
.schedule-table-wrap {
  margin-top: var(--space-3);
}

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.schedule-table th {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
}

.schedule-table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.schedule-table tr.paused td {
  color: var(--color-muted);
}

.schedule-table .batch-state {
  display: inline-block;
  min-width: 0;
}

.schedule-table tr.running .batch-state { color: #234a8a; background: #e6eefb; }
.schedule-table tr.done .batch-state { color: #0d5c31; background: #e4f4ea; }
.schedule-table tr.failed .batch-state { color: #8b1f17; background: #fdeae7; }

.schedule-table .secondary-button {
  min-height: 28px;
  padding: 0 9px;
  font-size: var(--text-xs);
}

.schedule-row-actions {
  text-align: right;
  white-space: nowrap;
}

/* Where a "Run now" or "Re-run" is: waiting its turn, or searching. */
.run-state {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 700;
  color: #6b4a12;
  background: #fbf1dd;
}

.run-state.running {
  color: #234a8a;
  background: #e6eefb;
}

.history-actions .run-state {
  min-height: 36px;
}

.schedule-failures-row td {
  padding-top: 0;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: #cfd6e0;
  cursor: pointer;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}

.switch[aria-checked="true"] {
  border-color: var(--color-accent);
  background: var(--color-accent);
}

.switch[aria-checked="true"]::after {
  transform: translateX(16px);
}

.schedule-selection {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* Run times: on the search card, in the Save search panel and in each row of
   the Schedule table. */
.home-row-schedule {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.sched-times {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.sched-times.hidden,
.sched-time.hidden {
  display: none;
}

.sched-time,
.sched-time-input {
  width: 128px;
  min-height: 32px;
}

.sched-times .schedule-zone,
.schedule-table .sched-time-input + .secondary-button {
  padding-bottom: 0;
}

.schedule-table td[data-label="Times"] {
  gap: var(--space-2);
}

.save-search-wrap {
  position: relative;
  display: inline-block;
}

.save-search-panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: 30;
  display: grid;
  gap: var(--space-3);
  width: 340px;
  max-width: calc(100vw - 32px);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: 0 8px 24px rgba(23, 32, 42, 0.16);
}

.save-search-panel.hidden {
  display: none;
}

.save-search-panel .schedule-lead {
  margin: 0;
}

.save-search-buttons {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

.analysis-card-filters {
  margin: 2px 0 var(--space-2);
  color: var(--color-muted);
  font-size: var(--text-sm);
}

/* The master filters: one bar for every card, Rent and Buy alike. */
.analysis-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-3);
}

.analysis-filters.hidden {
  display: none;
}

.analysis-filters .field {
  flex: 1 1 130px;
  min-width: 0;
}

/* Sources, property type, let agreed and "More filters": one compact row under
   the bedroom and bathroom boxes. Each picker opens a small panel. */
.analysis-filter-more {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.analysis-picker,
.analysis-more {
  position: relative;
  min-width: 0;
}

.analysis-more[open] {
  flex-basis: 100%;
}

.analysis-picker-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-md);
  cursor: pointer;
  list-style: none;
}

.analysis-picker-button::-webkit-details-marker {
  display: none;
}

.analysis-picker-button::after {
  content: "▾";
  color: var(--color-muted);
  font-size: var(--text-sm);
}

[open] > .analysis-picker-button::after {
  content: "▴";
}

.analysis-picker-button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.analysis-picker-label {
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

.analysis-picker-value {
  font-weight: 600;
}

.analysis-picker-value:empty {
  display: none;
}

.analysis-picker-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  display: grid;
  gap: var(--space-2);
  width: min(320px, calc(100vw - 32px));
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-drawer);
}

.analysis-picker-panel input[type="search"] {
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-md);
}

.analysis-picker-list {
  display: grid;
  gap: 2px;
  max-height: 320px;
  overflow-y: auto;
}

.analysis-picker-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: var(--space-2);
  padding: 6px var(--space-1);
  border-radius: 6px;
  color: var(--color-text);
  font-size: var(--text-md);
  cursor: pointer;
}

.analysis-picker-option:hover {
  background: var(--color-page);
}

/* A label's span is a field caption elsewhere; here it is the option's name. */
.analysis-picker-option span {
  display: inline;
  margin: 0;
  color: var(--color-text);
  font-size: var(--text-md);
  font-weight: 400;
}

.analysis-picker-option small {
  grid-column: 2;
  overflow: hidden;
  color: var(--color-muted);
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analysis-picker-empty {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.analysis-link {
  justify-self: start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-accent);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.analysis-link.hidden {
  display: none;
}

.analysis-check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  color: var(--color-text);
  font-size: var(--text-md);
}

.analysis-check input,
.analysis-picker-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--color-accent);
}

.analysis-more-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-3) var(--space-4);
  margin-top: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
}

.analysis-more-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2) var(--space-3);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.analysis-more-group legend {
  margin-bottom: var(--space-1);
  padding: 0;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 700;
}

.analysis-more-words {
  grid-column: 1 / -1;
}

.analysis-more-words .location-help {
  margin: var(--space-1) 0 0;
}

.analysis-filter-summary {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

/* Where the runs could hold different homes under the filters. */
.analysis-chart-mark {
  stroke: var(--color-warning);
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
}

.analysis-change-notes {
  margin: var(--space-1) 0 0;
  padding-left: 18px;
  color: var(--color-warning);
  font-size: var(--text-xs);
}

.analysis-list-note {
  padding: 0 6px;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--color-warning);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  cursor: help;
}

@media (max-width: 560px) {
  .analysis-picker,
  .analysis-more {
    flex: 1 1 100%;
  }

  .analysis-picker-button {
    justify-content: space-between;
    width: 100%;
  }

  .analysis-picker-label {
    margin-right: auto;
  }

  .analysis-picker-panel {
    width: 100%;
  }
}

.analysis-section {
  display: grid;
  gap: var(--space-3);
}

.analysis-section-title {
  margin: 0;
  font-size: var(--text-lg);
}

/* Time on market inside a card: three figures and, small, what is behind them. */
.analysis-market {
  display: grid;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.analysis-market-numbers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.analysis-market-numbers .metric-value {
  font-size: var(--text-lg);
}

.analysis-price-numbers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: var(--space-3);
}

.analysis-price-numbers .metric-value {
  font-size: var(--text-lg);
}

.analysis-market-note {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

@media (max-width: 700px) {
  /* The panel opens under the whole bar rather than the button, so a button
     near the left edge cannot push it off screen. */
  .save-search-wrap {
    position: static;
  }

  .save-search-panel {
    right: var(--space-3);
    left: var(--space-3);
    width: auto;
    max-width: none;
  }
}

@media (max-width: 700px) {
  .schedule-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .schedule-table,
  .schedule-table tbody,
  .schedule-table tr,
  .schedule-table td {
    display: block;
  }

  .schedule-table tr {
    margin-bottom: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
  }

  .schedule-table td {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-1) 0;
    border: 0;
  }

  .schedule-table td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 72px;
    color: var(--color-muted);
    font-size: var(--text-xs);
    font-weight: 700;
  }

  .schedule-table tr.schedule-failures-row {
    border-top: 0;
    margin-top: calc(var(--space-2) * -1);
  }

  .schedule-row-actions {
    justify-content: flex-end;
  }
}
.yield-count { color: var(--muted); font-size: 12px; }

/* Schedule page: the master switch, collapsed defaults and one-off run, the
   list's toolbar and bulk bar, and the sources-by-time heatmap. */
.schedule-master {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-page);
}

.schedule-master .switch {
  width: 48px;
  height: 28px;
}

.schedule-master .switch::after {
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
}

.schedule-master .switch[aria-checked="true"]::after {
  transform: translateX(20px);
}

.schedule-master-text {
  flex: 1 1 auto;
  min-width: 0;
}

.schedule-master-text .batch-summary {
  margin: 0;
  font-weight: 600;
}

.schedule-master .schedule-note {
  padding-bottom: 0;
}

.schedule-defaults,
.one-off {
  margin-top: var(--space-3);
}

.schedule-defaults > summary,
.one-off > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 700;
}

.one-off > summary .schedule-note {
  padding-bottom: 0;
}

.one-off-actions {
  margin-top: var(--space-3);
}

.one-off-batch {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.schedule-toolbar,
.schedule-bulk {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-3);
}

.schedule-toolbar .seg button {
  min-height: 30px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
}

.schedule-toolbar input[type="search"] {
  min-height: 34px;
  width: 200px;
}

.schedule-toolbar .schedule-note,
.schedule-bulk .schedule-note,
.schedule-bulk .schedule-zone {
  padding-bottom: 0;
}

.schedule-bulk {
  padding: var(--space-3);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-control);
  background: var(--color-page);
}

.schedule-bulk.hidden {
  display: none;
}

.schedule-bulk label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.schedule-bulk label.hidden {
  display: none;
}

.schedule-bulk input[type="time"],
.schedule-bulk select {
  min-height: 34px;
}

.schedule-check-col {
  width: 28px;
}

.schedule-table tr.picked td {
  background: color-mix(in srgb, var(--color-accent) 8%, var(--color-surface));
}

.schedule-sort {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}

.schedule-sort:hover {
  color: var(--color-text);
}

th[aria-sort="ascending"] .schedule-sort::after {
  content: " \25B2";
  font-size: 9px;
}

th[aria-sort="descending"] .schedule-sort::after {
  content: " \25BC";
  font-size: 9px;
}

.schedule-last {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.schedule-last-detail {
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.schedule-last .secondary-button {
  margin-top: 2px;
}

/* Heatmap. Cells mix red to green by success rate, then thin that with the
   surface colour so the text stays readable; the dark values apply when the
   page is shown in a dark colour scheme. */
.heatmap-body {
  --hm-bad: #d2523f;
  --hm-good: #2e9e62;
  --hm-surface: var(--color-surface);
  --hm-text: var(--color-text);
  --hm-muted: var(--color-muted);
  --hm-line: var(--color-border);
  --hm-tint: 60%;
  margin-top: var(--space-3);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .heatmap-body {
    --hm-bad: #e0705e;
    --hm-good: #3fb97a;
    --hm-surface: #1b222b;
    --hm-text: #e8edf3;
    --hm-muted: #9fb0c3;
    --hm-line: #354151;
    --hm-tint: 48%;
  }
}

:root[data-theme="dark"] .heatmap-body {
  --hm-bad: #e0705e;
  --hm-good: #3fb97a;
  --hm-surface: #1b222b;
  --hm-text: #e8edf3;
  --hm-muted: #9fb0c3;
  --hm-line: #354151;
  --hm-tint: 48%;
}

.hm-scroll {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--hm-line);
  border-radius: var(--radius-control);
  background: var(--hm-surface);
}

.hm-table {
  border-collapse: separate;
  border-spacing: 2px;
  font-size: var(--text-xs);
  color: var(--hm-text);
}

.hm-table th,
.hm-table td {
  padding: 6px 10px;
  text-align: center;
  white-space: nowrap;
}

.hm-table thead th {
  color: var(--hm-muted);
  font-weight: 700;
}

.hm-table th.hm-source {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--hm-surface);
  font-weight: 600;
  text-align: left;
}

.hm-total {
  color: var(--hm-muted);
  font-weight: 700;
}

.hm-cell {
  min-width: 56px;
  border-radius: 4px;
  background: color-mix(in srgb, color-mix(in srgb, var(--hm-good) calc(var(--rate, 0) * 100%), var(--hm-bad)) var(--hm-tint), var(--hm-surface));
  font-weight: 700;
}

.hm-cell:focus-visible {
  outline: 2px solid var(--hm-text);
  outline-offset: 1px;
}

.hm-empty {
  background: transparent;
  color: var(--hm-muted);
  box-shadow: inset 0 0 0 1px var(--hm-line);
}

.hm-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  color: var(--hm-muted);
  font-size: var(--text-xs);
}

.hm-ramp {
  width: 140px;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(to right,
    color-mix(in srgb, var(--hm-bad) var(--hm-tint), var(--hm-surface)),
    color-mix(in srgb, color-mix(in srgb, var(--hm-good) 50%, var(--hm-bad)) var(--hm-tint), var(--hm-surface)),
    color-mix(in srgb, var(--hm-good) var(--hm-tint), var(--hm-surface)));
}

.hm-swatch {
  display: inline-block;
  width: 24px;
  height: 14px;
  margin-left: var(--space-3);
  border-radius: 4px;
  text-align: center;
  line-height: 14px;
}

@media (max-width: 700px) {
  .schedule-master {
    flex-wrap: wrap;
  }

  .schedule-toolbar input[type="search"] {
    flex: 1 1 100%;
    width: auto;
  }

  .schedule-table td.schedule-check-col {
    justify-content: flex-start;
  }
}

/* "Also run on a schedule": Rent / Buy / Both, each with its own times. */
.sched-channel {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.sched-channel select {
  min-height: 32px;
}

.sched-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.sched-group.hidden {
  display: none;
}

.sched-group-name {
  min-width: 34px;
  font-size: var(--text-sm);
  font-weight: 700;
}

.sched-note-line {
  flex-basis: 100%;
  margin: 0;
  padding-bottom: 0;
}

.sched-note-line.hidden {
  display: none;
}

/* Defaults for new schedules: a row each for Rent and Buy. */
.schedule-default-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  flex-basis: 100%;
}

.schedule-default-name {
  min-width: 40px;
  align-self: center;
  font-size: var(--text-sm);
}

.schedule-bulk-more {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* The clone / bulk edit form. */
.schedule-dialog {
  width: min(760px, 94vw);
  max-height: 90vh;
  padding: var(--space-4) var(--space-5);
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  color: var(--color-text);
  background: var(--color-surface);
  box-shadow: var(--shadow-drawer);
}

.schedule-dialog::backdrop {
  background: rgba(23, 32, 42, 0.45);
}

.schedule-dialog h3 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg);
}

.sd-group {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.sd-label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 700;
}

.sd-hint,
.sd-label .sd-hint {
  padding-bottom: 0;
  font-weight: 400;
}

.sd-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-accent);
  cursor: pointer;
}

.sd-times {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.sd-times input[type="time"],
.sd-times select,
.sd-group > select {
  min-height: 34px;
  max-width: 280px;
}

.sd-times input.hidden {
  display: none;
}

.sd-filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--space-3);
}

.sd-field {
  display: grid;
  gap: 4px;
  align-content: start;
}

.sd-field label:not(.sd-change) {
  display: grid;
  gap: 4px;
  font-size: var(--text-xs);
}

.sd-field select,
.sd-field input[type="text"] {
  width: 100%;
  min-height: 34px;
}

.sd-field-wide {
  grid-column: 1 / -1;
}

.sd-place {
  position: relative;
  display: grid;
  gap: var(--space-2);
  justify-items: start;
}

.sd-place input[type="search"] {
  width: 100%;
  min-height: 36px;
}

.sd-place .location-suggestions {
  top: 40px;
  max-height: 260px;
  overflow: auto;
}

.sd-sources.hidden {
  display: none;
}

.sd-sources-tools {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.sd-sources-list {
  max-height: 220px;
  padding: var(--space-2);
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
}

.sd-note {
  min-height: 1.2em;
  margin: var(--space-3) 0 0;
  color: var(--color-danger);
}

.sd-buttons {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* Heatmap: old slots, run lengths and the axis title. */
.heatmap-run-line {
  margin-top: var(--space-1);
  font-weight: 600;
}

.hm-table th.hm-axis {
  border-bottom: 1px solid var(--hm-line);
}

.hm-table .hm-meta th,
.hm-table .hm-meta td {
  color: var(--hm-muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

.hm-table .hm-meta th.hm-source {
  font-weight: 700;
}

/* The scheduled day: Rent and Buy rows over 24 hours, 1 minute = --do-min. */
.hm-metric-bar {
  margin-top: var(--space-3);
}

.day-overview {
  --do-min: 1.1px;
  --do-label: 56px;
  --do-run: color-mix(in srgb, var(--color-accent) 55%, var(--hm-surface));
  --do-wait: color-mix(in srgb, var(--color-warning) 80%, var(--hm-surface));
}

.do-chart {
  position: relative;
  width: calc(var(--do-label) + 1440 * var(--do-min) + 16px);
  padding: 8px 8px 8px 0;
  color: var(--hm-text);
  font-size: var(--text-xs);
}

.do-axis,
.do-row {
  display: flex;
}

.do-name {
  position: sticky;
  left: 0;
  z-index: 3;
  flex: 0 0 var(--do-label);
  padding: 0 8px;
  background: var(--hm-surface);
  font-weight: 700;
  line-height: 30px;
}

.do-track {
  position: relative;
  flex: 1 1 auto;
  background-image: repeating-linear-gradient(to right, var(--hm-line) 0 1px, transparent 1px calc(60 * var(--do-min)));
}

.do-axis-track {
  height: 20px;
  background-image: none;
}

.do-hour {
  position: absolute;
  top: 0;
  padding-left: 3px;
  color: var(--hm-muted);
  font-weight: 600;
}

.do-rows {
  position: relative;
  border-top: 1px solid var(--hm-line);
}

.do-row + .do-row {
  border-top: 1px solid var(--hm-line);
}

.do-run,
.do-wait {
  position: absolute;
  height: 24px;
  box-sizing: border-box;
  border-radius: 4px;
}

.do-run {
  z-index: 1;
  background: var(--do-run);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-accent) 80%, var(--hm-text));
}

.do-run.do-estimated {
  background: repeating-linear-gradient(135deg, var(--do-run) 0 2px, color-mix(in srgb, var(--do-run) 40%, var(--hm-surface)) 2px 5px);
}

.do-auc {
  min-width: 4px;
}

.do-auc .do-label {
  right: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.do-auc-1 {
  --do-run: color-mix(in srgb, var(--color-accent) 30%, var(--hm-surface));
}

.do-run.do-bad {
  box-shadow: inset 0 0 0 2px var(--color-danger);
}

.do-overlap {
  position: absolute;
  z-index: 3;
  height: 24px;
  box-sizing: border-box;
  border-radius: 4px;
  background: repeating-linear-gradient(45deg, var(--color-danger) 0 3px, transparent 3px 7px);
  box-shadow: inset 0 0 0 1px var(--color-danger);
}

.do-note {
  position: absolute;
  top: 0;
  left: 6px;
  color: var(--hm-muted);
  line-height: 30px;
  white-space: nowrap;
}

.arch-sub {
  margin: var(--space-3) 0 var(--space-1);
  font-size: var(--text-sm);
}

.arch-bad {
  color: var(--color-danger);
  font-weight: 700;
}

.do-wait {
  background: repeating-linear-gradient(45deg, var(--do-wait) 0 4px, transparent 4px 8px);
  box-shadow: inset 0 0 0 1px var(--do-wait);
}

.do-run:focus-visible {
  outline: 2px solid var(--hm-text);
  outline-offset: 1px;
}

.do-label {
  position: absolute;
  left: 4px;
  top: 0;
  z-index: 2;
  max-width: none;
  padding: 0 3px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--hm-surface) 82%, transparent);
  color: var(--hm-text);
  font-weight: 700;
  line-height: 24px;
  white-space: nowrap;
  pointer-events: none;
}

.do-now,
.do-now-key {
  background: var(--color-danger);
}

.do-now {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 4;
  width: 2px;
  pointer-events: none;
}

.do-key {
  display: inline-block;
  position: static;
  width: 28px;
  height: 14px;
  margin-left: var(--space-3);
}

.do-now-key {
  width: 2px;
  height: 14px;
}

@media (max-width: 700px) {
  .day-overview {
    --do-min: 0.9px;
    --do-label: 44px;
  }
}

/* Stop all: the one red button on the Schedule page. */
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 1px solid var(--color-danger);
  border-radius: 8px;
  padding: 0 12px;
  color: #fff;
  background: var(--color-danger);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.danger-button:hover:not(:disabled) {
  filter: brightness(0.92);
}

.danger-button:disabled {
  cursor: default;
  opacity: 0.6;
}

.schedule-switch-help {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.run-stopped {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  color: var(--color-danger);
  border: 1px solid currentColor;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

/* ---- Phone: a History entry stacks its text over its buttons ---- */
@media (max-width: 640px) {
  .history-card {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 8px 10px;
  }

  .history-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
  }

  .history-actions .secondary-button {
    flex: 1 1 auto;
  }

  .history-actions .history-del {
    flex: 0 0 auto;
  }
}

/* ---- Results bar: the places chip and its full list ---- */
#barPlaces {
  max-width: min(100%, 34rem);
}

.bar-places-wrap {
  position: relative;
  display: inline-flex;
}

.bar-places-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  width: min(22rem, 86vw);
  max-height: 60vh;
  overflow: auto;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.bar-places-popover.hidden {
  display: none;
}

.bar-places-head {
  margin: 0 0 var(--space-2);
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: 700;
}

.bar-places-popover ul {
  margin: 0;
  padding-left: 18px;
  font-size: var(--text-md);
}

/* ---- Saved searches on the Saved page ---- */
.saved-heading {
  margin: var(--space-3) 0 var(--space-2);
  font-size: var(--text-md);
  color: var(--color-muted);
}

.saved-search-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  color: var(--color-text);
}

.saved-search-main {
  flex: 1 1 16rem;
  min-width: 0;
}

.saved-search-main h4 {
  margin: 0 0 4px;
  font-size: 15px;
  overflow-wrap: break-word;
}

.saved-search-main .channel-badge {
  white-space: nowrap;
  vertical-align: middle;
}

.saved-search-meta {
  margin: 2px 0 0;
  font-size: 13px;
  overflow-wrap: break-word;
}

.saved-search-meta.muted {
  color: var(--color-muted);
  font-size: 12px;
}

.saved-search-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ---- A short message with a link, at the foot of the screen ---- */
.app-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  max-width: min(32rem, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--color-text);
  color: var(--color-surface);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.app-toast.hidden {
  display: none;
}

.app-toast a {
  color: inherit;
  text-decoration: underline;
}

/* ---- History toolbar: choose, then act; the destructive buttons stand apart ---- */
.btn-sm {
  min-height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
}

/* Outline in the danger colour; fills only on hover so it never reads as the main action. */
.btn-danger {
  border-color: var(--color-danger);
  background: transparent;
  color: var(--color-danger);
}

.btn-danger:hover:not(:disabled) {
  border-color: var(--color-danger);
  background: rgba(180, 35, 24, 0.08);
}

.history-bar {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.history-bar-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
}

.history-selected-count {
  color: var(--color-muted);
  font-size: var(--text-md);
  font-weight: 700;
}

.history-selected-count:not(:empty) {
  font-variant-numeric: tabular-nums;
}

.history-select-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}

.history-group-label {
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.history-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.history-main-actions,
.history-danger-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.history-danger-actions {
  margin-left: auto;
  padding-left: var(--space-4);
  border-left: 1px solid var(--color-border);
}

.history-load-status {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: 700;
}

@media (max-width: 640px) {
  .history-action-row {
    display: grid;
    gap: var(--space-3);
  }

  .history-main-actions .btn {
    flex: 1 1 auto;
  }

  .history-danger-actions {
    margin-left: 0;
    padding: var(--space-3) 0 0;
    border-left: 0;
    border-top: 1px solid var(--color-border);
  }

  .history-danger-actions .btn {
    flex: 1 1 auto;
    white-space: normal;
    line-height: 1.2;
    padding-block: 6px;
  }
}

/* A big result list shows a page of cards and asks for more. */
.list-more {
  display: flex;
  justify-content: center;
  padding: var(--space-3) 0;
}

.list-more-left {
  margin-left: var(--space-2);
  color: var(--color-muted);
  font-weight: 500;
}

/* A bunch of homes on the map, drawn as one numbered disc. */
.map-cluster {
  border: 0;
  background: transparent;
}

.map-cluster span {
  display: flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  background: rgba(163, 72, 22, 0.9);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ---- Test search: one row per source, filling in as each answers ---- */
.test-search {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
}

.test-search-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.test-search-head h2 {
  margin: 0;
  font-size: var(--text-lg);
}

.test-search-lead {
  margin: var(--space-1) 0 var(--space-3);
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.test-search-summary {
  margin: 0 0 var(--space-3);
  font-size: var(--text-md);
  font-weight: 700;
}

.test-search-hints:empty {
  display: none;
}

.test-hint {
  margin: 0 0 var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--color-warning);
  background: rgba(183, 121, 31, 0.1);
  font-size: var(--text-sm);
}

.test-table-wrap {
  overflow-x: auto;
}

.test-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.test-table th,
.test-table td {
  padding: 6px var(--space-2);
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: top;
}

.test-table thead th {
  color: var(--color-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.test-table tbody th {
  font-weight: 700;
}

.test-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.test-table td a {
  overflow-wrap: anywhere;
}

.test-none {
  color: var(--color-muted);
}

.test-state {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(96, 112, 133, 0.14);
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-weight: 800;
  white-space: nowrap;
}

.test-state.answered {
  background: rgba(20, 122, 63, 0.14);
  color: var(--color-success);
}

.test-state.blocked,
.test-state.error {
  background: rgba(180, 35, 24, 0.12);
  color: var(--color-danger);
}

.test-state.needs_chrome,
.test-state.reading {
  background: rgba(183, 121, 31, 0.16);
  color: var(--color-warning);
}

.test-note {
  display: block;
  margin-top: 2px;
  color: var(--color-muted);
  font-size: var(--text-xs);
}

@media (max-width: 640px) {
  .test-search {
    padding: var(--space-3);
  }

  .test-table {
    min-width: 440px;
  }

  .test-table th,
  .test-table td {
    padding: 6px 4px;
  }

  .test-table td a {
    overflow-wrap: normal;
  }
}

/* The map's area tools: draw, rectangle, circle and clear, with a line saying
   what to do next or how many homes the areas hold. */
.map-area-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.map-area-tools.hidden,
.map-area-tools .hidden {
  display: none;
}

.map-area-tools .btn {
  min-height: 36px;
  padding: 0 var(--space-3);
}

.map-area-tools .btn.active {
  border-color: var(--color-accent);
  background: rgba(8, 127, 115, 0.1);
  color: var(--color-accent);
}

.map-area-status {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

.map-area-status:empty {
  display: none;
}

/* While drawing, a press on the map draws instead of panning, scrolling the
   page or opening a home. */
.leaflet-map.is-drawing {
  cursor: crosshair;
  touch-action: none;
}

.leaflet-map.is-drawing .leaflet-marker-pane,
.leaflet-map.is-drawing .leaflet-interactive {
  pointer-events: none !important;
}

.result-area-note {
  color: var(--color-muted);
  font-size: 0.62em;
  font-weight: 600;
  vertical-align: middle;
}

@media (max-width: 700px) {
  .map-area-tools .btn {
    flex: 1 1 auto;
  }

  .map-area-status {
    flex-basis: 100%;
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .map-area-tools .btn.active {
    background: rgba(8, 127, 115, 0.22);
  }
}

:root[data-theme="dark"] .map-area-tools .btn.active {
  background: rgba(8, 127, 115, 0.22);
}

/* Auctions page: upcoming lots and results from the archive, plus labelled portal listings. */
.auctions-page {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-4) 0 var(--space-6);
}

/* The grid above comes after the global .hidden rule, so without this a lot's
   page opened below the whole list and map, and a click looked like nothing. */
.auctions-page.hidden {
  display: none;
}

.auctions-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.auctions-title {
  margin: 0 auto 0 0;
  font-size: var(--text-xl);
}

.auctions-filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-3);
  align-items: end;
}

.auctions-filters .auctions-wide {
  grid-column: span 2;
}

.auctions-filters .field.hidden {
  display: none;
}

.auctions-filter-actions {
  display: flex;
  gap: var(--space-2);
}

.auctions-sources > summary {
  cursor: pointer;
  font-weight: 600;
}

.auctions-sources-list {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.auctions-source {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.auctions-source-status,
.auctions-source-progress {
  color: var(--color-muted);
}

.auctions-source-progress {
  flex-basis: 100%;
}

.auctions-source-error {
  color: var(--color-danger, #b91c1c);
}

.auctions-source-controls {
  display: inline-flex;
  gap: var(--space-1);
}

.auctions-status {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-md);
  font-weight: 600;
}

.auctions-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-3);
}

.auction-card h3 {
  margin: var(--space-2) 0 var(--space-1);
  font-size: var(--text-lg);
}

.auction-card h3 a {
  color: var(--color-text);
  text-decoration: none;
}

.auction-card h3 a:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

.auction-meta,
.auction-price {
  margin: var(--space-1) 0 0;
  font-size: var(--text-md);
}

.auction-meta {
  color: var(--color-muted);
}

.auction-result {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.auction-card.portal {
  border-style: dashed;
  border-color: var(--blue);
}

.badge.portal-badge {
  color: #1d4a99;
  background: #e3ecfb;
}

.badge.auction-outcome.sold,
.badge.auction-outcome.sold_prior,
.badge.auction-outcome.sold_post {
  color: #1e4620;
  background: #e6f4ea;
}

.badge.auction-outcome.unsold,
.badge.auction-outcome.postponed {
  color: #7a3a0c;
  background: #fff4df;
}

.badge.auction-outcome.withdrawn {
  color: #4a4f57;
  background: #e6e9ee;
}

.badge.lease-ok {
  color: #1e4620;
  background: #e6f4ea;
}

.badge.lease-watch {
  color: #6b4a00;
  background: #fdf0c8;
}

.badge.lease-short {
  color: #7a3a0c;
  background: #ffe3cc;
}

.badge.lease-bad {
  color: #8c1d14;
  background: #fde0dd;
}

.auction-lease-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-3) 0;
}

.auction-lease-term {
  margin: 0 0 var(--space-2);
}

.auction-lease > .auctions-note:last-child {
  margin-top: var(--space-3);
}

.lease-headroom.negative {
  color: var(--color-danger);
  font-weight: 700;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.lease-ok {
    color: #b7e4c4;
    background: #1a3a24;
  }

  :root:not([data-theme="light"]) .badge.lease-watch {
    color: #f6dc8f;
    background: #4a3a0c;
  }

  :root:not([data-theme="light"]) .badge.lease-short {
    color: #ffc9a3;
    background: #5a2d10;
  }

  :root:not([data-theme="light"]) .badge.lease-bad {
    color: #ffb4ac;
    background: #5c1a15;
  }

  :root:not([data-theme="light"]) .lease-headroom.negative {
    color: #ff8a80;
  }
}

:root[data-theme="dark"] .badge.lease-ok {
  color: #b7e4c4;
  background: #1a3a24;
}

:root[data-theme="dark"] .badge.lease-watch {
  color: #f6dc8f;
  background: #4a3a0c;
}

:root[data-theme="dark"] .badge.lease-short {
  color: #ffc9a3;
  background: #5a2d10;
}

:root[data-theme="dark"] .badge.lease-bad {
  color: #ffb4ac;
  background: #5c1a15;
}

:root[data-theme="dark"] .lease-headroom.negative {
  color: #ff8a80;
}

.auctions-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
}

.auctions-pager:empty {
  display: none;
}

.auctions-page-count,
.auctions-note,
.auctions-map-key {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.auctions-portal h3 {
  margin: 0 0 var(--space-1);
}

.auctions-note {
  margin: 0 0 var(--space-3);
}

.auctions-map-key {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2) 0 0;
}

.auctions-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.auctions-dot.lot {
  background: var(--rust);
}

.auctions-dot.portal {
  margin-left: var(--space-3);
  background: var(--blue);
}

.auction-detail h2 {
  margin: var(--space-2) 0 var(--space-3);
}

.auction-detail h3 {
  margin: var(--space-5) 0 var(--space-2);
}

.auction-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
  margin: var(--space-3) 0 0;
}

.auction-facts dt {
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

.auction-facts dd {
  margin: 0;
  font-size: var(--text-md);
}

.auction-description {
  margin: 0;
  white-space: pre-wrap;
}

.auction-timeline {
  margin: 0;
  padding-left: var(--space-5);
  display: grid;
  gap: var(--space-2);
}

.auction-timeline-when {
  display: inline-block;
  min-width: 96px;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

@media (max-width: 700px) {
  .auctions-list {
    grid-template-columns: 1fr;
  }

  .auctions-filters .auctions-wide {
    grid-column: 1 / -1;
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.portal-badge {
    color: #b9d0f7;
    background: #1d2f52;
  }
}

:root[data-theme="dark"] .badge.portal-badge {
  color: #b9d0f7;
  background: #1d2f52;
}
