.document-template-toolbar,.document-template-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.document-template-toolbar{margin:20px 0}.document-template-toolbar label{display:flex;align-items:center;gap:8px}
.document-template-toolbar input,.document-template-toolbar select,.document-template-row select{padding:10px 12px;border:1px solid var(--line);border-radius:10px;background:var(--paper-soft);color:var(--navy);font-size:14px;max-width:100%}
.document-template-toolbar input[type=search]{flex:1;min-width:180px}.document-template-toolbar input[type=checkbox]{width:auto}
.document-template-row{display:grid;grid-template-columns:minmax(190px,1fr) minmax(200px,1fr);gap:14px 24px;padding:20px 0;border-bottom:1px solid var(--line);align-items:start}
.document-template-meta span,.document-template-row small{font-size:12px;color:var(--muted)}.document-template-row h4{font-size:17px;line-height:1.4;margin:4px 0}
.document-template-row label{display:grid;gap:5px;font-size:13px;min-width:0}.document-template-actions{grid-column:1/-1}
.document-template-actions button,.document-viewer header button,.document-editor header button{padding:9px 13px;border:1px solid var(--line);border-radius:9px;background:var(--paper-soft);color:var(--navy);font-weight:700;cursor:pointer}
.document-template-actions .primary-btn{background:var(--green);color:#fff}.document-template-actions a{text-decoration:none}
#document-template-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-top:18px}#document-template-fields>div{display:grid;gap:4px;font-size:13px;overflow-wrap:anywhere}#document-template-fields code{color:var(--green)}
.document-viewer,.document-editor{inset:0;margin:auto;padding:0;border:1px solid var(--line);border-radius:16px;background:var(--paper);color:var(--navy);box-shadow:0 18px 60px #0005;max-width:96vw;max-height:94dvh}
.document-viewer{width:1200px;height:90dvh}.document-editor{width:800px}.document-viewer::backdrop,.document-editor::backdrop{background:#0008}
.document-viewer[open]{display:flex;flex-direction:column}.document-viewer header{flex:none}.document-template-actions a,.document-viewer header a{display:inline-flex;align-items:center;justify-content:center;align-self:center;padding:9px 13px;min-height:0;min-width:0;border:1px solid var(--line);border-radius:9px;text-decoration:none}
.document-viewer header,.document-editor header{display:flex;gap:12px;align-items:center;padding:16px 22px;border-bottom:1px solid var(--line)}
.document-viewer h2,.document-editor h2{font-size:19px;line-height:1.35;flex:1;margin:0;overflow-wrap:anywhere}
.document-viewer .document-body{flex:1;min-height:0;overflow:auto;background:#e7e9e6}.document-viewer iframe{display:block;width:100%;height:100%;border:0;background:white}.document-viewer img{display:block;max-width:100%;max-height:100%;object-fit:contain;margin:auto}
.document-loading,.document-error{padding:12px 0;line-height:1.5;font-size:14px}.document-viewer .document-loading,.document-viewer .document-error{padding:24px;color:#242a24}.document-error{color:var(--red,#b62635)}
.document-editor .document-body{padding:22px;max-height:calc(94dvh - 78px);overflow:auto}.document-template-form{display:grid;gap:16px}
.document-viewer.has-pdf .document-body{display:flex;flex-direction:column;overflow:hidden;background:#dfe5e0}
.document-viewer.has-pdf>header{min-height:58px;margin:0;padding:10px 14px}
.document-viewer.has-pdf .contract-pdf-toolbar{display:flex;flex-wrap:nowrap;align-items:center;gap:8px;margin:0;padding:6px 12px;min-height:48px;border-bottom:1px solid var(--line);background:var(--paper)}
.document-viewer.has-pdf .contract-pdf-icon{display:inline-flex;align-items:center;justify-content:center;flex:none;width:32px;height:32px;padding:6px;border:1px solid var(--line);border-radius:4px;background:var(--paper);color:var(--ink)}
.document-viewer.has-pdf .contract-pdf-toolbar input,.document-viewer.has-pdf .contract-pdf-toolbar select{height:32px;margin:0;padding:4px;border:1px solid var(--line);border-radius:4px;background:var(--paper);color:var(--ink);font-size:13px;box-sizing:border-box}
.document-viewer.has-pdf .contract-pdf-toolbar input{width:48px;text-align:center}.document-viewer.has-pdf .contract-pdf-toolbar select{width:122px}
.document-viewer.has-pdf .contract-pdf-page img{width:100%;height:auto;max-height:none;max-width:none}
.document-viewer.has-pdf [hidden]{display:none!important}
:root[data-theme=dark] .document-viewer.has-pdf .document-body{background:#151c18}
@media(max-width:540px){.document-viewer.has-pdf .contract-pdf-toolbar{gap:6px;padding:6px}.document-viewer.has-pdf .contract-pdf-toolbar input{width:40px;height:44px}.document-viewer.has-pdf .contract-pdf-toolbar select{width:98px;height:44px}.document-viewer.has-pdf .contract-pdf-icon{width:44px;height:44px}.document-viewer.has-pdf>header button,.document-viewer.has-pdf>header a{min-height:44px}}
.document-template-form label{display:grid;gap:7px;font-size:14px;font-weight:700}.document-template-form input,.document-template-form select,.document-template-form textarea{width:100%;padding:11px;border:1px solid var(--line);border-radius:9px;background:var(--paper-soft);color:var(--navy);font:inherit}
.document-template-form p,.document-template-form small{font-size:13px;line-height:1.5;color:var(--muted)}.document-template-form .document-source{height:360px;font:13px/1.5 monospace;tab-size:2}.document-template-form .document-error{color:var(--red,#b62635)}
@media(max-width:700px){.document-template-row{grid-template-columns:minmax(0,1fr)}#document-template-fields{grid-template-columns:minmax(0,1fr)}.document-viewer header,.document-editor header{padding:12px;flex-wrap:wrap}.document-viewer h2{flex-basis:100%;font-size:16px}.document-viewer .document-body{height:calc(100% - 110px)}.document-template-toolbar>*{max-width:100%}}
