/* QRIL · Daily Briefing Popup — der In-App-Zwilling des Telegram-Briefings.
 *
 * Erscheint einmal morgens nach dem Login, auf JEDER Seite (globale Einbindung
 * via dashboard/briefing_popup_middleware.py), und verschwindet nur durch
 * „Gelesen" oder „Später" — kein Auto-Dismiss.
 *
 * Nutzt die QRIL-Design-Tokens (tokens.css) mit sicheren Rueckfallwerten, damit
 * auch Seiten ohne Token-Einbindung korrekt aussehen.
 *
 * z-index 9500: ueber den Toasts (9400), unter Sicherheitsdialogen.
 *
 * Sektionen (Inhalt kommt als JSON vom Server, nicht als HTML):
 *   kind timeline — Zeit | Waehrung | Termin | erw. | akt.   (High Impact)
 *   kind list     — Zeit | Waehrung | Termin | <extra>       (News, Earnings)
 *   kind tags     — Chips                                    (ganztägig)
 *   kind text     — Klartextblock                            (Altbestand)
 */

/* ── Backdrop ──────────────────────────────────────────────────────────── */
.qbp-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20.8px;
  background: rgba(4, 7, 11, .74);
  -webkit-backdrop-filter: blur(6.5px) saturate(.85);
  backdrop-filter: blur(6.5px) saturate(.85);
  animation: qbpFade .22s ease both;
}

/* ── Panel ─────────────────────────────────────────────────────────────── */
.qbp {
  position: relative;
  width: min(910px, 100%);
  max-height: min(90vh, 1222px);
  display: flex;
  flex-direction: column;
  background: #151a21;
  border: 1px solid var(--border, #30363d);
  border-radius: 18.2px;
  overflow: hidden;
  font-family: var(--font-ui, monospace);
  color: var(--text, #e6edf3);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .02),
              0 10.4px 31.2px -10.4px rgba(0, 0, 0, .7),
              0 52px 117px -31.2px rgba(0, 0, 0, .85);
  animation: qbpIn .26s cubic-bezier(.2, .8, .2, 1) both;
}
/* obere Lichtkante */
.qbp::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  z-index: 2;
  background: linear-gradient(90deg, transparent,
              rgba(201, 205, 211, .42) 22%, rgba(201, 205, 211, .42) 78%, transparent);
}
/* leiser Sheen unter dem Kopf */
.qbp::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 156px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, .035), transparent);
}

/* ── Kopf ──────────────────────────────────────────────────────────────── */
.qbp-head {
  position: relative;
  z-index: 1;
  padding: 26px 33.8px 19.5px;
  border-bottom: 1px solid rgba(48, 54, 61, .62);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 10.4px 26px;
}
.qbp-overline {
  font-size: 12.3px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text2, #8b949e);
  display: flex;
  align-items: center;
  gap: 13px;
}
.qbp-overline::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(48, 54, 61, .9), transparent);
}
.qbp-title {
  font-size: 24.7px;
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 7.8px 0 0;
  color: #eef2f6;
}
.qbp-sub {
  font-size: 15px;
  color: var(--text2, #8b949e);
  margin-top: 3.9px;
}
.qbp-head-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 9.1px;
  padding-right: 39px;
  padding-top: 1px;
}
.qbp-time {
  font-size: 13.7px;
  letter-spacing: .06em;
  color: var(--text2, #8b949e);
  border: 1px solid rgba(48, 54, 61, .85);
  border-radius: 6.5px;
  padding: 3.9px 10.4px;
  white-space: nowrap;
}
.qbp-pill {
  font-size: 12.3px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 3.9px 10.4px;
  border-radius: 26px;
  white-space: nowrap;
  border: 1px solid;
}
.qbp-pill.SENT,
.qbp-pill.DELIVERED {
  color: var(--green, #3fb950);
  border-color: rgba(63, 185, 80, .38);
  background: rgba(63, 185, 80, .07);
}
.qbp-pill.FAILED {
  color: var(--red, #f85149);
  border-color: rgba(248, 81, 73, .42);
  background: rgba(248, 81, 73, .08);
}
.qbp-pill.QUEUED,
.qbp-pill.PENDING,
.qbp-pill.UNKNOWN {
  color: var(--text2, #8b949e);
  border-color: rgba(48, 54, 61, .95);
  background: rgba(255, 255, 255, .03);
}
.qbp-x {
  position: absolute;
  top: 19.5px; right: 18.2px;
  width: 33.8px; height: 33.8px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9.1px;
  color: #6e7681;
  font-size: 20.8px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  transition: .14s;
}
.qbp-x:hover {
  color: var(--text, #e6edf3);
  background: rgba(255, 255, 255, .05);
  border-color: #333c47;
}

/* ── Kennzahlen ────────────────────────────────────────────────────────── */
.qbp-kpis {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid rgba(48, 54, 61, .62);
  background: rgba(255, 255, 255, .012);
}
.qbp-kpi {
  padding: 15.6px 33.8px 16.9px;
  border-right: 1px solid rgba(48, 54, 61, .5);
}
.qbp-kpi:last-child { border-right: 0; }
.qbp-kpi .n {
  font-size: 28.6px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  color: #e3e9ef;
}
.qbp-kpi.hot .n { color: #ff8078; }
.qbp-kpi.calm .n { color: #79c98a; }
.qbp-kpi .l {
  font-size: 12.3px;
  font-weight: 600;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--text2, #8b949e);
  margin-top: 9.1px;
}

/* ── Hinweiszeile (z. B. Telegram-Fehler) ──────────────────────────────── */
.qbp-note {
  display: flex;
  gap: 11.7px;
  align-items: flex-start;
  margin: 16.9px 33.8px 0;
  padding: 11.7px 15.6px;
  font-size: 15px;
  line-height: 1.5;
  color: #e8c46a;
  background: rgba(210, 153, 34, .07);
  border: 1px solid rgba(210, 153, 34, .34);
  border-left-width: 2px;
  border-radius: 9.1px;
}

/* ── Inhalt ────────────────────────────────────────────────────────────── */
.qbp-bodywrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}
.qbp-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 0 23.4px;
}
.qbp-body::-webkit-scrollbar { width: 11.7px; }
.qbp-body::-webkit-scrollbar-thumb {
  background: #2b333d;
  border-radius: 11.7px;
  border: 2px solid #151a21;
}
.qbp-body::-webkit-scrollbar-thumb:hover { background: #3a434f; }
.qbp-bodywrap::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 33.8px;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, #151a21);
  opacity: 0;
  transition: opacity .18s;
}
.qbp-bodywrap.more::after { opacity: 1; }

.qbp-sec { padding-top: 18.2px; }
.qbp-sec-head {
  display: flex;
  align-items: center;
  gap: 11.7px;
  padding: 0 33.8px 11.7px;
}
.qbp-sec-head .dot {
  width: 7.8px; height: 7.8px;
  border-radius: 2px;
  flex: none;
}
.qbp-sec-head .dot.high {
  background: var(--red, #f85149);
  box-shadow: 0 0 10.4px rgba(248, 81, 73, .6);
}
.qbp-sec-head .dot.hold { background: var(--orange, #d29922); }
.qbp-sec-head .dot.news {
  background: #58a6ff;
  box-shadow: 0 0 10.4px rgba(88, 166, 255, .5);
}
.qbp-sec-head .dot.future {
  background: var(--purple, #bc8cff);
  box-shadow: 0 0 10.4px rgba(188, 140, 255, .5);
}
.qbp-sec-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #a9b1ba;
}
.qbp-sec-head .count {
  font-size: 12.3px;
  font-weight: 700;
  color: var(--text2, #8b949e);
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(48, 54, 61, .8);
  border-radius: 26px;
  padding: 1px 9.1px;
  font-variant-numeric: tabular-nums;
}
.qbp-sec-head .rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(48, 54, 61, .75), transparent);
}
.qbp-sec-sub {
  padding: 0 33.8px 10.4px;
  margin-top: -3.9px;
  font-size: 13.7px;
  color: #6e7681;
}

/* Zeilenraster: Zeit | Waehrung | Termin | Werte */
.qbp-row {
  display: grid;
  align-items: baseline;
  grid-template-columns: 78px 52px minmax(0, 1fr) auto;
  grid-template-areas: "t c n vals";
  column-gap: 16.9px;
  padding: 10.4px 33.8px 10.4px 31.2px;
  border-left: 2px solid transparent;
  transition: background .13s ease;
}
.qbp-row.hot { border-left-color: rgba(248, 81, 73, .6); }
.qbp-row:hover { background: rgba(255, 255, 255, .024); }
.qbp-row.hot:hover { background: rgba(248, 81, 73, .05); }
.qbp-row.hot:hover .qbp-row-name { color: #fff; }
.qbp-row-time {
  grid-area: t;
  font-size: 15.6px;
  font-variant-numeric: tabular-nums;
  color: #c6cdd5;
  text-align: right;
  white-space: nowrap;
}
.qbp-ccy {
  grid-area: c;
  font-size: 12.3px;
  font-weight: 700;
  letter-spacing: .09em;
  color: #b9c1ca;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(48, 54, 61, .9);
  border-radius: 5.2px;
  padding: 2px 0;
  text-align: center;
  align-self: center;
}
.qbp-row-name {
  grid-area: n;
  font-size: 16.9px;
  font-weight: 500;
  color: #e3e9ef;
  line-height: 1.4;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qbp-next {
  display: inline-block;
  font-size: 11.1px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #d2d9e0;
  background: rgba(201, 205, 211, .09);
  border: 1px solid rgba(139, 148, 158, .55);
  border-radius: 5.2px;
  padding: 1px 7.8px;
  margin-left: 11.7px;
  vertical-align: 1.5px;
}
.qbp-vals {
  grid-area: vals;
  display: grid;
  grid-template-columns: 80.6px 80.6px;
  column-gap: 15.6px;
  justify-items: end;
  font-size: 13.7px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.qbp-vals .f { color: #8fa0b3; }
.qbp-vals .a { color: #9fd6a8; }
.qbp-vals .na { color: #4b535d; }
.qbp-extra {
  grid-area: vals;
  justify-self: end;
  font-size: 13.7px;
  color: var(--text2, #8b949e);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Spaltenkoepfe der Terminliste */
.qbp-thead {
  display: grid;
  grid-template-columns: 78px 52px minmax(0, 1fr) auto;
  grid-template-areas: "t c n vals";
  column-gap: 16.9px;
  padding: 0 33.8px 7.8px 31.2px;
  font-size: 11.1px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #6e7681;
}
.qbp-thead .vh {
  grid-area: vals;
  display: grid;
  grid-template-columns: 80.6px 80.6px;
  column-gap: 15.6px;
  justify-items: end;
}

/* Ganztaegige Eintraege: Chips (eine Uhrzeit gibt es dort nicht) */
.qbp-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10.4px;
  padding: 0 33.8px;
}
.qbp-tag {
  display: inline-flex;
  align-items: center;
  gap: 11.7px;
  padding: 5.2px 14.3px 5.2px 10.4px;
  background: rgba(255, 255, 255, .028);
  border: 1px solid rgba(48, 54, 61, .9);
  border-radius: 9.1px;
  font-size: 15px;
  color: #dbe1e8;
}
.qbp-tag .qbp-ccy { padding: 1px 7.8px; margin: 0; }
.qbp-tag .w {
  font-size: 12.3px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text2, #8b949e);
}

.qbp-text {
  margin: 0 33.8px;
  padding: 15.6px 18.2px;
  font-family: var(--font-mono, monospace);
  font-size: 15.6px;
  line-height: 1.7;
  white-space: pre-wrap;
  color: #dbe1e8;
  background: rgba(255, 255, 255, .018);
  border: 1px solid rgba(48, 54, 61, .75);
  border-radius: 10.4px;
}
.qbp-empty {
  margin: 0 33.8px 5.2px;
  padding: 14.3px 16.9px;
  font-size: 15px;
  color: var(--text2, #8b949e);
  border: 1px dashed rgba(48, 54, 61, .9);
  border-radius: 10.4px;
  background: rgba(255, 255, 255, .012);
}
.qbp-empty b { color: #a9b1ba; font-weight: 600; }

/* ── Fuss ──────────────────────────────────────────────────────────────── */
.qbp-foot {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 23.4px;
  flex-wrap: wrap;
  padding: 16.9px 33.8px 19.5px;
  border-top: 1px solid rgba(48, 54, 61, .62);
  background: rgba(0, 0, 0, .16);
}
.qbp-src {
  font-size: 13.7px;
  color: var(--text2, #8b949e);
  flex: 1;
  min-width: 234px;
}
.qbp-src .ln { display: block; white-space: nowrap; line-height: 1.7; }
.qbp-src a {
  color: #ced5dd;
  text-decoration: none;
  border-bottom: 1px solid rgba(139, 148, 158, .55);
  padding-bottom: 1px;
  white-space: nowrap;
}
.qbp-src a:hover { color: #fff; border-bottom-color: #fff; }
.qbp-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 9.1px;
}
.qbp-actions { display: flex; gap: 11.7px; }
.qbp-kbd {
  font-size: 12.3px;
  color: #6e7681;
  letter-spacing: .03em;
}
.qbp-kbd kbd {
  font-family: inherit;
  font-size: 11.7px;
  color: #aeb6bf;
  border: 1px solid rgba(48, 54, 61, .95);
  border-bottom-width: 2px;
  border-radius: 5.2px;
  padding: 0 5.2px;
  margin: 0 1px;
}
.qbp-btn {
  font-family: inherit;
  font-size: 16.2px;
  font-weight: 600;
  height: 46.8px;
  padding: 0 22.1px;
  border-radius: 10.4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10.4px;
  transition: .15s;
}
.qbp-btn.ghost {
  color: #c9d1d9;
  background: transparent;
  border: 1px solid #333c47;
}
.qbp-btn.ghost:hover {
  color: #fff;
  background: rgba(255, 255, 255, .045);
  border-color: #4a5361;
}
.qbp-btn.primary {
  color: #0d1117;
  background: linear-gradient(180deg, #eef2f6, #c9cdd3);
  border: 1px solid rgba(255, 255, 255, .5);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .35) inset,
              0 10.4px 26px -10.4px rgba(201, 205, 211, .42);
}
.qbp-btn.primary:hover { background: linear-gradient(180deg, #fff, #d7dbe0); }
.qbp-btn[disabled] { opacity: .55; cursor: default; }
.qbp-btn:focus-visible,
.qbp-x:focus-visible {
  outline: 2px solid rgba(201, 205, 211, .6);
  outline-offset: 2px;
}

@keyframes qbpFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes qbpIn {
  from { opacity: 0; transform: translateY(18.2px) scale(.984); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .qbp, .qbp-backdrop { animation: none !important; }
}

@media (max-width: 936px) {
  .qbp-backdrop { padding: 0; align-items: flex-end; }
  .qbp {
    width: 100%;
    max-height: 92vh;
    border-radius: 20.8px 20.8px 0 0;
  }
  .qbp-head { padding: 23.4px 23.4px 18.2px; }
  .qbp-head-side { padding-right: 31.2px; }
  .qbp-kpi { padding: 14.3px 18.2px 15.6px; }
  .qbp-kpi .n { font-size: 24.7px; }
  .qbp-note { margin: 15.6px 23.4px 0; }
  .qbp-sec-head { padding: 0 23.4px 11.7px; }
  .qbp-row {
    grid-template-columns: 67.6px 46.8px minmax(0, 1fr);
    grid-template-areas: "t c n" ". . vals";
    row-gap: 3.9px;
    padding: 11.7px 23.4px 11.7px 20.8px;
  }
  .qbp-ccy { align-self: baseline; padding: 1px 0; }
  .qbp-row-name { white-space: normal; }
  .qbp-vals {
    grid-template-columns: auto auto;
    justify-items: start;
    column-gap: 13px;
    margin-top: 1px;
  }
  .qbp-extra { justify-self: start; margin-top: 1px; }
  .qbp-thead { display: none; }
  .qbp-tags { padding: 0 23.4px; }
  .qbp-text { margin: 0 23.4px; }
  .qbp-empty { margin: 0 23.4px 5.2px; }
  .qbp-foot { padding: 15.6px 23.4px 19.5px; gap: 15.6px; }
  .qbp-side { width: 100%; align-items: stretch; }
  .qbp-kbd { text-align: center; }
  .qbp-actions { width: 100%; }
  .qbp-btn { flex: 1; }
}

/* Drucken: nie ein Overlay aufs Papier */
@media print {
  .qbp-backdrop { display: none !important; }
}
