:root {
  --orange: #e5740b;
  --orange-600: #c9620a;
  --orange-50: #fff4ea;
  --orange-100: #ffe6cf;
  --ink: #2a2b2a;
  --ink-2: #555755;
  --ink-3: #8a8c8a;
  --line: #e9e6e1;
  --bg: #f7f5f2;
  --card: #ffffff;
  --green: #16a34a;
  --green-50: #e9f8ef;
  --blue: #2563eb;
  --blue-50: #eaf1ff;
  --amber-50: #fff8e6;
  --amber: #b7791f;
  --client: #7c3aed;
  --client-50: #f3edff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(42, 43, 42, .06), 0 8px 24px rgba(42, 43, 42, .06);
  --shadow-lg: 0 20px 60px rgba(42, 43, 42, .18);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--orange-600); }
.boot { display: grid; place-items: center; height: 100vh; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }

/* ------------------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 24px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; letter-spacing: -.01em; }
.brand img { height: 30px; }
.brand small { display: block; font-weight: 500; color: var(--ink-3); font-size: 12px; letter-spacing: 0; }
.topbar .spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 14px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--orange); color: #fff; font-weight: 700; font-size: 13px;
  flex: none;
}
.avatar.client { background: var(--client); }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card);
  font-weight: 600; font-size: 14px; cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s, box-shadow .15s;
  text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: #d6d1ca; background: #fcfbfa; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; box-shadow: 0 4px 14px rgba(229, 116, 11, .3); }
.btn.primary:hover { background: var(--orange-600); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(0, 0, 0, .04); }
.btn.lg { padding: 13px 22px; font-size: 16px; border-radius: 12px; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------------------ login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art {
  background: radial-gradient(1200px 600px at -10% -20%, #ffb46b 0%, transparent 60%), radial-gradient(900px 700px at 120% 120%, #b94f00 0%, transparent 60%), var(--orange);
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.login-art h1 { font-size: 44px; line-height: 1.1; letter-spacing: -.03em; margin: 0 0 16px; max-width: 520px; }
.login-art p { font-size: 18px; opacity: .9; max-width: 460px; margin: 0; }
.login-art .logo-card { background: #fff; border-radius: 16px; padding: 12px 16px; width: max-content; box-shadow: var(--shadow-lg); }
.login-art .logo-card img { height: 44px; display: block; }
.login-art .float { position: absolute; right: -40px; top: 140px; width: 360px; opacity: .95; transform: rotate(-6deg); }
.mini-card { background: #fff; color: var(--ink); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow-lg); margin-bottom: 14px; display: flex; gap: 12px; align-items: center; font-weight: 600; font-size: 14px; }
.mini-card .tick { width: 22px; height: 22px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; font-size: 12px; flex: none; }
.login-form { display: grid; place-items: center; padding: 40px 24px; }
.login-form form { width: 100%; max-width: 380px; }
.login-form h2 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 6px; }
.login-form p.sub { color: var(--ink-2); margin: 0 0 28px; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 13px; color: var(--ink-2); }
.input {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid #ddd8d1; background: #fff;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.input:focus { border-color: var(--orange); box-shadow: 0 0 0 4px rgba(229, 116, 11, .15); }
.pin-input { font-size: 30px; letter-spacing: 14px; text-align: center; font-weight: 700; padding: 12px; }
.error { color: #b42318; font-size: 14px; margin: 8px 0 0; min-height: 20px; }
.devpin { background: var(--amber-50); border: 1px dashed var(--amber); color: var(--amber); padding: 8px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }

/* ------------------------------------------------------------ dashboard */
.page { max-width: 1180px; margin: 0 auto; padding: 32px 24px 80px; }
.hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.hello h1 { font-size: 30px; letter-spacing: -.02em; margin: 0; }
.hello p { margin: 4px 0 0; color: var(--ink-2); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat b { font-size: 28px; letter-spacing: -.02em; display: block; }
.stat span { color: var(--ink-2); font-size: 13px; font-weight: 500; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 220px; }
.search input { padding-left: 38px; }
.search::before { content: '⌕'; position: absolute; left: 13px; top: 50%; transform: translateY(-52%); color: var(--ink-3); font-size: 19px; }
.chips { display: flex; gap: 6px; }
.chip { padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.ob-list { display: grid; gap: 10px; }
.ob-row {
  display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.3fr) 150px 130px 110px; gap: 16px; align-items: center;
  background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  text-decoration: none; color: inherit; border: 1px solid transparent; transition: border-color .15s, transform .15s;
}
.ob-row:hover { border-color: var(--orange-100); transform: translateY(-1px); }
.ob-row .co { font-weight: 700; font-size: 16px; }
.ob-row .muted, .muted { color: var(--ink-3); font-size: 13px; }
.bar { height: 7px; border-radius: 99px; background: #f0ece6; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--orange), #f59e0b); border-radius: inherit; transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.draft { background: #f1efec; color: var(--ink-2); }
.pill.in_progress { background: var(--blue-50); color: var(--blue); }
.pill.complete { background: var(--green-50); color: var(--green); }
.pill.live { background: #e9fbe9; color: var(--green); }
.pill.amended { background: var(--amber-50); color: var(--amber); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(22, 163, 74, .5); animation: ping 1.8s infinite; flex: none; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .5); } 70% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); } }
.empty { text-align: center; padding: 60px 20px; color: var(--ink-2); background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty .big { font-size: 44px; }

/* ------------------------------------------------------------ modal */
.modal-back { position: fixed; inset: 0; background: rgba(30, 28, 25, .45); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 60; padding: 16px; animation: fade .15s; }
.modal { background: #fff; border-radius: 18px; padding: 26px; width: 100%; max-width: 520px; box-shadow: var(--shadow-lg); animation: rise .2s cubic-bezier(.2, .8, .2, 1); max-height: 92vh; overflow: auto; }
.modal h2 { margin: 0 0 4px; letter-spacing: -.02em; }
.modal .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: grid; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500; display: flex; gap: 10px; align-items: center; animation: rise .25s; max-width: 380px; }
.toast.out { animation: fadeout .3s forwards; }
@keyframes fadeout { to { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------ list rows (staff) */
.ob-row { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.5fr) 170px 130px; }
.pill.invited { background: #f1efec; color: var(--ink-2); }
.pill.draft { background: var(--blue-50); color: var(--blue); }
.pill.submitted { background: var(--green-50); color: var(--green); }
.pill.withdrawn { background: #fdecea; color: #b42318; }
.pill.jotform { background: var(--amber-50); color: var(--amber); }
.check { display: flex; gap: 9px; align-items: center; font-size: 14px; font-weight: 500; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--orange); }

/* ------------------------------------------------------------ the client's form */
.form-wrap { max-width: 1080px; margin: 0 auto; padding: 28px 24px 100px; display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 28px; align-items: start; }
.steps { position: sticky; top: 76px; display: grid; gap: 4px; }
.steps .intro { font-size: 13px; color: var(--ink-2); margin: 0 0 12px; }
.step { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 10px; border: 0; background: transparent; text-align: left; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-2); width: 100%; }
.step:hover { background: rgba(0, 0, 0, .04); }
.step.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.step .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: #ebe7e1; color: var(--ink-2); flex: none; }
.step.done .n { background: var(--green); color: #fff; }
.step.on .n { background: var(--orange); color: #fff; }
.savestate { font-size: 13px; color: var(--ink-3); font-weight: 600; min-width: 70px; text-align: right; }
.savestate.err { color: #b42318; }
.sheet { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 30px 32px; }
.sheet > h1 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 4px; }
.sheet > p.blurb { color: var(--ink-2); margin: 0 0 22px; }
.q { padding: 18px 0; border-top: 1px solid var(--line); }
.q:first-of-type { border-top: 0; }
.q-label { font-weight: 700; font-size: 15px; display: block; margin-bottom: 2px; }
.q-label .req { color: var(--orange-600); margin-left: 3px; }
.q-help { color: var(--ink-2); font-size: 13px; margin: 0 0 10px; }
.q-body { margin-top: 10px; }
.q.need .q-label { color: #b42318; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 2fr 70px 110px; gap: 12px; }
.sub { display: grid; gap: 4px; }
.sub > span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.sub .msg { font-size: 12px; color: #b42318; min-height: 0; }
.input.invalid { border-color: #d92d20; box-shadow: 0 0 0 4px rgba(217, 45, 32, .1); }
.input.narrow { max-width: 220px; }
select.input { appearance: auto; }
textarea.input { min-height: 96px; resize: vertical; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 10px; border: 1px solid #ddd8d1; background: #fff; cursor: pointer; font-weight: 600; font-size: 14px; }
.opt:hover { border-color: #c9c3ba; }
.opt input { accent-color: var(--orange); margin: 0; }
.opt:has(input:checked) { border-color: var(--orange); background: var(--orange-50); }
.sames { display: grid; gap: 6px; margin-bottom: 10px; }
.rowline { display: grid; gap: 10px; align-items: end; margin-bottom: 10px; }
.rowline.owner { grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) 110px 36px; }
.rowline.signer { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.2fr) minmax(0, 1.6fr) 36px; }
.x { width: 36px; height: 42px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--ink-3); font-size: 17px; }
.x:hover { color: #b42318; border-color: #f1b5ae; }
.total { font-size: 13px; font-weight: 700; margin: 2px 0 10px; color: var(--green); }
.total.off { color: var(--amber); }
.entity { border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 12px; background: #fcfbfa; }
.entity-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 700; }
.entity .grid2, .entity .grid3 { margin-bottom: 12px; }
.filelist { display: grid; gap: 6px; margin-top: 10px; }
.fileitem { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.fileitem b { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 26px; }
.gaps { display: grid; gap: 6px; margin: 0 0 18px; padding: 0; list-style: none; }
.gaps li { display: flex; justify-content: space-between; gap: 12px; align-items: center; background: var(--amber-50); border-radius: 10px; padding: 9px 12px; font-size: 14px; font-weight: 600; }
.note { background: var(--orange-50); border-radius: 12px; padding: 12px 14px; font-size: 14px; color: var(--ink-2); margin: 0 0 18px; }
.done-wrap { min-height: 80vh; display: grid; place-items: center; padding: 24px; text-align: center; }
.done-card { background: var(--card); border-radius: 22px; box-shadow: var(--shadow); padding: 44px 40px; max-width: 520px; }
.done-card .tickbig { width: 68px; height: 68px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; font-size: 34px; margin: 0 auto 18px; }
.done-card h1 { margin: 0 0 8px; letter-spacing: -.02em; }
.done-card p { color: var(--ink-2); margin: 0; }

/* ------------------------------------------------------------ one form, as staff see it */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 12px; font-size: 16px; letter-spacing: -.01em; }
.kv { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.linkbox { display: flex; gap: 8px; }
.linkbox input { font-size: 13px; }
.hist { display: grid; gap: 10px; font-size: 13px; max-height: 520px; overflow: auto; }
.hist div b { display: block; font-weight: 600; }
.hist .old { color: var(--ink-3); text-decoration: line-through; }
.crumb { font-size: 13px; color: var(--ink-3); text-decoration: none; font-weight: 600; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .form-wrap { grid-template-columns: 1fr; padding: 16px 14px 90px; }
  .steps { position: static; grid-auto-flow: column; overflow-x: auto; }
  .steps .intro { display: none; }
  .step span.t { display: none; }
  .sheet { padding: 22px 18px; }
  .grid2, .rowline.owner, .rowline.signer { grid-template-columns: 1fr; }
  .detail { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .ob-row { grid-template-columns: 1fr; gap: 6px; }
  .stats { grid-template-columns: 1fr 1fr; }
}
