/* Look and feel einer Dynamics-365-App (Fluent 2): dunkle App-Leiste,
   Sitemap-Navigation links, Befehlsleiste, weisse Karten mit leichtem
   Schatten auf grauem Grund, Pivot-Tabs und dichte Grids.

   Farbrollen. Die Portalfarben sind feste Slots je Portal - sie folgen der
   Entitaet, nie dem Rang: eine Umsortierung oder ein anderer Zeitraum faerbt
   niemals um. Slot 1-8 ist die kategoriale Standardreihenfolge, Slot 9 ein
   Cyan, das mit den acht anderen zusammen die Pruefung fuer beide Modi besteht
   (validate_palette.js: hell alle PASS bis auf die Kontrastwarnung, dunkel alle
   PASS). Der Kontrastwarnung wird mit sichtbaren Direktlabels und der
   Tabellenansicht begegnet. --q1..q4 ist eine geordnete Blau-Rampe fuer
   Positionsbereiche (Top 3 am dunkelsten). */
:root {
  color-scheme: light;
  --appbar: #002050;
  --appbar-hover: #0a2f6b;
  --appbar-text: #ffffff;
  --surface-0: #f5f5f5;
  --surface-1: #ffffff;
  --surface-2: #f5f5f5;
  --surface-3: #ebebeb;
  --nav-bg: #fafafa;
  --border:    #e0e0e0;
  --border-subtle: #f0f0f0;
  --border-strong: #c7c7c7;
  --text-primary:   #242424;
  --text-secondary: #424242;
  --text-muted:     #6b6b6b;
  --accent: #0f6cbd;
  --accent-hover: #115ea3;
  --accent-soft: #ebf3fc;
  --accent-text: #0f6cbd;
  --accent-fill: #0f6cbd;
  --good: #107c10;
  --bad:  #c50f1f;
  --warn: #bc4b09;
  --good-soft: #f1faf1;
  --bad-soft:  #fdf3f4;
  --warn-soft: #fff9f5;
  --shadow-2: 0 0 2px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.14);
  --shadow-4: 0 0 2px rgba(0,0,0,.12), 0 2px 4px rgba(0,0,0,.14);
  --shadow-28: 0 0 8px rgba(0,0,0,.12), 0 14px 28px rgba(0,0,0,.14);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4;
  --s6: #008300; --s7: #4a3aa7; --s8: #e34948; --s9: #00a2b8; --s10: #8c6a4f;
  --s11: #3f4b59; --s12: #6b7f00;
  --s13: #b4009e; --s14: #986f0b; --s15: #005b70; --s16: #7a7574;
  --q1: #0c3b5e; --q2: #0f6cbd; --q3: #62abf5; --q4: #c7e0f4;
  --grid: #ebebeb;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --appbar: #0a1a33; --appbar-hover: #15294a; --appbar-text: #ffffff;
    --surface-0: #141414; --surface-1: #242424; --surface-2: #2e2e2e; --surface-3: #383838;
    --nav-bg: #1c1c1c;
    --border: #3a3a3a; --border-subtle: #2f2f2f; --border-strong: #575757;
    --text-primary: #ffffff; --text-secondary: #d6d6d6; --text-muted: #adadad;
    --accent: #479ef5; --accent-hover: #62abf5; --accent-soft: #0e2a47; --accent-text: #62abf5; --accent-fill: #115ea3;
    --good: #54b054; --bad: #f1707b; --warn: #f7a16a;
    --good-soft: #0d2e0d; --bad-soft: #3b0509; --warn-soft: #3b1d07;
    --shadow-2: 0 0 2px rgba(0,0,0,.24), 0 1px 2px rgba(0,0,0,.28);
    --shadow-4: 0 0 2px rgba(0,0,0,.24), 0 2px 4px rgba(0,0,0,.28);
    --shadow-28: 0 0 8px rgba(0,0,0,.24), 0 14px 28px rgba(0,0,0,.28);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
    --s6: #008300; --s7: #9085e9; --s8: #e66767; --s9: #00a2b8; --s10: #b98f73;
    --s11: #9aa7b6; --s12: #a3b52e;
    --s13: #e36fd5; --s14: #d6a84a; --s15: #3fb7cf; --s16: #b3aeac;
    --q1: #b4d6fa; --q2: #62abf5; --q3: #2886de; --q4: #0e4775;
    --grid: #333333;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --appbar: #0a1a33; --appbar-hover: #15294a; --appbar-text: #ffffff;
  --surface-0: #141414; --surface-1: #242424; --surface-2: #2e2e2e; --surface-3: #383838;
  --nav-bg: #1c1c1c;
  --border: #3a3a3a; --border-subtle: #2f2f2f; --border-strong: #575757;
  --text-primary: #ffffff; --text-secondary: #d6d6d6; --text-muted: #adadad;
  --accent: #479ef5; --accent-hover: #62abf5; --accent-soft: #0e2a47; --accent-text: #62abf5; --accent-fill: #115ea3;
  --good: #54b054; --bad: #f1707b; --warn: #f7a16a;
  --good-soft: #0d2e0d; --bad-soft: #3b0509; --warn-soft: #3b1d07;
  --shadow-2: 0 0 2px rgba(0,0,0,.24), 0 1px 2px rgba(0,0,0,.28);
  --shadow-4: 0 0 2px rgba(0,0,0,.24), 0 2px 4px rgba(0,0,0,.28);
  --shadow-28: 0 0 8px rgba(0,0,0,.24), 0 14px 28px rgba(0,0,0,.28);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
  --s6: #008300; --s7: #9085e9; --s8: #e66767; --s9: #00a2b8; --s10: #b98f73;
  --s11: #9aa7b6; --s12: #a3b52e;
  --s13: #e36fd5; --s14: #d6a84a; --s15: #3fb7cf; --s16: #b3aeac;
  --q1: #b4d6fa; --q2: #62abf5; --q3: #2886de; --q4: #0e4775;
  --grid: #333333;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 14px/1.43 "Segoe UI", "Segoe UI Web (West European)", -apple-system, BlinkMacSystemFont, system-ui, Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; line-height: 28px; }
h2 { font-size: 14px; line-height: 20px; }
h3 { font-size: 13px; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { flex: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- App-Leiste ------------------------------------------------------- */
.appbar {
  height: 48px; display: flex; align-items: center; gap: 4px;
  background: var(--appbar); color: var(--appbar-text);
  padding: 0 8px 0 0; position: relative; z-index: 40;
}
.appbar-btn {
  width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; cursor: pointer; color: var(--appbar-text);
}
.appbar-btn:hover { background: var(--appbar-hover); }
.appbar-btn svg, .icon-btn svg, .cmd svg, .nav-item svg, .view-search svg, .appbar-search svg {
  width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round;
}
.appbar-title { display: flex; align-items: center; gap: 12px; padding: 0 8px; white-space: nowrap; }
.app-name { font-weight: 600; font-size: 16px; }
.app-sep { width: 1px; height: 18px; background: rgba(255,255,255,.4); }
.app-area { font-size: 15px; }
.appbar-search {
  flex: 0 1 460px; margin: 0 auto; display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px; border-radius: 4px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18);
}
.appbar-search:focus-within { background: #fff; color: #242424; }
.appbar-search input[type="search"] {
  flex: 1; height: 30px; padding: 0; border-radius: 0; min-width: 0; border: 0; outline: 0; background: transparent; color: inherit; font: inherit; font-size: 14px;
}
.appbar-search input[type="search"]::placeholder { color: rgba(255,255,255,.75); }
.appbar-search:focus-within input[type="search"]::placeholder { color: #707070; }
.appbar-actions { display: flex; align-items: center; margin-left: 8px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; margin-left: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #c7e0f4; color: #002050; font-size: 12px; font-weight: 600;
}

/* ---- Grundgerüst ------------------------------------------------------ */
.shell { display: flex; height: calc(100vh - 48px); }

.sitemap {
  width: 220px; flex: none; display: flex; flex-direction: column;
  background: var(--nav-bg); border-right: 1px solid var(--border);
  transition: width .15s ease;
}
.sitemap-scroll { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-group { padding: 4px 0 8px; }
.nav-label { font-size: 12px; font-weight: 600; color: var(--text-primary); padding: 8px 16px 4px; white-space: nowrap; }
.nav-item, .nav-site {
  position: relative; width: 100%; display: flex; align-items: center; gap: 12px;
  font-size: 14px; color: var(--text-primary); background: transparent; border: 0;
  height: 36px; padding: 0 16px; cursor: pointer; text-align: left; white-space: nowrap;
}
.nav-item span { overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover, .nav-site:hover { background: var(--surface-3); }
.nav-item[aria-current="page"] { background: var(--accent-soft); font-weight: 600; }
.nav-item[aria-current="page"]::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; border-radius: 0 2px 2px 0; background: var(--accent);
}
.nav-item[aria-current="page"] svg { color: var(--accent); }
.nav-site { height: 32px; font-size: 13px; color: var(--text-secondary); gap: 10px; font-variant-numeric: tabular-nums; }
.nav-site .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin: 0 4px; }
.nav-site .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-site .vv { color: var(--text-muted); font-size: 12px; }
.nav-site.active { background: var(--accent-soft); color: var(--text-primary); }

.area-switch {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-top: 1px solid var(--border); min-height: 56px;
}
.area-tile {
  width: 28px; height: 28px; flex: none; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-fill); color: #fff; font-weight: 600; font-size: 13px;
}
.area-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.area-text b { font-size: 13px; }
.area-text small { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* eingeklappt: nur Icons, wie die schmale Sitemap in D365 */
.shell.collapsed .sitemap { width: 48px; }
.shell.collapsed .nav-label,
.shell.collapsed .nav-item span,
.shell.collapsed .nav-site .nm,
.shell.collapsed .nav-site .vv,
.shell.collapsed .area-text { display: none; }
.shell.collapsed .nav-item, .shell.collapsed .nav-site { padding: 0; justify-content: center; }
.shell.collapsed .nav-group + .nav-group { border-top: 1px solid var(--border); }
.shell.collapsed .area-switch { justify-content: center; padding: 10px 0; }

.scrim { display: none; position: fixed; inset: 48px 0 0; background: rgba(0,0,0,.4); z-index: 25; }

.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

/* ---- Befehlsleiste ---------------------------------------------------- */
.commandbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
  margin: 8px 16px 0; padding: 4px; min-height: 44px;
  background: var(--surface-1); border-radius: 8px; box-shadow: var(--shadow-2);
}
.cmd {
  height: 36px; display: inline-flex; align-items: center; gap: 8px; padding: 0 10px;
  background: transparent; border: 0; border-radius: 4px; cursor: pointer; font-size: 14px; color: var(--text-primary);
}
.cmd svg { color: var(--accent); }
.cmd:hover { background: var(--surface-2); }
.cmd:active { background: var(--surface-3); }
.cmd[disabled] { opacity: .5; cursor: default; }
.cmd-sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }
.cmd-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-left: auto; padding-right: 4px; }

.page-header { padding: 16px 24px 4px; }
.crumbs { font-size: 12px; color: var(--text-muted); }
.page-header #page-sub { font-size: 13px; margin: 2px 0 0; }

.content { flex: 1; overflow-y: auto; padding: 12px 16px 48px; }
.page > * + * { margin-top: 16px; }

/* ---- Bedienelemente --------------------------------------------------- */
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 4px; overflow: hidden; }
.seg button {
  border: 0; background: var(--surface-1); color: var(--text-primary);
  font-size: 13px; padding: 0 10px; height: 30px; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button:hover { background: var(--surface-2); }
.seg button[aria-pressed="true"] { background: var(--accent-fill); color: #fff; font-weight: 600; }
.seg.small button { height: 26px; font-size: 12px; padding: 0 8px; }

select, input[type="date"], input[type="search"], input[type="number"] {
  font: inherit; font-size: 13px; color: var(--text-primary); height: 32px;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-bottom-color: var(--text-muted);
  border-radius: 4px; padding: 0 8px;
}
select:focus, input:focus { outline: 0; border-bottom: 2px solid var(--accent); }
.field-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.btn {
  height: 32px; padding: 0 12px; border-radius: 4px; cursor: pointer; font-size: 13px; font-weight: 600;
  background: var(--accent-fill); color: #fff; border: 1px solid var(--accent-fill);
}
.btn:hover { filter: brightness(1.1); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-text); cursor: pointer; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }
.icon-btn {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--text-secondary); border-radius: 4px; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.custom-range { display: none; gap: 6px; align-items: center; font-size: 13px; }
.custom-range.on { display: inline-flex; }

/* ---- Karten ----------------------------------------------------------- */
.card { background: var(--surface-1); border-radius: 8px; box-shadow: var(--shadow-4); padding: 16px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 12px; min-height: 26px; }
.card-sub { font-size: 12px; color: var(--text-muted); }
.spacer { margin-left: auto; }
.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent-text); font-size: 12px; font-weight: 600;
}

.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
.dash-grid.two-col { grid-template-columns: 1fr 1fr; }
.span-2 { min-width: 0; }
@media (max-width: 1100px) { .dash-grid, .dash-grid.two-col { grid-template-columns: 1fr; } }

/* KPI-Leiste: eine Karte, durch Linien geteilt - wie die Kennzahlenkacheln in D365 */
.kpi-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  background: var(--surface-1); border-radius: 8px; box-shadow: var(--shadow-4); overflow: hidden;
}
.kpi { padding: 14px 16px 10px; border-right: 1px solid var(--border-subtle); border-bottom: 1px solid var(--border-subtle); min-width: 0; }
.kpi .label { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .value { font-size: 22px; line-height: 32px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .delta { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: center; }
.kpi .delta > * { white-space: nowrap; }
.kpi .spark { margin-top: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 2px; height: 20px; padding: 0 6px; border-radius: 4px;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; background: var(--surface-2); color: var(--text-secondary);
}
.pill.up { background: var(--good-soft); color: var(--good); }
.pill.down { background: var(--bad-soft); color: var(--bad); }
.up { color: var(--good); } .down { color: var(--bad); }

/* ---- Erkenntnisse ----------------------------------------------------- */
.insights { list-style: none; margin: 0 -4px; padding: 0 4px; max-height: 360px; overflow-y: auto; }
.insights li {
  display: flex; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--border-subtle); font-size: 13px;
}
.insights li:last-child { border-bottom: 0; }
.insights li.clickable { cursor: pointer; border-radius: 4px; }
.insights li.clickable:hover { background: var(--surface-2); }
.insights .ico {
  width: 28px; height: 28px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-text);
}
.insights .ico svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.insights .ico.good { background: var(--good-soft); color: var(--good); }
.insights .ico.bad { background: var(--bad-soft); color: var(--bad); }
.insights .ico.warn { background: var(--warn-soft); color: var(--warn); }
.insights b { font-weight: 600; }
.insights .ins-sub { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* ---- Pivot-Tabs und Ansichtsleiste ------------------------------------ */
.pivot { display: flex; gap: 4px; padding: 4px 12px 0; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.pivot button {
  position: relative; background: transparent; border: 0; cursor: pointer; white-space: nowrap;
  font-size: 14px; color: var(--text-secondary); padding: 10px 10px 12px;
}
.pivot button:hover { color: var(--text-primary); }
.pivot button[aria-selected="true"] { color: var(--text-primary); font-weight: 600; }
.pivot button[aria-selected="true"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px; border-radius: 2px; background: var(--accent);
}
.pivot .count { font-weight: 400; color: var(--text-muted); font-size: 12px; margin-left: 4px; }
.view-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px 16px; border-bottom: 1px solid var(--border-subtle); }
.view-search {
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px; width: 260px; max-width: 100%;
  border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface-1); color: var(--text-muted);
}
.view-search:focus-within { border-bottom: 2px solid var(--accent); }
.view-search input[type="search"] { border: 0; height: 28px; padding: 0; flex: 1; min-width: 0; background: transparent; }
.view-search input[type="search"]:focus { border: 0; }
.tab-pane { padding: 12px 16px 16px; }
.pane-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 1100px) { .pane-grid { grid-template-columns: 1fr; } }
.pane-h { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: var(--text-primary); }
.pane-h .muted { font-weight: 400; font-size: 12px; }
.pane-note {
  margin: 0 0 12px; padding: 8px 12px; font-size: 13px; color: var(--text-secondary);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 4px;
}

/* ---- Grids (D365-Ansichten) ------------------------------------------- */
.grid-wrap { overflow: auto; margin: 0 -4px; }
.grid-wrap.tall { max-height: 62vh; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.grid th, .grid td { text-align: right; padding: 0 10px; height: 40px; border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
.grid th:first-child, .grid td:first-child { text-align: left; }
.grid th.left, .grid td.left { text-align: left; }
.grid td.wrap { white-space: normal; min-width: 140px; max-width: 420px; overflow-wrap: anywhere; }
.grid th {
  height: 36px; font-size: 12px; font-weight: 600; color: var(--text-secondary);
  position: sticky; top: 0; z-index: 1; background: var(--surface-1);
  border-bottom: 1px solid var(--border); cursor: pointer; user-select: none;
}
.grid th:hover { background: var(--surface-2); }
.grid th[aria-sort="descending"]::after { content: " ↓"; color: var(--accent-text); }
.grid th[aria-sort="ascending"]::after { content: " ↑"; color: var(--accent-text); }
.grid tbody tr:hover td { background: var(--surface-2); }
.grid tbody tr.clickable { cursor: pointer; }
.grid td.num, .grid th.num { font-variant-numeric: tabular-nums; }
.grid.compact th, .grid.compact td { height: 34px; padding: 0 8px; }
.grid .primary { color: var(--accent-text); font-weight: 600; }
.grid tr.clickable:hover .primary { text-decoration: underline; }
.grid .sub { display: block; font-size: 12px; color: var(--text-muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.grid .empty td { text-align: center; color: var(--text-muted); height: 72px; }
.grid .cell-spark { width: 120px; }
.grid .cell-spark .chart { width: 120px; }
.grid .bar-cell { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.grid .bar-cell i { display: inline-block; height: 8px; border-radius: 2px; background: var(--accent); opacity: .8; }
.grid-foot { font-size: 12px; color: var(--text-muted); padding: 8px 4px 0; }
.site-cell { display: inline-flex; align-items: center; gap: 6px; }
.site-cell .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pos {
  display: inline-block; min-width: 38px; text-align: center; padding: 1px 6px; border-radius: 4px;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.pos.p1 { background: var(--q1); color: #fff; }
.pos.p2 { background: var(--q2); color: #fff; }
.pos.p3 { background: var(--q3); color: #0c1d33; }
.pos.p4 { background: var(--q4); color: var(--text-primary); }
:root[data-theme="dark"] .pos.p1, :root[data-theme="dark"] .pos.p2 { color: #0c1d33; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pos.p1, :root:not([data-theme="light"]) .pos.p2 { color: #0c1d33; } }
.tag {
  display: inline-block; padding: 0 6px; height: 20px; line-height: 20px; border-radius: 4px; font-size: 12px;
  background: var(--surface-3); color: var(--text-secondary);
}
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }

/* ---- Datensatzkopf (Portal im Detail) --------------------------------- */
.record-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.record-icon {
  width: 48px; height: 48px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 18px; flex: none;
}
.record-title h2 { font-size: 20px; line-height: 28px; }
.record-title .muted { font-size: 13px; }
.record-fields { display: flex; gap: 28px; margin-left: auto; flex-wrap: wrap; }
.record-fields div { display: flex; flex-direction: column; }
.record-fields small { font-size: 12px; color: var(--text-muted); }
.record-fields b { font-size: 14px; font-variant-numeric: tabular-nums; }

/* ---- Seitenpanel ------------------------------------------------------ */
.panel-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 50; }
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 51;
  background: var(--surface-1); box-shadow: var(--shadow-28);
  transform: translateX(100%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s;
  display: flex; flex-direction: column;
}
.panel.open { transform: translateX(0); visibility: visible; transition: transform .2s ease; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 12px; border-bottom: 1px solid var(--border); }
.panel-head h2 { font-size: 20px; line-height: 28px; overflow-wrap: anywhere; }
.panel-kicker { font-size: 12px; color: var(--text-muted); }
.panel-body { flex: 1; overflow-y: auto; padding: 16px 20px 32px; }
.panel-body section + section { margin-top: 22px; }
.panel-body h3 { font-size: 14px; margin-bottom: 8px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 1px; background: var(--border-subtle); border-radius: 8px; overflow: hidden; border: 1px solid var(--border-subtle); }
.facts div { background: var(--surface-1); padding: 10px 12px; }
.facts small { display: block; font-size: 12px; color: var(--text-muted); }
.facts b { font-size: 18px; font-variant-numeric: tabular-nums; }
.facts .d { display: block; font-size: 12px; margin-top: 2px; }
.advice { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text-secondary); }
.advice li + li { margin-top: 4px; }

/* ---- Rest ------------------------------------------------------------- */
.legend { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-bottom: 10px; }
.legend button {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 12px; padding: 2px 8px; height: 24px; border-radius: 4px;
  background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
}
.legend button[aria-pressed="true"] { background: var(--surface-2); color: var(--text-primary); }
.legend button[aria-pressed="false"] { opacity: .45; }
.legend .swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }

.msg { padding: 12px 16px; border-radius: 4px; background: var(--surface-1); color: var(--text-secondary); font-size: 13px; box-shadow: var(--shadow-2); border: 1px solid var(--border); }
.msg.error { border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: var(--bad-soft); }
.msg b { color: var(--text-primary); }
.msg code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.muted { color: var(--text-muted); }
.hint { font-size: 12px; color: var(--text-muted); margin: 8px 0 0; }
.loading .page { opacity: .45; transition: opacity .15s; pointer-events: none; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 60;
  background: var(--text-primary); color: var(--surface-1); padding: 10px 16px; border-radius: 4px; font-size: 13px;
  box-shadow: var(--shadow-28); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---- Diagramme -------------------------------------------------------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.axis text, text.axis { font-size: 12px; fill: var(--text-muted); }
.gridline { stroke: var(--grid); stroke-width: 1; }
.serie { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.crosshair { stroke: var(--border-strong); stroke-width: 1; }
.tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 140px;
  background: var(--surface-1); border-radius: 4px;
  padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow-28);
  opacity: 0; transition: opacity .1s;
}
.tip.on { opacity: 1; }
.tip .t-title { font-weight: 600; margin-bottom: 4px; color: var(--text-primary); }
.tip .t-row { display: flex; align-items: center; gap: 7px; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.tip .t-row .sw { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.tip .t-row .v { margin-left: auto; font-weight: 600; color: var(--text-primary); }
.bar-label { font-size: 12px; fill: var(--text-secondary); font-variant-numeric: tabular-nums; }
.bar-name { font-size: 12px; fill: var(--text-primary); }

/* ---- Schmale Fenster -------------------------------------------------- */
@media (max-width: 480px) {
  .app-name { display: none; }
}
@media (max-width: 880px) {
  .app-sep, .app-area { display: none; }
  .appbar-search { flex: 1 1 auto; min-width: 0; margin: 0 4px; }
  .appbar-title { padding: 0 4px; }
  #help-btn, .avatar { display: none; }
  .sitemap { position: fixed; top: 48px; bottom: 0; left: 0; z-index: 30; width: 260px; transform: translateX(-100%); transition: transform .18s; }
  .shell.nav-open .sitemap { transform: translateX(0); }
  .shell.nav-open .scrim { display: block; }
  .shell.collapsed .sitemap { width: 260px; }
  .shell.collapsed .nav-label, .shell.collapsed .nav-item span, .shell.collapsed .nav-site .nm,
  .shell.collapsed .nav-site .vv, .shell.collapsed .area-text { display: revert; }
  .commandbar { margin: 8px 8px 0; }
  .cmd span { display: none; }
  .cmd-filters { margin-left: 0; width: 100%; padding: 4px; }
  .page-header { padding: 12px 16px 0; }
  .content { padding: 12px 8px 40px; }
  .record-fields { margin-left: 0; }
}

/* ---- Portale & Maßnahmen ---------------------------------------------- */
.pivot.page-pivot { padding: 0 4px; margin-top: -4px; }
.tab-pane.bare { padding: 0; }
.tab-pane.bare > * + * { margin-top: 16px; }
.card-bar { background: var(--surface-1); border-radius: 8px; box-shadow: var(--shadow-2); border-bottom: 0; }
.site-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); gap: 16px; }
@media (max-width: 880px) { .site-cards { grid-template-columns: 1fr; } }
.site-card { display: flex; flex-direction: column; }
.site-card .sc-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.site-card .sc-name { min-width: 0; }
.site-card .sc-name b { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.site-card .sc-name b .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.site-card .sc-name a { font-size: 12px; color: var(--text-muted); }
.site-card .sc-val { margin-left: auto; text-align: right; }
.site-card .sc-val .v { font-size: 22px; font-weight: 600; line-height: 28px; font-variant-numeric: tabular-nums; }
.site-card .sc-val .pill { margin-top: 2px; }
.site-card .sc-mini { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-muted); margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.site-card .sc-mini b { color: var(--text-primary); font-weight: 600; }
.site-card h3 { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin: 14px 0 4px; text-transform: uppercase; letter-spacing: .03em; }
.site-card .sc-foot { margin-top: auto; padding-top: 10px; }

.actions { list-style: none; margin: 0; padding: 0; counter-reset: act; }
.actions li {
  counter-increment: act; position: relative; display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 6px 9px 4px; border-bottom: 1px solid var(--border-subtle); font-size: 13px; border-radius: 4px;
}
.actions li:last-child { border-bottom: 0; }
.actions li.clickable { cursor: pointer; }
.actions li.clickable:hover { background: var(--surface-2); }
.actions li::before {
  content: counter(act); flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-fill); color: #fff; font-size: 12px; font-weight: 600; margin-top: 1px;
}
.actions .a-body { flex: 1; min-width: 0; }
.actions .a-title { font-weight: 600; color: var(--text-primary); overflow-wrap: anywhere; }
.actions .a-why { color: var(--text-muted); font-size: 12px; margin-top: 2px; overflow-wrap: anywhere; }
.actions .a-impact { flex: none; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.actions .a-impact b { display: block; color: var(--good); font-size: 13px; }
.actions .a-impact span { color: var(--text-muted); }
.actions .a-type { display: inline-block; margin-right: 6px; }
.actions.top li { padding: 10px 6px 10px 4px; }
.actions .empty { color: var(--text-muted); }
.actions .empty::before { display: none; }

/* ---- Websites verwalten ------------------------------------------------ */
input[type="text"] {
  font: inherit; font-size: 13px; color: var(--text-primary); height: 32px;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-bottom-color: var(--text-muted);
  border-radius: 4px; padding: 0 8px; min-width: 0;
}
.grid.manage td { height: 48px; }
.grid.manage select { max-width: 260px; }
.grid.manage input[type="text"] { width: 140px; }
.grid.manage .actions-cell { text-align: right; }
.btn.subtle { background: transparent; color: var(--bad); border-color: var(--border-strong); font-weight: 400; }
.btn.subtle:hover { background: var(--bad-soft); filter: none; }
.btn.small { height: 26px; padding: 0 10px; font-size: 12px; }
.manage-form { display: grid; gap: 12px; max-width: 460px; }
.manage-form label { display: grid; gap: 4px; font-size: 12px; color: var(--text-muted); }
.manage-form input, .manage-form select { width: 100%; }
#page-manage .dash-grid { margin-top: 16px; }
.grid.manage .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
#manage-suggest td { white-space: normal; overflow-wrap: anywhere; }

/* ---- Anmeldung ---------------------------------------------------------- */
.login-body { display: flex; flex-direction: column; min-height: 100%; background: var(--surface-0); }
.login-wrap { flex: 1; display: grid; place-items: center; padding: 32px 16px; }
.login-card { width: 100%; max-width: 400px; padding: 32px; display: grid; gap: 16px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p { margin: 0; font-size: 13px; line-height: 1.5; }
.login-card form, .login-card > div { display: grid; gap: 14px; }
.login-icon { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; }
.login-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.login-field { display: grid; gap: 4px; font-size: 12px; color: var(--text-muted); }
.login-field input { width: 100%; }
.login-field code { font-size: 11px; }
.login-btn { height: 40px; width: 100%; font-size: 14px; }
.login-btn:disabled { opacity: .6; cursor: progress; }
.login-msg { font-size: 13px; padding: 10px 12px; border-radius: 4px; background: var(--surface-2); color: var(--text-secondary); }
.login-msg.bad { background: var(--bad-soft); color: var(--bad); }
.login-body .appbar { padding-left: 16px; }
.login-card [hidden] { display: none; }
