/* PN Sign: Physionorth brand (vault note "Brand and design system").
   Deep teal for buttons/links (accessible), primary teal for rules, text #1F2937, never pure black. */
:root {
  --teal: #2A8C95; --teal-deep: #1F7079; --teal-pale: #E6F4F6; --teal-whisper: #F4FAFB;
  --text: #1F2937; --grey: #6B7280; --border: #D8DEE2; --error: #B3261E; --success: #1E7A46;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 17px; }
body {
  margin: 0; background: var(--teal-whisper); color: var(--text);
  font-family: Calibri, Carlito, "Segoe UI", system-ui, -apple-system, Arial, sans-serif; line-height: 1.5;
}
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1rem; background: #fff; border-bottom: 3px solid var(--teal);
}
.top img { display: block; height: 44px; width: auto; }
.who { display: flex; align-items: center; gap: .75rem; color: var(--grey); }
main { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 1.5rem; }
.narrow { max-width: 440px; margin: 2rem auto; }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; }
.muted { color: var(--grey); }
label { display: block; font-weight: 700; margin: 1rem 0 .3rem; }
input[type=email], input[type=password], input[type=text], textarea, select {
  width: 100%; min-height: 48px; padding: .6rem .75rem; font: inherit; color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; background: #fff;
}
input:focus-visible, button:focus-visible, a:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--teal-deep); outline-offset: 2px;
}
.btn {
  display: inline-block; min-height: 48px; margin-top: 1.25rem; padding: .7rem 1.6rem; border: 0; border-radius: 6px;
  background: var(--teal-deep); color: #fff; font: inherit; font-weight: 700; cursor: pointer;
}
.btn:hover { background: #18606A; }
button.link { background: none; border: 0; padding: .5rem; font: inherit; color: var(--teal-deep); text-decoration: underline; cursor: pointer; min-height: 44px; }
a { color: var(--teal-deep); }
.alert { background: #FDECEA; color: var(--error); border-left: 4px solid var(--error); padding: .75rem 1rem; border-radius: 4px; }
.foot { text-align: center; color: var(--grey); font-size: .85rem; padding: 2rem 1rem; }
@media (max-width: 480px) { .card { padding: 1.1rem; } .top img { height: 36px; } }

/* Task 7: new document form */
h2 { font-size: 1.25rem; margin: 1.75rem 0 .25rem; }
.hint { color: var(--grey); font-size: .9rem; margin: .3rem 0 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.row-between .btn { margin-top: 0; }
.row-gap { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: .75rem; }
textarea { min-height: 80px; resize: vertical; }
input[type=file] { width: 100%; min-height: 48px; padding: .6rem; border: 1px dashed var(--border); border-radius: 6px; background: var(--teal-whisper); font: inherit; }
input[type=number] { width: 100%; min-height: 48px; padding: .6rem .5rem; font: inherit; border: 1px solid var(--border); border-radius: 6px; }
.btn-secondary { min-height: 44px; padding: .5rem 1rem; border: 1px solid var(--teal-deep); border-radius: 6px; background: #fff; color: var(--teal-deep); font: inherit; font-weight: 700; cursor: pointer; }
.btn:disabled { opacity: .6; cursor: progress; }
.recipient { border: 1px solid var(--border); border-left: 4px solid var(--teal); border-radius: 6px; padding: .5rem 1rem 1rem; margin: .75rem 0 0; }
.recipient[data-kind="cc"] { border-left-color: var(--grey); }
.recipient legend { font-weight: 700; padding: 0 .25rem; color: var(--teal-deep); }
.recipient .grid { display: grid; grid-template-columns: 2fr 2.5fr 80px auto; gap: .75rem; align-items: end; }
.recipient label { margin-top: .5rem; font-size: .9rem; }
.r-remove { min-height: 48px; background: none; border: 0; color: var(--error); text-decoration: underline; font: inherit; cursor: pointer; }
@media (max-width: 700px) { .recipient .grid { grid-template-columns: 1fr 80px; } .recipient .grid > div:nth-child(1), .recipient .grid > div:nth-child(2) { grid-column: 1 / -1; } }
.alert div + div { margin-top: .25rem; }
.table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.table th { text-align: left; background: var(--teal); color: #fff; padding: .5rem .75rem; }
.table td { padding: .5rem .75rem; border-bottom: 1px solid var(--border); }
.table tr:nth-child(even) td { background: var(--teal-whisper); }

/* Task 8: field editor */
main:has(.editor) { max-width: 1400px; }
.editor-head { margin-bottom: 1rem; }
.editor-head h1 { margin-bottom: 0; }
label.inline { display: inline; margin: 0; align-self: center; }
.editor-head select { width: auto; }
.editor-head .btn { margin-top: 0; }
.editor { display: grid; grid-template-columns: 260px 1fr; gap: 1rem; align-items: start; }
.palette { position: sticky; top: 1rem; padding: 1rem; }
.palette h2 { font-size: 1rem; margin: .5rem 0 .4rem; }
.palette h2:first-child { margin-top: 0; }
.signer-picker { display: grid; gap: .35rem; }
.signer-chip { display: flex; align-items: center; gap: .5rem; margin: 0; font-weight: 400; padding: .35rem .5rem; border-radius: 6px; border-left: 6px solid var(--c); background: color-mix(in srgb, var(--c) 10%, #fff); cursor: pointer; min-height: 40px; }
.signer-chip input { accent-color: var(--c); width: 18px; height: 18px; }
.palette-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.palette-buttons button { min-height: 44px; border: 1px solid var(--border); border-radius: 6px; background: #fff; font: inherit; cursor: pointer; }
.palette-buttons button:hover { border-color: var(--teal-deep); }
.palette-buttons button.armed { background: var(--teal-deep); color: #fff; border-color: var(--teal-deep); }
#selected-panel label { margin-top: .5rem; }
label.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.btn-secondary.danger { border-color: var(--error); color: var(--error); }
.pages { display: flex; flex-direction: column; align-items: center; gap: .25rem; min-width: 0; }
.page-no { color: var(--grey); font-size: .85rem; margin-top: .75rem; }
.page { position: relative; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.15); max-width: 100%; }
.page canvas { display: block; }
.layer { position: absolute; inset: 0; }
body.placing .layer { cursor: crosshair; outline: 2px dashed var(--teal); }
.field { position: absolute; box-sizing: border-box; border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 22%, transparent); color: var(--text); font-size: 11px; line-height: 1.1; padding: 1px 3px; overflow: hidden; white-space: nowrap; cursor: move; touch-action: none; user-select: none; border-radius: 3px; }
.field span:first-child { pointer-events: none; }
.field.selected, .field:focus-visible { outline: 3px solid var(--c); outline-offset: 1px; z-index: 2; }
.field .handle { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; background: var(--c); cursor: nwse-resize; }
body.previewing .field { cursor: default; }
body.previewing .field .handle { display: none; }
.field.locked { border-style: dashed; border-color: #9CA3AF; background: rgba(156,163,175,.25); color: var(--grey); }
.field.mine { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 35%, transparent); }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } .palette { position: static; } }

/* Task 9: signing page (mobile first) */
#sign-app { padding-bottom: 96px; }
.sign-intro p { margin: .25rem 0 .75rem; }
.note { background: var(--teal-pale); border-left: 4px solid var(--teal); padding: .6rem .9rem; margin: .75rem 0; }
.consent { display: flex; gap: .75rem; align-items: flex-start; font-weight: 700; margin: 1rem 0 0; padding: .75rem; border: 2px solid var(--teal); border-radius: 8px; background: var(--teal-whisper); cursor: pointer; }
.consent input { width: 28px; height: 28px; flex: none; accent-color: var(--teal-deep); margin: 0; }
.sign-pages { margin-top: 1rem; gap: .75rem; }
.sign-pages .page { width: 100%; }
.sfield { position: absolute; box-sizing: border-box; border-radius: 3px; font: inherit; font-size: clamp(10px, 1.6vw, 14px); }
.sfield.other { border: 1px dashed #9CA3AF; background: rgba(156,163,175,.18); pointer-events: none; }
.sfield.own { border: 2px solid #E0A23C; background: rgba(224,162,60,.22); color: var(--text); }
.sfield.own.done { border-color: var(--success); background: rgba(30,122,70,.08); }
.sfield.own.missing { border-color: var(--error); background: rgba(179,38,30,.15); }
.sfield.own.pulse { animation: pulse 1.2s ease-out; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(31,112,121,.7); } 100% { box-shadow: 0 0 0 16px rgba(31,112,121,0); } }
button.sfield { cursor: pointer; font-weight: 700; padding: 0 4px; min-height: 28px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
button.sfield img { max-width: 100%; max-height: 100%; object-fit: contain; }
div.sfield.t-date_signed, div.sfield.t-full_name { display: flex; align-items: center; padding: 0 4px; white-space: nowrap; overflow: hidden; border-style: dotted; }
input.sfield[type=text] { padding: 0 4px; min-height: 24px; }
input.sfield[type=checkbox] { margin: 0; accent-color: var(--teal-deep); min-width: 22px; min-height: 22px; }
.sign-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom)); background: #fff; border-top: 3px solid var(--teal); box-shadow: 0 -2px 8px rgba(0,0,0,.08); }
.sign-bar-buttons { display: flex; gap: .5rem; }
.sign-bar .btn, .sign-bar .btn-secondary { margin: 0; min-height: 48px; }
#progress { color: var(--grey); font-size: .95rem; }
dialog#sig-dialog { width: min(640px, 96vw); border: 0; border-radius: 12px; padding: 1.25rem; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog#sig-dialog::backdrop { background: rgba(31,41,55,.55); }
.sig-form h2 { margin-top: 0; }
.tabs { display: flex; gap: .25rem; margin-bottom: .75rem; border-bottom: 2px solid var(--border); }
.tabs button { min-height: 44px; padding: .4rem 1.2rem; border: 0; background: none; font: inherit; font-weight: 700; color: var(--grey); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs button[aria-selected=true] { color: var(--teal-deep); border-bottom-color: var(--teal-deep); }
#sig-canvas, #type-canvas { display: block; border: 1px solid var(--border); border-radius: 6px; background: #fff; touch-action: none; }
#sig-canvas { background: linear-gradient(to top, transparent 39px, var(--border) 39px, var(--border) 40px, transparent 40px) #fff; }
#type-canvas { margin-top: .5rem; }
.sig-actions { justify-content: flex-end; }
.sig-actions .btn { margin: 0; }
@media (max-width: 480px) { .sign-bar { padding-left: .6rem; padding-right: .6rem; } #progress { font-size: .85rem; } .sign-bar-buttons .btn-secondary { padding: .5rem .7rem; } }

/* Task 10: detail page, decline */
.small { font-size: .85rem; }
.flash { background: #E8F5EE; color: var(--success); border-left: 4px solid var(--success); padding: .75rem 1rem; border-radius: 4px; }
.badge { display: inline-block; padding: .1rem .6rem; border-radius: 999px; font-weight: 700; font-size: .85rem; background: var(--teal-pale); color: var(--teal-deep); }
.badge.st-completed { background: #E8F5EE; color: var(--success); }
.badge.st-declined, .badge.st-voided, .badge.st-expired { background: #FDECEA; color: var(--error); }
.badge.st-draft { background: #F3F4F6; color: var(--grey); }
.signers-table td { vertical-align: top; }
.signers-table .actions { min-width: 150px; }
.actions form { margin: 0; }
.actions details summary { cursor: pointer; color: var(--teal-deep); text-decoration: underline; padding: .5rem; min-height: 44px; }
.inline-form label { margin-top: .25rem; font-size: .85rem; }
.inline-form .btn-secondary { margin-top: .5rem; }
details.void { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
details.void summary { cursor: pointer; color: var(--error); font-weight: 700; min-height: 44px; }
.btn.danger-btn { background: var(--error); }
.decline-link { margin: .75rem 0 0; }
dialog#decline-dialog { width: min(520px, 96vw); border: 0; border-radius: 12px; padding: 1.25rem; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog#decline-dialog::backdrop { background: rgba(31,41,55,.55); }
@media (max-width: 700px) { .signers-table thead { display: none; } .signers-table td { display: block; border: 0; padding: .2rem .5rem; } .signers-table tr { display: block; border-bottom: 1px solid var(--border); padding: .5rem 0; } }

/* Task 12: documents list */
.list-tabs { margin: 1rem 0 .75rem; flex-wrap: wrap; }
.list-tabs a { display: inline-block; padding: .5rem .9rem; color: var(--grey); text-decoration: none; font-weight: 700; border-bottom: 3px solid transparent; margin-bottom: -2px; min-height: 44px; }
.list-tabs a[aria-current=page] { color: var(--teal-deep); border-bottom-color: var(--teal-deep); }
.list-tabs .count { display: inline-block; min-width: 1.6em; padding: 0 .4em; border-radius: 999px; background: #F3F4F6; color: var(--grey); font-size: .8rem; text-align: center; }
.search { display: flex; gap: .5rem; margin-bottom: .5rem; }
.search input { flex: 1; min-height: 44px; padding: .5rem .75rem; font: inherit; border: 1px solid var(--border); border-radius: 6px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.doc-list td a { text-decoration: none; }
.doc-list td a:hover { text-decoration: underline; }
.empty { padding: 2rem 0; text-align: center; }
.mono { font-family: Consolas, "DejaVu Sans Mono", monospace; font-size: .85rem; word-break: break-all; }
.audit-summary { margin-top: 1rem; }
.audit-summary h2 { margin-top: 0; }
.row-between .btn + .btn { margin-left: .5rem; }
@media (max-width: 700px) {
  .doc-list thead { display: none; }
  .doc-list tr { display: block; padding: .6rem 0; border-bottom: 1px solid var(--border); }
  .doc-list td { display: flex; gap: .5rem; border: 0; padding: .15rem .25rem; }
  .doc-list td::before { content: attr(data-label); min-width: 95px; color: var(--grey); font-size: .85rem; }
  .doc-list tr:nth-child(even) td { background: none; }
}
