:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1c2430;
  --muted: #657182;
  --line: #dbe1e8;
  --accent: #15616d;
  --accent-dark: #0e4650;
  --warn: #a84f19;
  --bad: #a93226;
  --ok: #28704b;
  --shadow: 0 10px 28px rgba(28, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px;
  background: #101820;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand small {
  display: block;
  color: #aeb8c5;
  margin-top: 2px;
}

.mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #d9f0f2;
  color: var(--accent-dark);
  font-weight: 800;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item,
.ghost,
.primary,
.file-button,
.link-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: none;
}

.nav-item {
  text-align: left;
  background: transparent;
  color: #dce4ec;
}

.nav-item:hover,
.nav-item.active {
  background: #22313d;
  color: white;
}

.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.primary:hover {
  background: var(--accent-dark);
}

.primary:disabled,
.ghost:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ghost {
  background: white;
  border-color: var(--line);
  color: var(--text);
}

.sidebar .ghost {
  margin-top: auto;
  background: transparent;
  color: #dce4ec;
  border-color: #344454;
}

.file-button {
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: white;
}

.file-button input {
  display: none;
}

main {
  min-width: 0;
}

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

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

h1 {
  margin-bottom: 4px;
  font-size: 26px;
}

h2 {
  font-size: 20px;
  margin-bottom: 6px;
}

h3 {
  font-size: 15px;
  margin-bottom: 8px;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.workspace {
  padding: 28px;
  display: grid;
  gap: 20px;
}

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

.section-head,
.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.actions,
.filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.filters {
  margin-bottom: 16px;
}

.api-note {
  margin: -4px 0 12px;
  color: var(--ok);
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: white;
  color: var(--text);
}

input[type="search"] {
  min-width: min(420px, 100%);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
}

.metrics.compact {
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  margin: 14px 0;
}

.metric {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.metric strong {
  font-size: 28px;
  line-height: 1.3;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  vertical-align: top;
  min-width: 100px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #f8fafc;
}

tr:last-child td {
  border-bottom: 0;
}

a {
  color: var(--accent-dark);
  font-weight: 650;
}

.record-grid,
.mapping-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 12px;
}

.record-grid > div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.record-grid strong,
.record-grid span {
  display: block;
}

.record-grid strong {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.mapping-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  background: #edf2f7;
}

.badge.ok {
  color: var(--ok);
  background: #e6f4ee;
}

.empty {
  padding: 36px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.match-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
  margin-bottom: 14px;
}

.match-score {
  border-right: 1px solid var(--line);
  padding-right: 14px;
}

.match-score strong {
  display: block;
  font-size: 38px;
  color: var(--accent-dark);
}

.match-score span {
  color: var(--muted);
  font-size: 13px;
}

.match-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.evidence,
.review-actions {
  grid-column: 2;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.evidence span {
  border-radius: 999px;
  padding: 5px 9px;
  background: #e9f5f6;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 650;
}

.evidence .negative {
  background: #fff1ea;
  color: var(--warn);
}

.review-actions input {
  flex: 1;
  min-width: 220px;
}

.report,
.email {
  max-width: 980px;
}

.report-match {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

.disclaimer {
  border-left: 4px solid var(--warn);
  padding: 10px 12px;
  background: #fff8f3;
  color: #4a3529;
}

details {
  margin-top: 18px;
}

pre {
  white-space: pre-wrap;
  overflow: auto;
  background: #0e1720;
  color: #e9eef5;
  border-radius: 8px;
  padding: 14px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: #101820;
  color: white;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 10;
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .metrics,
  .record-grid,
  .mapping-grid,
  .match-columns {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  nav,
  .metrics,
  .record-grid,
  .mapping-grid,
  .match-card,
  .match-columns,
  .metrics.compact {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head,
  .detail-header {
    flex-direction: column;
    align-items: stretch;
  }

  .workspace {
    padding: 16px;
  }

  .match-score {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-right: 0;
    padding-bottom: 12px;
  }

  .evidence,
  .review-actions {
    grid-column: 1;
  }
}
