/* Kontorist Freigabe-UI im CI "Ostermann Graphit", Dichte Werkbank.
   Farben, Abstaende, Radien und Schriften kommen aus static/ostermann/ (unveraendert
   kopiert von scripts/sync-ostermann-ci.sh); hier steht nur, was es im CI nicht gibt.
   Keine eigenen Farbwerte, keine Schatten, keine Konturen an Karten. Laeuft offline. */

body { margin: 0; }

h1, h2, h3 { margin: 0; text-wrap: balance; overflow-wrap: break-word; hyphens: auto; }
h1 { font-family: var(--font-display); font-size: 28px; line-height: 34px; font-weight: 700; }
h2 { font-family: var(--font-display); font-size: 20px; line-height: 26px; font-weight: 700; }
h3 { font-size: 16px; line-height: 22px; font-weight: 700; }
p { margin: 0; }
a { color: var(--brand-text); text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

.mono { font-family: var(--font-mono); font-size: 0.93em; }
.muted { color: var(--ink-muted); }
.small { font-size: 12px; line-height: 18px; }
.nowrap { white-space: nowrap; }
.hint { max-width: var(--measure); font-size: 14px; line-height: 22px; color: var(--ink-muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Rahmen ----------------------------------------------------------- */

.ost-header__inner { max-width: none; padding-inline: var(--space-5); }
.ost-wordmark { min-height: 44px; justify-content: center; }

/* Logo: Zeichen aus scripts/build-logo.py (_logo_mark.html) neben dem Namen. Linie in
   ink, mittleres Fenster in brand; Mindesthoehe 24px, Schutzraum ueber den Abstand. */
.brand { display: inline-flex; align-items: center; gap: var(--space-3); color: var(--ink); text-decoration: none; }
.brand:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }
.logo-mark { flex: none; width: 36px; height: 36px; }
.logo-mark__line { fill: none; stroke: var(--ink); }
.logo-mark__dot { fill: var(--ink); }
.logo-mark__accent { fill: var(--brand); }
.who { color: var(--ink-muted); }

.page { max-width: 1240px; margin: 0 auto; padding: var(--space-5); }

/* Kinder einer ost-card (Flex) duerfen schmaler werden als ihr Inhalt, sonst schiebt
   ein breites Ablaufbild oder eine Tabelle die ganze Seite auf. */
.ost-card, .ost-card > * { min-width: 0; }
.ost-card + .ost-card, .details > .ost-card + .ost-card { margin-top: var(--space-4); }
.ost-card.narrow { max-width: 560px; margin: var(--space-7) auto; }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
}

.back { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: var(--space-2); }

/* Ein Wort in einer Pill (ost-status), etwas kleiner im Fliesstext und in Tabellen. */
.ost-status { vertical-align: 1px; }
th .ost-status, td .ost-status, .ost-table .ost-status { min-height: 20px; padding: 0 var(--space-2); letter-spacing: 0.08em; }

/* --- Startseite ------------------------------------------------------- */

.index {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: var(--space-6);
  align-items: start;
}
.jobs { display: grid; gap: var(--space-3); min-width: 0; }

.tabs { flex-wrap: wrap; gap: var(--space-1) var(--space-5); border-bottom: 1px solid var(--line); }
.count {
  display: inline-block;
  min-width: 24px;
  margin-left: var(--space-1);
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--surface-raised);
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.empty { color: var(--ink-muted); padding: var(--space-5) 0; }

.start form { display: grid; gap: var(--space-4); }
.choices { display: grid; gap: var(--space-2); margin: 0; padding: 0; border: 0; min-width: 0; }
.choices legend { margin-bottom: var(--space-2); padding: 0; font-weight: 700; }
.choice {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
}
.choice:has(input:checked) { box-shadow: inset 0 0 0 2px var(--brand-text); }
.choice.disabled { cursor: not-allowed; }
.choice input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--action); }
.choice-body { display: grid; gap: 2px; min-width: 0; }
.choice-title { font-weight: 700; }
.choice-meta { color: var(--ink-muted); font-size: 12px; line-height: 18px; }
.choice-note { color: var(--signal-warn); font-size: 12px; line-height: 18px; font-weight: 700; }
.start .ost-btn { width: 100%; }

/* --- Lagebild (Startseite) -------------------------------------------- */

.dash-head { margin-bottom: var(--space-5); }
.dash-head__text { display: grid; gap: var(--space-2); }
.dash-kpis { margin-bottom: var(--space-5); min-width: 0; }
.dash-kpis__row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.dash-kpi {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}
.dash-kpi__value {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 32px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.dash-kpi__label { font-size: 14px; line-height: 20px; font-weight: 700; }
.dash-kpi__note { color: var(--ink-muted); font-size: 12px; line-height: 18px; }

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: var(--space-5);
  align-items: start;
}
.dash-main { display: grid; gap: var(--space-5); min-width: 0; }
.dash-side { display: grid; gap: var(--space-4); min-width: 0; }
.dash-section { min-width: 0; }
.dash-section h2 { margin-bottom: var(--space-3); }
.dash-section .empty { padding: var(--space-3) 0; }
.dash-queue td:first-child { white-space: nowrap; }
.dash-side .start form { display: grid; gap: var(--space-4); }
.dash-side .start .ost-btn { width: 100%; }

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-kpis__row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .dash-kpis__row { grid-template-columns: 1fr; }
}

/* Erreichbarkeit des Modellservers */
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); color: var(--ink-muted); }
.status-line + .status-line { margin-top: var(--space-2); }

/* --- Bedienelemente --------------------------------------------------- */

/* Im Werkbank-Text 14px; das CI setzt Eingabefelder sonst auf 16px. */
.ost-page--werkbank .ost-input { font-size: 14px; }
textarea.ost-input { min-height: 88px; }
input[type="file"].ost-input { padding-block: var(--space-2); }
.ost-btn[disabled] { cursor: progress; }

.link-button {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand-text);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.link-button:hover { text-decoration-thickness: 2px; }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-pill);
  animation: spin 0.8s linear infinite;
}
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* Meldungen: ost-note; in Karten auf der hellen Flaeche, nicht auf dem Kartenton. */
.ost-card .ost-note { background: var(--surface); }
#start-message:empty, #decision-message:empty, #correction-message:empty, #retry-message:empty { display: none; }

/* Punkte mit Warnung: Ausrufezeichen im Kreis, Text bleibt in ink. */
.facts, .findings { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.facts li, .findings li { position: relative; padding-left: var(--space-6); overflow-wrap: anywhere; }
.facts li::before, .findings li::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--ink-muted);
}
.facts li.warn::before, .findings li.warn::before {
  content: "!";
  left: 0;
  top: 1px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  background: var(--signal-warn);
  color: var(--surface);
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
}

/* --- Tabellen --------------------------------------------------------- */

.table-wrap { overflow-x: auto; min-width: 0; }
.ost-table th, .ost-table td { overflow-wrap: break-word; }
.ost-table thead th { color: var(--ink-muted); font-size: 12px; line-height: 18px; letter-spacing: 0.08em; text-transform: uppercase; }
.ost-table tbody tr:hover { background: var(--surface-raised); }
.ost-card .ost-table tbody tr:hover { background: var(--surface); }
.ost-table td.num, .ost-table td.nowrap { overflow-wrap: normal; }
.jobs .ost-table td:first-child { white-space: nowrap; }

.record { width: 100%; border-collapse: collapse; table-layout: fixed; }
.record th { width: 32%; padding: var(--space-2) var(--space-3) var(--space-2) 0; text-align: left; vertical-align: top; color: var(--ink-muted); font-weight: 400; }
.record td { padding: var(--space-2) 0; vertical-align: top; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.record tr + tr th, .record tr + tr td { border-top: 1px solid var(--line); }
.record tr.wide-label th { width: auto; padding-bottom: 0; }
.record tr.wide > td { padding-top: var(--space-1); }
.record tr.wide-label + tr.wide td { border-top: 0; }
.record ul { margin: 0; padding-left: var(--space-4); }

.nested { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 22px; font-variant-numeric: tabular-nums; }
.nested th, .nested td { padding: var(--space-1) var(--space-2); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.nested th { color: var(--ink-muted); font-size: 12px; line-height: 18px; font-weight: 700; }
.record .nested td { overflow-wrap: normal; min-width: 7em; }

/* Korrektur vor der Gegenzeichnung */
.correct { display: grid; gap: var(--space-4); }
.edit .ost-input { min-width: 6em; }
.edit input.ost-input[size] { width: auto; max-width: 100%; }
.edit td { vertical-align: top; }
.edit .ost-check { justify-content: center; }

.citations q { quotes: "„" "“"; }

/* --- Vorgang ---------------------------------------------------------- */

.job-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: var(--space-2) var(--space-4); }
.job-head > div { display: grid; gap: var(--space-1); min-width: 0; }
.intro { max-width: var(--measure); margin-top: var(--space-3); }

.meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: var(--space-3) var(--space-5);
  margin: var(--space-5) 0;
}
.meta dt { color: var(--ink-muted); font-size: 12px; line-height: 18px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.meta dd { margin: 2px 0 0; overflow-wrap: anywhere; }

.job-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-areas: "details decision";
  gap: var(--space-4);
  align-items: start;
}
.details { grid-area: details; min-width: 0; }
.decision { grid-area: decision; position: sticky; top: var(--space-4); min-width: 0; }
/* Pfade der Ablage sind lang und ohne Leerzeichen; sonst laeuft die Seite seitlich ueber. */
.decision .mono, .decision .paths { overflow-wrap: anywhere; }
.decision form { display: grid; gap: var(--space-3); }
.decision form + form, .retry { margin-top: var(--space-2); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.paths { margin: 0; padding-left: var(--space-4); overflow-wrap: anywhere; }
.reason { padding: var(--space-3); border-radius: var(--radius-sm); background: var(--surface); }

details > summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); min-height: 44px; cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; color: var(--ink-muted); }
details[open] > summary::before { content: "▾"; }
details[open] > summary { margin-bottom: var(--space-3); }
details[open] { display: grid; gap: var(--space-3); }
.audit td { overflow-wrap: anywhere; }

.docx { display: grid; gap: var(--space-2); padding: var(--space-4) var(--space-5); border-radius: var(--radius-sm); background: var(--surface); }
.docx .docx-title { font-family: var(--font-display); font-size: 20px; line-height: 26px; font-weight: 700; }
.docx .docx-heading { margin-top: var(--space-3); font-weight: 700; }
.docx .docx-bullet { position: relative; padding-left: var(--space-4); }
.docx .docx-bullet::before { content: "•"; position: absolute; left: var(--space-1); }

/* --- Ablaufbild ------------------------------------------------------- */
/* Mermaid zeichnet, flow.js setzt st-<Stand> an die Knoten. !important, weil
   Mermaid seine Stile mit der ID des Bilds in das SVG schreibt. Der Stand steht
   nie nur in der Farbe: Strichart und der Satz ueber dem Bild sagen ihn auch. */

.flow { margin-bottom: var(--space-4); }
.flow-caption { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--ink-muted); font-size: 14px; }
.flow-canvas { overflow-x: auto; }
.flow-canvas svg { display: block; margin: 0 auto; min-width: 640px; height: auto; }
.flow-canvas.rendered .flow-fallback { display: none; }

.flow-canvas g.node :is(rect, polygon, path, circle) { transition: fill 0.2s, stroke 0.2s; }
.flow-canvas g.node.ki :is(rect, polygon, path) { stroke: var(--ink) !important; stroke-width: 1.5px !important; }
.flow-canvas g.node.st-pending { opacity: 0.5; }
.flow-canvas g.node.st-done :is(rect, polygon, path) { fill: var(--surface-raised) !important; stroke: var(--brand) !important; stroke-width: 2px !important; }
.flow-canvas g.node.st-running :is(rect, polygon, path) {
  fill: var(--surface-raised) !important;
  stroke: var(--brand-text) !important;
  stroke-width: 3px !important;
  animation: flow-pulse 1.4s ease-in-out infinite;
}
.flow-canvas g.node.st-waiting :is(rect, polygon, path) { stroke: var(--ink-muted) !important; stroke-width: 2px !important; stroke-dasharray: 2 4; }
.flow-canvas g.node.st-failed :is(rect, polygon, path) { stroke: var(--signal-error) !important; stroke-width: 3px !important; stroke-dasharray: 8 4; }
.flow-canvas g.node.st-rejected :is(rect, polygon, path) { stroke: var(--signal-warn) !important; stroke-width: 2px !important; stroke-dasharray: 8 4; }
.flow-canvas g.node.linked { cursor: pointer; }
.flow-canvas g.node.linked:hover :is(rect, polygon, path) { stroke-width: 3px !important; }
.flow-canvas g.node.linked:focus { outline: none; }
.flow-canvas g.node.linked:focus-visible :is(rect, polygon, path) { stroke: var(--focus) !important; stroke-width: 3px !important; }
@keyframes flow-pulse { 50% { stroke-opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .flow-canvas g.node.st-running :is(rect, polygon, path) { animation: none; } }

.prompt-dialog {
  width: min(880px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: var(--space-5);
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
}
.prompt-dialog[open] { display: grid; gap: var(--space-3); }
.prompt-dialog::backdrop { background: color-mix(in srgb, var(--surface-graphit) 60%, transparent); }
.prompt-dialog .meta { margin: 0; }
.prompt-dialog form { margin: 0; }
.prompt-text {
  margin: 0;
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 22px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Laufzettel: Schritte als ost-steps, Angaben darunter */
.ost-steps__title { font-size: 16px; line-height: 22px; }
.ost-steps__text { overflow-wrap: anywhere; font-size: 14px; line-height: 22px; }
.ost-steps > li > * { grid-column: 2; }
.ost-steps__text + .ost-steps__text { margin-top: var(--space-1); }

/* --- Schmal ----------------------------------------------------------- */

@media (max-width: 900px) {
  .page { padding: var(--space-4); }
  .ost-header__inner { padding-inline: var(--space-4); }
  .index { grid-template-columns: minmax(0, 1fr); }
  .start { order: -1; }
  .job-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "decision" "details"; }
  .decision { position: static; }
  .record th { width: 40%; }
}

/* --- Original: Seitenbilder der Eingaben und Betrachter ---------------- */

.originals { display: grid; gap: var(--space-3); }
.original { display: grid; gap: var(--space-2); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--space-2); }
.thumb {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--ink);
  cursor: zoom-in;
  overflow: hidden;
}
.thumb img { display: block; width: 100%; height: auto; }
.thumb:hover { border-color: var(--ink-muted); }
.thumb:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.thumb-page {
  position: absolute;
  right: var(--space-1);
  bottom: var(--space-1);
  padding: 0 var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.thumb-more { padding: var(--space-3); font-size: 14px; cursor: pointer; }
.citation-page { min-height: 0; padding: 0; font-family: var(--font-mono); font-size: 14px; font-weight: 400; }

.viewer {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--surface);
  color: var(--ink);
}
.viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.viewer::backdrop { background: var(--surface-graphit); }
.viewer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-bottom: 1px solid var(--line);
}
.viewer-title { overflow-wrap: anywhere; }
.viewer-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
.viewer-tools svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.viewer-tools .ost-iconbtn:disabled { opacity: 1; color: var(--line); cursor: default; }
.viewer-zoom { min-width: 7.5em; font-variant-numeric: tabular-nums; }
.viewer-download { margin-inline: var(--space-2); }
.viewer-stage {
  display: grid;
  place-items: center;
  overflow: auto;
  padding: var(--space-3);
  background: var(--surface-raised);
}
.viewer-image { display: block; max-width: none; height: auto; cursor: zoom-in; user-select: none; touch-action: pan-x pan-y; }
.viewer.is-zoomed .viewer-stage { place-items: start; }
.viewer.is-zoomed .viewer-image { cursor: grab; }
.viewer[aria-busy="true"] .viewer-image { opacity: 0.4; }
@media (prefers-reduced-motion: no-preference) {
  .viewer-image { transition: opacity 120ms; }
}

/* Anmeldung (auth.mode oidc) */
.who { display: flex; align-items: center; gap: var(--space-3, 0.75rem); }
.logout { margin: 0; }
.login-providers { display: flex; flex-wrap: wrap; gap: var(--space-3, 0.75rem); }
