:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #5f6d68;
  --line: #d8dfdc;
  --paper: #fbfcfa;
  --surface: #ffffff;
  --green: #1e7c5b;
  --green-soft: #dff2e9;
  --amber: #a45d16;
  --amber-soft: #f6ead8;
  --red: #b33a3a;
  --red-soft: #f7dddd;
  --blue: #295f9e;
  --blue-soft: #e1ebf7;
  --shadow: 0 12px 30px rgba(23, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

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

a {
  color: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 4vw, 2.65rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

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

.topnav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.summary-band {
  padding: 24px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #eef7f1 0%, #f8f4ea 56%, #f3f7fb 100%);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 1180px;
}

.metric {
  min-height: 86px;
  padding: 16px;
  border: 1px solid rgba(216, 223, 220, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.28rem;
  overflow-wrap: anywhere;
}

.status-chart {
  display: grid;
  gap: 10px;
  max-width: 1180px;
  margin-top: 18px;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr minmax(44px, auto);
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}

.chart-label {
  color: var(--muted);
  font-weight: 750;
}

.chart-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.chart-fill {
  width: var(--width);
  height: 100%;
  border-radius: inherit;
  background: var(--color);
}

.workspace {
  padding: 22px clamp(16px, 4vw, 48px) 32px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(160px, 220px);
  gap: 12px;
  max-width: 1180px;
}

.search-field,
.select-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

input,
select,
button {
  font: inherit;
}

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

input {
  padding: 10px 12px;
}

select {
  padding: 10px;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(41, 95, 158, 0.26);
  outline-offset: 2px;
}

.status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 1180px;
  margin-top: 14px;
}

.status-tab {
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 760;
}

.status-tab[aria-selected="true"] {
  border-color: transparent;
  background: var(--ink);
  color: #fff;
}

.rxnorm-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  max-width: 1180px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #cfdce9;
  border-radius: 8px;
  background: #f4f8fc;
}

.rxnorm-panel[hidden] {
  display: none;
}

.rxnorm-panel strong {
  display: block;
  margin-bottom: 2px;
}

#rxnorm-status {
  color: var(--muted);
  font-size: 0.86rem;
}

#rxnorm-button,
.rxnorm-choice {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 760;
}

#rxnorm-button {
  padding: 7px 11px;
}

.rxnorm-results {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rxnorm-choice {
  padding: 6px 9px;
  text-align: left;
}

.rxnorm-choice span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 18px;
  max-width: 1180px;
  margin-top: 18px;
}

.results-pane,
.detail-pane {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

#result-count {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
  white-space: nowrap;
}

.results-list {
  display: grid;
  max-height: 680px;
  overflow: auto;
}

.result-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.result-item:hover,
.result-item[aria-pressed="true"] {
  background: #f6faf7;
}

.result-title {
  margin-bottom: 4px;
  font-weight: 790;
  overflow-wrap: anywhere;
}

.result-meta {
  color: var(--muted);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.pill {
  align-self: start;
  min-width: 86px;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 790;
  text-align: center;
  white-space: nowrap;
}

.pill-current {
  background: var(--green-soft);
  color: var(--green);
}

.pill-resolved {
  background: var(--blue-soft);
  color: var(--blue);
}

.pill-discontinued {
  background: var(--amber-soft);
  color: var(--amber);
}

.pill-other {
  background: var(--red-soft);
  color: var(--red);
}

.detail-pane {
  position: sticky;
  top: 14px;
  align-self: start;
  min-height: 360px;
  padding: 16px;
}

.detail-empty {
  display: grid;
  min-height: 320px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.detail-title {
  margin-bottom: 8px;
  font-size: 1.15rem;
  overflow-wrap: anywhere;
}

.detail-subtitle {
  margin-bottom: 14px;
  color: var(--muted);
}

.field-list {
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 3px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.field dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 780;
}

.field dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.notice-band {
  padding: 22px clamp(16px, 4vw, 48px) 36px;
  border-top: 1px solid var(--line);
  background: #fff7ef;
}

.notice-band h2,
.notice-band p {
  max-width: 1000px;
}

.notice-band p {
  margin-bottom: 0;
  color: #68420f;
}

.empty-state {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 820px) {
  .topbar,
  .toolbar,
  .content-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .topnav {
    justify-content: start;
  }

  .rxnorm-panel {
    grid-template-columns: 1fr;
  }

  .detail-pane {
    position: static;
  }

  .chart-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .result-item {
    grid-template-columns: 1fr;
  }

  .pill {
    justify-self: start;
  }
}
