/* ─── Client form + live document ─── */
.client {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  background: var(--paper);
}

.client.client-no-fields {
  grid-template-columns: minmax(0, 1fr);
}

.client-form {
  border-inline-end: 1px solid var(--paper-edge);
  display: flex; flex-direction: column;
  background: var(--paper-2);
  min-height: 0;
}
.client-form-hd {
  padding: var(--s-7) var(--s-8) var(--s-5);
  display: flex; flex-direction: column; gap: 6px;
  border-bottom: 1px solid var(--paper-edge);
}
.client-form-hd .from {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: 11.5px;
  color: var(--ink-3);
}
.client-form-hd .from .av {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-display);
}
.client-form-hd h1 {
  margin: 6px 0 2px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.client-form-hd p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
  max-width: 52ch;
  line-height: 1.55;
}

.client-progress {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-8);
  background: var(--paper-2);
  border-bottom: 1px solid var(--paper-edge);
  position: sticky; top: 0;
  z-index: 2;
}
.client-progress .bar {
  flex: 1;
  height: 4px;
  background: var(--paper-3);
  border-radius: 999px;
  overflow: hidden;
}
.client-progress .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .35s cubic-bezier(.3,.7,.4,1);
}
.client-progress .count {
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--ink-3);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.client-form-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-5) var(--s-8) var(--s-9);
  display: flex; flex-direction: column;
  gap: var(--s-5);
}

.cf-section {
  display: flex; flex-direction: column;
  gap: var(--s-2);
}
.cf-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}

.cf-field {
  display: flex; flex-direction: column; gap: 6px;
  padding: var(--s-3);
  border-radius: 10px;
  transition: background .2s;
}
.cf-field[data-active="1"] {
  background: var(--paper);
  box-shadow: var(--shadow-1);
  border: 1px solid var(--paper-edge);
}
.cf-field-lbl {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 12.5px;
  color: var(--ink);
  font-weight: 500;
}
.cf-field-lbl .req { color: var(--accent); }
.cf-field-lbl .id {
  margin-inline-start: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
}
.cf-field-help {
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.5;
}

.cf-input {
  appearance: none;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font-ui);
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.cf-input:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.cf-input::placeholder {
  color: var(--ink-4);
  opacity: 1;
}
.cf-date input::placeholder {
  color: var(--ink-4);
  opacity: 1;
}
.cf-textarea {
  height: auto;
  min-height: 84px;
  padding: 10px 12px;
  resize: vertical;
}

.cf-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='rgba(80,90,110,.6)' d='M0 0h10L5 6z'/></svg>");
  background-repeat: no-repeat;
  background-position: calc(100% - 12px) center;
  padding-inline-end: 32px;
}

/* Date picker */
.cf-date {
  display: flex; align-items: center;
  gap: 0;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  height: 38px;
  padding-inline: 12px 0;
}
.cf-date svg { color: var(--ink-3); margin-inline-end: 8px; }
.cf-date input {
  flex: 1;
  height: 100%;
  border: 0; background: transparent; outline: none;
  font-family: var(--font-mono);
  font-size: 13px;
}

/* File upload */
.cf-upload {
  display: flex; align-items: center; gap: 12px;
  padding: var(--s-3);
  border: 1.5px dashed var(--paper-edge);
  border-radius: 10px;
  background: var(--paper);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.cf-upload:hover {
  border-color: var(--accent-line);
  background: color-mix(in oklab, var(--accent) 4%, var(--paper));
}
.cf-upload .ic {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--paper-3);
  display: grid; place-items: center;
  color: var(--ink-2);
}
.cf-upload .meta {
  display: flex; flex-direction: column; gap: 2px;
}
.cf-upload .meta b {
  font-size: 12.5px;
  font-weight: 500;
}
.cf-upload .meta span {
  font-size: 11px;
  color: var(--ink-3);
}
.cf-upload[data-filled="1"] {
  border-style: solid;
  border-color: var(--ok);
  background: color-mix(in oklab, var(--ok) 6%, var(--paper));
}

/* Signature pad */
.cf-sig {
  position: relative;
  height: 120px;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 10px;
  overflow: hidden;
}
.cf-sig canvas {
  width: 100%; height: 100%;
  display: block;
  cursor: crosshair;
}
.cf-sig .sig-baseline {
  position: absolute;
  inset-inline: 16px;
  bottom: 28px;
  border-bottom: 1px dashed var(--paper-edge);
  pointer-events: none;
}
.cf-sig .sig-x {
  position: absolute;
  inset-inline-start: 14px; bottom: 22px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-4);
  pointer-events: none;
}
.cf-sig .sig-hint {
  position: absolute;
  inset-inline-end: 14px; bottom: 8px;
  font-size: 10.5px;
  color: var(--ink-4);
  font-family: var(--font-mono);
  pointer-events: none;
}
.cf-sig .sig-clear {
  position: absolute;
  top: 8px; inset-inline-end: 8px;
  appearance: none; border: 0;
  height: 22px; padding: 0 8px;
  font-size: 10.5px;
  color: var(--ink-3);
  background: var(--paper-3);
  border-radius: 4px;
  cursor: pointer;
}
.cf-sig .sig-clear:hover { color: var(--ink); background: var(--paper-edge); }

.client-form-foot {
  padding: var(--s-4) var(--s-8);
  background: var(--paper-2);
  border-top: 1px solid var(--paper-edge);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
}
.client-form-foot .trust {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px;
  color: var(--ink-3);
}
.client-form-foot .trust svg { color: var(--ok); }

/* Live document side */
.client-doc {
  display: flex; flex-direction: column;
  background:
    radial-gradient(900px 500px at 50% -200px, color-mix(in oklab, var(--accent) 5%, transparent), transparent 60%),
    var(--paper);
  min-height: 0;
}
.client-doc-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--paper-edge);
  background: var(--paper);
}
.client-doc-hd .ttl {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: 12.5px;
  color: var(--ink-2);
}
.client-doc-hd .ttl b { color: var(--ink); font-weight: 500; }
.client-doc-hd .live {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ok); font-weight: 600;
}
.client-doc-hd .live .pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok);
  position: relative;
}
.client-doc-hd .live .pulse::after {
  content: ""; position: absolute; inset: -3px;
  border-radius: 50%;
  background: var(--ok);
  opacity: 0.4;
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(0.6); opacity: 0.5; }
  100% { transform: scale(1.7); opacity: 0; }
}
.client-doc-hd .right {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: 11px;
  color: var(--ink-3);
}
.client-doc-hd .right .lock {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  background: var(--paper-3);
  border: 1px solid var(--paper-edge);
  border-radius: 999px;
  color: var(--ink-2);
}

.client-doc-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-7) var(--s-5) var(--s-9);
  /* align-items:flex-start stops the flex row from stretching the document
     "page" to the container height — without it the page card is clipped to the
     viewport and its border cuts across the middle of a long document. */
  display: flex; justify-content: center; align-items: flex-start;
}

/* "filled" highlight for the live doc */
.placeholder.filled {
  background: transparent;
  border-bottom: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1em;
  font-style: italic;
  padding: 0 1px;
  font-weight: 500;
  animation: fillIn .35s ease;
}
.placeholder.live-pulse {
  background: var(--field-active);
  box-shadow: 0 0 0 2px var(--accent-line);
  animation: livePulse .8s ease;
}

/* Hover linking — left input ⇄ right document placeholder (neon-yellow) */
:root { --lf-link: #eaff00; --lf-link-soft: rgba(234, 255, 0, .38); --lf-link-edge: #c8dd00; }
.cf-field.lf-linked {
  background: var(--lf-link-soft);
  box-shadow: 0 0 0 1.5px var(--lf-link-edge);
  scroll-margin: 40px;
}
.cf-field.lf-linked .cf-input,
.cf-field.lf-linked .cf-date,
.cf-field.lf-linked .cf-upload {
  border-color: var(--lf-link-edge);
}
.placeholder.lf-linked {
  background: var(--lf-link);
  color: var(--ink);
  border-radius: 4px;
  box-shadow: 0 0 0 2px var(--lf-link), 0 0 0 3px rgba(0, 0, 0, .16);
  scroll-margin: 48px;
}
.placeholder.filled.lf-linked {
  padding: 0 3px;
  background: var(--lf-link);
}
@keyframes fillIn {
  from { background: var(--field-active); transform: translateY(-1px); }
  to   { background: transparent; transform: translateY(0); }
}
@keyframes livePulse {
  0% { background: var(--field-active); }
  100% { background: transparent; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.cf-radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}
.cf-radio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
}
.cf-radio-row input[type="radio"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

/* Field flagged by the firm in a "request changes" reopen */
.cf-field[data-flagged="1"] {
  border-radius: 10px;
  box-shadow: 0 0 0 2px #f59e0b;
  background: #fffbeb;
}
.cf-field-flag {
  display: inline-block;
  margin-inline-start: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #92400e;
  background: #fde68a;
}

/* Required answer still empty after a submit attempt */
.cf-field[data-missing="1"] { box-shadow: 0 0 0 2px #dc2626; background: #fef2f2; }
.cf-field[data-missing="1"] .cf-input,
.cf-field[data-missing="1"] .cf-date,
.cf-field[data-missing="1"] select,
.cf-field[data-missing="1"] textarea { border-color: #dc2626; }
.cf-field-missing { font-size: 12px; font-weight: 600; color: #b91c1c; }

/* Native date picker inside the .cf-date shell: the whole box opens it, our icon stays on the left. */
.cf-date { position: relative; cursor: pointer; }
.cf-date input[type="date"] {
  flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none;
  font: inherit; color: var(--ink); cursor: pointer; padding-inline-end: 12px;
}
.cf-date input[type="date"]:invalid, .cf-date input[type="date"][value=""] { color: var(--ink-4); }
.cf-date input[type="date"]::-webkit-calendar-picker-indicator { opacity: 0; cursor: pointer; }
.cf-date:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Phones: two side-by-side panes leave the document a sliver, so stack them (fields first,
   then the live document) and scroll the whole thing instead of each pane. */
@media (max-width: 820px) {
  .client {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: max-content;
    overflow-y: auto;
  }
  .client-form { border-inline-end: 0; border-bottom: 1px solid var(--paper-edge); }
  .client-form-hd { padding: var(--s-5) var(--s-4) var(--s-4); }
  .client-form-body,
  .client-doc-scroll { flex: none; overflow: visible; }
  .client-form-body { padding: var(--s-4) var(--s-4) var(--s-6); }
  .client-doc-scroll { padding: var(--s-4) var(--s-3); }
}
