/* Vertrieb.web - Shell-Layout um die DevExtreme-Widgets
   (uebernommen aus Homepage.customer.portal/web/css/portal.css, helles Material-Theme) */
:root {
  --bg:       #f3f5f8;
  --surface:  #ffffff;
  --surface2: #f7f8fa;
  --border:   #dfe3e8;
  --text:     #1f2933;
  --muted:    #6b7280;
  --primary:  #1976d2;
  --danger:   #d32f2f;
  --ok:       #2e7d32;
  --r:        8px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: Roboto, "Segoe UI", Helvetica, Arial, sans-serif; font-size: 13px;
}
a { color: var(--primary); }

/* === Login === */
#login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 32px 40px; width: 420px; max-width: 100%;
  box-shadow: 0 4px 24px rgba(0,0,0,.06);
}
.login-logo { display: block; height: 36px; width: auto; margin: 0 auto 16px; }
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-card p  { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.login-card .field { margin-bottom: 14px; }
.login-card .field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.login-error { color: var(--danger); font-size: 13px; margin-bottom: 14px; }

/* === App-Shell === */
#app { display: none; flex-direction: column; height: 100vh; }
header.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 16px; display: flex; align-items: center; gap: 12px; height: 48px; flex-shrink: 0;
}
.topbar-logo { height: 30px; width: auto; }
header.topbar .title { font-size: 15px; font-weight: 600; flex: 1; }
.user-badge {
  font-size: 12px; color: var(--muted); background: var(--surface2);
  border: 1px solid var(--border); padding: 3px 10px; border-radius: 20px;
}
/* Mandant neben dem Anmeldenamen; alles ausser dem produktiven Mandanten faellt farbig auf */
.mandant-badge.mandant-test { background: #fff3e0; color: #b45309; border-color: #f59e0b; font-weight: 600; }
.main { display: flex; flex: 1; min-height: 0; }
#main-splitter .dx-splitter-item-content { overflow: hidden; height: 100%; }

nav#sidebar { width: 100%; height: 100%; background: var(--surface); padding: 6px 4px; overflow-y: auto; }
nav#sidebar .dx-treeview-item { padding-top: 2px; padding-bottom: 2px; min-height: 26px; }
nav#sidebar .dx-treeview-node { padding-inline-start: 18px; }
nav#sidebar .dx-treeview .dx-treeview-node.dx-treeview-root-node { padding-inline-start: 0; }
nav#sidebar .nav-badge {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px;
  border-radius: 10px; background: var(--primary); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}

.content { height: 100%; padding: 12px 16px; overflow-y: auto; min-width: 0; }
.page { display: none; }
.page.active { display: block; }
.page h1 { font-size: 18px; margin: 0 0 12px; }
.page h2 { font-size: 15px; margin: 16px 0 6px; }
.page p  { line-height: 1.5; margin: 6px 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; margin-bottom: 12px; }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.section-title  { font-size: 16px; font-weight: 600; }
.section-subtitle { color: var(--muted); font-size: 12px; margin-top: 1px; }
.toolbar { display: flex; gap: 10px; align-items: center; }
/* Kopfzeile bleibt beim Scrollen stehen (Adressseite); deckt das Padding von .content mit ab */
.sticky-header { position: sticky; top: -12px; z-index: 10; background: var(--bg); margin: -12px -16px 8px; padding: 12px 16px 8px; border-bottom: 1px solid var(--border); }
.text-muted { color: var(--muted); }
.text-ok { color: var(--ok); }
.text-danger { color: var(--danger); }
/* Hotline-Status auf der Adressseite: frei / Achtung / kostenpflichtig */
.hotline-badge { justify-self: start; padding: 1px 8px; border-radius: 10px; font-weight: 600; border: 1px solid transparent; }
.hotline-frei            { background: #e8f5e9; color: #1b5e20; border-color: #a5d6a7; }
.hotline-achtung         { background: #fff8e1; color: #8a5a00; border-color: #ffd54f; }
.hotline-kostenpflichtig { background: #fdecea; color: #b71c1c; border-color: #f5c6c2; }
.load-error { background: #fdecea; border: 1px solid #f5c6c2; border-radius: var(--r); padding: 10px 14px; color: #b71c1c; }

/* Uebersicht: Kacheln */
.tiles { display: flex; flex-wrap: wrap; gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 16px; min-width: 200px; flex: 1 1 200px; cursor: pointer; }
.tile:hover { border-color: var(--primary); }
.tile .tile-title { font-weight: 600; margin-bottom: 4px; }
.tile .tile-text { color: var(--muted); font-size: 12px; }

/* Vertragsdetail: Kopf als Schluessel/Wert-Raster */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; align-items: baseline; }
.kv .k { color: var(--muted); }
.kv-cols { display: flex; gap: 32px; flex-wrap: wrap; }
.kv-cols .kv { flex: 1 1 320px; }

/* Dichte Tabellen */
.dx-datagrid .dx-datagrid-headers .dx-header-row > td { padding: 4px 8px; white-space: nowrap; font-size: 12px; }
/* bis 2026-10-12 stand white-space: nowrap in der folgenden Regel fuer ALLE Listen - das ueberstimmte wordWrapEnabled
   (Protokoll: lange Texte brachen nicht um). Jetzt nur noch fuer Listen ohne Umbruch (DevExtreme setzt dort dx-datagrid-nowrap). */
.dx-datagrid .dx-datagrid-rowsview .dx-row > td { padding: 3px 8px; }
.dx-datagrid .dx-datagrid-rowsview.dx-datagrid-nowrap .dx-row > td { white-space: nowrap; }
/* einzelne Zelle in einer Liste ohne Umbruch trotzdem umbrechen (Rechnungslauf, Spalte Ergebnis) */
.cell-wrap { white-space: normal; line-height: 1.35; overflow-wrap: anywhere; }
/* Listen MIT Umbruch (wordWrapEnabled: Protokoll, Aktivitaeten der Adresse): auch lange Zeichenfolgen ohne Leerzeichen
   umbrechen (URL-Parameter "winava=false&netbau=false&...", Message-IDs). Ohne das bestimmt die laengste solche Folge
   die Spaltenbreite, die Liste wird breiter als der Platz und man muss waagerecht rollen (Ronald 2026-10-12). */
.dx-datagrid .dx-datagrid-rowsview:not(.dx-datagrid-nowrap) .dx-row > td { overflow-wrap: anywhere; }
/* In hohen Zeilen stehen Datum, Kuerzel, Symbol und Haken oben neben der ersten Textzeile statt in der Zeilenmitte
   (Ronald 2026-10-12). Gleiche Zeilenhoehe wie .adr-wrap, damit die ersten Zeilen aller Spalten auf einer Linie stehen. */
/* Der lange Selektor ist noetig: das Thema setzt vertical-align: middle mit
   .dx-datagrid .dx-datagrid-content .dx-datagrid-table .dx-row>td:not(.dx-validation-pending):not(.dx-datagrid-select-all) */
.dx-datagrid .dx-datagrid-rowsview:not(.dx-datagrid-nowrap) .dx-datagrid-table .dx-row.dx-data-row > td:not(.dx-validation-pending):not(.dx-datagrid-select-all) { vertical-align: top; line-height: 1.35; }
/* Haken-Zellen (nur Anzeige): das Thema blaeht sie ueber ein ::before mit je 10 px Polster auf und setzt den Haken in die
   Mitte - einzeilige Zeilen wurden dadurch hoeher als ihr Text und der Haken stand tiefer als die erste Textzeile.
   Hier: Polster weg, Zelle mit demselben Rand wie die Textzellen. */
.dx-datagrid .dx-datagrid-rowsview:not(.dx-datagrid-nowrap) .dx-data-row > td.dx-editor-cell.dx-editor-inline-block.dx-datagrid-readonly:not(.dx-command-select)::before { padding-top: 0; padding-bottom: 0; }
.dx-datagrid .dx-datagrid-rowsview:not(.dx-datagrid-nowrap) .dx-datagrid-table .dx-row.dx-data-row > td.dx-editor-cell.dx-datagrid-readonly:not(.dx-validation-pending):not(.dx-datagrid-select-all) { padding-top: 3px; padding-bottom: 3px; }
.dx-datagrid .dx-datagrid-rowsview .dx-group-row > td { padding: 3px 8px; }
.dx-datagrid .dx-command-edit .dx-link { margin: 0 3px; }
/* Vor-/Nachtext eines Belegs (HTML aus RTF, vertrag.js) */
.belegtext { margin-top: 10px; }
.belegtext-body { max-width: 900px; line-height: 1.45; }
.belegtext-body p, .belegtext-body div { margin: 0; }
.belegtext-body table { border-collapse: collapse; }
.belegtext-body td { padding: 0 6px 0 0; vertical-align: top; }

/* PDF-Ansicht (js/pdfviewer.js): iframe fuellt das Popup */
.pdf-frame { width: 100%; height: 100%; border: 0; display: block; }
.dx-popup-content:has(> .pdf-frame) { padding: 0; }

.row-gekuendigt td { color: var(--muted); }
/* Rechnungslauf: gesperrt (nicht waehlbar), erledigt, fehlgeschlagen */
.row-gesperrt td { color: var(--muted); }
.row-gesperrt .dx-select-checkbox { visibility: hidden; }
/* bis 2026-10-12: .row-erledigt td / .row-fehler td - zu schwach: die Wechselfarbe des Themas (.dx-datagrid .dx-row-alt > td)
   gewann, die Farbe erschien nur auf jeder zweiten Zeile. Die Regeln muessen auch die weisse Flaeche festgehefteter Zellen
   (.dx-datagrid .dx-datagrid-sticky-column*, Spalte Ergebnis im Rechnungslauf) ueberstimmen.
.row-erledigt td { background: #eef7ee; }
.row-fehler td { background: #fdecea; } */
.dx-datagrid .dx-datagrid-rowsview .dx-row.row-erledigt > td { background-color: #eef7ee; }
.dx-datagrid .dx-datagrid-rowsview .dx-row.row-fehler > td { background-color: #fdecea; }
.row-abgelaufen td { color: var(--danger); }

@media (max-width: 800px) {
  .content { padding: 14px 16px; }
  .topbar-logo { display: none; }
}

/* Credits buchen (ki.js, Bauabschnitt 6) */
.buchen-form .field { margin-bottom: 12px; }
.buchen-form label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 13px; }
.buchen-info { margin-bottom: 12px; }
.buchen-confirm { max-width: 440px; white-space: normal; line-height: 1.45; }
.buchen-confirm p { margin: 0 0 8px; }
.buchen-confirm p:last-child { margin-bottom: 0; }
.buchen-hinweis { margin: -6px 0 12px; font-size: 12px; }
.buchen-result { margin-top: 14px; }
.buchen-result .kv { margin: 8px 0; }
.buchen-result .load-error { margin-top: 8px; }
.buchen-ok { color: #2e7d32; font-weight: 600; }

/* Adressanzeige (adresse.js) */
.adr-card-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.adr-card-head h2 { margin: 0; }
.adr-card-head .dx-button { margin-left: auto; align-self: center; }
.adr-sub { font-weight: 600; margin: 14px 0 6px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }
.adr-empty { padding: 6px 0 2px; }
.adr-bemerkung { margin-top: 10px; white-space: pre-wrap; background: #f7f7fa; border-radius: var(--r); padding: 8px 12px; overflow-wrap: anywhere; }
/* HTML-Auszeichnung in den Bemerkungen (adresse.js safeHtml): Abstaende kommen aus den Zeilenwechseln des Textes */
.adr-bemerkung p, .adr-bemerkung div, .adr-bemerkung ul, .adr-bemerkung ol, .adr-bemerkung blockquote, .adr-bemerkung pre { margin: 0; }
.adr-bemerkung h1, .adr-bemerkung h2, .adr-bemerkung h3, .adr-bemerkung h4, .adr-bemerkung h5, .adr-bemerkung h6 { margin: 0; font-size: 1.1em; }
.adr-bemerkung a[href] { color: #1984b4; }
.adr-bemerkung td, .adr-bemerkung th { border: 1px solid #d8d8e0; padding: 2px 6px; white-space: normal; }
.adr-bemerkung table { border-collapse: collapse; }
.adr-wrap { white-space: normal; line-height: 1.35; overflow-wrap: anywhere; }
/* Typ-Symbol in den Aktivitaeten der Adresse (statt der Textspalte "Typ") */
.akt-typ { font-size: 18px; color: var(--muted); cursor: default; }
/* Sammelknopf "Credits" in der Kopfzeile der Adresse: Eintrag mit Symbol, bei gesperrten Eintraegen der Grund darunter */
.credit-item-text { display: flex; align-items: center; gap: 10px; }
.credit-item-grund { margin: 2px 0 0 28px; font-size: 12px; white-space: normal; line-height: 1.3; }
.adr-link { color: inherit; text-decoration: underline dotted; }
/* Adressliste: grosses, umrandetes Suchfeld; die Werkzeugleiste nimmt dafuer die freie Breite der Kopfzeile */
#adressen-toolbar { flex: 1 1 560px; justify-content: flex-end; }
.adr-suche { flex: 1 1 420px; max-width: 680px; min-width: 260px; }
.adr-suche.dx-texteditor.dx-editor-outlined { background: #fff; border-radius: 6px; box-shadow: inset 0 0 0 2px #1984b4; }
.adr-suche.dx-texteditor.dx-editor-outlined.dx-state-focused { box-shadow: inset 0 0 0 2px #1984b4, 0 0 0 3px rgba(25, 132, 180, .22); }
.adr-suche .dx-texteditor-input { font-size: 15px; min-height: 40px; }
.adr-suche .dx-placeholder { font-size: 15px; }
.adr-suche-btn.dx-button { height: 40px; }
/* Adressliste: zweite Zeile unter dem Sortierbegriff, ueber wen die Suche die Adresse gefunden hat */
.adr-treffer { color: var(--muted); font-size: 11px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }
.adr-link:hover { color: #1984b4; }

/* Seite Registrierung: Ablageflaeche, Felder der Registrierung, Trefferlisten */
.reg-eingabe { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.reg-links { flex: 1 1 360px; min-width: 300px; display: flex; flex-direction: column; gap: 8px; }
.reg-drop { border: 2px dashed var(--border); border-radius: var(--r); padding: 16px; text-align: center; color: var(--muted); cursor: pointer; }
.reg-drop b { display: block; color: #333; font-weight: 600; margin-bottom: 2px; }
.reg-drop.aktiv { border-color: #1984b4; background: #eef7fb; }
.reg-felder { flex: 1 1 380px; display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; align-items: center; }
.reg-felder label { color: var(--muted); }
.reg-meta { color: var(--muted); font-size: 12px; margin-top: 8px; overflow-wrap: anywhere; }
.reg-meta.reg-fehler { color: #b71c1c; }
.reg-klein { color: var(--muted); font-size: 12px; }
.reg-table { width: 100%; border-collapse: collapse; }
.reg-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 4px 12px 4px 0; border-bottom: 1px solid var(--border); }
.reg-table td { padding: 5px 12px 5px 0; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.reg-table tr:last-child td { border-bottom: 0; }
.reg-stark .adr-link { font-weight: 600; }
.reg-aktion { white-space: normal; max-width: 270px; }
.reg-aktion a { display: inline-block; margin-right: 12px; color: #1984b4; text-decoration: none; line-height: 1.5; white-space: nowrap; }
.reg-aktion a:hover { text-decoration: underline; }
.reg-aktion a.reg-schritt1 { font-weight: 600; }
.reg-erledigt { margin-top: 6px; }
.reg-dialog { max-height: 72vh; overflow-y: auto; padding-right: 4px; }
.reg-dialog .buchen-info b { display: block; }
.reg-dialog-felder.reg-zweispaltig { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.reg-dialog-felder.reg-zweispaltig .reg-breit { grid-column: 1 / -1; }
.reg-zuordnung { margin-top: 0; }
.reg-zuordnung.reg-fehler { color: #b71c1c; }
.reg-auch span { display: inline-block; padding: 0 8px; margin: 0 4px 2px 0; border-radius: 10px; font-size: 12px; background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }
.tile-title { color: var(--muted); font-size: 13px; }
.tile-value { font-size: 22px; font-weight: 600; margin: 2px 0; }
.tile-sub { font-size: 12px; }
