:root {
  --bg: #f6f7f9; --card: #fff; --text: #1d2330; --muted: #5d6675; --line: #dde1e7;
  --accent: #1f5fbf; --accent-soft: #e6eefb; --danger: #b3261e; --ok: #1e7a3c;
  --chip: #e8f0fe; --chip-text: #174ea6; --loop: #fdf1dc; --loop-text: #8a5300; --warn: #8a5300;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; padding-bottom: var(--footer-height); font: 14px/1.5 system-ui, sans-serif; background: var(--bg); color: var(--text); }

/* Footer bar with the copyright, bottom right on every page */
.site-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; height: var(--footer-height);
  display: flex; justify-content: flex-end; align-items: center; padding: 0 16px;
  background: var(--card); border-top: 1px solid var(--line); color: var(--muted); font-size: 12px;
}
h1 { font-size: 17px; margin: 0; }
h2 { font-size: 14px; margin: 0; }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
input { width: 100%; padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
button, .button { display: inline-block; text-decoration: none; padding: 6px 12px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; font: inherit; cursor: pointer; white-space: nowrap; }
button.secondary, .button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
button:disabled { opacity: .5; cursor: default; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); white-space: pre-wrap; }
.success { color: var(--ok); }
.row { display: flex; gap: 8px; align-items: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 20px; }
#login { max-width: 360px; margin: 80px auto; }
#login button { margin-top: 12px; }
.mfa-qr { display: block; margin: 8px auto; image-rendering: pixelated; }
.mfa-secret { font-family: ui-monospace, monospace; font-size: 13px; word-break: break-all; }
.recovery-codes { columns: 2; font-family: ui-monospace, monospace; padding-left: 1.6em; }

/* Fixed heights, so the editor layout fits exactly between the top bar and the footer. */
:root { --topbar-height: 56px; --footer-height: 28px; }
.topbar { display: flex; justify-content: space-between; align-items: center; height: var(--topbar-height); padding: 0 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr) 340px; height: calc(100vh - var(--topbar-height) - var(--footer-height)); }
.panel { background: var(--card); border-right: 1px solid var(--line); padding: 12px; overflow-y: auto; }
.catalog-panel { border-right: 0; border-left: 1px solid var(--line); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; min-height: 30px; }

.template-list { list-style: none; padding: 0; margin: 0; }
.template-list li { padding: 6px 8px; border-radius: 6px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.template-list li:hover { background: var(--bg); }
.template-list li.active { background: var(--accent-soft); }

.editor-panel { padding: 16px 24px; overflow-y: auto; }
.empty { margin-top: 40px; text-align: center; }
.editor-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.name-input { font-size: 17px; font-weight: 600; border-color: transparent; background: transparent; }
.name-input:hover, .name-input:focus { border-color: var(--line); background: var(--card); }
#toolbar { background: var(--card); border-radius: 6px 6px 0 0; }
#editor { background: var(--card); min-height: 420px; border-radius: 0 0 6px 6px; font-size: 14px; }
#editor .ql-editor { min-height: 420px; font-family: Calibri, Arial, sans-serif; font-size: 11pt; }

/* Dutch labels for the paragraph style picker (Quill sets these in its own CSS) */
.ql-snow .ql-picker.ql-header .ql-picker-label::before,
.ql-snow .ql-picker.ql-header .ql-picker-item::before { content: "Normaal"; }
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="1"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="1"]::before { content: "Kop 1"; }
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="2"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before { content: "Kop 2"; }
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="3"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before { content: "Kop 3"; }

/* Placeholders and repeat blocks in the editor */
.ql-editor .ph > span, .ql-editor .loop > span, .ql-editor .cond > span, .ql-editor .blk > span { user-select: none; cursor: default; }
.ql-editor .blk > span { display: inline-block; background: #e3f3ef; color: #0b6e5f; border: 1px solid #b9e0d7; border-radius: 4px; padding: 1px 8px; font-size: .85em; font-weight: 600; }
.ql-editor .cond > span { display: inline-block; background: #f1eafa; color: #5f2d99; border-radius: 4px; padding: 1px 8px; font-size: .85em; font-weight: 600; }
.ql-editor .ph > span { background: var(--chip); color: var(--chip-text); border-radius: 4px; padding: 0 4px; font-family: ui-monospace, monospace; font-size: .9em; }
.ql-editor .loop > span { display: inline-block; background: var(--loop); color: var(--loop-text); border-radius: 4px; padding: 1px 8px; font-size: .85em; font-weight: 600; }

/* Sections drawn beside the text: a named bar in the left margin plus a light tint */
#editor.show-sections .ql-editor { padding-left: 64px; }
#section-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.section-tint { position: absolute; right: 0; border-radius: 4px; }
.section-tint.section { background: rgba(208, 0, 0, .035); }
.section-tint.repeat { background: rgba(230, 140, 0, .07); }
.section-bar { position: absolute; width: 3px; border-radius: 2px; }
.section-bar.section { background: #d00000; }
.section-bar.repeat { background: #d98200; }
.section-tint.condition { background: rgba(123, 63, 191, .06); }
.section-bar.condition { background: #7b3fbf; }
.section-bar.condition span { color: #7b3fbf; }
.section-bar span {
  position: absolute; left: 5px; top: 0; writing-mode: vertical-rl; transform: rotate(180deg);
  font-size: 10px; font-weight: 600; line-height: 1; white-space: nowrap; max-height: 100%; overflow: hidden; text-overflow: ellipsis;
}
.section-bar.short span { max-height: 90px; }
.section-bar.section span { color: #d00000; }
.section-bar.repeat span { color: #a86400; }

.code-preview { margin-top: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; }
.code-preview summary { cursor: pointer; font-weight: 600; }
.code-preview pre { white-space: pre-wrap; font-size: 12px; margin: 8px 0 0; max-height: 360px; overflow-y: auto; }
.code-section { color: #d00000; }
.code-placeholder { color: var(--chip-text); }
.code-dropdown { background: #e3f3ef; color: #0b6e5f; border-radius: 3px; }
.code-dropdown::before { content: "▾ "; }
.check { display: flex; align-items: center; gap: 4px; margin: 0; color: var(--muted); font-size: 13px; white-space: nowrap; cursor: pointer; }
.check input { width: auto; margin: 0; }
.badge { background: var(--loop); color: var(--warn); border-radius: 10px; padding: 0 8px; font-size: 12px; margin-left: 6px; }
.warnings { margin: 8px 0 0; padding-left: 18px; color: var(--warn); }
#export-result p { margin: 8px 0 0; }

/* Catalog */
.hint { margin: 6px 0 10px; }
#catalog details { border-bottom: 1px solid var(--line); }
#catalog details details { margin-left: 12px; border-bottom: 0; }
#catalog summary { cursor: pointer; padding: 6px 0; font-weight: 600; }
#catalog summary .kind { font-weight: 400; color: var(--loop-text); font-size: 12px; margin-left: 4px; }
.field { display: block; width: 100%; text-align: left; background: transparent; color: var(--text); padding: 4px 6px; border-radius: 4px; white-space: normal; }
.field:hover { background: var(--accent-soft); }
.field code { color: var(--chip-text); font-size: 12px; }
.field span { display: block; color: var(--muted); font-size: 12px; }
.insert-loop { background: var(--loop); color: var(--loop-text); font-size: 12px; padding: 3px 8px; }
.insert-condition { background: #f1eafa; color: #5f2d99; font-size: 12px; padding: 3px 8px; }
.insert-block { background: #e3f3ef; color: #0b6e5f; font-size: 12px; padding: 3px 8px; }
#catalog summary .blk-kind { color: #0b6e5f; }
#catalog .blocks-group > summary { color: #0b6e5f; }
.block-buttons { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 6px; }
.field-row { display: flex; align-items: flex-start; gap: 2px; }
.field-row .field { flex: 1; min-width: 0; }
.field-if { background: transparent; color: #5f2d99; font-size: 12px; padding: 4px 6px; opacity: 0; }
.field-row:hover .field-if, .field-if:focus { opacity: 1; }
.field-if:hover { background: #f1eafa; }
.condition-preview, #condition-field { display: block; background: var(--bg); border-radius: 4px; padding: 4px 8px; font-size: 13px; }
.condition-preview { color: #d00000; }
#condition-dialog select { width: 100%; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .panel { border: 0; border-bottom: 1px solid var(--line); max-height: 50vh; }
}

/* Choice within a sentence (from an old Word dropdown) */
.ql-editor .choice-chip > span { user-select: none; cursor: default; background: #f1eafa; color: #5f2d99; border: 1px dashed #b89ae0; border-radius: 4px; padding: 0 4px; }

/* Import wizard */
dialog.wizard { width: min(960px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; display: flex; flex-direction: column; }
dialog.wizard:not([open]) { display: none; }
.wizard-head { padding: 16px 20px 0; border-bottom: 1px solid var(--line); }
.wizard-steps { display: flex; gap: 4px; list-style: none; padding: 0; margin: 10px 0 0; counter-reset: step; flex-wrap: wrap; }
.wizard-steps li { counter-increment: step; padding: 6px 12px; color: var(--muted); border-bottom: 3px solid transparent; font-size: 13px; }
.wizard-steps li::before { content: counter(step) ". "; }
.wizard-steps li.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.wizard-steps li.done { color: var(--ok); }
.wizard-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.wizard-body h3 { font-size: 14px; margin: 18px 0 6px; }
.wizard-foot { display: flex; gap: 8px; align-items: center; padding: 12px 20px; border-top: 1px solid var(--line); }
#wizard-error { margin: 0 20px; white-space: pre-wrap; }
.wizard-row { border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 6px; padding: 10px 12px; margin-bottom: 10px; }
.wizard-row.checked { border-left-color: var(--ok); }
.wizard-row.invalid { border-left-color: var(--danger); background: #fff7f6; }
.wizard-row-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.wizard-row-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.wizard-row-controls select, .wizard-row-controls input:not([type]) { width: auto; min-width: 260px; flex: 1; }
.wizard-row .check { margin: 0; color: var(--text); font-size: 13px; }
.old-tag { color: #8a5300; font-size: 13px; }
.context { margin-top: 4px; font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.choice-options { margin-top: 4px; font-weight: 600; color: #5f2d99; }
.choice-details { margin-top: 6px; }
.choice-table { margin-top: 8px; }
/* .cat-table.choice-table: more specific than the catalog editor's .cat-table rules further down */
.cat-table.choice-table td:first-child { width: 40%; font-size: 13px; }
.cat-table.choice-table td:nth-child(2) { width: 35%; }
.cat-table.choice-table td:last-child { width: 25%; text-align: left; }
.cat-table.choice-table select, .cat-table.choice-table input { width: 100%; border-color: var(--line); }
/* Two buttons (Importeren, Nieuw) in the narrow template panel */
.templates-panel .panel-head { flex-wrap: wrap; gap: 6px; }
.templates-panel .panel-head .row { gap: 4px; }
.templates-panel .panel-head button { padding: 4px 10px; font-size: 13px; }
.badge-status { border-radius: 10px; padding: 0 8px; font-size: 12px; font-weight: 600; }
.badge-status.ok { background: #e3f4e8; color: var(--ok); }
.badge-status.suggest { background: var(--accent-soft); color: var(--accent); }
.badge-status.weak { background: #fff1d6; color: #8a5300; }
.badge-status.none { background: #fdecea; color: var(--danger); }
.wizard-comments li { margin-bottom: 6px; }
.recognized { background: #e3f4e8; border: 1px solid #bfe3ca; border-radius: 6px; padding: 10px 12px; margin-bottom: 12px; }
.recognized-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
.recognized-tags code { background: var(--card); border-radius: 4px; padding: 0 6px; font-size: 12px; color: var(--chip-text); }

/* Admin: tabs */
.tabs { display: flex; gap: 4px; }
.tab { background: transparent; color: var(--muted); border-radius: 6px; }
.tab:hover { background: var(--bg); }
.tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Admin: catalog editor */
.catalog-editor { padding: 16px 24px; }
.catalog-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.catalog-toolbar input[type="search"] { max-width: 320px; }
.scope-label { margin: 0; white-space: nowrap; }
#cat-scope { min-width: 220px; font-weight: 600; }
#cat-scope-info button { margin-left: 4px; }
.notice { background: #fff8e6; border: 1px solid #f3dfae; color: #6b4e00; border-radius: 6px; padding: 8px 12px; margin: 0 0 8px; font-size: 13px; }
#cat-message { min-height: 1.5em; margin: 0 0 8px; white-space: pre-wrap; }
.catalog-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.cat-tree { border: 1px solid var(--line); border-radius: 8px; max-height: calc(100vh - 220px); position: sticky; top: 8px; }
.tree-item { display: flex; align-items: center; gap: 4px; width: 100%; text-align: left; background: transparent; color: var(--text); padding: 4px 8px; border-radius: 4px; white-space: nowrap; overflow: hidden; }
.tree-item:hover { background: var(--bg); }
.tree-item.active { background: var(--accent-soft); color: var(--accent); }
.tree-item.blocks { color: #0b6e5f; font-weight: 600; margin-bottom: 6px; }
.tree-item .kind { color: var(--loop-text); font-size: 11px; }
.tree-item .count { margin-left: auto; color: var(--muted); font-size: 11px; }
.add-group { margin-top: 8px; }
.cat-detail { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px 20px; }
.cat-detail h3 { font-size: 14px; margin: 18px 0 6px; }
.breadcrumb { margin: 0 0 8px; }
.group-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.group-settings .check { grid-column: 1 / -1; font-size: 14px; color: var(--text); }
.group-settings label { margin-top: 4px; }
.cat-table { width: 100%; border-collapse: collapse; }
.cat-table th { text-align: left; font-size: 12px; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.cat-table td { padding: 3px 4px; border-bottom: 1px solid var(--line); }
.cat-table td:first-child { width: 34%; }
.cat-table td:last-child { width: 36px; text-align: center; }
.cat-table input { border-color: transparent; padding: 5px 6px; }
.cat-table input:hover, .cat-table input:focus { border-color: var(--line); }
.cat-table tr.match { background: #fff8e6; }
.mono { font-family: ui-monospace, monospace; font-size: 13px; color: var(--chip-text); }
.icon-button { background: transparent; color: var(--muted); padding: 2px 8px; }
.icon-button:hover { background: #fdecea; color: var(--danger); }
.cat-detail > .secondary.small { margin-top: 8px; }
.subgroups { margin: 0 0 8px; padding-left: 18px; }
.danger-zone { margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--line); }
@media (max-width: 900px) { .catalog-layout, .group-settings { grid-template-columns: 1fr; } .cat-tree { position: static; } }

/* Admin panel */
.narrow { max-width: 420px; margin: 80px auto; }
.tag { background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 1px 8px; font-size: 12px; font-weight: 600; }
.admin-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - var(--topbar-height) - var(--footer-height)); }
.admin-main { padding: 20px 24px; }
.admin-head { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.spacer { flex: 1; }
h2.big { font-size: 18px; }
.template-list li .count { float: right; color: var(--muted); font-size: 12px; }
#message { min-height: 1.5em; margin: 0 0 8px; }
.backup-view { max-width: 860px; }
.backup-view .card { margin-bottom: 20px; }
.backup-view .card h2 { margin-bottom: 4px; }
.backup-view .card > p.muted { margin: 0 0 12px; }
.backup-view form { max-width: 480px; }
.backup-view #restore-summary { margin: 8px 0 0; }
#backup-message { min-height: 1.5em; margin: 0 0 8px; }
.mappings-view { max-width: 1100px; }
.mappings-view .card { margin-bottom: 20px; }
.mappings-view .card h2 { margin-bottom: 8px; }
.mappings-view .card > p.muted { margin: 0 0 12px; }
#map-message { min-height: 1.5em; margin: 0 0 8px; }
.mappings-view .admin-head, .map-toolbar { flex-wrap: wrap; }
.mappings-view .map-prefixes { padding: 12px 16px; margin-bottom: 12px; }
.map-prefixes label { margin-top: 0; }
.map-prefixes .row input { max-width: 320px; }
.map-prefixes p.muted { margin: 6px 0 0; }
.map-toolbar input[type="search"] { flex: 1; min-width: 12em; }
.map-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.map-summary button { background: var(--card); color: var(--text); border: 1px solid var(--line); font-size: 13px; padding: 4px 10px; }
.map-summary button.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.map-summary button strong { margin-right: 4px; }
.map-summary button.problem strong { color: var(--danger); }
table.mappings td.wrap { white-space: normal; min-width: 14em; }
table.mappings code { font-size: 13px; }
table.mappings ul.changes { margin: 4px 0 0; padding-left: 1.2em; }
table.mappings ul.changes:first-child { margin: 0; }
table.mappings tr.problem td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
table.mappings .problem-text { display: block; color: var(--danger); font-size: 12px; white-space: normal; }
.mapping-dialog { width: min(560px, calc(100vw - 32px)); }
.mapping-dialog select { width: 100%; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
table.users { width: 100%; border-collapse: collapse; }
table.users th, table.users td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.users th { font-size: 12px; color: var(--muted); font-weight: 600; }
table.users tr:last-child td { border-bottom: 0; }
table.users tr.disabled td { color: var(--muted); }
table.users td.actions { text-align: right; }
table.users td.actions button { margin-left: 4px; }
table.audit td.warn { color: var(--danger); font-weight: 600; }
table.audit td.wrap { white-space: normal; min-width: 16em; }
table.audit td.wrap summary { cursor: pointer; }
table.audit td.wrap ul { margin: 4px 0 0; padding-left: 1.2em; }
table.audit td.wrap ul.changes:first-child { margin: 0; padding-left: 0; list-style: none; }
.status { border-radius: 10px; padding: 1px 8px; font-size: 12px; font-weight: 600; }
.status.on { background: #e3f4e8; color: var(--ok); }
.status.off { background: #f1f1f1; color: var(--muted); }
button.small, select.small { padding: 3px 8px; font-size: 13px; }
select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: var(--card); }
button.link { background: none; color: var(--accent); padding: 0; text-decoration: underline; }
#templates-section { margin-top: 20px; }
.admin-templates { list-style: none; padding: 0; margin: 0; }
.admin-templates li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.admin-templates li:last-child { border-bottom: 0; }
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 20px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(20, 25, 35, .35); }
dialog h2 { margin-bottom: 8px; }
dialog select { width: 100%; }
.row.end { justify-content: flex-end; margin-top: 16px; }
@media (max-width: 800px) { .admin-layout { grid-template-columns: 1fr; } }

/* Template list: search, sort, trash */
.template-list li .date { display: block; color: var(--muted); font-size: 11px; }
.empty .row { justify-content: center; margin-top: 8px; }

/* Editor head: the name keeps room; the buttons move to a line of their own when it gets narrow */
.editor-head { flex-wrap: wrap; }
.editor-head .name-input { flex: 1 1 240px; min-width: 0; }
.editor-actions { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }

/* Dialogs with a header row: title left, close button right */
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-head h2 { margin: 0; }
dialog.wide { width: min(1000px, calc(100vw - 32px)); }

/* Versions: list left, read-only preview right */
.versions-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 16px; height: min(560px, calc(100vh - 220px)); }
.versions-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; border-right: 1px solid var(--line); }
.versions-list li { padding: 6px 8px; border-radius: 6px; cursor: pointer; margin-right: 8px; }
.versions-list li:hover { background: var(--bg); }
.versions-list li.active { background: var(--accent-soft); }
.versions-list li .muted { display: block; font-size: 12px; }
.versions-preview { display: flex; flex-direction: column; min-height: 0; }
.versions-preview .row.end { margin-top: 8px; }
#version-editor { flex: 1; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
#version-editor .ql-editor { font-family: Calibri, Arial, sans-serif; font-size: 11pt; }
#version-editor.ql-container.ql-snow { border: 1px solid var(--line); }

/* Trash */
.trash-list { list-style: none; margin: 12px 0 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.trash-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.trash-list li:last-child { border-bottom: 0; }
.trash-list li span { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 700px) { .versions-layout { grid-template-columns: 1fr; height: auto; } .versions-list { max-height: 160px; border-right: 0; } }

/* Catalog editor: where placeholders and building blocks are used */
.warn-notice { background: #fdecea; border-color: #f2c4bf; color: var(--danger); }
.warn-notice summary { cursor: pointer; }
.cat-table td.usage-cell { width: 190px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.usage summary { cursor: pointer; color: var(--accent); list-style-position: inside; }
.usage ul, .impact-list ul { margin: 4px 0 0; padding-left: 1.2em; font-size: 12px; color: var(--text); white-space: normal; }
.usage-line { margin: 0 0 12px; font-size: 13px; }
dialog.impact-dialog { width: min(640px, calc(100vw - 32px)); }
.impact-list { max-height: 45vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; }
.impact-list > div + div { margin-top: 8px; }
.impact-list code { font-weight: 600; }

/* Toolbar: text buttons (table, page break) next to Quill's icon buttons */
#toolbar button.tool-text { width: auto; padding: 3px 6px; font-size: 12px; color: #444; white-space: nowrap; }
#toolbar button.tool-text:hover { color: var(--accent); }
#toolbar button.danger-text { color: var(--danger); }
#toolbar .table-tools { background: var(--accent-soft); border-radius: 4px; }
/* Read-only (under review or approved): no editing tools */
#editor-area.readonly #toolbar { opacity: .45; pointer-events: none; }
#editor-area.readonly #editor .ql-editor { background: #fafbfc; }

/* Tables and page breaks in the editor */
#editor .ql-editor td, #version-editor .ql-editor td { border: 1px solid #b8c0cc; padding: 3px 6px; vertical-align: top; }
.ql-editor .pb > span { display: block; text-align: center; color: var(--muted); border-top: 2px dashed var(--line); padding-top: 2px; font-size: .8em; user-select: none; }

/* Status */
.status-badge { border-radius: 10px; padding: 1px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-concept { background: #eef0f3; color: var(--muted); }
.st-review { background: #fff1d6; color: #8a5300; }
.st-approved { background: #e3f4e8; color: var(--ok); }
.status-dot.st-review { background: #e0a030; }
.status-dot.st-approved { background: var(--ok); }
.status-banner { background: #fff8e6; border: 1px solid #f3dfae; color: #6b4e00; border-radius: 6px; padding: 8px 12px; margin-bottom: 8px; font-size: 13px; }


/* Notes */
.badge-muted { color: var(--muted); font-weight: 400; font-size: 12px; }
.notes-list { list-style: none; margin: 8px 0; padding: 0; max-height: 280px; overflow-y: auto; }
.notes-list li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.notes-list li:last-child { border-bottom: 0; }
.notes-list p { margin: 2px 0 0; white-space: pre-wrap; }
.note-head { color: var(--muted); font-size: 12px; }
.note-status { font-weight: 600; color: #5f2d99; font-size: 12px; }
.note-form { display: flex; gap: 8px; align-items: flex-end; }
textarea { width: 100%; padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; resize: vertical; }

/* Rules in the condition dialog */
dialog.rules-dialog { width: min(620px, calc(100vw - 32px)); }
.rules { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.rule { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.rule select, .rule input { width: 100%; }

/* Text fragments in the right panel */
#catalog .fragments-group > summary { color: #7a4b00; }
#catalog summary .frag-kind { color: #7a4b00; }
#catalog .fragments-group .field strong { font-weight: 600; font-size: 13px; }
#catalog .fragments-group .field-if { color: #7a4b00; }
/* Nothing to insert into a read-only template */
#catalog.readonly { opacity: .5; pointer-events: none; }
/* Version of an approved template */
.version-tag { margin-left: 6px; color: var(--ok); font-size: 11px; font-weight: 600; }
.versions-list li.approved-version strong { color: var(--ok); font-size: 12px; }

/* Left panel: header, review queue, the list (the only part that scrolls), and a footer
   with search, sort and the actions on all templates. */
.templates-panel { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.templates-panel .panel-head { padding: 12px 12px 0; }
.templates-panel .panel-head h2 { display: flex; align-items: center; gap: 6px; }
.count-pill { background: var(--bg); color: var(--muted); border-radius: 10px; padding: 0 7px; font-size: 11px; font-weight: 600; }
.count-pill:empty { display: none; }
.count-pill.warm { background: #fff1d6; color: #8a5300; }

.reviews-section { margin: 4px 12px 8px; padding: 8px; background: #fffaf0; border: 1px solid #f3dfae; border-radius: 8px; }
.reviews-section h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: #8a5300; }
.reviews-section .template-list li:hover { background: #fff1d6; }

.template-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 8px 8px; }
.template-list li { padding: 6px 8px; }
.tpl-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tpl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.template-list li .date { padding-left: 14px; }
.status-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.status-dot.st-concept { background: #c9ced6; }
.empty-list { padding: 8px; text-align: center; }

.panel-foot { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line); background: #fafbfc; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 8px; top: 50%; width: 14px; height: 14px; margin-top: -7px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; pointer-events: none; }
.search-box input { padding: 6px 8px 6px 28px; font-size: 13px; background: var(--card); }
.segmented { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 2px; }
.segmented label { flex: 1; margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: 3px 4px; border-radius: 4px; font-size: 12px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.segmented input:checked + span { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(20, 25, 35, .12); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }
.foot-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.foot-actions button { display: flex; align-items: center; justify-content: center; gap: 5px; padding: 5px 6px; font-size: 12px; background: var(--card); }
.foot-actions button:hover { border-color: var(--accent); }
.foot-actions svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
/* Short tip above the editor, e.g. which repeat block was added */
.editor-notice { background: var(--accent-soft); border: 1px solid #c9d9f5; color: #1b4a8f; border-radius: 6px; padding: 6px 12px; margin-bottom: 8px; font-size: 13px; }
