*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; font-family: var(--font); color: var(--text); background: var(--bg);
    font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 6px; font-weight: 700; }
h2 { font-size: 18px; letter-spacing: -.01em; margin: 28px 0 12px; font-weight: 650; }
h3 { font-size: 15px; margin: 0 0 8px; font-weight: 650; }
p { margin: 0 0 12px; }
small, .muted { color: var(--text-2); }
code, pre { font-family: var(--font-mono); font-size: 13px; }
pre { background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--radius-input); padding: 12px 14px; overflow: auto; margin: 0 0 12px; white-space: pre-wrap; word-break: break-all; }
code { background: var(--accent-soft); padding: 1px 5px; border-radius: 5px; }
pre code { background: none; padding: 0; }
hr { border: 0; border-top: 1px solid var(--hairline); margin: 20px 0; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; }

/* ---------- Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-width); flex: 0 0 var(--sidebar-width); background: var(--surface);
    border-right: 1px solid var(--hairline); display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; padding: 20px 14px;
}
.main { flex: 1; min-width: 0; padding: 32px 40px 60px; max-width: 1180px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .sub { color: var(--text-2); margin: 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: inherit; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-avatar {
    width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--accent-text);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex: 0 0 auto;
}
.brand-logo { max-height: 36px; max-width: 120px; border-radius: 6px; }
.login-card .brand-logo, .admin .brand-logo { border-radius: 0; }
.brand-name { font-weight: 650; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); padding: 16px 12px 6px; font-weight: 600; }
.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--text);
    font-weight: 500; transition: background .15s var(--ease);
}
.nav-item:hover { background: var(--accent-soft); text-decoration: none; }
.nav-item.is-active { background: var(--accent); color: var(--accent-text); }
.nav-item .icon { color: inherit; opacity: .85; }
.nav-badge { margin-left: auto; background: var(--info); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: var(--radius-pill); }
.nav-item.is-active .nav-badge { background: rgba(255,255,255,.25); }
.sidebar-footer { border-top: 1px solid var(--hairline); padding-top: 10px; margin-top: 10px; }
.sidebar-user { font-size: 12px; color: var(--text-3); padding: 8px 12px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.impersonation-bar {
    position: sticky; top: 0; z-index: 20; background: var(--warning); color: #fff; padding: 8px 16px; font-size: 14px; text-align: center;
}
.impersonation-bar a { color: #fff; text-decoration: underline; margin-left: 10px; }

/* Eingeklappte Seitenleiste (nur Desktop): nur Icons, Zustand in localStorage */
.sidebar-toggle { width: 100%; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; color: var(--text-3); }
.sidebar-toggle .icon { transition: transform .2s var(--ease); }
.sidebar { transition: width .2s var(--ease), flex-basis .2s var(--ease); }
@media (min-width: 861px) {
    body.sidebar-collapsed .sidebar { width: 68px; flex-basis: 68px; padding-left: 10px; padding-right: 10px; }
    body.sidebar-collapsed .brand-name, body.sidebar-collapsed .nav-item span, body.sidebar-collapsed .nav-section,
    body.sidebar-collapsed .sidebar-user, body.sidebar-collapsed .brand-logo { display: none; }
    body.sidebar-collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }
    body.sidebar-collapsed .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }
    body.sidebar-collapsed .nav-badge { position: absolute; top: 4px; right: 4px; margin: 0; }
    body.sidebar-collapsed .nav-item { position: relative; }
    body.sidebar-collapsed .sidebar-toggle .icon { transform: rotate(180deg); }
}
@media (max-width: 860px) { .sidebar-toggle { display: none; } }

/* ---------- Cards, grids */
.card {
    background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow-card);
    border: 1px solid var(--hairline); padding: 20px 22px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card.is-link { transition: transform .2s var(--ease), box-shadow .2s var(--ease); display: block; color: inherit; }
.card.is-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); text-decoration: none; }
.card.is-link:active { transform: scale(.995); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border-radius: var(--radius-card); border: 1px solid var(--hairline); box-shadow: var(--shadow-card); padding: 16px 18px; }
.stat .label { font-size: 12px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.stat .hint { font-size: 12px; color: var(--text-3); }
.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty .icon { width: 36px; height: 36px; color: var(--text-3); margin-bottom: 8px; }

/* ---------- Buttons, badges, pills */
.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: var(--radius-pill);
    font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; border: 1px solid transparent; line-height: 1.2;
    transition: background .15s var(--ease), transform .1s var(--ease); white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--accent); border-color: var(--hairline-strong); }
.btn-secondary:hover { background: var(--accent-soft); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--accent-soft); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn .icon { width: 16px; height: 16px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-blue { background: var(--info-soft); color: var(--info); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-orange { background: var(--warning-soft); color: var(--warning); }
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-gray { background: var(--gray-soft); color: var(--gray); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { padding: 6px 14px; border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--hairline-strong); font-size: 13px; font-weight: 600; color: var(--text-2); }
.pill:hover { text-decoration: none; background: var(--accent-soft); }
.pill.is-active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: 0 0 auto; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.stars { color: var(--stars); letter-spacing: 1px; font-size: 14px; }
.stat.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.pill-btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.pill-btn .icon { width: 14px; height: 14px; }
.pill-btn.has-filter, .pill-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }
.pill-count { background: var(--accent); color: var(--accent-text); font-size: 11px; padding: 0 6px; border-radius: var(--radius-pill); line-height: 16px; }
[hidden] { display: none !important; }
.pill-group { display: inline-flex; align-items: center; }
/* Löschen-Knopf gespeicherter Filter nur, wenn die Filterdetails offen sind */
.pills .pill-x { display: none; }
.pills.filter-open .pill-x { display: inline-block; }
.pills .filter-save { display: none !important; }
.pills.filter-open .filter-save { display: inline-flex !important; }
.pills:not(.filter-open) .pill-group .pill { border-top-right-radius: var(--radius-pill); border-bottom-right-radius: var(--radius-pill); border-right: 1px solid var(--hairline-strong); }
.pill-group .pill { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: 0; }
.pill-x { font: inherit; font-size: 14px; line-height: 1; padding: 6px 9px; border-radius: 0 var(--radius-pill) var(--radius-pill) 0; border: 1px solid var(--hairline-strong); background: var(--surface); color: var(--text-3); cursor: pointer; }
.pill-x:hover { color: var(--danger); background: var(--danger-soft); }
.filter-card { padding: 12px 16px; }
/* Schnellfilter als Dropdown-Chips in der Filterleiste */
.chip-dd { position: relative; display: inline-flex; align-items: center; }
.chip-dd-btn { font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.chip-caret { font-size: 10px; opacity: .6; }
.chip-clear { margin-left: -6px; padding: 0 8px; font-size: 15px; color: var(--text-3); text-decoration: none; }
.chip-clear:hover { color: var(--danger); text-decoration: none; }
.chip-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 240px; max-width: 320px; background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px; box-shadow: var(--shadow-hover); padding: 6px; }
.chip-menu-title { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: 6px 10px 4px; }
.chip-item { display: flex; justify-content: space-between; gap: 12px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; font: inherit; font-size: 14px; color: var(--text); background: none; border: 0; text-decoration: none; cursor: pointer; }
.chip-item:hover { background: var(--accent-soft); text-decoration: none; }
.chip-item.is-active { background: var(--accent); color: var(--accent-text); }
.chip-item.is-active .muted { color: rgba(255,255,255,.75); }
.chip-item .muted { font-variant-numeric: tabular-nums; }
.chip-more { color: var(--accent); font-size: 13px; }
.pill-count-soft { opacity: .6; font-weight: 500; margin-left: 2px; }
.pill.is-active .pill-count-soft { opacity: .8; }
@media (max-width: 860px) {
    /* Als Sheet über der Tab-Leiste. Das JS hängt das Menü beim Öffnen an <body>, weil iOS Safari
       position:fixed innerhalb eines scrollenden Containers (.pills-scroll) abschneidet. */
    .chip-menu { position: fixed; left: 12px !important; right: 12px !important; bottom: calc(88px + env(safe-area-inset-bottom)); top: auto; z-index: 60; max-width: none; max-height: 60vh; overflow: auto; border-radius: 16px; }
    .chip-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .25); }
    .chip-item { padding: 12px 12px; }
}
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.filter-row:last-child { margin-bottom: 0; }
.condition { padding-left: 10px; border-left: 2px solid var(--accent-soft); }

/* ---------- Forms */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin: 12px 0 5px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; }
label.check input { width: auto; margin: 0; }
input[type=text], input[type=email], input[type=url], input[type=number], input[type=password], input[type=date], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--hairline-strong); border-radius: var(--radius-input);
    font: inherit; background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 100px; resize: vertical; }
.form-actions { margin-top: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
form.inline { display: inline; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.help { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 12px; }

/* ---------- Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tr.is-link { cursor: pointer; transition: background .12s; }
tr.is-link:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
th.is-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.is-sortable:hover { color: var(--text); }
th.is-sortable::after { content: "↕"; opacity: .35; margin-left: 4px; font-size: 10px; }
th[aria-sort="descending"]::after { content: "↓"; opacity: 1; color: var(--accent); }
th[aria-sort="ascending"]::after { content: "↑"; opacity: 1; color: var(--accent); }
th[aria-sort] { color: var(--accent); }
.bar { height: 6px; background: var(--accent-soft); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* ---------- Ladebalken beim Seitenwechsel */
body.is-loading::before { content: ""; position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--accent); z-index: 200; animation: fp-loading 2.5s ease-out forwards; }
@keyframes fp-loading { 0% { width: 0; } 30% { width: 45%; } 70% { width: 80%; } 100% { width: 94%; } }
body.is-loading .pills .pill.is-active, body.is-loading .tabs a.is-active { opacity: .7; }

/* ---------- Flash */
.flash { padding: 12px 16px; border-radius: var(--radius-input); margin-bottom: 16px; font-weight: 500; }
.flash-success { background: var(--success-soft); color: var(--success); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-info { background: var(--info-soft); color: var(--info); }

/* ---------- Snippets */
.snippet { position: relative; }
.snippet pre { padding-right: 90px; margin: 0; }
.snippet .btn-copy { position: absolute; top: 8px; right: 8px; }

/* ---------- Chart */
.chart { width: 100%; height: 220px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- Modal / Sheet (mobile first: von unten, ab 560px zentriert) */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.42); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); z-index: 100; display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .2s var(--ease); }
.modal-backdrop.is-open { opacity: 1; }
.modal { background: var(--surface); border-radius: 20px 20px 0 0; width: 100%; max-height: 88vh; overflow: auto; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); transform: translateY(24px); transition: transform .25s var(--ease); box-shadow: var(--shadow-hover); }
.modal-backdrop.is-open .modal { transform: none; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-head h3 { margin: 4px 0 6px; font-size: 17px; word-break: break-all; }
.modal-close { border: 0; background: var(--accent-soft); color: var(--text); width: 32px; height: 32px; border-radius: 50%; font-size: 18px; cursor: pointer; flex: 0 0 auto; }
.modal-rows { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; font-size: 14px; }
.modal-rows dt { color: var(--text-2); margin: 0; }
.modal-rows dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
/* URL/Pfad im Sheet-Titel: wirkt wie ein Wert, ist aber ein Link (dezenter Chip mit Pfeil) */
.modal-url { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 13px; color: var(--accent); text-decoration: none; word-break: break-all; }
.modal-url svg { width: 14px; height: 14px; flex: 0 0 auto; }
.modal-url span { border-bottom: 1px dotted currentColor; }
.modal-url:hover span { border-bottom-style: solid; }
.modal-section { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin: 16px 0 6px; }
.modal-delta { display: block; font-weight: 500; font-size: 11px; color: var(--text-3); }
.modal-delta.good { color: var(--success); }
.modal-delta.bad { color: var(--danger); }
.modal-hint { margin: 14px 0 0; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-input); font-size: 13px; color: var(--text-2); }
.modal-links { display: flex; flex-direction: column; gap: 2px; }
.modal-links a { display: flex; align-items: center; justify-content: space-between; padding: 13px 12px; border-radius: 10px; color: var(--text); font-weight: 500; font-size: 15px; }
.modal-links a:hover { background: var(--accent-soft); text-decoration: none; }
.modal-links a.is-active { background: var(--accent); color: var(--accent-text); }
@media (min-width: 560px) {
    .modal-backdrop { align-items: center; padding: 24px; }
    .modal { border-radius: 20px; max-width: 460px; padding: 24px; transform: scale(.96); }
}
@media (prefers-reduced-motion: reduce) { .modal, .modal-backdrop { transition: none; } }

/* ---------- Quellen-/Kanal-Icons */
.src { display: inline-flex; align-items: center; gap: 10px; }
.src-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 8px; font-size: 13px; font-weight: 700; flex: 0 0 auto; letter-spacing: -.02em; }
.src-icon[data-len="2"] { font-size: 11px; }
.src-icon svg { width: 16px; height: 16px; }
.src-icon-channel { background: var(--accent-soft); color: var(--accent); }
.src-icon-flag { background: var(--surface-2); font-size: 18px; border: 1px solid var(--hairline); }
.src-icon-channel.is-paid { background: var(--warning-soft); color: var(--warning); }

/* ---------- Seiten-Grafik */
.page-chart svg { width: 100%; height: auto; display: block; }
.page-chart circle { transition: opacity .15s; cursor: pointer; outline: none; }
.page-chart circle:focus-visible { stroke: var(--accent); stroke-width: 3; }
.page-chart circle:hover { opacity: 1; }

/* ---------- Funnel + Tabs in Karten */
.tabs.tabs-inline { border-bottom: 0; margin: 0; gap: 2px; overflow: visible; flex-wrap: wrap; }
.tabs.tabs-inline a { padding: 6px 12px; border-radius: var(--radius-pill); border-bottom: 0; margin: 0; font-size: 13px; }
.tabs.tabs-inline a.is-active { background: var(--accent); color: var(--accent-text); }
.tabs.tabs-inline a:hover:not(.is-active) { background: var(--accent-soft); color: var(--text); }
.funnel-vis { display: grid; grid-template-columns: minmax(140px, 38%) 1fr; gap: 20px; align-items: start; }
.funnel-vis svg { width: 100%; display: block; }
.funnel-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--hairline); }
.funnel-row:last-child { border-bottom: 0; }
.funnel-name { font-weight: 600; font-size: 14px; }
.funnel-sub { font-size: 12px; color: var(--text-2); }
.funnel-num { font-size: 18px; letter-spacing: -.01em; white-space: nowrap; }
@media (max-width: 560px) { .funnel-vis { grid-template-columns: 1fr; } .funnel-vis svg { height: 120px !important; } }

/* ---------- Lead detail */
/* Beschriftung = Sekundärtext (klein, Versalien, grau), Wert = Primärtext (größer, dunkel, halbfett) */
.lead-fields { margin: 0; }
.lead-fields dt { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 600; margin-top: 12px; }
.lead-fields dd { margin: 3px 0 0; font-size: 15px; font-weight: 500; color: var(--text); white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.status-big { font-size: 14px; padding: 8px 14px; cursor: pointer; border: 0; font-family: inherit; }
.status-dd .chip-menu { min-width: 200px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; }
.status-dot-blue { background: var(--info); } .status-dot-purple { background: var(--purple); } .status-dot-orange { background: var(--warning); } .status-dot-green { background: var(--success); } .status-dot-gray { background: var(--gray); }
.chip-item.is-active .status-dot { background: #fff; }
.lead-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 20px; }
.lead-grid > div { min-width: 0; }
.lead-grid dt { margin-top: 8px; }
@media (max-width: 560px) { .lead-grid { grid-template-columns: 1fr; } }
.status-select { display: flex; gap: 6px; flex-wrap: wrap; }
.status-select button { border: 1px solid var(--hairline-strong); }
.status-select button.is-active { border-color: transparent; }

/* ---------- Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-hover); padding: 32px; }
.login-card .brand { padding: 0 0 20px; }

/* ---------- Prose (Markdown-Seiten) */
.prose { max-width: 760px; }
.prose h1 { margin-top: 0; }
.prose h2 { margin-top: 32px; }
.prose img { max-width: 100%; border-radius: var(--radius-input); }
.prose blockquote { border-left: 3px solid var(--accent); margin: 0 0 12px; padding: 4px 16px; color: var(--text-2); }
.prose ul, .prose ol { padding-left: 24px; margin: 0 0 12px; }
.prose li { margin-bottom: 4px; }

/* ---------- Seiten mit eigenem HTML */
.page-frame { width: 100%; border: 0; display: block; min-height: 320px; background: #fff; border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
body.page-full { background: var(--surface); }
.page-full-bar { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 8px 12px; background: rgba(255,255,255,.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--hairline); font-size: 14px; }
.page-full-bar strong { text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-frame-full { min-height: calc(100vh - 50px); border-radius: 0; box-shadow: none; }
.page-frame-url { height: calc(100vh - 200px); min-height: 480px; }
.page-frame-url.page-frame-full { height: calc(100vh - 50px); }
@media (max-width: 859px) { .page-frame-url { height: calc(100vh - 220px); } }
.page-full-content { padding: 24px 16px; max-width: 900px; margin: 0 auto; }
.page-inline { min-width: 0; }
.prompt-box { font-size: 12px; white-space: pre-wrap; max-height: 260px; }

/* ---------- Admin */
.admin .sidebar .brand-avatar { background: #111; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--hairline); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; font-weight: 600; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
details.card > summary { cursor: pointer; font-weight: 650; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "+"; float: right; color: var(--text-3); }
details.card[open] > summary::after { content: "–"; }
.placeholder-list { font-size: 13px; }
.placeholder-list code { display: inline-block; margin-bottom: 2px; }

/* ---------- Untere Tab-Leiste (nur Mobile) */
.tabbar { display: none; }
@media (max-width: 860px) {
    /* Schwebende Leiste wie in der Apple-Store-App: mit Abstand zum Rand und zum Home-Indikator,
       damit man nicht versehentlich die iOS-Home-Geste auslöst. */
    .tabbar {
        display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30;
        background: rgba(255, 255, 255, .88); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
        border: 1px solid var(--hairline-strong); border-radius: 30px; padding: 4px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, .10), 0 12px 32px rgba(0, 0, 0, .08);
    }
    .tabbar-item {
        flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        height: 52px; border-radius: 26px; color: var(--text-2); font: inherit; font-size: 11px; font-weight: 500; background: none; border: 0;
        text-decoration: none; position: relative; -webkit-tap-highlight-color: transparent;
    }
    .tabbar-item.is-active { background: var(--accent-soft); }
    .tabbar-item:active { background: var(--accent-soft); }
    .tabbar-item .icon { width: 22px; height: 22px; }
    .tabbar-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .tabbar-item.is-active { color: var(--accent); font-weight: 600; }
    .tabbar-item:hover { text-decoration: none; }
    .tabbar-badge { position: absolute; top: 4px; left: calc(50% + 6px); background: var(--info); color: #fff; font-style: normal; font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: var(--radius-pill); line-height: 15px; }
}

/* ---------- Mobile */
@media (max-width: 860px) {
    .layout { flex-direction: column; }
    /* Kopf: nur noch der Kunde, die Navigation liegt unten */
    .sidebar { width: auto; flex: none; height: auto; position: static; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--hairline); flex-direction: row; align-items: center; }
    .brand { padding: 0; }
    .brand-avatar { width: 32px; height: 32px; font-size: 13px; }
    .nav, .sidebar-footer, .nav-section, .sidebar-user { display: none; }
    .main { padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); }
    .pills-scroll { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px; margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
    .pills-scroll::-webkit-scrollbar { display: none; }
    .pills-scroll .pill { flex: 0 0 auto; }
    .card-head .tabs.tabs-inline { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
    .card-head .tabs.tabs-inline::-webkit-scrollbar { display: none; }
    .card-head .tabs.tabs-inline a { flex: 0 0 auto; }
    .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
    h1 { font-size: 22px; }
    .stat .value { font-size: 24px; }
    .snippet pre { padding-right: 14px; padding-top: 40px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Symbolauswahl für Seiten (Admin) */
.icon-pick { position: relative; }
.icon-pick-btn { display: inline-flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px; border: 1px solid var(--hairline-strong); border-radius: var(--radius-input); background: var(--surface); font: inherit; font-size: 14px; color: var(--text); cursor: pointer; text-align: left; }
.icon-pick-btn .icon-pick-cur svg { width: 20px; height: 20px; display: block; }
.icon-pick-btn .icon-pick-label { flex: 1; }
.icon-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; width: min(440px, calc(100vw - 32px)); max-height: 340px; overflow: auto; background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px; box-shadow: var(--shadow-hover); padding: 8px 10px 10px; }
.icon-menu-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin: 8px 2px 4px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; }
.icon-opt { width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--text-2); cursor: pointer; padding: 0; }
.icon-opt svg { width: 20px; height: 20px; }
.icon-opt:hover { background: var(--bg); color: var(--text); }
.icon-opt.is-selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.page-icon svg { width: 16px; height: 16px; vertical-align: -3px; color: var(--text-3); }

/* Push-Karte */
.help.is-ok { color: var(--success); }
.help.is-error { color: var(--danger); }

/* ---------- iOS-nahe Bausteine: Liste statt Tabelle, kompakte Kennzahlen, Auswahlfeld als Pill */
.list-rows { display: none; list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--hairline); min-height: 60px; }
.list-row:active { background: var(--accent-soft); }
.list-row .status-dot { margin: 0; flex: 0 0 auto; }
.list-row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list-row-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row-sub { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row-chevron { color: var(--text-3); font-size: 22px; line-height: 1; flex: 0 0 auto; }
li:last-child > .list-row { border-bottom: 0; }
.stat-grid-status .stat { padding: 14px 16px; }
.stat-grid-status .stat .value { font-size: 24px; }
.stat .label .status-dot { margin-right: 6px; vertical-align: 1px; }
.chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 56vw; }
.pills-scroll > * { flex: 0 0 auto; }
.pill-select { display: inline-flex; align-items: center; gap: 6px; position: relative; padding-right: 12px; }
.pill-select .icon { width: 14px; height: 14px; }
.pill-select > .muted { white-space: nowrap; font-size: 12px; }
.pill-select select { appearance: none; -webkit-appearance: none; border: 0; background: none; font: inherit; font-weight: 600; color: inherit; padding: 0; margin: 0; max-width: 46vw; }
.mobile-only { display: none !important; }
@media (max-width: 860px) {
    .mobile-only { display: inline-flex !important; }
    .desktop-only { display: none !important; }
    .list-rows { display: block; }
    .table-wrap.has-list { display: none; }
    /* Kennzahlen kompakt: drei pro Reihe, halbe Höhe */
    .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .stat-grid-status .stat, .stat { padding: 10px 12px; }
    .stat .label { font-size: 10px; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .stat .value, .stat-grid-status .stat .value { font-size: 20px; margin-top: 0; }
    .stat .hint { font-size: 11px; }
}

/* ---------- Pills: Häkchen, Chip mit ×, Segmented, Sheet-Gruppen, Listen in Karten */
.pills a.pill.is-active::before { content: "✓"; margin-right: 6px; font-size: 11px; }
.chip-dd.has-selected .chip-dd-btn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.chip-dd.has-selected .chip-clear { margin-left: -1px; padding: 0 10px; align-self: stretch; display: inline-flex; align-items: center; border: 1px solid var(--accent); border-left-color: rgba(255,255,255,.35); background: var(--accent); color: #fff; border-radius: 0 var(--radius-pill) var(--radius-pill) 0; font-size: 15px; line-height: 1; }
.chip-dd.has-selected .chip-clear:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.list-row.is-link { cursor: pointer; }
/* Hierarchie: Icon links auf eigener Spalte, Titel dunkel, Nebenzeile hellgrau, Hauptwert rechts groß mit kleiner Beschriftung */
.list-row-lead { flex: 0 0 auto; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; }
.list-row-lead .src-icon { width: 34px; height: 34px; border-radius: 10px; font-size: 14px; }
.list-row-lead .src-icon svg { width: 18px; height: 18px; }
.list-row-lead .src-icon-flag { font-size: 20px; }
.list-row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; flex: 0 0 auto; min-width: 56px; }
.list-row-value { font-size: 16px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.list-row-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.list-rows-flush .list-row { padding: 11px 0; gap: 12px; min-height: 58px; }
.list-rows-flush .list-row-title { font-size: 15px; font-weight: 600; color: var(--text); }
.list-rows-flush .list-row-sub { font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.list-rows-flush .list-row-sub .badge { font-size: 10px; padding: 1px 7px; vertical-align: 1px; margin-right: 2px; }
.list-rows-flush .list-row-chevron { margin-left: -4px; font-size: 20px; }
.sheet-section { margin: 14px 0 0; }
.sheet-section h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: 0 0 4px; font-weight: 600; }
.sheet-group { border-bottom: 1px solid var(--hairline); }
.sheet-group summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 0; font-weight: 600; font-size: 15px; cursor: pointer; }
.sheet-group summary::-webkit-details-marker { display: none; }
.sheet-group summary .muted { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-group[open] summary .muted span { display: inline-block; transform: rotate(90deg); }
.sheet-group .chip-item { padding: 11px 12px; }
.sheet-group .chip-item:last-child { margin-bottom: 8px; }
.sheet-row { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--hairline); }
.sheet-row .chip-item { flex: 1 1 auto; padding: 13px 0; border-radius: 0; }
.sheet-row .pill-x { border-radius: var(--radius-pill); }
.modal .filter-card { box-shadow: none; border: 0; padding: 0; margin: 0; }
.modal .filter-save { display: flex !important; gap: 6px; margin: 12px 0 0; }
.modal .filter-save input[type=text] { flex: 1 1 auto; width: auto !important; }
.tabs-select { margin-left: auto; }
@media (max-width: 860px) {
    /* Tippziele ≥ 40 pt, größere Schrift */
    .pill, .pill-btn, .chip-dd-btn { padding: 9px 14px; font-size: 14px; min-height: 40px; }
    .pills { gap: 8px; }
    .chip-dd.has-selected .chip-clear { font-size: 17px; padding: 0 12px; }
    .tabs.tabs-inline a { padding: 9px 12px; font-size: 14px; }
    /* Wischbare Reihen: Verlauf am rechten Rand, solange rechts noch etwas kommt */
    .pills-scroll.has-more { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); }
    /* Segmented Control: alle Optionen sichtbar, gleich breit */
    .tabs.tabs-inline.segmented, .pills.segmented { display: flex; flex-wrap: nowrap; overflow: visible; width: 100%; margin: 0; padding: 3px; gap: 2px; background: var(--accent-soft); border-radius: 11px; -webkit-mask-image: none; mask-image: none; }
    .tabs.tabs-inline.segmented a, .pills.segmented .pill { flex: 1 1 0; min-width: 0; text-align: center; justify-content: center; padding: 8px 6px; min-height: 36px; border: 0; border-radius: 8px; background: none; color: var(--text-2); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .tabs.tabs-inline.segmented a.is-active, .pills.segmented .pill.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }
    .pills.segmented a.pill.is-active::before { content: none; }
    .card-head .tabs.segmented, .card-head .tabs-select { flex: 1 1 100%; margin-left: 0; }
    /* Karten-Kopf mit Reiter/Auswahlfeld: halber Abstand zum Inhalt darunter */
    .card-head:has(.tabs-select), .card-head:has(.segmented) { margin-bottom: 0; row-gap: 6px; }
    .goal-picker-mobile { margin: -2px 0 6px; }
    /* Anfragen: Reihe = Filter, Alle, Schnellfilter-Chips; gespeicherte Filter (außer dem aktiven) nur im Sheet */
    #filter-pills .pill-group:not(.is-active-group), #filter-pills .filter-save { display: none !important; }
    .mobile-only > .pill-select, .pill-select.mobile-only { width: 100%; }
    .pill-select select { flex: 1 1 auto; max-width: none; min-width: 0; }
    .filter-sheet .modal { max-height: 90vh; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
}


/* Statusverwaltung (Einstellungen → Anfragen) */
.status-table input[type=text] { min-width: 140px; }
.status-table td { vertical-align: middle; }
.status-table .status-dot { margin-right: 6px; }


/* ---------- Anfrage-Detail (mobile first): Kopf → Status-Chips → Kontakt → Notizen → Felder */
.lead-back-btn { min-height: 40px; padding: 0 16px 0 12px; font-weight: 600; flex: 0 0 auto; }
.lead-back-btn .icon { width: 18px; height: 18px; }
.lead-status-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; padding: 8px 14px; }
.lead-status-badge .status-dot { margin: 0; }
.badge-blue .status-dot { background: var(--info); } .badge-purple .status-dot { background: var(--purple); } .badge-orange .status-dot { background: var(--warning); } .badge-green .status-dot { background: var(--success); } .badge-gray .status-dot { background: var(--gray); } .badge-red .status-dot { background: var(--danger); }
.lead-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin: 0 0 12px; }
.lead-head-main { min-width: 0; flex: 1 1 240px; }
.lead-head h1 { margin: 0 0 4px; font-size: 24px; line-height: 1.15; overflow-wrap: anywhere; }
.lead-meta { margin: 0; font-size: 13px; color: var(--text-2); line-height: 1.45; }
.lead-meta-status { color: var(--text-2); }
.status-big { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; padding: 8px 12px 8px 14px; cursor: pointer; border: 0; font-family: inherit; min-height: 36px; }
.status-big .icon { width: 14px; height: 14px; opacity: .7; }
.status-actions { margin: 0 0 20px; align-items: center; }
.status-chip { display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; min-height: 36px; }
.status-chip:disabled { cursor: default; }
.status-chip.is-active .status-dot { background: #fff; }
.status-chip .status-dot { margin: 0; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.detail-grid > .card { margin: 0; }
.detail-grid h3 { margin-bottom: 10px; }
.detail-delete { padding: 4px 0 0; display: flex; gap: 8px; flex-wrap: wrap; }
.detail-delete .btn { color: var(--text-2); }
.detail-delete .btn:hover { color: var(--danger); background: var(--danger-soft); }
/* Kontakt als Liste: Wert führt, Aktion als Nebenzeile, Pfeil rechts – 48 pt Tippfläche */
.contact-rows { list-style: none; margin: 0 -4px; padding: 0; }
.contact-row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 4px; border-radius: 10px; color: var(--text); text-decoration: none; }
.contact-row:hover { background: var(--accent-soft); text-decoration: none; }
.contact-row:active { background: var(--accent-soft); }
.contact-rows li + li .contact-row { border-top: 1px solid var(--hairline); border-radius: 0 0 10px 10px; }
.contact-row-icon { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: var(--accent-text); }
.contact-row-icon .icon { width: 17px; height: 17px; }
.contact-row-secondary .contact-row-icon { background: var(--accent-soft); color: var(--accent); }
.contact-row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.contact-row-value { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.contact-row-hint { font-size: 12px; color: var(--text-2); }
.contact-row-chevron { flex: 0 0 auto; color: var(--text-3); }
.contact-row-chevron .icon { width: 18px; height: 18px; }
/* Felder: zwei Spalten, lange Werte volle Breite; ruhige Zeilen mit Haarlinie */
.detail-fields .lead-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.detail-fields .lead-grid > div { padding: 9px 0 10px; border-bottom: 1px solid var(--hairline); }
.detail-fields .lead-grid > div.is-wide { grid-column: 1 / -1; }
.detail-fields .lead-grid dt { margin-top: 0; color: var(--text-2); }
.detail-fields .lead-grid dd { margin-top: 2px; }
.detail-raw summary { cursor: pointer; font-weight: 600; font-size: 14px; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.detail-raw summary::-webkit-details-marker { display: none; }
.detail-raw summary::after { content: "+"; color: var(--text-3); font-size: 18px; line-height: 1; }
.detail-raw[open] summary::after { content: "–"; }
.detail-raw[open] summary { margin-bottom: 6px; }
@media (min-width: 861px) {
    .lead-head h1 { font-size: 28px; }
    .detail-grid { grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; }
    .detail-grid > * { grid-column: 1; }
    .detail-grid > .detail-notes { grid-column: 2; grid-row: 1; }
    .detail-grid > .detail-delete { grid-column: 2; grid-row: 2; justify-self: start; }
    .status-actions { margin-bottom: 24px; }
}
@media (max-width: 860px) {
    .lead-head { margin-bottom: 10px; }
    .lead-back-btn { min-height: 44px; width: 100%; justify-content: center; order: 2; }
    .status-actions { margin: 0 -16px 16px; padding-left: 16px; padding-right: 16px; }
    .status-chip { min-height: 40px; font-size: 14px; }
    .detail-fields .lead-grid > div.is-wide dd { font-size: 15px; }
}

/* Hinweiskarten auf der Übersicht (App installieren, Mitteilungen) */
.hint-card { position: relative; display: flex; gap: 14px; align-items: flex-start; background: var(--accent-soft); border: 1px solid var(--hairline); box-shadow: none; padding: 16px 44px 16px 16px; margin-bottom: 16px; }
.hint-icon { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: var(--accent-text); display: inline-flex; align-items: center; justify-content: center; }
.hint-icon .icon { width: 20px; height: 20px; }
.hint-body { min-width: 0; flex: 1 1 auto; }
.hint-body h3 { margin: 2px 0 4px; font-size: 16px; }
.hint-body p { margin: 0 0 8px; font-size: 14px; color: var(--text-2); }
.hint-steps { margin: 0 0 10px; padding-left: 20px; font-size: 14px; }
.hint-steps li { margin: 0 0 4px; }
.hint-steps .icon { width: 15px; height: 15px; vertical-align: -3px; }
.hint-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hint-close { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: var(--text-2); font-size: 20px; line-height: 1; cursor: pointer; }
.hint-close:hover { background: var(--surface); color: var(--text); }
