/*
 * Little Legends OT forms — base styles. Mobile first. Brand colours from the practice website
 * (LittleLegendsWebsite/src/styles/global.css). System fonts only: nothing is loaded from another host.
 * No inline styles anywhere (the CSP forbids them): use these classes.
 */
:root {
  --blue: #05a5d8;
  --blue-dark: #0487b3;
  --blue-deep: #056f92;
  --blue-tint: #ecf8fc;
  --blue-tint-2: #d9f0f9;
  --yellow: #fbed24;
  --red: #d1252a;
  --red-dark: #b01c21;
  --red-tint: #fdeeee;
  --green: #1d7a46;
  --green-tint: #e8f7ee;
  --amber-tint: #fff6e0;
  --amber: #8a5a00;
  --white: #ffffff;
  --black: #111111;
  --text: #2b3238;
  --muted: #5b6670;
  --border: #d5e1e8;
  --radius: 6px;
  --font-body: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Roboto, Arial, sans-serif;
  --font-heading: 'Trebuchet MS', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  --gutter: 18px;
}
@media (min-width: 768px) {
  :root { --gutter: 28px; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background: var(--blue-tint);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; height: auto; }
a { color: var(--blue-deep); }
a:hover { color: var(--blue-dark); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
main:focus { outline: none; }
h1, h2, h3, h4 { font-family: var(--font-heading); line-height: 1.2; color: var(--blue-deep); margin: 1.2em 0 0.5em; }
h1 { font-size: 1.75rem; margin-top: 0; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.12rem; color: var(--red); }
p, ul, ol, dl { margin: 0 0 1em; }
strong { font-weight: 700; }
::selection { background: var(--yellow); color: var(--black); }
@media (min-width: 768px) {
  h1 { font-size: 2.1rem; }
  h2 { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -100px; z-index: 100;
  padding: 10px 16px; border-radius: var(--radius); background: var(--yellow); color: var(--black); font-weight: 700;
}
.skip-link:focus { top: 12px; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; }
.text-right { text-align: right; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.row--between { justify-content: space-between; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: calc(760px + var(--gutter) * 2); margin-inline: auto; padding-inline: var(--gutter); }
.container--narrow { max-width: calc(680px + var(--gutter) * 2); }
.container--wide { max-width: calc(1180px + var(--gutter) * 2); }
.main { flex: 1 0 auto; padding-top: 24px; padding-bottom: 40px; }
@media (min-width: 768px) { .main { padding-top: 36px; } }

.site-header { background: var(--blue-dark); color: var(--white); }
.site-header__inner { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding-block: 10px; }
.site-logo { display: block; width: 120px; height: auto; }
@media (min-width: 768px) { .site-logo { width: 150px; } }
.site-header__home { display: flex; align-items: center; gap: 12px; color: var(--white); text-decoration: none; }
.site-header__app { font-family: var(--font-heading); font-weight: 700; font-size: 1.25rem; color: var(--white); }
.site-header--staff .site-logo { width: 96px; }
.staff-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; }
.staff-nav a {
  display: inline-block; padding: 8px 14px; border-radius: var(--radius);
  color: var(--white); text-decoration: none; font-weight: 600;
}
.staff-nav a:hover { background: rgba(255, 255, 255, 0.14); color: var(--white); }
.staff-nav a[aria-current='page'] { background: var(--white); color: var(--blue-deep); }
.staff-user { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 0.95rem; }
.staff-user__out { margin: 0; }
.site-header :focus-visible { outline-color: var(--yellow); }

.site-footer { flex-shrink: 0; padding: 20px 0 28px; color: var(--muted); font-size: 0.9rem; border-top: 1px solid var(--border); background: var(--white); }
.site-footer p { margin: 0; }

/* ---------- Cards and panels ---------- */
.card {
  background: var(--white); border-radius: var(--radius); box-shadow: 0 0 7px rgba(0, 0, 0, 0.08);
  border-top: 8px solid var(--blue); padding: 22px 18px; margin-bottom: 20px;
}
@media (min-width: 768px) { .card { padding: 30px 32px; } }
.card--plain { border-top: 0; }
.card--red { border-top-color: var(--red); }
.card > :last-child { margin-bottom: 0; }
.panel { background: var(--blue-tint); border: 1px solid var(--blue-tint-2); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 1rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 22px; border-radius: var(--radius); border: 2px solid var(--blue-dark);
  background: var(--blue-dark); color: var(--white); font: inherit; font-weight: 700; line-height: 1.2;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--blue-deep); border-color: var(--blue-deep); color: var(--white); }
.btn[disabled], .btn[aria-disabled='true'] { opacity: 0.6; cursor: default; }
.btn--secondary { background: var(--white); color: var(--blue-deep); }
.btn--secondary:hover { background: var(--blue-tint); color: var(--blue-deep); }
.btn--danger { background: var(--white); color: var(--red-dark); border-color: var(--red); }
.btn--danger:hover { background: var(--red); border-color: var(--red); color: var(--white); }
.btn--ghost { background: transparent; border-color: rgba(255, 255, 255, 0.8); color: var(--white); }
.btn--ghost:hover { background: var(--white); color: var(--blue-deep); border-color: var(--white); }
.btn--small { min-height: 36px; padding: 6px 14px; font-size: 0.9rem; }
.btn--block { width: 100%; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--blue-deep); text-decoration: underline; cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 1.5rem; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 1.1rem; }
.field > label, .field__label, legend { font-weight: 700; color: var(--black); }
.field__hint { font-size: 0.92rem; color: var(--muted); }
.field__error { font-size: 0.95rem; font-weight: 700; color: var(--red-dark); }
.field--error .input, .field--error .select, .field--error .textarea { border-color: var(--red); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--white); color: var(--black); font: inherit; font-size: 16px; line-height: 1.4;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(5, 165, 216, 0.25); }
.input[readonly] { background: var(--blue-tint); }
.textarea { min-height: 110px; resize: vertical; }
fieldset { border: 0; margin: 0 0 1.1rem; padding: 0; min-width: 0; }
.choices { display: grid; gap: 10px; }
.choice { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; line-height: 1.45; }
.choice input { width: 22px; height: 22px; margin: 1px 0 0; flex: 0 0 auto; accent-color: var(--blue-dark); }
.req { color: var(--red); font-weight: 400; }
.error-summary { border: 3px solid var(--red); border-radius: var(--radius); background: var(--red-tint); padding: 14px 18px; margin-bottom: 1.5rem; }
.error-summary h2 { margin-top: 0; color: var(--red-dark); font-size: 1.15rem; }
.error-summary ul { margin: 0; padding-left: 1.2em; }

/* ---------- Signature pad ---------- */
.signature-pad { border: 2px dashed var(--blue); border-radius: var(--radius); background: var(--white); touch-action: none; width: 100%; height: 180px; display: block; }
.signature-preview { max-width: 100%; height: auto; border: 1px solid var(--border); background: var(--white); }

/* ---------- Messages ---------- */
.flash { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 1.25rem; font-weight: 600; }
.flash--ok { background: var(--green-tint); border: 1px solid #9fd8b5; color: var(--green); }
.flash--error { background: var(--red-tint); border: 1px solid #f2b8ba; color: var(--red-dark); }
.notice { background: var(--amber-tint); border: 1px solid #f0d48a; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 1rem; }

/* ---------- Status badges ---------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 100px; font-size: 0.85rem; font-weight: 700; white-space: nowrap; background: var(--blue-tint-2); color: var(--blue-deep); }
.badge--draft { background: #eceff1; color: #455a64; }
.badge--sent, .badge--opened { background: var(--blue-tint-2); color: var(--blue-deep); }
.badge--in_progress { background: var(--amber-tint); color: var(--amber); }
.badge--completed, .badge--signed { background: var(--green-tint); color: var(--green); }
.badge--declined, .badge--bounced { background: var(--red-tint); color: var(--red-dark); }
.badge--cancelled, .badge--expired, .badge--pending { background: #eceff1; color: #455a64; }

/* ---------- Tables, lists, tabs ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--white); font-size: 0.97rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.table tr:hover td { background: #fafdfe; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 1rem; }
.tabs a { display: inline-block; padding: 6px 12px; border-radius: 100px; background: var(--white); border: 1px solid var(--border); text-decoration: none; color: var(--text); font-weight: 600; font-size: 0.92rem; }
.tabs a[aria-current='page'] { background: var(--blue-dark); border-color: var(--blue-dark); color: var(--white); }
.details { display: grid; grid-template-columns: 1fr; gap: 4px 18px; }
.details dt { color: var(--muted); font-size: 0.92rem; }
.details dd { margin: 0 0 0.6rem; overflow-wrap: anywhere; }
@media (min-width: 640px) {
  .details { grid-template-columns: minmax(140px, max-content) 1fr; }
  .details dd { margin: 0; }
}
.timeline { list-style: none; padding: 0; margin: 0; border-left: 3px solid var(--blue-tint-2); }
.timeline li { position: relative; padding: 0 0 14px 18px; }
.timeline li::before { content: ''; position: absolute; left: -8px; top: 0.45em; width: 13px; height: 13px; border-radius: 50%; background: var(--blue); }
.timeline time { display: block; font-size: 0.85rem; color: var(--muted); }

/* ---------- The document itself (signer page) ---------- */
.doc h2 { color: var(--blue-deep); }
.doc p, .doc li { overflow-wrap: break-word; }
.doc ul, .doc ol { padding-left: 1.3em; }
.doc .note { font-size: 0.95rem; color: var(--muted); }

@media print {
  body { background: var(--white); }
  .site-header, .site-footer, .actions, .skip-link, .staff-nav { display: none; }
  .card { box-shadow: none; border: 0; padding: 0; }
}
