/* Kwik Forms — shared styles for the public forms and the admin area.
   Palette and shapes come from the Kwik logo: signal red, black, white, square corners. */

@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/archivo-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/archivo-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --red: #ff0000;        /* logo red — blocks and marks only */
  --red-text: #c00000;   /* red that passes contrast as text on white */
  --black: #000000;
  --white: #ffffff;
  --concrete: #e9e9e6;   /* page background, the grey of a cured slab */
  --concrete-dark: #cfcfcb;
  --grey: #55585a;       /* secondary text */
  --tint: #f4f4f2;
  --line: 2px solid var(--black);
  --hair: 1px solid var(--concrete-dark);
  --measure: 40rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--concrete);
  color: var(--black);
  font-family: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; }
h2 { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
a { color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--black); outline-offset: 2px; }
.on-black :focus-visible { outline-color: var(--white); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ───────── Buttons and inputs ───────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 3rem; padding: 0.6rem 1.25rem;
  border: var(--line); border-radius: 0;
  background: var(--white); color: var(--black);
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--tint); }
.btn-primary { background: var(--red); border-color: var(--red); color: var(--white); }
.btn-primary:hover { background: #d90000; border-color: #d90000; }
.btn-dark { background: var(--black); color: var(--white); }
.btn-dark:hover { background: #2a2a2a; }
.btn-small { min-height: 2.5rem; padding: 0.35rem 0.85rem; font-size: 0.9375rem; }
.btn-danger { border-color: var(--red-text); color: var(--red-text); }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn-link {
  border: 0; background: none; padding: 0; min-height: 0;
  font: inherit; font-weight: 600; color: inherit; text-decoration: underline; cursor: pointer;
}

.input, .textarea {
  display: block; width: 100%;
  padding: 0.7rem 0.8rem; min-height: 3rem;
  border: var(--line); border-radius: 0;
  background: var(--white); color: var(--black);
  font: inherit; -webkit-appearance: none; appearance: none;
}
.textarea { min-height: 7.5rem; resize: vertical; line-height: 1.4; }
.input:focus-visible, .textarea:focus-visible { outline-offset: 0; }

.label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
.hint { display: block; color: var(--grey); font-size: 0.9375rem; font-weight: 400; margin-top: 0.1rem; }
.error-text { color: var(--red-text); font-weight: 700; font-size: 0.9375rem; margin-top: 0.4rem; }

/* ───────── Public form ───────── */

.sheet {
  max-width: var(--measure);
  margin: 0 auto;
  background: var(--white);
  min-height: 100vh;
}
@media (min-width: 44rem) {
  .sheet { margin: 2rem auto; min-height: 0; border: var(--line); }
}

.doc-head { border-bottom: 6px solid var(--red); }
.doc-head-logo { padding: 1.1rem 1.25rem 1rem; }
.doc-head-logo img { display: block; height: 2.6rem; width: auto; }
.doc-title {
  display: grid; grid-template-columns: 1fr auto auto;
  border-top: var(--line);
}
.doc-title > div { padding: 0.7rem 1.25rem; }
.doc-title > div + div { border-left: var(--line); padding-left: 0.9rem; padding-right: 0.9rem; }
.doc-title h1 { font-size: 1.6rem; align-self: center; }
.doc-title .cell-label { display: block; font-size: 0.8125rem; color: var(--grey); line-height: 1.2; }
.doc-title .cell-value { display: block; font-weight: 800; white-space: nowrap; }

.sheet-body { padding: 1.4rem 1.25rem 2.5rem; }
.intro { color: var(--grey); margin-bottom: 1.6rem; max-width: 34rem; }

.field { margin-bottom: 1.5rem; position: relative; }
.field.has-error::before {
  content: ''; position: absolute; left: -1.25rem; top: 0; bottom: 0; width: 6px; background: var(--red);
}

.section-head {
  margin: 2.2rem -1.25rem 1.5rem; padding: 0.55rem 1.25rem;
  background: var(--black); color: var(--white);
  font-size: 1rem; font-weight: 700; letter-spacing: 0;
}

fieldset.field { border: 0; padding: 0; min-width: 0; margin-left: 0; margin-right: 0; }
fieldset.field > legend { padding: 0; font-weight: 700; margin-bottom: 0.6rem; display: flex; gap: 0.6rem; }
.q-num {
  flex: none; min-width: 1.6rem; height: 1.6rem; padding: 0 0.3rem;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--black); color: var(--white); font-size: 0.875rem; font-weight: 800;
}
.q-optional, .q-required { font-weight: 400; color: var(--grey); font-size: 0.9375rem; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.options.two { grid-template-columns: 1fr 1fr; max-width: 20rem; }
@media (min-width: 36rem) { .options.four { grid-template-columns: repeat(4, 1fr); } }

.option { position: relative; display: flex; }
.option input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.option span {
  flex: 1; display: flex; align-items: center; gap: 0.6rem;
  min-height: 3.25rem; padding: 0.5rem 0.7rem;
  border: var(--line); background: var(--white);
  font-weight: 600; line-height: 1.15; font-size: 1rem;
}
.option span::before {
  content: ''; flex: none; width: 1.1rem; height: 1.1rem;
  border: var(--line); background: var(--white);
}
.option input:checked + span { background: var(--black); color: var(--white); }
.option input:checked + span::before { background: var(--red); border-color: var(--red); }
.option input:focus-visible + span { outline: 3px solid var(--black); outline-offset: 2px; }
.option:hover span { background: var(--tint); }
.option:hover input:checked + span { background: var(--black); }
.clear-choice { margin-top: 0.5rem; font-size: 0.9375rem; }

/* Signature */
.sig-wrap { position: relative; border: var(--line); background: var(--white); touch-action: none; }
.sig-wrap canvas { display: block; width: 100%; aspect-ratio: 5 / 2; touch-action: none; cursor: crosshair; }
.sig-line {
  position: absolute; left: 6%; right: 6%; bottom: 26%;
  border-bottom: 1px solid var(--concrete-dark); pointer-events: none;
}
.sig-line::before {
  content: '×'; position: absolute; left: 0; bottom: 0.1rem;
  color: var(--concrete-dark); font-size: 1.4rem; line-height: 1;
}
.sig-tools { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-top: 0.45rem; }

.submit-row { margin-top: 2.2rem; }
.submit-row .btn { width: 100%; min-height: 3.5rem; font-size: 1.125rem; }
.form-alert {
  border: var(--line); border-left: 6px solid var(--red);
  padding: 0.8rem 1rem; margin-bottom: 1rem; font-weight: 700;
}
.small-print { color: var(--grey); font-size: 0.875rem; margin-top: 1rem; }

.done { padding: 3rem 1.25rem 4rem; }
.done h1 { font-size: 3.2rem; margin-bottom: 1rem; }
.done .mark { width: 3rem; height: 3rem; background: var(--red); margin-bottom: 1.6rem; }
.done p { max-width: 30rem; margin-bottom: 0.8rem; }
.done .ref { font-weight: 800; }

.state { padding: 3rem 1.25rem; }
.state h1 { margin-bottom: 0.8rem; }
.state p { color: var(--grey); max-width: 30rem; }

/* ───────── Admin ───────── */

.bar {
  background: var(--black); color: var(--white);
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.6rem 1.25rem;
}
.bar .brand { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; font-weight: 800; font-size: 1.25rem; letter-spacing: -0.01em; }
.bar .brand img { width: 2.2rem; height: 2.2rem; display: block; }
.bar nav { margin-left: auto; display: flex; align-items: center; gap: 1.1rem; font-size: 0.9375rem; }
.bar nav a { text-decoration: none; font-weight: 600; }
.bar nav a:hover, .bar nav a[aria-current='page'] { text-decoration: underline; text-underline-offset: 0.3em; text-decoration-thickness: 2px; }
.bar .who { color: #b9b9b9; }
@media (max-width: 40rem) { .bar .who { display: none; } }

.wrap { max-width: 68rem; margin: 0 auto; padding: 1.6rem 1.25rem 4rem; }
.crumb { font-size: 0.9375rem; margin-bottom: 0.9rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.8rem 1.5rem; margin-bottom: 1.4rem; }
.page-head h1 { margin-right: auto; }
.page-head .sub { display: block; font-size: 1rem; font-weight: 600; color: var(--grey); letter-spacing: 0; margin-bottom: 0.35rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.panel { background: var(--white); border: var(--line); }
.panel + .panel { margin-top: 1.25rem; }
.panel-pad { padding: 1.1rem 1.25rem; }

/* Folder list */
.folder {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.4rem 1.1rem;
  padding: 1rem 1.25rem; text-decoration: none; color: inherit;
}
.folder + .folder { border-top: var(--line); }
.folder:hover { background: var(--tint); }
.folder .tab {
  width: 3.4rem; height: 2.6rem; background: var(--red); position: relative; margin-top: 0.4rem;
}
.folder .tab::before {
  content: ''; position: absolute; left: 0; top: -0.4rem; width: 45%; height: 0.4rem; background: var(--red);
}
.folder .name { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
.folder .meta { color: var(--grey); font-size: 0.9375rem; }
.folder .count { text-align: right; font-weight: 800; font-size: 1.5rem; line-height: 1; }
.folder .count small { display: block; font-size: 0.8125rem; font-weight: 400; color: var(--grey); margin-top: 0.25rem; }

/* Share box */
.share { display: grid; gap: 0.9rem; }
.share-row { display: flex; gap: 0.5rem; }
.share-row .input { font-size: 0.9375rem; background: var(--tint); }
.share-grid { display: grid; gap: 0.75rem; grid-template-columns: 1fr; }
@media (min-width: 40rem) { .share-grid { grid-template-columns: 1fr 1fr; } }
details.share-more summary { cursor: pointer; font-weight: 600; text-decoration: underline; width: fit-content; }
details.share-more[open] summary { margin-bottom: 0.9rem; }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; padding: 0.8rem 1.25rem; border-bottom: var(--line); }
.toolbar .input { max-width: 22rem; min-height: 2.5rem; padding: 0.4rem 0.7rem; }
.toolbar .count { margin-left: auto; color: var(--grey); font-size: 0.9375rem; }

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 0.875rem; font-weight: 600; color: var(--grey); padding: 0.6rem 0.9rem; border-bottom: var(--hair); white-space: nowrap; }
table.list td { padding: 0.75rem 0.9rem; border-bottom: var(--hair); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list th:first-child, table.list td:first-child { padding-left: 1.25rem; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: var(--tint); }
table.list td.date { white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
table.list td.ref { white-space: nowrap; color: var(--grey); font-variant-numeric: tabular-nums; }
table.list a { text-decoration: none; }
.tag { display: inline-block; padding: 0.05rem 0.45rem; border: 1px solid var(--black); font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }
.tag-new { background: var(--red); border-color: var(--red); color: var(--white); }

@media (max-width: 44rem) {
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; }
  table.list tr { padding: 0.8rem 1.25rem; border-bottom: var(--hair); }
  table.list tr:last-child { border-bottom: 0; }
  table.list td { padding: 0; border: 0; }
  table.list td:first-child { padding-left: 0; }
  table.list td.project { font-weight: 800; font-size: 1.0625rem; }
  table.list td.ref { margin-top: 0.2rem; }
}

.empty { padding: 2.5rem 1.25rem; }
.empty h2 { margin-bottom: 0.4rem; }
.empty p { color: var(--grey); max-width: 32rem; }

/* Sign-in */
.signin { max-width: 26rem; margin: 0 auto; padding: 2.5rem 1.25rem; }
.signin .logo { display: block; height: 3rem; width: auto; margin-bottom: 2rem; }
.signin h1 { margin-bottom: 0.5rem; }
.signin .lead { color: var(--grey); margin-bottom: 1.6rem; }
.signin .btn { width: 100%; }

/* Completed form as a document */
.document { background: var(--white); border: var(--line); max-width: 52rem; }
.document .doc-head-logo img { height: 2.4rem; }
.doc-meta { display: grid; grid-template-columns: 1fr 1fr; border-bottom: var(--line); }
.doc-meta > div { padding: 0.6rem 1.25rem; border-top: var(--hair); }
.doc-meta > div:nth-child(-n + 2) { border-top: 0; }
.doc-meta > div:nth-child(even) { border-left: var(--hair); }
.doc-meta dt, .kv dt { font-size: 0.8125rem; color: var(--grey); }
.doc-meta dd, .kv dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
dl { margin: 0; }

table.answers { width: 100%; border-collapse: collapse; }
table.answers th, table.answers td { border-bottom: var(--hair); padding: 0.6rem 0.5rem; text-align: center; vertical-align: middle; }
table.answers th { font-size: 0.75rem; font-weight: 600; line-height: 1.15; color: var(--grey); width: 4.6rem; vertical-align: bottom; }
table.answers th.q, table.answers td.q { text-align: left; width: auto; padding-left: 1.25rem; font-size: 1rem; }
table.answers td.q { font-weight: 500; }
table.answers td + td, table.answers th + th { border-left: var(--hair); }
table.answers .tick { display: inline-block; width: 1.1rem; height: 1.1rem; background: var(--red); vertical-align: middle; }
table.answers .na { color: var(--grey); font-size: 0.875rem; }
table.answers tr.sub th { border-top: var(--line); }
table.answers .pick-label { display: none; }

@media screen and (max-width: 40rem) {
  table.answers, table.answers tbody, table.answers tr, table.answers td { display: block; }
  table.answers thead { display: none; }
  table.answers tr { padding: 0.7rem 1.25rem; border-bottom: var(--hair); }
  table.answers td, table.answers td + td { border: 0; padding: 0; text-align: left; }
  table.answers td.q { padding-left: 0; }
  table.answers td:not(.q):not(.picked) { display: none; }
  table.answers td.picked { margin-top: 0.35rem; font-weight: 700; }
  table.answers .pick-label { display: inline; margin-left: 0.5rem; }
  table.answers + table.answers { border-top: var(--line); }
}

.doc-block { padding: 0.9rem 1.25rem; border-top: var(--line); }
.doc-block h2 { font-size: 1rem; margin-bottom: 0.5rem; }
.doc-block .q-text { font-weight: 500; margin-bottom: 0.5rem; }
.doc-block .answer-text { white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 600; }
.doc-block .muted { color: var(--grey); font-weight: 400; }
.signoff { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.5rem; }
.signoff .sig { grid-column: 1 / -1; }
.signoff .sig img { display: block; width: 100%; max-width: 22rem; border-bottom: 1px solid var(--black); }
.internal { background: var(--tint); }
.internal .field { margin-bottom: 1rem; }
.internal .grid2 { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 36rem) { .internal .grid2 { grid-template-columns: 1fr 1fr; } }
.saved-note { color: var(--grey); font-size: 0.9375rem; margin-left: 0.8rem; }
.print-only { display: none; }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--black); color: var(--white); padding: 0.7rem 1.1rem; font-weight: 700;
  border-left: 6px solid var(--red); z-index: 20; max-width: calc(100vw - 2rem);
}

.linkbox { margin-top: 1rem; border: var(--line); border-left: 6px solid var(--red); padding: 0.9rem 1rem; }
.linkbox p { margin-bottom: 0.6rem; }

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in 0.18s ease-out; }
  @keyframes toast-in { from { opacity: 0; transform: translate(-50%, 0.5rem); } }
}

@media print {
  @page { size: A4; margin: 12mm; }
  html { font-size: 12px; }
  body { background: #fff; font-size: 9.5pt; }
  .bar, .crumb, .page-head .actions, .no-print, .toast { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .page-head { display: none; }
  .document { border: 1.5pt solid #000; max-width: none; }
  .internal { background: #fff; }
  .screen-only { display: none !important; }
  .print-only { display: block; }
  .doc-block, table.answers tr { break-inside: avoid; }
  .doc-head-logo { padding: 0.6rem 1rem; }
  .document .doc-head-logo img { height: 1.9rem; }
  .doc-title > div { padding: 0.4rem 1rem; }
  .doc-title h1 { font-size: 1.3rem; }
  .doc-meta > div { padding: 0.35rem 1rem; }
  table.answers th, table.answers td { padding: 0.32rem 0.4rem; }
  table.answers th.q, table.answers td.q { padding-left: 1rem; font-size: inherit; }
  table.answers th { width: 3.9rem; }
  .doc-block { padding: 0.55rem 1rem; }
  .doc-block .q-text, .internal .field { margin-bottom: 0.35rem; }
  .signoff { gap: 0.4rem 1.5rem; }
  .signoff .sig img { max-width: 13rem; }
  .internal .label { margin-bottom: 0.1rem; }
  .internal .answer-text { min-height: 1.4em; }
  .doc-head, .section-head, table.answers .tick, .q-num { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.admins tbody tr, table.list.admins tbody tr { cursor: default; }
table.list.admins tbody tr:hover { background: none; }
