/* Auswertungen, Einstellungen, Insights, Live, Bereitschaft, Termine-Kalender.
   Teil des frueheren portal.css (Refactoring 23.11.2026). portal.html laedt
   die Teile in DIESER Reihenfolge — die Kaskade bleibt dieselbe. */
    /* analytics */
    .akpis {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 14px;
      margin-bottom: 16px
    }

    .akpi {
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: 16px;
      padding: 18px;
      box-shadow: var(--shadow);
      display: flex;
      flex-direction: column;
      gap: 6px;
      transition: transform .15s, box-shadow .2s, border-color .2s
    }
    .akpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--line) }

    /* label on top, big number below — like the mockup tiles */
    .akpi .cap {
      color: var(--muted);
      font-size: 12px;
      font-weight: 700;
      order: 1
    }
    .akpi .big {
      font-size: 28px;
      font-weight: 900;
      letter-spacing: -.03em;
      line-height: 1;
      order: 2
    }
    /* the headline KPI gets the accent gradient, like the mockup */
    .akpis .akpi:first-child .big {
      background: var(--accent);
      -webkit-background-clip: text; background-clip: text; color: transparent
    }

    .delta-up {
      color: var(--pos);
      font-weight: 700
    }

    .delta-dn {
      color: var(--neg);
      font-weight: 700
    }

    .agrid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px
    }

    .acard {
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: 16px;
      padding: 18px;
      box-shadow: var(--shadow)
    }
    /* Light group divider that clusters related Settings cards. */
    .sgroup {
      margin: 26px 2px 12px;
      padding-bottom: 9px;
      border-bottom: 1px solid var(--line);
      font-size: 12px;
      font-weight: 800;
      letter-spacing: .06em;
      text-transform: uppercase;
      color: var(--muted);
    }
    .sgroup:first-child { margin-top: 6px }

    /* Das Symbol bekommt eine eigene, feste Spalte. Vorher stand es im
       Textknoten: ein Titel MIT Symbol begann dadurch um dessen Breite weiter
       rechts als einer ohne, und die Karten in den Einstellungen standen
       gegeneinander versetzt. Gemeldet am 01.10.2026. */
    .acard h3 .ic {
      flex: none;
      width: 1.15em;
      display: inline-flex;
      justify-content: center;
      font-size: 13px;
      line-height: 1
    }
    .acard h3 {
      margin: 0 0 14px;
      font-size: 11px;
      font-weight: 800;
      letter-spacing: .1em;
      text-transform: uppercase;
      color: var(--muted);
      display: flex;
      align-items: center;
      gap: 8px
    }
    .acard > h3::before {
      content: '';
      width: 6px; height: 6px; border-radius: 50%;
      background: var(--accent);
      box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
      flex: none
    }
    .acard.clps > h3::before { display: none }

    /* Settings modules collapse to just their title so the page isn't a wall
       of forms — the h3 toggles each one open. */
    .acard.clps:not(.open)>*:not(h3) { display: none !important }
    .acard.clps>h3 { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 8px }
    .acard.clps:not(.open)>h3 { margin-bottom: 0 }
    .acard.clps>h3::after { content: '▸'; margin-left: auto; font-size: 13px; color: var(--muted); transition: transform .15s }
    .acard.clps.open>h3::after { transform: rotate(90deg) }
    .acard.clps>h3:hover { color: var(--text) }

    .brow {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 9px;
      font-size: 13px
    }

    .blab {
      min-width: 120px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis
    }

    .btrack {
      flex: 1;
      height: 8px;
      background: var(--brand-soft, #eef0ff);
      border-radius: 5px;
      overflow: hidden
    }

    .btrack i {
      display: block;
      height: 100%;
      border-radius: 5px
    }

    .bval {
      min-width: 32px;
      text-align: right;
      font-weight: 700
    }

    .vchart {
      display: flex;
      align-items: flex-end;
      gap: 3px;
      height: 120px
    }

    .vbar {
      flex: 1;
      display: flex;
      align-items: flex-end;
      height: 100%
    }

    .vbar i {
      display: block;
      width: 100%;
      background: var(--accent);
      border-radius: 5px 5px 2px 2px;
      min-height: 2px;
      opacity: .85
    }

    @media(max-width:760px) {
      .akpis {
        grid-template-columns: repeat(2, 1fr)
      }
    }

    /* ai insights */
    /* AI-Insight cards — schlicht: clean neutral card, tone only as a soft
       tint on the icon chip (no rainbow left borders / gradient fills). */
    .ins {
      display: flex;
      gap: 13px;
      align-items: center;
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: 16px;
      padding: 15px 17px;
      margin-bottom: 10px;
      box-shadow: var(--shadow)
    }

    .ins .ic {
      font-size: 18px;
      width: 38px;
      height: 38px;
      border-radius: 11px;
      background: var(--brand-soft);
      display: grid;
      place-items: center;
      flex: none
    }

    .ins .tx {
      font-size: 14.5px;
      line-height: 1.5;
      color: var(--ink)
    }

    .ins.up .ic, .ins.good .ic { background: color-mix(in srgb, #16a34a 14%, transparent) }
    .ins.down .ic { background: color-mix(in srgb, #dc2626 13%, transparent) }

    /* grouped insights card (mockup style): eyebrow + rows split by hairlines */
    .ins-eye { font-size: 11px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; color: var(--brand); margin-bottom: 4px }
    .insrow { display: flex; align-items: center; gap: 13px; padding: 13px 2px }
    .insrow + .insrow { border-top: 1px solid var(--line) }
    .insrow .ic { font-size: 16px; width: 34px; height: 34px; border-radius: 10px; background: var(--brand-soft); display: grid; place-items: center; flex: none }
    .insrow .tx { font-size: 14px; color: var(--ink); line-height: 1.5 }
    .insrow.up .ic, .insrow.good .ic { background: color-mix(in srgb, #16a34a 14%, transparent) }
    .insrow.down .ic { background: color-mix(in srgb, #dc2626 13%, transparent) }

    /* 👎 conversations to review */
    .rev-h {
      font-size: 15px;
      font-weight: 700;
      margin: 0 0 4px
    }
    .rev {
      background: var(--surface);
      border: 1px solid var(--line);
      border-left: 4px solid #dc2626;
      border-radius: 14px;
      padding: 12px 16px;
      margin-bottom: 10px
    }
    .rev summary {
      cursor: pointer;
      list-style: none;
      display: flex;
      align-items: center;
      gap: 10px;
      font-size: 13.5px;
      font-weight: 600
    }
    .rev summary::-webkit-details-marker { display: none }
    .rev summary .meta {
      color: var(--muted);
      font-weight: 500;
      margin-left: auto;
      font-size: 12.5px
    }
    .rev .thread,
    .lv-thread {
      margin-top: 12px;
      display: flex;
      flex-direction: column;
      gap: 8px
    }
    .rev .bub,
    .lv-thread .bub {
      max-width: 82%;
      padding: 8px 12px;
      border-radius: 12px;
      font-size: 13.5px;
      line-height: 1.4;
      white-space: pre-wrap;
      word-break: break-word;
      color: var(--ink)
    }
    .rev .bub.user {
      align-self: flex-end;
      background: var(--brand-soft, #eef2ff);
      color: var(--ink)
    }
    .rev .bub.assistant {
      align-self: flex-start;
      background: var(--bg);
      border: 1px solid var(--line)
    }
    /* Live view is the OWNER's perspective: visitor left, bot/own replies right */
    .lv-msg {
      display: flex;
      flex-direction: column;
      max-width: 82%
    }
    .lv-msg.left { align-self: flex-start; align-items: flex-start }
    .lv-msg.right { align-self: flex-end; align-items: flex-end }
    .lv-msg .lv-who {
      font-size: 11px;
      font-weight: 600;
      color: var(--muted);
      margin: 0 4px 2px
    }
    .lv-msg .bub { max-width: 100% }
    /* WhatsApp photo thumbnail inside a Live bubble */
    .lv-att { display: block; margin-top: 6px; max-width: 190px; max-height: 190px;
      border-radius: 10px; cursor: pointer; border: 1px solid var(--line); background: var(--bg) }
    .lv-attfile { display: inline-block; margin-top: 6px; background: var(--bg);
      border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer }
    .lv-msg .lv-time { font-size: 10.5px; color: var(--muted); margin: 2px 4px 0 }
    .lv-audio { display: block; margin-top: 6px; max-width: 230px; height: 38px }
    /* Wochentage und Leute als Knoepfe zum Umschalten: gedrueckt = dabei.
       Kaestchen in zwei Reihen waeren auf einem Laptop schwerer zu treffen. */
    /* Die Bereitschaftsleiste: ruhig, aber nicht zu überlesen. Rot waere
       falsch — Bereitschaft ist der Normalfall, kein Alarm. */
    .dp-dienst { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
      border: 1px solid var(--line); border-left: 4px solid var(--brand);
      border-radius: 10px; padding: 9px 13px; margin-bottom: 12px; font-size: 13.5px }
    .dp-dienst .dd-wer { font-weight: 700 }
    .dp-dienst .dd-zeit { color: var(--muted) }
    .dp-dienst .dd-leer { color: var(--muted) }
    .dp-dienst button { margin-left: auto }
    .dp-tage { display: flex; flex-wrap: wrap; gap: 6px }
    .dp-tage button { appearance: none; cursor: pointer; font: 600 13px inherit;
      padding: 8px 12px; min-height: 38px; border-radius: 9px; border: 1px solid var(--border);
      background: var(--bg); color: inherit }
    .dp-tage button.an { background: var(--brand); color: #fff; border-color: var(--brand) }
    /* Eine Antwort, die gespeichert ist, aber noch niemand gelesen hat: die
       Seite des Besuchers war zu. Gestrichelter Rand statt roter Farbe —
       es ist kein Fehler, es ist ein Warten. */
    .lv-msg .bub.wartet { border: 1px dashed var(--border); opacity: .9 }
    .lv-msg .lv-wartet { font-size: 11.5px; color: var(--muted); max-width: 320px;
      margin: 3px 4px 0; text-align: right; line-height: 1.35 }
    .lv-thread .bub.user {
      align-self: flex-start;
      background: var(--bg);
      border: 1px solid var(--line)
    }
    .lv-thread .bub.assistant {
      align-self: flex-end;
      background: var(--brand-soft, #eef2ff)
    }
    /* own (human) replies: green tint so they stand out from bot messages */
    .lv-thread .bub.human {
      background: #16a34a1c;
      border: 1px solid #16a34a44
    }
    /* handover alert: persistent banner (a 2.6s toast is too easy to miss
       when a customer is waiting for a human RIGHT NOW) */
    .hv-alert {
      position: fixed;
      top: 16px;
      left: 50%;
      transform: translateX(-50%);
      z-index: 9999;
      display: flex;
      align-items: center;
      gap: 12px;
      background: var(--card, #fff);
      border: 2px solid #dc2626;
      border-radius: 14px;
      padding: 12px 16px;
      max-width: 92vw;
      font-size: 14px;
      font-weight: 600;
      animation: hvPulse 1.6s ease-in-out infinite
    }
    @keyframes hvPulse {
      0%, 100% { box-shadow: 0 8px 30px rgba(220, 38, 38, .25) }
      50% { box-shadow: 0 8px 36px rgba(220, 38, 38, .55) }
    }
    @media (prefers-reduced-motion: reduce) {
      .hv-alert { animation: none; box-shadow: 0 8px 30px rgba(220, 38, 38, .35) }
    }
    .hv-alert .hv-x {
      background: none;
      border: none;
      color: var(--muted);
      font-size: 16px;
      cursor: pointer;
      padding: 4px;
      line-height: 1
    }

    /* settings */
    .sgrid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px
    }

    @media(max-width:760px) {
      .sgrid {
        grid-template-columns: 1fr
      }
    }

    .chips {
      display: flex;
      flex-wrap: wrap;
      gap: 8px
    }

    .chips .m {
      background: var(--brand-soft, #eef0ff);
      color: var(--brand-d, #3b3bb3);
      border-radius: 999px;
      padding: 5px 12px;
      font-size: 12.5px;
      font-weight: 600
    }

    .chips .none {
      color: var(--muted);
      font-size: 13px
    }

    .faq details {
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 10px 14px;
      margin-bottom: 8px
    }

    .faq summary {
      cursor: pointer;
      font-weight: 600;
      font-size: 14px
    }

    .faq p {
      margin: 8px 0 0;
      color: var(--muted);
      font-size: 13.5px
    }

    .kv {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      padding: 5px 0;
      border-bottom: 1px solid var(--line);
      font-size: 13.5px
    }

    .kv:last-child {
      border-bottom: 0
    }

    .kv .k {
      color: var(--muted)
    }

    /* ── Termine: month calendar ── */
    .apcal { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
    .apcal-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
    .apcal-title { font-size: 16px; font-weight: 800; text-transform: capitalize; margin-right: auto; }
    .apcal-head .btn-ghost { padding: 8px 12px; font-size: 13px; }
    .apcal-head .btn-primary { width: auto; padding: 9px 14px; font-size: 13.5px; }
    .apcal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
    .apcal-dow { text-align: center; font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 9px 0 7px; border-bottom: 1px solid var(--line); }
    .apcal-cell { min-height: 88px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 6px; cursor: pointer; transition: background .12s; display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
    .apcal-cell:nth-child(7n) { border-right: 0; }
    .apcal-cell:hover { background: var(--brand-soft); }
    .apcal-cell.dim { cursor: default; background: transparent; }
    .apcal-cell.dim:hover { background: transparent; }
    .apcal-cell.sel { box-shadow: inset 0 0 0 2px var(--brand); border-radius: 4px; }
    .apcal-num { font-size: 12px; font-weight: 700; color: var(--muted); width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
    .apcal-cell.today .apcal-num { background: var(--brand); color: #fff; }
    .apcal-chip { font-size: 10.5px; font-weight: 700; background: var(--brand-soft); color: var(--brand-d); border-radius: 6px; padding: 2px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .apcal-chip.block { background: rgba(120,120,120,.16); color: var(--muted); }
    [data-theme="dark"] .apcal-chip.block { background: rgba(120,120,120,.16); color: var(--muted); }
    [data-theme="dark"] .apcal-chip { color: var(--brand); }
    /* Google-imported events: read-only overlay, distinct neutral look */
    .apcal-chip.gcal { background: rgba(120,120,120,.14); color: var(--muted); font-weight: 600; }
    [data-theme="dark"] .apcal-chip.gcal { background: rgba(255,255,255,.09); }
    .ap-appt.gcal { background: var(--bg); border-style: dashed; opacity: .92; }
    .ap-appt.gcal .apt { font-weight: 600; }
    .ap-gsrc { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); background: rgba(120,120,120,.14); padding: 3px 9px; border-radius: 999px; white-space: nowrap; flex: none; }
    [data-theme="dark"] .ap-gsrc { background: rgba(255,255,255,.09); }
    .apcal-more { font-size: 10px; font-weight: 700; color: var(--muted); padding-left: 2px; }
    .apday-h { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 18px 2px 6px; display: flex; align-items: center; gap: 10px; }
    .apday-h button { margin-left: auto; }
    /* day agenda — exactly like the mockup: dashed slots, faint time, clean card */
    .apday { display: flex; flex-direction: column; gap: 2px; }
    .ap-slot { display: grid; grid-template-columns: 56px 1fr; gap: 14px; padding: 10px 0; border-top: 1px dashed var(--line); align-items: start; }
    .ap-slot .t { font-size: 12px; color: var(--faint); font-weight: 700; font-variant-numeric: tabular-nums; padding-top: 13px; }
    .ap-appt { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface); box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px; transition: border-color .2s, box-shadow .2s; }
    .ap-appt:hover { border-color: color-mix(in srgb, var(--brand) 25%, var(--line)); box-shadow: var(--shadow-lg); }
    .ap-appt.block { background: var(--bg); border-style: dashed; }
    .ap-appt .apm { flex: 1; min-width: 0; }
    .ap-appt .apt { font-weight: 700; font-size: 13.5px; letter-spacing: -.01em; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
    .ap-appt .aps { font-size: 12px; color: var(--muted); margin-top: 2px; }
    .ap-appt .apsr { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; flex: none; }
    .ap-appt .apact { display: flex; gap: 6px; }
    .apst { font-size: 11.5px; font-weight: 700; padding: 5px 12px; border-radius: 999px; white-space: nowrap; }
    .apst.confirmed { background: color-mix(in srgb, #2563eb 12%, transparent); color: #2563eb; }
    .apst.reminded  { background: color-mix(in srgb, #d97706 16%, transparent); color: #b45309; }
    .apst.arrived   { background: color-mix(in srgb, #16a34a 13%, transparent); color: #15803d; }
    [data-theme="dark"] .apst.reminded { color: #f0b866; }
    [data-theme="dark"] .apst.arrived  { color: #4ade80; }
    [data-theme="dark"] .apst.confirmed { color: #7aa2ff; }
    .apres-h { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 16px 2px 2px; }
    .apday > .ap-slot:first-child { border-top: 0; }
    .ap-modal-bg { position: fixed; inset: 0; background: rgba(15,15,20,.45); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; }
    .ap-modal { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px; width: 100%; max-width: 420px; max-height: 92vh; overflow-y: auto; box-shadow: 0 24px 60px rgba(0,0,0,.25); }
    .ap-modal h3 { margin: 0 0 14px; font-size: 17px; }
    .ap-modal .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .ap-modal select { width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; font-size: 14.5px; outline: none; background: var(--field); font-family: inherit; color: inherit; }
    @media (max-width: 700px) { .apcal-cell { min-height: 62px; } .apcal-chip { display: none; } .apcal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--brand); } }
    .apcal-dot { display: none; }
    @media (max-width: 700px) { .apcal-dot { display: block; } }
