/* SAM Board – „Quiet Luxury": Off-White, Charcoal, Kupfer. Mobil zuerst, Dark Mode automatisch. */

:root {
  --bg: #f4f2ee;
  --bg-sunk: #ece9e3;
  --surface: #fbfaf8;
  --surface-2: #ffffff;
  --ink: #1a1a18;
  --ink-2: #4a4945;
  --muted: #8a877f;
  --line: #e2ded6;
  --line-strong: #cfc9bd;
  --accent: #b07d62;
  --accent-ink: #8c5f47;
  --accent-soft: #f1e6df;
  --ok: #4f7a5a;
  --ok-soft: #e4ede5;
  --warn: #b38a2e;
  --warn-soft: #f5ecd6;
  --bad: #a8473b;
  --bad-soft: #f5e1dd;
  --info-soft: #e7e9ee;
  --shadow: 0 1px 2px rgba(26, 26, 24, 0.04), 0 8px 24px -12px rgba(26, 26, 24, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --bg-sunk: #0f0f0e;
    --surface: #1c1c1a;
    --surface-2: #232321;
    --ink: #f1eee8;
    --ink-2: #c9c5bc;
    --muted: #8f8b82;
    --line: #2d2c29;
    --line-strong: #3d3b37;
    --accent: #c99577;
    --accent-ink: #dcae93;
    --accent-soft: #33271f;
    --ok: #86b590;
    --ok-soft: #1f2b22;
    --warn: #d8b25c;
    --warn-soft: #2f2817;
    --bad: #e08a7d;
    --bad-soft: #351f1b;
    --info-soft: #24262b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg-sunk); padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.icon { display: inline-flex; width: 20px; height: 20px; flex: none; }
.icon svg { width: 100%; height: 100%; }

/* ─── Hülle ─────────────────────────────────────────────────────────── */
.shell { min-height: 100%; }
.main { min-height: 100vh; padding: calc(16px + var(--safe-t)) 16px calc(var(--tabbar-h) + 24px + var(--safe-b)); outline: none; }
.view { max-width: 1120px; margin: 0 auto; }

.sidebar { display: none; }
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(18px); -webkit-backdrop-filter: saturate(1.4) blur(18px);
  border-top: 1px solid var(--line);
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font: 500 11px/1 var(--font); color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer;
}
.tab:hover { text-decoration: none; }
.tab .icon { width: 23px; height: 23px; }
.tab.active { color: var(--ink); }
.tab.active .icon { color: var(--accent); }
.tab .badge { position: absolute; top: 8px; left: calc(50% + 6px); }

.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; font: 600 11px/18px var(--font); text-align: center;
}

@media (min-width: 900px) {
  .tabbar { display: none; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 248px; z-index: 30;
    display: flex; flex-direction: column; gap: 4px; padding: 24px 14px;
    border-right: 1px solid var(--line); background: var(--bg);
  }
  .main { margin-left: 248px; padding: 32px 40px 48px; }
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 22px; }
.brand img { border-radius: 9px; }
.brand strong { display: block; font-size: 15px; letter-spacing: 0.06em; }
.brand span { display: block; font-size: 12.5px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-list { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
  color: var(--ink-2); font: 500 14px/1.2 var(--font); background: none; border: 0; cursor: pointer; text-align: left; width: 100%;
}
.nav-item:hover { background: var(--bg-sunk); text-decoration: none; color: var(--ink); }
.nav-item.active { background: var(--surface-2); color: var(--ink); box-shadow: var(--shadow); }
.nav-item.active .icon { color: var(--accent); }
.nav-item .icon { width: 19px; height: 19px; }
.nav-item .badge { margin-left: auto; }
.nav-logout { color: var(--muted); }

/* „Mehr"-Blatt am Handy */
.sheet {
  margin: auto 0 0; width: 100%; max-width: 100%; border: 0; padding: 10px 16px calc(20px + var(--safe-b));
  border-radius: 22px 22px 0 0; background: var(--surface); color: var(--ink);
}
.sheet::backdrop, .dialog::backdrop { background: rgba(20, 20, 18, 0.35); backdrop-filter: blur(2px); }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 0 auto 14px; }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-item {
  display: flex; align-items: center; gap: 10px; padding: 16px 14px; border-radius: 14px;
  background: var(--bg); color: var(--ink); font: 500 14px/1.25 var(--font); border: 1px solid var(--line); cursor: pointer; text-align: left;
}
.sheet-item:hover { text-decoration: none; border-color: var(--line-strong); }
.sheet-item .icon { color: var(--accent); }

/* ─── Seitenkopf, Karten ─────────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 4px 0 22px; }
.page-head p { margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { font: 600 11.5px/1 var(--font); letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent-ink); margin-bottom: 8px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { display: flex; align-items: center; gap: 10px; }
.card-head .icon { color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid-2 { display: grid; gap: 14px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

/* ─── Banner ─────────────────────────────────────────────────────────── */
#banners:empty { display: none; }
#banners { max-width: 1120px; margin: 0 auto 16px; display: flex; flex-direction: column; gap: 8px; }
.banner {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; font-size: 14px; border: 1px solid transparent;
}
.banner > span:not(.icon):not(.dot) { flex: 1; }
.banner-test { background: var(--warn-soft); color: var(--ink); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner-test .icon { color: var(--warn); }
.banner-danger { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.banner-danger .icon { color: var(--bad); }
.banner-info { background: var(--info-soft); }

/* ─── Knöpfe & Formulare ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink);
  font: 500 14px/1 var(--font); cursor: pointer; white-space: nowrap; transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { border-color: var(--ink-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--accent)); border-color: transparent; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-icon { width: 42px; padding: 0; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font: 500 13px/1.3 var(--font); color: var(--ink-2); }
.help { font-size: 12.5px; color: var(--muted); }
input[type='text'], input[type='password'], input[type='search'], input[type='tel'], input[type='number'], input[type='url'], input[type='time'], input[type='email'], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 13px; border-radius: 11px; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--ink); font: 16px/1.4 var(--font); /* 16px = kein iOS-Zoom */
  transition: border-color 0.15s, box-shadow 0.15s;
}
@media (min-width: 900px) { input[type='text'], input[type='password'], input[type='search'], input[type='tel'], input[type='number'], input[type='url'], select, textarea { font-size: 14.5px; } }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-error { color: var(--bad); font-size: 13.5px; }
.form-grid { display: grid; gap: 14px; }
@media (min-width: 760px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; } .form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); } .form-grid.cols-4 { grid-template-columns: repeat(4, 1fr); } }

/* Schalter */
.switch { position: relative; display: inline-flex; flex: none; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch-track { width: 46px; height: 28px; border-radius: 14px; background: var(--line-strong); transition: background 0.2s; position: relative; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.2s; }
.switch input:checked + .switch-track { background: var(--ok); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.6; }

/* Segment-Filter */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-sunk); border-radius: 11px; border: 1px solid var(--line); max-width: 100%; overflow-x: auto; }
.segmented button { border: 0; background: none; padding: 7px 13px; border-radius: 8px; font: 500 13px/1 var(--font); color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.segmented button.active { background: var(--surface-2); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

/* Tags */
.tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 7px; min-height: 44px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--surface-2); cursor: text; }
.tags:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tags input { flex: 1; min-width: 140px; border: 0 !important; box-shadow: none !important; min-height: 30px; padding: 2px 6px; background: transparent; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--ink); font-size: 13.5px; }
.tag button { border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; padding: 2px 6px; cursor: pointer; border-radius: 6px; }
.tag button:hover { color: var(--bad); }

/* Pillen & Ampeln */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font: 500 12px/1.4 var(--font); background: var(--bg-sunk); color: var(--ink-2); white-space: nowrap; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-accent { background: var(--accent-soft); color: var(--accent-ink); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--line-strong); }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot-bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

/* Leer-, Lade-, Fehlerzustände */
.empty { text-align: center; padding: 48px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty .empty-icon { width: 40px; height: 40px; color: var(--accent); opacity: 0.8; margin-bottom: 6px; }
.empty p { max-width: 380px; }
.empty .btn { margin-top: 10px; }
.empty-error .empty-icon { color: var(--bad); }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toasts & Dialoge */
.toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 16px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
@media (min-width: 900px) { .toasts { bottom: 24px; left: auto; right: 24px; transform: none; } }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--ink); color: var(--bg); font-size: 14px; box-shadow: var(--shadow); animation: rise 0.25s ease-out; transition: opacity 0.3s, transform 0.3s; }
.toast-error { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.dialog { border: 0; border-radius: 18px; padding: 24px; width: min(440px, calc(100% - 32px)); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.dialog h3 { font-size: 18px; margin-bottom: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; flex-wrap: wrap; }

/* ─── Übersicht ──────────────────────────────────────────────────────── */
.hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.hero h1 { font-size: 28px; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 6px; color: var(--ink); min-width: 0; }
a.kpi:hover { text-decoration: none; border-color: var(--line-strong); }
.kpi-label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi-label .icon { width: 15px; height: 15px; }
.kpi-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12.5px; color: var(--muted); }
.kpi-accent .kpi-value { color: var(--accent-ink); }
.status-list { display: flex; flex-direction: column; }
.status-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.status-row:first-child { border-top: 0; padding-top: 2px; }
.status-row .icon { color: var(--ink-2); }
.status-row .grow { flex: 1; min-width: 0; }
.status-row .detail { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.killswitch { display: flex; align-items: center; gap: 14px; }
.killswitch .grow { flex: 1; }

/* ─── Posteingang ────────────────────────────────────────────────────── */
.inbox { display: grid; gap: 0; }
.inbox-list-pane { min-width: 0; }
.inbox-tools { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.search { position: relative; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; pointer-events: none; }
.search input { padding-left: 38px; }
.conv-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.conv { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-top: 1px solid var(--line); color: var(--ink); cursor: pointer; }
.conv:first-child { border-top: 0; }
.conv:hover { background: var(--bg); text-decoration: none; }
.conv.active { background: var(--accent-soft); }
.avatar { width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--bg-sunk); color: var(--ink-2); font-weight: 600; font-size: 14.5px; position: relative; }
.avatar .ch { position: absolute; right: -3px; bottom: -3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; border: 1px solid var(--line); }
.avatar .ch .icon { width: 13px; height: 13px; color: var(--accent); }
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: baseline; gap: 8px; }
.conv-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 12px; color: var(--muted); flex: none; }
.conv-last { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.conv.unread .conv-last { color: var(--ink); font-weight: 500; }
.conv-meta { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.conv .badge { margin-left: auto; }

.chat { display: flex; flex-direction: column; min-width: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 0 0 12px; }
.chat-head .grow { flex: 1; min-width: 0; }
.chat-head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-status { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; margin-bottom: 12px; font-size: 13.5px; flex-wrap: wrap; }
.chat-status > span:not(.icon) { flex: 1; min-width: 160px; }
.chat-status .btn { flex: none; }
@media (max-width: 480px) { .chat-status .btn { width: 100%; } }
.chat-status.bot { background: var(--ok-soft); }
.chat-status.bot .icon { color: var(--ok); }
.chat-status.human { background: var(--warn-soft); }
.chat-status.human .icon { color: var(--warn); }
.messages { display: flex; flex-direction: column; gap: 6px; padding: 16px 12px; background: var(--bg-sunk); border-radius: var(--radius); border: 1px solid var(--line); min-height: 280px; max-height: calc(100vh - 360px); overflow-y: auto; overscroll-behavior: contain; }
.day-sep { align-self: center; font-size: 11.5px; color: var(--muted); padding: 6px 0; letter-spacing: 0.02em; }
.msg { max-width: min(78%, 520px); padding: 9px 13px; border-radius: 16px; font-size: 14.5px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; position: relative; }
.msg-in { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg-out { align-self: flex-end; border-bottom-right-radius: 6px; }
.msg-sam { background: var(--ink); color: var(--bg); }
.msg-staff { background: var(--accent); color: #fff; }
.msg-system { align-self: center; background: transparent; color: var(--muted); font-size: 12.5px; text-align: center; max-width: 90%; }
.msg-author { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; opacity: 0.72; margin-bottom: 2px; }
.msg-foot { display: flex; justify-content: flex-end; gap: 6px; font-size: 10.5px; opacity: 0.65; margin-top: 3px; }
.msg img { display: block; max-width: 100%; max-height: 280px; border-radius: 10px; margin: 2px 0 4px; }
.msg .attach { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; opacity: 0.85; }
.composer { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; }
.composer textarea { min-height: 46px; max-height: 160px; resize: none; border-radius: 14px; }
.composer .btn { height: 46px; }
.composer-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.contact-pane { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.kv + .toggle-row, .divider + .toggle-row { border-top: 0; }
.toggle-row .help { margin-top: 2px; }
.appt { padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); font-size: 13.5px; }
.appt + .appt { margin-top: 6px; }

@media (min-width: 900px) {
  .view-inbox { max-width: none; }
  .inbox { grid-template-columns: minmax(300px, 360px) 1fr; gap: 20px; align-items: start; }
  .inbox.has-contact { grid-template-columns: minmax(280px, 340px) 1fr 300px; }
  .inbox .back-btn { display: none; }
  .inbox-list-pane { position: sticky; top: 32px; max-height: calc(100vh - 64px); overflow-y: auto; }
  .contact-pane { margin-top: 0; position: sticky; top: 32px; }
  .messages { max-height: calc(100vh - 330px); }
}
@media (max-width: 899px) {
  .inbox.chat-open .inbox-list-pane { display: none; }
  .inbox:not(.chat-open) .chat, .inbox:not(.chat-open) .contact-pane { display: none; }
  body[data-page='inbox'] .inbox.chat-open .messages { max-height: none; min-height: 50vh; }
}
.chat-empty { display: none; }
@media (min-width: 900px) { .inbox:not(.chat-open) .chat-empty { display: flex; } }

/* ─── Tabellen & Listen ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font: 500 12px/1.2 var(--font); color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: top; }
tr:first-child td { border-top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-item { display: flex; align-items: flex-start; gap: 14px; padding: 15px 16px; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item h3 { font-weight: 500; }
.list-item.done h3 { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.check-btn { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--line-strong); background: var(--surface-2); flex: none; display: grid; place-items: center; cursor: pointer; color: transparent; padding: 0; margin-top: -2px; }
.check-btn:hover { border-color: var(--ok); color: var(--ok); }
.check-btn.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.check-btn .icon { width: 16px; height: 16px; }
.summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.summary .kpi { flex: 1; min-width: 140px; padding: 14px; }
.summary .kpi-value { font-size: 22px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .search { flex: 1; min-width: 200px; }

/* Mobil: Tabellen als Karten */
@media (max-width: 759px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { padding: 12px 14px; border-top: 1px solid var(--line); }
  .table-cards tr:first-child { border-top: 0; }
  .table-cards td { border: 0; padding: 2px 0; text-align: left !important; }
  .table-cards td[data-label]::before { content: attr(data-label) ': '; color: var(--muted); font-size: 12.5px; }
  .table-cards td.primary { font-weight: 600; font-size: 15px; }
  .table-cards td.primary::before { content: none; }
}

/* ─── Verbindungen ───────────────────────────────────────────────────── */
.progress { height: 6px; border-radius: 3px; background: var(--bg-sunk); overflow: hidden; margin: 12px 0 14px; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.4s; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.check-item { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 8px 10px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); color: var(--ink); }
.check-item:hover { text-decoration: none; border-color: var(--line-strong); }
.check-item .icon { width: 16px; height: 16px; }
.check-item.ok .icon { color: var(--ok); }
.check-item:not(.ok) { color: var(--muted); }
.conn-card .card-head { align-items: flex-start; }
.conn-title { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.card-head > .switch, .card-head > .dot, .card-head > .pill { flex: none; }
.conn-title .icon-wrap { width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.conn-title p { font-size: 13px; }
.secret-state { font-size: 12px; margin-left: 6px; font-weight: 400; }
.copy-box { display: flex; gap: 8px; align-items: stretch; }
.copy-box code { flex: 1; display: block; padding: 11px 12px; border-radius: 11px; border: 1px dashed var(--line-strong); background: var(--bg); overflow-x: auto; white-space: nowrap; font-size: 12.5px; }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px; background: #fff; border-radius: 14px; border: 1px solid var(--line); }
.qr-box img { width: min(280px, 100%); height: auto; image-rendering: pixelated; }
.qr-box p { color: #4a4945; font-size: 13px; text-align: center; }
.steps { margin: 0; padding-left: 20px; font-size: 13.5px; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; }
.details-toggle { cursor: pointer; font-size: 13.5px; color: var(--accent-ink); font-weight: 500; list-style: none; padding: 4px 0; }
.details-toggle::-webkit-details-marker { display: none; }
details[open] > .details-toggle { margin-bottom: 12px; }

/* ─── Wissen ─────────────────────────────────────────────────────────── */
.section-nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.section-nav a { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.section-nav a:hover { text-decoration: none; border-color: var(--line-strong); }
.repeat-item { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); position: relative; }
.repeat-item + .repeat-item { margin-top: 10px; }
.repeat-item .remove { position: absolute; top: 8px; right: 8px; }
.savebar {
  position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px); z-index: 20; margin-top: 18px;
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.savebar .grow { flex: 1; font-size: 13px; color: var(--muted); }
@media (min-width: 900px) { .savebar { bottom: 16px; } }
@media (max-width: 520px) { .savebar .grow { display: none; } .savebar .btn { flex: 1; } }
.hours { display: grid; grid-template-columns: 44px 1fr; gap: 8px 10px; align-items: center; }
.hours label { font-weight: 500; font-size: 13.5px; color: var(--ink-2); }

/* ─── Simulator ──────────────────────────────────────────────────────── */
.sim { display: flex; flex-direction: column; max-width: 640px; margin: 0 auto; }
.sim .messages { min-height: 200px; height: calc(100svh - 470px); max-height: none; }
@media (min-width: 900px) { .sim .messages { min-height: 360px; height: calc(100vh - 360px); } }
.typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }
.suggestions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.suggestions button { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 7px 12px; font: 13px/1.2 var(--font); cursor: pointer; }
.suggestions button:hover { border-color: var(--accent); color: var(--ink); }

/* ─── System / Logs ──────────────────────────────────────────────────── */
.logs { font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; max-height: 420px; overflow: auto; background: var(--bg-sunk); border-radius: 12px; padding: 10px 12px; border: 1px solid var(--line); }
.log-line { display: grid; grid-template-columns: 64px 46px 1fr; gap: 8px; padding: 2px 0; border-bottom: 1px dashed var(--line); }
.log-line:last-child { border-bottom: 0; }
.log-warn { color: var(--warn); }
.log-error { color: var(--bad); }
.log-line .msg-text { color: var(--ink); overflow-wrap: anywhere; }

/* ─── Automationen ───────────────────────────────────────────────────── */
.auto-card .card-head { margin-bottom: 8px; }
.auto-stats { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin: 4px 0 12px; flex-wrap: wrap; }
.variant { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.variant + .variant { margin-top: 10px; }
.variant-label { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--ink); color: var(--bg); font-weight: 600; font-size: 13px; }
.bar { height: 8px; border-radius: 4px; background: var(--bg-sunk); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }
.result-box { padding: 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); font-size: 13.5px; }

/* ─── Login ──────────────────────────────────────────────────────────── */
.login-body { display: grid; min-height: 100%; }
.login { display: grid; place-items: center; padding: 24px 16px calc(24px + var(--safe-b)); min-height: 100vh; }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 36px 28px 28px; box-shadow: var(--shadow); text-align: left; }
.login-mark { border-radius: 14px; margin-bottom: 22px; display: block; }
.login-card h1 { font-size: 24px; margin-bottom: 6px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 24px; }
.login-foot { font-size: 12.5px; margin-top: 18px; line-height: 1.5; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* Erfolgszahlen */
.metrics-card { margin-bottom: 14px; }
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 14px; }
@media (min-width: 760px) { .metrics { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .metrics { grid-template-columns: repeat(6, 1fr); } }
.metric { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.metric-value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.metric-label { font-size: 13px; color: var(--ink-2); }
.metric-sub { font-size: 12px; color: var(--muted); }
.callout { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 500; font-size: 14px; }
.callout a { font-weight: 600; }

/* Gefährliche Aktion als zurückhaltender Text-Knopf (z. B. „Gerät abmelden") */
.btn-danger-text { color: var(--bad); }
.btn-danger-text:hover { border-color: var(--bad); }
/* Optionale Punkte der Verbindungs-Checkliste */
.check-item.optional { border-style: dashed; }
/* Raster-Spalten dürfen schrumpfen (lange Status-Texte sprengten auf dem Handy die Breite) */
.grid-2 > * { min-width: 0; }
.status-row .detail { overflow-wrap: anywhere; }
@media (max-width: 759px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.callout.warn { background: #fbecd9; color: #7a4a12; display: block; } @media (prefers-color-scheme: dark) { .callout.warn { background: #3a2a14; color: #f3d1a2; } }
