:root {
  --bg: #f4eee4;
  --bg-strong: #efe3d1;
  --ink: #1f2d2f;
  --muted: #56676a;
  --line: rgba(31, 45, 47, 0.14);
  --card: rgba(255, 252, 247, 0.9);
  --shadow: 0 18px 50px rgba(48, 54, 43, 0.12);
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --warm: #b45309;
  --warm-soft: rgba(180, 83, 9, 0.14);
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Candara", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(180, 83, 9, 0.18), transparent 30%),
    radial-gradient(circle at 85% 10%, rgba(15, 118, 110, 0.16), transparent 26%),
    linear-gradient(180deg, #f9f3ea 0%, #f4eee4 45%, #efe5d5 100%);
  color: var(--ink);
}

.page-shell {
  position: relative;
  overflow: hidden;
}

.ambient {
  position: absolute;
  width: 28rem;
  height: 28rem;
  border-radius: 999px;
  filter: blur(60px);
  opacity: 0.35;
  pointer-events: none;
}

.ambient-left {
  top: -8rem;
  left: -8rem;
  background: rgba(180, 83, 9, 0.25);
}

.ambient-right {
  top: 12rem;
  right: -8rem;
  background: rgba(15, 118, 110, 0.18);
}

.layout {
  position: relative;
  z-index: 1;
  width: min(1400px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 2.5rem;
}

.workspace {
  display: grid;
  gap: 1.35rem;
}

.card {
  position: relative;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero {
  padding: 1.6rem 1.6rem 1.8rem;
  margin-bottom: 0.9rem;
}

.eyebrow {
  margin: 0 0 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.76rem;
  color: var(--warm);
  font-weight: 700;
}

.hero h1,
.summary h2,
.results h2,
.notes h2 {
  margin: 0;
  font-family: "Georgia", "Cambria", serif;
  font-weight: 700;
  line-height: 1.1;
}

.hero h1 {
  max-width: 12ch;
  font-size: clamp(2.1rem, 4vw, 3.9rem);
}

.hero-copy {
  max-width: 58rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.hero-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.5rem;
}

.hero-notes span {
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 246, 235, 0.88));
  border: 1px solid var(--line);
  font-size: 0.92rem;
}

.controls,
.summary,
.results,
.notes {
  padding: 1.4rem;
}

.field-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(240px, 420px) minmax(240px, 1fr);
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field span,
.toggle span {
  font-size: 0.94rem;
  font-weight: 700;
}

select,
textarea,
button {
  font: inherit;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  padding: 0.9rem 1rem;
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

textarea {
  min-height: 240px;
  resize: vertical;
  margin-top: 0.35rem;
  line-height: 1.5;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: rgba(255, 250, 242, 0.74);
}

.toggle input {
  inline-size: 1.1rem;
  block-size: 1.1rem;
  accent-color: var(--accent);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1rem;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.82rem 1.2rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

button.ghost.small {
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  font-size: 0.9rem;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.primary {
  color: #fffaf5;
  background: linear-gradient(135deg, #0f766e, #155e75);
  box-shadow: 0 16px 30px rgba(15, 118, 110, 0.2);
}

.ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
}

.helper-text,
.summary-head p,
.notes p {
  margin: 0.9rem 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.summary-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
}

.summary-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 1rem;
}

.metric {
  padding: 1rem;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(239, 227, 209, 0.75));
  border: 1px solid var(--line);
}

.metric strong {
  display: block;
  font-size: 1.85rem;
  font-family: "Georgia", "Cambria", serif;
}

.metric span {
  color: var(--muted);
}

.results-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.loading {
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.error-box {
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  background: rgba(180, 35, 24, 0.08);
  border: 1px solid rgba(180, 35, 24, 0.18);
  color: var(--danger);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
}

th,
td {
  padding: 1rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(31, 45, 47, 0.08);
}

th {
  position: sticky;
  top: 0;
  background: rgba(244, 238, 228, 0.96);
  z-index: 1;
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

tbody tr:hover {
  background: rgba(15, 118, 110, 0.04);
}

.empty-state td {
  color: var(--muted);
  text-align: center;
  padding: 1.6rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-exact {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-likely {
  background: rgba(180, 83, 9, 0.14);
  color: var(--warm);
}

.status-review {
  background: rgba(29, 78, 216, 0.12);
  color: #1d4ed8;
}

.status-no_match {
  background: rgba(180, 35, 24, 0.1);
  color: var(--danger);
}

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

.match-item {
  padding: 0.85rem 1rem;
  border-radius: 18px;
  border: 1px solid rgba(31, 45, 47, 0.08);
  background: rgba(255, 252, 247, 0.95);
  display: grid;
  gap: 0.5rem;
}

.match-item.selected {
  border-color: rgba(15, 118, 110, 0.25);
  background: rgba(15, 118, 110, 0.08);
}

.selection-note {
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.match-item button {
  justify-self: start;
  border: 1px solid rgba(31, 45, 47, 0.12);
  background: rgba(255, 255, 255, 0.92);
}

.selected-list .match-item {
  padding: 1rem 1rem 0.85rem;
}

.match-item strong {
  display: block;
  margin-bottom: 0.2rem;
}

.match-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.code-list {
  display: grid;
  gap: 0.5rem;
}

.code-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.65rem;
  border-radius: 12px;
  background: rgba(31, 45, 47, 0.06);
  font-family: "Consolas", "Courier New", monospace;
}

.active-flag {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.42rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
}

.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.is-inactive {
  background: rgba(31, 45, 47, 0.08);
  color: var(--muted);
}

.hidden {
  display: none !important;
}

code {
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  background: rgba(31, 45, 47, 0.06);
}

@media (max-width: 900px) {
  .layout {
    width: min(100% - 1rem, 1180px);
    padding-top: 1rem;
  }

  .hero,
  .controls,
  .summary,
  .results,
  .notes {
    padding: 1.1rem;
    border-radius: 20px;
  }

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

  .summary-head,
  .results-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    flex-direction: column;
  }

  button {
    width: 100%;
  }
}
