/* ---------- tokens ---------- */
:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #1c2228;
  --ink-2: #3b444e;
  --muted: #69727c;
  --line: #e4e1d9;
  --line-2: #d6d2c7;
  --accent: #0f6e6e;
  --accent-ink: #ffffff;
  --accent-soft: #e3f0ef;
  --warn: #9a5b0a;
  --warn-soft: #fcf0d9;
  --danger: #b42318;
  --danger-soft: #fde8e6;
  --ok: #1f7a44;
  --ok-soft: #e3f3e9;
  --c1: #0f6e6e;
  --c2: #b0620e;
  --c3: #4b4fb8;
  --c4: #5b6b7a;
  --c5: #2f7d3b;
  --c6: #8a3f8f;
  --shadow: 0 1px 2px rgba(20, 24, 28, .05), 0 4px 16px rgba(20, 24, 28, .06);
  --radius: 12px;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111416; --surface: #181c1f; --surface-2: #1d2226; --ink: #e9e7e2; --ink-2: #c9ccd0;
    --muted: #949ca5; --line: #2a3035; --line-2: #363d43; --accent: #53b5b1; --accent-ink: #0b1414;
    --accent-soft: #15302f; --warn: #e2a24b; --warn-soft: #33270f; --danger: #f07a6e; --danger-soft: #3a1b18;
    --ok: #6cc58b; --ok-soft: #15301f; --c1: #53b5b1; --c2: #e2a24b; --c3: #9a9df0;
    --c4: #9fb0c0; --c5: #7cc788; --c6: #d58ad9;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111416; --surface: #181c1f; --surface-2: #1d2226; --ink: #e9e7e2; --ink-2: #c9ccd0;
  --muted: #949ca5; --line: #2a3035; --line-2: #363d43; --accent: #53b5b1; --accent-ink: #0b1414;
  --accent-soft: #15302f; --warn: #e2a24b; --warn-soft: #33270f; --danger: #f07a6e; --danger-soft: #3a1b18;
  --ok: #6cc58b; --ok-soft: #15301f; --c1: #53b5b1; --c2: #e2a24b; --c3: #9a9df0;
  --c4: #9fb0c0; --c5: #7cc788; --c6: #d58ad9;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25); color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 30px; }
h2 { font-size: 21px; }
h3 { font-size: 16px; font-family: var(--sans); font-weight: 650; letter-spacing: 0; }
button { font: inherit; color: inherit; }
kbd { font: 11px var(--mono); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; color: var(--muted); background: var(--surface-2); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.nav { position: sticky; top: 0; height: 100vh; overflow: auto; background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; gap: 11px; align-items: center; padding: 4px 8px 10px; color: var(--ink); text-decoration: none !important; }
.brand strong { display: block; font-family: var(--serif); font-size: 17px; }
.brand small { color: var(--muted); font-size: 12px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 8px 10px; border: 2px solid var(--accent-ink); border-radius: 2px 6px 2px 2px; }
#menu { display: flex; flex-direction: column; gap: 2px; }
#menu .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 12px 10px 4px; }
#menu a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; }
#menu a:hover { background: var(--surface-2); }
#menu a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
#menu .ic { width: 18px; text-align: center; opacity: .85; }
#menu .cnt { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 8px 10px; border-top: 1px solid var(--line); }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; align-items: center; padding: 12px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.search-trigger { flex: 1; max-width: 560px; display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 12px; color: var(--muted); cursor: pointer; }
.search-trigger:hover { border-color: var(--accent); }
.icon-btn { border: 1px solid var(--line-2); background: var(--surface); border-radius: 10px; width: 38px; height: 38px; cursor: pointer; font-size: 17px; margin-left: auto; }
.top .icon-btn:first-child { margin-left: 0; }
.only-mobile { display: none; }
main { padding: 28px; max-width: 1240px; width: 100%; outline: none; }

/* ---------- common ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 70ch; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--accent); font-weight: 650; margin-bottom: 6px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 18px 20px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 30px 0 12px; }
.section-title h2 { font-size: 19px; }

.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; text-decoration: none !important; color: inherit; }
.stat .lbl { font-size: 12.5px; color: var(--muted); }
.stat .val { font-family: var(--serif); font-size: 27px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .sub { font-size: 12.5px; color: var(--ink-2); }
a.stat:hover { border-color: var(--accent); }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-2); background: var(--surface-2); white-space: nowrap; }
.chip.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chip.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.chip.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.chip.acc { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; color: var(--ink-2); font-size: 13.5px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.input { border: 1px solid var(--line-2); background: var(--surface); border-radius: 10px; padding: 7px 11px; color: var(--ink); min-width: 220px; }

.note { border-left: 3px solid var(--warn); background: var(--warn-soft); padding: 10px 14px; border-radius: 0 10px 10px 0; color: var(--ink); font-size: 14px; }
.note.info { border-color: var(--accent); background: var(--accent-soft); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- document cards ---------- */
.doc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.doc { display: flex; flex-direction: column; gap: 8px; padding: 15px 16px; text-decoration: none !important; color: inherit; transition: border-color .15s, transform .15s; }
.doc:hover { border-color: var(--accent); transform: translateY(-1px); }
.doc .meta { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); }
.doc .t { font-weight: 650; font-size: 15px; line-height: 1.35; }
.doc .s { font-size: 13.5px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.doc .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.year-head { display: flex; align-items: center; gap: 12px; margin: 26px 0 12px; }
.year-head h2 { font-size: 24px; }
.year-head .line { flex: 1; height: 1px; background: var(--line); }

/* ---------- timeline ---------- */
.tl { position: relative; margin-left: 8px; }
.tl::before { content: ""; position: absolute; left: 98px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { display: grid; grid-template-columns: 90px 20px 1fr; gap: 0 12px; margin-bottom: 14px; }
.tl-date { text-align: right; font-size: 13px; color: var(--muted); padding-top: 13px; font-variant-numeric: tabular-nums; }
.tl-date b { display: block; color: var(--ink); font-size: 14px; }
.tl-dot { width: 14px; height: 14px; border-radius: 50%; margin: 15px 0 0 2px; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line-2); z-index: 1; }
.tl-card { padding: 12px 15px; }
.tl-card .t { font-weight: 650; }
.tl-card .x { color: var(--ink-2); font-size: 14px; margin-top: 3px; }
.tl-card .links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tl-year { font-family: var(--serif); font-size: 22px; font-weight: 600; margin: 24px 0 10px 0; padding-left: 132px; }
.tl-item.key .tl-card { border-color: var(--accent); }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; cursor: pointer; user-select: none; white-space: nowrap; }
th.r, td.r { text-align: right; }
tbody tr:hover { background: var(--surface-2); }
tfoot td { font-weight: 700; background: var(--surface-2); }
td .sub { color: var(--muted); font-size: 12.5px; }

/* ---------- viewer ---------- */
.viewer { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.viewer aside { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 12px; }
.viewer .frame { height: calc(100vh - 120px); min-height: 520px; overflow: hidden; display: flex; flex-direction: column; }
.viewer .frame iframe { border: 0; width: 100%; flex: 1; background: #fff; }
.viewer .frame .imgbox { flex: 1; overflow: auto; background: var(--surface-2); display: flex; justify-content: center; align-items: flex-start; padding: 10px; }
.viewer .frame img { max-width: 100%; height: auto; cursor: zoom-in; box-shadow: var(--shadow); background: #fff; }
.viewer .frame .zoomed img { max-width: none; cursor: zoom-out; }
.viewer .frame .zoomed.pages img { width: 160%; }
.imgbox.pages { flex-direction: column; align-items: center; gap: 6px; }
.imgbox.pages figure { margin: 0 0 14px; width: 100%; max-width: 920px; text-align: center; }
.imgbox.pages.zoomed figure { max-width: none; }
.imgbox.pages img { width: 100%; }
.imgbox.pages figcaption { font-size: 12px; color: var(--muted); margin-top: 6px; }
.frame-bar { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.frame-bar .sp { flex: 1; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--surface); border-radius: 8px; padding: 5px 11px; cursor: pointer; color: var(--ink); text-decoration: none !important; font-size: 13.5px; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn[disabled] { opacity: .4; pointer-events: none; }
dl.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); font-size: 13px; }
dl.kv dd { margin: 0; }
.prose { font-size: 15px; line-height: 1.65; max-width: 78ch; }
.prose p { margin: 0 0 12px; }
.prose ul { padding-left: 20px; margin: 0 0 12px; }
.prose li { margin: 3px 0; }
.prose h1, .prose h2, .prose h3 { margin: 20px 0 10px; }
.prose table { margin: 10px 0 16px; font-size: 13.5px; }
.prose code { font-family: var(--mono); font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.pre { white-space: pre-wrap; font: 13.5px/1.6 var(--mono); padding: 18px; overflow: auto; flex: 1; }
.ocr-text { overflow-wrap: anywhere; white-space: pre-wrap; font: 12.5px/1.55 var(--mono); color: var(--ink-2); max-height: 260px; overflow: auto; background: var(--surface-2); padding: 10px; border-radius: 8px; }
details summary { cursor: pointer; color: var(--accent); font-size: 13.5px; }

.catrow { display: grid; grid-template-columns: 190px 1fr 110px; gap: 12px; align-items: center; margin-top: 9px; font-size: 14px; }
@media (max-width: 600px) { .catrow { grid-template-columns: 1fr auto; gap: 4px 12px; } .catrow > span:nth-child(2) { grid-column: 1 / -1; grid-row: 2; } }

/* ---------- documente Word ---------- */
.docx { flex: 1; overflow: auto; padding: 36px 48px; background: #fff; color: #1a1a1a; font: 15px/1.6 "Times New Roman", Georgia, serif; }
.docx p { margin: 0 0 8px; text-align: justify; }
.docx p.c { text-align: center; }
.docx table { border-collapse: collapse; margin: 8px 0; }
.docx td { border: 1px solid #ccc; padding: 4px 8px; font-size: 14px; }
.docx ins { color: #116b2e; background: #e4f5e9; text-decoration: underline; }
.docx del { color: #b42318; background: #fde8e6; }
.docx .cmt, .docx-legend .cmt { font: 12.5px var(--sans); color: #6b4f00; background: #fff4cc; border-radius: 6px; padding: 2px 8px; display: inline-block; }
.docx p.note-cmt { text-align: left; margin: -2px 0 10px 18px; }
.docx.clean del, .docx.clean .note-cmt { display: none; }
.docx-legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.docx-legend ins { color: var(--ok); text-decoration: underline; }
.docx-legend del { color: var(--danger); }
@media (max-width: 860px) { .docx { padding: 20px 16px; } }

/* ---------- emails ---------- */
.thread { display: flex; flex-direction: column; gap: 12px; max-width: 820px; }
.msg { padding: 14px 18px; max-width: 88%; }
.msg.me { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.msg .h { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.msg .h b { color: var(--ink); }
.msg .b { white-space: pre-wrap; }
.msg.hl { border: 2px solid var(--c2); }

/* ---------- search ---------- */
.search-layer { position: fixed; inset: 0; z-index: 50; background: rgba(10, 14, 18, .45); display: flex; justify-content: center; align-items: flex-start; padding: 9vh 16px 16px; }
.search-layer[hidden] { display: none; }
.search-box { width: min(760px, 100%); max-height: 80vh; display: flex; flex-direction: column; background: var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden; }
.search-box input { border: 0; border-bottom: 1px solid var(--line); padding: 18px 20px; font-size: 18px; background: transparent; color: var(--ink); outline: none; }
.search-hint { padding: 10px 20px; font-size: 13px; color: var(--muted); }
.search-results { overflow: auto; }
.res { display: block; padding: 11px 20px; border-top: 1px solid var(--line); color: inherit; text-decoration: none !important; }
.res:hover, .res.sel { background: var(--accent-soft); }
.res .rt { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.res .rs { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
mark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .viewer { grid-template-columns: 1fr; } .viewer aside { position: static; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .nav { position: fixed; z-index: 40; left: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .nav.open { transform: none; }
  .only-mobile { display: inline-block; }
  main { padding: 18px 16px; }
  .top { padding: 10px 16px; }
  .g3, .g2 { grid-template-columns: 1fr; }
  .search-trigger kbd { display: none; }
  .tl::before { left: 7px; }
  .tl-item { grid-template-columns: 16px minmax(0, 1fr); }
  .chip { white-space: normal; max-width: 100%; }
  td .sub, .tl-card .t, .doc .t { overflow-wrap: anywhere; }
  .stack > a.doc { flex-wrap: wrap; }
  .stack > a.doc > span { min-width: 0; }
  .nav { width: 100%; padding-top: 14px; }
  .viewer .frame:not(:has(iframe, .imgbox, .docx, .pre)) { height: auto; min-height: 0; }
  .nav-close { position: absolute; top: 14px; right: 14px; margin: 0; }
  .nav .brand { padding-right: 56px; }
  body:has(.nav.open) { overflow: hidden; }
  .table-wrap:has(.stk) { overflow: visible; }
  .stk thead { display: none; }
  .stk, .stk tbody, .stk tfoot { display: block; }
  .stk tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .stk td { display: block; padding: 0; border: 0; }
  .ch tbody td:nth-child(3), .dl tbody td:nth-child(2) { order: -1; flex-basis: 100%; }
  .ch tbody td:nth-child(1)::before { content: "Nr. "; }
  .ch tbody td:nth-child(5), .dl tbody td:nth-child(5) { margin-left: auto; }
  .ch tbody td:nth-child(5) { font-weight: 650; }
  .ch tbody td:nth-child(6) { flex-basis: 100%; }
  .dl tbody td:nth-child(1), .dl tbody td:nth-child(3), .dl tbody td:nth-child(4) { font-size: 13px; color: var(--muted); }
  .stk tfoot td:first-child { flex: 1; }
  .stk tfoot td:empty { display: none; }
  .tl-date { grid-column: 2; text-align: left; padding: 0; }
  .tl-dot { grid-row: 1 / span 2; margin: 3px 0 0 0; }
  .tl-card { grid-column: 2; }
  .tl-year { padding-left: 24px; }
  h1 { font-size: 25px; }
}
@media (max-width: 520px) { .g4 { grid-template-columns: 1fr; } .msg { max-width: 100%; } }

/* ---------- print ---------- */
@media print {
  .nav, .top, .filters, .frame-bar { display: none !important; }
  .app { display: block; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; color: #000; }
}
