/* Infinity @ Feicht – gleiches Design wie Trading @ Feicht und die Weboberfläche des Mailservers.
   Dunkles Design als Standard, helles über data-theme="light" (Umschalter in der Seitenleiste). */
[hidden], .hidden { display: none !important; }

:root {
  color-scheme: dark;
  --bg: #070b1d;
  --bg-glow-1: rgba(124, 92, 255, .20);
  --bg-glow-2: rgba(46, 140, 255, .14);
  --surface: rgba(18, 25, 54, .72);
  --surface-solid: #11183a;
  --surface-2: rgba(30, 40, 82, .55);
  --surface-hover: rgba(124, 92, 255, .10);
  --border: rgba(130, 150, 255, .16);
  --border-strong: rgba(130, 150, 255, .30);
  --text: #e9edff;
  --muted: #8d98c3;
  --accent: #8b6dff;
  --accent-2: #3b8bff;
  --accent-3: #22d3ee;
  --accent-text: #ffffff;
  --gradient: linear-gradient(135deg, #8b6dff 0%, #3b8bff 100%);
  --good: #34d399; --good-bg: rgba(52, 211, 153, .12);
  --bad: #fb7185; --bad-bg: rgba(251, 113, 133, .12);
  --warn: #fbbf24; --warn-bg: rgba(251, 191, 36, .12);
  --nav: rgba(8, 12, 34, .82);
  --nav-text: #c9d1f5;
  --shadow: 0 12px 40px rgba(0, 0, 0, .35);
  --grid: rgba(130, 150, 255, .10);
  --input: rgba(9, 14, 36, .75);
  --radius: 16px;
  /* Chartfarben (lightweight-charts liest sie aus) */
  --candle-up: #34d399; --candle-down: #fb7185; --line-entry: #3b8bff; --line-sl: #fb7185; --line-tp: #34d399;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5fc;
  --bg-glow-1: rgba(124, 92, 255, .12);
  --bg-glow-2: rgba(46, 140, 255, .10);
  --surface: rgba(255, 255, 255, .86);
  --surface-solid: #ffffff;
  --surface-2: #f1f3fb;
  --surface-hover: rgba(109, 74, 255, .07);
  --border: #e1e5f3;
  --border-strong: #cdd3ea;
  --text: #161b36;
  --muted: #5f6789;
  --accent: #6d4aff;
  --accent-2: #2f6fed;
  --accent-3: #0891b2;
  --gradient: linear-gradient(135deg, #7c5cff 0%, #2f80ed 100%);
  --good: #059669; --good-bg: #e6f7f0;
  --bad: #e11d48; --bad-bg: #fde8ee;
  --warn: #b45309; --warn-bg: #fdf3e1;
  --nav: rgba(255, 255, 255, .88);
  --nav-text: #39406a;
  --shadow: 0 10px 30px rgba(30, 40, 90, .08);
  --grid: #e7eaf5;
  --input: #ffffff;
  --candle-up: #059669; --candle-down: #e11d48; --line-entry: #2f6fed; --line-sl: #e11d48; --line-tp: #059669;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  font: 15px/1.55 "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 600px at 12% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, var(--bg-glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); text-decoration: underline; }
::selection { background: rgba(139, 109, 255, .35); }
.icon { width: 18px; height: 18px; flex: none; vertical-align: -3px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
h1 { font-size: 26px; margin: 4px 0 18px; letter-spacing: -.02em; font-weight: 700; }
h2 { font-size: 17px; margin: 0 0 12px; letter-spacing: -.01em; font-weight: 650; }
h3 { font-size: 14px; margin: 18px 0 10px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pos { color: var(--good); } .neg { color: var(--bad); }
.error { color: var(--bad); min-height: 1em; margin: 6px 0; font-size: 14px; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }

/* ---------- Layout und Navigation (wie Mailserver) ---------- */
.shell { min-height: 100vh; }
.sidebar { background: var(--nav); color: var(--nav-text); border-right: 1px solid var(--border);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 18px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 22px 0 18px; font-weight: 700; font-size: 18px;
  letter-spacing: -.01em; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); text-decoration: none; }
.brand .logo { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: var(--gradient); color: #fff; box-shadow: 0 6px 20px rgba(124, 92, 255, .45); }
.brand .logo .icon { width: 20px; height: 20px; }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: .02em; }
.nav-toggle { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.burger { display: none; cursor: pointer; padding: 7px 11px; border: 1px solid var(--border-strong); border-radius: 10px;
  font-size: 18px; line-height: 1; user-select: none; color: var(--text); }
.burger::before { content: "☰"; }
.nav-toggle:checked + .sidebar-top .burger::before { content: "✕"; }
.menu { display: flex; flex-direction: column; }
.sidebar nav { display: flex; flex-direction: column; gap: 3px; padding: 6px 12px; }
.sidebar nav button {
  font: inherit; color: var(--nav-text); background: none; text-align: left; cursor: pointer; padding: 9px 12px;
  border-radius: 11px; display: flex; align-items: center; gap: 12px; border: 1px solid transparent; font-size: 14.5px;
  transition: background .15s, color .15s, border-color .15s; box-shadow: none;
}
.sidebar nav button .icon { opacity: .85; }
.sidebar nav button:hover { background: var(--surface-hover); color: var(--text); }
.sidebar nav button.active { color: var(--text); font-weight: 600;
  background: linear-gradient(90deg, rgba(139, 109, 255, .30), rgba(59, 139, 255, .12));
  border-color: rgba(139, 109, 255, .45); box-shadow: 0 6px 22px rgba(99, 72, 255, .22); }
:root[data-theme="light"] .sidebar nav button.active { background: linear-gradient(90deg, rgba(109, 74, 255, .14), rgba(47, 111, 237, .06)); }
.sidebar nav button.active .icon { color: var(--accent); opacity: 1; }
.sidebar nav .count { margin-left: auto; font-weight: 700; font-size: 12px; background: var(--gradient); color: #fff;
  border-radius: 999px; padding: 0 8px; font-variant-numeric: tabular-nums; }
.sidebar nav .count:empty { display: none; }
.who { display: flex; flex-direction: column; gap: 10px; font-size: 13px; padding: 14px 16px 18px; margin: 10px 12px 0;
  border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.who .account { display: flex; align-items: center; gap: 10px; color: var(--text); }
.who .account small { display: block; font-size: 11.5px; }
.who .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.who button { font: inherit; background: var(--surface-2); color: var(--nav-text); border: 1px solid var(--border); border-radius: 11px;
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; font-weight: 550;
  padding: 7px 8px; cursor: pointer; white-space: nowrap; }
.who button:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-hover); }
.who .icon { width: 15px; height: 15px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 13px; font-weight: 700;
  color: #fff; flex: none; letter-spacing: .02em; }
.av0 { background: linear-gradient(135deg, #8b6dff, #3b8bff); } .av1 { background: linear-gradient(135deg, #22d3ee, #3b8bff); }
.av2 { background: linear-gradient(135deg, #fb7185, #8b6dff); } .av3 { background: linear-gradient(135deg, #34d399, #22d3ee); }
.av4 { background: linear-gradient(135deg, #fbbf24, #fb7185); } .av5 { background: linear-gradient(135deg, #3b8bff, #34d399); }

@media (min-width: 901px) {
  .shell.signed-in { display: grid; grid-template-columns: 252px minmax(0, 1fr); }
  .shell.signed-in .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
  .shell.signed-in .menu { flex: 1; justify-content: space-between; }
}
@media (max-width: 900px) {
  /* Installierte App auf dem Handy: Abstand zu Notch und Statusleiste */
  .sidebar { position: sticky; top: 0; z-index: 10; border-right: 0; border-bottom: 1px solid var(--border);
    padding-top: env(safe-area-inset-top); }
  .sidebar-top { padding: 0 14px; }
  .brand { padding: 10px 0; font-size: 16px; }
  .brand .logo { width: 32px; height: 32px; }
  .burger { display: block; }
  .menu { display: none; max-height: calc(100vh - 54px); overflow-y: auto; border-top: 1px solid var(--border); }
  .nav-toggle:checked ~ .menu { display: flex; }
}

main.content { width: 100%; max-width: 1320px; margin: 0 auto; min-width: 0;
  padding: 22px max(28px, env(safe-area-inset-right)) calc(56px + env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left)); }
@media (max-width: 760px) { main.content { padding: 16px max(14px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); } }
.view > * { min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.page-head .subtitle { color: var(--muted); margin: 4px 0 0; font-size: 14px; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 760px) { .page-head h1 { font-size: 22px; } .page-head .subtitle { font-size: 13px; } }

/* Statuszeile oben: Modus, Überwachung, Guthaben */
.statusbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 20px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13px; backdrop-filter: blur(12px); white-space: nowrap; }
.chip b { font-weight: 650; font-variant-numeric: tabular-nums; }
.chip .k { color: var(--muted); }
.balance { display: contents; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
.status #engineText { color: var(--muted); }

/* ---------- Flächen ---------- */
.card, .login, .table-wrap.boxed {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.card { padding: 18px 20px; }
.view.narrow { max-width: 760px; }
.view.narrow > .card, #viewAdmin > .card { margin-bottom: 18px; }
.page { display: flex; flex-direction: column; gap: 18px; }
.layout { display: grid; grid-template-columns: 410px minmax(0, 1fr); gap: 18px; align-items: start; }
.layout > * { min-width: 0; }
@media (max-width: 1100px) { .layout { grid-template-columns: minmax(0, 1fr); } }

/* Kennzahlen-Kacheln (wie Mailserver-Übersicht) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpis:empty { display: none; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 13px 15px 11px; min-width: 0;
  box-shadow: var(--shadow); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.kpi .label { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 8px; }
.kpi .value { font-size: 23px; font-weight: 700; letter-spacing: -.02em; line-height: 1.3; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .foot { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.warn { border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.kpi.bad { border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 10px 11px 8px; } .kpi .value { font-size: 19px; } .kpi .label { font-size: 11.5px; }
}

/* ---------- Formulare ---------- */
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input, select, textarea {
  font: inherit; font-size: 15px; color: var(--text); background: var(--input); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 8px 11px; width: 100%; 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 rgba(139, 109, 255, .22); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); padding: 0; }
.row { display: flex; gap: 10px; align-items: flex-start; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.pct { width: 110px; }
.align-end { align-self: center; margin-top: 8px; white-space: nowrap; }
.field-title { font-size: 12px; color: var(--muted); margin: 6px 0; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.break { flex-basis: 100%; height: 0; }
label.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; margin: 0; padding: 3px 0; }
label.inline input { width: auto; }

/* Buttons wie beim Mailserver: .btn = sekundär, .primary = Verlauf, .danger = rot */
.btn {
  font: inherit; font-size: 14px; font-weight: 550; cursor: pointer; border-radius: 11px; padding: 8px 15px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  transition: transform .12s, box-shadow .15s, filter .15s, border-color .15s, background .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); background: var(--surface-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--gradient); color: var(--accent-text); border-color: transparent; font-weight: 600;
  box-shadow: 0 6px 18px rgba(99, 72, 255, .30); }
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 8px 24px rgba(99, 72, 255, .40); }
.btn.danger { background: linear-gradient(135deg, #f43f5e, #e11d48); color: #fff; border-color: transparent; font-weight: 600;
  box-shadow: 0 6px 18px rgba(225, 29, 72, .28); }
.btn.danger:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 11px; font-size: 13px; border-radius: 9px; }
.btn.wide { width: 100%; padding: 12px; font-size: 15px; }
.btn .icon { width: 16px; height: 16px; }

/* Segment-Schalter (Long/Short, Einstieg, Zeiträume) */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 2px; margin-bottom: 12px; }
.seg button { font: inherit; background: none; color: var(--muted); border: 0; padding: 6px 13px; cursor: pointer; font-size: 13.5px;
  border-radius: 8px; font-weight: 550; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--gradient); color: #fff; box-shadow: 0 4px 14px rgba(99, 72, 255, .30); }
.seg button.long.active { background: linear-gradient(135deg, #34d399, #10b981); box-shadow: 0 4px 14px rgba(16, 185, 129, .30); }
.seg button.short.active { background: linear-gradient(135deg, #fb7185, #e11d48); box-shadow: 0 4px 14px rgba(225, 29, 72, .30); }
.seg.small button { padding: 4px 10px; font-size: 12.5px; }
#sideSeg { margin-top: 20px; }

.quick { font-size: 12.5px; color: var(--muted); margin: -4px 0 12px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.quick button { font: inherit; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 3px 9px; cursor: pointer; }
.quick button:hover { border-color: var(--accent); }

.ticker { background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 8px 11px; font-size: 12.5px;
  margin: -2px 0 12px; display: flex; gap: 6px 14px; flex-wrap: wrap; color: var(--muted); }
.ticker b { color: var(--text); font-weight: 600; }
.preview { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font-size: 13px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; margin: 6px 0 4px; }
.preview:empty { display: none; }
.preview div { display: flex; justify-content: space-between; gap: 8px; }
.preview span { color: var(--muted); }
@media (max-width: 420px) { .preview { grid-template-columns: 1fr; } }

/* Pills (Status, Richtung, Rolle) */
.pill, .tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  white-space: nowrap; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }
.tag.long, .tag.open.good, .pill.good { background: var(--good-bg); color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.tag.short, .tag.error, .tag.inactive, .pill.bad { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.tag.pending, .tag.closing, .pill.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.tag.open { background: color-mix(in srgb, var(--accent-2) 14%, transparent); color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 35%, transparent); }
.tag.admin { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.pill.live { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); cursor: pointer; letter-spacing: .04em; }
.pill.paper { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); cursor: pointer; letter-spacing: .04em; }

/* Reiter (Aktiv, Historie …) */
.tabs { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px;
  margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { font: inherit; background: none; border: 0; color: var(--muted); padding: 7px 13px; cursor: pointer; font-size: 14px;
  border-radius: 9px; white-space: nowrap; flex-shrink: 0; font-weight: 550; display: inline-flex; align-items: center; gap: 6px; }
.tabs button:hover { color: var(--text); }
.tabs button.active { background: var(--surface-solid); color: var(--text); box-shadow: 0 2px 10px rgba(0, 0, 0, .18); }
:root[data-theme="light"] .tabs button.active { box-shadow: 0 2px 8px rgba(30, 40, 90, .10); }
.count { background: var(--gradient); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.count:empty { display: none; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
th { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
td { font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:hover { background: var(--surface-hover); }
tbody tr.norow { cursor: default; }
tbody tr.sel { background: var(--surface-hover); box-shadow: inset 3px 0 0 var(--accent); }
tr:last-child td { border-bottom: 0; }
.bar { position: relative; width: 110px; height: 6px; border-radius: 999px; background: linear-gradient(90deg, var(--bad), var(--surface-2) 50%, var(--good)); }
.bar i { position: absolute; top: -3px; width: 3px; height: 12px; background: var(--text); border-radius: 2px; }
.empty { color: var(--muted); padding: 30px; text-align: center; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px; padding: 11px 13px; }
.stat > span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.stat b { font-size: 20px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.checks { list-style: none; padding: 10px 12px; margin: 0 0 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; font-size: 13.5px; }
.checks li { padding: 3px 0; }
#pushDevices li { display: block; position: relative; padding-right: 90px; }
#pushDevices li button { position: absolute; right: 0; top: 2px; }

.events { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.events li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; gap: 12px; }
.events li:last-child { border-bottom: 0; }
.events time { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.events .warning { color: var(--warn); } .events .error, .events .critical { color: var(--bad); } .events .success { color: var(--good); }
@media (max-width: 600px) { .events li { flex-direction: column; gap: 2px; } }

.invite-box { background: var(--surface-2); border: 1px solid var(--accent); border-radius: 12px; padding: 12px; margin-top: 8px; }
.invite-box p { margin: 0 0 8px; }
.adopt-row { margin: 12px 0 4px; gap: 8px; flex-wrap: wrap; }

/* ---------- Charts ---------- */
.chart-card { padding: 16px 18px; }
.chart-head { display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; margin-bottom: 10px; }
.chart-head h2 { margin: 0; }
.chart-head .seg { margin: 0; }
.legend { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 2px; margin-left: 6px; border-radius: 2px; }
.l-entry { background: var(--line-entry); } .l-sl { background: var(--line-sl); } .l-tp { background: var(--line-tp); }
.chart { height: 340px; }
.form-chart { height: 320px; }
#viewNew .form-chart { height: 520px; }
#viewNew .chart-card { position: sticky; top: 20px; }
.lines-toggle.warn { border-color: var(--warn); color: var(--warn); }
.attribution { font-size: 11px; color: var(--muted); text-align: right; margin: 4px 0 12px; }
.attribution a { color: var(--muted); }
@media (max-width: 1100px) { #viewNew .chart-card { position: static; } #viewNew .form-chart { height: 340px; } }
@media (max-width: 600px) {
  .chart-head .legend { display: none; }
  .form-chart, #viewNew .form-chart { height: 280px; }
  .chart { height: 300px; }
}

/* ---------- Detailansicht (Seitenpanel) ---------- */
.drawer { position: fixed; inset: 0; background: rgba(4, 6, 20, .55); z-index: 40; display: flex; justify-content: flex-end;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.drawer-inner { width: min(920px, 100%); height: 100%; overflow-y: auto; overflow-x: hidden; border-radius: 0;
  background: var(--surface-solid); border: 0; border-left: 1px solid var(--border); box-shadow: var(--shadow);
  padding: calc(env(safe-area-inset-top, 0px) + 20px) max(22px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom, 0px) + 28px) 22px; }
:root:not([data-theme="light"]) .drawer-inner { background: linear-gradient(180deg, #121a3f, #0b1130); }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.drawer-head h2 { margin: 4px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; line-height: 1.3; font-size: 19px; }
.close-btn { width: 40px; height: 40px; padding: 0; flex-shrink: 0; font-size: 16px; }
.chart-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 12px; row-gap: 10px; }
.chart-tools .seg { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.actions label { margin: 0; width: 150px; }
.actions label.inline-field { width: auto; }
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 18px; font-size: 13.5px; }
.metrics div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--border); padding: 6px 0; gap: 8px; }
.metrics span { color: var(--muted); }
.metrics b { text-align: right; min-width: 0; overflow-wrap: anywhere; font-weight: 600; font-variant-numeric: tabular-nums; }
.metrics .full { grid-column: 1 / -1; }
.metrics code { font-size: 12px; word-break: break-all; }
@media (max-width: 600px) {
  .drawer-inner { padding-left: 14px; padding-right: 14px; border-left: 0; }
  .drawer-head h2 { font-size: 17px; }
  .chart-tools { justify-content: space-between; margin-bottom: 14px; }
  .chart-tools .lines-toggle, .chart-tools .seg { flex: 1 1 100%; }
  .chart-tools .seg { display: flex; } .chart-tools .seg button { flex: 1; }
  .metrics { grid-template-columns: 1fr; gap: 0; }
  .actions label { width: calc(50% - 4px); }
  .actions .grow { display: none; }
  .actions #eClose { width: 100%; }
}

/* ---------- Anmeldung, Dialoge, Hinweise ---------- */
.overlay { position: fixed; inset: 0; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 16px; }
.login { width: 100%; max-width: 420px; margin: 9vh auto 40px; padding: 30px 30px 26px; }
.login .brand { padding: 0 0 18px; justify-content: center; }
.login h1 { text-align: center; font-size: 22px; margin-bottom: 18px; }
.login label { margin-bottom: 14px; }
.login input { padding: 10px 12px; }
.login .btn { width: 100%; padding: 11px; margin-top: 4px; }
dialog { border: 0; padding: 0; background: transparent; color: var(--text); max-width: 480px; width: calc(100% - 24px); }
dialog::backdrop { background: rgba(4, 6, 20, .6); backdrop-filter: blur(3px); }
dialog .card { background: var(--surface-solid); }
dialog .preview { margin-bottom: 14px; }
#adoptDlg, #userDlg { max-width: 560px; }
.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); right: 20px; z-index: 60; background: var(--surface-solid);
  border: 1px solid var(--border-strong); padding: 12px 16px; border-radius: 13px; max-width: min(420px, calc(100% - 40px));
  box-shadow: var(--shadow); font-size: 14px; }
.toast.err { border-color: var(--bad); color: var(--bad); } .toast.ok { border-color: color-mix(in srgb, var(--good) 60%, transparent); }
.toast.clickable { cursor: pointer; border-color: var(--accent); }
.stale { opacity: .6; transition: opacity .3s; }

/* Ziehen zum Aktualisieren (installierte App) */
.ptr { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 8px); left: 50%; z-index: 100; width: 40px; height: 40px; margin-left: -20px;
  border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border-strong); display: flex; align-items: center;
  justify-content: center; color: var(--muted); font-size: 20px; transform: translateY(-70px); transition: transform .2s; pointer-events: none; }
.ptr.ready { color: #fff; background: var(--accent); border-color: var(--accent); }
.ptr.spin span { display: inline-block; animation: ptrspin .8s linear infinite; }
@keyframes ptrspin { to { transform: rotate(360deg); } }
@media (display-mode: standalone) { body { overscroll-behavior-y: contain; } }

/* ---------- Handy-Anpassungen einzelner Formulare ---------- */
@media (max-width: 600px) {
  .card { padding: 15px 14px; }
  .pct { width: 96px; }
  table { font-size: 13.5px; }
  th, td { padding: 9px 10px; }
  #newUserForm { display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px; }
  #newUserForm label { width: auto; min-width: 0; }
  #newUserForm .f-user, #newUserForm .f-role, #newUserForm .f-email, #newUserForm .f-submit { grid-column: 1 / -1; }
  #newUserForm .break { display: none; }
  #newUserForm .f-submit { margin-top: 4px; width: 100%; padding: 12px; }
  #inviteBox .row { flex-direction: column; }
  #inviteBox .row .btn { width: 100%; }
  .statusbar { margin-bottom: 14px; }
}

/* ---------- Tabellen: kompakter auf dem Desktop, Karten auf dem Handy ---------- */
td .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
td.pos .sub, td.neg .sub { color: inherit; opacity: .8; }
td .sub.pos { color: var(--good); } td .sub.neg { color: var(--bad); }
.m-only { display: none; }
.row-actions { white-space: normal; }
.row-actions .btn { margin: 2px 2px 2px 0; }
table.users td.row-actions { min-width: 230px; }
.metrics { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
@media (max-width: 760px) {
  table.cards thead { display: none; }
  table.cards, table.cards tbody { display: block; }
  table.cards tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; padding: 12px 13px;
    border: 1px solid var(--border); border-radius: 13px; margin-bottom: 10px; background: var(--surface-2); }
  table.cards tr:hover { background: var(--surface-2); }
  table.cards tr.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: var(--surface-hover); }
  table.cards td { display: flex; flex-direction: column; border: 0; padding: 0; white-space: normal; font-size: 14px; min-width: 0; }
  table.cards td[data-l]::before { content: attr(data-l); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
  table.cards td.d-only, table.cards th.d-only { display: none; }
  table.cards td.m-only { display: flex; }
  table.cards td.c-head { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 15px; }
  table.cards td.c-full { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; gap: 6px; }
  table.cards td.c-full .btn { flex: 1 1 auto; }
  table.cards .bar { width: 100%; margin-top: 8px; }
  table.users td.row-actions { min-width: 0; }
  .table-wrap:has(> table.cards) { overflow: visible; }
  /* Startseite: weniger Lücken, Kacheln ohne Leerplatz */
  .page { gap: 14px; }
  .page .page-head { margin-bottom: 0; }
  .kpis .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
/* Feinschliff Tabellen */
table.cards td > .tag, table.cards td > .pill { align-self: flex-start; }
@media (min-width: 761px) {
  table.cards th, table.cards td { padding: 9px 9px; }
  table.cards .bar { width: 72px; }
}
.pills { display: inline-flex; gap: 4px; flex-wrap: wrap; }

/* Detailansicht: Titelzeile bleibt beim Scrollen oben stehen (mit Abstand zur Statusleiste) */
.drawer-inner { padding-top: 0; }
.drawer-head { position: sticky; top: 0; z-index: 5; margin: 0 -22px 14px; padding: calc(env(safe-area-inset-top, 0px) + 16px) 22px 12px;
  background: var(--surface-solid); border-bottom: 1px solid var(--border); }
:root:not([data-theme="light"]) .drawer-head { background: #121a3f; }
@media (max-width: 600px) { .drawer-head { margin: 0 -14px 14px; padding-left: 14px; padding-right: 14px; } }

/* Hinweise (wie Mailserver) */
.notice { padding: 12px 16px; border-radius: 14px; margin-bottom: 18px; border: 1px solid; backdrop-filter: blur(12px); font-size: 14px; }
.notice.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.notice.bad { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.warn-text { color: var(--warn); }
:root { --ema50: #a78bfa; --ema200: #22d3ee; --line-liq: #fbbf24; }
:root[data-theme="light"] { --ema50: #7c3aed; --ema200: #0891b2; --line-liq: #b45309; }
.l-ema50 { background: var(--ema50); } .l-ema200 { background: var(--ema200); }
.fee-table { width: 100%; font-size: 13.5px; margin-top: 8px; }
.fee-table td, .fee-table th { padding: 6px 8px; white-space: nowrap; }

/* ---------- Markt-Seite (Panels wie Mailserver-Übersicht) ---------- */
.dash { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 14px; }
.dash .card { margin: 0; min-width: 0; }
.dash .wide { grid-column: span 2; }
@media (max-width: 1200px) { .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .dash { grid-template-columns: minmax(0, 1fr); } .dash .wide { grid-column: auto; } }
.panel-head { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 16px; }
.badge-icon { width: 34px; height: 34px; border-radius: 11px; display: inline-grid; place-items: center; color: #fff; flex: none;
  background: var(--gradient); box-shadow: 0 6px 18px rgba(99, 72, 255, .35); }
.badge-icon.cyan { background: linear-gradient(135deg, #22d3ee, #3b8bff); }
.badge-icon.rose { background: linear-gradient(135deg, #fb7185, #8b6dff); }
.badge-icon.green { background: linear-gradient(135deg, #34d399, #22d3ee); }
.badge-icon.amber { background: linear-gradient(135deg, #fbbf24, #fb7185); }
.big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13.5px; margin-top: 10px; }
.kv span { color: var(--muted); } .kv b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.gauge { height: 10px; border-radius: 999px; margin: 12px 0 4px; position: relative;
  background: linear-gradient(90deg, #fb7185, #fbbf24 50%, #34d399); }
.gauge i { position: absolute; top: -4px; width: 4px; height: 18px; border-radius: 2px; background: var(--text); box-shadow: 0 0 0 2px var(--surface-solid); }
.gauge-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.spark { width: 100%; height: 46px; margin-top: 10px; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; }
.track { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.track > i { display: block; height: 100%; border-radius: 999px; background: var(--gradient); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.events-list { list-style: none; margin: 0; padding: 0; }
.events-list li { display: grid; grid-template-columns: 118px 1fr auto; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; align-items: center; }
.events-list li:last-child { border-bottom: 0; }
.events-list li.soon { color: var(--warn); }
.events-list time { color: var(--muted); font-variant-numeric: tabular-nums; }
.events-list li.soon time { color: var(--warn); }
@media (max-width: 600px) { .events-list li { grid-template-columns: 1fr auto; } .events-list time { grid-column: 1 / -1; } }
.inline-field { flex-direction: row; align-items: center; gap: 8px; margin: 0; flex-shrink: 0; white-space: nowrap; }
.inline-field input { flex: 0 0 160px; width: 160px; min-width: 0; }
/* Kontextzeile unter „Neue Position“ */
.ctx { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 12px; cursor: pointer; }
.ctx:empty { display: none; }
.ctx .pill { font-weight: 550; }
/* Auswertung (Statistik) */
.eq-chart { height: 260px; margin: 12px 0 6px; }
.sub-h { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; margin: 20px 0 8px; }

/* Combobox (Handelspaar) */
.combo { position: relative; width: 100%; }
.combo input { padding-right: 36px; }
.combo-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: grid; place-items: center;
  width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; box-shadow: none; }
.combo-btn svg { transition: transform .15s; }
.combo.open .combo-btn svg { transform: rotate(180deg); }
.combo-list { position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; min-width: 100%; width: max-content; max-width: min(380px, calc(100vw - 32px));
  max-height: min(340px, 50vh); overflow-y: auto; overscroll-behavior: contain; margin: 0; padding: 6px; list-style: none;
  background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow); }
.combo-right .combo-list { left: auto; right: 0; }
.combo-list li[data-v] { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; color: var(--text); font-size: 14px; }
.combo-list li[data-v]:hover, .combo-list li.active { background: var(--surface-hover); }
.combo-list li[aria-selected="true"] { box-shadow: inset 3px 0 0 var(--accent); }
.combo-name b { font-weight: 650; }
.combo-meta { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.combo-head { padding: 8px 10px 4px; font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.combo-empty { padding: 10px; color: var(--muted); font-size: 14px; }
@media (max-width: 760px) { .combo-list li[data-v] { padding: 11px 10px; } }
.inline-field .combo { flex: 0 0 190px; width: 190px; }
.inline-field .combo input { flex: none; width: 100%; }

/* Kraken-Konto: Richtung/Quelle stehen auf dem Handy im Kartenkopf */
.m-inline { display: none; }
@media (max-width: 760px) { table.cards .m-inline { display: inline-flex; gap: 6px; margin-left: auto; } }

/* Positions-Check und KI-Einschätzung */
.check-box:empty { display: none; }
.check-box { margin: 12px 0; display: grid; gap: 10px; }
#dCheck h3 { margin: 6px 0 0; }
.ck-head { font-size: 13px; }
.ck-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ck { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; line-height: 1.45; padding: 8px 10px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); }
.ck-ico { flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; margin-top: 1px; }
.ck.bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.ck.bad .ck-ico { background: var(--bad); color: #fff; }
.ck.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.ck.warn .ck-ico { background: var(--warn); color: #1b1300; }
.ck.ok .ck-ico { background: var(--good); color: #04130c; }
.ai-ask { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ai-ask input { flex: 1 1 220px; min-width: 0; }
.ai-btn { background: var(--gradient); color: var(--accent-text); border: 0; white-space: nowrap; }
.ai-btn:disabled { opacity: .55; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-review { border: 1px solid var(--border-strong); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); font-size: 14px; line-height: 1.5; }
.ai-review p { margin: 6px 0; }
.ai-review .sub-h { margin: 10px 0 4px; }
.ai-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ai-head .muted { margin-left: auto; }
.ai-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.ai-review.good { border-color: color-mix(in srgb, var(--good) 45%, transparent); } .ai-review.good .ai-dot { background: var(--good); }
.ai-review.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); } .ai-review.warn .ai-dot { background: var(--warn); }
.ai-review.bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); } .ai-review.bad .ai-dot { background: var(--bad); }
.ai-list { margin: 0; padding-left: 18px; display: grid; gap: 5px; }
.ai-list .tag { font-size: 11px; padding: 0 7px; vertical-align: 1px; }
.tag.bad { background: var(--bad-bg); color: var(--bad); } .tag.warn { background: var(--warn-bg); color: var(--warn); }

/* ============================================================ Infinity @ Feicht */
.statusbar .btn .icon { width: 16px; height: 16px; }
.search-box { position: relative; flex: 1 1 340px; max-width: 620px; display: flex; align-items: center; }
.search-box > .icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 38px; margin: 0; border-radius: 12px; }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30; max-height: min(70vh, 560px); overflow-y: auto;
  background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; }
.search-results h4 { margin: 8px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.search-results button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 8px 10px;
  border-radius: 10px; cursor: pointer; font: inherit; }
.search-results button:hover, .search-results button.active { background: var(--surface-hover); }
.search-results .sr-sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
mark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
@media (max-width: 760px) { .search-box { flex-basis: 100%; max-width: none; order: -1; } }

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain > li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--border); min-width: 0; }
.list-plain > li:last-child { border-bottom: 0; }
.list-plain .grow { min-width: 0; }
.list-plain .t-title { font-weight: 600; overflow-wrap: anywhere; }
.list-plain .t-sub { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.list-plain .clickable { cursor: pointer; }
.list-plain .clickable:hover .t-title { color: var(--accent); }
.when { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.when b { display: block; font-size: 15px; }
.when small { color: var(--muted); font-size: 11.5px; }
.type-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--c, var(--accent)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, var(--accent)) 22%, transparent); }
.type-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); white-space: nowrap; }
.done-item { opacity: .55; } .done-item .t-title { text-decoration: line-through; }
.empty-small { color: var(--muted); font-size: 13.5px; padding: 8px 0; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }

/* Kalender */
.cal-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 10px; }
.cal-toolbar h2 { margin: 0; font-size: 18px; text-transform: capitalize; }
.cal-toolbar .row { margin: 0; gap: 6px; }
.cal-toolbar .seg { margin: 0; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.cal-grid .dow { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px; text-align: center;
  background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-day { min-height: 104px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: pointer;
  display: flex; flex-direction: column; gap: 3px; min-width: 0; background: transparent; transition: background .15s; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:hover { background: var(--surface-hover); }
.cal-day.other { opacity: .45; }
.cal-day.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day .num { font-size: 12.5px; font-weight: 600; color: var(--muted); align-self: flex-end; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-day.today .num { background: var(--gradient); color: #fff; }
.cal-ev { font-size: 11.5px; line-height: 1.25; padding: 2px 6px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--c) 18%, transparent); border-left: 3px solid var(--c); color: var(--text); }
.cal-ev.done { opacity: .5; text-decoration: line-through; }
.cal-more { font-size: 11px; color: var(--muted); padding-left: 4px; }
.cal-dots { display: none; gap: 3px; flex-wrap: wrap; justify-content: center; }
.cal-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
@media (max-width: 760px) {
  .cal-day { min-height: 54px; padding: 4px 2px; align-items: center; }
  .cal-day .num { align-self: center; }
  .cal-day .cal-ev, .cal-day .cal-more { display: none; }
  .cal-dots { display: flex; }
}
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.week-col { border: 1px solid var(--border); border-radius: 12px; padding: 8px; min-height: 160px; cursor: pointer; min-width: 0; }
.week-col.today { border-color: var(--accent); }
.week-col h4 { margin: 0 0 8px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.week-col .cal-ev { white-space: normal; margin-bottom: 5px; padding: 4px 6px; cursor: pointer; }
@media (max-width: 900px) { .week-grid { grid-template-columns: 1fr; } .week-col { min-height: 0; } }
.agenda-day { margin: 14px 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: capitalize; }
.agenda-day:first-child { margin-top: 0; }

/* Termintypen und Erinnerungen im Dialog */
.type-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.type-picker button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); border-radius: 999px; padding: 6px 11px; font: inherit; font-size: 13px; cursor: pointer; }
.type-picker button.active { border-color: var(--c); background: color-mix(in srgb, var(--c) 18%, transparent); box-shadow: 0 0 0 1px var(--c) inset; }
.chips-select { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.chips-select button { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 999px; padding: 5px 11px;
  font: inherit; font-size: 12.5px; cursor: pointer; }
.chips-select button.active { background: var(--gradient); color: #fff; border-color: transparent; }
#apptDlg, #contactDlg, #uploadDlg { max-width: 600px; }
dialog.wide-dlg { max-width: 860px; }
dialog form.card { max-height: calc(100dvh - 24px); overflow-y: auto; }
#apptForm.allday .ap-time { display: none; }

/* Kontakte */
.filter-row label { margin-bottom: 0; }
.filter-row { margin-bottom: 14px; align-items: flex-end; }
.stage { --c: var(--accent-2); }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 10px; min-height: 120px; }
.board-col.drop { border-color: var(--accent); background: var(--surface-hover); }
.board-col h4 { margin: 2px 4px 10px; font-size: 13px; display: flex; justify-content: space-between; }
.board-card { background: var(--surface-solid); border: 1px solid var(--border); border-radius: 11px; padding: 9px 10px; margin-bottom: 8px; cursor: pointer; }
.board-card:hover { border-color: var(--accent); }
.board-card b { display: block; font-size: 14px; }
.board-card small { color: var(--muted); }
.overdue { color: var(--bad); font-weight: 600; }
.due-today { color: var(--warn); font-weight: 600; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.timeline li.system::before { background: var(--muted); }
.timeline li:last-child { border-left-color: transparent; }
.timeline .t-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.timeline .t-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.note-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.note-form textarea { flex: 1 1 260px; margin: 0; }
.note-form select { width: auto; margin: 0; }

/* Wissensdatenbank */
.kb-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.kb-cats { position: sticky; top: 16px; }
.kb-cats-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.kb-cats-head h2 { margin: 0; }
#kbCatList { list-style: none; margin: 0; padding: 0; }
#kbCatList li { display: flex; align-items: center; gap: 4px; }
#kbCatList button.cat { flex: 1; display: flex; justify-content: space-between; gap: 8px; text-align: left; background: none; border: 0; color: var(--nav-text);
  font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 10px; cursor: pointer; min-width: 0; }
#kbCatList button.cat span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#kbCatList button.cat:hover { background: var(--surface-hover); }
#kbCatList button.cat.active { background: var(--surface-hover); color: var(--text); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
#kbCatList .edit { opacity: .5; padding: 4px 6px; }
#kbCatList .edit:hover { opacity: 1; }
.kb-main > .card { margin-bottom: 16px; }
.search-inline { position: relative; display: flex; align-items: center; }
.search-inline .icon { position: absolute; left: 12px; color: var(--muted); }
.search-inline input { padding-left: 38px; margin: 0; }
.kb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.kb-card { border: 1px solid var(--border); border-radius: 14px; padding: 13px 14px; background: var(--surface-2); cursor: pointer; min-width: 0;
  display: flex; flex-direction: column; gap: 6px; transition: border-color .15s, transform .15s; }
.kb-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.kb-card h3 { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.kb-card p { margin: 0; font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.kb-card .meta { font-size: 11.5px; color: var(--muted); margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.doc-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; font-size: 10.5px; font-weight: 700;
  color: #fff; background: var(--gradient); text-transform: uppercase; letter-spacing: .02em; }
.doc-icon.pdf { background: linear-gradient(135deg, #fb7185, #e11d48); }
.doc-icon.img { background: linear-gradient(135deg, #34d399, #22d3ee); }
.doc-icon.office { background: linear-gradient(135deg, #3b8bff, #8b6dff); }
.doc-icon.media { background: linear-gradient(135deg, #fbbf24, #fb7185); }
.section-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; }
.section-h h2 { margin: 0; }
.article { line-height: 1.65; font-size: 15px; overflow-wrap: anywhere; }
.article h1, .article h2, .article h3 { margin: 1.2em 0 .4em; line-height: 1.3; }
.article h1 { font-size: 22px; } .article h2 { font-size: 18px; } .article h3 { font-size: 16px; }
.article p { margin: 0 0 .9em; }
.article ul, .article ol { margin: 0 0 .9em; padding-left: 1.4em; }
.article blockquote { margin: 0 0 .9em; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 10px 10px 0; }
.article hr { border: 0; border-top: 1px solid var(--border); margin: 1.4em 0; }
.preview-frame { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.preview-img { max-width: 100%; border-radius: 12px; border: 1px solid var(--border); }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 22px; border: 2px dashed var(--border-strong);
  border-radius: 14px; cursor: pointer; color: var(--muted); }
.dropzone.drag, .dropzone:hover { border-color: var(--accent); color: var(--text); background: var(--surface-hover); }
.dropzone input { display: none; }
.dropzone .icon { width: 28px; height: 28px; }
@media (max-width: 900px) {
  .kb-layout { grid-template-columns: minmax(0, 1fr); }
  .kb-cats { position: static; }
  #kbCatList { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
  #kbCatList li { flex: none; }
  #kbCatList button.cat { border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; }
  #kbCatList button.cat.active { box-shadow: none; border-color: var(--accent); }
}

/* Dashboard */
.pipe { display: flex; flex-direction: column; gap: 7px; }
.pipe-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 34px; gap: 10px; align-items: center; font-size: 13px; cursor: pointer; }
.pipe-row .track { height: 8px; }
.pipe-row b { text-align: right; font-variant-numeric: tabular-nums; }
.kpi.click { cursor: pointer; } .kpi.click:hover { border-color: var(--accent); }
#kpis { margin-bottom: 16px; }
.kb-card h3 { text-transform: none; letter-spacing: -.01em; color: var(--text); font-weight: 650; }
@media (max-width: 760px) { #calLegend { display: none; } .statusbar .btn { flex: 1; justify-content: center; } }
