/* App-Rahmen: Breite, Kopf, Kacheln, Reiter, Filter, Chips, Sprache, dunkles Thema, Akzentfarben.
   Teil des frueheren portal.css (Refactoring 23.11.2026). portal.html laedt
   die Teile in DIESER Reihenfolge — die Kaskade bleibt dieselbe. */
    /* ---------- APP ---------- */
    /* Die Breite.
       Hier stand 1400px, und ab 1080px Fensterbreite sogar 1180px — auf einem
       Laptop mit 1440 blieben damit 260px leer, auf einem Schreibtisch-Bildschirm
       mit 1920 fast siebenhundert. Genau da fehlt die Breite aber: das
       Wochenraster des Dienstplans, die Auftragstafel und die Liste mit ihren
       Spalten. (Erica, 02.10.2026: „los margenes … son demasiado grandes y se
       pierde muchisimo espacio a los lados".)
       Jetzt nutzt die Anwendung die Breite, die da ist; die Grenze ist nur noch
       ein Anschlag fuer sehr grosse Bildschirme, damit eine Tabelle nicht
       zweieinhalb Meter breit wird. Lesetexte haben ihre eigene Breite dort, wo
       sie stehen (.who, .detail-empty .de-s). */
    #app {
      max-width: 2200px;
      margin: 0 auto;
      display: grid;
      grid-template-columns: 236px minmax(0, 1fr);
      align-items: start;
      min-height: 100vh;
    }

    .topbar {
      position: sticky;
      top: 0;
      z-index: 20;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 16px 0;
      margin-bottom: 8px;
      /* Solid — the tabs stick right below; a fade-to-transparent bottom let
         the scrolling content shine through between logo and tabs. */
      background: var(--bg)
    }

    .greet-date { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); line-height: 1.4; }
    .greet-date:empty { display: none; }
    /* Tap-to-see help bubble (mobile/touch); desktop also gets the native title.
       Inverts with the theme (--ink bg / --bg text) so it reads on both. */
    .hintpop { position: fixed; z-index: 200; max-width: 260px; background: var(--ink); color: var(--bg); padding: 8px 11px; border-radius: 9px; font-size: 12.5px; line-height: 1.45; box-shadow: var(--shadow-lg); pointer-events: none; }
    /* Right side of the Inbox topbar: search + the primary "new lead" action,
       so the button sits top-right on the greeting row (matches the layout). */
    .topbar-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

    .top-right {
      display: flex;
      align-items: center;
      gap: 14px
    }

    .client-chip {
      display: flex;
      align-items: center;
      gap: 9px;
      background: var(--surface);
      border: 1px solid var(--line);
      padding: 7px 12px;
      border-radius: 999px;
      box-shadow: var(--shadow);
      font-size: 13.5px;
      font-weight: 600
    }

    .client-chip .av {
      width: 24px;
      height: 24px;
      border-radius: 50%;
      background: var(--accent);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 11px;
      font-weight: 700
    }

    .icon-btn {
      width: 38px;
      height: 38px;
      border-radius: 11px;
      background: var(--surface);
      border: 1px solid var(--line);
      box-shadow: var(--shadow);
      color: var(--muted);
      font-size: 15px;
      display: flex;
      align-items: center;
      justify-content: center
    }

    .icon-btn:hover {
      color: var(--ink)
    }

    /* stats */
    /* bento action tiles — one glanceable line each */
    .bento { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 12px }
    .bento:empty { display: none }
    .btile {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      border: 1px solid transparent;
      border-radius: 999px;
      padding: 9px 16px;
      cursor: pointer;
      text-align: left;
      font-family: inherit;
      transition: .15s;
      box-shadow: var(--shadow)
    }
    .btile:hover { transform: translateY(-1px) }
    .btile .bic { font-size: 16px }
    .btile .bnum { font-size: 14.5px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap }
    .btile .bsub { font-size: 11.5px; opacity: .7; white-space: nowrap }
    /* tab counts */
    .tab .tcount { font-size: 10.5px; font-weight: 700; opacity: .55; margin-left: 4px; font-variant-numeric: tabular-nums }
    /* filter button + collapsible panel */
    .fbtn { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; font-size: 13.5px; white-space: nowrap }
    .fbtn .fdot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); position: absolute; top: 7px; right: 7px }
    .fpanel {
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: 14px;
      padding: 12px 16px;
      margin-bottom: 12px;
      display: flex;
      flex-direction: column;
      gap: 10px;
      box-shadow: var(--shadow)
    }
    .fprow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap }
    .fplab { font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted) }
    .fprow .fplab { width: 82px; flex: none }
    .fprow .fchips { margin: 0 }
    /* Vier Auswahlfelder nebeneinander, solange Platz ist; darunter zwei, dann
       eines. `auto-fit` statt fester Spalten: die Zeile bricht dort um, wo sie
       muss, und nicht dort, wo jemand eine Breite geraten hat. */
    .fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 12px }
    .ffeld { display: flex; flex-direction: column; gap: 5px; min-width: 0 }
    .ffeld .sel { width: 100%; padding: 9px 11px; font-size: 13.5px; min-height: 42px }
    /* Ein gesetzter Filter faellt auf, ohne zu schreien: nur Rahmen und Schrift
       in der Markenfarbe. Sonst sucht man beim „warum ist die Liste leer?"
       wieder alle Felder ab. */
    .ffeld .sel.aktiv { border-color: var(--brand); color: var(--brand); font-weight: 650 }
    .fzeile { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-top: 2px;
      border-top: 1px solid var(--line); margin-top: 2px }
    .fcheck { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; min-height: 38px }
    .fcheck input { width: auto }
    #fReset { font-size: 13px }
    .btile.hot { background: #FBE9E4; color: #B4443A }
    .btile.draft { background: var(--brand-soft); color: var(--brand-d) }
    .btile.active { border-color: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent) }
    [data-theme="dark"] .btile.hot { background: #33201C; color: #FF9B8F }
    [data-theme="dark"] .btile.draft { background: var(--brand-soft); color: var(--brand) }

    .stats {
      /* one row of equal-width boxes that resize to fit however many pipeline
         stages exist (add/remove a stage → they all re-fit the leads column).
         Falls back to horizontal scroll if there are too many to fit. */
      display: grid;
      grid-auto-flow: column;
      grid-auto-columns: minmax(72px, 1fr);
      gap: 8px;
      margin: 8px 0 16px;
      overflow-x: auto
    }

    .stat {
      min-width: 0;
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: 12px;
      padding: 8px 10px;
      box-shadow: var(--shadow)
    }

    .stat .n {
      font-size: 17px;
      font-weight: 800;
      letter-spacing: -.3px;
      line-height: 1;
      font-variant-numeric: tabular-nums
    }

    .stat .l {
      font-size: 11px;
      color: var(--muted);
      font-weight: 500;
      margin-top: 4px;
      display: flex;
      align-items: center;
      gap: 5px;
      min-width: 0
    }

    .stat .l .lt {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap
    }

    .stat .l .pip {
      width: 7px;
      height: 7px;
      border-radius: 50%;
      flex: none
    }

    /* unified row badge — one visual language for all chips */
    .badge {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 2px 9px;
      border-radius: 999px;
      font-size: 10.5px;
      font-weight: 700;
      line-height: 1.65;
      letter-spacing: .01em;
      vertical-align: middle
    }
    .badge-irr { background:#f1f5f9;color:#64748b;border:1px solid #e2e8f0 }
    .badge-dup { background:#fef2f2;color:#b91c1c;border:1px solid #fecaca }
    .badge-rev-up { background:#f0fdf4;color:#15803d;border:1px solid #bbf7d0 }
    .badge-rev-dn { background:#fef2f2;color:#b91c1c;border:1px solid #fecaca }
    .badge-paid { background:#DCFCE7;color:#166534;border:1px solid #bbf7d0 }
    .badge-inv { background:#F0FDF4;color:#166534;font-size:11px }
    [data-theme="dark"] .badge-irr { background:#1e2330;color:#94a3b8;border-color:#2d3548 }
    [data-theme="dark"] .badge-dup { background:#2a1215;color:#fca5a5;border-color:#7f1d1d }
    [data-theme="dark"] .badge-rev-up { background:#0a2615;color:#4ade80;border-color:#166534 }
    [data-theme="dark"] .badge-rev-dn { background:#2a1215;color:#fca5a5;border-color:#7f1d1d }
    [data-theme="dark"] .badge-paid { background:#0a2615;color:#4ade80;border-color:#166534 }
    [data-theme="dark"] .badge-inv { background:#0a2615;color:#4ade80 }

    /* skeleton shimmer (loading placeholders) */
    .skel {
      position: relative;
      overflow: hidden;
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: 14px
    }
    .skel::after {
      content: '';
      position: absolute;
      inset: 0;
      transform: translateX(-100%);
      background: linear-gradient(90deg, transparent, rgba(148, 161, 182, .16), transparent);
      animation: shimmer 1.2s infinite
    }
    @keyframes shimmer { 100% { transform: translateX(100%) } }
    .skel-row { height: 74px; margin-bottom: 10px }
    .skel-card { height: 56px; margin-bottom: 12px }

    /* reload spinner */
    @keyframes spin { to { transform: rotate(360deg) } }
    .spin { animation: spin .8s linear infinite }

    /* toolbar */
    .toolbar {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
      margin-top: 12px;
      margin-bottom: 16px
    }
    /* The tabs and the filter button stay put while the list scrolls under
       them; the ground colour keeps rows from showing through. Only in the
       inbox — the other toolbars sit above short content. */
    .inbox-list > .toolbar {
      position: sticky;
      top: 0;
      z-index: 5;
      background: var(--bg);
      padding: 6px 0;
      margin-top: 6px;
    }

    .tabs {
      display: flex;
      gap: 6px;
      background: var(--surface);
      border: 1px solid var(--line);
      padding: 5px;
      border-radius: 13px;
      box-shadow: var(--shadow);
      flex-wrap: wrap
    }

    .tab {
      padding: 8px 13px;
      border-radius: 9px;
      font-size: 13px;
      font-weight: 600;
      color: var(--muted);
      background: transparent
    }

    .tab:hover {
      color: var(--ink)
    }

    .tab.active {
      background: var(--brand-soft);
      color: var(--brand-d)
    }

    .search {
      flex: 1;
      min-width: 160px;
      position: relative
    }

    .search input {
      width: 100%;
      padding: 11px 14px 11px 38px;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: var(--surface);
      font-size: 14px;
      outline: none;
      box-shadow: var(--shadow)
    }

    .search input:focus {
      border-color: var(--brand);
      box-shadow: 0 0 0 4px var(--brand-soft)
    }

    .search svg {
      position: absolute;
      left: 13px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--muted)
    }

    .btn-add {
      background: var(--accent);
      color: #fff;
      padding: 11px 16px;
      border-radius: 12px;
      font-weight: 600;
      font-size: 14px;
      box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 38%, transparent);
      white-space: nowrap;
      transition: .15s;
    }

    .btn-add:hover {
      filter: brightness(1.08);
      transform: translateY(-1px);
      box-shadow: 0 9px 22px color-mix(in srgb, var(--brand) 45%, transparent);
    }

    /* segmented sort control */
    .seg {
      display: inline-flex;
      gap: 4px;
      background: var(--surface);
      border: 1px solid var(--line);
      padding: 4px;
      border-radius: 12px;
      box-shadow: var(--shadow)
    }

    .seg-opt {
      padding: 8px 12px;
      border-radius: 9px;
      font-size: 13px;
      font-weight: 600;
      color: var(--muted);
      background: transparent;
      white-space: nowrap
    }

    .seg-opt:hover {
      color: var(--ink)
    }

    .seg-opt.active {
      background: var(--brand-soft);
      color: var(--brand-d)
    }

    /* category filter chips */
    .fchips {
      display: flex;
      gap: 7px;
      flex-wrap: wrap;
      width: 100%;
      margin: -4px 0 16px
    }

    .fchip {
      padding: 6px 12px;
      border-radius: 999px;
      font-size: 12.5px;
      font-weight: 600;
      color: var(--muted);
      background: var(--surface);
      border: 1px solid var(--line)
    }
    /* weekday toggle chips (staff hours) */
    .daychip { min-width: 38px; padding: 6px 9px; border-radius: 9px; font-size: 12.5px; font-weight: 700; cursor: pointer; color: var(--muted); background: var(--surface); border: 1px solid var(--line); font-family: inherit; }
    .daychip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
    /* multi-assignee (Auftrag crew) checkbox chips */
    .asgn-list { display: flex; flex-wrap: wrap; gap: 6px; }
    .asgn-list label { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; cursor: pointer; background: var(--surface); user-select: none; }
    .asgn-list label.on { border-color: var(--brand); background: var(--brand-soft, #eef2ff); color: var(--brand-d, #4338ca); font-weight: 600; }
    .asgn-list input { accent-color: var(--brand); margin: 0; }
    .asgn-list .none { color: var(--muted); font-size: 12.5px; padding: 5px 0; }

    .fchip:hover {
      color: var(--ink);
      border-color: var(--brand)
    }

    .fchip.active {
      background: var(--brand);
      color: #fff;
      border-color: var(--brand)
    }

    .row2col {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      /* the labels inside are :first-child of their column (margin-top:0), so
         give the row itself the same top gap the other fields have */
      margin-top: 18px
    }

    /* language switcher */
    .langsel {
      display: inline-flex;
      gap: 2px;
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: 999px;
      padding: 3px;
      box-shadow: var(--shadow)
    }

    .langsel button {
      padding: 5px 9px;
      border-radius: 999px;
      font-size: 11.5px;
      font-weight: 700;
      color: var(--muted);
      background: transparent;
      letter-spacing: .02em
    }

    .langsel button:hover {
      color: var(--ink)
    }

    .langsel button.active {
      background: var(--brand);
      color: #fff
    }

    /* ===== dark theme ===== */
    [data-theme="dark"] {
      /* 🌙 Midnight Ops — graphite command center, electric accent, deep shadow */
      color-scheme: dark;
      --bg: #0D1016;
      /* Derselbe Schleier in dunkel, an die Betriebsfarbe gebunden: waehlt der
         Betrieb ein eigenes Akzentpaar, faerbt sich der Hintergrund mit. */
      --wash:
        radial-gradient(150% 180% at 95% -40%,
          color-mix(in srgb, var(--brand) 18%, transparent) 0%,
          color-mix(in srgb, var(--brand) 16.92%, transparent) 12%,
          color-mix(in srgb, var(--brand) 13.97%, transparent) 25%,
          color-mix(in srgb, var(--brand) 9.97%, transparent) 38%,
          color-mix(in srgb, var(--brand) 5.94%, transparent) 50%,
          color-mix(in srgb, var(--brand) 2.74%, transparent) 62%,
          color-mix(in srgb, var(--brand) 0.83%, transparent) 75%,
          color-mix(in srgb, var(--brand) 0.1%, transparent) 88%,
          color-mix(in srgb, var(--brand) 0%, transparent) 100%),
        radial-gradient(140% 170% at -18% -10%,
          color-mix(in srgb, var(--acc2) 12%, transparent) 0%,
          color-mix(in srgb, var(--acc2) 11.28%, transparent) 12%,
          color-mix(in srgb, var(--acc2) 9.31%, transparent) 25%,
          color-mix(in srgb, var(--acc2) 6.65%, transparent) 38%,
          color-mix(in srgb, var(--acc2) 3.96%, transparent) 50%,
          color-mix(in srgb, var(--acc2) 1.83%, transparent) 62%,
          color-mix(in srgb, var(--acc2) 0.55%, transparent) 75%,
          color-mix(in srgb, var(--acc2) 0.06%, transparent) 88%,
          color-mix(in srgb, var(--acc2) 0%, transparent) 100%);
      --surface: #141821;
      --ink: #EAEDF3;
      --muted: #8B93A2;
      --line: #222836;
      --brand: #8E7DFF;
      --brand-d: #7C6CFF;
      --brand-soft: #1E2333;
      --acc1: #8E7DFF;
      --acc2: #FF7B5C;
      --accent: linear-gradient(120deg, #7C6CFF, #B15CFF, #FF7B5C);
      --field: #0D1016;
      --field-focus: #0B0E13;
      --chart-1: #8E7DFF;
      --chart-2: #4FD1C5;
      --chart-3: #FBBF24;
      --chart-4: #FB923C;
      --pos: #4ADE80;
      --neg: #F87171;
      --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 12px 32px rgba(0, 0, 0, .5);
      --shadow-lg: 0 28px 70px rgba(0, 0, 0, .65);
    }
    [data-theme="dark"] .inp,
    [data-theme="dark"] .txt,
    [data-theme="dark"] .sel,
    [data-theme="dark"] .field input { background: var(--field); color: var(--ink) }
    /* focus must stay dark — the light theme turns the field white on focus,
       which made the text invisible while editing in dark mode. */
    [data-theme="dark"] .inp:focus,
    [data-theme="dark"] .txt:focus,
    [data-theme="dark"] .sel:focus,
    [data-theme="dark"] .field input:focus { background: var(--field-focus); color: var(--ink) }
    [data-theme="dark"] .lab,
    [data-theme="dark"] .field label { color: var(--muted) }
    [data-theme="dark"] .search input { color: var(--ink) }
    [data-theme="dark"] .status-opt { background: var(--field); color: var(--muted) }
    [data-theme="dark"] .btn-ghost { background: #161A21; color: #C7CEDA; border-color: var(--line) }
    [data-theme="dark"] .btn-ghost:hover { background: #1C212B }
    [data-theme="dark"] .ltag { background: #1E2434; border-color: #2A3140; color: #C4CCDB }
    /* accent colour swatches (Settings) */
    .swatch { width: 26px; height: 26px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; padding: 0 }
    .swatch.on { border-color: var(--ink) }
