:root {
  --navy: #003970;         /* brand primary (site header/navbar) */
  --navy-deep: #002678;    /* darker heading blue */
  --navy-2: #0a4a86;       /* sidebar gradient stop */
  --cyan: #27a7de;         /* bright accent (hexagon / WELLNESS GROUP) */
  --cyan-soft: #e3f3fc;
  --blue-mid: #0078a7;
  --ink: #17222e;
  --muted: #5b6b7b;
  --line: #d9e0e8;
  --line-soft: #eef2f6;
  --bg: #f4f7fa;
  --card: #ffffff;
  --ok: #1a9d5a;
  --accent: #c1272d;       /* required-field red, matches paper form headers */
  --radius: 14px;
  --shadow: 0 10px 34px rgba(0, 41, 89, 0.10);
  --sidebar-w: 320px;
  --content-max: 820px;
  --font: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.55; }

/* ============================= LAYOUT ============================= */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* -------- Sidebar (desktop) -------- */
.sidebar {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 26px 22px;
  overflow-y: auto;
}
.sb-net { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.sidebar-top, .stepper, .sidebar-foot { position: relative; z-index: 1; }
.sidebar-top { margin-bottom: 22px; }
.brand-lockup { display: flex; align-items: center; gap: 9px; }
.brand-mark { width: 56px; height: 56px; flex: none; }
.brand-word { height: 42px; width: auto; max-width: 176px; display: block; }
.sidebar-tag { margin-top: 10px; font-size: 12.5px; color: #bcd6ef; font-weight: 500; letter-spacing: .2px; }

.stepper { flex: 1; display: flex; flex-direction: column; gap: 2px; margin: 6px 0; position: relative; }
.stepper-rail, .stepper-fill { position: absolute; left: 22px; width: 2px; border-radius: 2px; z-index: 0; pointer-events: none; }
.stepper-rail { background: rgba(255,255,255,.14); }
.stepper-fill { background: linear-gradient(180deg, var(--cyan), #9fdcf8); height: 0; transition: height .5s cubic-bezier(.4,0,.2,1); box-shadow: 0 0 10px rgba(39,167,222,.5); }
.step-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px;
  cursor: default; color: #cfe0f1; font-size: 13.5px; font-weight: 500; border: none; background: none;
  text-align: left; width: 100%; font-family: inherit; transition: background .15s, color .15s;
}
.step-item .num {
  width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; border: 1.5px solid rgba(255,255,255,.35); color: #cfe0f1;
}
.step-item.done { color: #eaf4fe; }
.step-item.done .num { background: var(--cyan); border-color: var(--cyan); color: #fff; }
.step-item.clickable { cursor: pointer; }
.step-item.clickable:hover { background: rgba(255,255,255,.08); }
.step-item.active { background: rgba(39,167,222,.18); color: #fff; font-weight: 600; }
.step-item.active .num { background: #fff; border-color: #fff; color: var(--navy); animation: nodePulse 2.2s ease-in-out infinite; }
@keyframes nodePulse { 0%,100% { box-shadow: 0 0 0 0 rgba(159,220,248,.55); } 50% { box-shadow: 0 0 0 8px rgba(159,220,248,0); } }
@media (prefers-reduced-motion: reduce) { .step-item.active .num { animation: none; } .stepper-fill { transition: none; } }

.sidebar-foot { margin-top: 16px; }
.side-progress { height: 6px; background: rgba(255,255,255,.18); border-radius: 99px; overflow: hidden; }
.side-progress-fill { height: 100%; width: 0%; background: var(--cyan); border-radius: 99px; transition: width .35s ease; }
.side-progress-meta { font-size: 12px; color: #bcd6ef; margin-top: 7px; }
.side-help { margin-top: 14px; font-size: 12.5px; color: #bcd6ef; border-top: 1px solid rgba(255,255,255,.15); padding-top: 12px; }
.side-help a { color: #fff; font-weight: 600; text-decoration: none; }

/* -------- Content column -------- */
.content { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }

/* Top bar shown only on tablet/mobile */
.topbar { display: none; }

main {
  flex: 1; width: 100%; max-width: var(--content-max);
  margin: 0 auto; padding: 40px 40px 150px;
}

.step { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity:1; transform:none;} }

.step-head { margin: 0 0 22px; }
.step-eyebrow { color: var(--cyan); font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; font-size: 12px; }
.step-title { font-size: 30px; font-weight: 700; margin: 5px 0 4px; color: var(--navy-deep); line-height: 1.15; }
.step-sub { color: var(--muted); font-size: 15.5px; max-width: 62ch; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px; margin-bottom: 18px;
}
.legal {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px;
  font-size: 14.5px; color: #35414d; max-height: 340px; overflow-y: auto; -webkit-overflow-scrolling: touch; margin-bottom: 20px;
}
.legal h4 { margin: 16px 0 6px; color: var(--navy-deep); font-size: 15px; }
.legal ol, .legal ul { padding-left: 20px; margin: 8px 0; }
.legal li { margin-bottom: 8px; }
.legal p { margin: 8px 0; }
.legal .u { text-decoration: underline; }

/* ============================= FIELDS ============================= */
.field { margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }
.field > label, .field-label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 15px; color: var(--ink); }
.field .req { color: var(--accent); margin-left: 3px; }
.hint { color: var(--muted); font-size: 13px; margin: -3px 0 8px; }

input[type=text], input[type=tel], input[type=email], input[type=number],
input[type=date], select, textarea {
  width: 100%; padding: 13px 14px; font-size: 16px; border: 1.5px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(39,167,222,.18); }
textarea { min-height: 100px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 560px){ .grid2, .grid3 { grid-template-columns: 1fr; } .grid2.keep, .grid3.keep { grid-template-columns: 1fr 1fr; } }

.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.choices.stack { flex-direction: column; }
.choice {
  position: relative; display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--line);
  border-radius: 10px; padding: 12px 16px; cursor: pointer; background: #fff; min-height: 50px; flex: 1 1 auto; user-select: none;
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; }
.choice.checked { border-color: var(--cyan); background: var(--cyan-soft); }
.choice.checked .dot { border-color: var(--cyan); }
.choice.checked .dot::after { content:""; width: 10px; height:10px; border-radius:50%; background: var(--cyan); }
.choice .txt { font-size: 15px; }

.ack { display: flex; gap: 12px; align-items: flex-start; border: 1.5px solid var(--line); border-radius: 10px; padding: 15px; background: #fff; cursor: pointer; }
.ack.checked { border-color: var(--ok); background: #f0fbf4; }
.ack .box { width: 22px; height: 22px; margin-top: 1px; border-radius: 6px; border: 2px solid var(--line); flex: none; display: grid; place-items: center; }
.ack.checked .box { border-color: var(--ok); background: var(--ok); }
.ack.checked .box::after { content:"\2713"; color:#fff; font-weight: 700; font-size: 14px; }
.ack input { display: none; }
.ack .txt { font-size: 14.5px; }

.cond-grid { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 10px; }
table.cond { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 14px; }
table.cond th, table.cond td { border-bottom: 1px solid var(--line); padding: 9px 6px; text-align: center; }
table.cond th { background: var(--navy); color: #fff; position: sticky; top: 0; font-size: 12px; font-weight: 600; }
table.cond td.cond-name { text-align: left; font-weight: 600; white-space: normal; min-width: 190px; }
table.cond tr:nth-child(even) td { background: #f8fafc; }
table.cond td small { color: var(--muted); font-weight: 400; display:block; }
.cbx { width: 22px; height: 22px; accent-color: var(--cyan); }

.rep-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; margin-bottom: 10px; align-items: start; }
.rep-row .del { border: 1.5px solid var(--line); background:#fff; border-radius: 10px; width: 48px; height: 50px; font-size: 18px; color: var(--accent); cursor: pointer; }
.btn-add { border: 1.5px dashed var(--cyan); color: var(--navy-deep); background: var(--cyan-soft); border-radius: 10px; padding: 12px; width: 100%; font-weight: 600; cursor: pointer; font-family: inherit; font-size: 15px; }

.sig-wrap { border: 1.5px solid var(--line); border-radius: 10px; background: #fff; position: relative; }
.sig-toggle { display: flex; gap: 6px; padding: 8px 8px 0; }
.sig-tab {
  flex: 1; border: 1.5px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 10px;
  font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.sig-tab.active { border-color: var(--cyan); background: var(--cyan-soft); color: var(--navy-deep); }
.sig-pad { display: block; width: 100%; height: 180px; border-radius: 10px; touch-action: none; }
.sig-type { padding: 0 12px 4px; }
.sig-type input { font-family: "Dancing Script", cursive; font-size: 22px; }
.sig-line { position: absolute; left: 16px; right: 16px; bottom: 44px; border-bottom: 1.5px dashed #cbd5e1; pointer-events: none; }
.sig-hint { position: absolute; left: 22px; bottom: 48px; color: #b7c1cd; font-size: 13px; pointer-events: none; }
.sig-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-top: 1px solid var(--line); }
.sig-bar small { color: var(--muted); }
.sig-clear { border: none; background: none; color: var(--accent); font-weight: 600; cursor: pointer; font-size: 14px; font-family: inherit; }

.photo-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.photo-btn {
  flex: 1 1 auto; min-width: 150px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff; padding: 14px 16px;
  font-weight: 600; font-size: 15px; color: var(--ink); cursor: pointer; min-height: 52px;
}
.photo-btn.primary { border-color: var(--cyan); background: var(--cyan-soft); color: var(--navy-deep); }
.photo-btn input { display: none; }
.photo-preview { margin-top: 12px; display: flex; gap: 10px; flex-wrap: wrap; }
.photo-preview .thumb { position: relative; }
.photo-preview img { height: 92px; border-radius: 8px; border: 1px solid var(--line); }
.photo-preview .rm { position: absolute; top: -8px; right: -8px; background: var(--accent); color:#fff; border:none; border-radius:50%; width: 24px; height:24px; cursor:pointer; }

/* ============================= NAV ============================= */
.footer-nav {
  position: sticky; bottom: 0; z-index: 30; background: rgba(255,255,255,.94);
  backdrop-filter: saturate(1.4) blur(10px); border-top: 1px solid var(--line);
  padding: 16px 40px calc(16px + env(safe-area-inset-bottom));
}
.footer-nav .inner { max-width: var(--content-max); margin: 0 auto; display: flex; gap: 12px; align-items: center; justify-content: flex-end; }
.btn {
  appearance: none; border: none; border-radius: 12px; padding: 14px 28px; font-size: 16px; font-weight: 600;
  cursor: pointer; font-family: inherit; min-height: 52px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary { background: var(--navy); color: #fff; min-width: 180px; }
.btn-primary:hover { background: var(--navy-deep); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--muted); }
.btn-submit { background: var(--ok); color: #fff; min-width: 200px; }
.btn-submit:hover { filter: brightness(.95); }

.err-msg { color: var(--accent); font-size: 13px; margin-top: 6px; font-weight: 600; display:none; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--accent); }
.field.invalid .err-msg { display: block; }

.banner { background: #fff8e6; border: 1px solid #f2d488; color: #8a6100; border-radius: 10px; padding: 13px 16px; font-size: 14px; margin-bottom: 18px; }
.banner.info { background: var(--cyan-soft); border-color: #b9dcf6; color: var(--navy-deep); }

/* review */
.review-group { margin-bottom: 20px; }
.review-group h3 { font-size: 15px; color: var(--navy); border-bottom: 2px solid var(--cyan-soft); padding-bottom: 7px; margin: 0 0 10px; }
.review-row { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14.5px; }
.review-row .k { color: var(--muted); flex: 1; }
.review-row .v { font-weight: 600; text-align: right; flex: 1; word-break: break-word; }
.review-row .v img { height: 46px; border: 1px solid var(--line); border-radius: 6px; }

.success { text-align: center; padding: 46px 10px; max-width: 560px; margin: 0 auto; }
.success .check { width: 82px; height: 82px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items:center; font-size: 44px; margin: 0 auto 18px; }
.success .check-warn { background: var(--warn, #b45309); font-weight: 800; }
.success h2 { color: var(--navy-deep); }
.success .handoff { margin: 22px auto 4px; font-size: 14px; color: var(--muted); }
.success-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 14px; }
.btn-restart { min-height: 60px; font-size: 17px; padding: 16px 34px; }

.hidden { display: none !important; }
.spin { width: 18px; height: 18px; border: 3px solid rgba(255,255,255,.4); border-top-color:#fff; border-radius: 50%; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ============================= RESPONSIVE ============================= */
/* Tablet & mobile: hide sidebar, show top bar, sticky bottom nav */
@media (max-width: 1023px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 25;
    background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%); color: #fff;
    padding: 12px 20px calc(12px);
  }
  .topbar-mark { width: 38px; height: 38px; flex: none; }
  .topbar-mid { flex: 1; min-width: 0; }
  .topbar-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-track { height: 5px; background: rgba(255,255,255,.22); border-radius: 99px; margin-top: 6px; overflow: hidden; }
  .topbar-fill { height: 100%; width: 0%; background: var(--cyan); border-radius: 99px; transition: width .35s ease; }
  .topbar-count { font-size: 12.5px; color: #cfe0f1; font-weight: 600; flex: none; }
  main { padding: 26px 22px 150px; max-width: 760px; }
  .step-title { font-size: 25px; }
  .footer-nav {
    position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  }
  .footer-nav .inner { justify-content: stretch; }
  .btn-ghost { flex: 0 0 auto; min-width: 96px; }
  .btn-primary, .btn-submit { flex: 1; min-width: 0; }
}

@media (max-width: 560px) {
  main { padding: 20px 16px 150px; }
  .card { padding: 18px; }
  .step-title { font-size: 22px; }
}

@media print {
  .sidebar, .topbar, .footer-nav, .no-print { display: none !important; }
  .layout { grid-template-columns: 1fr; }
  body { background: #fff; }
  main { padding: 0; }
}

/* In-page submit on the review step — always reachable even if the sticky
   footer is obscured by the mobile browser's own toolbar. */
.review-submit { margin-top: 22px; display: flex; justify-content: center; }
.btn-inline-submit { width: 100%; max-width: 420px; min-height: 60px; font-size: 17px; }
