/* NAIDI Dashboard — editoriales Light-Design. Inter (Daten/UI) + Instrument Serif (Display).
   Accent: NAIDI-Rot (ersetzt Klars Flieder #5f51c2). */

:root {
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Instrument Serif', Georgia, 'Times New Roman', serif;

  --bg: #f6f4f1;
  --surface: #ffffff;
  --surface-2: #fbfaf8;
  --ink: #191817;
  --ink-2: #4b4946;
  --muted: #8a8681;
  --border: #e9e5df;
  --border-strong: #dcd6cd;

  /* NAIDI-Rot aus Naidi_Herz_2026.svg (#e52825). --accent-ink = dunklere Variante
     für Text auf Hell (Kontrast ~6:1; #e52825 selbst wäre auf Weiß zu knapp). */
  --accent: #e52825;
  --accent-ink: #b81f1d;
  --accent-soft: rgba(229, 40, 37, 0.08);
  --accent-line: rgba(229, 40, 37, 0.22);

  --positive: #1f8f4e;
  --negative: #cc3838;
  --info: #2f6bd6;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(25, 24, 23, 0.04), 0 1px 3px rgba(25, 24, 23, 0.03);
  --shadow: 0 2px 8px rgba(25, 24, 23, 0.05), 0 12px 30px -12px rgba(25, 24, 23, 0.12);

  --space: 22px;
  --sidebar-w: 250px;

  --toast-bg: #232120;
  --toast-fg: #ffffff;
}

/* ── Dark Mode ─────────────────────────────────────────── */
:root[data-theme='dark'] {
  --bg: #1b1a18;
  --surface: #24221f;
  --surface-2: #201e1b;
  --ink: #f3f0ea;
  --ink-2: #cbc5bb;
  --muted: #948e85;
  --border: #322e29;
  --border-strong: #45403a;

  --accent: #e52825;
  --accent-ink: #ff6259; /* auf Dunkel heller für Kontrast */
  --accent-soft: rgba(229, 40, 37, 0.16);
  --accent-line: rgba(229, 40, 37, 0.34);

  --positive: #43c07a;
  --negative: #ff6b6b;
  --info: #5b93f0;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 12px 30px -12px rgba(0, 0, 0, 0.6);

  --toast-bg: #3a352f;
  --toast-fg: #f3f0ea;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum' 1, 'cv05' 1;
}
button {
  font-family: inherit;
  cursor: pointer;
}
h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
}

/* ── Layout ─────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 26px 18px;
}
.brand {
  padding: 2px 8px 4px;
}
.brand-logo {
  display: block;
  width: 116px;
  height: auto;
}
.brand-sub {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-top: 10px;
  padding-left: 2px;
}

.nav {
  margin-top: 34px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}
.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
  flex: none;
  transition: background 0.15s;
}
.nav-item.is-active .nav-dot {
  background: var(--accent);
}
.nav-gear {
  font-size: 14px;
  width: 6px;
  display: inline-flex;
  justify-content: center;
  color: var(--muted);
}
.nav-item.is-active .nav-gear {
  color: var(--accent);
}
.nav-settings {
  margin-top: 8px;
}
.logout-btn {
  margin-top: 12px;
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.logout-btn:hover {
  border-color: var(--negative);
  color: var(--negative);
}

/* ── Einstellungen ──────────────────────────────────────── */
.set-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.set-row:last-child {
  border-bottom: 0;
}
.set-row label {
  font-size: 13px;
  color: var(--ink-2);
}
.set-row .hint {
  font-size: 11.5px;
  color: var(--muted);
}
.set-input {
  width: 180px;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface-2);
  text-align: right;
}
.set-input.wide {
  width: 240px;
  text-align: left;
}
.set-input:focus {
  outline: 2px solid var(--accent-line);
}
.pill-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}
.pill-badge.on {
  color: var(--positive);
  background: rgba(31, 143, 78, 0.1);
}
.pill-badge.off {
  color: var(--muted);
  background: var(--surface-2);
}
.toggle {
  appearance: none;
  width: 40px;
  height: 22px;
  border-radius: 20px;
  background: var(--border-strong);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
  flex: none;
}
.toggle:checked {
  background: var(--accent);
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.toggle:checked::after {
  transform: translateX(18px);
}
@media (max-width: 900px) {
  .set-grid {
    grid-template-columns: 1fr;
  }
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 18px;
}
.datasource {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.6;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.datasource b {
  color: var(--ink-2);
  font-weight: 600;
}
.src-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
}
.src-ok {
  background: var(--positive);
}
.src-skip {
  background: var(--border-strong);
}
.src-err {
  background: var(--negative);
}

/* ── Topbar ─────────────────────────────────────────────── */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 22px var(--space) 16px;
  background: linear-gradient(var(--bg) 72%, rgba(246, 244, 241, 0));
  backdrop-filter: blur(2px);
}
.topbar-title h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 30px;
  letter-spacing: 0.2px;
  line-height: 1.05;
}
.view-range {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}
.topbar-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}
.range-picker {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 4px;
  box-shadow: var(--shadow-sm);
}
.range-btn {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 6px 11px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
}
.range-btn:hover {
  background: var(--surface-2);
}
.range-btn.is-active {
  background: var(--ink);
  color: #fff;
}
.range-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 3px;
}
.date-input {
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  color: var(--ink-2);
  padding: 4px;
  border-radius: 6px;
}
.date-input:focus {
  outline: 2px solid var(--accent-line);
}
.range-dash {
  color: var(--muted);
}

/* Datums-Preset-Dropdown */
.range-preset {
  position: relative;
}
.range-preset-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.range-preset-btn:hover {
  background: var(--surface-2);
}
.range-caret {
  color: var(--muted);
  font-size: 10px;
}
.range-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 60;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.range-menu.is-hidden {
  display: none;
}
.range-menu button {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.range-menu button:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.range-menu button.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}

/* Optionen-Dropdown */
.opt-wrap {
  position: relative;
}
.opt-menu {
  min-width: 230px;
  right: 0;
  left: auto;
}
.opt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  border-radius: 7px;
}
.opt-row:hover {
  background: var(--surface-2);
}
.opt-row input {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}
.range-preset-btn.opt-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* Sichtbarer Kosten-Schalter (Toggle) */
.cost-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  user-select: none;
}
.cost-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.switch-ui {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  flex: none;
  transition: background 0.15s;
}
.switch-ui::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}
.cost-toggle input:checked + .switch-ui {
  background: var(--accent);
}
.cost-toggle input:checked + .switch-ui::after {
  transform: translateX(14px);
}
.cost-toggle input:focus-visible + .switch-ui {
  outline: 2px solid var(--accent-line);
  outline-offset: 2px;
}
/* Theme-Umschalter */
.icon-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-2);
  width: 34px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.content {
  padding: 6px var(--space) 48px;
}
.view.is-hidden {
  display: none;
}

/* ── Grid + Cards ───────────────────────────────────────── */
.section-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 30px 2px 12px;
}
.section-label:first-child {
  margin-top: 8px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 12px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  min-height: 108px;
  display: flex;
  flex-direction: column;
}
.kpi-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-value {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 6px;
  line-height: 1.1;
}
.kpi-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}
.kpi-spark {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 34px;
  opacity: 0.9;
}
.kpi.accent .kpi-value {
  color: var(--accent-ink);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
}
.badge.up {
  color: var(--positive);
  background: rgba(31, 143, 78, 0.1);
}
.badge.down {
  color: var(--negative);
  background: rgba(204, 56, 56, 0.1);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.panel-title {
  font-size: 14px;
  font-weight: 600;
}
.panel-tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

.cols-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.cols-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.chart-wrap {
  position: relative;
  height: 260px;
}
.chart-wrap.short {
  height: 200px;
}

/* ── Toggle / pills ─────────────────────────────────────── */
.pill-toggle {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}
.pill {
  border: 0;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  padding: 4px 10px;
  border-radius: 6px;
}
.pill.is-active {
  background: var(--surface);
  color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
}
.btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 8px;
}
.btn:hover {
  border-color: var(--ink-2);
  color: var(--ink);
}

/* ── Tabellen ───────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th,
table.data td {
  padding: 10px 12px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
table.data th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
table.data th:hover {
  color: var(--ink-2);
}
table.data th.sorted::after {
  content: ' ▾';
  color: var(--accent);
}
table.data th.sorted.asc::after {
  content: ' ▴';
}
table.data th:first-child,
table.data td:first-child {
  text-align: left;
}
table.data tbody tr:hover {
  background: var(--surface-2);
}
table.data tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--border-strong);
  border-bottom: 0;
}
.cell-strong {
  font-weight: 600;
  color: var(--ink);
}
.chan-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.chan-swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex: none;
}
.num-pos {
  color: var(--positive);
}
.num-neg {
  color: var(--negative);
}
.muted {
  color: var(--muted);
}

/* ── P&L Wasserfall ─────────────────────────────────────── */
.pnl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.pnl td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
}
.pnl .pnl-label {
  color: var(--ink-2);
}
.pnl .pnl-val {
  text-align: right;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.pnl .pnl-pct {
  text-align: right;
  width: 92px;
  color: var(--muted);
  font-size: 12.5px;
}
.pnl tr.subtotal td {
  background: var(--surface-2);
  font-weight: 700;
}
.pnl tr.subtotal .pnl-label {
  color: var(--ink);
}
.pnl tr.strong td {
  background: var(--accent-soft);
}
.pnl tr.strong .pnl-label,
.pnl tr.strong .pnl-val {
  color: var(--accent-ink);
  font-weight: 800;
}
.pnl-bar {
  height: 4px;
  border-radius: 3px;
  background: var(--accent-line);
  margin-top: 5px;
}

/* ── Misc ───────────────────────────────────────────────── */
.split-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--ink-2);
}
.split-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px;
  font-size: 13px;
}
.note {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 12px;
}
/* Warnung bei unvollständiger Datenlage — muss auffallen, nicht dekorieren. */
.note.warn {
  color: var(--ink-2);
  background: rgba(229, 40, 37, 0.05);
  border: 1px solid var(--accent-line);
  font-size: 12.5px;
  line-height: 1.55;
  margin: 8px 0 4px;
}
.note.warn b {
  color: var(--accent-ink);
}

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--toast-bg);
  color: var(--toast-fg);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, #f0ede8 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1080px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .cols-3 {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
  }
  .nav {
    margin-top: 0;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sidebar-foot {
    display: none;
  }
  .cols-2 {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
@media (max-width: 560px) {
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
  .filter-row {
    flex-direction: column;
  }
  .f-field {
    width: 100%;
  }
}

/* ── Produkt-Baum + Schnellauswahl ──────────────────────── */
.panel-actions {
  display: flex;
  gap: 8px;
}
.panel-hint {
  font-size: 12px;
  color: var(--muted);
}
.small {
  font-size: 11px;
}

.prod-filter {
  margin-bottom: 16px;
}
.filter-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.f-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  min-width: 200px;
  flex: 1;
}
.f-field select {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
}
.f-field select:focus {
  outline: 2px solid var(--accent-line);
  border-color: var(--accent);
}
.f-field select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.filter-result {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  min-height: 24px;
}
.filter-result .muted {
  font-size: 13px;
}
.fr-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-ink);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.fr-vals {
  font-size: 15px;
  color: var(--ink-2);
}
.fr-num {
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.fr-sep {
  color: var(--border-strong);
  margin: 0 3px;
}

/* Baum-Tabelle */
table.data.tree td {
  font-variant-numeric: tabular-nums;
}
.tree-row.is-hidden {
  display: none;
}
.tree-row.lvl-prod {
  cursor: pointer;
}
.tree-row.lvl-prod > td {
  font-weight: 600;
}
.tree-row.lvl-color {
  cursor: pointer;
  background: var(--surface-2);
}
.tree-row.lvl-color[data-node] {
  cursor: pointer;
}
.tree-row.lvl-color:not([data-node]) {
  cursor: default;
}
.tree-row.lvl-size {
  background: var(--surface-2);
  color: var(--ink-2);
}
.tree-row.lvl-size > td:first-child {
  color: var(--muted);
}
.num-strong {
  font-weight: 700;
  color: var(--ink);
}
td.pad-1 {
  padding-left: 30px !important;
}
td.pad-2 {
  padding-left: 58px !important;
}
.tw-caret {
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  width: 18px;
  padding: 0;
  margin-right: 6px;
  transition: color 0.12s;
}
.tree-row:hover .tw-caret {
  color: var(--accent);
}
.tw-spacer {
  display: inline-block;
  width: 18px;
  margin-right: 6px;
}
.tag-count {
  font-size: 11px;
  color: var(--muted);
  margin-left: 8px;
  font-weight: 500;
}
.size-badge {
  display: inline-block;
  min-width: 34px;
  text-align: center;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-2);
  margin-right: 8px;
}

/* ── Eigene Kosten (Einstellungen) ──────────────────────── */
.cost-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cost-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.cost-item.is-off {
  opacity: 0.5;
}
.ci-name {
  font-weight: 600;
  font-size: 13px;
}
.ci-actions {
  display: flex;
  gap: 6px;
  flex: none;
}
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}
.btn-on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.cost-add {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-strong);
}
.cost-add .set-input {
  flex: 1;
  min-width: 110px;
}
.ci-period {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-basis: 100%;
}
.ci-period.is-hidden {
  display: none;
}
/* Kostenposten im Bearbeiten-Modus: volle Breite, Formular untereinander */
.cost-item.editing {
  flex-direction: column;
  align-items: stretch;
}
.cost-item.editing .cost-add {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.ci-edit-actions {
  display: flex;
  gap: 6px;
  flex-basis: 100%;
  margin-top: 4px;
}
/* Eigene Kostenzeilen in der P&L */
.pnl tr.custom .pnl-label {
  padding-left: 22px;
  color: var(--ink-2);
}
