@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #5d6b64;
  --line: #dfe6df;
  --paper: #f7f5ef;
  --panel: #ffffff;
  --accent: #226a5a;
  --accent-strong: #16483d;
  --gold: #b8892f;
  --rose: #a5493f;
  --blue: #315f87;
  --shadow: 0 18px 48px rgba(32, 43, 36, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 28px;
  background: rgba(247, 245, 239, 0.92);
  border-bottom: 1px solid rgba(23, 32, 27, 0.1);
  backdrop-filter: blur(16px);
}

.brand,
.nav a {
  color: var(--ink);
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background:
    linear-gradient(135deg, transparent 43%, #fff 44% 55%, transparent 56%),
    linear-gradient(145deg, var(--accent), var(--gold));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.nav {
  display: flex;
  gap: 22px;
  font-size: 0.94rem;
  font-weight: 700;
}

.hero {
  position: relative;
  min-height: 420px;
  isolation: isolate;
  overflow: hidden;
}

.hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: -2;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(13, 21, 18, 0.76) 0%, rgba(13, 21, 18, 0.45) 42%, rgba(13, 21, 18, 0.06) 100%),
    linear-gradient(0deg, rgba(247, 245, 239, 1) 0%, rgba(247, 245, 239, 0) 30%);
}

.hero-overlay {
  width: min(720px, calc(100% - 40px));
  padding: 76px 0 104px;
  margin-left: max(24px, calc((100vw - 1180px) / 2));
  color: #fff;
}

.eyebrow {
  margin: 0 0 10px;
  color: currentColor;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.78;
}

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

h1 {
  max-width: 680px;
  margin-bottom: 18px;
  font-size: clamp(2.45rem, 5vw, 5.6rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 560px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 1.13rem;
  line-height: 1.55;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(310px, 390px) minmax(0, 1fr);
  gap: 22px;
  width: min(1180px, calc(100% - 36px));
  margin: 28px auto 56px;
  align-items: start;
}

.input-panel,
.summary-band,
.metric,
.record-section {
  background: var(--panel);
  border: 1px solid rgba(23, 32, 27, 0.11);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel {
  position: sticky;
  top: 84px;
  padding: 22px;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading h2,
.summary-band h2 {
  margin-bottom: 4px;
  font-size: 1.45rem;
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 800;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcf9;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus {
  border-color: rgba(34, 106, 90, 0.72);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(34, 106, 90, 0.11);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 2px;
}

.lookup-note {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  font-weight: 850;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary,
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

button.secondary:hover,
.icon-button:hover {
  background: #f0f4ef;
}

.dashboard {
  display: grid;
  gap: 18px;
}

.summary-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
}

#summary-subtitle {
  margin-bottom: 0;
  color: var(--muted);
}

.score-block {
  display: grid;
  justify-items: center;
  min-width: 128px;
  padding: 15px 16px;
  border-radius: 8px;
  background: #edf5f0;
  color: var(--accent-strong);
}

.score-block span {
  font-size: 2.7rem;
  line-height: 1;
  font-weight: 900;
}

.score-block small {
  margin-top: 6px;
  color: var(--accent-strong);
  font-weight: 800;
  text-align: center;
}

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

.metric {
  display: grid;
  gap: 8px;
  min-height: 136px;
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.metric strong {
  font-size: clamp(1.35rem, 2vw, 2rem);
  line-height: 1.05;
}

.metric small {
  color: var(--muted);
  line-height: 1.4;
}

.record-section {
  padding: 22px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title h3 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

#source-badge {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

#records-badge,
#municipal-source {
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.record-section {
  display: grid;
  gap: 16px;
}

.record-group {
  margin-top: 18px;
}

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
}

.group-head h4 {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 850;
  color: var(--ink);
}

.record-group .record-grid + .record-grid {
  margin-top: 12px;
}

.group-chip {
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  white-space: nowrap;
}

.group-chip[data-signal="ok"] { color: var(--accent-strong); background: #ecf5ef; border-color: #cfe6d8; }
.group-chip[data-signal="warn"] { color: #8a6312; background: #fbf2dd; border-color: #ecdcae; }
.group-chip[data-signal="risk"] { color: #8c372e; background: #fbe7e4; border-color: #eccbc6; }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.verdict {
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.verdict:empty { display: none; }
.verdict[data-signal="ok"] { color: var(--accent-strong); background: #e4f0e8; }
.verdict[data-signal="warn"] { color: #8a6312; background: #f6ead0; }
.verdict[data-signal="risk"] { color: #8c372e; background: #f6dcd7; }

.record-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.record-card {
  display: grid;
  gap: 8px;
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf9;
  padding: 16px;
}

.record-card.wide {
  grid-column: span 2;
}

.record-card[data-signal] {
  border-left-width: 3px;
}

.record-card[data-signal="ok"] {
  border-left-color: var(--accent);
  background: #f6faf7;
}

.record-card[data-signal="warn"] {
  border-left-color: #c08a20;
  background: #fdf9f0;
}

.record-card[data-signal="risk"] {
  border-left-color: var(--rose);
  background: #fdf5f4;
}

.record-label,
.detail-list dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.record-card strong {
  color: var(--ink);
  font-size: clamp(1.08rem, 1.55vw, 1.42rem);
  line-height: 1.15;
}

.record-card small {
  color: var(--muted);
  line-height: 1.35;
}

.municipal-records {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.municipal-records[hidden] {
  display: none;
}

.compact-title {
  margin-bottom: 0;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.detail-list div {
  display: grid;
  gap: 6px;
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf9;
  padding: 14px;
}

.detail-list dd {
  margin: 0;
  color: var(--ink);
  font-weight: 850;
  line-height: 1.25;
}



@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
    margin-top: 22px;
  }

  .input-panel {
    position: static;
  }

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

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 14px 18px;
  }

  .nav {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.86rem;
  }

  .hero {
    min-height: 460px;
  }

  .hero-overlay {
    width: calc(100% - 32px);
    margin-left: 16px;
    padding-top: 64px;
  }

  .workspace {
    width: calc(100% - 24px);
    margin-bottom: 32px;
  }

  .summary-band,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .score-block {
    width: 100%;
  }

  .metric-grid,
  .record-grid,
  .detail-list,
  .field-grid,
  .actions {
    grid-template-columns: 1fr;
  }

  .record-card.wide {
    grid-column: auto;
  }
}

/* Loading shimmer */
[data-loading="true"] .metric strong,
[data-loading="true"] .metric small,
[data-loading="true"] #summary-title,
[data-loading="true"] #summary-subtitle,
[data-loading="true"] #score,
[data-loading="true"] .record-card strong,
[data-loading="true"] .record-card small {
  color: transparent;
  background: linear-gradient(90deg, #e8ede9 25%, #d4dcd5 50%, #e8ede9 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 4px;
  pointer-events: none;
  user-select: none;
}
