:root {
  color-scheme: light;
  --ink: #1c2522;
  --muted: #5d6863;
  --line: #d9e2dc;
  --surface: #f6f8f5;
  --panel: #ffffff;
  --brand: #176b5b;
  --brand-dark: #0f4f43;
  --accent: #3867a8;
  --warn: #9f4c16;
  --danger: #b3261e;
  --ok: #19723b;
  --shadow: 0 12px 30px rgba(26, 39, 35, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--line);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: grid;
  gap: 6px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.brand p,
.muted {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

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

.auth {
  max-width: 980px;
  margin: 7vh auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 0 20px;
}

.auth .intro {
  padding: 28px;
}

.auth .intro h1 {
  margin: 0 0 12px;
  font-size: 30px;
}

.auth-tabs {
  padding: 18px;
}

.tabs,
.segmented {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: #edf2ef;
  border-radius: 8px;
  width: fit-content;
}

.tabs button,
.segmented button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.tabs button.active,
.segmented button.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: #ffffff;
  color: var(--ink);
}

textarea {
  min-height: 140px;
  resize: vertical;
}

.btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 7px;
  background: var(--brand);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover {
  background: var(--brand-dark);
}

.btn.secondary {
  background: #e7eee9;
  color: var(--ink);
}

.btn.secondary:hover {
  background: #dce7e1;
}

.btn.danger {
  background: var(--danger);
}

.status {
  padding: 10px 12px;
  border-radius: 7px;
  font-size: 14px;
  line-height: 1.4;
}

.status.error {
  background: #fff0ee;
  color: var(--danger);
  border: 1px solid #f1c7c2;
}

.status.ok {
  background: #edf8f1;
  color: var(--ok);
  border: 1px solid #c8e8d2;
}

.status.warn {
  background: #fff5eb;
  color: var(--warn);
  border: 1px solid #f2d6ba;
}

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

.card-grid:has(.metric:nth-child(2):last-child) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric {
  padding: 16px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
}

.question {
  padding: 22px;
  display: grid;
  gap: 16px;
}

.question h3 {
  margin: 0;
  font-size: 19px;
  line-height: 1.35;
}

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

.choice {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  padding: 9px 12px;
  text-align: left;
}

.choice.active {
  border-color: var(--brand);
  background: #eef8f5;
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: #dce6e0;
  overflow: hidden;
}

.progress div {
  height: 100%;
  background: var(--brand);
}

.bristol-chart {
  display: block;
  width: min(100%, 680px);
  max-height: 360px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.side-panel {
  padding: 18px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.answer-list {
  display: grid;
  gap: 8px;
  max-height: 540px;
  overflow: auto;
}

.answer-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfb;
}

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

.answer-row strong {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.selectable-row {
  cursor: pointer;
}

.selectable-row:hover {
  background: #f1f6f3;
}

.selected-row {
  background: #eaf6f1;
  box-shadow: inset 3px 0 0 var(--brand);
}

.dashboard {
  display: grid;
  gap: 16px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 16px;
}

.section {
  padding: 18px;
}

.section h3 {
  margin: 0 0 12px;
  font-size: 17px;
}

.subsection {
  margin-top: 14px;
}

.subsection h4 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--brand-dark);
}

.clinical-tabs {
  margin-bottom: 12px;
  max-width: 100%;
  flex-wrap: wrap;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  color: var(--ink);
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

.hidden {
  display: none !important;
}

@media (max-width: 920px) {
  .shell,
  .auth,
  .workbench,
  .split {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

@media (max-width: 560px) {
  .main {
    padding: 16px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
