/* DIE AKTEN IM NEUEN DESIGN (F-0022, 18.10.2026; F-0024: Reiter, Verlauf-Titel; F-0025: Ablage).

   Gilt fuer alle Detailseiten des CRM (Kunde, Opportunity, Lead, Angebot, Vertrag, Ticket,
   Installation, Produkt, Projekt, Agent): crm-akte.js ordnet das bestehende Markup in
   Kopfband + Hauptspalte + rechte Seitenspalte um (Vorbild: Artboard D20 "Projekt" und das
   Panel in D15). Die Elemente bleiben unveraendert; hier wird nur gestaltet.

   Muster A: .crm-krumen + .crm-akte-kopf  (Akten mit Kachel, Chips, Feldraster)
   Muster B: .crm-kopf (h1 + .crm-kopf-tat) (Angebot, Listen)

   Alle Regeln haengen an .crm-ak (setzt das Skript) und schlagen so crm.css. */

.crm-seite.crm-ak { display: flex; flex-direction: column; gap: 0; }

/* ---------- Das Kopfband ---------- */
.crm-ak-band {
  margin: -20px -24px 20px;
  padding: 12px 24px 0;
  background:
    radial-gradient(45% 170% at 100% 0%, color-mix(in srgb, var(--obs-primary) 14%, transparent), transparent 60%),
    var(--obs-surface);
  border-bottom: 1px solid var(--obs-border);
  display: flex; flex-direction: column; gap: 8px;
}
.crm-ak-pfadzeile { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 28px; }
.crm-ak-pfadzeile nav { font-family: var(--obs-font-mono); font-size: 12px; line-height: 16px; color: var(--obs-text-faint); }
.crm-ak-pfadzeile nav a { color: inherit; text-decoration: none; }
.crm-ak-pfadzeile nav a:hover { color: var(--obs-text); text-decoration: underline; }
.crm-ak .crm-krumen-tat, .crm-ak .crm-kopf-tat { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Muster A: die Kopfkarte wird zum Band-Inhalt */
.crm-ak .crm-akte-kopf {
  background: transparent; border: 0; box-shadow: none; border-radius: 0;
  padding: 0 0 14px; margin: 0; display: flex; flex-direction: column; gap: 12px;
}
.crm-ak .crm-akte-oben { display: flex; align-items: center; gap: 12px; justify-content: flex-start; flex-wrap: wrap; }
.crm-ak .crm-akte-kachel.crm-initialen {
  width: 42px; height: 42px; border-radius: 13px; font-size: 15px; font-weight: 800;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--obs-primary) 30%, transparent);
}
.crm-ak .crm-akte-kachel.crm-initialen[data-ton="0"] { background: linear-gradient(135deg, #8B86FF, #4C44E0) !important; }
.crm-ak .crm-akte-kachel.crm-initialen[data-ton="1"] { background: linear-gradient(135deg, #C4B5FD, #7C3AED) !important; }
.crm-ak .crm-akte-kachel.crm-initialen[data-ton="2"] { background: linear-gradient(135deg, #FDA4AF, #E11D48) !important; }
.crm-ak .crm-akte-kachel.crm-initialen[data-ton="3"] { background: linear-gradient(135deg, #2DD4BF, #0E9F9A) !important; }
.crm-ak .crm-akte-kachel.crm-initialen[data-ton="4"] { background: linear-gradient(135deg, #FCD34D, #D97706) !important; }
.crm-ak .crm-akte-kachel.crm-initialen[data-ton="5"] { background: linear-gradient(135deg, #93C5FD, #2563EB) !important; }
.crm-ak .crm-akte-titel { flex: 0 1 auto; min-width: 0; }
.crm-ak .crm-akte-titel h1 { font-size: 22px; line-height: 28px; font-weight: 800; letter-spacing: -.02em; margin: 0; color: var(--obs-text); }
.crm-ak .crm-akte-titel p { margin: 2px 0 0; font-size: 13px; line-height: 18px; color: var(--obs-text-muted); }
.crm-ak .crm-akte-chips { display: flex; gap: 6px; flex-wrap: wrap; align-self: center; }

.crm-ak .crm-pille {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: 999px; font-size: 12px; line-height: 16px; font-weight: 700; white-space: nowrap;
  background: var(--obs-surface-2); color: var(--obs-text-muted);
}
.crm-ak .crm-pille::before { content: ""; width: 6px; height: 6px; border-radius: 3px; background: currentColor; opacity: 1; font-size: 0; }
.crm-ak .crm-pille--stufe::before { content: ""; width: 6px; height: 6px; border-radius: 3px; background: currentColor; }
.crm-ak .crm-pille--stufe { background: var(--obs-warn-soft); color: var(--obs-warn); }
.crm-ak .crm-pille--stufe[data-stufe="won"] { background: var(--obs-ok-soft); color: var(--obs-ok); }
.crm-ak .crm-pille--stufe[data-stufe="lost"] { background: var(--obs-error-soft); color: var(--obs-error); }
.crm-ak .crm-pille--stufe[data-stufe="negotiation"] { background: var(--obs-primary-soft); color: var(--obs-primary); }
.crm-ak .crm-pille--kunde { background: var(--obs-ok-soft); color: var(--obs-ok); }
.crm-ak .crm-pille--interessent { background: var(--obs-warn-soft); color: var(--obs-warn); }
.crm-ak .crm-pille--eigen { background: var(--obs-primary-soft); color: var(--obs-primary); }

/* Das Feldraster wird zur Meta-Zeile aus Chips */
.crm-ak .crm-akte-raster { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.crm-ak .crm-akte-feld {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  border: 1px solid var(--obs-border-strong); border-radius: 999px; background: var(--obs-surface);
  font-size: 12px; line-height: 16px; white-space: nowrap; max-width: 100%;
}
.crm-ak .crm-akte-feld span { display: inline; margin: 0; font-size: 12px; letter-spacing: 0; text-transform: none; font-weight: 600; color: var(--obs-text-faint); }
.crm-ak .crm-akte-feld span::after { content: ":"; }
.crm-ak .crm-akte-feld b, .crm-ak .crm-akte-feld a { display: inline; font-size: 12px; font-weight: 700; color: var(--obs-text); overflow: hidden; text-overflow: ellipsis; }
.crm-ak .crm-akte-feld a { color: var(--obs-primary); }
.crm-ak .crm-akte-feld--leer { border-style: dashed; }
.crm-ak .crm-akte-feld--leer b { color: var(--obs-text-faint); font-weight: 500; }

/* Stufensteuerung (Opportunity, Lead) als Knopfzeile im Band */
.crm-ak .crm-op-stufen, .crm-ak .crm-le-stufen { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.crm-ak .crm-op-grundzeile { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; }
.crm-ak .crm-op-grundzeile input { flex: 1 1 220px; }

/* Muster B: .crm-kopf */
.crm-ak .crm-kopf { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0; padding: 0 0 14px; }
.crm-ak .crm-kopf h1 { font-size: 22px; line-height: 28px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.crm-ak .crm-kopf-text p { margin: 2px 0 0; font-size: 13px; color: var(--obs-text-muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crm-ak .crm-an-kopfnummer { font-family: var(--obs-font-mono); font-size: 12px; color: var(--obs-text-faint); }

/* Reiter: Unterstrich wie in D20. Mit .obs-main davor, weil obs.css Reiterknoepfe mit
   [role=tablist] button[aria-selected] (0,4,1) einfaerbt. */
.crm-ak .crm-reiter {
  display: flex; gap: 2px; margin: 0 0 18px; padding: 0; background: transparent;
  border-bottom: 1px solid var(--obs-border); flex-wrap: wrap; overflow-x: auto;
}
.obs-main .crm-ak .crm-reiter button {
  height: 38px; padding: 0 12px; margin: 0; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  background: none; box-shadow: none; font: inherit; font-size: 13px; font-weight: 700; color: var(--obs-text-muted); white-space: nowrap;
}
.obs-main .crm-ak .crm-reiter button:hover { color: var(--obs-text); background: none; }
.obs-main .crm-ak .crm-reiter button[aria-selected="true"] { color: var(--obs-text); border-bottom-color: var(--obs-primary); background: none; }
.obs-main .crm-ak .crm-reiter button[disabled] { color: var(--obs-text-faint); opacity: .7; }

/* Knoepfe im Band */
.crm-ak-band .crm-knopf {
  height: 34px; padding: 0 13px; border-radius: 10px; font-size: 13px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--obs-border-strong);
  background: var(--obs-surface); color: var(--obs-text); box-shadow: none; transition: background .12s;
}
.crm-ak-band .crm-knopf:hover { background: var(--obs-surface-2); transform: none; }
.crm-ak-band .crm-knopf--haupt { border-color: transparent; background: var(--obs-primary-gradient); color: var(--obs-on-primary); box-shadow: var(--obs-shadow-primary); }
.crm-ak-band .crm-knopf--still { border-color: transparent; background: transparent; color: var(--obs-text-muted); }
.crm-ak-band .crm-knopf--haupt:hover { filter: brightness(1.05); }
#crm-k-bearbeiten::before { content: none; }

/* Karten */
.crm-ak .crm-block { border-radius: var(--obs-radius-card, 14px); box-shadow: var(--obs-shadow-card); border-color: var(--obs-border); }
.crm-ak .crm-block > h2, .crm-ak .crm-abschnitt h2 { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }

/* ---------- Koerper: Hauptspalte + Seitenspalte ---------- */
.crm-ak-koerper { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; align-items: start; }
.crm-ak-haupt { min-width: 0; }
.crm-ak-seite { min-width: 0; display: flex; flex-direction: column; gap: 14px; position: sticky; top: calc(var(--obsa-top-h, 48px) + 16px); }
.crm-ak-seite > .crm-block { margin: 0; }
/* leere Seitenkarten (noch nicht montiert) bleiben unsichtbar */
.crm-ak-seite > .crm-block:not(:has(> * > *)) { display: none; }
.crm-ak .crm-ak-seite .crm-block > h2 { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--obs-text-faint); margin: 0 0 10px; }

/* ---------- Responsiv ---------- */
@media (max-width: 1279px) {
  .crm-ak-koerper { grid-template-columns: minmax(0, 1fr); }
  .crm-ak-seite { position: static; }
}
@media (max-width: 599px) {
  .crm-ak-band { margin: -16px -14px 16px; padding: 10px 14px 0; }
  .crm-ak .crm-akte-titel h1, .crm-ak .crm-kopf h1 { font-size: 20px; line-height: 26px; }
  .crm-ak .crm-krumen-tat, .crm-ak .crm-kopf-tat { margin-left: 0; width: 100%; }
  .crm-ak .crm-reiter { flex-wrap: nowrap; }
  .crm-ak .crm-akte-feld { height: 28px; }
}

/* Die schmale Schiene (unter 1024 px, 72 px breit) zeigt keinen Hinweistext mehr. */
@media (max-width: 1023px) {
  .obsa-rail .obs-railhint, .obsa-rail .obs-lbl { display: none; }
}

/* Der Verlauf bringt im Pipeline-Panel seine eigene Ueberschrift mit - die Beschriftung davor faellt weg. */
.crm-pl-abschnitt:has(> #crm-opp-strom) > .crm-pl-lbl { display: none; }

/* ---------- Eingebettet in der Desktop-App (html.obsa-eingebettet, siehe crm-akte.js) ----------
   Die App bringt Titelleiste und Seitenleiste selbst mit (D15); die Seite zeigt nur den Inhalt. */
html.obsa-eingebettet .obs-topbar.obsa-top,
html.obsa-eingebettet .obs-rail.obsa-rail,
html.obsa-eingebettet .obsa-bottom,
html.obsa-eingebettet .crm-ws { display: none !important; }
html.obsa-eingebettet .obs-app.obsa { --obsa-top-h: 0px; }
html.obsa-eingebettet .obsa-koerper { padding-bottom: 0; }
html.obsa-eingebettet .crm-lizenz { min-height: calc(100vh - 60px); }

/* ---------- Die Ablage (Dokumente, crm-ablage.js) in den Akten (F-0025) ----------
   crm-ablage.js baut table.crm-an-pos - die Klasse stammt aus crm-angebot.css, das auf den
   Akten nicht geladen ist. Hier die Tabelle und die Hochlade-Leiste im Karten-Look. */
.crm-ak [data-crm-ablage] .crm-an-pos { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 18px; margin: 0 0 12px; }
.crm-ak [data-crm-ablage] .crm-an-pos th {
  text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; font-weight: 700;
  color: var(--obs-text-faint); padding: 0 10px 8px 0; border-bottom: 1px solid var(--obs-border); white-space: nowrap;
}
.crm-ak [data-crm-ablage] .crm-an-pos td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--obs-border); vertical-align: middle; color: var(--obs-text-muted); background: transparent !important; box-shadow: none !important; }
/* freigegebene Datei: gefuelltes Symbol statt blauer Zeile */
.crm-ak [data-crm-ablage] .crm-an-pos tr:has(input:checked) td:first-child a::before { background: var(--obs-primary); }
.crm-ak [data-crm-ablage] .crm-an-pos tr:last-child td { border-bottom: 0; }
.crm-ak [data-crm-ablage] .crm-an-pos td:first-child { color: var(--obs-text); max-width: 420px; overflow-wrap: anywhere; }
.crm-ak [data-crm-ablage] .crm-an-pos td:first-child a { color: var(--obs-text); font-weight: 700; text-decoration: none; }
.crm-ak [data-crm-ablage] .crm-an-pos td:first-child a:hover { color: var(--obs-primary); text-decoration: underline; }
.crm-ak [data-crm-ablage] .crm-an-pos td:first-child a::before {
  content: ""; display: inline-block; width: 14px; height: 14px; margin: 0 8px -2px 0; border-radius: 3px;
  background: var(--obs-primary-soft); border: 1.5px solid var(--obs-primary); box-sizing: border-box;
}
.crm-ak [data-crm-ablage] .crm-an-rechts { text-align: right; font-family: var(--obs-font-mono); font-size: 12px; white-space: nowrap; }
.crm-ak [data-crm-ablage] .crm-an-pos th:nth-child(5), .crm-ak [data-crm-ablage] .crm-an-pos td:nth-child(5) { text-align: center; }
.crm-ak [data-crm-ablage] .crm-an-pos input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--obs-primary); margin: 0; }
.crm-ak [data-crm-ablage] .crm-an-posweg { text-align: right; padding-right: 0; width: 36px; }
.crm-ak [data-crm-ablage] .crm-an-posweg .crm-knopf { width: 28px; height: 28px; padding: 0; border-radius: 8px; font-size: 13px; color: var(--obs-text-faint); }
.crm-ak [data-crm-ablage] .crm-an-posweg .crm-knopf:hover { background: var(--obs-error-soft); color: var(--obs-error); }
.crm-ak [data-crm-ablage] .crm-schild { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; margin-left: 6px; border-radius: 999px; font-size: 11px; font-weight: 700; vertical-align: middle; }
.crm-ak [data-crm-ablage] .crm-schild--warn { background: var(--obs-warn-soft); color: var(--obs-warn); }
.crm-ak [data-crm-ablage] .crm-an-postat {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 12px; margin-top: 4px;
  border: 1px dashed var(--obs-border-strong); border-radius: 10px; background: var(--obs-surface-2); font-size: 13px;
}
.crm-ak [data-crm-ablage] .crm-an-postat input[type="file"] { flex: 1 1 220px; min-width: 0; font: inherit; font-size: 13px; color: var(--obs-text-muted); }
.crm-ak [data-crm-ablage] .crm-an-postat input[type="file"]::file-selector-button {
  font: inherit; font-size: 13px; font-weight: 700; height: 32px; padding: 0 12px; margin-right: 10px; border-radius: 9px;
  border: 1px solid var(--obs-border-strong); background: var(--obs-surface); color: var(--obs-text); cursor: pointer;
}
.crm-ak [data-crm-ablage] .crm-pa-satz { display: inline-flex; align-items: center; gap: 6px; color: var(--obs-text-muted); white-space: nowrap; }
.crm-ak [data-crm-ablage] .crm-pa-satz input { accent-color: var(--obs-primary); margin: 0; }
.crm-ak [data-crm-ablage] .crm-an-postat > .crm-knopf { margin-left: auto; height: 32px; padding: 0 12px; border-radius: 9px; font-weight: 700; font-size: 13px; }
.crm-ak [data-crm-ablage] .crm-leer { margin: 0 0 10px; }
@media (max-width: 599px) {
  .crm-ak [data-crm-ablage] .crm-an-pos th:nth-child(3), .crm-ak [data-crm-ablage] .crm-an-pos td:nth-child(3),
  .crm-ak [data-crm-ablage] .crm-an-pos th:nth-child(4), .crm-ak [data-crm-ablage] .crm-an-pos td:nth-child(4) { display: none; }
}
