:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-strong: #eef3f6;
  --ink: #151923;
  --muted: #5f6b78;
  --line: #d8e1ea;
  --accent: #007f73;
  --accent-soft: #ddf3ee;
  --coral: #d86f45;
  --blue: #376fb7;
  --gold: #b57b18;
  --shadow: 0 18px 50px rgba(17, 24, 39, 0.1);
  --radius: 8px;
  --max-width: 1280px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111419;
  --surface: #1a1f27;
  --surface-strong: #232a35;
  --ink: #f5f7fb;
  --muted: #b5bfcb;
  --line: #323b48;
  --accent: #45c7b5;
  --accent-soft: #123b36;
  --coral: #ff9b70;
  --blue: #8fb6ff;
  --gold: #f3c56b;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(0, 127, 115, 0.08), transparent 35%),
    linear-gradient(180deg, rgba(216, 111, 69, 0.08), transparent 42%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem max(1rem, calc((100vw - var(--max-width)) / 2));
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface), transparent 8%);
  backdrop-filter: blur(16px);
}

.brand,
.app-header nav {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand,
.app-header a {
  text-decoration: none;
}

.brand span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--surface);
  font-weight: 900;
}

.app-header nav a,
.theme-toggle,
.primary-action,
.quiet-action,
.preset-row button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
  min-height: 38px;
  padding: 0.55rem 0.75rem;
  text-decoration: none;
}

.app-shell {
  width: min(var(--max-width), calc(100% - 2rem));
  margin: 0 auto;
  padding: 4rem 0 5rem;
}

.intro {
  max-width: 860px;
  margin-bottom: 1.5rem;
}

.eyebrow {
  margin: 0 0 0.7rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 1rem;
  font-size: clamp(2.3rem, 5vw, 4.6rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0.5rem;
  font-size: 1.45rem;
}

h3 {
  margin-bottom: 0.55rem;
}

.intro p,
.section-heading p,
.empty-state p,
.result-card p,
.source-card p,
.checklist,
.field span,
legend,
.filter-field span,
.metric-grid span,
.query-strip span {
  color: var(--muted);
}

.scanner-layout {
  display: grid;
  grid-template-columns: minmax(290px, 360px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.query-panel,
.results-panel,
.source-card,
.metric-grid article,
.query-strip,
.provider-card,
.insight-panel,
.result-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface), transparent 2%);
  box-shadow: var(--shadow);
}

.query-panel {
  position: sticky;
  top: 5.4rem;
  padding: 1rem;
}

.scanner-form,
.field,
.choice-stack,
.panel-heading {
  display: grid;
  gap: 0.75rem;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.field span,
legend,
.filter-field span {
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  min-height: 44px;
  padding: 0.65rem 0.75rem;
}

fieldset {
  margin: 0;
  border: 0;
  padding: 0;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.choice-grid label,
.choice-stack label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  cursor: pointer;
  font-weight: 800;
  padding: 0.55rem 0.65rem;
}

.choice-grid input,
.choice-stack input {
  width: auto;
  min-height: auto;
}

.action-row,
.toolbar,
.status-strip,
.query-strip,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.primary-action {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.quiet-action {
  background: var(--surface);
}

.quiet-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.results-panel {
  min-width: 0;
  padding: 1rem;
}

.status-strip {
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1rem;
}

.status-strip h2 {
  margin-bottom: 0;
}

.status-strip > span {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
  padding: 0.45rem 0.65rem;
  white-space: nowrap;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.preset-row button {
  color: var(--accent);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.metric-grid article {
  padding: 0.9rem;
}

.metric-grid strong {
  display: block;
  font-size: 1.7rem;
  line-height: 1;
}

.metric-grid span {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.86rem;
  font-weight: 750;
}

.query-strip {
  margin-bottom: 1rem;
  padding: 0.85rem;
}

.query-strip div {
  min-width: 0;
}

.query-strip strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.launchpad {
  margin-bottom: 1rem;
}

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

.source-card {
  display: grid;
  gap: 0.75rem;
  min-height: 170px;
  padding: 0.9rem;
  text-decoration: none;
  transition: border-color 160ms ease, transform 160ms ease;
}

.source-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.source-card strong,
.result-card strong {
  display: block;
  line-height: 1.25;
}

.source-card p,
.result-card p {
  margin-bottom: 0;
  font-size: 0.92rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag-row span,
.result-meta span,
.reason-row span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  padding: 0.25rem 0.45rem;
}

.source-card em {
  align-self: end;
  color: var(--accent);
  font-style: normal;
  font-weight: 900;
}

.toolbar {
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.filter-field {
  display: grid;
  flex: 1 1 260px;
  gap: 0.35rem;
}

.filter-field--compact {
  flex: 0 1 155px;
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.provider-card {
  display: grid;
  gap: 0.35rem;
  padding: 0.75rem;
}

.provider-card strong {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.provider-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.provider-state {
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  padding: 0.2rem 0.45rem;
  text-transform: uppercase;
}

.provider-card[data-state="ok"] .provider-state {
  background: var(--accent-soft);
  color: var(--accent);
}

.provider-card[data-state="error"] .provider-state {
  background: color-mix(in srgb, var(--coral), transparent 82%);
  color: var(--coral);
}

.provider-card[data-state="pending"] .provider-state {
  background: color-mix(in srgb, var(--gold), transparent 82%);
  color: var(--gold);
}

.insight-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.insight-panel {
  padding: 0.9rem;
}

.coverage-bars {
  display: grid;
  gap: 0.65rem;
}

.coverage-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) 38px;
  gap: 0.65rem;
  align-items: center;
}

.coverage-row span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.coverage-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.coverage-track i {
  display: block;
  width: var(--bar-width, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--blue));
}

.checklist {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding-left: 1.1rem;
}

.result-list {
  display: grid;
  gap: 0.75rem;
}

.result-card,
.empty-state {
  padding: 1rem;
}

.result-card {
  display: grid;
  gap: 0.75rem;
}

.result-card header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.result-card a {
  color: inherit;
  text-decoration: none;
}

.result-card a:hover {
  color: var(--accent);
}

.score-pill {
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  padding: 0.35rem 0.5rem;
  white-space: nowrap;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.reason-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.reason-row span {
  background: color-mix(in srgb, var(--accent), var(--surface) 88%);
  color: var(--accent);
}

.empty-state {
  text-align: center;
}

@media (max-width: 980px) {
  .scanner-layout,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .query-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 1rem, var(--max-width));
    padding-top: 2rem;
  }

  .app-header {
    align-items: flex-start;
  }

  .metric-grid,
  .field-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .status-strip,
  .query-strip,
  .section-heading,
  .result-card header {
    align-items: stretch;
    flex-direction: column;
  }

  .status-strip > span,
  .query-strip strong {
    white-space: normal;
  }
}

@media (max-width: 520px) {
  .metric-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .coverage-row {
    grid-template-columns: 74px minmax(0, 1fr) 32px;
  }
}
