:root {
  color-scheme: light;
  --bg: #f8fafc;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --input: #e2e8f0;
  --accent: #0f172a;
  --accent-strong: #334155;
  --secondary: #f1f5f9;
  --secondary-text: #0f172a;
  --danger: #dc2626;
  --warn-bg: #fef2f2;
  --ok-bg: #f0fdf4;
  --ok-text: #166534;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.06);
}

* {
  box-sizing: border-box;
}

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

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 36px;
  font-weight: 700;
}

h2 {
  font-size: 18px;
  font-weight: 650;
  margin-bottom: 18px;
}

form {
  margin: 0;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  min-height: 36px;
  padding: 0 16px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

button.secondary {
  background: var(--secondary);
  border: 1px solid var(--line);
  color: var(--secondary-text);
}

button.secondary:hover {
  background: #e2e8f0;
}

input,
select,
textarea {
  width: 100%;
  background: transparent;
  border: 1px solid var(--input);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  min-height: 36px;
  padding: 8px 10px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgb(148 163 184 / 0.28);
  outline: none;
}

input[type="file"] {
  background: white;
  padding: 7px 10px;
}

textarea {
  resize: vertical;
}

label {
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}

.label-row {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  min-width: 0;
}

code {
  white-space: normal;
  word-break: break-all;
}

.hero {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.subtle,
.empty {
  color: var(--muted);
  margin: 8px 0 0;
}

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

.grid.stats {
  grid-template-columns: repeat(4, 1fr);
}

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

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

.panel {
  margin-bottom: 16px;
}

.stat span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  font-size: 20px;
  font-weight: 650;
  margin-top: 4px;
}

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

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

.section-head h2 {
  margin-bottom: 4px;
}

.priority-panel {
  border-color: #cbd5e1;
}

.search-form,
.verify-form {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 16px;
}

.verify-form {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  grid-template-columns: 180px minmax(0, 1fr) auto;
  padding: 14px;
}

.drug-results {
  display: grid;
  gap: 10px;
}

.drug-card {
  align-items: center;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 14px 0;
}

.drug-card:first-of-type {
  border-top: 0;
}

.drug-card strong,
.drug-card span,
.drug-card small {
  display: block;
}

.drug-card span,
.drug-card small {
  color: var(--muted);
}

.drug-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.visit-form {
  display: grid;
  gap: 18px;
}

.form-section {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
  min-width: 0;
  padding: 18px 0 0;
}

.form-section:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.form-section legend {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  padding-right: 12px;
}

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

.form-fields .span-2 {
  grid-column: span 2;
}

.questionnaire {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.question-block {
  align-items: stretch;
  display: grid;
  gap: 6px;
}

.question-block .label-row {
  color: var(--text);
  font-weight: 700;
}

.question-copy {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.question-copy summary {
  cursor: pointer;
  font-weight: 650;
  list-style-position: inside;
}

.question-copy p {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 8px 0 0;
  padding: 10px;
  white-space: pre-line;
}

.copy-row {
  background: #f1f5f9;
  border-radius: 6px;
  padding: 12px;
}

.row-card,
.mini-table > div {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 2px;
  padding: 12px 0;
}

.row-card:first-of-type,
.mini-table > div:first-child {
  border-top: 0;
}

.row-card span,
.mini-table span,
.row-card small {
  color: var(--muted);
}

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

.run-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.run-card:first-of-type {
  border-top: 1px solid var(--line);
}

.run-card.ok {
  border-color: #bbf7d0;
}

.run-card.error {
  border-color: #fecaca;
}

.visit-head {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.visit-head strong,
.visit-head small {
  display: block;
}

.run-meta {
  align-items: center;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.status-badge,
.env-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 5px 8px;
  text-transform: capitalize;
  white-space: nowrap;
}

.status-badge.ok {
  background: var(--ok-bg);
  border-color: #bbf7d0;
  color: var(--ok-text);
}

.status-badge.error {
  background: var(--warn-bg);
  border-color: #fecaca;
  color: var(--danger);
}

.status-badge.neutral,
.env-chip {
  background: #f8fafc;
  color: var(--muted);
}

.error-text {
  color: var(--danger) !important;
}

.subdetails,
.details-panel {
  margin-top: 16px;
}

.details-panel {
  display: block;
}

.details-panel > summary,
.subdetails > summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  list-style: none;
}

.details-panel > summary::-webkit-details-marker,
.subdetails > summary::-webkit-details-marker {
  display: none;
}

.details-panel > summary::before,
.subdetails > summary::before {
  color: var(--muted);
  content: "+";
  font-weight: 800;
}

.details-panel[open] > summary::before,
.subdetails[open] > summary::before {
  content: "-";
}

.details-panel > summary > span,
.subdetails > summary {
  color: var(--text);
  font-size: 16px;
  font-weight: 750;
}

.details-panel > summary > small,
.subdetails > summary strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.details-panel[open] > summary {
  margin-bottom: 16px;
}

.subdetails[open] > summary {
  margin-bottom: 10px;
}

.compact-runs .run-card {
  background: #fffafa;
}

.advanced-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.7fr);
}

.advanced-grid h3,
.event-section h3 {
  font-size: 14px;
  margin: 0 0 10px;
}

.event-section {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.upload-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
}

.upload-form {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.notice,
.alert {
  border-radius: 8px;
  font-weight: 700;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.notice {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.alert {
  background: var(--warn-bg);
  color: var(--danger);
}

.compact {
  margin-bottom: 12px;
  padding: 10px 12px;
}

[hidden] {
  display: none !important;
}

.login {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 16px;
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: auto;
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.login-panel form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

@media (max-width: 860px) {
  main {
    width: min(100% - 20px, 1180px);
  }

  .hero,
  .grid.two,
  .drug-card,
  .search-form,
  .verify-form,
  .advanced-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .drug-actions {
    justify-content: stretch;
  }

  .drug-actions form,
  .drug-actions button {
    width: 100%;
  }

  .grid.stats,
  .form-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 30px;
  }

  .grid.stats,
  .form-fields,
  .upload-grid {
    grid-template-columns: 1fr;
  }

  .form-fields .span-2 {
    grid-column: auto;
  }
}
