:root {
  --paper: #fffdf7;
  --wash: #f3f6ef;
  --ink: #1e2721;
  --muted: #617069;
  --line: #d9dfd6;
  --green: #2f7d57;
  --gold: #d4b35d;
  --red: #7a263a;
  --blue: #4e6b8a;
  --focus: #254e38;
  --shadow: 0 18px 55px rgba(30, 39, 33, .12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

a {
  color: var(--focus);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

button,
input,
select {
  font: inherit;
}

button,
.result-actions a,
.band-header a,
.profile-link {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  border-radius: 7px;
  padding: .72rem .9rem;
  text-decoration: none;
  cursor: pointer;
  min-height: 42px;
}

button:hover,
.result-actions a:hover,
.band-header a:hover,
.profile-link:hover {
  background: var(--focus);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(420px, 760px);
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 48px);
  align-items: stretch;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(120deg, rgba(243, 246, 239, .94), rgba(255, 253, 247, .86)),
    var(--paper);
}

.brand-block {
  display: grid;
  grid-template-columns: 156px 1fr;
  gap: 20px;
  align-items: center;
  min-width: 0;
}

.brand-block img {
  width: 156px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.eyebrow,
.panel-kicker {
  color: var(--red);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 .35rem;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  letter-spacing: 0;
  line-height: 1.05;
  margin: 0;
}

h1 {
  max-width: 820px;
  font-size: clamp(2rem, 4vw, 4rem);
}

h2 {
  font-size: clamp(1.5rem, 2vw, 2.25rem);
}

h3 {
  font-size: 1.04rem;
}

.lookup {
  align-self: center;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 110px 160px auto;
  gap: 10px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.address-field {
  min-width: min(100%, 320px);
}

label,
.select-row {
  display: grid;
  gap: 5px;
  min-width: 0;
}

label span,
.select-row span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 750;
}

input,
select {
  width: 100%;
  border: 1px solid #c8d0c7;
  background: #fff;
  border-radius: 7px;
  color: var(--ink);
  min-height: 42px;
  padding: .62rem .72rem;
}

input:focus,
select:focus,
button:focus,
a:focus {
  outline: 3px solid rgba(47, 125, 87, .25);
  outline-offset: 2px;
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr) minmax(300px, 380px);
  gap: 0;
  min-height: 680px;
}

.side-rail,
.detail-panel {
  background: var(--wash);
  border-right: 1px solid var(--line);
  padding: 22px;
}

.detail-panel {
  border-right: 0;
  border-left: 1px solid var(--line);
  background: #fbfcf8;
}

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

.tool-panel:first-child {
  padding-top: 0;
}

.location-summary {
  display: grid;
  gap: 10px;
}

.summary-chip,
.tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: .28rem .55rem;
  border-radius: 999px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  font-size: .78rem;
  font-weight: 750;
}

.tag.is-red {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.tag.is-green {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.tag.is-gold {
  background: #fbefca;
  border-color: #e5cb7d;
}

.tag.is-blue {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.status-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.status-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.status-list dt {
  color: var(--muted);
  font-size: .85rem;
}

.status-list dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
}

.results-region {
  min-width: 0;
  padding: 26px clamp(16px, 3vw, 34px) 36px;
}

.result-header,
.band-header {
  display: flex;
  gap: 18px;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 18px;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.result-actions a,
.band-header a,
.profile-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .88rem;
  min-height: 38px;
  padding: .55rem .72rem;
}

.precision-note {
  border: 1px solid #e6d395;
  background: #fff9df;
  color: #5d4b16;
  border-radius: 8px;
  padding: .82rem .95rem;
  margin-bottom: 18px;
}

.race-list,
.judge-list,
.source-list {
  display: grid;
  gap: 14px;
}

.race-card,
.judge-card,
.source-card,
.candidate-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 16px;
}

.race-card {
  display: grid;
  gap: 14px;
}

.race-top {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
}

.race-meta,
.candidate-meta,
.judge-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.candidate-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: start;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
}

.candidate-card:hover {
  border-color: var(--green);
  box-shadow: 0 10px 24px rgba(47, 125, 87, .12);
}

.avatar {
  width: 44px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eef6ef;
  color: var(--focus);
  font-weight: 900;
}

.candidate-card p,
.race-card p,
.judge-card p,
.source-card p,
.detail-panel p {
  margin: .45rem 0 0;
  color: var(--muted);
}

.empty-state {
  border: 1px dashed #b9c3b7;
  border-radius: 8px;
  padding: 24px;
  background: #fff;
  color: var(--muted);
}

.empty-state strong,
.no-data-card strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
  margin-bottom: 6px;
}

.no-data-card {
  display: grid;
  gap: 14px;
  border: 1px solid #e2c8c8;
  border-radius: 8px;
  background: #fff8f8;
  color: var(--muted);
  padding: 22px;
}

.no-data-card .links-row {
  margin-top: 2px;
}

.detail-name {
  margin-bottom: 8px;
}

.detail-block {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.detail-block:first-child {
  border-top: 0;
  padding-top: 0;
}

.detail-list {
  display: grid;
  gap: 9px;
  padding: 0;
  margin: 10px 0 0;
  list-style: none;
}

.detail-list li {
  display: grid;
  gap: 3px;
}

.detail-list strong {
  font-size: .86rem;
}

.detail-list span {
  color: var(--muted);
  font-size: .9rem;
}

.service-history {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.service-history > strong {
  display: block;
  font-size: .86rem;
}

.links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.profile-link {
  background: #fff;
  color: var(--ink);
}

.profile-link:hover {
  color: #fff;
}

.judge-band,
.source-band {
  padding: 30px clamp(16px, 4vw, 48px);
  border-top: 1px solid var(--line);
}

.judge-band {
  background: #f9fbfd;
}

.source-band {
  background: #fff;
}

.judge-list {
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
}

.source-list {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.source-card a {
  font-weight: 800;
}

.small-note {
  font-size: .86rem;
  color: var(--muted);
}

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

  .side-rail,
  .detail-panel {
    border: 0;
    border-bottom: 1px solid var(--line);
  }

  .detail-panel {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 16px;
  }

  .brand-block,
  .lookup {
    grid-template-columns: 1fr;
  }

  .brand-block img {
    width: 100%;
    max-height: 180px;
  }

  .result-header,
  .band-header,
  .race-top {
    align-items: stretch;
    flex-direction: column;
  }

  .result-actions {
    justify-content: flex-start;
  }
}
