/* dena Medienresonanz — Design-Tokens (verifiziert aus dena.de + Datawrapper-Charts) */
:root {
  --pri1: #2900ED;     /* electric blue */
  --pri2: #EC6500;     /* orange */
  --indigo: #190091;
  --blue: #007BED;
  --blue-light: #95C6E6;
  --blue-bg: #E5F1FD;
  --magenta: #A80578;
  --orange-light: #F38A47;
  --red: #EC0000;

  --text: #181716;
  --grey1: #F3F3F3;
  --grey2: #E7E7E7;
  --grey3: #D0D0D0;
  --grey8: #5C5C5B;
  --grey9: #464544;

  --success: #006600;
  --neutral: #BABAB9;

  --white: #fff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(24,23,22,.08), 0 8px 24px rgba(24,23,22,.05);

  --font-main: "DM Sans", system-ui, sans-serif;
  --font-head: "Lexend Deca", "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-main);
  color: var(--text);
  background: var(--grey1);
  line-height: 1.5;
}

h1, h2, h3 { font-family: var(--font-head); font-weight: 600; margin: 0; }

a { color: var(--pri1); }

/* ---------- Header ---------- */
.topbar {
  background: var(--white);
  border-bottom: 3px solid var(--pri1);
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-word {
  font-family: "Lexend Deca", "DM Sans", system-ui, sans-serif;
  font-weight: 500; font-size: 28px; line-height: 1; color: #181716; letter-spacing: -.5px;
}
.brand .subtitle {
  font-size: 15px; color: var(--grey8); font-weight: 500;
  padding-left: 14px; border-left: 1px solid var(--grey3);
}
.topbar .meta { font-size: 13px; color: var(--grey8); text-align: right; }
.topbar .meta a { text-decoration: none; font-weight: 600; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 24px 28px 60px; }

/* ---------- Filterleiste ---------- */
.filters {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: flex-end;
  margin-bottom: 22px;
}
/* hidden-Attribut muss display:flex überschreiben (sonst kollabiert die Leiste nicht) */
.filters[hidden] { display: none; }
.filter-group { display: flex; flex-direction: column; gap: 7px; }
.filter-group > label {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .4px; color: var(--grey8);
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--grey3); background: var(--white); color: var(--grey9);
  border-radius: 999px; padding: 7px 15px; font: inherit; font-size: 14px;
  cursor: pointer; transition: all .12s ease;
}
.chip:hover { border-color: var(--pri1); }
.chip.active { background: var(--pri1); border-color: var(--pri1); color: var(--white); }
select, input[type="range"] {
  font: inherit; border: 1.5px solid var(--grey3); border-radius: 9px;
  padding: 8px 12px; background: var(--white); color: var(--text); min-width: 200px;
}
/* Provider-Dropdown kompakt halten (lange Quellnamen abschneiden) */
#filter-source {
  min-width: 0; width: 200px; max-width: 200px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row output { font-weight: 700; color: var(--pri1); min-width: 34px; }
input[type="range"] { min-width: 160px; padding: 0; accent-color: var(--pri1); }
.btn-reset {
  background: none; border: none; color: var(--pri1); font: inherit; font-weight: 600;
  cursor: pointer; padding: 8px 0; text-decoration: underline;
}

/* ---------- Filter-Umschalter ---------- */
.filter-bar { margin-bottom: 14px; }
.filter-toggle {
  display: inline-flex; align-items: center; gap: 8px; background: var(--white);
  border: 1.5px solid var(--grey3); border-radius: 999px; padding: 8px 16px;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--grey9); cursor: pointer;
  box-shadow: var(--shadow); transition: border-color .12s, color .12s;
}
.filter-toggle:hover { border-color: var(--pri1); }
.filter-toggle.active { border-color: var(--pri1); color: var(--pri1); }
.filter-toggle .ft-icon { width: 16px; height: 16px; }
.filter-count {
  background: var(--pri1); color: var(--white); font-size: 11px; font-weight: 700;
  border-radius: 999px; min-width: 18px; height: 18px; display: inline-flex;
  align-items: center; justify-content: center; padding: 0 5px;
}

/* ---------- KPI-Kacheln ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.kpi {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px; border-left: 5px solid var(--pri1);
}
.kpi .label { font-size: 13px; color: var(--grey8); font-weight: 600; }
.kpi .value { font-family: var(--font-head); font-size: 34px; font-weight: 700; margin-top: 4px; }
.kpi .sub { font-size: 12.5px; color: var(--grey8); margin-top: 6px; }

/* kompakte KPI-Variante */
.kpis-sm { gap: 12px; margin-bottom: 18px; }
.kpis-sm .kpi { padding: 13px 16px; border-left-width: 4px; }
.kpis-sm .kpi .label { font-size: 11.5px; }
.kpis-sm .kpi .value { font-size: 24px; margin-top: 2px; }
.kpis-sm .kpi .value.sm { font-size: 15px; line-height: 1.25; }
.kpis-sm .kpi .sub { font-size: 11px; margin-top: 4px; }
.kpi.accent { border-left-color: var(--pri2); }
.kpi .value.pos { color: var(--success); }
.kpi .value.neg { color: var(--red); }
.kpi .value.neu { color: var(--grey8); }

/* ---------- Karten-Layout ---------- */
.grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-bottom: 16px; }
.card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}
.card h2 { font-size: 17px; margin-bottom: 14px; }
.card .hint { font-size: 12.5px; color: var(--grey8); font-weight: 400; }
.chart-box { position: relative; height: 320px; }
.chart-box.tall { height: 380px; }

/* ---------- Stakeholder-Ranking ---------- */
.stake-list { display: flex; flex-direction: column; gap: 7px; }
.stake-row {
  display: flex; flex-direction: column; gap: 4px; cursor: pointer;
  border-radius: 8px; padding: 5px 7px; margin: 0 -7px; transition: background .12s;
}
.stake-row:hover { background: var(--grey1); }
.stake-row.active { background: var(--blue-bg); }
.stake-row.active .bar { background: var(--pri2); }
.stake-row.active .cnt { color: var(--pri1); }
.stake-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stake-row .name { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.stake-ic { width: 13px; height: 13px; flex: 0 0 13px; color: var(--grey8); }
.stake-row .cnt { font-weight: 700; color: var(--grey9); font-size: 12.5px; flex: 0 0 auto; }
.stake-row .bar-wrap { background: var(--grey1); border-radius: 5px; overflow: hidden; height: 9px; }
.stake-row .bar { height: 100%; background: var(--pri1); border-radius: 5px; }

/* ---------- Meldungs-Karten ---------- */
.articles { display: flex; flex-direction: column; gap: 12px; }
.article {
  border: 1px solid var(--grey2); border-radius: 12px; padding: 16px 18px;
  display: flex; align-items: flex-start; gap: 14px;
  transition: border-color .12s ease;
}
.article:hover { border-color: var(--pri1); }
.a-thumb {
  width: 64px; height: 64px; flex: 0 0 64px; object-fit: cover; border-radius: 8px;
  background: var(--grey1); border: 1px solid var(--grey2);
}
.a-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.article .a-title { font-family: var(--font-head); font-weight: 600; font-size: 16px; }
.article .a-title a { text-decoration: none; color: var(--text); }
.article .a-title a:hover { color: var(--pri1); }
.article .a-meta { font-size: 12.5px; color: var(--grey8); }
.article .a-snippet { font-size: 14px; color: var(--grey9); margin-top: 2px; }
/* Social-Media-Beitrag: kein Titel, Text größer */
.article.social .a-social-text { font-size: 16px; line-height: 1.55; color: var(--text); font-weight: 500; margin-top: 4px; }
.article .a-side { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.badge { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 4px 11px; white-space: nowrap; }
.badge.positiv { background: rgba(0,102,0,.12); color: var(--success); }
.badge.neutral { background: var(--grey1); color: var(--grey8); }
.badge.negativ { background: rgba(236,0,0,.12); color: var(--red); }
.relscore { display: flex; flex-direction: column; align-items: flex-end; }
.relscore .n { font-family: var(--font-head); font-weight: 700; font-size: 22px; color: var(--pri1); }
.relscore .l { font-size: 10.5px; color: var(--grey8); text-transform: uppercase; letter-spacing: .3px; }
.mtype-tag { font-size: 11px; color: var(--grey8); border: 1px solid var(--grey3); border-radius: 5px; padding: 1px 7px; }

/* Quellenart-Icon */
.src-icon-wrap { display: inline-flex; vertical-align: middle; margin-right: 8px; }
.src-icon { width: 18px; height: 18px; display: block; }
.a-title { display: flex; align-items: flex-start; gap: 0; }
.ft-open {
  background: none; border: none; color: var(--pri2); font: inherit; font-size: 12.5px;
  font-weight: 700; cursor: pointer; padding: 0; margin-left: 10px; white-space: nowrap;
}
.ft-open:hover { text-decoration: underline; }

.empty { color: var(--grey8); padding: 30px; text-align: center; font-size: 15px; }
.loading { color: var(--grey8); padding: 16px; font-size: 14px; }

/* ---------- Volltext-Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(24,23,22,.55); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--white); border-radius: var(--radius); max-width: 760px; width: 100%;
  box-shadow: 0 12px 48px rgba(24,23,22,.25); position: relative; padding: 30px 34px 26px;
}
.modal-close {
  position: absolute; top: 14px; right: 18px; background: none; border: none;
  font-size: 30px; line-height: 1; color: var(--grey8); cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal-head { border-bottom: 2px solid var(--grey2); padding-bottom: 16px; margin-bottom: 18px; }
.ft-badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px; color: var(--grey8); margin-bottom: 10px;
}
.ft-badge .src-icon { width: 16px; height: 16px; }
.modal-head h2 { font-size: 23px; line-height: 1.25; margin-bottom: 8px; }
.ft-meta { font-size: 13.5px; color: var(--grey8); }
.modal-body { font-size: 15.5px; line-height: 1.65; color: var(--grey9); max-height: 60vh; overflow-y: auto; }
.modal-body p { margin: 0 0 14px; }
.modal-body h3 { font-size: 16px; color: var(--text); margin: 22px 0 10px; }
.modal-body li { margin: 0 0 8px 20px; }
.modal-foot { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--grey2); }

/* Flow-Output-Vorschau */
.fp-head { padding: 15px 48px 15px 22px; border-bottom: 1px solid var(--grey2); font-family: var(--font-head); font-weight: 600; font-size: 16px; }
#fp-frame { width: 100%; height: 72vh; border: 0; display: block; background: var(--grey1); }

/* ---------- Admin ---------- */
.admin-card { max-width: 460px; margin: 60px auto; }
.admin-wide { max-width: 1100px; }
.form-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.form-row label { font-weight: 600; font-size: 14px; }
input[type="email"], textarea {
  font: inherit; border: 1.5px solid var(--grey3); border-radius: 9px; padding: 10px 12px;
  width: 100%; color: var(--text);
}
textarea { min-height: 130px; resize: vertical; line-height: 1.5; }
.btn {
  background: var(--pri1); color: var(--white); border: none; border-radius: 9px;
  padding: 11px 22px; font: inherit; font-weight: 600; cursor: pointer; transition: opacity .12s;
}
.btn:hover { opacity: .9; }
.btn.secondary { background: var(--white); color: var(--pri1); border: 1.5px solid var(--pri1); }
.btn.cta { background: var(--pri2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.notice { padding: 12px 16px; border-radius: 9px; font-size: 14px; margin: 12px 0; }
.notice.ok { background: rgba(0,102,0,.1); color: var(--success); }
.notice.err { background: rgba(236,0,0,.1); color: var(--red); }
.notice.info { background: var(--blue-bg); color: var(--indigo); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--grey2); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--grey8); }
td select { min-width: 150px; padding: 5px 8px; }
.tabs { display: flex; gap: 8px; margin-bottom: 20px; border-bottom: 2px solid var(--grey2); }
.tab { background: none; border: none; padding: 12px 18px; font: inherit; font-weight: 600; color: var(--grey8); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tab.active { color: var(--pri1); border-bottom-color: var(--pri1); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
/* ---------- Connectoren ---------- */
.connector-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.connector {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px; border-left: 5px solid var(--pri1);
}
.connector.off { border-left-color: var(--grey3); opacity: .82; }
.conn-head { display: flex; align-items: flex-start; gap: 14px; }
.conn-ic {
  flex: 0 0 44px; width: 44px; height: 44px; border-radius: 10px; background: var(--grey1);
  display: flex; align-items: center; justify-content: center;
}
.conn-icon { width: 24px; height: 24px; }
.conn-title { flex: 1; min-width: 0; }
.conn-name { font-family: var(--font-head); font-weight: 600; font-size: 16px; }
.conn-desc { font-size: 13px; color: var(--grey8); margin-top: 3px; line-height: 1.4; }
.conn-status {
  font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 4px 11px; white-space: nowrap;
}
.conn-status.ok { background: rgba(0,102,0,.12); color: var(--success); }
.conn-status.info { background: var(--blue-bg); color: var(--indigo); }
.conn-status.muted { background: var(--grey1); color: var(--grey8); }
.conn-detail { font-size: 12.5px; color: var(--grey8); margin: 10px 0 0 58px; min-height: 1px; }
.conn-config { margin-top: 12px; }
.conn-config summary {
  cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--pri1); list-style: none;
  padding: 8px 0 0; user-select: none;
}
.conn-config summary::-webkit-details-marker { display: none; }
.conn-config summary::before { content: "⚙ "; }
.conn-config[open] summary::before { content: "▾ "; }
.conn-fields { padding-top: 14px; }
.conn-fields .form-row { margin-bottom: 12px; }
.conn-toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; margin: 6px 0 14px; }
.conn-toggle input { width: auto; }
.conn-save { padding: 9px 18px; }

/* ---------- Analyseflow ---------- */
.flow-canvas { position: relative; width: 100%; overflow: hidden; }
.flow-edges { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.flow-edge { fill: none; stroke: var(--grey3); stroke-width: 2; }
.flow-edge.on { stroke: var(--pri1); stroke-width: 2; }
.flow-node {
  position: absolute; z-index: 1; background: var(--white); border: 1.5px solid var(--grey3);
  border-radius: 10px; padding: 9px 12px; cursor: pointer; box-shadow: var(--shadow);
  transition: border-color .12s, box-shadow .12s;
}
.flow-node:hover { border-color: var(--pri1); }
.flow-node.sel { border-color: var(--pri1); box-shadow: 0 0 0 3px rgba(41,0,237,.15); }
.flow-node.src { display: flex; align-items: center; gap: 9px; height: 52px; }
.flow-node.src .fn-ic { width: 22px; height: 22px; flex: 0 0 22px; }
.flow-node.src .fn-ic svg { width: 22px; height: 22px; }
.flow-node.src .fn-label { font-size: 13px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-node.src.disconnected { opacity: .5; border-style: dashed; }
.fn-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.fn-dot.on { background: var(--success); }
.fn-dot.off { background: var(--grey3); }
.flow-node.agent { border-color: var(--pri1); background: var(--blue-bg); min-height: 88px; }
.flow-node.agent.filter { border-color: var(--magenta); background: #fbeef6; }
.flow-node.output { border-color: var(--pri2); background: #fff4ec; min-height: 80px; }
.fn-kind { display: flex; align-items: center; gap: 5px; }
.fn-svg { width: 14px; height: 14px; }
.flow-node.agent.filter .fn-kind { color: var(--magenta); }

.flow-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.flow-tb-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.flow-tb-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--grey8); }
#flow-select { min-width: 240px; font-weight: 600; }
.fn-kind { font-size: 10.5px; font-weight: 700; letter-spacing: .6px; color: var(--grey8); }
.flow-node.agent .fn-kind { color: var(--pri1); }
.flow-node.output .fn-kind { color: var(--pri2); }
.fn-title { font-family: var(--font-head); font-weight: 600; font-size: 15px; margin: 3px 0 4px; }
.fn-sub { font-size: 12px; color: var(--grey8); line-height: 1.35; }

.fmt-palette { display: flex; gap: 8px; flex-wrap: wrap; }
.fmt-chip {
  border: 1.5px solid var(--grey3); background: var(--white); color: var(--grey9);
  border-radius: 999px; padding: 7px 15px; font: inherit; font-size: 13.5px; cursor: pointer;
}
.fmt-chip:hover { border-color: var(--pri2); }
.fmt-chip.active { background: var(--pri2); border-color: var(--pri2); color: var(--white); }
.flow-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.status-line { font-size: 14px; color: var(--grey9); margin-top: 12px; }
.progress { background: var(--grey1); border-radius: 8px; height: 12px; overflow: hidden; margin-top: 8px; }
.progress .fill { height: 100%; background: var(--pri2); width: 0; transition: width .3s; }

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