/* Vertrag-tool — look & feel taken over from BelegAI (which follows the office's PHOEVER-ERP):
   left sidebar, calm paper palette, serif headings, KPI cards, pill badges, uppercase table heads,
   light/dark theme and font size switch (remembered per browser), colour themes + layouts (core/ui_theme.py).
   Components only use the variables below; the dark theme only redefines variables. */
:root {
  --ink: #10241A; --ink-soft: #1B3A2B; --paper: #F6F5F1; --surface: #FFFFFF; --line: #E2E0D6;
  --accent: #1F7A54; --accent-dark: #175E41; --accent-soft: #E8F3ED; --amber: #B45309; --amber-soft: #FDF1E3;
  --red: #B3261E; --red-soft: #FBEAE9; --muted: #6E7480; --side-bg: #10241A; --side-text: #8B92A8;
  --hover-row: #FAF9F5; --head-row: #F1EFE8; --sub-row: #F8F7F3; --selected-row: #E8F3ED;
  --head-font: Georgia, "Times New Roman", serif; --sans: system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace; --radius: 10px; --side-w: 14.4rem;
  /* names used by older templates */
  --bg: var(--paper); --card: var(--surface); --text: var(--ink); --border: var(--line); --primary: var(--accent);
  --primary-dark: var(--accent-dark); --ok: var(--accent-soft); --ok-text: var(--accent); --error: var(--red-soft);
  --error-text: var(--red); --warn: var(--amber-soft); --warn-text: var(--amber);
}
html[data-theme="dark"] {
  --ink: #EDEEF4; --ink-soft: #C7CBD9; --paper: #121824; --surface: #1E2430; --line: #2E3546;
  --accent: #9C93EA; --accent-dark: #B0A8F2; --accent-soft: #252A3E; --amber: #E8B341; --amber-soft: #2E2712;
  --red: #F09098; --red-soft: #3A1E22; --muted: #98A0B4; --side-bg: #0E131D; --side-text: #8B92A8;
  --hover-row: #232A38; --head-row: #252B38; --sub-row: #1A2030; --selected-row: #252A3E;
}
html { font-size: calc(15px * var(--font-scale, 1)); scrollbar-gutter: stable; }  /* no width jump when a page gets a scrollbar */
* { box-sizing: border-box; }
body { margin: 0; font: 1rem/1.5 var(--sans); background: var(--paper); color: var(--ink); }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--head-font); font-weight: 700; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .7rem; }
h3 { font-size: 1rem; margin: .9rem 0 .4rem; }

/* ---------- app shell: sidebar + content ---------- */
.app { display: flex; min-height: 100vh; }
aside.side { width: var(--side-w); flex: 0 0 var(--side-w); background: var(--side-bg); color: #E6E8F0;
  padding: 1.1rem .85rem; display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 0;
  height: 100vh; overflow-y: auto; border-right: 1px solid rgba(255,255,255,.06); }
.side-brand { padding: 0 .4rem; }
.side-brand b { display: block; font: 700 1.15rem var(--head-font); letter-spacing: .02em; color: #fff; }
.side-brand span { display: block; font-size: .72rem; color: var(--side-text); margin-top: .1rem; }
aside.side nav { display: flex; flex-direction: column; gap: .12rem; }
aside.side nav a { color: var(--side-text); font-weight: 600; font-size: .9rem; text-decoration: none;
  padding: .5rem .65rem; border-radius: 8px; display: flex; align-items: center; gap: .55rem; }
aside.side nav a .ico { width: 1.2rem; text-align: center; opacity: .85; }
aside.side nav a:hover { color: #E6E8F0; background: rgba(255,255,255,.05); }
aside.side nav a.active { background: rgba(255,255,255,.09); color: #fff; box-shadow: inset 3px 0 0 #5FBF8F; }
aside.side nav .nav-label { font-size: .66rem; letter-spacing: .09em; text-transform: uppercase; color: #5D6578;
  padding: .7rem .65rem .2rem; }
.mandant-box { margin: .6rem 0 .2rem; padding: .55rem .4rem .45rem; border-radius: 10px; background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: .12rem; }
.mandant-box .nav-label { padding-top: 0; color: #7FCFA4; }
.mandant-switch { display: flex; gap: .3rem; align-items: center; margin: .15rem .25rem .35rem; }
.mandant-switch select { background: #1B3A2B; color: #fff; border: 1px solid rgba(255,255,255,.2); font-weight: 600; font-size: .85rem;
  padding: .4rem .5rem; border-radius: 8px; }
.mandant-close { color: #AAB2C6; text-decoration: none; padding: .2rem .4rem; border-radius: 6px; }
.mandant-close:hover { color: #fff; background: rgba(255,255,255,.1); }
.mandant-hint { font-size: .78rem; color: #AAB2C6; padding: .1rem .5rem .3rem; }
html[data-theme="dark"] .mandant-switch select { background: #1E2430; }
.side-import { margin-top: auto; padding: 0 .2rem; }
.import-btn { width: 100%; justify-content: center; padding: .7rem 1rem; font-size: .95rem; border-radius: 10px;
  background: #2E8B5E; border-color: #2E8B5E; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.import-btn:hover { background: #3AA06D; border-color: #3AA06D; }
dialog.import-dlg { border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem 1.4rem; width: min(640px, 94vw);
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog.import-dlg::backdrop { background: rgba(16,36,26,.45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.dlg-head h2 { margin: 0; }
.drop-zone { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 120px; margin: .3rem 0;
  border: 2px dashed var(--line); border-radius: 12px; background: var(--paper); color: var(--muted); cursor: pointer;
  font-weight: 600; padding: 1rem; position: relative; }
.drop-zone.over, .drop-zone:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.drop-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.side-foot { margin-top: .8rem; display: flex; flex-direction: column; gap: .5rem; padding: 0 .2rem; }
.side-foot .who { color: #AAB2C6; font-size: .8rem; text-decoration: none; overflow-wrap: anywhere; }
.side-foot .who b { color: #E6E8F0; display: block; }
.side-foot .row { display: flex; gap: .35rem; align-items: center; }
.side-foot form { margin: 0; }
.btn.ghost, button.ghost { background: transparent; border: 1px solid rgba(255,255,255,.3); color: #E6E8F0; }
.btn.ghost:hover, button.ghost:hover { border-color: #fff; background: rgba(255,255,255,.08); }
.btn.ghost.on, button.ghost.on { background: #E6E8F0; color: var(--side-bg); border-color: #E6E8F0; }
.side-foot .fval { color: #AAB2C6; font-size: .75rem; min-width: 2.6rem; text-align: center; }
.content { flex: 1; min-width: 0; }
main { max-width: var(--main-w, none); margin: 0 auto; padding: calc(1.5rem * var(--dens, 1)) clamp(12px, 2vw, 32px) 4rem; }
main.wide { max-width: none; margin: 0; padding: 0; }
.narrow { max-width: 440px; margin: 60px auto; }
body.no-side .app { display: block; }

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: calc(1.2rem * var(--dens, 1)) 1.35rem;
  margin-bottom: 1.1rem; overflow-wrap: break-word; transition: box-shadow .25s ease; }
.card:hover { box-shadow: 0 6px 22px rgba(0,0,0,.07); }
.card > h2:first-child, .card > .lines-head:first-child h2 { margin-top: 0; }
.page-head { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: baseline; justify-content: space-between; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.kpi { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem; color: var(--ink); text-decoration: none; transition: transform .18s ease, box-shadow .25s ease; }
a.kpi:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.10); }
.kpi .k-label { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.kpi .k-val { font: 700 1.7rem/1.2 var(--head-font); margin-top: .25rem; }
.kpi .k-sub { font-size: .8rem; color: var(--muted); }
.kpi.hl { background: var(--side-bg); border-color: var(--side-bg); }
.kpi.hl .k-label { color: #AAB2C6; } .kpi.hl .k-val { color: #fff; } .kpi.hl .k-sub { color: #AAB2C6; }
.kpi.good .k-val { color: var(--accent); }
.kpi.warn { border-color: color-mix(in srgb, var(--amber) 40%, var(--line)); } .kpi.warn .k-val { color: var(--amber); }
.kpi.bad { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); background: var(--red-soft); } .kpi.bad .k-val { color: var(--red); }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: .3rem; }

table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .92rem; }
th, td { text-align: left; padding: calc(.55rem * var(--dens, 1)) .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .7rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 700;
  background: transparent; border-bottom: 1px solid var(--line); }
tr:hover td { background: var(--hover-row); }
th.num, td.num { text-align: right; }
label { display: block; font-weight: 600; margin: .8rem 0 .25rem; font-size: .9rem; }
label.inline { display: flex; align-items: center; gap: .5rem; font-weight: 400; margin: .4rem 0; }
input:not([type]), input[type=text], input[type=password], input[type=number], input[type=date], input[type=month], select, textarea {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px; font: inherit;
  background: var(--surface); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
textarea { min-height: 70px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 20px; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 2px; }

button, .btn { display: inline-flex; align-items: center; gap: .35rem; background: var(--accent); color: #fff;
  border: 1px solid var(--accent); border-radius: 8px; padding: .5rem 1rem; font: 600 .92rem var(--sans); cursor: pointer;
  text-decoration: none; transition: background .15s, border-color .15s, transform .08s; }
button:hover, .btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button:active, .btn:active { transform: scale(.965); }
.btn.secondary, button.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover, button.secondary:hover { border-color: var(--ink); background: var(--surface); }
.btn.small, button.small { padding: .3rem .65rem; font-size: .8rem; }
/* Dark mode: dark text only on the filled accent buttons. Buttons that bring their own (transparent) background –
   calendar, filter value list – keep their own text colour, otherwise dark text would sit on a dark background. */
html[data-theme="dark"] button:not(.secondary):not(.ghost):not(.cal-nav):not(.cal-cell):not(.cal-link):not(.cal-btn):not(.filter-pick-btn):not(.filter-pick-item):not(.filter-pick-all),
html[data-theme="dark"] .btn:not(.secondary):not(.ghost) { color: #10131C; }
/* Disabled buttons: clearly inactive but still readable. */
button:disabled, button:disabled:hover { cursor: not-allowed; opacity: .6; transform: none; }
button.secondary:disabled:hover { border-color: var(--line); }
.actions { display: flex; gap: .6rem; margin: 1rem 0; flex-wrap: wrap; align-items: center; }
.msg { padding: .65rem .9rem; border-radius: 8px; margin-bottom: .8rem; border: 1px solid transparent; }
.msg.ok { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.msg.error { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.msg.warn { background: var(--amber-soft); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }
.badge { display: inline-block; padding: .12rem .6rem; border-radius: 99px; font-size: .72rem; font-weight: 600;
  background: var(--head-row); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.off { background: var(--red-soft); color: var(--red); }
dl.profile { display: grid; grid-template-columns: 260px 1fr; gap: 6px 16px; margin: 0; }
dl.profile dt { color: var(--muted); }
dl.profile dd { margin: 0; white-space: pre-line; }
pre.json { white-space: pre-wrap; word-break: break-all; font-size: 12px; margin: 0; max-width: 380px; }
code { font-family: var(--mono); font-size: .85em; }
.inline-form { display: inline; }
details.card > summary { cursor: pointer; font-weight: 600; }
details.card[open] > summary { margin-bottom: 10px; }

/* ---------- document page: preview left, work area right, both fill the window ---------- */
.doc-layout { --preview-w: 42%; display: grid; grid-template-columns: var(--preview-w) 6px minmax(0, 1fr); height: 100vh; }
.doc-layout.with-queue { grid-template-columns: 230px var(--preview-w) 6px minmax(0, 1fr); }
.doc-queue { overflow-y: auto; background: var(--paper); border-right: 1px solid var(--line); font-size: .88rem; }
.queue-head { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 6px;
  padding: 8px 10px; background: var(--paper); border-bottom: 1px solid var(--line); }
.queue-mandant { padding: 8px 10px 2px; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.queue-item { display: block; padding: 6px 10px; border-left: 3px solid transparent; color: var(--ink); text-decoration: none; }
.queue-item:hover { background: var(--line); }
.queue-item.current { border-left-color: var(--accent); background: var(--line); font-weight: 600; }
.queue-item .q-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-item .q-meta { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: .8rem; }
.settings-block + .settings-block { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.queue-all { display: block; padding: 10px; border-top: 1px solid var(--line); }
.doc-preview { display: flex; flex-direction: column; min-width: 0; background: #2b2f36; }
.preview-bar { display: flex; gap: 10px; align-items: center; padding: 6px 10px; background: var(--side-bg); color: #cfd6e0; }
.preview-bar .hint { color: #cfd6e0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-bar .btn { margin-left: auto; }
.doc-preview iframe { flex: 1; width: 100%; border: 0; background: #2b2f36; }
.preview-image { flex: 1; overflow: auto; text-align: center; }
.preview-image img { max-width: 100%; }
.splitter { cursor: col-resize; background: var(--line); }
.splitter:hover, body.resizing .splitter { background: var(--accent); }
body.resizing { user-select: none; cursor: col-resize; }
body.resizing iframe { pointer-events: none; }
.doc-main { overflow-y: auto; padding: 14px clamp(12px, 1.5vw, 24px) 40px; min-width: 0; }
.doc-title { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.doc-title h1 { font-size: 1.3rem; margin: 0; }
.doc-nav { display: flex; gap: 6px; align-items: center; }
.summary-head { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 8px; }
.msg.compact { padding: 6px 10px; margin: 4px 0; font-size: .92rem; }
strong.big { font: 700 1.45rem var(--head-font); }
.compact-list { margin: 4px 0 0 18px; padding: 0; }
.problem { border-top: 1px solid var(--line); padding: 8px 0; }
kbd { font: 11px/1 var(--mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 4px;
  margin-left: 4px; background: var(--paper); color: var(--ink); }
@media (max-width: 900px) {
  .app { display: block; }
  aside.side { position: static; width: auto; height: auto; flex-direction: column; }
  aside.side nav { flex-direction: row; flex-wrap: wrap; }
  aside.side nav .mandant-box, aside.side nav .nav-label { width: 100%; }
  aside.side nav .mandant-box { flex-direction: row; flex-wrap: wrap; }
  .doc-layout, .doc-layout.with-queue { grid-template-columns: 1fr; height: auto; }
  .doc-queue { max-height: 30vh; }
  .doc-preview { height: 65vh; }
  .splitter { display: none; }
}

/* ---------- data tables: sort, filter, inline edit ---------- */
.table-scroll { overflow-x: auto; }
table.data-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
table.data-table th.sortable:hover { color: var(--ink); }
table.data-table th.sorted-asc, table.data-table th.sorted-desc { color: var(--accent); }
table.data-table th.sorted-asc::after { content: " ▲"; font-size: 10px; }
table.data-table th.sorted-desc::after { content: " ▼"; font-size: 10px; }
table.data-table .filter-row th { background: var(--sub-row); padding: 4px; text-transform: none; letter-spacing: 0; }
table.data-table .filter-row input, table.data-table .filter-row select { padding: 3px 5px; font-size: 12px; min-width: 40px; border-radius: 6px; }
table.data-table tr.filtered-out { display: none; }
table.data-table tfoot td { background: var(--sub-row); }
.lines-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.lines-head h2 { margin: 0; }
table.lines tr.line-row { cursor: pointer; }
table.lines tr.line-row.selected td { background: var(--selected-row); }
table.lines tr.line-row.decided td { color: var(--muted); }
table.lines td.text-cell { min-width: 220px; }
input.cell-edit { border: 1px solid transparent; background: transparent; padding: 3px 4px; border-radius: 4px; font: inherit; width: auto; color: var(--ink); }
input.cell-edit.wide { width: 100%; }
input.cell-edit.num { text-align: right; }
input.cell-edit:hover { border-color: var(--line); background: var(--surface); }
input.cell-edit:focus { border-color: var(--accent); background: var(--surface); outline: none; }
input.cell-edit.saved { background: var(--accent-soft); }
input.cell-edit.invalid { background: var(--red-soft); border-color: var(--red); }

/* ---------- calendar for month and date fields (pickers.js) ---------- */
.cal-wrap { position: relative; display: inline-flex; align-items: center; width: 100%; }
.cal-wrap.cell { width: auto; }
.cal-wrap input { padding-right: 2.2rem; }
.cal-wrap.cell input { padding-right: 1.8rem; min-width: 7.5rem; }
.cal-btn { position: absolute; right: .25rem; top: 50%; transform: translateY(-50%); background: transparent; border: 0;
  padding: .15rem .35rem; font-size: 1rem; line-height: 1; color: var(--ink); cursor: pointer; }
.cal-btn:hover { background: var(--accent-soft); }
.cal-pop { position: absolute; top: calc(100% + 4px); left: 0; z-index: 1000; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.22); padding: .6rem; width: 17rem; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.cal-head strong { font-family: var(--head-font); }
.cal-nav { background: transparent; color: var(--ink); border: 1px solid var(--line); padding: .15rem .6rem; }
.cal-nav:hover { background: var(--accent-soft); border-color: var(--accent); }
.cal-grid { display: grid; gap: .25rem; }
.cal-grid.months { grid-template-columns: repeat(3, 1fr); }
.cal-grid.days { grid-template-columns: repeat(7, 1fr); }
.cal-dow { font-size: .7rem; color: var(--muted); text-align: center; font-weight: 700; }
.cal-cell { background: var(--paper); color: var(--ink); border: 1px solid transparent; padding: .4rem 0; justify-content: center;
  font-weight: 600; font-size: .85rem; border-radius: 8px; }
.cal-cell:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.cal-cell.today { border-color: var(--accent); }
.cal-cell.sel { background: var(--accent); color: #fff; }
html[data-theme="dark"] .cal-cell.sel { color: #10131C; }
.cal-foot { display: flex; justify-content: space-between; margin-top: .45rem; }
.cal-link { background: transparent; border: 0; color: var(--accent); padding: .2rem .3rem; font-size: .82rem; }
.cal-link:hover { background: var(--accent-soft); color: var(--accent); }
dialog.import-dlg { overflow: visible; }

/* "Dieses Jahr" / "Vorjahr" quick buttons next to interval fields (pickers.js) */
.quick-years { display: inline-flex; gap: .3rem; margin-left: .3rem; vertical-align: middle; }
.quick-years button { white-space: nowrap; }  /* normal secondary buttons, same height as the date fields */
/* filter value list (table.js): input + ▾ button, popup with the column's distinct values */
table.data-table .filter-row .filter-combo { display: flex; align-items: stretch; gap: 2px; }
table.data-table .filter-row .filter-combo input { flex: 1; width: 100%; }
.filter-pick-btn { padding: 0 5px; font-size: 11px; line-height: 1; border: 1px solid var(--border, #ddd); border-radius: 6px;
  background: var(--card, #fff); color: inherit; cursor: pointer; min-height: 0; }
.filter-pick { position: absolute; z-index: 50; max-height: 320px; max-width: 420px; overflow-y: auto; padding: 4px;
  background: var(--card, #fff); border: 1px solid var(--border, #ddd); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.filter-pick button { display: flex; justify-content: space-between; gap: 12px; width: 100%; padding: 5px 8px; margin: 0;
  border: 0; border-radius: 5px; background: none; color: inherit; font: inherit; font-size: 13px; text-align: left;
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filter-pick button:hover, .filter-pick button:focus { background: var(--sub-row, #f3f3f3); outline: none; }
.filter-pick button.current { font-weight: 600; }
.filter-pick .filter-pick-all { color: var(--muted, #777); border-bottom: 1px solid var(--border, #eee); border-radius: 0; }
.filter-pick .filter-pick-count { color: var(--muted, #888); font-size: 11px; }
.filter-pick .filter-pick-none { padding: 5px 8px; color: var(--muted, #888); }
/* floating preview window (preview.js) and the stand-alone preview page (belege/vorschau.html) */
.preview-window { position: fixed; z-index: 2000; display: flex; flex-direction: column; background: #2b2f36;
  border-radius: 10px; overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,.45); border: 1px solid #444b57; }
.preview-drag { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 10px; background: #1b222c; color: #cfd6e0;
  cursor: move; user-select: none; touch-action: none; font-size: .85rem; }
.preview-grip { opacity: .8; }
.preview-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-window iframe { flex: 1; width: 100%; border: 0; display: block; }
.preview-window.dragging iframe { pointer-events: none; }
.preview-window.dragging { user-select: none; }
.preview-resize { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize; touch-action: none;
  background: linear-gradient(135deg, transparent 50%, #8b92a8 50%, #8b92a8 60%, transparent 60%, transparent 70%, #8b92a8 70%, #8b92a8 80%, transparent 80%); }
.preview-close { padding: .2rem .55rem; background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  font-size: .95rem; line-height: 1; }
.preview-close:hover { background: var(--surface); border-color: var(--ink); }
html[data-theme="dark"] .preview-close { color: var(--ink); }
body.vorschau { margin: 0; height: 100vh; display: flex; flex-direction: column; background: #2b2f36; }
body.vorschau .preview-bar { flex-wrap: wrap; }
body.vorschau .preview-bar .btn { margin-left: 0; }
body.vorschau .preview-bar .btn:first-of-type { margin-left: auto; }
body.vorschau iframe { flex: 1; width: 100%; border: 0; }
/* "← Zurück" (base.html) */
.back-bar { margin: 0 0 .6rem; }
main.wide > .back-bar { margin: .6rem clamp(12px, 2vw, 32px); }
/* Belegnummernkreis edit window (export/number_ranges.html) */
dialog.range-dlg { width: min(980px, 96vw); max-height: 92vh; overflow: auto; }
/* BWA / EÜR (berichte/bwa.html, euer.html) and server-drawn charts (berichte/auswertung.py).
   Series colours: validated reference palette slots 1-3 (blue, orange, aqua), own steps for dark mode. */
:root { --viz-1: #2a78d6; --viz-2: #eb6834; --viz-3: #1baf7a; --viz-grid: #e4e2da; --viz-axis: #6e7480; }
html[data-theme="dark"] { --viz-1: #3987e5; --viz-2: #d95926; --viz-3: #199e70; --viz-grid: #2e3546; --viz-axis: #98a0b4; }
.neg { color: var(--red); }
.kpi .k-val.small { font-size: 1.25rem; }
.viz-box { width: 100%; overflow-x: auto; }
.viz { width: 100%; max-width: 980px; height: auto; display: block; }
.viz .viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz .viz-zero { stroke: var(--viz-axis); }
.viz .viz-axis, .viz .viz-label { fill: var(--viz-axis); font-size: 11px; font-family: var(--sans); }
.viz .viz-label { fill: var(--ink); }
.viz .viz-s1 { fill: var(--viz-1); }
.viz .viz-s2 { fill: var(--viz-2); }
.viz .viz-line { stroke: var(--viz-3); stroke-width: 2; }
.viz .viz-line-dot { fill: var(--viz-3); stroke: var(--surface); stroke-width: 2; }
.viz rect:hover, .viz circle:hover { opacity: .8; }
.viz-legend { display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; font-size: .85rem; color: var(--ink-soft); margin-bottom: 4px; }
.viz-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; }
.viz-legend .sw.viz-s1 { background: var(--viz-1); }
.viz-legend .sw.viz-s2 { background: var(--viz-2); }
.viz-legend .viz-line-sw { width: 16px; height: 3px; background: var(--viz-3); border-radius: 2px; }
table.bwa tr.sum td { font-weight: 700; background: var(--sub-row); }
table.bwa tr.result td { border-top: 2px solid var(--ink); }
.viz .viz-prev { stroke: var(--viz-2); stroke-width: 2; stroke-dasharray: 5 4; }
.viz .viz-prev-dot { fill: var(--viz-2); stroke: var(--surface); stroke-width: 2; }
.viz-legend .viz-prev-sw { width: 16px; height: 0; border-top: 3px dashed var(--viz-2); border-radius: 0; }
/* "Vorschau - nicht zur Weitergabe" while the BWA/EÜR mapping is not verified (auswertung.MAPPING_VERIFIED) */
.preview-stamp { position: fixed; top: 45%; left: 50%; transform: translate(-50%, -50%) rotate(-24deg); z-index: 5;
  font: 800 clamp(28px, 6vw, 72px)/1 var(--sans); color: var(--red); opacity: .09; white-space: nowrap; pointer-events: none; }
@media print {
  aside.side, .back-bar, form.actions, .preview-window { display: none !important; }
  .preview-stamp { opacity: .14; }
  .card { break-inside: avoid; }
}
/* Darstellung (Mein Konto): theme and layout choice as clickable cards */
.ui-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin: 8px 0 14px; }
.ui-choice { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; }
.ui-choice:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.ui-choice input { margin: 0; width: auto; }
.ui-choice .sw { display: flex; gap: 4px; }
.ui-choice .sw span { width: 22px; height: 22px; border-radius: 5px; border: 1px solid rgba(0,0,0,.12); }
/* tabs of the report pages (berichte/_tabs.html) */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--line); margin: 0 0 1rem; }
.tabs .tab { padding: .5rem 1rem; text-decoration: none; color: var(--ink-soft); font-weight: 600; border: 1px solid transparent;
  border-bottom: none; border-radius: var(--radius) var(--radius) 0 0; margin-bottom: -2px; }
.tabs .tab:hover { background: var(--hover-row); }
.tabs .tab.on { color: var(--accent); background: var(--surface); border-color: var(--line); border-bottom: 2px solid var(--surface); }

/* Import page = workspace: tab bar + panes; tiles of the working order (layout like Lexware's start screen) */
html.embedded aside.side { display: none; }  /* page shown inside a workspace tab */
main.ws-main { padding-top: .6rem; padding-bottom: 0; }
.ws-tabs { display: flex; align-items: flex-end; gap: 3px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.ws-tab { display: flex; align-items: center; gap: .4rem; flex: 0 0 auto; max-width: 15rem; padding: .45rem .75rem;
  margin-bottom: -1px; border: 1px solid var(--line); border-top: 3px solid transparent; border-radius: 8px 8px 0 0;
  background: var(--surface); color: var(--muted); font-size: .9rem; cursor: pointer; white-space: nowrap; user-select: none; }
.ws-tab:hover { color: var(--ink); }
.ws-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ws-tab.active { background: var(--paper); color: var(--ink); font-weight: 600; border-top-color: var(--accent);
  border-bottom-color: var(--paper); }
/* main tab (working order): always on the left, also while the other tabs scroll */
.ws-tab.ws-home { position: sticky; left: 0; z-index: 1; font-weight: 700; color: var(--accent); background: var(--accent-soft);
  border-top-color: var(--accent); }
.ws-tab.ws-home.active { background: var(--paper); color: var(--accent); }
.ws-title { overflow: hidden; text-overflow: ellipsis; }
.ws-close { padding: 0 .25rem; border-radius: 4px; font-size: 1.05rem; line-height: 1; color: var(--muted); }
.ws-close:hover { background: var(--line); color: var(--ink); }
.ws-panes { position: relative; }
.ws-pane { display: none; height: 100%; }
.ws-pane.active { display: block; }
.ws-pane iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--paper); }
#wsHome { overflow: auto; }
.flow-board { --cgap: 3.2rem; --rgap: 2.2rem; display: flex; justify-content: center; align-items: flex-start; gap: var(--cgap);
  min-height: 100%; box-sizing: border-box; padding: 3rem 2rem; width: max-content; min-width: 100%;
  background: color-mix(in srgb, var(--accent) 50%, var(--paper)); }
.flow-col { display: flex; flex-direction: column; gap: var(--rgap); }
.flow-stage-name { display: flex; align-items: center; gap: .45rem; color: #fff; font-weight: 600; font-size: .9rem;
  margin-bottom: calc(var(--rgap) * -0.6); text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.flow-no { display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: #fff; color: var(--accent); font-size: .8rem; text-shadow: none; }
.flow-tile { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .7rem;
  width: 11.5rem; height: 8.2rem; padding: .6rem; box-sizing: border-box; background: var(--surface, #fff); color: var(--ink);
  border: 1px solid rgba(255,255,255,.6); text-align: center; text-decoration: none; transition: transform .15s, box-shadow .15s; }
.flow-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.18); color: var(--ink); }
.flow-tile svg { width: 2.8rem; height: 2.8rem; fill: none; stroke: var(--red); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.flow-tile + .flow-tile::before { content: ""; position: absolute; left: 50%; bottom: 100%; height: var(--rgap); border-left: 3px solid rgba(255,255,255,.75); }
.flow-col:not(:last-child) .flow-stage-name + .flow-tile::after { content: ""; position: absolute; left: 100%; top: 50%;
  width: var(--cgap); border-top: 3px solid rgba(255,255,255,.75); }
.fixed-value { padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }  /* read-only form value */

/* ---------- Vertrag-tool additions ---------- */
main .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; align-items: end; }
main .row > .actions { margin: .6rem 0 0; }
form.card.row { align-items: end; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
label.check input { width: auto; margin: 0; }
input[type=email], input[type=file] { width: 100%; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: var(--surface); color: var(--ink); }
form.inline { display: inline; }
button.link { background: none; border: 0; color: var(--accent); padding: 0; font-weight: 600; }
button.link:hover { background: none; text-decoration: underline; }
html[data-theme="dark"] button.link { color: var(--accent); }
button.danger { background: var(--surface); color: var(--red); border-color: var(--red); }
button.danger:hover { background: var(--red-soft); border-color: var(--red); }
html[data-theme="dark"] button.danger { color: var(--red); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.notice { background: var(--amber-soft); color: var(--amber); border: 1px solid color-mix(in srgb, var(--amber) 25%, transparent);
  padding: .6rem .9rem; border-radius: 8px; margin-bottom: .8rem; }
.notice a { color: inherit; font-weight: 700; }
dl.facts { display: grid; grid-template-columns: minmax(160px, 240px) 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
/* status / risk badges */
.badge.aktiv, .badge.low, .badge.approved, .badge.done { background: var(--accent-soft); color: var(--accent); }
.badge.in_pruefung, .badge.medium, .badge.waiting, .badge.risk, .badge.unclear, .badge.open, .badge.entwurf { background: var(--amber-soft); color: var(--amber); }
.badge.high, .badge.invalid, .badge.error, .badge.missing, .badge.gekuendigt, .badge.rejected { background: var(--red-soft); color: var(--red); }
.badge.auto { background: var(--accent-soft); color: var(--accent); }
.overdue { color: var(--red); font-weight: 700; }
.soon { color: var(--amber); font-weight: 700; }
.conf { font-size: .7rem; color: var(--muted); font-weight: 600; margin-left: .3rem; }
.conf.low { color: var(--red); }
ul.warnings li { color: var(--amber); }
ul.errors { list-style: none; padding-left: 0; }
ul.errors li { color: var(--red); }
blockquote { margin: .3rem 0; padding: .3rem .8rem; border-left: 3px solid var(--line); color: var(--muted); font-style: italic; }

/* ---------- sidebar exactly like the Rechnungstool (theme colours, foot pinned to the bottom) ---------- */
h1, h2, h3 { font-weight: var(--head-weight, 700); }
.side-brand span { color: var(--muted); }
aside.side nav a.active { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
html[data-theme="dark"] aside.side nav a.active { color: var(--accent); }
aside.side nav .nav-label { color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: .4rem; }
aside.side nav .nav-label::after { content: ""; flex: 1; height: 1px; background: rgba(255,255,255,.1); }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-top: .8rem; }
.side-foot .row { display: flex; flex-wrap: wrap; gap: .35rem; }
.side-foot .row > .btn, .side-foot .row > button { flex: 1 1 0; min-width: 0; justify-content: center; }
.side-foot .fontctl { display: flex; align-items: center; gap: .3rem; justify-content: center; }
.side-foot .fontctl button { width: 2rem; height: 1.8rem; padding: 0; justify-content: center; font-size: .9rem; }
.side-foot .fval { font-family: var(--mono); }
.btn.ghost.on, button.ghost.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }
/* contract draft review (proposal_draft.html) */
.card.draft p { margin: .35rem 0; }
.card.draft p.chg { background: color-mix(in srgb, #F5D90A 32%, transparent); border-radius: 4px; padding: .1rem .3rem; }
.card.draft p.lawyer { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 4px; }
