:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1c2526;
  --ink-soft: #5a6566;
  --line: #e3e1da;
  --accent: #1f5e63;
  --accent-soft: #e8f0f0;
  --ok: #2f7d46;
  --ok-soft: #e6f2ea;
  --warn: #b4541f;
  --danger: #b3261e;
  --radius: 10px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--ink); line-height: 1.5; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 22px; color: var(--accent); width: 38px; height: 38px; display: grid; place-items: center; background: var(--accent-soft); border-radius: 9px; }
.brand-title { font-family: 'Fraunces', serif; font-weight: 600; font-size: 17px; }
.brand-sub { font-size: 12.5px; color: var(--ink-soft); }
.topnav { display: flex; gap: 4px; margin-left: auto; }
.topnav button { font: inherit; font-size: 13.5px; font-weight: 500; padding: 7px 13px; border: none; background: transparent; color: var(--ink-soft); border-radius: 7px; cursor: pointer; }
.topnav button.active { background: var(--accent-soft); color: var(--accent); }
.topnav button:hover { color: var(--ink); }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.user-chip { color: var(--ink-soft); }
.user-chip b { color: var(--ink); font-weight: 600; }

main { max-width: 940px; margin: 0 auto; padding: 28px 24px 80px; }
.centered { min-height: 60vh; display: grid; place-items: center; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 40px; max-width: 420px; text-align: center; }
.login-card h1 { font-family: 'Fraunces', serif; font-weight: 600; font-size: 24px; margin-bottom: 10px; }
.login-card p { color: var(--ink-soft); margin-bottom: 24px; }

.btn { font: inherit; font-size: 13.5px; font-weight: 500; padding: 8px 15px; border-radius: 8px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); text-decoration: none; display: inline-block; }
.btn-primary:hover { background: #18494d; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-danger { color: var(--danger); border-color: var(--line); }
.btn-danger:hover { border-color: var(--danger); background: #fbeceb; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.view-title, .section-head { font-family: 'Fraunces', serif; font-weight: 600; }
.view-title { font-size: 22px; }
.section-head { font-size: 24px; margin-bottom: 6px; }
.toolbar-actions { display: flex; gap: 8px; }
.hint { color: var(--ink-soft); font-size: 13.5px; margin-bottom: 20px; }

/* Team-Block / Kanäle */
.team-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; }
.team-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.team-name { font-family: 'Fraunces', serif; font-weight: 600; font-size: 18px; }
.team-count { font-size: 12.5px; color: var(--ink-soft); }
.channel-row { display: flex; align-items: center; gap: 14px; padding: 13px 20px; border-bottom: 1px solid var(--line); cursor: pointer; }
.channel-row:last-child { border-bottom: none; }
.channel-row.checked { background: var(--ok-soft); }
.check { appearance: none; width: 22px; height: 22px; flex-shrink: 0; border: 1.8px solid var(--line); border-radius: 6px; cursor: pointer; display: grid; place-items: center; transition: all .15s; }
.check:checked { background: var(--ok); border-color: var(--ok); }
.check:checked::after { content: '✓'; color: #fff; font-size: 14px; font-weight: 700; }
.check:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.channel-info { flex: 1; min-width: 0; }
.channel-name { font-weight: 500; font-size: 14.5px; }
.channel-sub { font-size: 12px; color: var(--ink-soft); font-family: var(--mono); }
.badge { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 2px 7px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); margin-left: 6px; }
.badge.private { background: #f3e9dd; color: var(--warn); }

/* Benutzerverwaltung */
.user-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; }
.user-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.user-id { flex: 1; min-width: 180px; }
.user-name { font-weight: 600; font-size: 15px; }
.user-upn { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.role-pill { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.role-pill.admin { background: var(--accent-soft); color: var(--accent); }
.role-pill.user { background: #eee; color: var(--ink-soft); }
.user-teams { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.team-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 11px; font-size: 12.5px; }
.team-chip button { border: none; background: transparent; cursor: pointer; color: var(--ink-soft); font-size: 15px; line-height: 1; padding: 0 3px; }
.team-chip button:hover { color: var(--danger); }
.no-teams { font-size: 12.5px; color: var(--ink-soft); }

/* Einstellungen */
.settings-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; max-width: 560px; }
.field-label { display: block; font-weight: 600; font-size: 14px; margin-top: 16px; }
.settings-card .field-label:first-child { margin-top: 0; }
.field-hint { font-size: 12.5px; color: var(--ink-soft); margin: 2px 0 8px; }
textarea, .settings-card input, #teamSearchInput { font: inherit; font-size: 13.5px; width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; resize: vertical; }
textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(28,37,38,.45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--surface); border-radius: 14px; padding: 26px; width: 100%; max-width: 520px; max-height: 86vh; overflow-y: auto; }
.modal h3 { font-family: 'Fraunces', serif; font-weight: 600; font-size: 20px; margin-bottom: 6px; }
.modal-sub { color: var(--ink-soft); font-size: 13px; margin-bottom: 16px; }
.summary-box { border: 1px solid var(--line); border-radius: 10px; padding: 4px 0; margin-bottom: 16px; max-height: 40vh; overflow-y: auto; }
.summary-team { padding: 9px 16px; border-bottom: 1px solid var(--line); }
.summary-team:last-child { border-bottom: none; }
.summary-team-name { font-weight: 600; font-size: 14px; }
.summary-channels { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.summary-empty { padding: 20px; text-align: center; color: var(--ink-soft); }
.modal-recipients { font-size: 13px; color: var(--ink-soft); margin-bottom: 18px; }
.modal-recipients b { color: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.search-results { max-height: 44vh; overflow-y: auto; margin-bottom: 14px; }
.search-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.search-item:last-child { border-bottom: none; }
.search-item.assigned { color: var(--ink-soft); }

.empty { text-align: center; color: var(--ink-soft); padding: 50px 20px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 9px; font-size: 13.5px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 100; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.error { background: var(--danger); }

@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; gap: 12px; }
  .topnav { margin-left: 0; order: 3; width: 100%; }
  .brand-sub { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
