:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --ink: #18201f;
  --muted: #66706c;
  --line: #dbe1dc;
  --panel: #ffffff;
  --green: #1f7a5a;
  --blue: #2457a6;
  --amber: #aa6b12;
  --red: #b23b3b;
  --violet: #6a4aa0;
  --shadow: 0 14px 40px rgba(32, 42, 38, 0.08);
}

* {
  box-sizing: border-box;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.counter,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: #f8faf7;
  color: var(--muted);
}

.badge.good {
  color: var(--green);
  border-color: rgba(31, 122, 90, 0.25);
  background: rgba(31, 122, 90, 0.08);
}

.badge.warn {
  color: var(--amber);
  border-color: rgba(170, 107, 18, 0.25);
  background: rgba(170, 107, 18, 0.08);
}

.badge.danger {
  color: var(--red);
  border-color: rgba(178, 59, 59, 0.25);
  background: rgba(178, 59, 59, 0.08);
}

.workspace {
  width: min(1480px, calc(100vw - 32px));
  margin: 18px auto 48px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
}

button,
.tab {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  border-radius: 6px;
  min-height: 40px;
  padding: 9px 13px;
  font-weight: 800;
  cursor: pointer;
}

button:hover,
.tab:hover {
  border-color: #aeb8b1;
}

button[type="submit"],
.tab.active {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

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

.preference-form,
.ingest-form {
  display: grid;
  gap: 12px;
}

.consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  color: var(--ink);
  background: #ffffff;
}

textarea {
  resize: vertical;
}

.issue-controls {
  display: grid;
  gap: 10px;
}

.issue-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 160px 90px;
  gap: 8px;
  align-items: center;
}

.issue-row label {
  font-weight: 800;
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.candidate-card,
.result-card,
.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
}

.candidate-card h3,
.result-card h3,
.list-item h3 {
  margin-bottom: 4px;
  font-size: 16px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.score-row {
  display: grid;
  grid-template-columns: 128px 1fr 42px;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  font-size: 13px;
}

.bar {
  height: 8px;
  border-radius: 999px;
  background: #e9ede9;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.bar.blue span {
  background: var(--blue);
}

.bar.amber span {
  background: var(--amber);
}

.bar.red span {
  background: var(--red);
}

.results-empty,
.note {
  color: var(--muted);
}

.result-card {
  margin-bottom: 10px;
}

.result-score {
  font-size: 32px;
  font-weight: 900;
  color: var(--green);
}

.stack {
  display: grid;
  gap: 10px;
}

.region-map {
  display: grid;
  gap: 10px;
}

.region-tile {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfb;
}

.table {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 7px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.compact table {
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: 160ms ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .grid.two,
  .grid.three,
  .candidate-grid {
    grid-template-columns: 1fr;
  }

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

  .status-strip {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .workspace {
    width: min(100vw - 20px, 1480px);
  }

  .issue-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }
}

