/* Seitenleiste (Bereiche), Suche, Benutzermenue, schmale Bildschirme.
   Teil des frueheren portal.css (Refactoring 23.11.2026). portal.html laedt
   die Teile in DIESER Reihenfolge — die Kaskade bleibt dieselbe. */
    /* ===== left sidebar (section nav) ===== */
    .side {
      position: sticky;
      top: 0;
      height: 100vh;
      display: flex;
      flex-direction: column;
      gap: 6px;
      padding: 18px 12px;
      border-right: 1px solid var(--line);
      background: color-mix(in srgb, var(--bg) 62%, transparent);
      backdrop-filter: blur(12px);
    }
    /* ── FLAECHEN, DIE DEN SCHLEIER NICHT ZERSCHNEIDEN DUERFEN ──────────
       Erica, 03.10.2026: „los colores de degradado del fondo se ven como
       cortados". Gemessen im echten Cockpit (scripts/hintergrund-check.js):
       an drei Stellen sprang die Farbe schlagartig um bis zu 34 Stufen —
       am rechten Rand der Seitenspalte, unter dem Kopfband und unter der
       Reiterleiste. Der Grund ist immer derselbe: der Schleier liegt als
       FIXIERTE Ebene hinter der Seite (body::before), und jede Flaeche, die
       darueber ihr eigenes --bg malt, stanzt ein sauberes Rechteck hinein.
       Bei der gelben Hausfarbe des Pilotbetriebs ist der Schleier kraeftig, also war das
       Rechteck deutlich zu sehen.

       Verstecken geht nicht: die Leisten MUESSEN deckend sein, sonst scrollt
       die Liste sichtbar unter ihnen durch. Also malen sie denselben
       Verlauf noch einmal — mit background-attachment:fixed, das heisst an
       derselben Stelle wie die Ebene darunter. Deckend und trotzdem
       unsichtbar.

       Nur fuer breite Schirme: auf dem Handy wird die Spalte zur Leiste am
       unteren Rand, und fixierte Hintergruende sind dort (iOS) unzuverlaessig
       — dann lieber der alte, schlichte Grund. */
    @media (min-width: 1001px) {
      .side,
      .topbar,
      .mainpane .topbar,
      .inbox-list > .toolbar,
      #dp_grid thead th {
        background: var(--wash), var(--bg);
        background-attachment: fixed, fixed;
      }
      /* Die Spalte bleibt eine Spalte — aber durch die Linie rechts, nicht
         durch einen Farbblock. Das Weichzeichnen hatte nur Sinn, solange sie
         durchscheinend war. */
      .side { backdrop-filter: none; }

      /* ── WEICHE RAENDER ───────────────────────────────────────────────
         Erica, 03.10.2026: „no se pueden hacer los bordes como difuminados
         para que no se note tanto el corte?" — doch, und genau so gehoert
         es sich.

         Der Grund der Leisten ist jetzt nahtlos, aber sie bleiben deckend:
         sobald eine Zeile darunter wegscrollt, wird sie an der Unterkante
         GEKAPPT — ein waagerechter Schnitt quer durchs Bild. Eine Maske
         laesst die Leiste auf den letzten Pixeln ausblenden: die Zeile
         verschwindet, statt abgeschnitten zu werden.

         Die Leisten haben unten extra Luft, damit die Maske nur den
         leeren Rand erwischt und nie den Text oder die Reiter. */
      .topbar,
      .inbox-list > .toolbar {
        /* Die Leiste reicht jetzt bis an den Rand des Arbeitsbereichs.
           Vorher endete sie am Textrand und liess links und rechts je 26
           Pixel blank — gemessen: dort schien die Liste in voller Staerke
           durch, waehrend sie zwei Zentimeter weiter innen verdeckt war.
           Das war der Rest, den Erica noch sah: „el borde de abajo ya esta
           arreglado pero no el de los laterales."
           Negative Aussen- plus gleich grosse Innenabstaende: die Leiste
           waechst, ihr Inhalt bleibt, wo er war. */
        margin-left: -26px;
        margin-right: -26px;
        padding-left: 26px;
        padding-right: 26px;
        padding-bottom: 22px;
        /* Zwei Masken, und es zaehlt nur, wo BEIDE decken: unten blendet sie
           aus, links und rechts ebenso. Die seitlichen 20 Pixel liegen im
           neuen Aussenrand, also nie auf Text oder Knopf. */
        -webkit-mask-image:
          linear-gradient(to bottom, #000 calc(100% - 18px), transparent),
          linear-gradient(to right, transparent, #000 20px, #000 calc(100% - 20px), transparent);
        mask-image:
          linear-gradient(to bottom, #000 calc(100% - 18px), transparent),
          linear-gradient(to right, transparent, #000 20px, #000 calc(100% - 20px), transparent);
        -webkit-mask-composite: source-in;
        mask-composite: intersect;
      }
      /* Auch die Trennlinie der Spalte endet nicht mehr abrupt: sie wird
         oben und unten zu nichts. Darum als eigene Flaeche statt als
         border-right — ein Rahmen kann nicht ausblenden. */
      .side { border-right: 0; position: relative; }
      .side::after {
        content: '';
        position: absolute;
        top: 0; right: 0; bottom: 0;
        width: 1px;
        background: linear-gradient(to bottom, transparent, var(--line) 12%, var(--line) 88%, transparent);
        pointer-events: none;
      }
    }

    .side-brand { padding: 4px 8px 14px; }
    .side-brand .brand-logo { height: 54px; max-width: 200px; }

    .secnav {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
    .secbtn {
      display: flex;
      align-items: center;
      gap: 11px;
      width: 100%;
      text-align: left;
      border: 1px solid transparent;
      background: none;
      border-radius: 11px;
      padding: 10px 13px;
      font-weight: 600;
      font-size: 14px;
      color: var(--muted);
      cursor: pointer;
      transition: .15s;
    }
    .secbtn .nic { width: 20px; height: 20px; flex: none; display: inline-flex; align-items: center; justify-content: center; }
    .secbtn .nic svg { width: 19px; height: 19px; stroke-width: 1.75; }
    .secbtn .nlb { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .secbtn:hover { color: var(--ink); background: var(--surface); }
    .secbtn.active {
      color: var(--ink);
      background: color-mix(in srgb, var(--brand) 12%, var(--surface));
      border-color: color-mix(in srgb, var(--brand) 34%, var(--line));
      box-shadow: var(--shadow);
      position: relative;
    }
    /* Accent bar on the active tab — uses the tenant's own accent (solid or
       gradient), so it follows whatever colour the client picked. */
    .secbtn.active::before {
      content: "";
      position: absolute;
      left: 3px; top: 9px; bottom: 9px;
      width: 3px; border-radius: 3px;
      background: var(--accent);
    }

    /* Sidebar sections (collapsible groups) — tame the long list of tabs. */
    .secgrp { display: flex; flex-direction: column; gap: 4px; }
    .secgrp + .secgrp { margin-top: 8px; }
    .secgrp-h {
      display: flex; align-items: center; gap: 6px; width: 100%;
      background: none; border: 0; cursor: pointer;
      padding: 5px 13px 3px; color: var(--muted);
      font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
    }
    .secgrp-h .nlb { flex: 1; text-align: left; }
    .secgrp-h:hover { color: var(--ink); }
    .secgrp-cv { width: 13px; height: 13px; flex: none; transition: transform .18s; opacity: .65; }
    .secgrp.collapsed .secgrp-cv { transform: rotate(-90deg); }
    .secgrp-b { display: flex; flex-direction: column; gap: 4px; }
    .secgrp.collapsed .secgrp-b { display: none; }
    .secgrp.gh-empty { display: none; }

    .side-foot {
      margin-top: auto;
      display: flex;
      flex-direction: column;
      gap: 10px;
      padding: 12px 6px 4px;
      border-top: 1px solid var(--line);
    }
    .side-foot .client-chip { width: 100%; }
    .side-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

    .mainpane { min-width: 0; padding: 0 26px 70px; }
    /* search lives in the top bar (fixed box, right side) */
    .mainpane .topbar .search { flex: 0 0 auto; width: 280px; max-width: 44vw; }

    /* user chip → click reveals the tools (theme / language / logout) */
    .side-foot { position: relative; }
    .user-btn {
      display: flex; align-items: center; gap: 10px; width: 100%;
      padding: 9px 10px; border-radius: 12px; border: 1px solid var(--line);
      background: var(--surface); box-shadow: var(--shadow);
      cursor: pointer; font: inherit; text-align: left;
    }
    .user-btn .av { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff;
      display: grid; place-items: center; font-size: 11px; font-weight: 800; flex: none; }
    .user-btn .un { font-size: 12.5px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.25; }
    .user-btn .un b, .user-btn .un small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .user-btn .un small { font-size: 11px; font-weight: 500; color: var(--muted); }
    .user-btn .chev { color: var(--muted); font-size: 13px; transition: .2s; }
    .user-btn.open .chev { transform: rotate(180deg); }
    .user-menu {
      position: absolute; bottom: 62px; left: 12px; right: 12px;
      background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
      box-shadow: var(--shadow-lg); padding: 7px; z-index: 60;
      display: flex; flex-direction: column; gap: 2px;
      animation: umRise .16s ease;
    }
    @keyframes umRise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
    .um-row {
      display: flex; align-items: center; gap: 11px; width: 100%;
      padding: 9px 11px; border: 0; border-radius: 10px;
      background: none; color: var(--ink); font: inherit; font-size: 13.5px; font-weight: 600;
      cursor: pointer; text-align: left;
    }
    .um-row:hover { background: var(--brand-soft); }
    .um-row.danger { color: #b91c1c; }
    .um-row.danger:hover { background: #fee2e2; }
    [data-theme="dark"] .um-row.danger { color: #fca5a5; }
    [data-theme="dark"] .um-row.danger:hover { background: #2a1215; }
    .um-ic { width: 20px; text-align: center; font-size: 15px; }
    .um-lang { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 11px; }
    .um-lang .um-lb { font-size: 13px; font-weight: 600; color: var(--muted); }
    .um-sep { height: 1px; background: var(--line); margin: 4px 6px; }
    .um-ver { text-align: center; padding: 4px 0 2px; }
    .um-ver #vStamp { font-size: 10.5px; color: var(--muted); opacity: .6; }

    /* priority as a coloured dot (not a line) */
    /* leads: just a coloured priority dot on the left (no avatar) */
    .lead > .pdot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: #cbd5e1; box-shadow: 0 0 0 4px color-mix(in srgb, #cbd5e1 26%, transparent); }
    .lead > .pdot.hot  { background: #dc2626; box-shadow: 0 0 0 4px rgba(220, 38, 38, .16); }
    .lead > .pdot.warm { background: #d97706; box-shadow: 0 0 0 4px rgba(217, 119, 6, .16); }
    .lead > .pdot.cold { background: #2563eb; box-shadow: 0 0 0 4px rgba(37, 99, 235, .16); }
    .lead .lchan { font-weight: 400; font-size: 13px; opacity: .85 }

    @media (max-width: 1000px) {
      .side-foot .user-btn .un { display: none; }
      .mainpane .topbar .search { width: 100%; max-width: none; }
    }

    /* narrow screens: sidebar collapses to a horizontal bar on top */
    @media (max-width: 1000px) {
      #app { grid-template-columns: 1fr; }
      /* fixed bottom bar — icons over labels, like the mobile mockup */
      .side {
        position: fixed;
        top: auto; bottom: 0; left: 0; right: 0;
        height: auto;
        flex-direction: row;
        align-items: stretch;
        gap: 2px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-right: 0;
        border-top: 1px solid var(--line);
        background: color-mix(in srgb, var(--bg) 88%, transparent);
        z-index: 40;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
      }
      .side-brand { display: none; }
      .secnav { flex: 1; flex-direction: row; justify-content: space-around; gap: 2px; }
      /* On the mobile bottom-bar the groups dissolve: headers hide and buttons
         flow straight into the row (display:contents), ignoring collapse state. */
      .secgrp, .secgrp-b { display: contents; }
      .secgrp.collapsed .secgrp-b { display: contents; }
      .secgrp-h { display: none; }
      .secgrp + .secgrp { margin-top: 0; }
      .secbtn {
        flex-direction: column;
        gap: 3px;
        padding: 6px 6px;
        min-width: 58px;
        font-size: 10px;
        font-weight: 700;
        align-items: center;
        justify-content: center;
        text-align: center;
      }
      .secbtn .nic { font-size: 19px; width: auto; }
      .secbtn .nlb { flex: none; }
      .side-foot {
        margin: 0;
        flex-direction: row;
        align-items: center;
        border-top: 0;
        padding: 0 2px 0 6px;
      }
      .side-foot .user-btn { padding: 6px; }
      .side-foot .client-chip { display: none; }
      /* fixed so the popup escapes the bottom bar's overflow clipping */
      .user-menu { position: fixed; bottom: 66px; top: auto; left: auto; right: 8px; width: 210px; }
      .mainpane { padding: 0 16px 92px; }
    }
