:root {
  color-scheme: light;
  font-family: Tahoma, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  --ink: #182f53;
  --muted: #4b5f7c;
  --edge: #8da4c5;
  --edge-dark: #5c7ca8;
  --shell: #e8effa;
  --control: #f5f2e6;
  --paper: #fff;
  --pale-blue: #edf4ff;
  --selected: #d7e7ff;
  --blue: #2458b1;
  --green: #316e26;
  --red: #8b2c30;
  --title-gradient: linear-gradient(180deg, #5290ec 0, #2867cf 21%, #1748ad 80%, #2867cc 100%);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; padding: clamp(8px, 3vw, 44px); background: #dce8f7; color: var(--ink); overflow-wrap: anywhere; }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button, input:not([type=file]), select, textarea { min-height: 36px; }
button { border: 1px solid var(--edge-dark); border-radius: 4px; background: linear-gradient(#fffefa, #e9e4d6); padding: .32rem .7rem; box-shadow: inset 0 0 0 1px #fff8; cursor: pointer; }
button:not(:disabled):hover { background: linear-gradient(#fff, #e4edfc); border-color: var(--blue); }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: linear-gradient(#51894c, #306329); border-color: #2b5825; color: #fff; box-shadow: inset 0 0 0 1px #ffffff36; }
button.primary:not(:disabled):hover { background: linear-gradient(#5b9754, #34712d); border-color: #2b5825; }
button.danger { color: var(--red); }
button.danger:not(:disabled):hover { background: #fff0ed; border-color: #a76d6c; }
:is(button, input, select, textarea, a, .table-wrap):focus-visible { outline: 2px solid #0f54b7; outline-offset: 2px; }
input:not([type=file]), select, textarea { background: var(--paper); border: 1px solid var(--edge-dark); border-radius: 3px; padding: .42rem .55rem; width: 100%; }
textarea { resize: vertical; }
a { color: #154e9f; }

.shell { max-width: 1360px; margin-inline: auto; min-width: 0; border: 1px solid #376dc3; border-radius: 8px 8px 4px 4px; background: var(--shell); box-shadow: 0 12px 32px #30508328; }
.window-title { min-height: 48px; padding: .4rem .75rem; display: flex; align-items: center; gap: .6rem; color: white; background: var(--title-gradient); border-radius: 7px 7px 0 0; }
.window-title h1 { font-size: clamp(1.05rem, 2.7vw, 1.35rem); line-height: 1.35; font-weight: 700; }
.app-icon { display: grid; flex: 0 0 auto; place-items: center; width: 26px; height: 26px; color: #fff; border-radius: 5px; background: linear-gradient(#4ca3a4, #156279); border: 1px solid #d0eef9; }
.role-label { margin-inline-start: auto; background: #0b3c97; color: #fff; border: 1px solid #88aef2; border-radius: 3px; padding: .15rem .4rem; font-size: .78rem; }
.menu-bar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .35rem .75rem; min-height: 43px; background: var(--control); border-block-end: 1px solid var(--edge); }
.menu-bar span { font-size: .9rem; }
.connection-notice { background: var(--paper); border: 1px solid var(--edge); margin: .8rem; padding: 1rem; display: grid; gap: .55rem; justify-items: start; }
.connection-notice h2 { font-size: 1.2rem; }
.workspace { display: grid; grid-template-columns: minmax(180px, 240px) minmax(0, 1fr); gap: .75rem; padding: .75rem; align-items: start; }
.page-sidebar, .editor, .empty-workspace { min-width: 0; background: var(--paper); border: 1px solid var(--edge); }
.page-sidebar { background: var(--control); }
.panel-heading { padding: .5rem .65rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; border-block-end: 1px solid var(--edge); background: linear-gradient(#f9fcff, #dce8fb); }
.panel-heading h2 { font-size: 1.04rem; }
.panel-heading output { font-size: .8rem; color: var(--muted); }
.page-list { display: grid; gap: .35rem; padding: .5rem; }
.page-list:empty { padding: 0; }
.page-choice { display: grid; gap: .15rem; min-width: 0; text-align: start; }
.page-choice[aria-current=true] { background: var(--selected); border-color: var(--blue); }
.page-choice small { color: var(--muted); }
.sidebar-action { display: block; width: calc(100% - 1rem); margin: .5rem; }
.empty-workspace { min-height: 245px; display: grid; align-content: center; justify-items: center; padding: 1rem; text-align: center; gap: .45rem; }
.empty-workspace h2 { font-size: 1.2rem; }
.empty-workspace p, .muted { color: var(--muted); }
.empty-icon { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--edge); border-radius: 5px; background: var(--selected); font-size: 1.4rem; }

.state-badge { border: 1px solid #adbddd; background: #e9effa; border-radius: 3px; padding: .1rem .48rem; font-size: .8rem; }
.state-badge[data-status=enabled] { border-color: #8bb082; background: #e9f7e7; color: #235921; }
.state-badge[data-status=disabled] { border-color: #c5aa76; background: #fff4d8; color: #6f4b16; }
.page-information { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(230px, 1fr); align-items: start; gap: .85rem; padding: .75rem; }
.page-title-fields { display: grid; gap: .4rem; min-width: 0; }
.page-title-fields .muted { font-size: .82rem; }
.field { display: grid; gap: .25rem; min-width: 0; }
.field input { min-width: 0; }
.qr-panel { display: flex; align-items: center; gap: .55rem; min-width: 0; background: var(--pale-blue); border: 1px solid var(--edge); padding: .45rem; }
.qr-panel canvas { display: block; flex: 0 0 auto; width: 86px; height: 86px; border: 1px solid #b4c7dd; background: white; }
.qr-copy { min-width: 0; display: grid; align-items: start; gap: .2rem; }
.qr-copy a { text-align: right; font-family: "Segoe UI", Arial, sans-serif; font-size: .78rem; overflow-wrap: anywhere; }
.qr-copy button { font-size: .82rem; }
.button-row { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; }
.inline-warning { display: grid; gap: .4rem; margin: 0 .75rem .75rem; background: #fff4dc; color: #674817; border: 1px solid #c9a765; padding: .55rem; }
.editor-fields { min-inline-size: 0; display: grid; border: 0; padding: 0; margin: 0; }
.editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; background: var(--control); border-block: 1px solid var(--edge); padding: .45rem .75rem; }
.editor-toolbar-spacer { flex: 1; }
.editor-blocks { min-height: 175px; padding: .75rem; background: #f4f7fb; display: grid; gap: .65rem; align-content: start; }
.editor-placeholder { margin: .15rem 0; border: 1px dashed var(--edge); background: var(--paper); padding: .85rem; color: var(--muted); }
.block { min-width: 0; background: var(--paper); border: 1px solid var(--edge); padding: .45rem; display: grid; gap: .4rem; }
.block-header { display: flex; align-items: center; gap: .4rem; justify-content: space-between; }
.block-header .button-row { justify-content: end; }
.block-header :is(button, select) { min-height: 30px; padding: .2rem .42rem; font-size: .83rem; }
.block-header select { width: auto; }
.block-header strong { font-size: .85rem; }
.table-commands button { font-size: .84rem; min-height: 31px; }
.table-wrap { max-width: 100%; overflow: auto; border: 1px solid var(--edge); }
.table-wrap table { width: 100%; border-collapse: collapse; text-align: start; }
.table-wrap th, .table-wrap td { border-inline-end: 1px solid #a8b8d0; border-block-end: 1px solid #a8b8d0; padding: .38rem .46rem; text-align: start; vertical-align: top; min-width: 100px; white-space: pre-wrap; overflow-wrap: anywhere; }
.table-wrap :is(th, td):last-child { border-inline-end: 0; }
.table-wrap tbody tr:last-child td { border-block-end: 0; }
.table-wrap th { background: #dce8fa; }
.table-wrap tbody tr:nth-child(even) { background: #f3f7fd; }
.edit-table :is(th, td) { min-width: 110px; padding: .2rem; }
.edit-table textarea, .edit-table input:not([type=file]) { border-color: #a9b9d3; border-radius: 2px; padding: .25rem .32rem; }
.edit-table textarea { display: block; min-height: 34px; }
.table-editor { display: grid; gap: .35rem; min-width: 0; }
.column-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem; align-items: stretch; }
.column-controls button, .row-action button { min-height: 32px; min-width: 32px; padding: .15rem; }
.edit-table .row-action { min-width: 47px; width: 47px; text-align: center; }
.editor-footer { display: grid; gap: .35rem; border-block-start: 1px solid var(--edge); padding: .65rem .75rem; background: var(--control); }
.status-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .35rem; font-size: .82rem; }
.feedback { color: var(--muted); font-size: .9rem; }
.feedback[data-error=true] { color: var(--red); }

.xp-dialog { width: min(520px, calc(100% - 22px)); max-height: calc(100vh - 22px); border: 1px solid #376dc3; border-block-start: 6px solid #275dbb; border-radius: 5px; background: var(--shell); color: var(--ink); padding: 0; box-shadow: 0 14px 34px #10295c5c; }
.xp-dialog::backdrop { background: #17305c76; }
.dialog-content { display: grid; gap: .55rem; padding: .75rem; }
.dialog-content h2, .dialog-toolbar h2 { font-size: 1.05rem; }
.dialog-toolbar { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: .5rem; }
.preview-dialog { width: min(850px, calc(100% - 22px)); }
.preview-dialog > .dialog-toolbar { padding: .5rem .75rem; background: var(--control); border-block-end: 1px solid var(--edge); }
.preview-dialog .print-sheet { margin: .75rem; }
.audit-list { display: grid; gap: .35rem; list-style: none; margin: 0; padding: 0; }
.audit-list li { padding: .4rem .45rem; background: white; border: 1px solid var(--edge); }
.audit-list small { display: block; color: var(--muted); }
.operator-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .35rem; align-items: end; }
.operator-list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .35rem; }

.reader-shell { max-width: 990px; }
.reader-shell main { padding: .75rem; }
.reader-shell .connection-notice { margin: 0; }
.print-sheet { background: var(--paper); border: 1px solid var(--edge); padding: clamp(.75rem, 3vw, 1.7rem); min-width: 0; }
.publication-header { border-block-end: 1px solid var(--edge); margin-block-end: .7rem; padding-block-end: .55rem; }
.publication-header h2 { font-size: clamp(1.25rem, 3.5vw, 1.8rem); line-height: 1.35; }
.publication-header .muted { margin-block-start: .2rem; font-size: .87rem; }
.eyebrow { color: #31588c; font-size: .92rem; }
.reader-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) max-content; gap: .5rem; align-items: end; margin-block-end: .6rem; }
.search-results { margin-block-end: .4rem; }
.document-body { display: grid; gap: .6rem; min-width: 0; }
.document-body :is(p, h3, h4) { white-space: pre-wrap; }
.document-body h3 { font-size: 1.2rem; }
.document-body h4 { font-size: 1.05rem; }
.visually-hidden { position: absolute; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  .workspace { grid-template-columns: minmax(0, 1fr); gap: .5rem; padding: .5rem; }
  .page-list { grid-template-columns: repeat(auto-fit, minmax(min(120px, 100%), 1fr)); }
  .sidebar-action { width: auto; }
}

@media (max-width: 520px) {
  .window-title { padding-inline: .5rem; gap: .4rem; }
  .page-information { grid-template-columns: minmax(0, 1fr); gap: .55rem; padding: .55rem; }
  .editor-toolbar, .editor-blocks, .editor-footer { padding-inline: .5rem; }
  .editor-toolbar-spacer { display: none; }
  .reader-toolbar { grid-template-columns: minmax(0, 1fr); justify-items: start; }
  .reader-toolbar .field { width: 100%; }
}

@media (pointer: coarse) {
  :is(button, input:not([type=file]), select, textarea) { min-height: 44px !important; }
  :is(input, select, textarea) { font-size: 16px !important; }
}

@page { size: A4; margin: 14mm; }
@page wide-sheet { size: A4 landscape; margin: 12mm; }
@media print {
  body { margin: 0; padding: 0; background: white; color: #111; font-size: 11pt; }
  .admin-page #admin-shell, .admin-page dialog:not([open]), .dialog-toolbar, .window-title, .reader-toolbar, .search-results { display: none !important; }
  .preview-dialog[open] { position: static; display: block; inset: auto; width: auto; height: auto; max-width: none; max-height: none; overflow: visible; border: 0; background: white; box-shadow: none; margin: 0; }
  .preview-dialog::backdrop { display: none; }
  .shell, .print-sheet { background: white; border: 0; box-shadow: none; }
  .wide-print .print-sheet { page: wide-sheet; }
  .preview-dialog .print-sheet, .reader-shell main, .print-sheet { margin: 0; padding: 0; }
  .document-body { display: block; }
  .document-body > * { margin-block-end: .5rem; }
  .document-body :is(h3, h4) { break-after: avoid; }
  .table-wrap { display: block; overflow: visible; }
  .table-wrap table { table-layout: fixed; }
  .table-wrap thead { display: table-header-group; }
  .table-wrap tr { break-inside: avoid; }
  .table-wrap :is(th, td) { min-width: 0; }
}
