:root {
  --bg: #f6f7f9; --panel: #fff; --panel2: #f1f3f6; --line: #e3e6eb; --text: #1b1f27; --muted: #6b7280;
  --accent: #5b5bf0; --accent-soft: #ececfe; --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --line: #2a2f3a; --text: #e8eaf0; --muted: #9aa1ad; --accent: #8080ff; --accent-soft: #23244a; --shadow: none; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 Inter, system-ui, sans-serif; background: var(--bg); color: var(--text); display: flex; min-height: 100vh; }
a { color: var(--accent); }
.side { width: 220px; flex: none; background: var(--panel); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
nav a.active, nav a:hover { background: var(--accent-soft); }
main { flex: 1; padding: 22px 26px; min-width: 0; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 16px; margin: 0 0 10px; } h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid { display: grid; gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500; }
.btn:hover { border-color: var(--accent); } .btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { color: var(--bad); } .btn.wide { width: 100%; } .btn.sm { padding: 4px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: wait; }
input, textarea, select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { resize: vertical; min-height: 110px; }
label { display: block; font-weight: 500; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--panel2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.banner { background: #fff7e6; color: #7a4b00; border: 1px solid #f3d49b; border-radius: 8px; padding: 8px 12px; margin: 10px 0; }
@media (prefers-color-scheme: dark) { .banner { background: #2b2210; color: #f3d49b; border-color: #5c4718; } }

/* Kalender */
.cal { display: grid; grid-template-columns: 52px repeat(7, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.cal .h { position: sticky; top: 0; z-index: 2; background: var(--panel); padding: 8px; font-weight: 600; border-bottom: 1px solid var(--line); text-align: center; }
.cal .h.today { color: var(--accent); }
.cal .t { font-size: 11px; color: var(--muted); padding: 4px 6px; border-top: 1px solid var(--line); text-align: right; }
.cal .slot { min-height: 46px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); padding: 2px; cursor: pointer; }
.cal .slot:hover { background: var(--panel2); } .cal .slot.over { background: var(--accent-soft); }
.cal .slot.past { background: repeating-linear-gradient(45deg, transparent, transparent 6px, var(--panel2) 6px, var(--panel2) 7px); }
.pc { background: var(--panel2); border-left: 3px solid var(--accent); border-radius: 6px; padding: 3px 6px; font-size: 11.5px; margin-bottom: 2px; cursor: grab; overflow: hidden; }
.pc .ttl { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc.published { border-left-color: var(--ok); } .pc.failed { border-left-color: var(--bad); } .pc.scheduled { border-left-color: var(--accent); } .pc.draft, .pc.idea, .pc.review { border-left-color: var(--warn); opacity: .85; }
.calwrap { display: grid; grid-template-columns: 1fr 240px; gap: 14px; align-items: start; }
.unplanned { position: sticky; top: 10px; max-height: calc(100vh - 40px); overflow: auto; }

/* Flow */
.board { display: grid; grid-template-columns: repeat(6, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; }
.col { background: var(--panel2); border-radius: var(--radius); padding: 10px; min-height: 60vh; }
.col.over { outline: 2px dashed var(--accent); }
.col h3 { display: flex; justify-content: space-between; }
.kc { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; cursor: grab; }
.kc img, .kc video { width: 100%; height: 90px; object-fit: cover; border-radius: 6px; margin-bottom: 6px; }

/* Modal / Composer */
.modal { position: fixed; inset: 0; background: rgba(10,12,18,.5); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal.hidden { display: none; }
.modal > .box { background: var(--panel); border-radius: 14px; width: min(1180px, 100%); max-height: 94vh; overflow: auto; padding: 20px; }
.composer { display: grid; grid-template-columns: 1.15fr 1fr .8fr; gap: 18px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.tab { padding: 6px 10px; border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent; font: inherit; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; cursor: pointer; display: flex; gap: 6px; align-items: center; font-size: 12.5px; user-select: none; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumb { position: relative; width: 74px; height: 74px; border-radius: 8px; overflow: hidden; background: var(--panel2); display: grid; place-items: center; font-size: 11px; text-align: center; border: 1px solid var(--line); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb .x { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 50%; width: 18px; height: 18px; cursor: pointer; font-size: 11px; line-height: 18px; padding: 0; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 14px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.counter { font-size: 11px; text-align: right; color: var(--muted); } .counter.bad { color: var(--bad); font-weight: 600; }
.preview { background: var(--panel2); border-radius: 12px; padding: 12px; font-size: 13px; }
.preview .ph { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; font-weight: 600; }
.preview .av { width: 28px; height: 28px; border-radius: 50%; }
.preview .pm img, .preview .pm video { width: 100%; border-radius: 8px; max-height: 320px; object-fit: cover; }
.preview .pt { white-space: pre-wrap; word-break: break-word; margin-top: 8px; }
.warn { color: var(--warn); font-size: 12px; margin-top: 4px; }

/* Medien */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.mitem { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.mitem .m { height: 120px; background: var(--panel2); display: grid; place-items: center; }
.mitem .m img, .mitem .m video { width: 100%; height: 100%; object-fit: cover; }
.mitem .i { padding: 6px 8px; font-size: 12px; }
.mitem.sel { outline: 3px solid var(--accent); }

/* Analytics */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi .v { font-size: 24px; font-weight: 700; } .kpi .l { color: var(--muted); font-size: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; } td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.heat { display: grid; grid-template-columns: 34px repeat(24, 1fr); gap: 2px; font-size: 10px; }
.heat div { aspect-ratio: 1.4; border-radius: 3px; } .heat .lab { aspect-ratio: auto; color: var(--muted); display: flex; align-items: center; }
.plat { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
code, pre { font-family: ui-monospace, Menlo, monospace; font-size: 12px; } pre { background: var(--panel2); padding: 10px; border-radius: 8px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
#toast { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 99; }
#toast div { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 420px; }
#toast div.err { background: var(--bad); color: #fff; }

.calwrap > div:first-child { min-width: 0; overflow-x: auto; }
.cal { min-width: 760px; }
@media (max-width: 1250px) { .calwrap { grid-template-columns: 1fr; } .unplanned { position: static; max-height: none; } .composer { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) {
  body { flex-direction: column; } .side { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; }
  nav { flex-direction: row; flex-wrap: wrap; } main { padding: 16px; }
  .calwrap, .composer { grid-template-columns: 1fr; } .cal { overflow-x: auto; grid-template-columns: 44px repeat(7, minmax(110px, 1fr)); }
}

/* Flows */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; cursor: pointer; transition: background .15s; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked + span { background: var(--ok); } .switch input:checked + span::before { transform: translateX(16px); }
.fstats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.fstats div { display: flex; flex-direction: column; } .fstats b { font-size: 18px; } .fstats span { font-size: 11px; color: var(--muted); }
.flowed { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
.flowed > div:last-child { position: sticky; top: 10px; }
.step { border-left: 3px solid var(--accent); }
.arrow { text-align: center; color: var(--muted); margin: 4px 0; }
.phone { background: var(--panel2); border-radius: 18px; border: 1px solid var(--line); overflow: hidden; }
.phead { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13px; }
.phead .av { width: 24px; height: 24px; border-radius: 50%; background: linear-gradient(45deg, #f58529, #dd2a7b, #8134af); }
.pbody { padding: 12px; display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow: auto; }
.bub { max-width: 80%; padding: 8px 11px; border-radius: 16px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.bub.in { background: var(--panel); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.bub.out { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bub.cm { background: transparent; border: 1px dashed var(--line); color: var(--text); }
.bub .k { font-size: 10px; opacity: .75; margin-bottom: 2px; }
.bbtn { margin-top: 6px; background: rgba(255,255,255,.18); border-radius: 8px; padding: 6px; text-align: center; font-weight: 600; }
.qrs { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.qrs span { border: 1px solid rgba(255,255,255,.6); border-radius: 99px; padding: 2px 9px; font-size: 12px; cursor: pointer; }
.inbox { display: grid; grid-template-columns: 280px 1fr 260px; gap: 14px; height: calc(100vh - 130px); }
.inbox > .card { overflow: auto; }
.ci { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.ci.on, .ci:hover { background: var(--accent-soft); }
.thread { display: flex; flex-direction: column; gap: 10px; }
.msgs { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 6px; padding: 6px 0; }
@media (max-width: 1100px) { .flowed, .inbox { grid-template-columns: 1fr; height: auto; } .flowed > div:last-child { position: static; } }
