:root {
  --ink: #243244;
  --muted: #667386;
  --line: #dce3ea;
  --panel: #ffffff;
  --page: #f4f7f9;
  --teal: #159aa1;
  --teal-dark: #0d7077;
  --mint: #dff4ef;
  --blue: #2e6dd8;
  --amber: #b56b00;
  --amber-bg: #fff5df;
  --danger: #b42318;
  --danger-bg: #fff0ed;
  --shadow: 0 18px 45px rgba(24, 40, 55, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  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 {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
}

.sidebar {
  color: #f6fbfc;
  background:
    linear-gradient(rgba(7, 72, 78, 0.88), rgba(7, 72, 78, 0.92)),
    radial-gradient(circle at 20% 0%, #53c9ca 0, transparent 34%),
    linear-gradient(135deg, #0c777f, #174364);
  padding: 32px 26px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #fff;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

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

.brand h1 {
  font-size: 21px;
  line-height: 1.2;
}

.eyebrow {
  color: inherit;
  opacity: 0.72;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.steps {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  list-style: none;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.75);
}

.steps li.active {
  color: #073d44;
  background: #e7fbf7;
}

.steps li.complete {
  color: #fff;
}

.step-index {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid currentColor;
  font-size: 13px;
  font-weight: 800;
}

.main-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar,
.footer-actions {
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 22px 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.footer-actions {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.topbar h2 {
  margin-top: 4px;
  font-size: 28px;
  line-height: 1.15;
}

.topbar .eyebrow {
  color: var(--teal-dark);
}

.content {
  padding: 36px 38px;
  overflow: auto;
}

.section-intro {
  max-width: 820px;
  margin-bottom: 22px;
  color: var(--muted);
  line-height: 1.5;
}

.row-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.clinic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.clinic-card,
.animal-card,
.service-card,
.screening-card,
.detail-card,
.summary-panel,
.policies-card,
.policy-ack-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(24, 40, 55, 0.04);
}

.clinic-card {
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  text-align: left;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.clinic-card:hover,
.clinic-card.selected {
  border-color: var(--teal);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.clinic-card.selected {
  border-width: 3px;
  outline: 4px solid rgba(21, 154, 161, 0.2);
}

.clinic-card h3,
.animal-card h3,
.service-card h3,
.detail-card h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.clinic-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  color: #e8fbf8;
  background:
    linear-gradient(rgba(7, 72, 78, 0.45), rgba(7, 72, 78, 0.58)),
    linear-gradient(135deg, #0c777f, #174364);
  font-size: 22px;
  font-weight: 900;
}

.clinic-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.clinic-body {
  padding: 16px;
}

.selected-ribbon {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  display: none;
  min-height: 32px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  color: #073d44;
  background: #e8fbf8;
  box-shadow: 0 8px 20px rgba(7, 61, 68, 0.18);
  font-size: 13px;
  font-weight: 900;
}

.clinic-card.selected .selected-ribbon {
  display: inline-flex;
}

.select-status {
  margin-top: 14px;
  min-height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--teal-dark);
  background: #fff;
  font-weight: 850;
}

.clinic-card.selected .select-status {
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
}

.lookup-box,
.match-box {
  max-width: 880px;
  margin: -8px 0 18px;
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 750;
}

.lookup-box {
  color: var(--muted);
  background: #eef3f6;
  border: 1px solid var(--line);
}

.match-box {
  color: var(--teal-dark);
  background: var(--mint);
  border: 1px solid rgba(21, 154, 161, 0.36);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--teal-dark);
  background: var(--mint);
  font-size: 13px;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 880px;
}

.conditional-section {
  max-width: 880px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #eef3f6;
}

.conditional-section h3 {
  margin-bottom: 14px;
}

.checkbox-fieldset {
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.checkbox-fieldset legend {
  padding: 0 6px;
}

.radio-row {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: #fbfcfd;
}

.radio-row input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  flex: 0 0 auto;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

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

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(21, 154, 161, 0.18);
  border-color: var(--teal);
}

.wide {
  grid-column: 1 / -1;
}

.animal-list,
.service-list {
  display: grid;
  gap: 16px;
  max-width: 980px;
}

.animal-card,
.service-card,
.detail-card {
  padding: 18px;
}

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

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--danger);
  background: #fff;
  cursor: pointer;
}

.service-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.checkbox-row,
.service-option,
fieldset label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--ink);
}

.checkbox-row input,
.service-option input,
fieldset input[type="checkbox"],
fieldset input[type="radio"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  flex: 0 0 auto;
}

.service-option {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: #fbfcfd;
}

.warning-box,
.error-box {
  margin-top: 14px;
  border-radius: 8px;
  padding: 12px;
  font-weight: 700;
}

.warning-box {
  color: var(--amber);
  background: var(--amber-bg);
  border: 1px solid #f2ca76;
}

.error-box {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #ffbeb7;
}

.screening-card {
  max-width: 980px;
  padding: 20px;
  display: grid;
  gap: 28px;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 12px;
}

legend {
  margin-bottom: 12px;
  font-weight: 850;
}

legend span {
  color: var(--muted);
}

.field-help {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.screening-question {
  gap: 14px;
}

.screening-question legend {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.35;
}

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

.screening-checkbox-grid label {
  min-height: 36px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.35;
}

.screening-checkbox-grid label:has(input:checked) {
  color: var(--teal-dark);
  font-weight: 750;
}

.choice-tile {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(24, 40, 55, 0.08);
  font-size: 14px;
  line-height: 1.3;
}

.choice-tile:has(input:checked) {
  border-color: var(--teal);
  background: #eef7f4;
}

.review-layout,
.payment-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
  align-items: start;
}

.policies-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
  align-items: start;
}

.policies-card,
.policy-ack-card {
  padding: 22px;
}

.policies-card {
  max-width: 980px;
  display: grid;
  gap: 20px;
  line-height: 1.5;
}

.policies-card h3 {
  margin: 0;
  font-size: 24px;
}

.policies-card h4 {
  margin: 0 0 8px;
  font-size: 17px;
}

.policies-card h5 {
  margin: 12px 0 6px;
  font-size: 15px;
}

.policies-card p,
.policies-card ul {
  margin: 0;
}

.policies-card ul {
  padding-left: 22px;
}

.policy-ack-card {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 22px;
}

.signature-section {
  display: grid;
  gap: 10px;
}

.signature-section label {
  font-weight: 850;
}

.signature-section label span {
  color: var(--muted);
}

.signature-pad {
  width: 100%;
  aspect-ratio: 32 / 11;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 1px 2px rgba(24, 40, 55, 0.08);
  touch-action: none;
}

.signature-actions {
  display: flex;
  justify-content: flex-end;
}

.single-column {
  grid-template-columns: 1fr;
}

.admin-shell {
  min-height: 100vh;
  padding: 28px;
  background: var(--page);
}

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

.admin-header h1 {
  margin: 0;
  font-size: 32px;
}

.admin-grid {
  display: grid;
  gap: 20px;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

.admin-table td span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef3f6;
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.status-finalized {
  background: #e8f7ee;
  color: #176536;
}

.status-error {
  background: var(--danger-bg);
  color: var(--danger);
}

.status-checkout_created {
  background: var(--amber-bg);
  color: var(--amber);
}

.admin-error-row td {
  color: var(--danger);
  background: var(--danger-bg);
}

.admin-note-row td {
  color: var(--muted);
  background: #f8fbfb;
}

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

.event-row {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.event-row time {
  color: var(--muted);
  font-size: 12px;
}

.event-row pre {
  max-height: 180px;
  margin: 0;
  overflow: auto;
  color: var(--muted);
  font-size: 12px;
  white-space: pre-wrap;
}

#reviewDetails {
  display: grid;
  gap: 16px;
}

.summary-panel {
  position: sticky;
  top: 18px;
  padding: 18px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.summary-line.total {
  border-bottom: 0;
  font-size: 20px;
  font-weight: 900;
}

.flag-list {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--amber);
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 44px;
  border-radius: 7px;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--teal);
  color: #fff;
  background: var(--teal);
}

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

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.secondary-button,
.ghost-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.ghost-button {
  color: var(--teal-dark);
}

.compact {
  min-height: 38px;
}

.confirmation {
  max-width: 920px;
  margin: 0 auto;
  text-align: center;
}

.success-mark {
  width: 62px;
  height: 62px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--teal-dark);
  background: var(--mint);
  font-size: 34px;
  font-weight: 900;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 20px;
  }

  .steps {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .topbar,
  .footer-actions,
  .content {
    padding-left: 20px;
    padding-right: 20px;
  }

  .form-grid,
  .review-layout,
  .payment-layout,
  .screening-checkbox-grid,
  .screening-choice-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .row-intro,
  .footer-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .footer-actions {
    flex-direction: column-reverse;
  }
}
