:root {
  --ink: #172033;
  --muted: #5c6678;
  --line: #d7deea;
  --surface: #ffffff;
  --field: #f8fafc;
  --blue: #365f9f;
  --blue-dark: #24477d;
  --teal: #17776d;
  --amber: #b7791f;
  --danger: #c53030;
  --page: #eef3f8;
  --shadow: 0 16px 40px rgba(23, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

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

.intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 0 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 12px;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1;
  letter-spacing: 0;
}

.intro-copy {
  max-width: 640px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
}

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

.demo-notice {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid #f0c879;
  border-radius: 8px;
  background: #fff8e8;
  color: #6f4a08;
  line-height: 1.45;
}

.view-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.view-tab {
  min-height: 48px;
  border: 1px solid #b9c8dc;
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
  font-weight: 850;
}

.view-tab.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

.visit-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  background: #dfe7f2;
  border-bottom: 1px solid var(--line);
}

.switch-button {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.switch-button.active {
  background: var(--surface);
  border-color: #b9c8dc;
  color: var(--blue-dark);
}

form {
  padding: 26px;
}

.field-section {
  padding: 0 0 28px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  margin-bottom: 12px;
  font-size: 1.16rem;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field.wide {
  grid-column: span 2;
}

.field span,
.inline-prompt legend {
  color: #26344d;
  font-size: 0.92rem;
  font-weight: 800;
}

.field strong {
  color: var(--danger);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c9d3e0;
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input,
select {
  min-height: 48px;
  padding: 0 14px;
}

textarea {
  min-height: 96px;
  padding: 13px 14px;
  line-height: 1.45;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  background: #ffffff;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(54, 95, 159, 0.16);
}

.inline-prompt {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 18px 0 0;
  padding: 14px;
  border: 1px solid #f0c879;
  border-radius: 8px;
  background: #fff8e8;
}

.inline-prompt legend {
  padding: 0 6px;
  color: #6f4a08;
}

.inline-prompt label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.inline-prompt input {
  width: 18px;
  min-height: auto;
}

.history-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 18px;
}

.history-field textarea {
  min-height: 220px;
}

.voice-box,
.prompt-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.voice-box {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 18px;
}

.voice-box h3,
.prompt-list h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.voice-box p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.recorder-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.record-button,
.secondary-button,
.submit-button {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 850;
}

.record-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  background: var(--danger);
  color: #ffffff;
}

.record-button.recording {
  background: var(--amber);
}

.record-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #ffffff;
}

.recording .record-dot {
  animation: pulse 900ms ease-in-out infinite;
}

.secondary-button {
  padding: 0 16px;
  background: #e7edf5;
  color: #26344d;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.recording-status {
  font-weight: 700;
}

.transcription-note {
  padding: 10px 12px;
  border: 1px solid #d7deea;
  border-radius: 6px;
  background: #ffffff;
  font-size: 0.9rem;
}

audio {
  width: 100%;
}

.question-group {
  margin-top: 18px;
}

.prompt-list {
  margin-top: 18px;
  padding: 18px;
}

.prompt-list ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.4;
}

.consent {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
  color: #26344d;
  font-weight: 700;
  line-height: 1.45;
}

.consent input {
  width: 20px;
  min-height: 20px;
  margin-top: 2px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 22px;
}

.submit-button {
  padding: 0 24px;
  background: var(--blue);
  color: #ffffff;
}

.submit-button:hover,
.submit-button:focus-visible {
  background: var(--blue-dark);
}

.success-dialog {
  width: min(520px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  padding: 26px;
  box-shadow: var(--shadow);
}

.success-dialog::backdrop {
  background: rgba(14, 22, 36, 0.46);
}

.success-dialog h2 {
  margin-bottom: 8px;
}

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

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

.review-header h2 {
  margin-bottom: 0;
  font-size: 1.8rem;
}

.review-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

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

.queue-summary div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.queue-summary span {
  display: block;
  color: var(--blue-dark);
  font-size: 1.8rem;
  font-weight: 900;
}

.queue-summary p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 800;
}

.empty-queue {
  padding: 18px;
  border: 1px dashed #b9c8dc;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 750;
  text-align: center;
}

.submission-list {
  display: grid;
  gap: 14px;
}

.submission-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.submission-card summary {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(4, minmax(120px, 0.7fr));
  gap: 12px;
  align-items: center;
  padding: 16px;
  cursor: pointer;
  list-style: none;
}

.submission-card summary::-webkit-details-marker {
  display: none;
}

.patient-main strong {
  display: block;
  font-size: 1.04rem;
}

.patient-main span,
.queue-cell span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.queue-cell b {
  display: block;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e7f4f2;
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 900;
}

.submission-detail {
  display: grid;
  gap: 16px;
  padding: 0 16px 16px;
}

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

.detail-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.detail-box.full {
  grid-column: 1 / -1;
}

.detail-box h3 {
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.detail-box p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-wrap;
}

.detail-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: minmax(130px, 0.36fr) 1fr;
  gap: 10px;
  color: var(--muted);
  line-height: 1.4;
}

.detail-list dt {
  color: #26344d;
  font-weight: 850;
}

.detail-list dd {
  margin: 0;
}

.copy-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.success-dialog p {
  color: var(--muted);
  line-height: 1.5;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

[hidden] {
  display: none !important;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(0.78);
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    padding-top: 18px;
  }

  .intro {
    padding-top: 12px;
  }

  h1 {
    font-size: 2.25rem;
  }

  form {
    padding: 18px;
  }

  .form-grid,
  .history-layout {
    grid-template-columns: 1fr;
  }

  .review-header,
  .submission-card summary {
    grid-template-columns: 1fr;
  }

  .review-header {
    align-items: stretch;
  }

  .detail-grid,
  .queue-summary {
    grid-template-columns: 1fr;
  }

  .detail-list div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .field.wide {
    grid-column: auto;
  }
}

@media (max-width: 520px) {
  .view-tabs,
  .visit-switch {
    grid-template-columns: 1fr;
  }

  .inline-prompt {
    display: grid;
  }

  .actions,
  .dialog-actions {
    justify-content: stretch;
  }

  .submit-button,
  .secondary-button,
  .record-button {
    width: 100%;
    justify-content: center;
  }
}
