
:root { color-scheme: light; font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif; color: #17212b; }
* { box-sizing: border-box; }
body { margin: 0; background: #f2f5f8; line-height: 1.65; }
.sitebar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; padding: 12px 18px; background: #18324b; color: #fff; box-shadow: 0 2px 8px #13233433; }
.sitebar a, .sitebar button { display: inline-block; border: 1px solid #ffffff66; border-radius: 6px; padding: 8px 13px; color: #fff; background: transparent; font: inherit; text-decoration: none; cursor: pointer; }
.sitebar .primary { border-color: #fff; color: #18324b; background: #fff; font-weight: 700; }
.sitebar a:hover, .sitebar button:hover { background: #ffffff20; }
.document-header { max-width: 210mm; margin: 22px auto 0; padding: 12px 18mm; background: #fff; border-bottom: 1px solid #d5dde5; color: #18324b; font-size: 10pt; }
.document-header .brand-logo { display: block; width: min(170px, 42vw); height: auto; margin: 0 0 10px; }
.document-content { max-width: 210mm; min-height: 245mm; margin: 0 auto 36px; padding: 14mm 18mm 18mm; background: #fff; box-shadow: 0 4px 20px #13233412; overflow-x: auto; }
.document-content table { max-width: 100%; }
.document-content table.party-information { width: 100%; }
.document-content table.party-information td p,
.document-content table.signature-block td p { font-size: 12px !important; line-height: 1.55; }
.document-content table td p { color: #17212b !important; }
.document-content img { max-width: 100%; height: auto; }
.document-content p { orphans: 3; widows: 3; }
.signature-heading { margin-top: 8mm; font-weight: 700; }
.signature-block { width: 100%; table-layout: fixed; }
.signature-block td { vertical-align: top; }
.signature-block .signature-signature td { height: 24mm; vertical-align: bottom; }
.signature-block .company-seal td { height: 48mm; }
.signature-block .company-seal td::after,
.signature-block .representative-seal td::after { content: ""; display: block; margin: 2mm auto 0; border: 1px dashed #687989; }
.signature-block .company-seal td::after { width: 40mm; height: 40mm; }
.signature-block .representative-seal td { height: 33mm; }
.signature-block .representative-seal td::after { width: 25mm; height: 25mm; }
.directory { max-width: 1100px; margin: 42px auto; padding: 0 22px 48px; }
.directory h1 { margin: 0 0 8px; color: #18324b; font-size: clamp(1.7rem, 4vw, 2.5rem); }
.directory .intro { margin: 0 0 24px; color: #536475; }
.doc-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)); gap: 14px; }
.doc-card { display: flex; flex-direction: column; gap: 12px; min-height: 142px; padding: 18px; border: 1px solid #dce3e9; border-radius: 10px; background: #fff; box-shadow: 0 2px 8px #18324b0a; }
.doc-card h2 { margin: 0; color: #18324b; font-size: 1.05rem; line-height: 1.45; }
.doc-card .code { color: #687989; font-size: .85rem; }
.doc-card .links { display: flex; gap: 14px; margin-top: auto; }
.doc-card a { color: #245b82; font-weight: 650; text-decoration: none; }
.doc-card a:hover { text-decoration: underline; }
.note { margin-top: 24px; padding: 14px 16px; border-left: 4px solid #a1844f; background: #fff; color: #536475; }
@media (max-width: 650px) {
  .document-header { margin-top: 0; padding: 12px 16px; }
  .document-content { margin: 0; padding: 18px 16px 30px; }
  .sitebar { position: static; }
}
@media print {
  @page { size: A4 portrait; margin: 16mm 16mm 17mm; }
  html, body { background: #fff !important; color: #000; }
  .sitebar, .no-print { display: none !important; }
  .document-header { max-width: none; margin: 0 0 7mm; padding: 0 0 3mm; border-bottom: .4pt solid #777; box-shadow: none; }
  .document-content { max-width: none; min-height: 0; margin: 0; padding: 0; overflow: visible; box-shadow: none; }
  .document-content table { max-width: 100%; }
  .document-content tr { break-inside: avoid; page-break-inside: avoid; }
  .directory { max-width: none; margin: 0; padding: 0; }
  .doc-list { display: block; }
  .doc-card { min-height: 0; margin: 0 0 8mm; break-inside: avoid; box-shadow: none; }
  .doc-card a[href]:after { content: none; }
}
/* 填寫與簽署 */
.fill { display: inline-block; min-height: 1.4em; padding: 0 3px; border-bottom: 1px solid #17212b; background: #fff6c8; vertical-align: bottom; outline: none; }
.fill:focus { background: #ffe98a; }
body.editing .document-content, body.editing .document-header { outline: 2px dashed #a1844f; outline-offset: 4px; }
.sitebar .on { background: #a1844f; border-color: #a1844f; }
.fill-status { font-size: .85rem; opacity: .8; }
.signature-block .signature-signature td { height: auto; vertical-align: top; }
.sign-slot { min-height: 22mm; display: flex; align-items: flex-end; border-bottom: 1px solid #17212b; }
.sign-slot img { max-height: 22mm; max-width: 100%; }
.signature-block .company-seal td { height: auto; }
.signature-block .company-seal td::after { content: none; }
.seal-slot { position: relative; height: 52mm; }
.seal-big { position: absolute; left: 50%; top: 4mm; width: 40mm; height: 40mm; transform: translateX(-50%); }
.seal-small { position: absolute; right: 4mm; bottom: 2mm; width: 25mm; height: 25mm; }
.seal-big img, .seal-small img { width: 100%; height: 100%; object-fit: contain; }
.slot-row { display: flex; gap: 8px; }
.slot-btn, .sign-pad button { flex: 1; margin-top: 6px; padding: 8px 10px; border: 1px solid #245b82; border-radius: 6px; background: #fff; color: #245b82; font: inherit; font-size: 14px; cursor: pointer; }
.sign-pad { display: none; position: fixed; inset: 0; z-index: 20; align-items: center; justify-content: center; padding: 16px; background: #0009; }
.sign-pad.show { display: flex; }
.sign-box { width: min(720px, 100%); padding: 16px; border-radius: 10px; background: #fff; }
.sign-box p { margin: 0 0 8px; color: #18324b; font-weight: 700; }
.sign-box canvas { display: block; width: 100%; height: min(320px, 45vh); border: 1px dashed #687989; border-radius: 6px; touch-action: none; background: #fafbfc; }
.sign-pad .ok { background: #18324b; color: #fff; }
@media print {
  .fill { background: none !important; }
  .document-content, .document-header { outline: none !important; }
}
.chk { cursor: pointer; padding: 0 2px; font-size: 1.1em; }
/* 雲端合約與遠端簽署 */
.sitebar .accent { border-color: #e3c27a; background: #a1844f; color: #fff; font-weight: 700; }
.sitebar [hidden], .slot-btn[hidden] { display: none !important; }
.fill.locked { background: none; }
body.readonly .fill, body.sign-mode .fill.locked { background: none; }
body.sign-mode .chk.open { background: #fff6c8; }
.link-box { width: 100%; padding: 10px; border: 1px solid #c9d3dc; border-radius: 6px; font: inherit; font-size: 14px; }
.submit-box { margin: 8mm 0 4mm; padding: 14px; border: 2px solid #a1844f; border-radius: 10px; background: #fffbef; }
.submit-box.warn { border-color: #c0392b; }
.agree { display: flex; gap: 8px; align-items: center; font-weight: 700; color: #18324b; }
.agree input { width: 22px; height: 22px; }
.submit-box .big { width: 100%; margin-top: 12px; padding: 14px; border: 0; border-radius: 8px; background: #18324b; color: #fff; font: inherit; font-size: 17px; font-weight: 700; }
.sign-proof { margin-top: 8mm; padding: 10px 12px; border: 1px solid #b9c6d2; border-radius: 6px; font-size: 11px; line-height: 1.7; color: #36495b; word-break: break-all; }
.sign-error { padding: 40px 0; text-align: center; font-size: 18px; color: #536475; }
.login-box { max-width: 420px; display: grid; gap: 10px; }
.login-box input { padding: 12px; border: 1px solid #c9d3dc; border-radius: 8px; font: inherit; }
.primary-btn { padding: 12px; border: 0; border-radius: 8px; background: #18324b; color: #fff; font: inherit; font-weight: 700; }
.muted { color: #687989; }
.filter-row { display: flex; gap: 8px; margin-bottom: 14px; }
.filter-row button { flex: 1; padding: 9px 4px; border: 1px solid #c9d3dc; border-radius: 8px; background: #fff; font: inherit; font-size: 14px; white-space: nowrap; }
.filter-row .on { border-color: #18324b; background: #18324b; color: #fff; }
.contract-list { display: grid; gap: 10px; }
.contract-row { display: block; padding: 14px 16px; border: 1px solid #dce3e9; border-radius: 10px; background: #fff; color: #17212b; text-decoration: none; }
.contract-row .r1 { display: flex; justify-content: space-between; align-items: center; }
.contract-row .r2 { margin-top: 4px; }
.contract-row .r3 { font-size: 13px; }
.badge { padding: 2px 10px; border-radius: 99px; background: #eef2f5; font-size: 13px; white-space: nowrap; }
.st-sent .badge { background: #fff1cc; color: #8a6100; }
.st-signed .badge { background: #dff3e4; color: #1d6b35; }
@media print { .sign-proof { break-inside: avoid; } }
[hidden] { display: none !important; }
.seal-big { left: 6%; width: min(40mm, 60%); height: auto; aspect-ratio: 1; transform: none; }
.seal-small { width: min(25mm, 36%); height: auto; aspect-ratio: 1; }
