/* SwissHuman Designsystem v2 – gemeinsam für Website, Kund:innen-, Helfer:innen- und Ops-App.
   Leitfaden: docs/DESIGN.md */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Neutrals */
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-2: #f2f4f6;
  --surface-3: #e8ebef;
  --border: #e4e7eb;
  --border-strong: #cfd4da;
  --text: #0f1419;
  --text-muted: #5a6370;
  --text-faint: #8a929d;
  --ink: #111827;               /* dunkle Primärflächen */
  --ink-hover: #1f2937;
  --ink-text: #ffffff;
  /* Marke */
  --accent: #d52b1e;
  --accent-hover: #b8231a;
  --accent-soft: #fdecea;
  --accent-ink: #ffffff;
  /* Status */
  --ok: #157347;      --ok-soft: #e6f4ec;
  --warn: #9a5b00;    --warn-soft: #fff4e0;
  --info: #1d5bd6;    --info-soft: #e8f0fe;
  --violet: #6b46c1;  --violet-soft: #f1ecfd;
  --danger: #c42b1f;  --danger-soft: #fdecea;
  /* Form */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 2px 8px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 16px 40px -12px rgba(16, 24, 40, 0.22), 0 4px 12px rgba(16, 24, 40, 0.06);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  /* Typo */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs: 14.5px;
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --fs-2xl: 28px;
  --fs-3xl: clamp(32px, 5vw, 52px);
  /* Layout */
  --topbar-h: 56px;
  --sidebar-w: 248px;
  --content-max: 1120px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1015;
    --surface: #141920;
    --surface-2: #1a2029;
    --surface-3: #222a35;
    --border: #252c37;
    --border-strong: #354050;
    --text: #e9edf2;
    --text-muted: #a3acb8;
    --text-faint: #6f7987;
    --ink: #e9edf2;
    --ink-hover: #ffffff;
    --ink-text: #0d1015;
    --accent: #ef4b3e;
    --accent-hover: #ff6155;
    --accent-soft: #3a1a18;
    --ok: #4cc585;      --ok-soft: #13291e;
    --warn: #eaa640;    --warn-soft: #33260f;
    --info: #74a0ff;    --info-soft: #172440;
    --violet: #ad8cf6;  --violet-soft: #251d3d;
    --danger: #ff6e62;  --danger-soft: #3b1917;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 10px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 18px 44px -12px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1015;
  --surface: #141920;
  --surface-2: #1a2029;
  --surface-3: #222a35;
  --border: #252c37;
  --border-strong: #354050;
  --text: #e9edf2;
  --text-muted: #a3acb8;
  --text-faint: #6f7987;
  --ink: #e9edf2;
  --ink-hover: #ffffff;
  --ink-text: #0d1015;
  --accent: #ef4b3e;
  --accent-hover: #ff6155;
  --accent-soft: #3a1a18;
  --ok: #4cc585;      --ok-soft: #13291e;
  --warn: #eaa640;    --warn-soft: #33260f;
  --info: #74a0ff;    --info-soft: #172440;
  --violet: #ad8cf6;  --violet-soft: #251d3d;
  --danger: #ff6e62;  --danger-soft: #3b1917;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 10px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 18px 44px -12px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.015em; font-weight: 650; }
h1 { font-size: var(--fs-2xl); letter-spacing: -0.025em; }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { margin: 0 0 10px; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button, input, textarea, select { font: inherit; color: inherit; }
img, svg { display: block; }
.icon { display: inline-block; flex: none; vertical-align: -0.2em; }
[hidden] { display: none !important; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num, .tabular { font-variant-numeric: tabular-nums; }

/* ---------- Helpers ---------- */
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: var(--fs-sm); }
.tiny { font-size: var(--fs-xs); }
.strong { font-weight: 600; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.m0 { margin: 0; }
.eyebrow { font-size: 11.5px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.02em; font-size: 16px; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand img, .brand .logo { width: 28px; height: 28px; border-radius: 8px; }
.brand-sub { font-weight: 500; color: var(--text-faint); font-size: var(--fs-sm); letter-spacing: 0; padding-left: 10px; border-left: 1px solid var(--border); }
/* Legacy mark (old markup) – now the logo */
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: url("/logo.svg") center / cover no-repeat; color: transparent; font-size: 0; flex: none; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h); padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}

/* ---------- App shell (Sidebar + Content) ---------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px; padding: 16px 12px;
  background: var(--surface); border-right: 1px solid var(--border);
}
.sidebar .brand { padding: 4px 8px 14px; }
.nav-section { margin-top: 12px; padding: 0 10px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: var(--radius-sm); border: none; background: none;
  color: var(--text-muted); font-size: var(--fs); font-weight: 500; text-align: left; cursor: pointer; text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active, .nav-item[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
.nav-item.active .icon, .nav-item[aria-current="page"] .icon { color: var(--accent); }
.nav-item .count { margin-left: auto; font-size: 11.5px; font-weight: 650; background: var(--surface-3); color: var(--text-muted); padding: 0 7px; border-radius: 99px; line-height: 18px; }
.nav-item .count.hot { background: var(--accent); color: #fff; }
.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.main { min-width: 0; }
.content { max-width: var(--content-max); margin: 0 auto; padding: 28px 28px 64px; }
.page-header { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-header h1 { font-size: var(--fs-xl); }
.page-header .sub { color: var(--text-muted); font-size: var(--fs-sm); margin-top: 4px; }
/* Mobile bottom navigation */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: none; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.bottom-nav .nav-item { flex-direction: column; gap: 3px; font-size: 11.5px; padding: 6px 4px; justify-content: center; text-align: center; }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .bottom-nav { display: grid; }
  .content { padding: 20px 16px calc(84px + env(safe-area-inset-bottom)); }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 13.5px; letter-spacing: -0.005em; cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.06s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"] { position: relative; color: transparent !important; }
.btn[aria-busy="true"]::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--text-faint) var(--text-faint) transparent transparent; animation: spin 0.7s linear infinite; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(213, 43, 30, 0.25); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
.btn-dark:hover { background: var(--ink-hover); border-color: var(--ink-hover); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: var(--ok); filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; gap: 6px; }
.btn-lg { min-height: 46px; padding: 0 20px; font-size: 15px; border-radius: var(--radius); }
.btn-block { width: 100%; }
.icon-btn { width: 36px; padding: 0; }
.btn-sm.icon-btn { width: 30px; }

/* ---------- Forms ---------- */
.input, .textarea, .select {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  outline: none; box-shadow: var(--shadow-xs);
  transition: border-color 0.12s, box-shadow 0.12s;
}
/* iOS zoomt beim Antippen in jedes Feld unter 16px – auf Touch-Geräten daher mindestens 16px. */
@media (pointer: coarse), (max-width: 860px) {
  body :is(.input, .textarea, .select, .composer-input, input, textarea, select) { font-size: 16px; }
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: var(--ring); }
.input:disabled { background: var(--surface-2); color: var(--text-muted); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a929d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.label { display: block; font-size: var(--fs-sm); font-weight: 600; margin: 0 0 6px; color: var(--text); }
.hint, .help { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 5px; }
.field { margin-bottom: 16px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: var(--fs); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; }
/* Switch: <label class="switch"><input type="checkbox"><span></span> Text</label> */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch > input + span { width: 34px; height: 20px; border-radius: 99px; background: var(--surface-3); position: relative; transition: background 0.15s; flex: none; }
.switch > input + span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-xs); transition: transform 0.15s var(--ease); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { box-shadow: var(--ring); }

/* Segmented control */
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.segmented button { border: none; background: none; padding: 5px 12px; border-radius: 7px; font-size: var(--fs-sm); font-weight: 550; color: var(--text-muted); cursor: pointer; }
.segmented button.on, .segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 10px 12px; border: none; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--text-muted); font-weight: 550; font-size: var(--fs); cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active, .tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { font-size: var(--fs-md); }
.card-body { padding: 18px; }
.card-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.section-title { font-size: 11.5px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin: 22px 0 10px; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: var(--fs-sm); }
.callout.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.callout.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.callout.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.callout .icon { margin-top: 1px; }

/* Stat / KPI */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(180px, calc(50% - 6px)), 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-xs); }
.stat .stat-label { font-size: var(--fs-sm); color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.stat .stat-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .stat-meta { font-size: var(--fs-xs); color: var(--text-faint); margin-top: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.table th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-faint); padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background 0.1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr[data-task], .table tbody tr.clickable { cursor: pointer; }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Badges, pills, chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 99px;
  font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 18px;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.s-draft { color: var(--text-muted); }
.badge.s-searching { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.s-assigned, .badge.s-in_progress { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.s-submitted { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.badge.s-completed { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.s-cancelled { color: var(--text-faint); }
.badge.s-failed { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.s-searching::before { animation: pulse 1.4s ease-in-out infinite; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; line-height: 18px; background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.err, .pill.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill.org, .pill.violet { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; color: var(--text);
  transition: border-color 0.12s, background 0.12s;
}
.chip:hover { border-color: var(--border-strong); background: var(--surface-2); }
.chip.active, .chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--ink-text); }
.ref { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border); padding: 0 6px; border-radius: 6px; line-height: 18px; }
.kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; color: var(--text-muted); }

/* Service icon tile */
.svc-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.svc-icon.sm { width: 28px; height: 28px; border-radius: 8px; }
.svc-icon.lg { width: 44px; height: 44px; border-radius: 12px; }
.svc-icon.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* Avatar */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-muted); font-weight: 650; font-size: 12.5px; letter-spacing: 0.02em; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.ai { background: url("/logo.svg") center / cover; color: transparent; font-size: 0; }

/* ---------- Progress ---------- */
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width 0.3s var(--ease); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 24px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline li.t-question::before { border-color: var(--warn); }
.timeline li.t-answer::before, .timeline li.t-completed::before { border-color: var(--ok); background: var(--ok); }
.timeline li.t-assigned::before, .timeline li.t-update::before, .timeline li.t-started::before { border-color: var(--info); }
.timeline li.t-nudge::before, .timeline li.t-escalated::before, .timeline li.t-escalation::before, .timeline li.t-delayed::before { border-color: var(--accent); }
.timeline li.t-internal { opacity: 0.7; }
.timeline .t-meta { font-size: var(--fs-xs); color: var(--text-faint); margin-top: 2px; }
.timeline .t-body { font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Overlays ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(10, 14, 20, 0.42); backdrop-filter: blur(2px); z-index: 40; animation: fade 0.15s; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 41;
  background: var(--bg); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: slidein 0.22s var(--ease);
}
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; }
.modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 41;
  width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 22px;
  animation: pop 0.16s var(--ease);
}
.modal.wide, .modal.modal-wide { width: min(680px, calc(100vw - 32px)); }
.modal h3 { margin: 0 0 6px; font-size: var(--fs-lg); }
.modal .dialog-actions, .modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  display: block; background: var(--ink); color: var(--ink-text); padding: 11px 14px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: var(--fs-sm); cursor: pointer; animation: toastin 0.2s var(--ease);
}
.toast strong { display: block; margin-bottom: 2px; font-weight: 650; }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- Empty, loading ---------- */
.empty { text-align: center; color: var(--text-muted); padding: 40px 16px; }
.empty .big, .empty .empty-icon { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 12px; background: var(--surface-2); color: var(--text-faint); font-size: 22px; }
.empty .empty-title { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin 0.7s linear infinite; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px; }
.skeleton.line { height: 12px; margin: 8px 0; }
.dots { display: inline-flex; gap: 4px; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); animation: bounce 1.2s infinite; }
.dots span:nth-child(2) { animation-delay: 0.15s; }
.dots span:nth-child(3) { animation-delay: 0.3s; }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); flex: none; }
.dot-live.off { background: var(--text-faint); box-shadow: none; }

/* ---------- Key/value, markdown ---------- */
.kv { margin: 0; display: grid; grid-template-columns: minmax(120px, 36%) 1fr; gap: 8px 14px; font-size: var(--fs-sm); }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.md { overflow-wrap: anywhere; }
.md a { word-break: break-word; }
.md p { margin: 0 0 8px; }
.md p:last-child { margin-bottom: 0; }
.md ul { margin: 4px 0 8px; padding-left: 20px; }
.md li { margin: 2px 0; }
.md code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); padding: 0 5px; border-radius: 5px; }
.md blockquote { margin: 6px 0; padding: 6px 12px; border-left: 3px solid var(--border-strong); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.md .md-table { overflow-x: auto; margin: 6px 0 10px; }
.md table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.md th, .md td { border: 1px solid var(--border); padding: 5px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); font-weight: 600; }
.stars { color: #e5a100; letter-spacing: 1px; }

/* ---------- Motion ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -48%) scale(0.98); } }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }
@keyframes slidein { from { transform: translateX(28px); opacity: 0; } }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

@media (max-width: 900px) {
  .btn-sm { min-height: 36px; }
  .btn-sm.icon-btn { width: 36px; }
  .chip { min-height: 36px; }
  .segmented button { min-height: 32px; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .topbar { padding: 0 14px; }
  .toasts { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .modal { padding: 18px; }
}

/* Icon-Platzhalter aus hydrateIcons() */
.icon-slot { display: inline-flex; align-items: center; justify-content: center; flex: none; line-height: 0; }
