/* German OCR — self-contained styles, no CDN (works offline / air-gapped). */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1c2024;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #2f6fdb;
  --accent-ink: #ffffff;
  --ok: #1a7f4b;
  --warn: #9a6700;
  --err: #b42318;
  --err-bg: #fdf3f2;
  --warn-bg: #fff8e6;
  --ok-bg: #f0f9f4;
  --radius: 10px;
}

/* Theme resolution, in precedence order:
     1. no data-theme attribute  -> follow the system (the default)
     2. data-theme="light"       -> stay light even if the system is dark
     3. data-theme="dark"        -> dark regardless of the system
   The dark values are repeated because CSS custom properties cannot be
   aliased across two independent selectors; keep the two blocks in sync. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171a;
    --panel: #1c2024;
    --ink: #e8eaed;
    --muted: #9aa2ad;
    --line: #2c3238;
    --accent: #5b91ea;
    --ok: #4ac585;
    --warn: #e0b64a;
    --err: #f0776b;
    --err-bg: #2a1b1a;
    --warn-bg: #2a2318;
    --ok-bg: #16261e;
  }
}

:root[data-theme="dark"] {
  --bg: #14171a;
  --panel: #1c2024;
  --ink: #e8eaed;
  --muted: #9aa2ad;
  --line: #2c3238;
  --accent: #5b91ea;
  --ok: #4ac585;
  --warn: #e0b64a;
  --err: #f0776b;
  --err-bg: #2a1b1a;
  --warn-bg: #2a2318;
  --ok-bg: #16261e;
}

/* Let form controls and scrollbars follow the resolved theme too. */
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}

* { box-sizing: border-box; }

/* The UA rule for [hidden] is `display: none` at author-agent level, so any
   author `display: flex` below would beat it and leak hidden elements
   (progress bars, action rows). Keep this above everything else. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

h1, h2 { margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.1rem; }
p { margin: .4rem 0; }

/* Fluid: use nearly the full window instead of a fixed 860px column, which
   left most of a wide monitor empty. The cap only stops the line length
   becoming absurd on ultrawides; `min()` keeps a gutter at every size, and the
   min-width floor means the page scrolls rather than collapsing on a tiny
   viewport. Tune --wrap-max if it feels too wide or too narrow. */
:root { --wrap-max: 2400px; }

.wrap {
  width: min(100% - 3rem, var(--wrap-max));
  min-width: 280px;
  margin: 0 auto;
  padding: 1.5rem 0 4rem;
}

@media (max-width: 640px) {
  .wrap { width: min(100% - 1.5rem, var(--wrap-max)); }
}
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

/* --- top bar --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem 1.2rem;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; color: var(--ink); text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.user { color: var(--muted); font-size: .9rem; }

/* Theme switch — fixed width so the label changing (Auto/Hell/Dunkel)
   doesn't shift the rest of the top bar around. */
#theme-toggle {
  min-width: 6.4rem; text-align: center; white-space: nowrap;
  font-size: .82rem; padding: .38rem .6rem;
}

/* Signed-out pages have no top bar; float the switch in the corner. */
.theme-float { position: absolute; top: .9rem; right: 1rem; z-index: 10; }
@media (max-width: 480px) {
  .theme-float { top: .6rem; right: .6rem; }
}

/* --- cards --- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1.1rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* --- login --- */
.login-card {
  max-width: 360px; margin: 12vh auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1.8rem;
}
.login-card h1 { font-size: 1.35rem; text-align: center; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 1.2rem; font-size: .9rem; }
.login-card .hint { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 1rem; }

label { display: block; font-size: .85rem; font-weight: 550; margin: .8rem 0 .3rem; }

input[type=text], input[type=password], select, textarea {
  width: 100%; padding: .55rem .65rem; font: inherit;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 7px;
}
input:focus, select:focus, textarea:focus, .dropzone:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { resize: vertical; }

/* --- buttons --- */
.btn {
  display: inline-block; padding: .5rem .9rem; font: inherit; font-size: .9rem;
  color: var(--ink); background: var(--panel); text-decoration: none;
  border: 1px solid var(--line); border-radius: 7px; cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 550; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); color: var(--accent-ink); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-danger:hover { border-color: var(--err); color: var(--err); }
.btn-block { width: 100%; margin-top: 1.2rem; }

/* --- alerts --- */
.alert { padding: .6rem .8rem; border-radius: 7px; font-size: .9rem; margin: .8rem 0; }
.alert-error { background: var(--err-bg); color: var(--err); border: 1px solid var(--err); }
.alert-warn  { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }
.alert-ok    { background: var(--ok-bg);   color: var(--ok);   border: 1px solid var(--ok); }

/* --- dropzone --- */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 1.8rem 1rem; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.dz-icon { font-size: 1.8rem; }
.dz-main { font-weight: 550; margin: .3rem 0 .1rem; }
.dz-sub { color: var(--muted); font-size: .85rem; margin: 0; }
.dz-file { margin-top: .6rem; font-size: .9rem; color: var(--accent); font-weight: 550; word-break: break-all; }

.row { display: flex; gap: 1rem; align-items: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.field { flex: 1 1 260px; }
.row label { margin-top: 0; }

/* --- job list --- */
.job-list { display: flex; flex-direction: column; gap: .55rem; }
.job {
  display: flex; align-items: center; gap: .8rem;
  padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 8px;
  text-decoration: none; color: var(--ink); background: var(--bg);
}
.job:hover { border-color: var(--accent); }
.job-main { flex: 1; min-width: 0; }
.job-name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-meta { font-size: .8rem; color: var(--muted); }

.badge {
  font-size: .75rem; padding: .18rem .5rem; border-radius: 99px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
/* Which model ran — informational, so it must not compete with the status. */
.badge-quiet   { color: var(--muted); border-color: var(--line); font-weight: 400; }
.badge.done    { color: var(--ok);   border-color: var(--ok); }
.badge.error   { color: var(--err);  border-color: var(--err); }
.badge.running { color: var(--accent); border-color: var(--accent); }

/* --- progress --- */
.progress-wrap { display: flex; align-items: center; gap: .7rem; margin: .8rem 0; }
.progress { flex: 1; height: 7px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s ease; }
.job .progress { width: 110px; flex: none; }

.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }

/* --- results --- */
.page-block { margin-top: 1.2rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .35rem; }
.page-head h3 { font-size: .85rem; color: var(--muted); margin: 0; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
pre.result {
  margin: 0; padding: .85rem; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px;
  white-space: pre-wrap; word-break: break-word;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  max-height: 460px; overflow: auto;
}
.back { color: var(--muted); text-decoration: none; font-size: .9rem; }
.back:hover { color: var(--accent); }

/* --- password page --- */
.pw-card { max-width: 460px; margin: 0 auto; }
.hint-inline { font-size: .8rem; color: var(--muted); margin: .25rem 0 0; }
.hint { text-align: center; color: var(--muted); font-size: .82rem; margin-top: 1rem; }

/* --- document viewer (side by side) --- */
.split { display: block; }
.split.split-active { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }

/* One column on narrow screens — two panes below ~900px is unreadable. */
@media (max-width: 900px) {
  .split.split-active { grid-template-columns: 1fr; }
}

.doc-pane { display: flex; flex-direction: column; min-width: 0; }
.text-pane { min-width: 0; }
.pane-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .35rem; }
.pane-title {
  font-size: .85rem; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em;
}
.doc-frame {
  width: 100%; height: 70vh; min-height: 380px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg);
}
.btn-small { padding: .28rem .55rem; font-size: .8rem; }

/* --- audit history table --- */
/* --- static pages (Impressum, Dokumentation) ------------------------------ */

/* These are read top to bottom, unlike the rest of the app, so they get a
   comfortable measure instead of the full fluid width. */
.prose { max-width: 72ch; }
.prose h3 { font-size: .95rem; margin: 1.4rem 0 .3rem; color: var(--ink); }
.prose h3:first-of-type { margin-top: .8rem; }
.prose ul, .prose ol { padding-left: 1.2rem; margin: .4rem 0; }
.prose li { margin-bottom: .3rem; }
.prose .lede { color: var(--muted); margin-bottom: 1rem; }
.prose .address { line-height: 1.7; }
.prose .back { margin-top: 1.8rem; }
.prose .alert p:last-child { margin-bottom: 0; }

/* Impressum has to be reachable from every page, so the footer is part of the
   layout rather than something individual templates opt into. */
.sitefoot { border-top: 1px solid var(--line); margin-top: 2rem; }
.sitefoot-inner {
  display: flex; gap: 1.2rem; justify-content: center;
  padding: .9rem 0 1.4rem; font-size: .82rem;
}
.sitefoot-inner a { color: var(--muted); text-decoration: none; }
.sitefoot-inner a:hover { color: var(--ink); text-decoration: underline; }

.table-scroll { overflow-x: auto; }          /* wide table scrolls, page does not */
.log-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.log-table th, .log-table td {
  text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.log-table th {
  position: sticky; top: 0; background: var(--panel); z-index: 1;
  font-size: .78rem; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); font-weight: 600;
}
.log-table tbody tr:hover { background: var(--bg); }
.log-table td.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
