/* Kolibri - Oberflaeche. Hell/dunkel automatisch, schmal (Tray-Fenster, Handy) und breit (Browser). */
:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #e6e9f0;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #0d9488;
  --brand-2: #7c3aed;
  --brand-grad: linear-gradient(135deg, #0d9488 0%, #10b981 50%, #7c3aed 100%);
  --mine: linear-gradient(135deg, #0f9f8f, #0d9488 60%, #0b7f75);
  --mine-text: #ffffff;
  --theirs: #ffffff;
  --important: #f59e0b;
  --important-bg: #fff7e6;
  --danger: #e11d48;
  --danger-bg: #fff1f3;
  --ok: #16a34a;
  --ok-bg: #ecfdf3;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .06);
  --radius: 14px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
}
/* Dunkel: wird über data-theme am <html> gesteuert (Umschalter in den Einstellungen).
   "Automatisch" setzt data-theme per JS auf den Systemwert, deshalb kein prefers-color-scheme mehr noetig. */
:root[data-theme="dark"] {
  --bg: #0b1120;
  --panel: #111827;
  --panel-2: #0f172a;
  --line: #1f2937;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --theirs: #1a2333;
  --important-bg: #2a2010;
  --danger-bg: #2a1118;
  --ok-bg: #0f2a1b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }

.app, .view { height: 100%; }
.view { display: flex; flex-direction: column; }
.center { align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 24px; }

/* ---------- Bausteine ---------- */
.btn { border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); transition: transform .08s, filter .15s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand-grad); color: #fff; border: 0; box-shadow: 0 6px 16px rgba(13, 148, 136, .3); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.wide { width: 100%; padding: 12px; font-size: 15px; }
.icon-btn { border: 0; background: transparent; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.small { width: 28px; height: 28px; }
.icon-btn.small svg { width: 16px; height: 16px; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
.spinner.big { width: 28px; height: 28px; border-width: 3px; margin-top: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; text-align: left; }
.field > span { font-weight: 600; font-size: 13px; }
.field em { font-weight: 400; color: var(--muted); font-style: normal; }
.field input { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(13, 148, 136, .15); }
.field small { color: var(--muted); font-size: 12px; }

/* ---------- Einrichtung ---------- */
.setup { align-items: center; justify-content: center; padding: 20px; background:
  radial-gradient(800px 400px at 0% 0%, rgba(13, 148, 136, .14), transparent 60%),
  radial-gradient(700px 400px at 100% 100%, rgba(124, 58, 237, .14), transparent 60%), var(--bg); overflow: auto; }
.setup-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 26px 24px; box-shadow: var(--shadow); text-align: center; }
.login-foot { position: fixed; left: 0; right: 0; bottom: 14px; text-align: center; font-size: 12px; color: var(--muted); }
.login-foot a { color: var(--brand); text-decoration: none; font-weight: 600; }
.login-foot a:hover { text-decoration: underline; }
.setup-logo { width: 64px; height: 64px; border-radius: 18px; box-shadow: 0 10px 24px rgba(13, 148, 136, .28); }
.setup h1 { font-size: 21px; margin: 14px 0 4px; letter-spacing: -.01em; }
.detected { margin: 16px 0 4px; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px dashed var(--line); font-size: 13px; }
.detected.ok { background: var(--ok-bg); border: 1px solid rgba(22, 163, 74, .25); color: var(--ok); font-weight: 600; }
.detected.warn { background: var(--important-bg); border: 1px solid rgba(245, 158, 11, .35); color: #b45309; }
.setup-error { color: var(--danger); font-size: 13px; margin: 10px 0 0; }

/* ---------- Kopfzeile ---------- */
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.logo { width: 34px; height: 34px; border-radius: 10px; }
.me { flex: 1; min-width: 0; }
.me-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; flex: none; }
.dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.dot.wait { background: var(--important); }

/* ---------- Bereiche ---------- */
.panes { flex: 1; display: flex; min-height: 0; }
.pane { min-height: 0; display: flex; flex-direction: column; }
.list { width: 300px; flex: none; border-right: 1px solid var(--line); background: var(--panel); }
.chat { flex: 1; position: relative; background: var(--bg); }
.back { display: none; }
@media (max-width: 680px) {
  .list { width: 100%; border-right: 0; }
  .chat { display: none; }
  .panes.show-chat .list { display: none; }
  .panes.show-chat .chat { display: flex; }
  .back { display: grid; }
}

.search { padding: 10px 12px 6px; }
.search input { width: 100%; border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 8px 12px; outline: none; }
.search input:focus { border-color: var(--brand); }
.channel-list { overflow-y: auto; padding: 4px 8px 12px; flex: 1; }
.group-title { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 14px 8px 6px; display: flex; justify-content: space-between; }
.ch { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; background: transparent; border-radius: 12px; text-align: left; }
.ch:hover { background: var(--panel-2); }
.ch.active { background: rgba(13, 148, 136, .1); }
.ch.offline { opacity: .45; cursor: default; }
.avatar { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex: none; position: relative; }
.avatar svg { width: 18px; height: 18px; }
.avatar .presence { position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--panel); background: #94a3b8; }
.avatar .presence.on { background: #22c55e; }
.avatar .dnd-badge { position: absolute; right: -4px; top: -4px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--panel); background: #6366f1; color: #fff; display: grid; place-items: center; }
.avatar .dnd-badge svg { width: 9px; height: 9px; fill: currentColor; stroke: none; }
.ch-main { flex: 1; min-width: 0; }
.ch-title { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-sub { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 11px; color: var(--muted); }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.badge.ack { background: var(--important); }
.badge.em { background: var(--danger); }

/* ---------- Chat ---------- */
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.chat-avatar { flex: none; }
.chat-titles { min-width: 0; }
.chat-title { font-weight: 700; }
.chat-sub { font-size: 12px; color: var(--muted); }
.messages { flex: 1; overflow-y: auto; padding: 14px 12px 8px; display: flex; flex-direction: column; gap: 6px; scroll-behavior: smooth; }
.empty-chat { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); gap: 8px; background: var(--bg); }
.empty-chat img { width: 56px; height: 56px; border-radius: 16px; opacity: .9; }

.msg { display: flex; flex-direction: column; max-width: 86%; align-self: flex-start; animation: pop .18s ease-out; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
@keyframes pop { from { transform: translateY(4px); opacity: 0; } to { transform: none; opacity: 1; } }
.msg-head { font-size: 12px; color: var(--muted); margin: 0 6px 3px; display: flex; gap: 6px; align-items: baseline; }
.msg-head strong { color: var(--text); font-weight: 600; }
.bubble { background: var(--theirs); border: 1px solid var(--line); border-radius: var(--radius); border-top-left-radius: 6px; padding: 9px 12px; box-shadow: var(--shadow); white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.mine .bubble { background: var(--mine); color: var(--mine-text); border: 0; border-top-left-radius: var(--radius); border-top-right-radius: 6px; }
.msg.important .bubble { border: 1px solid rgba(245, 158, 11, .55); background: var(--important-bg); }
.msg.mine.important .bubble { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; border: 0; }
.msg.emergency .bubble { border: 2px solid var(--danger); background: var(--danger-bg); }
.msg.mine.emergency .bubble { background: linear-gradient(135deg, #e11d48, #be123c); color: #fff; border: 0; }
.prio-tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; margin-bottom: 4px; }
.prio-tag.important { background: var(--important); color: #fff; }
.prio-tag.emergency { background: var(--danger); color: #fff; }
.quote { font-size: 12px; border-left: 3px solid var(--brand); padding: 3px 8px; margin-bottom: 6px; border-radius: 4px; background: rgba(13, 148, 136, .08); opacity: .9; }
.msg.mine .quote { border-left-color: rgba(255, 255, 255, .7); background: rgba(255, 255, 255, .15); }
.msg-foot { display: flex; gap: 8px; align-items: center; margin: 4px 6px 0; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.msg-foot button.link { border: 0; background: none; padding: 0; color: var(--muted); font-size: 12px; }
.msg-foot button.link:hover { color: var(--brand); text-decoration: underline; }
.ack-box { margin-top: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ack-btn { border: 0; border-radius: 9px; padding: 7px 12px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #16a34a, #15803d); box-shadow: 0 4px 12px rgba(22, 163, 74, .3); display: inline-flex; gap: 6px; align-items: center; }
.ack-btn svg { width: 16px; height: 16px; }
.ack-need { font-size: 12px; font-weight: 600; color: #b45309; display: inline-flex; gap: 4px; align-items: center; }
.ack-done { font-size: 12px; font-weight: 600; color: var(--ok); display: inline-flex; gap: 4px; align-items: center; }
.ack-need svg, .ack-done svg { width: 14px; height: 14px; }
.status-pill { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 1px 8px; font-size: 11px; color: var(--muted); }
.status-pill.done { color: var(--ok); border-color: rgba(22, 163, 74, .35); background: var(--ok-bg); }
.status-pill.open { color: #b45309; border-color: rgba(245, 158, 11, .4); background: var(--important-bg); }
.day-sep { align-self: center; font-size: 11px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; margin: 10px 0 4px; }
.system-note { align-self: center; font-size: 12px; color: var(--muted); margin: 6px 0; }

/* ---------- Eingabe ---------- */
.composer { background: var(--panel); border-top: 1px solid var(--line); padding: 8px 10px 10px; flex: none; }
.compose-options { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.chip.toggle input { display: none; }
.chip.toggle span { display: inline-flex; gap: 5px; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; transition: all .15s; }
.chip.toggle span svg { width: 14px; height: 14px; }
.chip.toggle input:checked + span { background: var(--ok-bg); color: var(--ok); border-color: rgba(22, 163, 74, .4); font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 4px 10px; font-size: 12px; color: var(--muted); }
.seg button.on { background: var(--panel-2); color: var(--text); font-weight: 600; }
.seg.prio button[data-v="important"].on { background: var(--important); color: #fff; }
.seg.prio button[data-v="emergency"].on { background: var(--danger); color: #fff; }
.compose-row { display: flex; gap: 8px; align-items: flex-end; }
.compose-row textarea { flex: 1; resize: none; border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 10px 12px; max-height: 140px; outline: none; transition: border-color .15s, box-shadow .15s; }
.compose-row textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(13, 148, 136, .14); background: var(--panel); }
.send { width: 42px; height: 42px; border-radius: 12px; border: 0; background: var(--brand-grad); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 16px rgba(13, 148, 136, .3); flex: none; }
.send:disabled { opacity: .45; box-shadow: none; cursor: default; }
.compose-hint { font-size: 11px; color: var(--muted); margin-top: 6px; }
.reply-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-left: 3px solid var(--brand); background: var(--panel-2); border-radius: 8px; padding: 6px 8px; margin-bottom: 8px; font-size: 12px; }
.reply-bar strong { margin-right: 6px; }
.composer.disabled textarea, .composer.disabled .compose-options { opacity: .5; pointer-events: none; }

/* ---------- Einstellungen ---------- */
.settings-body { padding: 8px 16px 20px; overflow: auto; max-width: 520px; width: 100%; }
.switch { display: flex; align-items: center; gap: 10px; margin: 14px 0 18px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch span { width: 40px; height: 22px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }
.btn.danger-outline { color: var(--danger); background: transparent; border-color: rgba(225, 29, 72, .35); margin-left: 8px; }
.about { margin-top: 22px; font-size: 12px; color: var(--muted); line-height: 1.7; }

/* ---------- Notfall ---------- */
.emergency { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 18px; background: rgba(190, 18, 60, .92); animation: flash 1s ease-in-out infinite alternate; }
@keyframes flash { from { background: rgba(190, 18, 60, .95); } to { background: rgba(225, 29, 72, .82); } }
.em-card { background: #fff; color: #0f172a; border-radius: 20px; padding: 24px; width: 100%; max-width: 420px; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.em-icon { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 50%; background: #e11d48; color: #fff; font-size: 32px; font-weight: 800; display: grid; place-items: center; }
.em-from { font-weight: 700; color: #e11d48; text-transform: uppercase; letter-spacing: .04em; font-size: 13px; }
.em-body { font-size: 20px; font-weight: 700; margin: 10px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.em-time { color: #64748b; font-size: 13px; margin-bottom: 16px; }
.em-btn { background: #e11d48; color: #fff; border: 0; width: 100%; padding: 13px; font-size: 16px; }

/* ---------- Popover / Toast ---------- */
.popover { position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, .35); display: grid; place-items: center; padding: 16px; }
.pop-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; width: 100%; max-width: 380px; max-height: 80vh; overflow: auto; box-shadow: var(--shadow); }
.pop-card h3 { margin: 0 0 10px; font-size: 15px; }
.pop-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.pop-row:last-child { border-bottom: 0; }
.pop-row .st { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }
.pop-row .st.ok { color: var(--ok); font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60; background: #0f172a; color: #fff; padding: 9px 14px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); max-width: 90%; }

/* ================= Stufe 2 ================= */
.sos-btn { border: 0; border-radius: 9px; padding: 6px 9px; font-weight: 800; font-size: 12px; letter-spacing: .04em; color: #fff;
  background: linear-gradient(135deg, #f43f5e, #be123c); box-shadow: 0 4px 12px rgba(225, 29, 72, .3); }
.sos-btn:hover { filter: brightness(1.08); }
.icon-btn.on { background: #312e81; color: #c7d2fe; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; font-size: 13px; flex: none; border-bottom: 1px solid var(--line); }
.banner.update { background: linear-gradient(90deg, rgba(13, 148, 136, .14), rgba(124, 58, 237, .14)); }
.banner.dnd { background: #1e1b4b; color: #e0e7ff; border-color: #312e81; }
.banner.dnd .btn { background: transparent; color: #e0e7ff; border-color: #4338ca; }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.muted.small, .small { font-size: 12px; }

/* Schnellnachrichten */
.quick-toggle { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--muted); }
.quick-toggle.on { background: rgba(13, 148, 136, .12); color: var(--brand); border-color: rgba(13, 148, 136, .4); font-weight: 600; }
.quick-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; max-height: 110px; overflow-y: auto; }
.quick-bar button { border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 6px 10px; font-size: 12px; text-align: left; }
.quick-bar button:hover { border-color: var(--brand); background: rgba(13, 148, 136, .08); }
.quick-bar button.important { border-color: rgba(245, 158, 11, .5); }
.quick-bar button.emergency { border-color: rgba(225, 29, 72, .5); color: var(--danger); }

/* Status in der Liste */
.dnd-tag { display: inline-block; font-size: 10px; font-weight: 700; color: #4338ca; background: #e0e7ff; border-radius: 6px; padding: 0 6px; margin-left: 6px; vertical-align: 1px; }
:root[data-theme="dark"] .dnd-tag { background: #312e81; color: #c7d2fe; }

/* Seiten (Hilfe, Info) */
.page { position: fixed; inset: 0; z-index: 30; background: var(--bg); }
.page-body { flex: 1; overflow-y: auto; padding: 14px 16px 30px; }
.settings-links { display: flex; gap: 8px; margin-top: 18px; }
.help h2 { font-size: 15px; margin: 18px 0 6px; display: flex; align-items: center; gap: 8px; }
.help h2:first-child { margin-top: 4px; }
.help p, .help li { color: var(--text); line-height: 1.55; margin: 4px 0; }
.help ul { padding-left: 18px; margin: 4px 0; }
.help .ico { width: 26px; height: 26px; border-radius: 8px; display: inline-grid; place-items: center; color: #fff; font-size: 13px; flex: none; }
.help .tip { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 10px 0; font-size: 13px; }
.help kbd { font: 600 12px var(--font); background: var(--panel); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; }
.info-page { text-align: center; }
.info-page .hero { width: 84px; height: 84px; border-radius: 24px; margin: 10px auto 6px; box-shadow: 0 12px 28px rgba(13, 148, 136, .3); }
.info-page h1 { font-size: 22px; margin: 6px 0 0; }
.info-page .ver { color: var(--muted); font-size: 13px; }
.info-page .tagline { margin: 10px auto 16px; max-width: 320px; color: var(--muted); }
.creds { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; margin: 0 auto; max-width: 360px; box-shadow: var(--shadow); }
.creds .name { font-weight: 800; font-size: 16px; }
.creds .role { color: var(--brand); font-weight: 600; font-size: 13px; margin-bottom: 10px; }
.creds .row { display: flex; gap: 10px; font-size: 13px; padding: 3px 0; }
.creds .row span:first-child { width: 48px; color: var(--muted); flex: none; }
.creds a { color: var(--brand); text-decoration: none; }
.info-page .tech { color: var(--muted); font-size: 12px; margin-top: 16px; line-height: 1.7; }

/* Update */
.update-card { text-align: center; }
.upd-logo { width: 56px; height: 56px; border-radius: 16px; }
.upd-notes { text-align: left; white-space: pre-wrap; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 10px 0; max-height: 200px; overflow-y: auto; }
.upd-notes:empty { display: none; }
.upd-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.updating { position: fixed; inset: 0; z-index: 70; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; padding: 20px; }
.updating img { width: 64px; height: 64px; border-radius: 18px; }

/* Behandlungsmodus-Auswahl */
.dnd-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }

/* Notfall melden */
.sos-pop { background: rgba(190, 18, 60, .55); }
.sos-card { text-align: center; border: 2px solid var(--danger); }
.sos-card h3 { margin: 4px 0 2px; color: var(--danger); }
.sos-card textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 15px; font-weight: 600; resize: none; background: var(--panel-2); margin-top: 8px; }
.sos-send { background: linear-gradient(135deg, #f43f5e, #be123c); color: #fff; border: 0; }

/* ================= Stufe 3 ================= */
/* Reiter in der Liste */
.list .tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); flex: none; }
.list .tabs button { flex: 1; border: 0; background: none; padding: 8px 4px 9px; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; position: relative; }
.list .tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.tab-badge { display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--important); color: #fff; font-size: 10px; margin-left: 3px; vertical-align: 1px; }
.tab-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tab-pane.scroll { overflow-y: auto; padding: 10px 12px 16px; display: block; }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 2px 0 10px; }
.pane-head h3 { margin: 0; font-size: 14px; }
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 24px 10px; }

/* Zimmer-Ampel */
.room-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 9px; width: 32px; height: 32px; display: grid; place-items: center; }
.room-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #cbd5e1; flex: none; }
.room-dot.free { background: #22c55e; } .room-dot.patient { background: #ef4444; } .room-dot.cleaning { background: #f59e0b; }
.room-dot.ready { background: #3b82f6; } .room-dot.away { background: #94a3b8; }
.rooms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.room-card { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 10px; border-left: 5px solid #cbd5e1; cursor: pointer; text-align: left; }
.room-card.free { border-left-color: #22c55e; } .room-card.patient { border-left-color: #ef4444; } .room-card.cleaning { border-left-color: #f59e0b; }
.room-card.ready { border-left-color: #3b82f6; } .room-card.away { border-left-color: #94a3b8; }
.room-card.off { opacity: .45; }
.room-card .rn { font-weight: 700; font-size: 13px; }
.room-card .rs { font-size: 12px; color: var(--muted); margin-top: 2px; }
.room-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; color: var(--muted); margin-top: 12px; }
.room-legend span { display: inline-flex; align-items: center; gap: 4px; }
.ch .room-dot { width: 9px; height: 9px; margin-left: 6px; vertical-align: 1px; }

/* Menues */
.menu-pop { position: fixed; z-index: 45; top: 52px; right: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: var(--shadow); min-width: 220px; }
.menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 9px 10px; border-radius: 8px; text-align: left; font-size: 13px; }
.menu-pop button:hover { background: var(--panel-2); }
.menu-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 6px 10px 4px; }

/* Anhaenge */
.attach-btn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); display: grid; place-items: center; flex: none; }
.attach-btn:hover { color: var(--brand); border-color: var(--brand); }
.att-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.att-chip { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--panel-2); display: grid; place-items: center; font-size: 11px; color: var(--muted); }
.att-chip img { width: 100%; height: 100%; object-fit: cover; }
.att-chip button { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(15, 23, 42, .75); color: #fff; font-size: 12px; line-height: 1; }
.msg-images { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.msg-images img { max-width: 220px; max-height: 180px; border-radius: 10px; cursor: zoom-in; border: 1px solid var(--line); background: #fff; }
.msg-images .gone { font-size: 12px; color: var(--muted); font-style: italic; }
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(2, 6, 23, .88); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: calc(100% - 30px); border-radius: 8px; }
.lb-hint { color: #cbd5e1; font-size: 12px; margin-top: 8px; }
.chip-select { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 3px 8px; font-size: 12px; color: var(--muted); }

/* Aufgaben */
.task-box { margin-top: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.task-state { font-weight: 700; border-radius: 6px; padding: 2px 8px; }
.task-state.open { background: var(--important-bg); color: #b45309; }
.task-state.claimed { background: #dbeafe; color: #1d4ed8; }
.task-state.done { background: var(--ok-bg); color: var(--ok); }
:root[data-theme="dark"] .task-state.claimed { background: #172554; color: #93c5fd; }
.task-btn { border: 0; border-radius: 8px; padding: 6px 10px; font-weight: 700; font-size: 12px; color: #fff; background: #2563eb; }
.task-btn.done { background: linear-gradient(135deg, #16a34a, #15803d); }
.task-btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.task-tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; margin-bottom: 4px; background: #2563eb; color: #fff; }

/* Systemnachrichten (Erinnerung, Labor, Durchsage) */
.msg.system { align-self: center; max-width: 92%; align-items: center; }
.msg.system .bubble { background: linear-gradient(135deg, rgba(13, 148, 136, .10), rgba(124, 58, 237, .10)); border: 1px dashed rgba(124, 58, 237, .35); text-align: center; }
.msg.system .msg-head { justify-content: center; }
.msg.remind-flash .bubble { animation: remindPulse 1s ease-in-out 3; }
@keyframes remindPulse { 0%, 100% { box-shadow: var(--shadow); } 50% { box-shadow: 0 0 0 4px rgba(245, 158, 11, .5); } }

/* Labor */
.lab-card { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.lab-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.lab-num { font-weight: 800; font-size: 14px; }
.lab-meta { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.lab-pill { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.lab-pill.ordered { background: #e0e7ff; color: #3730a3; } .lab-pill.in_work { background: #fef3c7; color: #92400e; }
.lab-pill.ready { background: #dcfce7; color: #166534; } .lab-pill.picked { background: #dbeafe; color: #1e40af; }
.lab-pill.arrived { background: #f1f5f9; color: #475569; } .lab-pill.cancelled { background: #fee2e2; color: #991b1b; }
.lab-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.lab-hist { font-size: 11px; color: var(--muted); margin-top: 6px; border-top: 1px dashed var(--line); padding-top: 6px; line-height: 1.6; }
.lab-filter { display: flex; gap: 6px; margin-bottom: 10px; }

/* Schwarzes Brett */
.notice { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; position: relative; }
.notice.unread { border-color: var(--important); box-shadow: 0 0 0 3px rgba(245, 158, 11, .12); }
.notice h4 { margin: 0 0 4px; font-size: 14px; display: flex; gap: 6px; align-items: center; }
.notice .nb { white-space: pre-wrap; font-size: 13px; overflow-wrap: anywhere; }
.notice .nm { font-size: 11px; color: var(--muted); margin-top: 6px; display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.new-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--important); display: inline-block; }

/* Formulare */
.form-card { max-width: 400px; }
.form-card h3 { margin: 0 0 4px; }
.form-card .field { margin: 10px 0; }
.form-card select, .form-card textarea { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 9px 11px; width: 100%; font: inherit; color: inherit; }
.form-card textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.form-hint { font-size: 12px; color: var(--muted); }
.form-hint.warn { color: #b45309; }
