:root {
  --ink: #17212b;
  --muted: #64717e;
  --line: #d8e0e7;
  --panel: #ffffff;
  --surface: #f5f7f9;
  --surface-2: #eef3f5;
  --teal: #147c76;
  --teal-dark: #0f5f5a;
  --blue: #245c8f;
  --amber: #a96800;
  --red: #af2d2d;
  --green: #2d7a43;
  --shadow: 0 14px 32px rgba(23, 33, 43, 0.08);
}

* {
  box-sizing: border-box;
}

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

body.lead-locked .topbar,
body.lead-locked .layout {
  display: none;
}

.lead-gate {
  display: none;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  gap: 40px;
  align-items: center;
  padding: 48px;
  background:
    linear-gradient(rgba(245, 247, 249, 0.94), rgba(245, 247, 249, 0.94)),
    url("./assets/source-images/c-j-301-400-101-visit-1/page-07.png") center right / 680px auto no-repeat;
}

body.lead-locked .lead-gate {
  display: grid;
}

.lead-copy {
  max-width: 640px;
}

.lead-copy h1 {
  margin: 0 0 14px;
  max-width: 680px;
  font-size: clamp(2rem, 4vw, 4.6rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.lead-copy p:last-child {
  max-width: 540px;
  margin: 0;
  color: #435261;
  font-size: 1.06rem;
  line-height: 1.6;
}

.lead-form {
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.lead-form h2 {
  margin: 0;
  font-size: 1.2rem;
}

.lead-form label {
  display: grid;
  gap: 5px;
  color: #344553;
  font-size: 0.83rem;
  font-weight: 650;
}

.lead-form input,
.lead-form select {
  min-height: 40px;
  border: 1px solid #cbd7df;
  border-radius: 7px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.consent-row {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.45;
}

.consent-row input {
  min-height: 18px;
  margin-top: 2px;
}

.lead-message {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.lead-message.error {
  color: var(--red);
}

.hidden-field {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

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

button,
a.ghost-btn {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 12px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

button:hover,
a.ghost-btn:hover {
  border-color: #9fb1c0;
}

.primary-btn {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

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

.danger-btn {
  border-color: #e8c5c5;
  color: var(--red);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 14px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar h1,
.workspace-header h2,
.study-band h2,
dialog h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 1.35rem;
}

.top-actions,
.visit-tabs,
.form-tabs,
.source-toolbar,
.dialog-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: calc(100vh - 76px);
}

.subjects-panel {
  border-right: 1px solid var(--line);
  background: #fff;
  overflow: auto;
}

.study-band {
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.study-band h2 {
  margin-bottom: 7px;
  font-size: 1.08rem;
}

.study-band p:last-child {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

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

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.metric {
  padding: 10px;
  background: var(--surface-2);
  border-radius: 7px;
}

.metric strong {
  display: block;
  font-size: 1.1rem;
}

.metric span {
  color: var(--muted);
  font-size: 0.75rem;
}

.subject-list {
  padding: 10px;
}

.subject-card {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  text-align: left;
  background: #fff;
}

.subject-card.active {
  border-color: var(--teal);
  box-shadow: inset 3px 0 0 var(--teal);
}

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

.subject-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.worklist-view,
.casebook-view {
  min-width: 0;
}

.casebook-view[hidden],
.worklist-view[hidden] {
  display: none;
}

.worklist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.worklist-header h2 {
  margin: 0;
  font-size: 1.18rem;
}

.worklist-controls {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) minmax(170px, 0.8fr) minmax(180px, 0.8fr);
  gap: 12px;
  padding: 14px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.worklist-controls label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #344553;
  font-size: 0.8rem;
  font-weight: 650;
}

.worklist-controls input,
.worklist-controls select {
  min-height: 38px;
  border: 1px solid #cbd7df;
  border-radius: 7px;
  padding: 8px 10px;
  background: #fff;
}

.subject-grid-wrap {
  margin: 14px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.subject-grid {
  min-width: 920px;
}

.subject-grid tbody tr:hover {
  background: #f8fbfc;
}

.subject-grid td:first-child strong {
  display: block;
}

.subject-grid td:first-child span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.subject-grid .primary-btn {
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid #c9d9de;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef7f6;
  color: var(--teal-dark);
  font-size: 0.76rem;
  font-weight: 700;
}

.status-pill.warning {
  background: #fff4df;
  border-color: #f2d59a;
  color: var(--amber);
}

.status-pill.neutral {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--muted);
}

.casebook-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.workspace-header h2 {
  font-size: 1.18rem;
}

.visit-tabs {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.visit-tabs button,
.form-tabs button {
  min-height: 34px;
  padding: 7px 10px;
}

.visit-tabs button.active,
.form-tabs button.active {
  border-color: var(--teal);
  background: #e4f3f1;
  color: var(--teal-dark);
}

.split {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(420px, 0.92fr);
  gap: 14px;
  padding: 14px;
  min-height: 640px;
}

.edc-panel,
.source-panel,
.review-band {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.form-tabs {
  flex-wrap: wrap;
}

.edc-form {
  padding: 16px;
  max-height: 610px;
  overflow: auto;
}

.form-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.form-section-title h3 {
  margin: 0;
  font-size: 1rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 99px;
  padding: 3px 9px;
  font-size: 0.74rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
}

.badge.open {
  background: #fff0d9;
  color: var(--amber);
}

.badge.complete {
  background: #e1f2e6;
  color: var(--green);
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: #2b3946;
  font-size: 0.83rem;
  font-weight: 650;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cbd7df;
  border-radius: 7px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.field textarea {
  min-height: 86px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid rgba(20, 124, 118, 0.18);
  border-color: var(--teal);
}

.field small {
  color: var(--muted);
  line-height: 1.35;
}

.check-field {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.check-field input {
  width: 18px;
  min-height: 18px;
}

.table-wrap {
  grid-column: 1 / -1;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: #344553;
  font-size: 0.76rem;
}

td input,
td select {
  width: 100%;
  min-height: 34px;
  border: 1px solid #cbd7df;
  border-radius: 6px;
  padding: 6px 8px;
}

.source-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.source-toolbar {
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.source-toolbar h3 {
  margin: 0;
  font-size: 0.98rem;
}

.source-pages {
  width: 100%;
  height: 100%;
  min-height: 600px;
  overflow: auto;
  padding: 14px;
  background: #d6dde3;
}

.source-page {
  display: block;
  width: min(100%, 980px);
  margin: 0 auto 14px;
  border: 1px solid #aebbc5;
  background: #fff;
  box-shadow: 0 8px 18px rgba(23, 33, 43, 0.12);
}

.protocol-actions {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.protocol-pages {
  height: calc(100% - 128px);
  min-height: 0;
}

.review-band {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 0 14px 14px;
  padding: 16px;
}

.review-band h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.query-item,
.audit-item,
.empty-state {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  margin-bottom: 8px;
}

.query-item strong,
.audit-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.86rem;
}

.query-item p,
.audit-item p,
.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.42;
}

.query-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.query-actions input {
  flex: 1;
  min-height: 34px;
  border: 1px solid #cbd7df;
  border-radius: 6px;
  padding: 6px 8px;
}

dialog {
  width: min(1100px, calc(100vw - 32px));
  height: min(860px, calc(100vh - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 22px 60px rgba(23, 33, 43, 0.22);
}

dialog::backdrop {
  background: rgba(23, 33, 43, 0.45);
}

.dialog-header {
  justify-content: space-between;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}


@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .workspace {
    order: 1;
  }

  .subjects-panel {
    order: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .subject-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .subject-card {
    margin-bottom: 0;
  }

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

@media (max-width: 760px) {
  .lead-gate {
    grid-template-columns: 1fr;
    padding: 24px;
    background:
      linear-gradient(rgba(245, 247, 249, 0.96), rgba(245, 247, 249, 0.96)),
      url("./assets/source-images/c-j-301-400-101-visit-1/page-07.png") center bottom / 520px auto no-repeat;
  }

  .lead-copy h1 {
    font-size: 2.15rem;
  }

  .topbar,
  .workspace-header,
  .form-toolbar,
  .worklist-header,
  .casebook-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .visit-tabs,
  .form-tabs {
    justify-content: flex-start;
  }

  .subject-list,
  .metrics,
  .review-band,
  .field-grid,
  .worklist-controls {
    grid-template-columns: 1fr;
  }

  .split {
    padding: 10px;
  }
}
