/* Sales documents (contract form, quotation letter, renewal form, treatment card): input sheet + live preview */
.sd-grid { display: grid; grid-template-columns: minmax(0, 480px) minmax(0, 1fr); gap: 16px; align-items: start; }
.sd-form { display: grid; gap: 12px; }
.sd-sec { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 12px 14px 14px; margin: 0; min-width: 0; }
.sd-sec legend { font: 700 13px/1 var(--display); padding: 0 6px; color: var(--ink); }
.sd-sec .muted { margin: 0 0 8px; font-size: 12.5px; }
.sd-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.sd-fields > .sd-f:has(textarea), .sd-fields > .sd-f:has(.sd-chips), .sd-fields > .sd-chips { grid-column: 1 / -1; }
.sd-f { display: grid; gap: 4px; min-width: 0; }
.sd-f input[type=text], .sd-f input[type=number], .sd-f input[type=date], .sd-f textarea, .sd-f select { width: 100%; min-width: 0; padding: 8px 9px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; color: var(--ink); }
.sd-f input[readonly] { background: var(--hover); }
.sd-f textarea { resize: vertical; }
.sd-lab { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.sd-f small { color: var(--muted); font-size: 11.5px; }
.sd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sd-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 13px; cursor: pointer; line-height: 1.2; }
.sd-chip:has(input:checked) { background: var(--navy); border-color: var(--navy); color: #fff; }
.sd-chip input { accent-color: var(--red); margin: 0; }
.sd-chip:has(input:disabled) { cursor: default; opacity: .8; }
.sd-prev { position: sticky; top: 12px; }
.sd-prev-wrap { background: #cfd3da; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
#sd-frame { width: 820px; border: 0; display: block; transform-origin: 0 0; background: #e5e7eb; }
.sd-seg { display: none; }
.sd-tabs { margin-top: 4px; }
.sd-entry .btn-row { gap: 8px; }
.sd-grp { border-top: 1px solid var(--line-2); padding: 8px 0; }
.sd-grp > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.sd-blk { display: grid; gap: 8px; padding: 10px; margin: 6px 0; border: 1px solid var(--line-2); border-radius: 8px; background: var(--hover); }
.sd-blk .f { display: grid; gap: 4px; }
.sd-new { background: #fff; border-style: dashed; }
@media (max-width: 900px) {
  .sd-grid { display: block; }
  .sd-seg { display: flex; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
  .sd-seg button { flex: 1; min-height: 44px; border: 0; background: none; font: 600 14px var(--body); border-right: 1px solid var(--line-2); }
  .sd-seg button:last-child { border-right: 0; }
  .sd-seg button.on { background: var(--navy); color: #fff; }
  .sd-grid[data-view=form] .sd-prev { display: none; }
  .sd-grid[data-view=prev] .sd-form { display: none; }
  .sd-prev { position: static; }
  .sd-fields { grid-template-columns: 1fr; }
  .sd-f input[type=text], .sd-f input[type=number], .sd-f input[type=date], .sd-f textarea, .sd-f select { min-height: 44px; font-size: 16px; }
  .sd-chip { min-height: 40px; }
  .sd-entry .btn-row .btn { flex: 1; min-height: 46px; }
}

/* Contracts: new-contract type picker, sign/lock panel, edit approvals (contracts.js) */
.ctype-pick { display: grid; gap: 8px; }
.ctype { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; background: #fff; }
.ctype:has(input:checked) { border-color: var(--red, #d0202a); box-shadow: 0 0 0 2px rgba(208, 32, 42, .12); }
.f .ctype input { margin-top: 3px; flex: none; width: auto; padding: 0; box-shadow: none; }
.f .ctype span { display: flex; flex-direction: column; line-height: 1.3; margin: 0; font-weight: 400; color: var(--ink-2, #3c4657); text-transform: none; letter-spacing: 0; font-size: 13px; }
.f .ctype span b { font-size: 14.5px; color: var(--ink, #16202f); }
.lock-ic svg { width: 13px; height: 13px; vertical-align: -1px; fill: none; stroke: currentColor; stroke-width: 2; color: var(--muted, #6b7484); }
.ct-panel { padding: 4px 0; }
.ct-line { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line-2, #efebe2); }
.ct-line:first-child { border-top: 0; }
.ct-line > svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; color: var(--muted, #6b7484); }
.ct-line > div:nth-child(2) { flex: 1; min-width: 0; }
.ct-line.good > svg { color: var(--good, #1d7a4b); }
.ct-line.info > svg { color: var(--info, #1e4f9a); }
.ct-line.warn > svg { color: var(--warn, #8a5a00); }
.ct-line .btn-row { flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 700px) { .ct-line { flex-wrap: wrap; } .ct-line .btn-row { width: 100%; justify-content: flex-start; } }
.ap-card { display: flex; gap: 12px; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.ap-main { flex: 1; min-width: 220px; }
.ap-reason { margin-top: 4px; padding: 6px 10px; background: var(--hover, #faf8f3); border-radius: 8px; white-space: pre-wrap; }
.ap-card select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
/* Full-screen signing (A.signBig) and the signature preview in a form */
dialog.sigbig { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #fff; }
dialog.sigbig::backdrop { background: rgba(11, 23, 46, .55); }
.sigbig-in { height: 100%; display: flex; flex-direction: column; max-width: 1100px; margin: 0 auto; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); gap: 10px; }
.sigbig-in header { display: flex; flex-direction: column; gap: 2px; }
.sigbig-in header b { font-size: 1.15rem; }
.sigbig-pad { flex: 1; min-height: 0; }
.sigbig-pad .sigpad-bar { justify-content: flex-start; }
.sigbig-in footer { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sigbig-in footer .btn { min-height: 44px; padding: 0 18px; }
.sig-open { min-height: 64px; width: 100%; border-style: dashed; font-size: 15px; }
.sig-shot { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fff; margin-bottom: 6px; text-align: center; }
.sig-shot img { max-height: 90px; max-width: 100%; }
.ap-diff { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.ap-diff th { text-align: left; font-weight: 600; color: var(--muted, #6b7484); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 4px 6px; }
.ap-diff td { border-top: 1px solid var(--line-2, #efebe2); padding: 5px 6px; vertical-align: top; word-break: break-word; }
tr.ap-new td { background: #fff7e8; }
#sec-cfg .sd-chip { display: flex; margin-bottom: 8px; }
.btn.danger { color: var(--bad, #b3141e); border-color: #f0c4c6; }

/* User manual (manual.js) */
.mn-grid { display: grid; grid-template-columns: 240px 1fr; gap: 16px; align-items: start; }
.mn-toc { position: sticky; top: 12px; padding: 8px; max-height: calc(100vh - 40px); overflow: auto; }
.mn-toc-h { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 6px 8px; }
.mn-toc a { display: block; padding: 6px 8px; border-radius: 6px; text-decoration: none; color: inherit; font-size: 14px; }
.mn-toc a:hover, .mn-toc a.on { background: var(--hover, #faf8f3); }
.mn-toc a.on { font-weight: 600; }
.mn-body { min-width: 0; }
.mn-ch + .mn-ch { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 20px; }
.mn-ch h2 { font-size: 1.3rem; margin: 0 0 4px; scroll-margin-top: 16px; }
.mn-for { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.mn-sec h3 { font-size: 1.02rem; margin: 16px 0 6px; }
.mn-sec p { margin: 0 0 8px; line-height: 1.55; }
.mn-sec ol { margin: 0 0 8px; padding-left: 22px; line-height: 1.55; }
.mn-sec li { margin-bottom: 4px; }
.mn-ui { background: #f1efe8; border-radius: 4px; padding: 0 4px; font-weight: 600; white-space: nowrap; }
.mn-tip { border-left: 3px solid var(--red, #d0202a); background: #fff8f3; padding: 8px 12px; border-radius: 0 8px 8px 0; margin: 8px 0; }
.mn-tip p { margin: 0 0 4px; }
@media (max-width: 900px) { .mn-grid { grid-template-columns: 1fr; } .mn-toc { position: static; max-height: none; display: flex; flex-wrap: wrap; gap: 4px; } .mn-toc-h { width: 100%; } .mn-toc a { background: var(--hover, #faf8f3); font-size: 13px; } .mn-ui { white-space: normal; } }

/* Contracts list filters and the delete dialog */
.qf-filters { align-items: flex-end; }
.qf-filters .f { font-size: 12px; }
.qf-filters .f input, .qf-filters .f select { min-height: 38px; }
.qf-filters .qf-q { flex: 1 1 220px; }
.qf-end { display: flex; align-items: center; gap: 10px; min-height: 38px; margin-left: auto; }
.qf-end [hidden] { display: none; }
.qf-table td:last-child { width: 1%; }
.ct-fallout { background: var(--warn-bg, #fdf3dc); border-radius: 8px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }
.ct-fallout p { margin: 6px 0 2px; }
.ct-fallout ul { margin: 2px 0 4px 18px; padding: 0; }
@media (max-width: 900px) {
  .qf-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .qf-filters .qf-q, .qf-filters .qf-end { grid-column: 1 / -1; }
  .qf-filters .f input, .qf-filters .f select { width: 100%; min-height: 44px; }
  .qf-end { margin-left: 0; justify-content: space-between; }
}
