/* OFSI Digital Forms — shop-floor UI. Big targets, high contrast, no decoration. */
:root {
  --paper: #ffffff;
  --floor: #e9ecf0;
  --ink: #17202a;
  --ink-2: #4a5563;
  --rule: #c9ced6;
  --rule-soft: #e3e6eb;
  --steel: #1d5ba6;
  --steel-dark: #154a89;
  --steel-soft: #e8f0fb;
  --amber: #b86e00;
  --amber-soft: #fff4dc;
  --green: #1f8a5b;
  --green-soft: #e4f4ec;
  --red: #c0392b;
  --red-soft: #fdeeec;
  --radius: 4px;
  --tap: 48px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--floor); color: var(--ink);
  font: 17px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--steel); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; background: var(--rule-soft); padding: 1px 4px; border-radius: 3px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--ink-2); }
.small { font-size: .92rem; }
.nowrap { white-space: nowrap; }
.hint { display: block; color: var(--ink-2); font-size: .9rem; font-weight: 400; margin-top: 2px; }
.req { color: var(--red); margin-left: 2px; }
.inline { display: inline; }
button.link { background: none; border: 0; color: var(--steel); font: inherit; padding: 6px 4px; cursor: pointer; text-decoration: underline; min-height: 36px; }

/* top bar */
.topbar { background: var(--ink); color: #fff; }
.topbar-inner { max-width: 960px; margin: 0 auto; padding: 0 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 0 16px; min-height: 56px; }
.brand { color: #fff; text-decoration: none; display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.brand-mark { font-weight: 800; letter-spacing: .5px; font-size: 1.1rem; }
.brand-name { opacity: .85; }
.topnav { display: flex; gap: 4px; margin-left: 8px; }
.topnav a { color: #fff; text-decoration: none; padding: 8px 10px; border-radius: var(--radius); opacity: .8; min-height: var(--tap); display: inline-flex; align-items: center; }
.topnav a.on, .topnav a:hover { opacity: 1; background: rgba(255,255,255,.12); }
.signout { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.signout .who { opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.signout button.link { color: #fff; opacity: .8; }
@media (max-width: 640px) {
  .brand-name { display: none; }
  .topbar-inner { min-height: 0; }
  .brand, .signout { min-height: 48px; }
  .topnav { order: 3; flex-basis: 100%; margin: 0 -16px; padding: 0 8px; border-top: 1px solid rgba(255,255,255,.12); }
  .topnav a { flex: 1; justify-content: center; min-height: 44px; }
  .signout .who { max-width: 120px; }
}

/* page */
.page { max-width: 840px; margin: 0 auto; padding: 20px 16px 120px; }
.page-form { padding-bottom: 140px; }
.flash { padding: 12px 14px; border-radius: var(--radius); margin: 0 0 16px; border: 1px solid; }
.flash-error { background: var(--red-soft); border-color: #efb3ab; color: #7a1f14; }
.flash-ok { background: var(--green-soft); border-color: #a9dcc1; color: #0f4d31; }
.flash-info { background: var(--amber-soft); border-color: #f0d48a; color: #5a3600; }
.flash ul { margin: 6px 0 0; padding-left: 20px; }
.empty { background: var(--paper); border: 1px dashed var(--rule); padding: 32px 20px; text-align: center; border-radius: var(--radius); }

/* login */
.login-body .topbar { display: none; }
.login-card { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 28px 24px; max-width: 420px; margin: 8vh auto 0; }
.login-card h1 { margin-bottom: 4px; }
.login-card label { display: block; font-weight: 600; margin: 16px 0 0; }
.login-card input { margin-top: 6px; }

/* inputs */
input[type=text], input[type=search], input[type=email], input[type=number], input[type=date], input[type=time],
input[type=datetime-local], input[type=password], input[type=tel], select, textarea {
  width: 100%; font: inherit; font-size: 18px; color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--rule); border-radius: var(--radius); padding: 10px 12px; min-height: var(--tap);
}
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='10'%3E%3Cpath d='M1 1l7 7 7-7' fill='none' stroke='%234a5563' stroke-width='2'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible, .seg-opt input:focus-visible + span {
  outline: 3px solid #9cc1f0; outline-offset: 1px; border-color: var(--steel);
}
input.bad, select.bad, textarea.bad, .seg.bad, .checks.bad { border-color: var(--red); }
.field { display: flex; flex-direction: column; margin: 0 0 14px; min-width: 0; }
.field .label, .label { font-weight: 600; margin-bottom: 6px; }
.has-error .label { color: var(--red); }
.err-msg { display: block; color: var(--red); font-size: .92rem; margin-top: 4px; font-weight: 600; }
.readonly { padding: 10px 12px; min-height: var(--tap); background: var(--rule-soft); border-radius: var(--radius); display: flex; align-items: center; }

.seg { display: inline-flex; flex-wrap: wrap; border: 1.5px solid var(--rule); border-radius: var(--radius); overflow: hidden; background: var(--paper); }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-opt span { display: inline-flex; align-items: center; justify-content: center; min-width: 64px; min-height: 44px; padding: 0 16px; cursor: pointer; border-right: 1.5px solid var(--rule); user-select: none; font-weight: 600; color: var(--ink-2); }
.seg-opt:last-child span { border-right: 0; }
.seg-opt input:checked + span { background: var(--steel); color: #fff; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-weight: 500; }
.check input { width: 24px; height: 24px; margin: 0; accent-color: var(--steel); }
.checks { display: flex; flex-direction: column; border: 1.5px solid transparent; border-radius: var(--radius); }
.checks .check { padding: 2px 6px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); padding: 0 18px; border-radius: var(--radius);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; border: 1.5px solid transparent; }
.btn-primary { background: var(--steel); color: #fff; }
.btn-primary:hover { background: var(--steel-dark); }
.btn-secondary { background: var(--paper); color: var(--steel); border-color: var(--steel); }
.btn-secondary:hover { background: var(--steel-soft); }
.btn-lg { font-size: 1.1rem; min-height: 56px; padding: 0 28px; }
.btn-block { width: 100%; margin-top: 20px; }
.btn[disabled] { opacity: .6; cursor: wait; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* home */
.home-head { margin-bottom: 18px; }
.search { font-size: 1.1rem; }
.form-group { margin-bottom: 22px; }
.form-group h2 { color: var(--ink-2); font-size: .95rem; font-weight: 600; margin: 0 0 6px 2px; }
.form-rows { list-style: none; margin: 0; padding: 0; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); }
.form-rows li + li { border-top: 1px solid var(--rule-soft); }
.form-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; min-height: 64px; color: var(--ink); text-decoration: none; }
.form-row:hover { background: var(--steel-soft); }
.form-stamp { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 78px; min-height: 44px; border: 2px solid var(--ink); padding: 3px 6px; line-height: 1.05; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.form-stamp b { font-size: .95rem; letter-spacing: .3px; }
.form-stamp small { font-size: .72rem; color: var(--ink-2); }
.form-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.form-title { font-weight: 600; }
.form-desc { color: var(--ink-2); font-size: .92rem; }
.chev { color: var(--rule); font-size: 1.6rem; }
.recent { margin-top: 30px; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--rule-soft); }

/* status pills */
.status { display: inline-block; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; padding: 3px 8px; border-radius: 3px; white-space: nowrap; }
.status-sent { background: var(--green-soft); color: var(--green); }
.status-queued, .status-sending { background: var(--amber-soft); color: var(--amber); }
.status-failed { background: var(--red-soft); color: var(--red); }
.status-disabled { background: var(--rule-soft); color: var(--ink-2); }

/* the form page */
.qa-form { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 0 0 8px; }
.title-block { display: flex; border-bottom: 2px solid var(--ink); }
.tb-main { flex: 1; padding: 16px 18px; min-width: 0; }
.tb-company { color: var(--ink-2); font-size: .9rem; font-weight: 600; }
.tb-title { margin: 2px 0 0; }
.tb-desc { margin: 6px 0 0; color: var(--ink-2); }
.tb-stamp { display: flex; border-left: 2px solid var(--ink); }
.tb-cell { display: flex; flex-direction: column; justify-content: center; padding: 10px 14px; border-left: 1px solid var(--rule); text-align: center; min-width: 84px; }
.tb-cell:first-child { border-left: 0; }
.tb-cell span { font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-2); }
.tb-cell b { font-size: 1.15rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
@media (max-width: 560px) {
  .title-block { flex-direction: column; }
  .tb-stamp { border-left: 0; border-top: 2px solid var(--ink); }
  .tb-cell { flex: 1; flex-direction: row; justify-content: center; gap: 8px; align-items: baseline; padding: 8px 10px; }
}
.fsection { padding: 18px 18px 6px; border-bottom: 1px solid var(--rule-soft); }
.fsection:last-of-type { border-bottom: 0; }
.fsection h2 { padding-left: 10px; border-left: 4px solid var(--steel); }
.section-help { margin: -6px 0 14px; color: var(--ink-2); }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.fgrid .field-textarea, .fgrid .field-signature, .fgrid .field-photo, .fgrid .field-multiselect, .fgrid .w-full { grid-column: 1 / -1; }
.fgrid .w-half { grid-column: span 1; }
@media (max-width: 640px) { .fgrid { grid-template-columns: 1fr; } }

/* tables as row cards */
.trow { border: 1px solid var(--rule); border-radius: var(--radius); padding: 10px 12px 0; margin-bottom: 12px; background: #fafbfc; }
.trow-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; color: var(--ink-2); font-size: .9rem; }
.trow.fixed { background: var(--paper); border-left: 4px solid var(--rule); padding-top: 8px; }
.trow-label { color: var(--ink); font-size: 1rem; }
.fixed-rows .trow-grid .field { margin-bottom: 8px; }
.trow-grid { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.trow-grid .field { margin-bottom: 10px; }
.trow-grid .label { font-size: .92rem; }
.table-tools { display: flex; align-items: center; gap: 14px; margin: 0 0 14px; }
.pills { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 12px; }
.pill { position: relative; }
.pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1.5px solid var(--rule); border-radius: 20px;
  background: var(--paper); color: var(--ink-2); font-weight: 600; font-size: .95rem; cursor: pointer; user-select: none; }
.pill span::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--rule); margin-right: 8px; }
.pill input:checked + span { background: var(--steel); border-color: var(--steel); color: #fff; }
.pill input:checked + span::before { background: #fff; border-color: #fff; }
.pill input:focus-visible + span { outline: 3px solid #9cc1f0; outline-offset: 1px; }

/* checklist */
.checklist { list-style: none; margin: 0 0 10px; padding: 0; counter-reset: item; }
.check-item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 0; border-bottom: 1px solid var(--rule-soft); counter-increment: item; }
.check-item:last-child { border-bottom: 0; }
.check-label { flex: 1 1 280px; font-weight: 500; }
.check-label::before { content: counter(item) ". "; color: var(--ink-2); }
.check-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.note-wrap input { display: none; width: 260px; min-height: 40px; font-size: 16px; }
.note-wrap.open input { display: block; }
.note-wrap.open .note-toggle { display: none; }
.check-item .err-msg { flex-basis: 100%; }

/* signature + photos */
.sigpad canvas { width: 100%; max-width: 640px; height: auto; aspect-ratio: 3.2 / 1; border: 1.5px dashed var(--rule); border-radius: var(--radius); background: #fff; touch-action: none; display: block; }
.has-error .sigpad canvas { border-color: var(--red); }
.sig-tools { display: flex; justify-content: space-between; align-items: center; max-width: 640px; }
.photos { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-previews { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-previews img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--rule); }

/* sticky submit */
.submit-bar { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.96); border-top: 1px solid var(--rule); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); z-index: 20; }
.submit-inner { max-width: 840px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.submit-note { color: var(--ink-2); font-size: .92rem; }
@media (max-width: 520px) { .submit-note { display: none; } .submit-inner .btn { width: 100%; } }

/* submission view */
.done-banner { display: flex; align-items: center; gap: 16px; background: var(--green-soft); border: 1px solid #a9dcc1; border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.done-check { width: 44px; height: 44px; border-radius: 50%; background: var(--green); color: #fff; font-size: 1.5rem; display: flex; align-items: center; justify-content: center; flex: none; }
.done-banner h1 { margin: 0; font-size: 1.3rem; }
.done-banner p { margin: 2px 0 0; color: var(--ink-2); }
.status-card { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.status-line { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.status-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.doc { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); }
.meta-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border-bottom: 1px solid var(--rule); }
.meta-row > div { padding: 10px 16px; border-right: 1px solid var(--rule-soft); display: flex; flex-direction: column; }
.meta-row > div:last-child { border-right: 0; }
.meta-row span { font-size: .75rem; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-2); }
.dsection { padding: 16px 18px 6px; border-bottom: 1px solid var(--rule-soft); }
.dsection:last-child { border-bottom: 0; }
.dsection h2 { padding-left: 10px; border-left: 4px solid var(--steel); }
.dgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.dfield { display: flex; flex-direction: column; padding: 6px 0 10px; border-bottom: 1px dotted var(--rule-soft); min-width: 0; }
.dfield.wide { grid-column: 1 / -1; }
.dlabel { font-size: .82rem; color: var(--ink-2); }
.dvalue { font-weight: 500; word-wrap: break-word; }
.dvalue.pre { white-space: pre-wrap; }
.dvalue.small { font-size: .9rem; font-weight: 400; color: var(--ink-2); }
.sig-img { max-width: 320px; width: 100%; border-bottom: 1px solid var(--ink); margin: 6px 0; }
.photo-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.photo-grid img { max-width: 260px; width: 100%; border: 1px solid var(--rule); border-radius: var(--radius); }
@media (max-width: 640px) { .dgrid { grid-template-columns: 1fr; } }

/* data tables */
.dtable, .list-table, .kv { width: 100%; border-collapse: collapse; font-size: .95rem; }
.dtable th, .dtable td, .list-table th, .list-table td { padding: 8px 8px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule-soft); }
.dtable th { border-bottom: 2px solid var(--ink); font-size: .85rem; }
.dtable .num { text-align: right; }
.dtable tfoot td { border-top: 2px solid var(--ink); border-bottom: 0; }
.dchecklist .res { white-space: nowrap; font-weight: 700; width: 90px; }
.res-no, .res-fail, .res-reject { color: var(--red); }
.res-yes, .res-pass, .res-ok, .res-accept { color: var(--green); }
.dtable { margin-bottom: 12px; }
.list-table { background: var(--paper); border: 1px solid var(--rule); }
.list-table th { background: var(--rule-soft); font-size: .85rem; }
.list-table tr.inactive { color: var(--ink-2); }
.kv th { text-align: left; padding: 6px 12px 6px 0; width: 220px; color: var(--ink-2); font-weight: 600; vertical-align: top; }
.kv td { padding: 6px 0; }
@media (max-width: 640px) {
  .list-table thead { display: none; }
  .list-table tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--rule); }
  .list-table td { display: inline-block; border: 0; padding: 2px 8px 2px 0; }
  .dtable { display: block; overflow-x: auto; }
}

/* lists & admin */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters input[type=search] { flex: 1 1 200px; width: auto; }
.filters select { width: auto; min-width: 160px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.subnav { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--rule); }
.subnav a { text-decoration: none; padding: 10px 12px; color: var(--ink-2); border-bottom: 3px solid transparent; font-weight: 600; min-height: var(--tap); display: inline-flex; align-items: center; }
.subnav a.on { color: var(--ink); border-bottom-color: var(--steel); }
.narrow { max-width: 520px; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px; }
.info-box { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 18px; margin: 16px 0; }
.info-box h2 { font-size: 1.05rem; }
.info-box p { margin: 6px 0; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.two-col .info-box { margin: 0; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form input { flex: 1 1 200px; width: auto; }

@media (prefers-reduced-motion: no-preference) {
  .form-row, .btn, .seg-opt span { transition: background-color .12s ease; }
}
