:root {
  --bg: #111211;
  --panel: #191b1a;
  --panel-strong: #202321;
  --panel-soft: #151715;
  --line: #31352f;
  --line-soft: #252923;
  --text: #f0f2ed;
  --muted: #b8c1b2;
  --faint: #879080;
  --green: #4fc46b;
  --green-soft: #193420;
  --amber: #d8a843;
  --amber-soft: #3a2d13;
  --red: #df625d;
  --red-soft: #371a18;
  --blue: #78a8d8;
  --blue-soft: #152736;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  border-bottom: 1px solid var(--line);
  background: #151715;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1680px;
  margin: 0 auto;
  padding: 16px 20px;
}

h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.15;
}

header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.header-chip {
  flex: 0 0 auto;
  border: 1px solid #3b5f42;
  border-radius: 999px;
  background: var(--green-soft);
  color: #bff0c8;
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

main {
  max-width: 1680px;
  margin: 0 auto;
  padding: 14px 20px 20px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 2px;
}

select,
input[type="range"],
.ofa-evidence-panel input,
.ofa-evidence-panel textarea,
.review-note-label textarea {
  width: 100%;
  color: var(--text);
  background: #101210;
  border: 1px solid #3a4038;
  border-radius: 8px;
  font: inherit;
}

select {
  min-height: 38px;
  padding: 8px 10px;
}

input[type="range"] {
  accent-color: var(--green);
}

input[type="checkbox"] {
  accent-color: var(--green);
}

#scoreValue {
  color: var(--text);
  font-size: 0.86rem;
}

.filter-button {
  align-self: end;
  width: 100%;
  min-height: 38px;
  color: #061109;
  background: var(--green);
  border: 1px solid var(--green);
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}

.filter-button.secondary {
  color: var(--text);
  background: #252823;
  border-color: #485142;
}

body:not([data-admin="true"]) .advanced-filter {
  display: none;
}

.filter-button:hover,
.review-actions button:hover,
.parent-review-actions button:hover,
.map-card-btn:hover,
.public-action:hover {
  filter: brightness(1.08);
}

.view-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 230px) minmax(180px, 230px) 1fr;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid #334136;
  border-radius: 8px;
  background: #151a15;
}

.view-toolbar-copy {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.view-toolbar-copy strong {
  color: var(--text);
  font-size: 0.96rem;
}

.public-disclaimer {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #4a5d4b;
  border-radius: 8px;
  background: #f7f8f3;
  color: #3f4b3b;
  font-size: 0.86rem;
  line-height: 1.45;
}

.public-disclaimer strong {
  color: #18331f;
}

.data-status {
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.status-topline {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.status-topline strong {
  color: var(--text);
  font-size: 0.94rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.metric {
  min-height: 76px;
  padding: 9px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel-soft);
}

.metric-label,
.metric-note {
  display: block;
  color: var(--faint);
  font-size: 0.73rem;
}

.metric strong {
  display: block;
  margin: 3px 0;
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1.1;
}

.status-footnote {
  margin-top: 9px;
  color: var(--faint);
  font-size: 0.78rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(520px, 1.12fr) minmax(440px, 0.88fr);
  gap: 12px;
  align-items: start;
}

#map {
  width: 100%;
  height: calc(100vh - 250px);
  min-height: 520px;
  max-height: 820px;
  align-self: start;
  position: sticky;
  top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #20231f;
}

#resultsMeta {
  display: flex;
  align-items: center;
  min-height: 34px;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 800;
}

#results {
  display: grid;
  gap: 10px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
}

.card.public-card {
  display: grid;
  grid-template-columns: 156px 1fr;
  gap: 12px;
  padding: 10px;
  background: #f7f8f3;
  border-color: #d7decf;
  color: #161a14;
  box-shadow: 0 8px 22px rgba(0,0,0,0.18);
}

.card.has-ofa-evidence {
  border-color: #3b7a48;
  box-shadow: inset 4px 0 0 var(--green);
}

.card.public-card.has-ofa-evidence {
  box-shadow: inset 4px 0 0 #2e8d47, 0 8px 22px rgba(0,0,0,0.18);
}

.card-content {
  min-width: 0;
}

.public-card-image {
  width: 100%;
  height: 156px;
  border-radius: 7px;
  object-fit: cover;
  background: #dfe5d8;
}

.card h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.25;
}

.public-card h3 {
  color: #111710;
  font-size: 1.05rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 9px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 800;
  line-height: 1.15;
}

.badge.ok { background: var(--green-soft); color: #bff0c8; border-color: #3b7a48; }
.badge.info { background: var(--blue-soft); color: #bdddf3; border-color: #3f6582; }
.badge.warn { background: var(--amber-soft); color: #f0d18c; border-color: #8b6725; }
.badge.fail { background: var(--red-soft); color: #f2b3af; border-color: #7d3733; }
.badge.exclusive { background: #332d16; color: #e7d482; border-color: #75662c; }
.badge.neutral { background: #242721; color: #c7d0c0; border-color: #42493d; }

.small {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.42;
}

.public-card .small {
  color: #52604d;
}

.small a,
.ofa-candidate-row a {
  color: #a9d2f0;
  text-decoration: none;
}

.small a:hover,
.ofa-candidate-row a:hover {
  text-decoration: underline;
}

.red-flags {
  color: #f0b2ae;
}

.parent-health-panel {
  display: grid;
  gap: 8px;
  margin: 10px 0;
  padding: 10px;
  border: 1px solid #344136;
  border-radius: 8px;
  background: #141814;
}

.public-card .parent-health-panel {
  border-color: #d5decf;
  background: #ffffff;
}

.parent-health-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 900;
}

.public-card .parent-health-header {
  color: #172015;
}

.parent-health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
}

.parent-health-row {
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px solid #2d352c;
  border-radius: 8px;
  background: #181c17;
}

.public-card .parent-health-row {
  background: #f5f7f0;
}

.parent-health-row.matched {
  border-color: #3b7a48;
  background: var(--green-soft);
}

.public-card .parent-health-row.matched {
  background: #e9f6ec;
}

.parent-health-row.review {
  border-color: #8b6725;
  background: var(--amber-soft);
}

.public-card .parent-health-row.review {
  background: #fbf2d9;
}

.parent-health-row.missing {
  border-color: #7d3733;
  background: var(--red-soft);
}

.public-card .parent-health-row.missing {
  background: #f9e8e6;
}

.parent-health-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.parent-health-top strong {
  color: var(--text);
  font-size: 0.82rem;
}

.public-card .parent-health-top strong {
  color: #172015;
}

.parent-health-top a {
  color: #a9d2f0;
  font-size: 0.75rem;
  font-weight: 800;
  text-decoration: none;
}

.parent-health-top a:hover {
  text-decoration: underline;
}

.parent-health-akc {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.public-card .parent-health-akc {
  color: #5f6b5a;
}

.parent-health-tests {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.parent-health-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 7px;
  border: 1px solid #4f8d5a;
  border-radius: 999px;
  background: rgba(11, 18, 12, 0.42);
  color: #d8f5dc;
  font-size: 0.73rem;
}

.public-card .parent-health-chip {
  background: #ffffff;
  color: #1f542c;
}

.parent-health-chip strong {
  color: #aaf0b7;
  font-weight: 900;
}

.public-card .parent-health-chip strong {
  color: #1f6b31;
}

.parent-health-chip.muted {
  border-color: #6b3935;
  color: #f2b3af;
  background: rgba(30, 12, 10, 0.35);
}

.public-trust {
  margin: 8px 0;
  color: #4d5849;
  font-size: 0.84rem;
  line-height: 1.4;
}

.public-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.public-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid #53705a;
  border-radius: 8px;
  background: #ffffff;
  color: #244d2e;
  font-size: 0.78rem;
  font-weight: 900;
  text-decoration: none;
}

.public-action.primary {
  background: #2e693d;
  color: #ffffff;
  border-color: #2e693d;
}

.review-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.review-actions button,
.parent-review-actions button {
  min-height: 30px;
  padding: 5px 8px;
  color: var(--text);
  background: #242821;
  border: 1px solid #46513f;
  border-radius: 8px;
  cursor: pointer;
}

.parent-review-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.parent-review-actions button {
  min-height: 26px;
  padding: 4px 7px;
  font-size: 0.72rem;
}

.review-note-label {
  font-size: 0.76rem;
}

.review-note-label textarea,
.ofa-evidence-panel textarea {
  resize: vertical;
  min-height: 54px;
  padding: 8px;
}

.ofa-evidence-panel {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #131513;
}

.ofa-evidence-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.ofa-evidence-title {
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 900;
}

.ofa-candidate-row {
  display: grid;
  gap: 6px;
  margin-top: 7px;
  padding: 7px;
  border: 1px solid #2a3028;
  border-radius: 8px;
  background: #171a16;
}

.ofa-candidate-row.no-record {
  border-color: #7d3733;
  background: var(--red-soft);
}

.ofa-parent-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.ofa-match-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 8px 0;
}

.ofa-match-summary span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid #46513f;
  border-radius: 999px;
  background: #20251e;
  color: var(--muted);
  font-size: 0.73rem;
}

.ofa-result-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.ofa-result-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 7px;
  border: 1px solid #3b7a48;
  border-radius: 999px;
  background: var(--green-soft);
  color: #d1f5d8;
  font-size: 0.73rem;
}

.ofa-result-chip strong {
  color: #9be7aa;
  font-weight: 900;
}

.ofa-result-chip.muted {
  border-color: #42493d;
  background: #242721;
  color: var(--muted);
}

.ofa-evidence-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.ofa-evidence-panel label {
  font-size: 0.76rem;
}

.ofa-evidence-panel input,
.ofa-evidence-panel textarea {
  padding: 7px;
}

.ofa-evidence-tests {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ofa-test {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 3px 7px;
  border: 1px solid #46513f;
  border-radius: 999px;
  color: var(--text);
  background: #242821;
  font-size: 0.74rem;
}

.ofa-test input {
  width: auto;
}

.ofa-evidence-note {
  margin-top: 8px;
}

.dog-pin {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 3px solid var(--green);
  background: #101210;
  overflow: hidden;
  box-shadow: 0 3px 14px rgba(0,0,0,0.38);
}

.dog-pin img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: transparent;
  box-shadow: none;
}

.leaflet-popup-content {
  margin: 0;
}

.map-card {
  width: 292px;
  overflow: hidden;
  border: 1px solid #d4ddcd;
  border-radius: 8px;
  background: #fbfcf8;
  color: #151812;
  box-shadow: 0 16px 30px rgba(0,0,0,0.28);
}

.map-card-image {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: cover;
}

.map-card-body {
  padding: 10px;
}

.map-card-topline {
  margin-bottom: 4px;
  color: #60705a;
  font-size: 0.72rem;
  font-weight: 900;
}

.map-card h4 {
  margin: 0;
  color: #111411;
  font-size: 1rem;
}

.map-card-meta {
  margin-top: 4px;
  color: #4d5849;
  font-size: 0.82rem;
}

.map-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.map-card-badges .badge {
  font-size: 0.66rem;
}

.map-card-cta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 10px;
}

.map-card-btn {
  display: inline-block;
  min-height: 32px;
  padding: 7px 8px;
  border: 1px solid #2e693d;
  border-radius: 8px;
  background: #2e693d;
  color: #ffffff;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.map-card-btn.ghost {
  background: #ffffff;
  color: #245432;
}

@media (max-width: 1120px) {
  .layout {
    grid-template-columns: 1fr;
  }

  #map {
    height: 52vh;
    min-height: 360px;
    position: relative;
    top: auto;
  }
}

@media (max-width: 700px) {
  .header-inner,
  main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .header-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .view-toolbar {
    grid-template-columns: 1fr;
  }

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

  .card.public-card {
    grid-template-columns: 1fr;
  }

  .public-card-image {
    height: 190px;
  }

  .map-card {
    width: 260px;
  }
}
