:root {
  --ink: #1c2330;
  --muted: #5b6472;
  --line: #d9dde3;
  --bg: #f3f4f6;
  --card: #ffffff;
  --accent: #24585c;
  --accent-ink: #ffffff;
  --accent-soft: #e5efef;
  --todo: #c26a12;
  --todo-soft: rgba(242, 166, 64, 0.22);
  --done-soft: rgba(36, 88, 92, 0.08);
  --danger: #a3322a;
  --pen: #10233f;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px 112px; }

/* Top bar */
.bar { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line); }
.bar-inner { max-width: 760px; margin: 0 auto; padding: 10px 16px 8px; }
.doc { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { height: 4px; background: var(--line); border-radius: 4px; margin: 8px 0 6px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }
.step-label { font-size: 12.5px; color: var(--muted); }

/* Cards and type */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 12px; }
.center { display: grid; place-items: center; min-height: 40vh; text-align: center; }
.kicker { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin: 0 0 6px; }
h1 { font-size: 24px; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 19px; margin: 0 0 6px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

ol.steps { margin: 12px 0 18px; padding-left: 22px; }
ol.steps li { margin-bottom: 4px; }

label.field { display: block; margin: 0 0 14px; }
label.field > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; }
label.field > span em { font-style: normal; font-weight: 400; color: var(--muted); }
input[type="text"], input[type="email"], input[type="date"], input[type="datetime-local"] {
  width: 100%; font: inherit; padding: 11px 12px; border: 1px solid #b9bfc8; border-radius: 9px; background: #fff; color: var(--ink);
}
input:focus { outline: 3px solid rgba(36, 88, 92, .25); border-color: var(--accent); }
input.invalid { border-color: var(--danger); }

.consent { display: flex; gap: 12px; align-items: flex-start; padding: 14px; background: var(--accent-soft); border-radius: 10px; font-size: 15px; cursor: pointer; }
.consent input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }

/* Signature pads */
.pad-label { display: flex; justify-content: space-between; align-items: baseline; margin: 4px 0 6px; font-weight: 600; font-size: 14px; }
.pad-label button { font: inherit; font-size: 14px; font-weight: 500; color: var(--accent); background: none; border: 0; padding: 4px; cursor: pointer; }
.pad {
  position: relative; width: 100%; background: #fff; border: 1.5px dashed #9aa3ae; border-radius: 10px;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.pad canvas { display: block; width: 100%; height: 100%; border-radius: 10px; cursor: crosshair; }
.pad .baseline { position: absolute; left: 6%; right: 6%; bottom: 26%; border-bottom: 1px solid #c8cdd4; pointer-events: none; }
.pad .hint { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; color: #a3aab4; pointer-events: none; font-size: 15px; }
.pad.has-ink .hint { display: none; }
.pad.sig { aspect-ratio: 3 / 1.15; }
.pad.ini { aspect-ratio: 2 / 1.1; max-width: 320px; }

/* Document pages */
.page-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.page-head a { font-size: 14px; color: var(--accent); white-space: nowrap; }
.sheet { position: relative; width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.sheet img { display: block; width: 100%; height: auto; }
.box {
  position: absolute; border: 0; padding: 0; margin: 0; border-radius: 3px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  font: 600 clamp(7px, 1.6vw, 11px)/1.1 system-ui, sans-serif; color: var(--todo);
  background: var(--todo-soft); outline: 2px solid var(--todo); animation: pulse 1.6s ease-in-out infinite;
}
.box.done { background: var(--done-soft); outline: 1.5px solid rgba(36, 88, 92, .55); animation: none; color: var(--ink); }
.box img { max-width: 92%; max-height: 88%; object-fit: contain; }
.box.text { justify-content: flex-start; padding: 0 4px; font-weight: 500; color: var(--ink); white-space: nowrap; }
.box.date { cursor: default; animation: none; outline: 1px dashed rgba(36,88,92,.45); background: var(--done-soft); color: var(--muted); font-weight: 500; white-space: nowrap; font-size: clamp(5px, 1.3vw, 10px); }
@keyframes pulse { 50% { outline-color: rgba(194, 106, 18, .35); } }
@media (prefers-reduced-motion: reduce) { .box { animation: none; } }

.todo-list { margin: 14px 0 0; }
.todo-note { font-size: 14px; color: var(--todo); font-weight: 600; margin: 12px 0 0; }
.ok-note { font-size: 14px; color: var(--accent); font-weight: 600; margin: 12px 0 0; }

/* Review */
dl.review { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 6px 14px; margin: 10px 0 16px; font-size: 15px; }
dl.review dt { color: var(--muted); }
dl.review dd { margin: 0; word-break: break-word; }
.ink-preview { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 6px 0 14px; }
.ink-preview img { height: 56px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }

/* Done */
.check { width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 34px; margin: 0 auto 14px; }
.error { color: var(--danger); font-weight: 600; }

/* Bottom actions */
.actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(6px); }
.actions-inner { max-width: 760px; margin: 0 auto; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.btn { font: inherit; font-weight: 600; border-radius: 10px; padding: 13px 18px; border: 1px solid transparent; cursor: pointer; }
.btn.primary { flex: 1; background: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { background: #a9b6b7; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost[hidden] { display: none; }
a.btn { display: inline-block; text-decoration: none; text-align: center; }

.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Top bar tools (same pattern as the SkyCrew document page) ---------- */
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-row .doc { flex: 1; min-width: 0; }
.tools { display: flex; align-items: center; gap: 6px; flex: none; }
.vp { position: relative; display: inline-flex; height: 38px; padding: 3px; background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 999px; }
.vp[hidden] { display: none; }
.vp-ind { position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); background: #fff; border-radius: 999px; box-shadow: 0 1px 3px rgba(0, 0, 0, .16); transition: transform .26s ease; }
.vp[data-active="desktop"] .vp-ind { transform: translateX(100%); }
.vp button { position: relative; z-index: 1; flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 0 11px; border: 0; background: none; font: 700 12.5px system-ui, sans-serif; color: #6b7280; cursor: pointer; border-radius: 999px; }
.vp button.on { color: #111827; }
.vp svg, .iconbtn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 50%; border: 1px solid #e5e7eb; background: rgba(255, 255, 255, .95); color: #1f2937; cursor: pointer; }
.iconbtn:hover { background: #f3f4f6; }
.iconbtn:disabled { opacity: .55; cursor: wait; }
.iconbtn[hidden] { display: none; }
@media (max-width: 430px) {
  .vp button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .vp button { padding: 0 10px; }
}

/* ---------- Type / Draw switch ---------- */
.seg { position: relative; display: flex; max-width: 260px; height: 40px; padding: 3px; margin: 4px 0 16px; background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 999px; }
.seg-ind { position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); background: #fff; border-radius: 999px; box-shadow: 0 1px 3px rgba(0, 0, 0, .16); transition: transform .26s ease; }
.seg[data-active="draw"] .seg-ind { transform: translateX(100%); }
.seg button { position: relative; z-index: 1; flex: 1; border: 0; background: none; font: 700 14px system-ui, sans-serif; color: #6b7280; cursor: pointer; }
.seg button.on { color: #111827; }
.typed { font-family: "Dancing Script", "Segoe Script", "Snell Roundhand", cursive; font-weight: 600; color: var(--pen); background: #fff; border: 1.5px dashed #9aa3ae; border-radius: 10px; padding: 6px 16px; min-height: 64px; display: flex; align-items: center; overflow: hidden; white-space: nowrap; }
.typed.sig { font-size: 42px; }
.typed.ini { font-size: 34px; max-width: 220px; }
input.ok { border-color: #b9bfc8; }

/* ---------- Mobile document view ---------- */
.mdoc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px 8px; font-size: 16px; line-height: 1.55; overflow-wrap: anywhere; }
.mdoc .center { min-height: 30vh; }
.mdoc .mast { border-bottom: 2px solid var(--accent); padding-bottom: 10px; margin-bottom: 12px; }
.mdoc .mast .kicker { font-size: 11px; }
.mdoc .mast h1 { font-family: Georgia, Cambria, serif; font-weight: normal; font-size: 26px; margin: 4px 0 6px; }
.mdoc .mast .addr { color: var(--muted); font-size: 14px; }
.mdoc .lede, .mdoc .small, .mdoc .sub { font-size: 14px; color: var(--muted); }
.mdoc .part { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin: 24px 0 10px; }
.mdoc .part .tag { background: var(--accent); color: #fff; font: 700 11px system-ui, sans-serif; letter-spacing: .12em; text-transform: uppercase; padding: 3px 8px; border-radius: 3px; }
.mdoc .part h2 { font-family: Georgia, Cambria, serif; font-weight: normal; font-size: 21px; margin: 0; }
.mdoc .part .note { width: 100%; font-size: 13px; color: var(--muted); }
.mdoc table.kt, .mdoc table.kt tbody, .mdoc table.kt tr, .mdoc table.kt th, .mdoc table.kt td { display: block; width: auto; text-align: left; }
.mdoc table.kt tr { border-top: 1px solid var(--line); padding: 12px 0; }
.mdoc table.kt th { font-weight: 700; margin-bottom: 4px; }
.mdoc .n { color: var(--accent); margin-right: 6px; font-weight: 700; }
.mdoc .grid2, .mdoc .grid3 { display: block; }
.mdoc .grid2 > div + div, .mdoc .grid3 > div + div { margin-top: 12px; }
.mdoc .lbl { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.mdoc .val { font-weight: 600; }
.mdoc .big { font-weight: 700; font-size: 17px; }
.mdoc .rent { display: grid; grid-template-columns: 1fr auto; gap: 2px 14px; margin: 4px 0 8px; }
.mdoc .rent .total { font-weight: 700; }
.mdoc .rent .total + .total { border-top: 1px solid var(--ink); }
.mdoc ul.checks { list-style: none; padding: 0; margin: 4px 0; columns: 2; column-gap: 16px; }
.mdoc ul.checks li { padding-left: 18px; position: relative; break-inside: avoid; }
.mdoc ul.checks li::before { content: "\2713"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
.mdoc ul.xs { list-style: none; padding: 0; margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.mdoc .cols { column-count: 1 !important; }
.mdoc .std { background: #f2f3f5; border-left: 3px solid #8a929e; border-radius: 6px; padding: 12px; }
.mdoc .std .banner { font-size: 14px; color: var(--muted); margin: 0 0 6px; }
.mdoc .std h3, .mdoc .add h3 { font-size: 16px; margin: 18px 0 4px; }
.mdoc .add h3 { color: var(--accent); }
.mdoc .std p, .mdoc .add p { margin: 0 0 8px; }
.mdoc .std p.i1 { padding-left: 14px; }
.mdoc .std p.i2 { padding-left: 28px; }
.mdoc .std em { color: var(--muted); }
.mdoc ol.alpha { padding-left: 20px; }
.mdoc .mat { font: 700 10px system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: #8a3b2e; border: 1px solid #c99a90; border-radius: 3px; padding: 0 4px; margin-left: 4px; vertical-align: 2px; }
.mdoc .signpair { display: block; }
.mdoc .signbox { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 12px; }
.mdoc .signbox .role { font: 700 12px system-ui, sans-serif; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.mdoc .signrow2, .mdoc .signrow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; margin-top: 8px; }
.mdoc .signrow2 .name, .mdoc .signrow .name { font-weight: 600; border-bottom: 1px solid var(--line); padding-bottom: 2px; }
.mdoc .fill { display: block; margin: 6px 0; }
.mdoc .fl { display: block; font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.mdoc .callout, .mdoc .ack { font-size: 15px; }

.mctl { display: block; }
input.minput { width: 100%; font: inherit; font-size: 16px; padding: 11px 12px; border: 2px solid var(--todo); border-radius: 9px; background: #fffaf3; color: var(--ink); }
input.minput.ok { border: 1px solid #b9bfc8; background: #fff; }
input.minput:focus { outline: 3px solid rgba(36, 88, 92, .25); border-color: var(--accent); }
.mtap { width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: center; border: 2px solid var(--todo); background: var(--todo-soft); border-radius: 10px; font: 700 15px system-ui, sans-serif; color: var(--todo); cursor: pointer; }
.mtap.done { border: 1.5px solid rgba(36, 88, 92, .55); background: var(--done-soft); }
.mtap img { max-height: 46px; max-width: 90%; }
.mtap.initials { max-width: 220px; }
.mdate { display: inline-block; padding: 9px 12px; border: 1px dashed rgba(36, 88, 92, .45); border-radius: 8px; background: var(--done-soft); color: var(--muted); }
.mother { display: block; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 8px; color: #9aa3ae; font-size: 14px; }
.pend { margin: 16px 0; padding: 10px 12px 12px; border-radius: 10px; background: #f7f8fa; border: 1px solid var(--line); }
.pend-line { display: flex; align-items: center; gap: 10px; font: 700 11px system-ui, sans-serif; letter-spacing: .1em; text-transform: uppercase; color: #8a929e; }
.pend-line::before, .pend-line::after { content: ""; flex: 1; border-top: 1px dashed #c9ced6; }
.pend-item { margin-top: 10px; }
.pend-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.pend-li { list-style: none; padding-left: 0 !important; }
.pend-li::before { content: none !important; }
.pend-row td { padding: 0; }
.jump { position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 6; border: 0; border-radius: 999px; padding: 10px 16px; background: var(--todo); color: #fff; font: 700 14px system-ui, sans-serif; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); cursor: pointer; }
.flash { animation: flash 1.2s ease; }
@keyframes flash { 30% { box-shadow: 0 0 0 6px rgba(242, 166, 64, .55); } }
