:root {
  --bg: #f5f6f8; --panel: #ffffff; --ink: #1a1d21; --muted: #6b7280;
  --line: #e5e7eb; --accent: #2563eb; --green: #16a34a; --amber: #d97706;
  --red: #dc2626; --radius: 10px;
}
html[data-theme="dark"] {
  --bg: #0e1116; --panel: #161b22; --ink: #e6e8eb; --muted: #98a2ad;
  --line: #272d36; --accent: #4c8dff;
  color-scheme: dark;
}
html[data-theme="dark"] .drop-hint { background: #12171e; border-color: #2c333d; }
html[data-theme="dark"] .frow input,
html[data-theme="dark"] .filterbar input,
html[data-theme="dark"] .filterbar select,
html[data-theme="dark"] .queuebar select,
html[data-theme="dark"] .filterbar button { background: #10151b; border-color: #2c333d; color: var(--ink); }
html[data-theme="dark"] .frow input:focus,
html[data-theme="dark"] .filterbar input:focus { background: #10151b; }
html[data-theme="dark"] table.items input { color: var(--ink); }
html[data-theme="dark"] table.queue tr:hover td { background: #1a2028; }
html[data-theme="dark"] table.items td { border-bottom-color: #20262e; }
html[data-theme="dark"] .tech { background: #1c232c; border-color: #2c333d; color: #a8b3bf; }
html[data-theme="dark"] details.raw pre { background: #10151b; border-color: #2c333d; }
html[data-theme="dark"] .page-wrap { box-shadow: 0 2px 22px rgba(0,0,0,.55); }
html[data-theme="dark"] .modal { box-shadow: 0 18px 70px rgba(0,0,0,.6); }
html[data-theme="dark"] .ctx-doc { background: #12171e; }
html[data-theme="dark"] .brand-logo-text { filter: brightness(1.6); }
html[data-theme="dark"] .btn-export { background: #10241a; }

.controls { display: flex; gap: 8px; align-items: center; }

.sel-all-btn {
  width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--accent);
  background: var(--panel); color: var(--accent); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
  padding: 0;
}
.sel-all-btn:hover { box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.sel-all-btn .sel-all-dash { display: none; }
.sel-all-btn.some .sel-all-check { display: none; }
.sel-all-btn.some .sel-all-dash { display: block; }
.sel-all-btn.some, .sel-all-btn.all {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.sel-all-btn.some:hover, .sel-all-btn.all:hover { box-shadow: 0 0 0 3px rgba(37,99,235,.25); }
.th-actions { white-space: nowrap; text-align: center; position: relative; }
.th-actions > span { margin-right: 4px; }

.chip-drop { display: inline-block; position: static; vertical-align: middle; }
.chip-drop .chip-btn { display: inline-flex; align-items: center; gap: 4px; }
.chip-drop-arrow { transition: transform .2s; flex-shrink: 0; }
.chip-drop.open .chip-drop-arrow { transform: rotate(180deg); }
.chip-drop-menu {
  position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 40;
  min-width: 140px; padding: 4px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel);
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
  animation: chipDropIn .15s ease;
}
@keyframes chipDropIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-4px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.chip-drop-item {
  display: block; width: 100%; padding: 7px 12px;
  border: none; background: none; color: var(--fg);
  font-size: .82rem; text-align: left; border-radius: 6px;
  cursor: pointer; transition: background .1s;
}
.chip-drop-item:hover { background: var(--hover, rgba(0,0,0,.05)); }
.chip-drop-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.sepa-fab { position: fixed; bottom: 24px; right: 88px; z-index: 900;
  height: 52px; border-radius: 26px; padding: 0 20px;
  font-size: .85rem; font-weight: 600; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(37,99,235,.35);
  transition: opacity .2s, transform .2s, box-shadow .15s; }
.sepa-fab:hover { transform: scale(1.04); box-shadow: 0 6px 22px rgba(37,99,235,.45); }
.sepa-fab:disabled { opacity: 0; pointer-events: none; transform: scale(.9); }
.sepa-fab:not(:disabled) { opacity: 1; transform: scale(1); }
.settings-btn { position: fixed; bottom: 86px; right: 24px; z-index: 895;
  width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.12);
  display: flex; align-items: center; justify-content: center;
  transition: bottom .28s ease, border-color .15s, color .15s; }
.settings-btn svg { width: 22px; height: 22px; display: block; }
.settings-btn:hover { border-color: var(--accent); color: var(--accent); }
.settings-pop { position: fixed; right: 24px; z-index: 950;
  min-width: 210px; padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); box-shadow: 0 10px 30px rgba(0,0,0,.18);
  opacity: 0; pointer-events: none; transform: translateY(8px) scale(.96);
  transform-origin: bottom right;
  transition: opacity .18s ease, transform .18s ease; }
.settings-pop.open { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }
.settings-pop .lang-switch { display: flex; width: 100%; border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; }
.settings-pop .lang-switch button { flex: 1; border: none; border-radius: 0;
  padding: 7px 0; font-size: 12px; background: transparent; color: var(--muted);
  font-weight: 600; }
.settings-pop .lang-switch button.active { background: var(--accent); color: #fff; }
.settings-theme-row { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.settings-theme-row .theme-btn { border: 1px solid var(--line); background: var(--bg);
  border-radius: 8px; padding: 4px 10px; font-size: 13px; cursor: pointer; }
.settings-theme-row .theme-btn:hover { border-color: var(--accent); }
html[data-theme="dark"] .settings-pop { box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.nav-toggle { display: block; font-size: 18px; line-height: 1; padding: 6px 10px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); cursor: pointer; }
.nav-pop { position: fixed; z-index: 950;
  min-width: 190px; padding: 8px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); box-shadow: 0 10px 30px rgba(0,0,0,.18); display: flex;
  flex-direction: column; }
.nav-pop[hidden] { display: none; }
.nav-pop .navlink { padding: 9px 12px; border-radius: 8px; font-size: 13.5px; }
.nav-pop .navlink:hover { background: rgba(37,99,235,.08); }
.nav-pop .navlink.current { background: rgba(37,99,235,.10); color: var(--accent); }
.nav-pop .navlink.current::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); margin-right: 8px; vertical-align: 2px; }
header .actions { position: relative; }
.view-controls { position: fixed; left: 14px; top: 72px; z-index: 880;
  display: flex; flex-direction: column; gap: 10px; }
header .actions .navlink { display: none !important; }
.busy-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .38); z-index: 990;
  display: flex; align-items: center; justify-content: center; }
.busy-overlay[hidden] { display: none; }
.busy-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 28px; display: flex; align-items: center; gap: 14px;
  box-shadow: 0 14px 48px rgba(0,0,0,.25); font-size: 14px; color: var(--ink); }
.busy-spinner { width: 22px; height: 22px; flex-shrink: 0; border: 3px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%; animation: busy-spin .8s linear infinite; }
@keyframes busy-spin { to { transform: rotate(360deg); } }
.back-btn, .nav-toggle { width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: border-color .15s, color .15s;
  box-shadow: 0 2px 8px rgba(0,0,0,.10); }
.nav-toggle { font-size: 16px; }
.back-btn svg { width: 18px; height: 18px; display: block; }
.back-btn svg { width: 18px; height: 18px; display: block; }
.back-btn:hover { border-color: var(--accent); color: var(--accent); }


.lang-switch { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang-switch button { border: none; border-radius: 0; padding: 6px 9px; font-size: 12px;
  background: transparent; color: var(--muted); font-weight: 600; }
.lang-switch button.active { background: var(--accent); color: #fff; }
.lang-switch button:hover:not(.active) { background: transparent; color: var(--ink); }
.theme-btn { padding: 6px 10px; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink);
  display: flex; flex-direction: column;
}
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line);
  flex-wrap: wrap; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 17px; margin: 0; font-weight: 650; }
.brand-logo { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand-logo-icon { height: 28px; width: auto; }
.brand-logo-text { height: 16px; width: auto; }
.badge {
  font-size: 11px; color: var(--green); background: #ecfdf5;
  border: 1px solid #a7f3d0; padding: 2px 8px; border-radius: 999px; font-weight: 600;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
button {
  font: inherit; font-size: 13px; padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); cursor: pointer; color: var(--ink);
}
button:hover:not(:disabled) { border-color: #cbd2da; background: #f9fafb; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #1d4ed8; }

main { flex: 1; display: flex; min-height: 0; }
.pane { overflow: auto; }
.pane.left {
  flex: 1.1; padding: 14px 18px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.pane.left.drag { outline: 2px dashed var(--accent); outline-offset: -10px; background: #eef4ff; }
.pane.right {
  flex: 1; max-width: 580px; min-width: 420px; border-left: 1px solid var(--line);
  padding: 16px 18px 28px;
}
/* review screen: the PDF side keeps clear of the floating back/menu stack (left),
   the form can scroll its last rows above the language and chat buttons (right) */
.pane.left { padding-left: 70px; }
.pane.right { padding-bottom: 150px; }
@media (max-width: 500px) { .pane.left { padding-left: 62px; } }

.drop-hint {
  margin-top: 10vh; text-align: center; color: var(--muted);
  border: 2px dashed #cbd2da; border-radius: 14px; padding: 54px 40px; background: #fafbfc;
  width: 100%; max-width: 640px;
}
.drop-hint.slim { margin-top: 24px; padding: 40px 30px; }
.drop-hint .big { font-size: 17px; font-weight: 650; color: var(--ink); margin-bottom: 8px; }
.drop-hint .small { font-size: 13px; line-height: 1.6; }
.samples { margin-top: 18px; font-size: 13px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; align-items: center; }

.zoombar {
  display: flex; gap: 4px; position: sticky; top: 8px; z-index: 5;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 3px;
  align-self: flex-end;
}
.zoombar button { font-size: 12px; padding: 3px 10px; border: none; background: none; }

.pages { display: flex; flex-direction: column; gap: 16px; width: 100%; align-items: center; }
.page-wrap { position: relative; box-shadow: 0 2px 14px rgba(0,0,0,.12); border-radius: 4px; background: #fff; max-width: 100%; }
.anno-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.anno-svg rect { fill: rgba(37, 99, 235, 0.13); stroke: #1d4ed8; stroke-width: 0.9; }
.anno-svg rect.anno-item { fill: rgba(22, 163, 74, 0.13); stroke: #15803d; }
.anno-svg rect.anno-total { fill: rgba(217, 119, 6, 0.15); stroke: #b45309; }
.anno-svg rect.hot { stroke-width: 2.4; fill-opacity: 0.32; }
.anno-svg text.anno-num { font-size: 6px; font-weight: 700; paint-order: stroke;
  stroke: rgba(0,0,0,0.45); stroke-width: 0.35; }
.anno-svg text.anno-field { fill: #93c5fd; }
.anno-svg text.anno-item { fill: #86efac; }
.anno-svg text.anno-total { fill: #fcd34d; }
.anno-svg .kind-off { display: none; }
.text-layer { position: absolute; top: 0; left: 0; transform-origin: 0 0; z-index: 1; line-height: 1; cursor: text;
  white-space: pre; color: transparent; font-size: 1px; font-family: Helvetica, Arial, sans-serif; }
.text-layer span { position: absolute; color: transparent; white-space: pre; transform-origin: 0 0; border-radius: 1px; }
.text-layer span:hover { background: rgba(37, 99, 235, .10); }
.text-layer span.copied { background: rgba(22, 163, 74, .28); transition: background .2s; }
.text-layer ::selection { background: rgba(37, 99, 235, .30); color: transparent; }
.copy-toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(8px); opacity: 0;
  background: #111827; color: #fff; font-size: 13px; padding: 8px 14px; border-radius: 999px; z-index: 50;
  pointer-events: none; transition: opacity .15s, transform .15s; max-width: 70vw; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.copy-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.copy-hint { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.kindbtn { font-size: 12px; padding: 4px 9px; }
.kindbtn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-wrap img { display: block; border-radius: 4px; max-width: 100%; height: auto; }
.pagenum {
  position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.65); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
}

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 14px;
}
.card h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 0 0 10px; font-weight: 700;
}
.frow { display: grid; grid-template-columns: 150px 1fr 14px; gap: 10px; align-items: center; margin-bottom: 8px; }
.frow label { font-size: 13px; color: var(--muted); }
.frow input {
  font: inherit; font-size: 13.5px; padding: 6px 9px; border: 1px solid var(--line);
  border-radius: 7px; width: 100%; background: #fbfcfd;
}
.frow input:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); background: #fff; }
.dot { width: 9px; height: 9px; border-radius: 50%; }
.dot.high { background: var(--green); }
.dot.med { background: var(--amber); }
.dot.low { background: var(--red); }
.dot.none { background: #d1d5db; }

.banner { border-radius: var(--radius); padding: 11px 14px; font-size: 13px; margin-bottom: 12px; border: 1px solid; line-height: 1.5; }
.banner.ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.banner.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.banner.bad { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.banner.pending { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; display: flex; align-items: center; gap: 10px; }
.banner.pending .busy-spinner { width: 16px; height: 16px; border-width: 2px; }
html[data-theme="dark"] .banner.pending { background: rgba(76,141,255,.10); border-color: rgba(76,141,255,.35); color: #bfdbfe; }

.meta { font-size: 12.5px; color: var(--muted); line-height: 1.7; margin-bottom: 14px; }
.meta b { color: var(--ink); font-weight: 600; }
.err { color: var(--red); }

table.items { width: 100%; border-collapse: collapse; font-size: 13px; }
table.items th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
  border-bottom: 1px solid var(--line); padding: 4px 6px;
}
table.items th.num, table.items td.num { text-align: right; }
table.items th:last-child, table.items td:last-child { width: 28px; text-align: center; padding: 1px 2px; }
table.items td { padding: 1px 3px; border-bottom: 1px solid #f1f3f5; }
table.items input {
  font: inherit; font-size: 13px; border: 1px solid transparent; background: transparent;
  width: 100%; padding: 5px 6px; border-radius: 6px;
}
table.items input:hover { border-color: var(--line); background: #fbfcfd; }
table.items input:focus { outline: 2px solid #bfdbfe; background: #fff; }
.rowbtns { display: flex; gap: 6px; margin-top: 8px; }
.rowbtns button { font-size: 12px; padding: 4px 10px; }
.del { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 2px; }
.del:hover { color: var(--red); }

.loader { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 16vh; color: var(--muted); }
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

details.raw { margin-top: 4px; }
details.raw pre {
  font-size: 11px; background: #f8f9fa; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; overflow: auto; max-height: 260px; white-space: pre-wrap; word-break: break-word;
}

.navlink { font-size: 13px; color: var(--accent); text-decoration: none; font-weight: 600; padding: 7px 10px; }
.navlink:hover { text-decoration: underline; }

main.wide { display: block; padding: 18px; max-width: 1400px; margin: 0 auto; width: 100%; }
/* keep content clear of the floating back/menu stack (left) and globe/chat (right) */
@media (min-width: 761px) { main.wide { padding-left: 80px; padding-right: 80px; max-width: 1560px; } }
@media (max-width: 760px) { main.wide { padding-left: 64px; } }
.queuebar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.queuebar h2 { margin: 0; }
.queuebar select { font: inherit; font-size: 13px; padding: 5px 8px; border-radius: 7px; border: 1px solid var(--line); background: #fff; }
.q-search { font: inherit; font-size: 13px; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 7px; background: #fbfcfd; width: 220px; }
.q-search:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); background: #fff; }
.q-status-select { font: inherit; font-size: 13px; padding: 6px 8px; border-radius: 7px;
  border: 1px solid var(--line); background: #fbfcfd; }
.q-table-wrap { overflow-x: auto; }
.q-filter-btn { position: relative; width: 36px; height: 36px; padding: 0; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: all .15s; flex-shrink: 0; }
.q-filter-btn svg { width: 16px; height: 16px; display: block; }
.q-filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.q-filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.q-filter-badge { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px;
  border-radius: 999px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 4px; line-height: 1; }
.q-filter-btn.active .q-filter-badge { background: #fff; color: var(--accent); }
.q-filter-pop { position: absolute; top: calc(100% + 8px); right: 0; z-index: 50;
  width: 320px; padding: 16px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); box-shadow: 0 10px 30px rgba(0,0,0,.18);
  animation: qfIn .15s ease; }
.q-filter-pop[hidden] { display: none; }
@keyframes qfIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.qf-grid { display: flex; flex-direction: column; gap: 10px; }
.qf-field label { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.qf-field input { font: inherit; font-size: 13px; padding: 7px 9px; border: 1px solid var(--line);
  border-radius: 7px; background: #fbfcfd; width: 100%; }
.qf-field input:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); background: #fff; }
.qf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.qf-actions { display: flex; gap: 8px; margin-top: 4px; }
.qf-actions button { flex: 1; }
html[data-theme="dark"] .q-filter-pop { box-shadow: 0 10px 30px rgba(0,0,0,.5); }
html[data-theme="dark"] .qf-field input { background: #10151b; border-color: #2c333d; color: var(--ink); }
html[data-theme="dark"] .q-search, html[data-theme="dark"] .q-status-select {
  background: #10151b; border-color: #2c333d; color: var(--ink); }
table.queue { width: 100%; border-collapse: collapse; font-size: 13px; }
table.queue th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--line); padding: 6px 8px;
  hyphens: auto; -webkit-hyphens: auto; }  /* 'Rechnungs-datum' may wrap so the row actions fit at laptop width */
table.queue th.num, table.queue td.num { text-align: right; }
table.queue td { padding: 7px 8px; border-bottom: 1px solid #f1f3f5; vertical-align: middle; }
table.queue tr:hover td { background: #fafbfc; }
table.queue th.sel-col { width: 34px; }
table.queue td.supplier-cell { max-width: 250px; word-break: break-word; }
tr.clickable-row { cursor: pointer; transition: background .15s; }
tr.clickable-row:hover td { background: #eef4ff; }
tr.clickable-row:hover td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tr.clickable-row:active td { background: #dbeafe; }
html[data-theme="dark"] tr.clickable-row:hover td { background: rgba(76,141,255,.08); }
html[data-theme="dark"] tr.clickable-row:active td { background: rgba(76,141,255,.14); }
.chip { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.chip-new { background: #eff6ff; color: #1d4ed8; }
.chip-ok { background: #ecfdf5; color: #047857; }
.chip-muted { background: #f3f4f6; color: #6b7280; }
.dup { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; border-radius: 6px; padding: 1px 6px; font-weight: 600; font-size: 11px; }
.actions-cell { display: flex; gap: 4px; align-items: center; }
.actions-cell button { font: inherit; font-size: 12.5px; padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer;
  transition: color .15s, border-color .15s; }
.actions-cell button:hover { border-color: var(--accent); color: var(--accent); }
.actions-cell button.danger:hover { border-color: var(--red); color: var(--red); }
.btn-link { font-size: 13px; color: var(--accent); text-decoration: none; font-weight: 600; padding: 4px 6px; }
.btn-link:hover { text-decoration: underline; }
.muted { color: var(--muted); }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.fnum-warn { background: var(--amber); }
.fnum-bad { background: var(--red); }
.fnum { display: inline-block; min-width: 14px; text-align: center; background: var(--accent);
  color: #fff; border-radius: 4px; font-size: 10px; font-weight: 700; padding: 1px 3px;
  margin-left: 2px; vertical-align: 1px; }
.toast { font-size: 13px; color: var(--green); font-weight: 600; }

/* filter bar */
.filterbar { display: grid; grid-template-columns: 2fr 1fr 1fr 130px 130px 90px 90px 110px auto; gap: 8px; }
.filterbar input, .filterbar select {
  font: inherit; font-size: 13px; padding: 7px 9px; border: 1px solid var(--line);
  border-radius: 7px; background: #fbfcfd; min-width: 0;
}
.filterbar input:focus, .filterbar select:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); background: #fff; }
@media (max-width: 1100px) { .filterbar { grid-template-columns: 1fr 1fr; } }

.btn-export { font: inherit; font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--green); color: var(--green); text-decoration: none; background: #f0fdf4; }
.btn-export:hover { background: #dcfce7; }

/* context modal */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 720px;
  max-height: 84vh; overflow: auto; padding: 18px 20px; box-shadow: 0 18px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 16px; }
.ctx-doc { padding: 10px 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px; font-size: 13.5px; }
.ctx-step { margin-bottom: 6px; }
.ctx-arrow { font-size: 12px; color: var(--amber); font-weight: 600; margin: 4px 0 4px 10px; }
.ctx-mail { border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font-size: 13px; }
.ctx-mail-head { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.ctx-actions { margin-top: 6px; display: flex; gap: 10px; }

/* system overview */
.flow { display: flex; flex-direction: column; gap: 0; max-width: 860px; }
.stage { display: flex; gap: 14px; align-items: stretch; }
.stage-rail { display: flex; flex-direction: column; align-items: center; width: 34px; flex-shrink: 0; }
.stage-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 18px; }
.stage-dot.live { background: var(--green); } .stage-dot.ready { background: var(--amber); } .stage-dot.planned { background: #cbd5e1; }
.stage-line { width: 2px; flex: 1; background: var(--line); }
.stage:last-child .stage-line { display: none; }
.stage-box { flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px; margin-bottom: 14px; }
.stage-box h3 { margin: 0 0 4px; font-size: 14.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stage-box p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.stage-box .chips { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.tech { font-size: 11px; background: #f1f5f9; border: 1px solid #e2e8f0; color: #475569;
  border-radius: 999px; padding: 1px 8px; font-weight: 600; }
.st-live { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; padding: 2px 8px; border-radius: 999px;
  background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.st-ready { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; padding: 2px 8px; border-radius: 999px;
  background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.st-planned { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; padding: 2px 8px; border-radius: 999px;
  background: #f8fafc; color: #64748b; border: 1px solid #e2e8f0; }
.live-stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0 20px; }


.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s; cursor: pointer;
}
.stat:hover { border-color: var(--accent); box-shadow: 0 2px 12px rgba(37,99,235,.1); }
html[data-theme="dark"] .stat:hover { box-shadow: 0 2px 12px rgba(76,141,255,.12); }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }

/* dashboard */
.mcol.clickable { cursor: pointer; }
.mcol.clickable:hover .mbar { filter: brightness(1.15); }
.mcol.clickable:hover .mlab { color: var(--accent); }
.md-summary { display: flex; flex-wrap: wrap; gap: 10px 26px; margin-bottom: 12px;
  padding: 10px 14px; background: var(--bg); border-radius: 10px; }
.md-sum { display: flex; flex-direction: column; font-size: 12.5px; color: var(--muted); }
.md-sum b { font-size: 15px; color: var(--ink); }
.md-table { font-size: 13px; width: 100%; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dash-card { margin-bottom: 0; position: relative; }
.dash-card.wide2 { grid-column: 1 / -1; }
.dash-scroll { max-height: 195px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.dash-scroll::-webkit-scrollbar { width: 5px; }
.dash-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.dash-scroll::-webkit-scrollbar-track { background: transparent; }
.dash-scroll-nav { position: absolute; bottom: 10px; right: 12px; display: flex; gap: 4px; z-index: 2; }
.dash-scroll-nav button { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted); cursor: pointer; display: flex; align-items: center;
  justify-content: center; padding: 0; transition: all .15s; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.dash-scroll-nav button:hover { border-color: var(--accent); color: var(--accent); }
.dash-scroll-nav button[hidden] { display: none; }
.dash-scroll-nav svg { width: 14px; height: 14px; }
.kpi-open b { color: var(--accent); }
.kpi-overdue b, .kpi-alarm b { color: var(--red); }
.aging-row { display: grid; grid-template-columns: 110px 1fr 110px; gap: 10px; align-items: center; margin-bottom: 0; padding: 8px 6px; border-left: 3px solid transparent; border-radius: 6px; cursor: pointer; transition: background .15s, border-color .15s, transform .15s; }
.aging-row:hover { background: #eef4ff; border-left-color: var(--accent); transform: translateX(2px); }
.aging-row:active { background: #dbeafe; }
html[data-theme="dark"] .aging-row:hover { background: rgba(76,141,255,.1); }
html[data-theme="dark"] .aging-row:active { background: rgba(76,141,255,.16); }
.aging-label { font-size: 12.5px; color: var(--muted); }
.aging-track { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; }
.aging-fill { height: 100%; border-radius: 999px; }
.bar-red { background: var(--red); } .bar-amber { background: var(--amber); }
.bar-blue { background: var(--accent); } .bar-green { background: var(--green); }
.aging-val { font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.mchart { display: flex; align-items: flex-end; gap: 14px; height: 150px; padding-top: 8px; }
.mcol { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.mbar-pair { display: flex; align-items: flex-end; gap: 3px; width: 100%; max-width: 64px; }
.mbar-col { display: flex; flex-direction: column; align-items: center; flex: 1; gap: 2px; }
.mbar { border-radius: 4px 4px 2px 2px; width: 100%; }
.mval-vat { color: #d97706; }
.mbar-total { background: linear-gradient(180deg, var(--accent), #6d9bff); }
.mbar-vat { background: linear-gradient(180deg, #f59e0b, #fbbf24); }
html[data-theme="dark"] .mbar-total { background: linear-gradient(180deg, #6d9bff, #2f5cc0); }
html[data-theme="dark"] .mbar-vat { background: linear-gradient(180deg, #d97706, #b45309); }
.mchart-legend { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.mchart-dot { width: 10px; height: 10px; border-radius: 3px; margin-left: 8px; }
.mchart-dot:first-child { margin-left: 0; }
.mchart-dot-total { background: var(--accent); }
.mchart-dot-vat { background: #f59e0b; }
.mval { font-size: 11px; color: var(--muted); }
.mlab { font-size: 11px; color: var(--muted); }
.sup-row { display: grid; grid-template-columns: 150px 1fr 96px; gap: 10px; align-items: center; margin-bottom: 0; padding: 8px 6px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; border-radius: 6px; cursor: pointer; transition: background .15s, border-color .15s, transform .15s; }
.sup-row:last-child { border-bottom: none; }
.sup-row:hover { background: #eef4ff; border-left-color: var(--accent); transform: translateX(2px); }
.sup-row:active { background: #dbeafe; }
html[data-theme="dark"] .sup-row:hover { background: rgba(76,141,255,.1); }
html[data-theme="dark"] .sup-row:active { background: rgba(76,141,255,.16); }
.sup-name { font-size: 12.5px; }
.sup-track { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.sup-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #7ea8f5); border-radius: 999px; }
.sup-val { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.watch-row { display: flex; gap: 10px; align-items: center; padding: 7px 6px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; border-radius: 6px; font-size: 13px; flex-wrap: wrap; cursor: pointer; transition: background .15s, border-color .15s, transform .15s; }
.watch-row:last-child { border-bottom: none; }
.watch-row:hover { background: #eef4ff; border-left-color: var(--accent); transform: translateX(2px); }
.watch-row:active { background: #dbeafe; }
html[data-theme="dark"] .watch-row:hover { background: rgba(76,141,255,.1); }
html[data-theme="dark"] .watch-row:active { background: rgba(76,141,255,.16); }
.watch-bad { background: #fef5f5; border-radius: 6px; padding-left: 6px; }
html[data-theme="dark"] .watch-bad { background: rgba(220, 38, 38, 0.08); }
.watch-amount { margin-left: auto; font-variant-numeric: tabular-nums; }
.watch-due { color: var(--muted); }
.watch-msg { flex: 1; font-size: 12.5px; line-height: 1.4; min-width: 0; }
.ok-line { color: var(--green); font-weight: 600; font-size: 13px; }
.wd-actions { display: flex; gap: 6px; flex-shrink: 0; }
.wd-btn { display: inline-flex; align-items: center; gap: 3px; padding: 3px 9px; border-radius: 6px;
  border: 1px solid var(--line); background: none; font: inherit; font-size: 11.5px;
  cursor: pointer; color: var(--muted); transition: all .15s; }
.wd-btn:hover { border-color: currentColor; }
.wd-btn-safe:hover, .wd-btn-safe.active { color: #15803d; border-color: #86efac; background: #f0fdf4; }
.wd-btn-threat:hover, .wd-btn-threat.active { color: #dc2626; border-color: #fca5a5; background: #fef2f2; }
html[data-theme="dark"] .wd-btn-safe:hover, html[data-theme="dark"] .wd-btn-safe.active { background: rgba(21,128,61,.12); border-color: #166534; }
html[data-theme="dark"] .wd-btn-threat:hover, html[data-theme="dark"] .wd-btn-threat.active { background: rgba(220,38,38,.1); border-color: #991b1b; }
.wd-safe { opacity: .55; }
.wd-threat { background: #fef2f2; border-radius: 6px; padding-left: 6px; }
html[data-theme="dark"] .wd-threat { background: rgba(220, 38, 38, 0.08); }
.wd-history-link { display: block; margin-top: 12px; font-size: 12.5px; color: var(--accent); text-decoration: none; font-weight: 500; }
.wd-history-link:hover { text-decoration: underline; }
.wd-open { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 12px; margin-right: 10px; white-space: nowrap; }
.wd-open:hover { text-decoration: underline; }
.wd-more { color: var(--text2, #6b7280); font-size: 11.5px; font-weight: 600; }
.wd-page-tabs { display: flex; gap: 4px; }
.wd-tab { font: inherit; font-size: 13.5px; font-weight: 600; padding: 8px 18px; border-radius: 8px;
  border: 1px solid var(--line); background: none; cursor: pointer; color: var(--muted);
  transition: all .15s; }
.wd-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.wd-tab:hover:not(.active) { background: rgba(37,99,235,.06); }
.wd-detail-row { padding: 16px; border-bottom: 1px solid var(--line); }
.wd-detail-row:last-child { border-bottom: none; }
.wd-detail-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.wd-detail-sev { font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.wd-sev-high { color: var(--red); } .wd-sev-medium { color: #d97706; } .wd-sev-low { color: var(--muted); }
.wd-ack-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.wd-ack-safe { background: #f0fdf4; color: #15803d; }
.wd-ack-threat { background: #fef2f2; color: #dc2626; }
html[data-theme="dark"] .wd-ack-safe { background: rgba(21,128,61,.12); }
html[data-theme="dark"] .wd-ack-threat { background: rgba(220,38,38,.1); }
.wd-detail-body { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; font-size: 13px; }
.wd-detail-field { display: flex; gap: 8px; }
.wd-label { color: var(--muted); min-width: 100px; flex-shrink: 0; }
.wd-detail-desc { grid-column: 1 / -1; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.wd-log-row { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.wd-log-row:last-child { border-bottom: none; }
.wd-log-header { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.wd-log-ts { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.wd-log-desc { margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.chip-warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.ask-row { display: flex; gap: 8px; }
.ask-row input { flex: 1; font: inherit; font-size: 13.5px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; }
.ask-row input:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }
.ask-out { margin-top: 10px; padding: 10px 12px; background: #f8f9fb; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; line-height: 1.55; }
html[data-theme="dark"] .ask-out { background: #12171e; }
.kpi-alarm { border-color: var(--red); }
#ledger-table th:first-child { width: 26px; }

@media (max-width: 900px) {
  main { flex-direction: column; }
  .pane.right { max-width: none; min-width: 0; border-left: none; border-top: 1px solid var(--line); }
  .dash-grid { grid-template-columns: 1fr; }
}
.chips-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn { font-size: 12px; padding: 5px 12px; border-radius: 999px; }
.chip-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-open { background: #eff6ff; color: #1d4ed8; }
.chip-overdue { background: #fef2f2; color: #991b1b; }
.overdue-text { color: var(--red); font-weight: 600; }
.pay-form { display: flex; flex-direction: column; gap: 6px; }
.pay-form label { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.pay-form input { font: inherit; font-size: 13.5px; padding: 7px 9px; border: 1px solid var(--line);
  border-radius: 7px; background: #fbfcfd; width: 100%; }
.pay-form input:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }
.modal-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.modal-actions .spacer { flex: 1; }
#ledger-table th.sortable { cursor: pointer; user-select: none; }
#ledger-table th.sortable:hover { color: var(--ink); }

/* sepa selection list in modal */
.sepa-list { max-height: 180px; overflow-y: auto; scrollbar-width: thin; border: 1px solid var(--line);
  border-radius: 7px; margin-top: 4px; }
.sepa-item { display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px;
  font-size: 13px; border-bottom: 1px solid var(--line); }
.sepa-item:last-child { border-bottom: none; }
html[data-theme="dark"] .sepa-list { border-color: #2c333d; }

/* payment detail modal */
.pd-modal { max-width: 520px; }
.pd-body { display: flex; flex-direction: column; gap: 16px; }
.pd-fields { display: flex; flex-direction: column; gap: 0; }
.pd-row { display: flex; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pd-row:last-child { border-bottom: none; }
.pd-label { font-size: 12.5px; color: var(--muted); font-weight: 600; width: 100px; flex-shrink: 0; }
.pd-value { font-size: 14px; color: var(--ink); }
.pd-proof-section { display: flex; flex-direction: column; gap: 8px; }
.pd-proof-section > .pd-label { width: auto; }
.pd-proof-frame {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: #f8fafc; min-height: 80px; display: flex; align-items: center; justify-content: center;
}
.pd-proof-frame iframe, .pd-proof-frame img {
  display: block; width: 100%; max-height: 320px; object-fit: contain; border: none;
}
.pd-proof-frame iframe { height: 320px; }
.pd-noproof { font-size: 13px; color: var(--muted); padding: 28px 0; text-align: center; }
html[data-theme="dark"] .pd-proof-frame { background: #10151b; border-color: #2c333d; }
.pd-paid-cell { cursor: pointer; }
.pd-paid-cell:hover { color: var(--accent); }

/* invoice drafter */
.draft-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.draft-section h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.5px; }
.draft-field { margin-bottom: 10px; }
.draft-field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.draft-field input, .draft-field textarea, .draft-field select {
  font: inherit; font-size: 13.5px; padding: 7px 9px; border: 1px solid var(--line);
  border-radius: 7px; background: #fbfcfd; width: 100%; }
.draft-field input:focus, .draft-field textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }
.draft-field textarea { resize: vertical; min-height: 60px; }
html[data-theme="dark"] .draft-field input,
html[data-theme="dark"] .draft-field textarea,
html[data-theme="dark"] .draft-field select { background: #10151b; border-color: #2c333d; color: var(--ink); }
.draft-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px;
  margin-bottom: 24px; }
table.draft-items { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 16px; }
table.draft-items th { text-align: left; font-size: 11.5px; color: var(--muted); padding: 6px 8px;
  border-bottom: 2px solid var(--line); text-transform: uppercase; letter-spacing: 0.3px; }
table.draft-items td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.draft-items input { font: inherit; font-size: 13px; padding: 5px 7px; border: 1px solid var(--line);
  border-radius: 5px; background: #fbfcfd; width: 100%; }
table.draft-items input:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }
html[data-theme="dark"] table.draft-items input { background: #10151b; border-color: #2c333d; color: var(--ink); }
table.draft-items .num { text-align: right; }
table.draft-items .col-desc { min-width: 200px; }
table.draft-items .col-qty, table.draft-items .col-unit { width: 70px; }
table.draft-items .col-price, table.draft-items .col-vat { width: 90px; }
table.draft-items .col-amount { width: 110px; }
table.draft-items .col-del { width: 40px; text-align: center; }
.draft-totals { display: flex; justify-content: flex-end; }
.draft-totals table { font-size: 14px; min-width: 260px; }
.draft-totals td { padding: 5px 10px; }
.draft-totals .total-row { font-weight: 700; font-size: 16px; border-top: 2px solid var(--ink); }
.draft-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding-top: 16px;
  border-top: 1px solid var(--line); }
.draft-actions .spacer { flex: 1; }
.pane.right > .draft-fromtext, .pane.right > .draft-grid, .pane.right > .draft-meta,
.pane.right > .draft-items, .pane.right > .draft-totals, .pane.right > .draft-actions,
.pane.right > #suggest-box { max-width: 100%; }

/* live invoice preview (A4 paper) */
.invoice-preview {
  width: 100%; max-width: 595px; min-height: 842px;
  background: #fff; color: #1a1d21;
  box-shadow: 0 2px 14px rgba(0,0,0,.12); border-radius: 4px;
  padding: 48px 50px 40px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 11px; line-height: 1.45; position: relative;
}
html[data-theme="dark"] .invoice-preview { box-shadow: 0 2px 22px rgba(0,0,0,.55); }
.inv-p-company { font-size: 22px; font-weight: 700; margin: 0 0 6px; }
.inv-p-from-line { font-size: 9.5px; color: #777; margin-bottom: 3px; }
.inv-p-header { display: flex; gap: 24px; margin-top: 16px; margin-bottom: 8px; }
.inv-p-to { flex: 1; }
.inv-p-to-name { font-weight: 700; font-size: 12px; margin-bottom: 4px; }
.inv-p-to-line { font-size: 11px; color: #333; margin-bottom: 2px; }
.inv-p-meta { text-align: right; min-width: 160px; }
.inv-p-meta-invno { font-weight: 700; font-size: 11px; margin-bottom: 4px; }
.inv-p-meta-line { font-size: 10px; color: #555; margin-bottom: 2px; }
.inv-p-table { width: 100%; border-collapse: collapse; margin-top: 20px; font-size: 10px; }
.inv-p-table thead th { background: #f5f6f8; padding: 5px 6px; font-weight: 600; font-size: 9px;
  text-transform: uppercase; letter-spacing: 0.3px; border-bottom: 1px solid #ddd; text-align: left; }
.inv-p-table thead th.r { text-align: right; }
.inv-p-table tbody td { padding: 4px 6px; border-bottom: 1px solid #eee; }
.inv-p-table tbody td.r { text-align: right; }
.inv-p-totals { margin-top: 12px; display: flex; justify-content: flex-end; }
.inv-p-totals table { font-size: 11px; min-width: 200px; }
.inv-p-totals td { padding: 3px 8px; }
.inv-p-totals td.r { text-align: right; }
.inv-p-totals .grand { font-weight: 700; font-size: 13px; border-top: 2px solid #222; }
.inv-p-notes { margin-top: 16px; font-size: 9.5px; color: #666; white-space: pre-wrap; }
.inv-p-bank { position: absolute; bottom: 32px; left: 50px; right: 50px;
  font-size: 8.5px; color: #999; border-top: 1px solid #ddd; padding-top: 6px; }
.inv-p-empty { color: #bbb; font-style: italic; }
.draft-fromtext { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.draft-fromtext h3 { margin: 0 0 8px; }
.draft-fromtext textarea { width: 100%; font: inherit; font-size: 13px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink);
  resize: vertical; }
.draft-fromtext .chips-row { margin-bottom: 8px; }
.draft-suggest { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); font-size: 13px; }
.draft-suggest h4 { margin: 0 0 8px; font-size: 13px; }
.draft-suggest .sg-row { margin-bottom: 6px; }
.draft-suggest .sg-note { white-space: pre-wrap; margin: 6px 0; color: var(--ink); }
.draft-suggest .sg-btn { font: inherit; font-size: 12px; padding: 3px 10px; margin-left: 8px;
  border-radius: 6px; border: 1px solid var(--accent); background: transparent;
  color: var(--accent); cursor: pointer; }
.draft-suggest .sg-btn:hover { background: var(--accent); color: #fff; }
@media (max-width: 700px) {
  .draft-grid { grid-template-columns: 1fr; }
  .draft-meta { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  main { flex-direction: column; }
  .pane.right { max-width: none; min-width: 0; border-left: none; border-top: 1px solid var(--line); }
}

/* ---- draft intro screen ---- */
.draft-intro {
  flex: 1; display: flex; justify-content: center; padding: 40px 24px 60px;
  overflow-y: auto; background: var(--bg);
}
.intro-inner { max-width: 920px; width: 100%; }
.intro-head { text-align: center; margin-bottom: 32px; }
.intro-head h2 { font-size: 24px; font-weight: 700; margin: 0 0 8px; }
.intro-head p { font-size: 14px; color: var(--muted); margin: 0; }

.intro-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 40px;
}
.intro-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 18px 16px; display: flex; flex-direction: column; gap: 12px;
  transition: border-color .15s, box-shadow .15s;
}
.intro-card:hover { border-color: var(--accent); box-shadow: 0 4px 20px rgba(37,99,235,.1); }
html[data-theme="dark"] .intro-card:hover { box-shadow: 0 4px 20px rgba(76,141,255,.12); }
.intro-card-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(37,99,235,.08); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.intro-card-scratch .intro-card-icon {
  background: rgba(22,163,74,.08); color: var(--green); font-size: 22px;
}
.intro-card-body { flex: 1; }
.intro-card-body h4 { margin: 0 0 4px; font-size: 14px; font-weight: 650; }
.intro-card-desc { font-size: 12.5px; color: var(--muted); line-height: 1.45; margin: 0; }
.intro-card-meta {
  display: flex; flex-wrap: wrap; gap: 8px; font-size: 11.5px; color: var(--muted);
  margin-top: 8px;
}
.intro-card-meta span { background: var(--bg); padding: 2px 8px; border-radius: 6px; }
.intro-card-clickable { cursor: pointer; }

/* ---- template detail view ---- */
.tpl-detail {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px 28px 24px; max-width: 640px; margin: 0 auto 40px;
  position: relative;
}
.tpl-detail-back {
  position: absolute; top: 16px; left: 16px;
  font: inherit; font-size: 18px; background: none; border: none;
  color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.tpl-detail-back:hover { color: var(--ink); background: var(--bg); }
.tpl-detail-header {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 20px; padding-left: 32px;
}
.tpl-detail-header h3 { margin: 0; font-size: 17px; font-weight: 650; }
.tpl-detail-body { margin-bottom: 16px; }
.tpl-detail-body label {
  display: block; font-size: 11.5px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px;
}
.tpl-detail-body pre {
  font-family: inherit; font-size: 13.5px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; margin: 0; color: var(--ink);
  max-height: 280px; overflow-y: auto;
}
.tpl-detail-meta {
  display: flex; flex-wrap: wrap; gap: 8px; font-size: 11.5px; color: var(--muted);
  margin-bottom: 20px;
}
.tpl-detail-meta span { background: var(--bg); padding: 3px 10px; border-radius: 6px; }
.tpl-detail-use {
  font: inherit; font-size: 14px; padding: 10px 20px; border-radius: 10px;
  border: none; background: var(--accent); color: #fff; cursor: pointer;
  font-weight: 600; width: 100%; transition: background .15s;
}
.tpl-detail-use:hover { background: #1d4ed8; }

/* ---- saved invoice list ---- */
.intro-saved h3 { font-size: 14px; font-weight: 650; margin: 0 0 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.invoice-list { display: flex; flex-direction: column; gap: 6px; }
.intro-empty { font-size: 13px; color: var(--muted); text-align: center; padding: 24px 0; }
.invoice-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; transition: border-color .15s;
}
.invoice-row:hover { border-color: var(--accent); }
.invoice-row-body { flex: 1; min-width: 0; }
.invoice-row-title { font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.invoice-row-meta {
  display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 3px;
}
.invoice-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.invoice-row-actions button {
  font: inherit; font-size: 12px; padding: 5px 12px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--panel); cursor: pointer; color: var(--muted);
  transition: all .15s;
}
.inv-open:hover { border-color: var(--accent); color: var(--accent); }
.inv-del:hover { border-color: var(--red); color: var(--red); }

/* ---- extraction progress steps ---- */
.extract-steps { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.extract-step {
  display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 6px 10px;
  border-radius: 8px; transition: background .2s;
}
.extract-step.active { background: rgba(37,99,235,.06); color: var(--accent); font-weight: 600; }
.extract-step.done { color: var(--green); }
.extract-step.pending { color: var(--muted); }
.extract-step-num {
  width: 22px; height: 22px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.extract-step.active .extract-step-num { background: var(--accent); color: #fff; }
.extract-step.done .extract-step-num { background: var(--green); color: #fff; }
.extract-step.pending .extract-step-num { background: var(--line); color: var(--muted); }



/* duplicates: the same invoice received twice, never paid twice */
tr.dup-row td { opacity: .55; }
tr.dup-row td:first-child, tr.dup-row .actions-cell { opacity: 1; }
.nowrap { white-space: nowrap; }
.banner.dup { background: #f5f3ff; border-color: #ddd6fe; color: #5b21b6; }
html[data-theme="dark"] .banner.dup { background: rgba(139,92,246,.12); border-color: rgba(139,92,246,.35); color: #ddd6fe; }
.banner.dup a { color: inherit; font-weight: 600; margin-left: 6px; }
.banner.tip { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; }
.banner.tip button { display: block; margin-top: 8px; }
html[data-theme="dark"] .banner.tip { background: rgba(76,141,255,.10); border-color: rgba(76,141,255,.35); color: #dbeafe; }

/* AI check: make the second reading visible */
.ai-card { border-color: #c7d2fe; background: linear-gradient(180deg, rgba(99,102,241,.06), transparent 60%), var(--panel); }
.ai-card h2 { display: flex; align-items: center; gap: 6px; }
.ai-spark { color: #6366f1; font-size: 15px; }
.ai-intro { font-size: 13px; color: var(--muted); margin: 0 0 10px; line-height: 1.5; }
.ai-row { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.ai-icon { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0; font-size: 12px; }
.ai-row.fixed .ai-icon { background: #ede9fe; color: #6d28d9; }
.ai-row.added .ai-icon { background: #dbeafe; color: #1d4ed8; }
.ai-row.ok .ai-icon { background: #dcfce7; color: #15803d; }
.ai-items { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 3px; color: var(--fg); }
.ai-items s { color: var(--muted); }
.ai-chip { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: rgba(22,163,74,.10); color: #15803d; }
.ai-badge { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 999px; vertical-align: 1px; white-space: nowrap; }
.ai-badge.ai-ok { background: rgba(22,163,74,.12); color: #15803d; }
.ai-badge.ai-added { background: rgba(37,99,235,.12); color: #1d4ed8; }
.ai-badge.ai-fixed { background: rgba(124,58,237,.14); color: #6d28d9; }
html[data-theme="dark"] .ai-card { border-color: rgba(129,140,248,.35); }
html[data-theme="dark"] .ai-row.fixed .ai-icon, html[data-theme="dark"] .ai-badge.ai-fixed { background: rgba(124,58,237,.25); color: #ddd6fe; }
html[data-theme="dark"] .ai-row.added .ai-icon, html[data-theme="dark"] .ai-badge.ai-added { background: rgba(37,99,235,.25); color: #bfdbfe; }
html[data-theme="dark"] .ai-row.ok .ai-icon, html[data-theme="dark"] .ai-badge.ai-ok, html[data-theme="dark"] .ai-chip { background: rgba(22,163,74,.22); color: #bbf7d0; }
.ai-time { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--muted); }

/* review form: autosave + undo/redo */
.edit-tools { display: flex; align-items: center; gap: 4px; margin-left: 10px; }
.icon-btn { width: 30px; height: 30px; padding: 0; font-size: 16px; line-height: 1; display: inline-flex;
  align-items: center; justify-content: center; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.save-status { font-size: 12px; color: var(--muted); margin-left: 6px; white-space: nowrap; }
.save-status.saved { color: var(--green); }
.save-status.error { color: var(--red); }
.edit-badge { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 999px; white-space: nowrap;
  background: rgba(217,119,6,.14); color: #b45309; vertical-align: 1px; text-transform: none; letter-spacing: 0; }
html[data-theme="dark"] .edit-badge { background: rgba(217,119,6,.25); color: #fde68a; }

/* system page: AI model switch */
.model-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin: 6px 0 10px; }
.model-opt { text-align: left; display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border-radius: 10px;
  border: 2px solid var(--line); background: var(--panel); cursor: pointer; font: inherit; color: var(--fg); }
.model-opt:hover:not(:disabled) { border-color: var(--accent); }
.model-opt.active { border-color: var(--accent); background: rgba(37,99,235,.06); }
.model-opt:disabled { opacity: .55; cursor: default; }
.model-desc { font-size: 12.5px; color: var(--muted); }
.model-status { font-size: 11.5px; font-weight: 700; color: var(--accent); min-height: 14px; }
.model-opt:disabled .model-status { color: var(--muted); }
