/* ==========================================================================
   Signing PWA styles — tablet-first. Branding lives in the :root variables
   below; swap --brand / --brand-ink / logo to rebrand the whole app.
   ========================================================================== */
:root {
  --brand: #1f6f54;
  --brand-dark: #16543f;
  --brand-ink: #ffffff;
  --accent: #e8a33d;
  --bg: #eef1f4;
  --surface: #ffffff;
  --text: #17202b;
  --muted: #5b6675;
  --line: #d7dce3;
  --danger: #c0392b;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(20, 30, 45, 0.10);
  font-size: 17px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

/* ---- Header ---- */
.app-header {
  background: linear-gradient(120deg, var(--brand), var(--brand-dark));
  color: var(--brand-ink);
  padding: 14px 22px;
  display: flex; align-items: baseline; gap: 12px;
  box-shadow: var(--shadow);
}
.brand { font-size: 1.35rem; font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: .95rem; opacity: .85; }

/* ---- Layout ---- */
.sign-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 18px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 900px) {
  .sign-main { grid-template-columns: 1fr; }
}

/* ---- Document pane ---- */
.doc-pane { position: relative; }
.doc-scroll {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 78vh;
  overflow-y: auto;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
}
.doc-page { width: 100%; height: auto; display: block; margin: 0 auto 10px; border: 1px solid var(--line); }
.doc-hint {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(23,32,43,.82); color: #fff; padding: 6px 14px; border-radius: 999px;
  font-size: .82rem; pointer-events: none;
}

/* ---- Form pane ---- */
.form-pane {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.form-title { margin: 0 0 4px; font-size: 1.4rem; }
.form-intro { margin: 0 0 18px; color: var(--muted); }

.field { margin-bottom: 16px; }
.field-label { display: block; font-weight: 600; margin-bottom: 6px; }
.req { color: var(--danger); }
.field input[type="text"], .field input[type="email"], .field input[type="tel"],
.field input[type="number"], .field input[type="date"], .repeat-input {
  width: 100%; padding: 13px 14px; font-size: 1.05rem;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fbfcfd;
}
.field input:focus, .repeat-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,111,84,.15); }
.field-err { color: var(--danger); font-size: .88rem; margin: 6px 0 0; }

/* repeatable rows (e.g. children) */
.repeat-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.repeat-remove {
  flex: 0 0 auto; width: 44px; height: 44px; border: 1.5px solid var(--line);
  background: #fff; border-radius: 10px; font-size: 1.3rem; color: var(--muted); cursor: pointer;
}
.repeat-add {
  background: none; border: none; color: var(--brand); font-weight: 600; font-size: 1rem;
  padding: 4px 0; cursor: pointer;
}
.repeat-add:disabled { color: var(--muted); cursor: not-allowed; }

/* signature */
.sig-wrap { position: relative; }
.sig-pad {
  width: 100%; height: 190px; background: #fbfcfd;
  border: 1.5px dashed var(--line); border-radius: 10px; touch-action: none; display: block;
}
.sig-clear {
  position: absolute; top: 8px; right: 8px; padding: 6px 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); cursor: pointer;
}

.consent { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0 18px; color: var(--text); }
.consent input { width: 22px; height: 22px; margin-top: 2px; }

.actions { display: flex; }
.btn {
  border: none; border-radius: 10px; font-size: 1.05rem; font-weight: 600; cursor: pointer;
  padding: 13px 22px; transition: transform .05s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-lg { width: 100%; padding: 16px; font-size: 1.15rem; }
.form-error { color: var(--danger); margin-top: 12px; font-weight: 500; }

/* ---- Empty state ---- */
.empty-state { max-width: 640px; margin: 12vh auto; text-align: center; padding: 24px; color: var(--muted); }
.empty-state h1 { color: var(--text); }

/* ---- Done overlay ---- */
.done-overlay {
  position: fixed; inset: 0; background: rgba(16,26,22,.55);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
/* An author display rule beats the UA [hidden] rule, so hidden must be explicit. */
.done-overlay[hidden] { display: none; }
.done-card {
  background: #fff; border-radius: 18px; padding: 34px; text-align: center; max-width: 420px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.done-check {
  width: 74px; height: 74px; border-radius: 50%; background: var(--brand); color: #fff;
  font-size: 2.4rem; line-height: 74px; margin: 0 auto 14px;
}
.done-card h2 { margin: 0 0 8px; }
.done-card p { color: var(--muted); margin: 0 0 22px; }

/* ---- PIN gate ---- */
.pin-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(120deg, var(--brand), var(--brand-dark)); }
.pin-card { background: #fff; padding: 34px; border-radius: 18px; width: 320px; text-align: center; box-shadow: var(--shadow); }
.pin-card h1 { margin: 0 0 6px; font-size: 1.3rem; }
.pin-card p { color: var(--muted); margin: 0 0 16px; }
.pin-input { width: 100%; font-size: 1.6rem; text-align: center; letter-spacing: .4em; padding: 12px; border: 1.5px solid var(--line); border-radius: 10px; margin-bottom: 14px; }
.pin-card .err { color: var(--danger); }
