:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #eef2f5;
  color: #17202a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid #c6d2de;
  border-radius: 6px;
  background: #ffffff;
  color: #17202a;
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
}

button:hover {
  background: #e8f1f7;
  border-color: #6b9cc7;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.danger-button {
  border-color: #d99a93;
  color: #8f2c23;
}

.danger-button:hover {
  background: #fdebea;
  border-color: #c5675e;
}

input,
select {
  border: 1px solid #c6d2de;
  border-radius: 6px;
  min-height: 38px;
  min-width: 220px;
  padding: 0 12px;
}

select {
  background: #ffffff;
}

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

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

h2 {
  font-size: 20px;
  font-weight: 700;
}

h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}

h4 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
}

p {
  color: #5d6c7a;
  font-size: 14px;
  margin-top: 6px;
}

small {
  color: #6c7885;
  display: block;
  font-size: 12px;
  margin-top: 4px;
}

.app-shell {
  margin: 0 auto;
  max-width: 1240px;
  padding: 24px;
}

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

.header-actions,
.token-row,
.actions,
.scenario-actions,
.table-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.eyebrow {
  color: #216750;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.muted {
  color: #5d6c7a;
  font-size: 14px;
}

.auth-strip {
  align-items: center;
  background: #ffffff;
  border: 1px solid #d7e0e8;
  border-radius: 8px;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 14px 16px;
}

.auth-strip strong {
  display: block;
  margin-bottom: 4px;
}

.tabs {
  background: #dfe7ee;
  border-radius: 8px;
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding: 4px;
}

.live-progress {
  background: #ffffff;
  border: 1px solid #cfdbe5;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.live-progress[data-state="running"] {
  border-color: #6b9cc7;
}

.live-progress[data-state="ok"] {
  border-color: #78b79b;
}

.live-progress[data-state="error"] {
  border-color: #d99a93;
}

.live-progress[data-state="warning"] {
  border-color: #d9b35f;
}

.live-progress-main {
  display: grid;
  gap: 3px;
}

.live-progress-main span,
.live-progress-meta {
  color: #53616f;
  font-size: 13px;
}

.live-progress-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.reset-progress-button {
  border-color: #d9b35f;
  color: #6d4f09;
  min-height: 32px;
  padding: 0 10px;
}

.reset-progress-button:hover {
  background: #fff4db;
  border-color: #b78d2d;
}

.live-progress-track {
  background: #edf2f6;
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}

.live-progress-track[hidden] {
  display: none;
}

.live-progress-track span {
  background: #4d8fc0;
  border-radius: inherit;
  display: block;
  height: 100%;
  transition: width 0.25s ease;
  width: 10%;
}

.live-progress[data-state="warning"] .live-progress-track span {
  background: #d9b35f;
}

.tab-button {
  background: transparent;
  border-color: transparent;
  white-space: nowrap;
}

.tab-button.is-active {
  background: #ffffff;
  border-color: #c9d5df;
  font-weight: 700;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

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

.panel,
.raw-panel {
  background: #ffffff;
  border: 1px solid #d7e0e8;
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 16px;
}

.metric-grid,
.summary-grid,
.settings-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

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

.metric-card,
.summary-card {
  background: #ffffff;
  border: 1px solid #d7e0e8;
  border-radius: 8px;
  padding: 14px;
}

.summary-card {
  background: #f8fafb;
}

.metric-card span,
.summary-card span {
  color: #5d6c7a;
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.metric-card strong,
.summary-card strong {
  display: block;
  font-size: 22px;
  line-height: 1.15;
}

.summary-card small {
  min-height: 16px;
}

.doctor-picker {
  align-items: flex-end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(320px, 1fr) auto;
  margin-bottom: 14px;
}

.doctor-picker label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.doctor-picker select,
.table-toolbar input {
  width: 100%;
}

.doctor-card {
  background: #f8fafb;
  border: 1px solid #d7e0e8;
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
  padding: 14px;
}

.doctor-card strong {
  display: block;
  margin-top: 4px;
}

.discovery-list {
  display: grid;
  gap: 12px;
}

.discovery-card {
  align-items: start;
  background: #f8fafb;
  border: 1px solid #d7e0e8;
  border-left-width: 4px;
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto;
  padding: 14px;
}

.discovery-card[data-confidence="exact"] {
  border-left-color: #2e8f68;
}

.discovery-card[data-confidence="high"] {
  border-left-color: #5d97c6;
}

.discovery-card[data-confidence="review"] {
  border-left-color: #d9b35f;
}

.discovery-card strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.scenario-actions {
  align-items: stretch;
}

.result-surface {
  display: grid;
  gap: 16px;
}

.result-block {
  border-top: 1px solid #e3e9ef;
  padding-top: 14px;
}

.result-block:first-child {
  border-top: 0;
  padding-top: 0;
}

.settings-list {
  display: grid;
  gap: 8px;
}

.autopilot-status-view {
  display: grid;
  gap: 14px;
}

.autopilot-state {
  border: 1px solid #d7e0e8;
  border-left-width: 4px;
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 12px 14px;
}

.autopilot-state span {
  color: #53616f;
  font-size: 13px;
}

.autopilot-state[data-state="running"] {
  background: #edf6fc;
  border-color: #6b9cc7;
}

.autopilot-state[data-state="waiting"] {
  background: #edf8f3;
  border-color: #78b79b;
}

.autopilot-state[data-state="warning"] {
  background: #fff8e8;
  border-color: #d9b35f;
}

.autopilot-state[data-state="error"] {
  background: #fdebea;
  border-color: #d99a93;
}

.autopilot-state[data-state="disabled"] {
  background: #f6f8fa;
  border-color: #b7c4cf;
}

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

.autopilot-status-grid .summary-card strong {
  font-size: 17px;
  overflow-wrap: anywhere;
}

.autopilot-progress-line {
  align-items: center;
  background: #f8fafb;
  border: 1px solid #d7e0e8;
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  justify-content: space-between;
  padding: 12px 14px;
}

.autopilot-progress-line span {
  color: #53616f;
  font-size: 13px;
}

.settings-row {
  align-items: center;
  border-bottom: 1px solid #eef2f5;
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
}

.settings-row:last-child {
  border-bottom: 0;
}

.settings-form,
.mapping-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

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

.settings-form label,
.mapping-form label {
  display: grid;
  gap: 6px;
}

.settings-form label span,
.mapping-form label span {
  color: #53616f;
  font-size: 13px;
  font-weight: 700;
}

.checkbox-row {
  align-items: center;
  display: flex !important;
  gap: 9px !important;
  min-height: 38px;
}

.checkbox-row input {
  min-height: auto;
  min-width: auto;
}

.compact-heading {
  margin-bottom: 14px;
}

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

.row-actions button {
  min-height: 32px;
  padding: 0 10px;
}

.pill.is-disabled {
  background: #edf1f5;
  color: #667381;
}

.table-toolbar {
  justify-content: space-between;
  margin-bottom: 12px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid #e3e9ef;
  font-size: 14px;
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f6f8fa;
  color: #53616f;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.compact table {
  min-width: 560px;
}

.pill {
  background: #e7f3ee;
  border-radius: 999px;
  color: #1f6b51;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
}

.journal-list {
  display: grid;
  gap: 8px;
}

.journal-row {
  border-left: 4px solid #8aa4bb;
  background: #f8fafb;
  border-radius: 6px;
  padding: 10px 12px;
}

.journal-row[data-level="error"] {
  border-left-color: #c5675e;
}

.journal-row[data-level="info"] {
  border-left-color: #4e9f7a;
}

.journal-row span {
  color: #6c7885;
  display: block;
  font-size: 12px;
  margin-bottom: 3px;
}

.journal-row strong {
  display: block;
  margin-bottom: 3px;
}

.empty-state {
  background: #f8fafb;
  border: 1px dashed #cbd6df;
  border-radius: 8px;
  color: #5d6c7a;
  padding: 16px;
}

.status-badge {
  background: #edf1f5;
  border-radius: 999px;
  color: #51606e;
  font-size: 12px;
  font-weight: 700;
  min-width: 72px;
  padding: 6px 11px;
  text-align: center;
}

.status-badge[data-state="ok"] {
  background: #e6f4ef;
  color: #1e6a50;
}

.status-badge[data-state="warning"] {
  background: #fff4db;
  color: #89610c;
}

.status-badge[data-state="error"] {
  background: #fde9e7;
  color: #a03329;
}

.raw-toggle {
  margin-bottom: 12px;
}

.output-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

pre {
  background: #111827;
  border-radius: 6px;
  color: #e5e7eb;
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
  max-height: 520px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

.install-page {
  min-height: 100vh;
}

.install-shell {
  margin: 0 auto;
  max-width: 720px;
  padding: 48px 24px;
}

.app-link {
  color: #175f91;
  display: inline-block;
  font-weight: 700;
  margin-top: 18px;
  text-decoration: none;
}

.app-link:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .app-header,
  .auth-strip,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid,
  .summary-grid,
  .autopilot-status-grid,
  .settings-grid,
  .doctor-card,
  .discovery-card,
  .mapping-form {
    grid-template-columns: 1fr;
  }

  .doctor-picker {
    grid-template-columns: 1fr;
  }

  .token-row,
  input,
  select {
    width: 100%;
  }
}
