:root {
  --bg: #f3f5f5;
  --surface: #ffffff;
  --surface-muted: #f7f9f9;
  --text: #182124;
  --heading: #152d31;
  --muted: #5c6a6f;
  --line: #d8dfe1;
  --line-subtle: #e9edef;
  --accent: #006d77;
  --accent-hover: #00545c;
  --control-line: #aebcc0;
  --raw-bg: #182629;
  --raw-text: #eef4f4;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #111516;
  --surface: #1a1f20;
  --surface-muted: #222829;
  --text: #edf1f1;
  --heading: #f5f8f8;
  --muted: #a8b4b7;
  --line: #394245;
  --line-subtle: #2c3436;
  --accent: #79cdd2;
  --accent-hover: #a1e3e6;
  --control-line: #536064;
  --raw-bg: #0b0e0f;
  --raw-text: #e8eeee;
  color-scheme: dark;
}

html,
body {
  background: var(--bg);
  color: var(--text);
}

body > header {
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 13px 24px;
  border-color: var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: 0 1px 0 rgb(0 0 0 / 4%);
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 2000;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--heading);
  color: var(--surface);
  font-weight: 800;
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

main {
  width: min(1440px, 100%);
  padding-top: 28px;
}

a { color: var(--accent); }
.brand,
h1,
h2,
h3,
.metric { color: var(--heading); }
p,
.label,
.summary-row { color: var(--muted); }

nav {
  align-items: center;
  column-gap: 14px;
  row-gap: 7px;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.logout-form {
  display: inline;
  max-width: none;
}

.logout-form .button-secondary {
  padding: 8px 10px;
}

.login-shell {
  display: grid;
  min-height: min(65vh, 560px);
  place-items: center;
}

.login-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: var(--surface);
  box-shadow: 0 12px 36px rgb(0 0 0 / 8%);
}

.login-card h1 { font-size: 28px; }
.login-card form { max-width: none; }
.login-error { color: #9b1c1c; font-weight: 700; }

.nav-count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  min-height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #b23a48;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
}

.theme-toggle {
  display: inline-grid;
  flex: 0 0 36px;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--control-line);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 19px;
  line-height: 1;
}

.theme-toggle:hover { border-color: var(--accent); }

.card,
.toolbar,
.table-wrap,
.map-band {
  border-color: var(--line) !important;
  background: var(--surface) !important;
}

.map-load-button {
  align-self: center;
  justify-self: center;
}

#lien-map {
  display: grid;
  place-items: center;
}

#lien-map.is-loaded { display: block; }

.toolbar,
.toolbar-wide,
.toolbar-opportunities {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}

.toolbar > div {
  flex: 1 1 142px;
  min-width: 0;
}

.toolbar > div:first-child { flex: 3 1 260px; }
.toolbar > .sort-control { flex: 1 1 150px; }
.toolbar > button { flex: 0 0 auto; }

label { color: var(--text); }

input[type="file"],
input[type="search"],
input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
  border-color: var(--control-line);
  background: var(--surface);
  color: var(--text);
}

input::placeholder { color: var(--muted); }

button:not(.theme-toggle):not(.button-secondary):not(.button-danger) {
  background: var(--accent-hover);
}

.button-secondary {
  border-color: var(--control-line);
  background: var(--surface);
  color: var(--text);
}

.button-reset,
.muted,
.fact-list dt { color: var(--muted); }

.table-wrap { box-shadow: 0 1px 2px rgb(0 0 0 / 4%); }
th,
td { border-color: var(--line-subtle); }
th {
  background: var(--surface-muted);
  color: var(--muted);
}

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: inherit;
  white-space: nowrap;
}

.sort-link:hover { color: var(--accent); }
.sort-indicator { min-width: 10px; color: var(--accent); }

.money {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  white-space: nowrap;
}

.money-negative { color: #b23a48; }
html[data-theme="dark"] .money-negative { color: #ff929d; }
.money-note { margin: 10px 0 18px; font-size: 13px; }

.chip,
.score-badge {
  border-color: var(--control-line);
  background: var(--surface-muted);
  color: var(--text);
}

.chip-linked,
.readiness-contact_ready {
  border-color: #7eb58a;
  background: #e3f9e5;
  color: #0f5132;
}

.readiness-researchable,
.severity-watch,
.score-medium {
  border-color: #d8b24c;
  background: #fff9e8;
  color: #704100;
}

.readiness-blocked,
.severity-high,
.severity-critical,
.score-high {
  border-color: #d88c8c;
  background: #fff1f1;
  color: #8b1d1d;
}

.readiness-disqualified {
  border-color: #9fb3c8;
  background: #e9eef3;
  color: #334e68;
}

html[data-theme="dark"] .chip-linked,
html[data-theme="dark"] .readiness-contact_ready {
  border-color: #34735a;
  background: #183c30;
  color: #a6e4c5;
}

html[data-theme="dark"] .readiness-researchable,
html[data-theme="dark"] .severity-watch,
html[data-theme="dark"] .score-medium {
  border-color: #826b31;
  background: #3b321b;
  color: #f2d88b;
}

html[data-theme="dark"] .readiness-blocked,
html[data-theme="dark"] .severity-high,
html[data-theme="dark"] .severity-critical,
html[data-theme="dark"] .score-high {
  border-color: #864b50;
  background: #412326;
  color: #ffb5ba;
}

html[data-theme="dark"] .readiness-disqualified {
  border-color: #58666a;
  background: #2d3537;
  color: #c4cdcf;
}

.raw-block {
  border-color: var(--line);
  background: var(--raw-bg);
  color: var(--raw-text);
}

.map-note {
  border-color: var(--line) !important;
  background: var(--surface-muted);
  color: var(--muted) !important;
}

#parcel-map { border-color: var(--line) !important; }

.case-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.case-heading h1 { margin-bottom: 3px; }
.case-heading-subtitle { margin: 0; font-size: 14px; }
.case-heading-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.inline-form { display: inline; max-width: none; }
.research-search-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.watch-notice,
.watch-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid #d3a947;
  border-radius: 6px;
  padding: 12px 14px;
  background: #fff9e8;
  color: #573b00;
}

.watch-notice > div,
.watch-status > div:first-child { display: grid; gap: 3px; }
.watch-notice span,
.watch-status span { color: #725817; font-size: 13px; }
.watch-status { margin-top: 18px; }
.watch-status-meta { color: #725817; font-size: 13px; text-align: right; }

.research-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding: 11px 0;
  border-block: 1px solid var(--line);
}

.research-status > div { display: grid; gap: 3px; }
.research-status span:not(.chip) { color: var(--muted); font-size: 13px; }

.research-steps {
  display: grid;
  grid-template-columns: repeat(7, minmax(110px, 1fr));
  border-bottom: 1px solid var(--line);
}

.research-step {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-content: start;
  gap: 2px 6px;
  min-height: 72px;
  padding: 12px 10px;
  border-right: 1px solid var(--line-subtle);
  color: var(--muted);
  font-size: 12px;
}

.research-step:last-child { border-right: 0; }
.research-step-mark {
  display: inline-grid;
  grid-row: 1 / span 2;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--control-line);
  border-radius: 50%;
  font-weight: 800;
  line-height: 1;
}
.research-step strong { color: var(--text); font-variant-numeric: tabular-nums; }
.research-step.is-complete .research-step-mark {
  border-color: #3b7d5f;
  background: #e5f5ed;
  color: #24553f;
}
.research-step.is-partial .research-step-mark {
  border-color: #b58a2d;
  background: #fff4d6;
  color: #725817;
}
.research-step.is-processing .research-step-mark,
.research-step.is-queued .research-step-mark {
  border-color: #4b7f8b;
  background: #e7f3f5;
  color: #285962;
}

.research-gaps {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 14px;
  padding: 8px 0;
  color: var(--muted);
  font-size: 12px;
}

.watch-update-list { display: grid; border-block: 1px solid var(--line); }
.watch-update-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line-subtle);
  color: var(--text);
}
.watch-update-item:last-child { border-bottom: 0; }
.watch-update-item:hover { text-decoration: none; background: var(--surface-muted); }
.watch-update-item > span:last-child { color: var(--muted); font-size: 12px; }
.watch-update-item.is-unread strong::before { content: "New: "; color: #b23a48; }

.view-tabs { display: flex; gap: 4px; margin: 22px 0 12px; }
.view-tabs a {
  border-bottom: 2px solid transparent;
  padding: 8px 12px;
  color: var(--muted);
  font-weight: 700;
}
.view-tabs a:hover { text-decoration: none; color: var(--accent); }
.view-tabs a.is-active { border-color: var(--accent); color: var(--text); }
.notification-unread { background: color-mix(in srgb, #fff4d0 65%, var(--surface)); }
.notification-title { display: block; margin-top: 7px; }
.notification-description { max-width: 540px; margin-top: 4px; line-height: 1.4; }
.notification-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.notification-actions button { padding: 7px 9px; font-size: 12px; }

html[data-theme="dark"] .watch-notice,
html[data-theme="dark"] .watch-status {
  border-color: #826b31;
  background: #302a1b;
  color: #f2d88b;
}
html[data-theme="dark"] .watch-notice span,
html[data-theme="dark"] .watch-status span,
html[data-theme="dark"] .watch-status-meta { color: #d9c47f; }
html[data-theme="dark"] .research-step.is-complete .research-step-mark {
  border-color: #34735a;
  background: #183c30;
  color: #a6e4c5;
}
html[data-theme="dark"] .research-step.is-partial .research-step-mark {
  border-color: #826b31;
  background: #3b321b;
  color: #f2d88b;
}
html[data-theme="dark"] .research-step.is-processing .research-step-mark,
html[data-theme="dark"] .research-step.is-queued .research-step-mark {
  border-color: #457782;
  background: #1d363b;
  color: #a6dce0;
}
html[data-theme="dark"] .notification-unread {
  background: color-mix(in srgb, #6b5726 30%, var(--surface));
}

.case-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  margin-top: 22px;
  border-block: 1px solid var(--line);
}

.case-summary > div {
  display: grid;
  gap: 2px;
  padding: 13px 16px;
  border-right: 1px solid var(--line-subtle);
}

.case-summary > div:last-child { border-right: 0; }
.case-summary strong { color: var(--heading); font-size: 22px; font-variant-numeric: tabular-nums; }
.case-summary span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }

.case-toolbar {
  display: block !important;
}

.case-filter-primary {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) repeat(4, minmax(130px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.case-filter-primary > div,
.case-filter-primary > div:first-child,
.case-filter-primary > .sort-control,
.case-filter-primary > button { width: auto; min-width: 0; }
.case-filter-primary > button { align-self: end; }
.case-filter-controls > summary { display: none; }

.case-filter-advanced {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line-subtle);
}

.case-filter-advanced > summary {
  min-height: 34px;
  padding-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.case-filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  padding-top: 6px;
}

.case-queue-wrap { overflow-x: hidden; }
.case-queue-table { table-layout: fixed; }
.lead-queue-wrap { overflow-x: hidden; }
.lead-queue-table { table-layout: fixed; }
.lead-col-rank { width: 16%; }
.lead-col-property { width: 24%; }
.lead-col-value { width: 19%; }
.lead-col-evidence { width: 20%; }
.lead-col-path { width: 21%; }
.lead-queue-table th,
.lead-queue-table td { overflow-wrap: anywhere; }
.lead-queue-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }
.case-col-score { width: 18%; }
.case-col-property { width: 21%; }
.case-col-economics { width: 19%; }
.case-col-distress { width: 21%; }
.case-col-execution { width: 21%; }

.case-queue-table th,
.case-queue-table td {
  overflow-wrap: anywhere;
}

.case-queue-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }
.case-score-cell { background: color-mix(in srgb, var(--surface-muted) 52%, transparent); }

.candidate-rank,
.case-inline-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.candidate-rank { margin-bottom: 9px; }
.candidate-tier { white-space: normal; }
.candidate-high_conviction { border-color: #3d8b68; background: #e7f5ed; color: #175d40; }
.candidate-qualified { border-color: #4d8296; background: #e7f2f5; color: #24586b; }
.candidate-watch { border-color: #c49a31; background: #fff7df; color: #765500; }
.candidate-screened_out { border-color: #9aa6aa; background: #edf0f1; color: #4b595d; }

html[data-theme="dark"] .candidate-high_conviction { border-color: #3d8b68; background: #173b2d; color: #a9e7c8; }
html[data-theme="dark"] .candidate-qualified { border-color: #4d8296; background: #18333d; color: #abd8e6; }
html[data-theme="dark"] .candidate-watch { border-color: #8f742e; background: #3b321b; color: #f2d88b; }
html[data-theme="dark"] .candidate-screened_out { border-color: #58666a; background: #2d3537; color: #c4cdcf; }

.note-source_ready { border-color: #34785a; background: #e5f4ec; color: #175d40; }
.note-research_ready { border-color: #9b7625; background: #fff6d9; color: #6b4d00; }
.note-blocked { border-color: #9a555b; background: #fae9eb; color: #7d2932; }
html[data-theme="dark"] .note-source_ready { border-color: #3d8b68; background: #173b2d; color: #a9e7c8; }
html[data-theme="dark"] .note-research_ready { border-color: #8f742e; background: #3b321b; color: #f2d88b; }
html[data-theme="dark"] .note-blocked { border-color: #864b50; background: #412326; color: #ffb5ba; }

.note-toolbar > div:first-child { flex: 2.4 1 250px; }
.note-toolbar > div { flex: 1 1 150px; }
.note-queue-wrap { overflow-x: auto; }
.note-queue-table { min-width: 1080px; table-layout: fixed; }
.note-queue-table th:nth-child(1) { width: 17%; }
.note-queue-table th:nth-child(2) { width: 22%; }
.note-queue-table th:nth-child(3) { width: 20%; }
.note-queue-table th:nth-child(4) { width: 21%; }
.note-queue-table th:nth-child(5) { width: 20%; }
.note-queue-table td { overflow-wrap: anywhere; vertical-align: top; }
.note-queue-table td > .button-secondary { display: inline-block; margin-top: 10px; }

.scenario-tabs {
  display: flex;
  gap: 2px;
  margin: 20px 0 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}
.scenario-tabs a {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}
.scenario-tabs a:hover,
.scenario-tabs a.is-active { border-color: var(--accent); color: var(--heading); }

.note-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  margin: 20px 0;
  border-block: 1px solid var(--line);
  background: var(--surface);
}
.note-metrics > div { min-width: 0; padding: 14px; border-right: 1px solid var(--line-subtle); }
.note-metrics > div:last-child { border-right: 0; }
.note-metrics span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.note-metrics strong { display: block; overflow-wrap: anywhere; color: var(--heading); font-size: 20px; font-variant-numeric: tabular-nums; }

.note-hurdle {
  margin: 20px 0;
  border-block: 1px solid var(--line);
  padding: 16px 0;
}
.note-hurdle .summary-row h2 { margin: 3px 0 0; }
.note-hurdle-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}
.note-hurdle-values {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  margin-top: 14px;
  border-top: 1px solid var(--line-subtle);
}
.note-hurdle-values > div {
  min-width: 0;
  padding: 14px;
  border-right: 1px solid var(--line-subtle);
}
.note-hurdle-values > div:last-child { border-right: 0; }
.note-hurdle-values span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.note-hurdle-values strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--heading);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.note-hurdle .note-requirements { margin: 10px 0 0; }

.note-requirements {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 18px;
  border-left: 3px solid #b78925;
  padding: 9px 12px;
  background: var(--surface-muted);
  font-size: 13px;
}
.note-requirements span { color: var(--muted); }
.note-detail-grid { grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.8fr); }
.note-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.note-form-grid > div { min-width: 0; }
.note-form-grid label:not([for="id_is_primary"]) { display: block; min-height: 34px; margin-bottom: 4px; font-size: 12px; line-height: 1.3; }
.note-form-grid input:not([type="checkbox"]),
.note-form-grid select,
.note-form-grid textarea { width: 100%; }
.note-field-wide { grid-column: 1 / -1; }
.note-checkbox { display: flex; align-items: center; gap: 8px; }
.note-checkbox label { margin: 0; }
.note-scenario-form .case-heading-actions { margin-top: 16px; }
.note-comparison { margin-top: 26px; }
.errorlist { margin: 5px 0 0; padding: 0; color: #b23a48; font-size: 12px; list-style: none; }
html[data-theme="dark"] .errorlist { color: #ff929d; }
.form-error { color: #b23a48; font-weight: 700; }
html[data-theme="dark"] .form-error { color: #ff929d; }
.button-danger { background: #a42d3b !important; color: #fff; }
.button-danger:hover { background: #84232e !important; }

.case-reason,
.case-address,
.case-route,
.case-meta,
.case-caveat {
  display: block;
}

.case-reason {
  margin-top: 5px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
}

.case-property { display: inline-block; margin-bottom: 3px; font-size: 15px; font-weight: 800; line-height: 1.3; }
.case-address { color: var(--muted); font-size: 12px; line-height: 1.4; }
.case-inline-chips { margin-top: 10px; }
.case-meta { margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.case-route { margin-top: 9px; color: var(--text); font-size: 12px; font-weight: 700; line-height: 1.4; }
.case-caveat { margin-top: 8px; border-left: 2px solid #c49a31; padding-left: 7px; color: var(--muted); font-size: 11px; line-height: 1.4; }

.case-facts { display: grid; gap: 7px; margin: 10px 0 0; }
.case-facts > div { display: grid; grid-template-columns: minmax(74px, 0.8fr) minmax(0, 1.2fr); gap: 8px; }
.case-facts dt { color: var(--muted); font-size: 11px; font-weight: 700; }
.case-facts dd { min-width: 0; margin: 0; color: var(--text); font-size: 12px; line-height: 1.35; }

.candidate-analysis { margin-top: 22px; }
.candidate-analysis .summary-row h2 { margin: 0; }
.candidate-components {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  margin: 16px 0;
  border-block: 1px solid var(--line-subtle);
}
.candidate-components > div { display: flex; justify-content: space-between; gap: 8px; padding: 12px; border-right: 1px solid var(--line-subtle); }
.candidate-components > div:last-child { border-right: 0; }
.candidate-components span { color: var(--muted); font-size: 12px; font-weight: 700; }
.candidate-components strong { color: var(--heading); font-variant-numeric: tabular-nums; }
.candidate-rationale { margin-top: 0; }
.candidate-score-audit { margin-top: 12px; border-top: 1px solid var(--line-subtle); }

html[data-theme="dark"] .leaflet-popup-content-wrapper,
html[data-theme="dark"] .leaflet-popup-tip {
  background: var(--surface);
  color: var(--text);
}

details > summary { color: var(--text); }
.message { border-color: #5f9b79; }
.message-error {
  border-color: #d88c8c;
  background: #fff1f1;
  color: #8b1d1d;
}
.message-warning {
  border-color: #d8b24c;
  background: #fff9e8;
  color: #704100;
}
.upload-failure-link { color: #8b1d1d; font-weight: 700; }

html[data-theme="dark"] .message-error {
  border-color: #824b50;
  background: #3d2024;
  color: #ffb2b8;
}

html[data-theme="dark"] .message-warning {
  border-color: #826b31;
  background: #3b321b;
  color: #f5d98a;
}

html[data-theme="dark"] .leaflet-layer,
html[data-theme="dark"] .leaflet-control-zoom-in,
html[data-theme="dark"] .leaflet-control-zoom-out,
html[data-theme="dark"] .leaflet-control-attribution {
  filter: invert(92%) hue-rotate(155deg) brightness(88%) contrast(90%);
}

@media (max-width: 820px) {
  body > header {
    position: static;
    display: grid;
    grid-template-columns: 1fr auto;
  }

  body > header nav {
    grid-column: 1 / -1;
    order: 3;
  }

  .theme-toggle {
    grid-column: 2;
    grid-row: 1;
  }

  .toolbar > div,
  .toolbar > div:first-child,
  .toolbar > .sort-control,
  .toolbar > button {
    flex-basis: 100%;
    width: 100%;
  }

  .toolbar > button { justify-content: center; }
  .responsive-table tr { border-color: var(--line); }
  .responsive-table td::before { color: var(--muted); }

  .case-heading { align-items: flex-start; flex-direction: column; }
  .case-heading-actions { width: 100%; }
  .case-heading-actions .button-secondary { flex: 1 1 auto; text-align: center; }
  .watch-notice,
  .watch-status,
  .research-status { align-items: flex-start; flex-direction: column; }
  .watch-status-meta { text-align: left; }
  .research-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .research-step:nth-child(2n) { border-right: 0; }
  .research-step { border-bottom: 1px solid var(--line-subtle); }
  .research-step:last-child { border-bottom: 0; }
  .watch-update-item { grid-template-columns: auto minmax(0, 1fr); }
  .watch-update-item > span:last-child { grid-column: 2; }
  .case-summary { grid-template-columns: repeat(2, 1fr); }
  .case-summary > div:nth-child(2n) { border-right: 0; }
  .case-summary > div:nth-child(-n + 4) { border-bottom: 1px solid var(--line-subtle); }

  .case-filter-controls > summary {
    display: flex;
    min-height: 38px;
    color: var(--text);
    font-weight: 800;
  }
  .case-filter-primary { grid-template-columns: 1fr; padding-top: 12px; }
  .case-filter-primary > div,
  .case-filter-primary > div:first-child,
  .case-filter-primary > .sort-control,
  .case-filter-primary > button {
    width: 100%;
  }
  .case-filter-grid { grid-template-columns: 1fr; }

  .case-queue-table colgroup { display: none; }
  .lead-queue-table colgroup { display: none; }
  .case-queue-table td {
    display: block;
    padding: 9px 0;
  }
  .lead-queue-table td {
    display: block;
    padding: 9px 0;
  }
  .lead-queue-table td::before {
    display: block;
    margin-bottom: 6px;
  }
  .lead-queue-table tr { padding: 12px 14px; }
  .case-queue-table td::before {
    display: block;
    margin-bottom: 6px;
  }
  .case-queue-table tr { padding: 12px 14px; }
  .case-score-cell { background: transparent; }
  .case-facts > div { grid-template-columns: minmax(88px, 0.65fr) minmax(0, 1.35fr); }
  .candidate-components { grid-template-columns: repeat(2, minmax(100px, 1fr)); }
  .candidate-components > div:nth-child(2) { border-right: 0; }
  .candidate-components > div:nth-child(-n + 2) { border-bottom: 1px solid var(--line-subtle); }
  .note-queue-table { min-width: 0; }
  .note-queue-table td { display: block; padding: 9px 0; }
  .note-queue-table td::before { display: block; margin-bottom: 6px; }
  .note-queue-table tr { padding: 12px 14px; }
  .note-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .note-metrics > div { border-bottom: 1px solid var(--line-subtle); }
  .note-metrics > div:nth-child(2n) { border-right: 0; }
  .note-metrics > div:last-child { grid-column: 1 / -1; border-bottom: 0; }
  .note-hurdle-values { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .note-hurdle-values > div { border-bottom: 1px solid var(--line-subtle); }
  .note-hurdle-values > div:nth-child(2n) { border-right: 0; }
  .note-hurdle-values > div:nth-last-child(-n + 2) { border-bottom: 0; }
  .note-detail-grid { grid-template-columns: 1fr; }
  .note-form-grid { grid-template-columns: 1fr; }
  .note-field-wide { grid-column: auto; }
}

@media (min-width: 821px) and (max-width: 1180px) {
  .case-filter-primary { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .case-search { grid-column: span 2; }
}
