:root {
  color-scheme: light;
  --bg: #f6f2ee;
  --surface: #ffffff;
  --surface-soft: #fbf8f5;
  --text: #25211f;
  --muted: #6c625c;
  --line: #e8ddd4;
  --accent: #d9590d;
  --accent-dark: #a94108;
  --accent-soft: #fff1e8;
  --teal: #1f6f8b;
  --success: #137a4b;
  --danger: #b42318;
  --shadow: 0 20px 60px rgba(64, 42, 27, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(rgba(246, 242, 238, 0.86), rgba(246, 242, 238, 0.92)),
    url("assets/clinic-hero.jpg") center top / cover fixed;
  color: var(--text);
  letter-spacing: 0;
  overflow-x: hidden;
  overflow-anchor: none;
}

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

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 42px);
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 156px;
  min-height: 42px;
}

.brand img {
  width: 210px;
  max-width: 52vw;
  height: auto;
  display: block;
}

.visit-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 28px rgba(64, 42, 27, 0.08);
  white-space: nowrap;
}

.visit-chip span {
  color: var(--muted);
  font-size: 13px;
}

.language-select {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 28px rgba(64, 42, 27, 0.08);
}

.language-select span {
  color: var(--muted);
  font-size: 13px;
}

.language-select select {
  min-height: 30px;
  width: 66px;
  padding: 4px 24px 4px 8px;
  border: 0;
  background-color: transparent;
  font-weight: 800;
}

.demo-fill-button {
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid #f0c7ad;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 8px 28px rgba(217, 89, 13, 0.18);
}

.demo-fill-button:hover {
  background: var(--accent-dark);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
  gap: 22px;
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto 34px;
  align-items: start;
}

.patient-flow,
.staff-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero-strip {
  display: grid;
  min-height: 230px;
  padding: clamp(24px, 4vw, 44px);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.9) 58%, rgba(255, 255, 255, 0.18) 100%),
    url("assets/clinic-hero.jpg") center / cover;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.step-kicker {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 660px;
  font-size: clamp(32px, 5vw, 54px);
}

h2 {
  font-size: 24px;
}

.lead {
  max-width: 660px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.progress {
  padding: 22px clamp(18px, 4vw, 38px) 0;
}

.progress-line {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: #eee3da;
  overflow: hidden;
}

.progress-line span {
  display: block;
  width: 25%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #f08a3f);
  border-radius: inherit;
  transition: width 220ms ease;
}

.progress ol {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.progress li {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.progress li.active {
  color: var(--accent-dark);
}

.draft-state {
  min-height: 18px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

form {
  padding: 0 clamp(18px, 4vw, 38px) 30px;
}

.step-panel {
  display: none;
  min-height: 360px;
  padding-top: 28px;
}

.step-panel.active {
  display: block;
  animation: stepIn 180ms ease-out;
}

@keyframes stepIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-heading {
  margin-bottom: 22px;
}

.notice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.notice {
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.notice strong,
.notice span {
  display: block;
}

.notice span {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.check-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  line-height: 1.45;
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.nfc-button {
  width: 100%;
  min-height: 78px;
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid #f0c7ad;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--text);
  text-align: left;
}

.button-title,
.button-subtitle {
  display: block;
}

.button-title {
  font-weight: 800;
}

.button-subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

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

label span,
legend {
  display: block;
  margin-bottom: 7px;
  color: #3a332f;
  font-size: 14px;
  font-weight: 750;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
input:not([type]),
textarea,
select {
  width: 100%;
  min-height: 48px;
  padding: 12px 13px;
  border: 1px solid #dbcfc6;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  outline: none;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #6c625c 50%),
    linear-gradient(135deg, #6c625c 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 20px,
    calc(100% - 12px) 20px;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

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

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 89, 13, 0.14);
}

.autofill-target {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(217, 89, 13, 0.18), 0 10px 28px rgba(217, 89, 13, 0.12) !important;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.invalid input:invalid,
.invalid #consent:invalid {
  border-color: var(--danger);
}

.question-stack {
  display: grid;
  gap: 16px;
}

fieldset {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

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

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

.choice-grid label,
.segmented label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: #403833;
  touch-action: manipulation;
}

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

.summary-box {
  display: grid;
  gap: 12px;
}

.summary-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.summary-row span {
  color: var(--muted);
  font-weight: 700;
}

.summary-row strong {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.primary,
.secondary {
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
}

.primary {
  background: var(--accent);
  color: #fff;
}

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

.cta-nudge {
  animation: ctaNudge 900ms ease-in-out 2;
}

@keyframes ctaNudge {
  0%, 100% {
    transform: translateX(0) scale(1);
    box-shadow: none;
  }
  35% {
    transform: translateX(4px) scale(1.02);
    box-shadow: 0 10px 28px rgba(217, 89, 13, 0.28);
  }
  70% {
    transform: translateX(-2px) scale(1.01);
  }
}

.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.secondary:hover {
  background: var(--surface-soft);
}

.compact {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 13px;
}

.done-panel {
  display: none;
  padding: 34px clamp(18px, 4vw, 38px) 38px;
  border-top: 1px solid var(--line);
}

.done-panel.active {
  display: block;
}

.done-panel h2 {
  max-width: 620px;
  margin-bottom: 18px;
}

.staff-panel {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
}

.staff-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
}

.staff-head h2 {
  font-size: 21px;
}

.staff-list {
  display: grid;
  gap: 12px;
  padding: 16px;
  overflow: auto;
}

.empty-state {
  padding: 18px;
  border: 1px dashed #d8c9bf;
  border-radius: 8px;
  color: var(--muted);
  line-height: 1.45;
  background: var(--surface-soft);
}

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

.submission-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.submission-card h3 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

.status-pill {
  align-self: start;
  padding: 5px 8px;
  border-radius: 999px;
  background: #e9f7f0;
  color: var(--success);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.submission-card dl {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 7px 10px;
  margin: 0;
  padding: 14px;
  font-size: 14px;
}

.submission-card dt {
  color: var(--muted);
  font-weight: 750;
}

.submission-card dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 10;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 28px));
  padding: 12px 16px;
  border-radius: 8px;
  background: #2d2824;
  color: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
}

@media (prefers-reduced-motion: reduce) {
  .step-panel.active,
  .cta-nudge {
    animation: none;
  }
}

@media (max-width: 980px) {
  body {
    background-attachment: scroll;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .staff-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    gap: 8px;
    padding: 14px 16px;
  }

  .top-actions {
    flex-wrap: wrap;
    gap: 7px;
  }

  .brand {
    min-width: 0;
    flex: 1 1 auto;
  }

  .brand img {
    width: clamp(126px, 38vw, 170px);
  }

  .visit-chip {
    flex: 0 1 auto;
    max-width: 52vw;
    min-width: 0;
    padding: 7px 9px;
    font-size: 13px;
  }

  .language-select {
    min-height: 36px;
    padding: 0 7px;
  }

  .language-select span {
    display: none;
  }

  .demo-fill-button {
    order: 3;
    flex-basis: 100%;
    min-height: 38px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .visit-chip strong {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .hero-strip {
    min-height: 210px;
    background:
      linear-gradient(rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.88)),
      url("assets/clinic-hero.jpg") center / cover;
  }

  .progress ol,
  .notice-grid,
  .field-grid,
  .choice-grid,
  .detail-grid,
  .segmented,
  .summary-row {
    grid-template-columns: 1fr;
  }

  .progress li {
    font-size: 12px;
  }

  .form-actions {
    position: sticky;
    bottom: 0;
    z-index: 3;
    margin: 0 -18px -30px;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.96);
  }

  body.keyboard-open .form-actions {
    position: static;
    margin: 0 -18px -30px;
  }

  .form-actions button {
    flex: 1;
  }

  .staff-head {
    align-items: flex-start;
  }
}
