main:has(#templates-view:not([hidden])){max-width:none}
#templates-view .toolbar{display:flex;flex-wrap:wrap;gap:12px;padding:0;margin:0 0 18px;align-items:center}
#templates-view .toolbar input,#templates-view .toolbar select,#templates-view .toolbar button{height:40px;margin:0;border-radius:8px;font-size:13px}
#templates-view .toolbar button{white-space:nowrap;flex-shrink:0;padding:0 16px}
#templates-view #template-new{display:inline-flex;align-items:center;justify-content:center;gap:7px;line-height:1;font-weight:600;box-shadow:0 2px 4px #147d7715}
#template-notice:empty{display:none}
#templates-view .toolbar{flex-wrap:wrap}#templates-view .toolbar input,#templates-view .toolbar select{width:auto;min-width:0;flex:1 1 140px}#templates-view #template-search{flex:2 1 180px}#templates-view #template-region-filter{flex:1 1 140px}#templates-view #template-school-filter{max-width:250px}
.template-assignment-summary{display:block;margin-top:10px;font-size:12px;line-height:1.6;color:#62757d}
.template-assignment{border:1px solid #dce5e8;border-radius:10px;padding:18px;display:grid;gap:16px}.template-assignment label{display:grid;gap:6px;margin:0}.template-assignment label[hidden]{display:none}.template-assignment select,.template-assignment textarea{width:100%;padding:8px;margin-top:0;border:1px solid #cbd8dc;border-radius:6px;font:inherit}.template-assignment small{font-size:12px;color:#62757d}.template-assignment legend{font-weight:600;padding:0 8px}.template-category-choices{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;margin:10px 0}.template-category-choices label{display:flex;align-items:center;gap:6px;font-weight:400}.template-category-choices input{width:auto;margin:0}
#template-assignment-dialog{width:min(620px,95vw);max-height:90vh;overflow:auto}#template-assignment-dialog h2{font-size:20px}#template-assignment-dialog [role=alert]{color:#b33838}
.template-school-choices,.template-region-choices{display:grid;gap:9px;max-height:180px;overflow:auto;padding:8px;background:#f7fafb;border-radius:8px}.template-school-choices label,.template-region-choices label{display:flex;align-items:center;gap:9px;font-weight:400;cursor:pointer}.template-school-choices input,.template-region-choices input{width:auto;margin:0}.template-school-choices small{display:block;margin-top:3px}.template-region-add{display:flex;gap:8px}.template-region-add button{flex-shrink:0}.template-assignment .template-region-add input{min-width:0}
#template-assignment-dialog .dialog-actions{position:sticky;bottom:-28px;background:white;padding:14px 0;border-top:1px solid #dce5e8;margin-top:10px}#templates-view .template-row-actions .template-assign{background:#147d77;border-color:#147d77;color:white;font-weight:600}
#template-preview-dialog{width:calc(100vw - 32px);max-width:1700px;height:calc(100dvh - 32px);max-height:none;padding:0;border-top:5px solid #32b8c3;overflow:hidden}#template-preview-dialog[open]{display:flex;flex-direction:column}#template-preview-dialog .dialog-head{padding:12px 20px;margin:0;flex-shrink:0}#template-preview-dialog h2{font-size:18px;margin:0}#template-preview-dialog .owner-preview-selection{display:grid;grid-template-columns:1fr 1fr;gap:10px 20px;padding:8px 20px;background:#fff}#template-preview-dialog label{margin:0;font-size:12px}#template-preview-dialog select{padding:8px;margin:4px 0 0}#ownerPreviewStatus{grid-column:1/-1;margin:0;color:#62757d;font-size:12px}#template-preview-dialog .document-viewer-workspace{min-height:0;flex:1}#template-preview-dialog .document-viewer-paper .doc-page p{min-height:1em}#template-preview-dialog .document-viewer-toolbar{flex-shrink:0}#template-preview-dialog .btn{padding:8px 12px;border-radius:7px}
@media(max-width:650px){#template-preview-dialog{width:100vw;height:100dvh}#template-preview-dialog .owner-preview-selection{grid-template-columns:1fr}.template-region-add{flex-wrap:wrap}}
#templates-view #template-count{font-size:12px;margin:0 0 12px}
#templates-view .table-wrap{border-radius:12px;overflow:hidden;background:#fff;box-shadow:0 2px 8px #172b3504}
#templates-view table{table-layout:fixed;white-space:normal}
#templates-view th{padding:13px 18px;text-transform:uppercase;letter-spacing:.7px;font-size:10px;background:#fbfcfd}
#templates-view th:first-child{width:42%}
#templates-view th:nth-child(2){width:19%}
#templates-view th:last-child{text-align:right;width:39%}
#templates-view td{padding:17px 18px;vertical-align:middle;white-space:normal;overflow-wrap:anywhere}
#templates-view tbody tr:hover{background:#fbfdfd}
#templates-view td strong{font-size:14px;line-height:1.5;font-weight:600}
#templates-view td small{font-size:11px;margin-top:5px;color:#87969f}
#templates-view td:last-child{white-space:normal}
.template-name{display:flex;align-items:center;gap:12px}
.template-file-icon{display:grid;place-items:center;flex:none;width:36px;height:42px;border-radius:8px;background:#eff6f7;color:#548b91;border:1px solid #e2edef}
.template-file-icon svg{width:19px;height:19px}
.template-state{display:inline-flex;align-items:center;gap:6px;font-size:11px;line-height:1.4;padding:5px 9px;border-radius:6px;background:#edf7f2;color:#267457;white-space:normal}
.template-state::before{content:'';width:5px;height:5px;background:currentColor;border-radius:50%;flex:none}
.template-state--hidden{background:#f0f3f5;color:#71828c}
.template-state--pending{background:#fff5e7;color:#a07334}
.template-row-actions{display:flex;justify-content:flex-end;gap:6px;flex-wrap:wrap;align-items:center}
#templates-view .template-row-actions button,#templates-view .template-row-actions a{display:inline-flex;align-items:center;justify-content:center;gap:6px;border:1px solid #e0e7eb;border-radius:7px;padding:7px 10px;min-height:32px;font-size:12px;line-height:1.2;white-space:nowrap;background:#fff;color:#526975;text-decoration:none;cursor:pointer;margin:0;transition:background .15s,border-color .15s}
#templates-view .template-row-actions svg{width:14px;height:14px;flex:none}
#templates-view .template-row-actions .template-edit{background:#edf7f5;border-color:#dcece7;color:#147d77;font-weight:600}
#templates-view .template-row-actions button:hover,#templates-view .template-row-actions a:hover{background:#eef4f5;border-color:#c6d8da}
#templates-view .template-row-actions .template-edit:hover{background:#e0f1ec;border-color:#bcd9d0}
#templates-view .template-row-actions--secondary{margin-top:8px}
#templates-view .template-row-actions--secondary button{background:transparent;border-color:transparent;min-height:26px;padding:4px 7px;color:#82929b;font-size:11px}
#templates-view .template-row-actions .template-delete{color:#ba6262}
#templates-view .template-row-actions .template-delete:hover{background:#fff0ef;border-color:#f1d9d7;color:#a94242}
.template-unavailable-reason{font-size:11px;line-height:1.5;color:#8696a0;text-align:right;margin:0 0 8px;white-space:normal}
#templates-view .template-upload-label{font-size:12px;font-weight:400;margin:0;text-align:right;color:#526975}
#templates-view input[type=file]{max-width:100%;font-size:11px;padding:6px;margin:5px 0 0;border-style:dashed}
#templates-view>p:last-child{font-size:12px;margin-top:18px;max-width:900px}
@media(min-width:1700px){#templates-view th:first-child{width:48%}#templates-view th:nth-child(2){width:18%}#templates-view th:last-child{width:34%}}
@media(max-width:1050px){#templates-view .toolbar{grid-template-columns:minmax(140px,1fr) 185px auto}#template-refresh{grid-column:3;grid-row:2}#templates-view th:first-child{width:38%}#templates-view th:nth-child(2){width:21%}#templates-view th:last-child{width:41%}#templates-view td{padding:15px 12px}.template-name{gap:8px}.template-file-icon{width:28px;height:34px}}
@media(max-width:650px){#templates-view .toolbar{grid-template-columns:1fr auto}#template-search{grid-column:1/-1}#template-filter{grid-column:1}#template-new{grid-column:2}#template-refresh{grid-column:2;grid-row:3}#templates-view th:first-child{width:44%}#templates-view th:nth-child(2){width:22%}#templates-view th:last-child{width:34%}#templates-view th,#templates-view td{padding:12px 8px}.template-file-icon{display:none}.template-row-actions{gap:5px}#templates-view .template-row-actions button,#templates-view .template-row-actions a{font-size:11px;padding:6px 7px}}
