/* ============================================================================
   Doku-Bereich — gemeinsame Optik fuer Ankauf / Verkauf / Entnahmen / Breaks
   (Norman 20.09.2026: "super klobig und unuebersichtlich").

   Vorher stand dasselbe CSS vier Mal inline in den Templates und driftete
   auseinander. Ab jetzt: EINE Datei, eingebunden von base.html, dazu der
   gemeinsame Kopf templates/partials/_doku_kopf.html.

   Bewusst NICHT auf .theme-new gescoped — der Doku-Bereich soll in beiden
   Themes gleich aussehen. Flaechen/Text ueber --bs-* (traegt Dark Mode in
   beiden Themes), Akzente ueber die CI-Token mit Hex-Fallback.
   ========================================================================= */

/* ── Mehr Breite, nur hier ────────────────────────────────────────────────
   base.html steckt JEDE Seite in '.container-xxl px-4' — nutzbar bleiben so
   1272px, und die Belegtabelle lief rechts aus dem Bild (Norman 20.09.2026:
   "die spalten breiter damit man auch alles sehen kann"). Statt base.html fuer
   alle Seiten anzufassen, hebt :has() den Deckel genau dort an, wo die
   Doku-Reiter stehen. Browser ohne :has() sehen einfach den alten Stand. */
.container-xxl:has(.skw-doku-nav) { max-width: 1560px; }

/* ── Reiter-Leiste: Ankauf · Verkauf · Entnahmen · Breaks ────────────────── */
.skw-doku-nav {
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--bs-border-color, #dee2e6);
  margin-bottom: 1rem;
}
.skw-doku-nav a {
  position: relative;
  padding: 0 0 0.55rem;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--bs-secondary-color, #6b7280);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s;
}
.skw-doku-nav a:hover { color: var(--bs-body-color, #212529); }
.skw-doku-nav a.aktiv {
  color: var(--bs-body-color, #212529);
  font-weight: 600;
  border-bottom-color: var(--skw-accent, #6366F1);
}

/* ── Titelzeile: Name + Info-Symbol links, Export rechts ─────────────────── */
.skw-doku-kopf {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}
.skw-doku-kopf h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.skw-doku-kopf .skw-doku-rechts { margin-left: auto; display: flex; gap: 0.5rem; }

/* Quadratischer Symbol-Knopf — gleiche Optik wie .skw-icon-btn im Rest des
   Projekts, hier aber ungescoped, damit er auch im Legacy-Theme sitzt. */
.skw-doku-ibtn {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 8px;
  border: 1px solid var(--bs-border-color, #dee2e6);
  background: transparent;
  color: var(--bs-secondary-color, #6b7280);
  font-size: 0.9rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.skw-doku-ibtn:hover:not(:disabled) {
  color: var(--skw-accent, #6366F1);
  border-color: var(--skw-accent, #6366F1);
}
.skw-doku-ibtn:disabled { opacity: 0.35; cursor: default; }

/* ── Kennzahlen: Bezeichnung gedaempft, Zahl kraeftig, eine ruhige Zeile ─── */
.skw-doku-kpi {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  font-size: 0.82rem;
  color: var(--bs-secondary-color, #6b7280);
  margin-bottom: 1rem;
}
.skw-doku-kpi > span { display: inline-flex; align-items: baseline; gap: 0.4rem; }
.skw-doku-kpi b {
  font-weight: 600;
  color: var(--bs-body-color, #212529);
  font-variant-numeric: tabular-nums;
}
.skw-doku-kpi .plus { color: var(--skw-success, #10B981); }
.skw-doku-kpi .minus { color: var(--skw-negative, #c92a7a); }

/* ── Kleines (i) neben dem Titel: Hinweis nur beim Drueberfahren/Antippen ─── */
.skw-doku-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  font-size: 0.85rem;
  color: var(--bs-secondary-color, #6b7280);
  cursor: help;
  outline: none;
}
.skw-doku-tip:hover, .skw-doku-tip:focus { color: var(--skw-accent, #6366F1); }
.skw-doku-tip-text {
  position: absolute;
  top: calc(100% + 6px);
  left: -6px;
  z-index: 20;
  width: max-content;
  max-width: min(280px, calc(100vw - 32px));
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--bs-border-color, #dee2e6);
  background: var(--bs-body-bg, #fff);
  color: var(--bs-body-color, #212529);
  font-size: 0.78rem;
  line-height: 1.45;
  font-weight: 400;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s;
}
.skw-doku-tip:hover .skw-doku-tip-text,
.skw-doku-tip:focus .skw-doku-tip-text { opacity: 1; visibility: visible; }

/* Hinweis-Streifen (DATEV unvollstaendig, OSS-Schwelle, Schwund-Konto) —
   gleiche Bauart wie die Info-Flaeche, nur die Kante traegt die Bedeutung. */
.skw-doku-hinweis {
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.9rem;
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-left: 3px solid var(--bs-secondary-color, #6b7280);
  border-radius: 8px;
  background: var(--bs-tertiary-bg, #f8f9fa);
  color: var(--bs-secondary-color, #6b7280);
}
.skw-doku-hinweis.warn { border-left-color: var(--skw-warning, #f7b13c); }
.skw-doku-hinweis.gefahr { border-left-color: var(--skw-danger, #F43F5E); }
.skw-doku-hinweis strong { color: var(--bs-body-color, #212529); font-weight: 600; }

/* ── Werkzeugleiste: Jahr + Suche + Filter + Zuruecksetzen in EINER Zeile ──
   Das Jahr steht im Template (partials/_doku_kopf.html), Suche und Filter
   haengt static/skw_doku_tools.js zur Laufzeit in dieselbe Leiste. */
.skw-doku-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}
.skw-doku-search {
  position: relative;
  flex: 1 1 240px;
  max-width: 360px;
  min-width: 180px;
}
/* input.form-control: Spezifitaet (0,0,2,1) schlaegt die globale Theme-Regel
   '.theme-new .form-control { padding: 9px 12px }' (0,0,2,0), sonst klebt der
   Platzhalter am Rand und das Lupen-Symbol ueberlappt. */
.skw-doku-search input.form-control { padding-left: 2rem; }
.skw-doku-search .bi-search {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--bs-secondary-color, #6b7280);
  font-size: 0.9rem;
  pointer-events: none;
  z-index: 2;
}
.skw-doku-filter { display: flex; align-items: center; margin: 0; }
.skw-doku-filter select { width: auto; }
.skw-doku-reset { white-space: nowrap; }
/* Leere Seite (kein Jahr, keine Belege) = keine Leiste, kein Leerraum. */
.skw-doku-toolbar:empty { display: none; }

/* ── Tabelle ─────────────────────────────────────────────────────────────
   Norman 20.09.2026: normale Schreibweise statt GROSSBUCHSTABEN, etwas mehr
   Luft, Zahlen gleich gross (tabular-nums), zarte Linien.

   Spezifitaet: style.css hat '.table thead th' MIT !important (Hintergrund +
   Farbe) und style.new.css '.theme-new .table thead th' (0,0,2,1) mit
   uppercase. Beide muessen geschlagen werden, sonst bleiben die
   GROSSBUCHSTABEN stehen — deshalb hier die doppelte Selektor-Liste. */
.skw-doku-table { font-size: 0.82rem; }
.table.skw-doku-table thead th,
.theme-new .table.skw-doku-table thead th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
  padding: 0.45rem 0.7rem;
  background-color: transparent !important;
  color: var(--bs-secondary-color, #6b7280) !important;
  border-bottom: 1px solid var(--bs-border-color, #dee2e6) !important;
}
.table.skw-doku-table tbody td,
.theme-new .table.skw-doku-table tbody td {
  padding: 0.62rem 0.7rem;
  border-top: none;
  border-bottom: 1px solid rgba(var(--bs-emphasis-color-rgb, 0, 0, 0), 0.06);
  vertical-align: middle;
}
/* Hover: style.css faerbt global in Bootstrap-Blau (!important) — hier
   stattdessen ein ruhiger, neutraler Ton, damit die CI nicht bricht. */
.table.skw-doku-table tbody tr:hover,
.theme-new .table.skw-doku-table tbody tr:hover {
  background-color: rgba(var(--skw-accent-rgb, 99, 102, 241), 0.05) !important;
}
/* Betraege: gleiche Ziffernbreite, damit die Spalte ruhig steht */
.skw-doku-table td.skw-zahl,
.skw-doku-table th.skw-zahl { font-variant-numeric: tabular-nums; }
/* Datum/Zeit nie umbrechen — "2026-05-25 19:25:52" wurde sonst dreizeilig. */
.skw-doku-table td.skw-nowrap { white-space: nowrap; }

/* Blaetter-Leiste unter der Tabelle: gleiche Feldhoehe wie die Werkzeugleiste,
   sonst steht dort ein deutlich klobigerer Kasten als oben. */
.skw-doku-pagebar select.form-select {
  height: 30px;
  padding: 0 1.6rem 0 0.5rem;
  font-size: 0.8rem;
  min-height: 0;
}
.skw-doku-pagebar .btn { --bs-btn-padding-y: 0.1rem; --bs-btn-padding-x: 0.45rem; }

/* Aufgeklappte Unter-Tabellen (Positionen im Beleg, Break-Positionen) — sonst
   erbt ihr Kopf wieder die GROSSBUCHSTABEN aus style.new.css. */
.table.skw-doku-subtable thead th,
.theme-new .table.skw-doku-subtable thead th,
.table.skw-brk-items thead th,
.theme-new .table.skw-brk-items thead th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
  padding: 0.3rem 0.5rem;
  background-color: transparent !important;
  color: var(--bs-secondary-color, #6b7280) !important;
}
.table.skw-doku-subtable tbody td,
.theme-new .table.skw-doku-subtable tbody td,
.table.skw-brk-items tbody td,
.theme-new .table.skw-brk-items tbody td {
  padding: 0.38rem 0.5rem;
  border-bottom: 1px solid rgba(var(--bs-emphasis-color-rgb, 0, 0, 0), 0.05);
}
.table.skw-doku-subtable tbody tr:hover,
.theme-new .table.skw-doku-subtable tbody tr:hover,
.table.skw-brk-items tbody tr:hover,
.theme-new .table.skw-brk-items tbody tr:hover {
  background-color: transparent !important;
}

/* Anker-Highlight: /sammlung/...#beleg-<nr> hebt die Zeile kurz hervor */
.skw-doku-table tbody tr:target td { animation: skw-beleg-highlight 2.6s ease-out; }
@keyframes skw-beleg-highlight {
  0% { background-color: rgba(var(--skw-accent-rgb, 99, 102, 241), 0.28); }
  50% { background-color: rgba(var(--skw-accent-rgb, 99, 102, 241), 0.18); }
  100% { background-color: transparent; }
}

.skw-doku-belegnr {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  padding: 0.12rem 0.45rem;
  background: var(--bs-secondary-bg, #e9ecef);
  color: var(--bs-body-color, #212529);
  border-radius: 4px;
  white-space: nowrap;
}
/* Zustands-Marke (STORNO, korrigiert, SumUp, Inventur) — kleiner als eine
   Aktion, normale Schreibweise. */
.skw-doku-flag {
  display: inline-block;
  font-size: 0.68rem;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  font-weight: 500;
  margin-left: 4px;
  background: var(--bs-tertiary-bg, #f8f9fa);
  color: var(--bs-secondary-color, #6b7280);
  border: 1px solid var(--bs-border-color, #dee2e6);
  vertical-align: 1px;
  white-space: nowrap;
}
.skw-doku-tax {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  background: var(--bs-secondary-bg, #e9ecef);
  color: var(--bs-secondary-color, #6b7280);
  font-weight: 500;
  white-space: nowrap;
}
/* Kleine Fussnote unter einer Zelle (Grund, Gebuehr, Versand, "ohne EK") */
.skw-doku-sub {
  font-size: 0.7rem;
  line-height: 1.3;
  font-weight: 400;
  color: var(--bs-secondary-color, #6b7280);
  margin-top: 1px;
}
.skw-doku-sub a { color: inherit; text-decoration: none; }
.skw-doku-sub a:hover { color: var(--skw-accent, #6366F1); }

/* ── Aktionsspalte: drei Symbolknoepfe statt drei Spalten ────────────────── */
.skw-doku-akt {
  white-space: nowrap;
  text-align: right;
}
.skw-doku-akt .skw-doku-ibtn { width: 28px; height: 28px; font-size: 0.85rem; }
.skw-doku-akt .skw-doku-ibtn + .skw-doku-ibtn { margin-left: 3px; }
/* Storno bleibt neutral, bis man drauf zeigt — es ist keine Alltagsaktion. */
.skw-doku-akt .skw-doku-ibtn.gefahr:hover:not(:disabled) {
  color: var(--skw-danger, #F43F5E);
  border-color: var(--skw-danger, #F43F5E);
}
.skw-doku-akt .leer {
  display: inline-block;
  width: 28px;
  text-align: center;
  color: var(--bs-secondary-color, #6b7280);
  opacity: 0.4;
}

/* ── Leerzustand ─────────────────────────────────────────────────────────── */
.skw-doku-leer {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--bs-secondary-color, #6b7280);
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: 10px;
  background: var(--bs-tertiary-bg, #f8f9fa);
}
.skw-doku-leer i.gross { font-size: 1.9rem; opacity: 0.35; display: block; }
.skw-doku-leer .titel {
  margin-top: 0.6rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--bs-body-color, #212529);
}
.skw-doku-leer .hinweis { font-size: 0.82rem; margin-top: 0.25rem; }

/* ── Fusszeile (Steuerberater-Hinweis) ───────────────────────────────────── */
.skw-doku-fuss {
  margin-top: 1.5rem;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--bs-secondary-color, #6b7280);
  padding-top: 0.8rem;
  border-top: 1px solid var(--bs-border-color, #dee2e6);
}

/* ── Schmale Fenster: Reiter scrollen statt umbrechen ────────────────────── */
@media (max-width: 575.98px) {
  .skw-doku-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 1.1rem;
    scrollbar-width: none;
  }
  .skw-doku-nav::-webkit-scrollbar { display: none; }
  .skw-doku-kopf h1 { font-size: 1.1rem; }
}
