:root {
  --wa-teal: #075e54;
  --wa-teal-2: #128c7e;
  --wa-green: #25d366;
  --bg: #f0f2f5;
  --chat-bg: #efeae2;
  --panel: #ffffff;
  --ink: #111b21;
  --muted: #667781;
  --line: #e5e9ec;
  --danger: #c0392b;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); font-size: 14px; }
.ok { color: var(--wa-green); }
.empty { color: var(--muted); padding: 24px; font-size: 14px; }

/* Brand */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--wa-green); box-shadow: 0 0 0 3px rgba(37,211,102,.25); }
.brand--lg { font-size: 22px; justify-content: center; }
.brand--lg .brand-dot { width: 18px; height: 18px; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(160deg, var(--wa-teal), var(--wa-teal-2)); }
.login-card { width: 360px; max-width: 100%; background: var(--panel); border-radius: 14px;
  padding: 28px 26px; box-shadow: 0 12px 40px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 10px; }
.login-card label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.login-card input { padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 15px; }
.login-card input:focus { outline: none; border-color: var(--wa-teal-2); }
.login-card button { margin-top: 12px; }

/* Buttons */
button { font: inherit; cursor: pointer; border: none; border-radius: 9px; padding: 11px 14px;
  background: var(--wa-teal); color: #fff; font-weight: 600; }
button:hover { background: var(--wa-teal-2); }
button:disabled { background: #b9c4c2; cursor: not-allowed; }
button.ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.5); padding: 7px 12px; }
button.ghost:hover { background: rgba(255,255,255,.12); }
button.mini { background: var(--bg); color: var(--wa-teal); padding: 5px 10px; font-size: 13px; border: 1px solid var(--line); }
button.mini:hover { background: #e4e9ec; }

/* App shell — full viewport, no page scroll */
.app { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 56px; flex: none; background: var(--wa-teal); color: #fff; display: flex; align-items: center;
  justify-content: space-between; padding: 0 18px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.pill { background: rgba(255,255,255,.16); padding: 5px 11px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill--ok { background: #e7f8ee; color: #1d6b3f; }
.pill--mute { background: var(--bg); color: var(--muted); }
.topbar .muted { color: rgba(255,255,255,.85); }

.layout { flex: 1; display: grid; grid-template-columns: 220px 1fr; overflow: hidden; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 9px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 14px; }
.nav-item:hover { background: var(--bg); }
.nav-item.is-active { background: rgba(18,140,126,.12); color: var(--wa-teal); }
.nav-item.is-soon { color: var(--muted); font-weight: 500; cursor: default; }
.soon { font-size: 10px; background: var(--bg); color: var(--muted); padding: 2px 6px; border-radius: 6px; }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--wa-green); color: #fff;
  font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }

.content { flex: 1; overflow: hidden; }
.view { height: 100%; }
#view-overview, #view-contacts { padding: 24px 28px; overflow-y: auto; }
.content h1 { margin: 0 0 18px; font-size: 22px; }
.content h2 { margin: 0 0 12px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* Overview cards/panels */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.card-k { font-size: 30px; font-weight: 700; color: var(--wa-teal); }
.card-l { color: var(--muted); font-size: 13px; margin-top: 4px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 18px; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.roadmap { margin: 0; padding-left: 18px; line-height: 1.9; font-size: 14px; }
.roadmap .ok { font-weight: 700; }
.banner { border-radius: 10px; padding: 12px 14px; margin-bottom: 18px; font-size: 14px; }
.banner.warn { background: #fff4e5; border: 1px solid #ffd8a8; color: #8a5a00; }

/* Inbox 2-pane */
.inbox { height: 100%; display: grid; grid-template-columns: 340px 1fr; }
.conv-list { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; overflow: hidden; }
.conv-list-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.conv-list-head h2 { margin: 0; }
.conv-items { flex: 1; overflow-y: auto; }
.conv { width: 100%; text-align: left; background: transparent; color: inherit; border: none; border-bottom: 1px solid var(--line);
  border-radius: 0; padding: 11px 14px; display: flex; gap: 11px; align-items: center; cursor: pointer; font-weight: 400; }
.conv:hover { background: var(--bg); }
.conv.is-active { background: rgba(18,140,126,.10); }
.avatar { width: 42px; height: 42px; flex: none; border-radius: 50%; background: var(--wa-teal-2); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; gap: 8px; }
.conv-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { color: var(--muted); font-size: 12px; flex: none; }
.conv-bot { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: 2px; }
.conv-prev { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Thread */
.thread { display: flex; flex-direction: column; height: 100%; background: var(--chat-bg); }
.thread-empty { flex: 1; display: grid; place-items: center; color: var(--muted); }
.thread-pane { display: flex; flex-direction: column; height: 100%; }
.thread-head { flex: none; background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.thread-name { font-weight: 700; font-size: 16px; }
.thread-sub { font-size: 12px; }
.thread-msgs { flex: 1; overflow-y: auto; padding: 18px 14% 18px 18px; display: flex; flex-direction: column; gap: 4px; }
.msg { display: flex; }
.msg--in { justify-content: flex-start; }
.msg--out { justify-content: flex-end; }
.bubble { max-width: 70%; background: var(--bubble-in); border-radius: 8px; padding: 6px 9px 4px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.msg--out .bubble { background: var(--bubble-out); }
.bubble-text { font-size: 14.5px; white-space: pre-wrap; word-wrap: break-word; line-height: 1.35; }
.bubble-meta { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.tick--read { color: #53bdeb; }
.composer { flex: none; display: flex; gap: 10px; padding: 12px 16px; background: var(--panel); border-top: 1px solid var(--line); }
.composer input { flex: 1; padding: 11px 14px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; }
.composer input:focus { outline: none; border-color: var(--wa-teal-2); }
.composer input:disabled { background: #f3f5f6; color: var(--muted); }
.composer-hint { flex: none; padding: 8px 16px; font-size: 13px; color: #8a5a00; background: #fff8e6; border-top: 1px solid #ffe8a8; }
.composer-error { flex: none; margin: 0; padding: 7px 16px; font-size: 13px; color: var(--danger); background: #fdecea; border-top: 1px solid #f5c6cb; }

/* Contacts */
.contacts-list { display: flex; flex-direction: column; gap: 8px; max-width: 720px; }
.contact { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.contact-main { flex: 1; min-width: 0; }
.contact-name { font-weight: 600; }
.contact-sub { font-size: 13px; }

/* Verwaltung (M4) */
.subtabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.subtab { background: transparent; color: var(--muted); border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 9px 12px; font-weight: 600; font-size: 14px; }
.subtab:hover { color: var(--ink); background: transparent; }
.subtab.is-active { color: var(--wa-teal); border-bottom-color: var(--wa-teal); }
.admin-content { max-width: 940px; }
.admin-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.inline-input { padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px; min-width: 200px; }
.tbl { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 10px 14px; background: #f7f9fa; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.tag--ok { background: #e7f8ee; color: #1d6b3f; }
.tag--warn { background: #fff4e5; color: #8a5a00; }
.tag--bad { background: #fdecea; color: #b3261e; }
.tag--mute { background: var(--bg); color: var(--muted); }
button.mini.danger { color: var(--danger); border-color: #f3c2bd; }
button.mini:disabled { opacity: .5; cursor: not-allowed; }
.admin-form { display: flex; flex-direction: column; gap: 10px; max-width: 560px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.admin-form > label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.admin-form input, .admin-form select, .admin-form textarea { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px; }
.admin-form input:focus, .admin-form select:focus, .admin-form textarea:focus { outline: none; border-color: var(--wa-teal-2); }
.admin-form textarea { resize: vertical; }
.form-row { display: flex; gap: 10px; margin-top: 6px; }
button.ghost-dark { background: var(--bg); color: var(--ink); }
button.ghost-dark:hover { background: #e4e9ec; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 26px; background: var(--wa-teal-2); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-lab { font-size: 10px; color: var(--muted); }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; }
  .inbox { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .kv { grid-template-columns: 1fr; }
}
