/* ==========================================================================
   Juveon Legal-Pack — Basis-Stylesheet (alle drei Flächen)
   Baut auf tokens.css auf. Komponenten-Vokabular gemäß Design-Brief §4:
   .data-card, .pill, .kpi, .record-item, .fehler-karte, .mappe-body u. a.
   ========================================================================== */

/* ---------- Reset / Grundgerüst ----------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.22;
  color: var(--ink);
  margin: 0 0 0.5em;
}

h1 { font-size: var(--fs-2xl); letter-spacing: -0.01em; }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

p { margin: 0 0 0.75em; }

a {
  color: var(--green);
  text-decoration-color: var(--green-line);
  text-underline-offset: 2px;
}

a:hover { color: var(--green-deep); }

code,
pre,
.mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

img { max-width: 100%; }

::selection {
  background: var(--green-soft);
  color: var(--green-deep);
}

/* Zahlen in Tabellen/KPIs ruhig und ausgerichtet */
.tnum {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ---------- A11y-Helfer -------------------------------------------------- */

.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;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  z-index: 60;
  background: var(--green-deep);
  color: #fff;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-s);
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus-visible { top: 0.75rem; }

:where(a, button, summary, input, textarea, select, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-s);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Kopfleiste --------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap);
  /* Bewusst der feste Design-Brief-Wert (60px), NICHT var(--topbar-h):
     shared/topbar-height.js schreibt --topbar-h live auf die tatsaechliche
     (ggf. umgebrochene) Hoehe DIESES Elements zurueck. Wuerde min-height
     stattdessen --topbar-h lesen, haelt sich die Kopfleiste bei einem
     spaeteren Wechsel zu einer breiteren Ansicht selbst auf ihrer alten,
     groesseren Hoehe fest (die Groessenaenderung faende nie statt, der
     ResizeObserver haette nichts zu melden) — ein Feedback-Loop, der die
     Sektions-Tabs/Case-Rail dauerhaft zu weit unten haelt. */
  min-height: 60px;
  padding: 0.45rem clamp(0.75rem, 2.5vw, 1.75rem);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line-strong);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: var(--radius-s);
  background: var(--green-deep);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: inset 0 0 0 1px rgb(244 239 228 / 0.25);
}

.brand-text { min-width: 0; }

.brand-title {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-tagline {
  display: block;
  font-size: var(--fs-xs);
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Zusatz-Segment des Markennamens („ Legal-Pack …"): fällt auf schmalen
   Headern weg, statt den Namen zu „Juveon Leg…" zu stutzen — „Juveon"
   bleibt immer vollständig lesbar. Die Basisregeln fuer .brand-tagline
   (oben) muessen VOR dieser Media-Query stehen: bei gleicher Spezifitaet
   gewinnt sonst die spaetere unbedingte Regel und macht das display:none
   hier wirkungslos (genau dieser Reihenfolge-Fehler hielt die Tagline
   bislang unterhalb 760px sichtbar). */
@media (max-width: 760px) {
  .brand-sub { display: none; }
  .brand-tagline { display: none; }

  /* Kanzlei-Kopfleiste traegt zusaetzlich den RDG-Hinweis (.rdg-pill).
     Marke und Hinweis bleiben zusammen auf der ersten Zeile; die
     Aktionsleiste bekommt bei Bedarf eine eigene zweite Zeile statt
     alle drei Elemente einzeln umbrechen zu lassen (unvorhersehbare
     Kopfhoehe, die den sticky-Versatz der Sektions-Tabs sprengt). */
  .top-actions { flex-basis: 100%; }
}

/* Landing-Hero: In der einspaltigen Ansicht darf der Min-Content-Titel die
   Grid-Spalte nicht verbreitern. Die Überschrift bleibt dadurch innerhalb
   des verfügbaren Inhaltsraums und die 3D-Mappe kann nicht mitgezogen werden. */
.landing-nav + main .hero-copy { min-width: 0; }

/* Bei 300px passt „Rechtsgebiete.“ in der bisherigen Mindestgröße nicht in
   den Innenraum. Eine abgestufte, noch klar lesbare Hero-Größe bewahrt das
   Wort als Einheit statt es an einer beliebigen Stelle umzubrechen. */
@media (max-width: 319px) {
  .landing-nav + main .hero h1 { font-size: 2.1rem; }

  /* Die dekorative Rücklage bleibt tiefenversetzt, aber ohne seitlichen
     Versatz, damit sie aus dem schmalen Inhaltsraum nicht herausragt. */
  .landing-nav + main .radar-beispiel::before {
    transform: translateY(10px) rotate(0.8deg);
  }
}

/* Die versetzten Papierlagen der Landing-Mappe bekommen ihren seitlichen
   Spielraum erst ab 1115px. Der Landing-Selektor ist absichtlich spezifischer
   als die seitenlokalen Ausgangstransforms. */
@media (max-width: 1114px) {
  .landing-nav + main .mappe-3d::before { transform: translateZ(-28px); }
  .landing-nav + main .mappe-3d::after { transform: translateZ(-56px); }
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Status-Chip */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--green-line);
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-ink);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
}

.status-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex: none;
}

.status-chip.is-busy {
  background: var(--amber-soft);
  border-color: color-mix(in srgb, var(--amber) 40%, var(--amber-soft));
  color: var(--amber-ink);
}

.status-chip.is-busy::before {
  background: var(--amber);
  animation: chip-puls 1.1s ease-in-out infinite;
}

.status-chip.is-error {
  background: var(--red-soft);
  border-color: color-mix(in srgb, var(--red) 40%, var(--red-soft));
  color: var(--red-ink);
}

.status-chip.is-error::before { background: var(--red); }

@keyframes chip-puls {
  50% { opacity: 0.35; }
}

/* Portal-Switcher */
.portal-switcher {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel-soft);
  padding: 2px;
}

.portal-switcher a {
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
}

.portal-switcher a:hover { color: var(--green-deep); }

.portal-switcher a[aria-current="page"] {
  background: var(--panel);
  color: var(--green-deep);
  box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line-strong);
}

/* ---------- Buttons ------------------------------------------------------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover { background: var(--panel-soft); border-color: var(--muted); }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--green);
  border-color: var(--green-deep);
  /* !important: seitenspezifische Link-Farben (z. B. Header-Navs mit
     .nav-links a) haben durch Verschachtelung oft höhere Spezifität als
     diese einzelne Klasse — die Button-Textfarbe muss trotzdem gewinnen. */
  color: #fbf8f1 !important;
}

.btn-primary:hover { background: var(--green-deep); border-color: var(--green-deep); }

.btn-cognac {
  background: var(--cognac);
  border-color: var(--cognac-deep);
  color: #fbf8f1;
}

.btn-cognac:hover { background: var(--cognac-deep); border-color: var(--cognac-deep); }

.btn-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--ink-soft);
}

.btn-quiet:hover { background: var(--panel-soft); color: var(--ink); }

.btn-small {
  padding: 0.3rem 0.65rem;
  font-size: var(--fs-xs);
}

.btn-block { width: 100%; }

/* ---------- Formulare ------------------------------------------------------ */

.field {
  display: block;
  margin-bottom: var(--gap);
}

.field-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 0.3rem;
}

.field-hint {
  display: block;
  font-size: var(--fs-xs);
  color: var(--muted);
  margin-top: 0.25rem;
}

input[type="text"],
input[type="url"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-base);
}

textarea {
  min-height: 7rem;
  resize: vertical;
  line-height: 1.5;
}

input:hover,
select:hover,
textarea:hover { border-color: var(--muted); }

input:focus,
select:focus,
textarea:focus { border-color: var(--green); }

input[type="file"] {
  width: 100%;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
}

input[type="file"]::file-selector-button {
  margin-right: 0.6rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--panel-soft);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover { background: var(--paper-2); }

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
}

/* Dropzone */
.dropzone {
  display: block;
  padding: 1.1rem;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.dropzone:hover,
.dropzone.dragging {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green-ink);
}

.dropzone strong { color: var(--ink-soft); }

.dropzone input[type="file"] { margin-top: 0.6rem; }

/* ---------- Karten ---------------------------------------------------------- */

.data-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: var(--gap-l);
  margin-bottom: var(--gap);
}

.data-card > h3:first-child,
.data-card > h2:first-child {
  margin-top: 0;
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  margin: 0 0 0.6rem;
}

.card-title .pill { vertical-align: middle; margin-left: 0.4rem; }

.card-sub {
  font-size: var(--fs-sm);
  color: var(--muted);
  margin-top: -0.35rem;
  margin-bottom: 0.75rem;
}

/* ---------- Pills ------------------------------------------------------------ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.14rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel-soft);
  color: var(--ink-soft);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.45;
  white-space: nowrap;
}

/* Lange Rechtstexte (Einreden, Linien) dürfen umbrechen. overflow-wrap
   zusaetzlich zu white-space: ein einzelnes langes Kompositum ohne
   Leerzeichen (z. B. "Kautionsrueckzahlung") haette sonst weiterhin keine
   Umbruchstelle — white-space: normal erlaubt nur Umbrueche AN Leerzeichen. */
.pill.lang { white-space: normal; overflow-wrap: anywhere; text-align: left; }

.pill.green  { background: var(--green-soft);  border-color: var(--green-line);  color: var(--green-ink); }
.pill.amber  { background: var(--amber-soft);  border-color: color-mix(in srgb, var(--amber) 35%, var(--amber-soft)); color: var(--amber-ink); }
.pill.red    { background: var(--red-soft);    border-color: color-mix(in srgb, var(--red) 35%, var(--red-soft)); color: var(--red-ink); }
.pill.blue   { background: var(--blue-soft);   border-color: var(--blue-line);   color: var(--blue); }
.pill.cognac { background: var(--cognac-soft); border-color: color-mix(in srgb, var(--cognac) 35%, var(--cognac-soft)); color: var(--cognac-ink); }

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

/* ---------- KPIs -------------------------------------------------------------- */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.6rem;
  margin-bottom: var(--gap);
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  box-shadow: var(--shadow-1);
}

.kpi-value {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
}

.kpi-value.good { color: var(--green-deep); }
.kpi-value.warn { color: var(--amber-ink); }
.kpi-value.bad  { color: var(--red-ink); }

.kpi-label {
  display: block;
  font-size: var(--fs-xs);
  color: var(--muted);
  margin-top: 0.15rem;
}

/* Signal-KPIs in der Rail (kompakt) */
.signal-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.signal {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 0.45rem 0.6rem;
}

.signal .kpi-value { font-size: var(--fs-lg); }

/* Ungerade Restzelle (z. B. 5 Signale) über die volle Breite — symmetrisches Raster */
.signal-row .signal:last-child:nth-child(odd) { grid-column: 1 / -1; }

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  margin-bottom: var(--gap);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--panel-soft);
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

td {
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  color: var(--ink-soft);
}

tr:last-child td { border-bottom: 0; }

tbody tr:hover { background: color-mix(in srgb, var(--panel-soft) 55%, transparent); }

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td.strong,
tr.total-row td {
  font-weight: 700;
  color: var(--ink);
}

/* ---------- Listen-Zeilen (records) -------------------------------------------------- */

.records {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: var(--gap);
}

.record-item {
  display: block;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--panel);
  color: inherit;
  text-decoration: none;
  font-size: var(--fs-sm);
  text-align: left;
  width: 100%;
}

button.record-item { cursor: pointer; font: inherit; font-size: var(--fs-sm); }

.record-item:hover { border-color: var(--line-strong); background: var(--panel-soft); }

.record-item.warn {
  border-left-color: var(--amber);
  background: color-mix(in srgb, var(--amber-soft) 45%, var(--panel));
}

.record-item.danger {
  border-left-color: var(--red);
  background: color-mix(in srgb, var(--red-soft) 50%, var(--panel));
}

.record-item.good { border-left-color: var(--green); }

.record-meta {
  display: block;
  font-size: var(--fs-xs);
  color: var(--muted);
  margin-top: 0.2rem;
  line-height: 1.45;
}

.record-title { font-weight: 600; color: var(--ink); }

/* ---------- Fehlerkarte / Hinweise ------------------------------------------------------ */

.fehler-karte {
  border: 1px solid color-mix(in srgb, var(--red) 45%, var(--red-soft));
  border-left: 4px solid var(--red);
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--red-soft) 55%, var(--panel));
  color: var(--red-ink);
  padding: 0.7rem 0.9rem;
  font-size: var(--fs-sm);
  margin-bottom: var(--gap);
}

.fehler-karte strong { color: var(--red-ink); }

.fehler-karte .record-meta { color: color-mix(in srgb, var(--red-ink) 75%, var(--panel)); }

.hinweis-karte {
  border: 1px solid color-mix(in srgb, var(--amber) 40%, var(--amber-soft));
  border-left: 4px solid var(--amber);
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--amber-soft) 50%, var(--panel));
  color: var(--amber-ink);
  padding: 0.7rem 0.9rem;
  font-size: var(--fs-sm);
  margin-bottom: var(--gap);
}

.notiz-karte {
  border: 1px solid var(--green-line);
  border-left: 4px solid var(--green);
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--green-soft) 55%, var(--panel));
  color: var(--green-ink);
  padding: 0.7rem 0.9rem;
  font-size: var(--fs-sm);
  margin-bottom: var(--gap);
}

/* ---------- Empty-State -------------------------------------------------------------------- */

.empty-note {
  padding: var(--gap-l);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: center;
  color: var(--muted);
}

.empty-note h3 {
  font-size: var(--fs-md);
  margin-bottom: 0.35rem;
  color: var(--ink-soft);
}

.empty-note p { font-size: var(--fs-sm); margin-bottom: 0; }

/* ---------- Tabs -------------------------------------------------------------------------------- */

.mode-tabs,
.section-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line-strong);
  overflow-x: auto;
  scrollbar-width: thin;
}

.mode-tab,
.section-tab {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0.55rem 0.8rem;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.mode-tab:hover,
.section-tab:hover { color: var(--ink); }

.mode-tab[aria-selected="true"],
.section-tab[aria-selected="true"] {
  color: var(--green-deep);
  border-bottom-color: var(--green);
}

/* ---------- Details / Summary --------------------------------------------------------------------- */

details.details-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  margin-bottom: var(--gap);
}

details.details-card > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  list-style: none;
}

details.details-card > summary::-webkit-details-marker { display: none; }

details.details-card > summary::before {
  content: "▸";
  color: var(--green);
  transition: transform 0.15s ease;
  flex: none;
}

details.details-card[open] > summary::before { transform: rotate(90deg); }

details.details-card > summary:hover { color: var(--ink); }

details.details-card > summary .count {
  margin-left: auto;
  color: var(--muted);
  font-weight: 600;
  font-size: var(--fs-xs);
}

.details-body {
  padding: 0 0.9rem 0.9rem;
  border-top: 1px solid var(--line);
}

/* ---------- Aktenliste ---------------------------------------------------------------------------- */

.akte-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--panel);
  margin-bottom: 0.4rem;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.akte-item:hover { background: var(--panel-soft); border-color: var(--muted); }

/* Flex-Kind muss schrumpfen dürfen, sonst wirkt die Ellipse nicht */
.akte-item > button { min-width: 0; }

.akte-open {
  display: block;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.akte-item.is-active {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
  background: var(--green-soft);
}

.akte-item .akte-titel {
  display: block;
  min-width: 0;
  font-weight: 600;
  font-size: var(--fs-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.akte-item .akte-meta {
  display: block;
  font-weight: 400;
  font-size: var(--fs-xs);
  color: var(--muted);
}

/* ---------- Spinner ---------------------------------------------------------------------------------- */

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -3px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.busy-zeile {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  font-size: var(--fs-sm);
  padding: 1rem 0.25rem;
}

/* ---------- Markdown-Rohtext ------------------------------------------------------------------------- */

.markdown-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--gap-l);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-height: none;
}

/* ==========================================================================
   Entscheidungsmappe — Buch-Satz (Design-Brief §4: Zeilenlänge ~70ch,
   klare h2/h3-Hierarchie, Blockquote für Rechtsprechungs-Zitate)
   ========================================================================== */

.mappe-body {
  max-width: var(--measure);
  font-family: var(--font-display);
  font-size: 1.02rem;
  line-height: 1.72;
  color: var(--ink);
}

/* Lange Tokens (ECLI, Quellen-URLs, Pfade) dürfen umbrechen — sonst
   entsteht Horizontal-Scroll auf schmalen Viewports. .section-content
   deckt zusaetzlich JEDEN Report-Tab beider Portale ab: mdToHtml() setzt
   Fliesstext (Termin-Briefing, Vergleichs-Check, Rohtext) direkt dort ein,
   ausserhalb von .mappe-body — ohne diese Regel bricht ein einzelner
   langer Fundstellen-/Normen-Token (z. B. "Tilgungsbestimmung/
   Objektbindung") den ganzen Seiten-Overflow, unabhaengig davon, welcher
   Tab gerade aktiv ist. */
.mappe-body,
.section-content,
.record-item,
.verdict-liste li,
.fehler-karte,
.hinweis-karte,
.notiz-karte,
.doc-line,
.clause-card {
  overflow-wrap: anywhere;
}

.mappe-body > h2 {
  font-size: var(--fs-xl);
  margin: 2.1em 0 0.55em;
  padding-top: 0.9em;
  border-top: 1px solid var(--line-strong);
  scroll-margin-top: calc(var(--topbar-h) + 3.5rem);
}

.mappe-body > h2:first-child { margin-top: 0.4em; padding-top: 0; border-top: 0; }

.mappe-body h3 {
  font-size: var(--fs-lg);
  margin: 1.6em 0 0.4em;
  scroll-margin-top: calc(var(--topbar-h) + 3.5rem);
}

.mappe-body h4 {
  font-size: var(--fs-md);
  font-family: var(--font-ui);
  font-weight: 700;
  margin: 1.3em 0 0.3em;
}

.mappe-body p { margin: 0 0 0.85em; }

.mappe-body strong { color: var(--ink); }

.mappe-body blockquote {
  margin: 1.1em 0;
  padding: 0.7em 1.1em;
  border-left: 3px solid var(--green-line);
  background: color-mix(in srgb, var(--green-soft) 45%, var(--panel));
  color: var(--ink-soft);
  font-style: italic;
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
}

.mappe-body blockquote p { margin-bottom: 0.4em; }
.mappe-body blockquote p:last-child { margin-bottom: 0; }

.mappe-body ul,
.mappe-body ol {
  margin: 0 0 0.95em;
  padding-left: 1.5em;
}

.mappe-body li { margin-bottom: 0.35em; }

.mappe-body li::marker { color: var(--green); }

.mappe-body .table-wrap { margin: 1em 0 1.3em; }

.mappe-body table { font-family: var(--font-ui); }

.mappe-body code {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.05em 0.3em;
  font-size: 0.86em;
}

/* Sprung-Navigation der Mappe */
.mappe-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.7rem 0.9rem;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: var(--gap-l);
}

.mappe-nav a {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.mappe-nav a:hover {
  color: var(--green-deep);
  border-color: var(--green-line);
  background: var(--panel);
}

/* ==========================================================================
   Druckbild — die Mappe als Ausdruck/PDF (Design-Brief §6.5)
   ========================================================================== */

@media print {
  :root {
    --paper: #fff;
    --panel: #fff;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
  }

  /* Chrome der Anwendung ausblenden — Flächen setzen bei Bedarf eigene
     Selektoren dazu (siehe kanzlei.css/consumer.css). */
  .topbar,
  .no-print,
  .portal-switcher,
  .mappe-nav,
  .btn,
  button,
  input,
  select,
  textarea {
    display: none !important;
  }

  .data-card,
  .table-wrap,
  details.details-card {
    border-color: #999;
    box-shadow: none;
    break-inside: avoid;
  }

  .mappe-body {
    max-width: none;
    font-size: 11.5pt;
    line-height: 1.6;
  }

  .mappe-body > h2 {
    border-top: 0;
    margin-top: 0;
  }

  /* Jede ##-Sektion der Mappe beginnt auf einer neuen Seite (Kanzlei-Usus) */
  .mappe-body > h3 { break-before: page; }

  .mappe-body > h3:first-of-type { break-before: auto; }

  .mappe-body blockquote {
    background: none;
    border-left: 2.5px solid #000;
    font-style: italic;
  }

  a { color: #000; text-decoration: underline; }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #333;
    word-break: break-all;
  }

  th { background: #eee; color: #000; }

  .pill { border: 1px solid #000; background: none; color: #000; }

  .fehler-karte,
  .hinweis-karte,
  .notiz-karte {
    border: 1.5px solid #000;
    background: none;
    color: #000;
  }
}

/* Native file-inputs in engen Grids: Dateiname-Anzeige nicht abschneiden
   ("Keine ausgewaehlt" wurde im Kanzlei-Intake zu "K.") */
input[type="file"] { min-width: 0; max-width: 100%; }
