/* ============================================================
   Dharma Funding OS — Design System v2
   Markenfarben von dharma-funding.solutions:
     Primär  #00606B (Petrol — CTA-Farbe der Website)
     Akzent  #FF2A13 (Logo-Rot — sehr sparsam: Logo + aktive Navigation)
   Funktionsfarben: gold = Förderung/Geld · violett = KI-generiert
   ============================================================ */

:root {
  --paper: #F3F6F6;
  --surface: #FFFFFF;
  --ink: #14262B;
  --ink-soft: #52676D;
  --ink-faint: #84979C;
  --line: #E2E9EA;
  --line-strong: #C7D3D5;

  --petrol: #00606B;          /* Primärfarbe = Marke */
  --petrol-deep: #004A52;
  --petrol-bg: #E4EFF0;

  --brand-red: #FF2A13;       /* Logo-Akzent, nur Mikro-Dosen */

  --sidebar-bg: #06282D;
  --sidebar-bg2: #052227;

  --gold: #96701F;
  --gold-bright: #C9971F;
  --gold-bg: #FAF3E2;

  --ki: #6D4FC2;
  --ki-deep: #55399E;
  --ki-bg: #F5F2FC;
  --ki-line: #DDD3F4;

  --ok: #217A4B;
  --ok-bg: #E9F5EE;
  --warn: #9C5D00;
  --warn-bg: #FCF3E3;
  --bad: #B3372F;
  --bad-bg: #FBECEA;

  --font-display: "Inter", "Avenir Next", "Segoe UI", -apple-system, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(6, 40, 45, .05), 0 3px 12px rgba(6, 40, 45, .05);
  --shadow-lift: 0 2px 4px rgba(6, 40, 45, .08), 0 12px 32px rgba(6, 40, 45, .11);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Shell ---------- */

.shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg2));
  color: #D7E5E7;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 16px;
}

.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* Topbar — App-Chrome wie in einer echten SaaS-Anwendung */
.topbar {
  height: 56px; flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
}
.topbar-crumb { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.topbar-crumb .crumb-app { font-size: 12px; color: var(--ink-faint); font-weight: 500; }
.topbar-crumb .crumb-sep { color: var(--line-strong); font-size: 12px; }
.topbar-crumb .crumb-page { font-family: var(--font-display); font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.topbar-search {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  width: 300px; max-width: 34vw;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  color: var(--ink-faint); font-size: 13px;
  cursor: text;
  transition: border-color .15s, background .15s;
}
.topbar-search:hover { border-color: var(--line-strong); background: var(--surface); }
.topbar-search svg { width: 15px; height: 15px; flex-shrink: 0; }
.topbar-search .kbd {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 10.5px;
  border: 1px solid var(--line); border-radius: 4px;
  padding: 1px 5px; color: var(--ink-faint); background: var(--surface);
}
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.topbar-btn {
  position: relative;
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); background: transparent; border: none; cursor: pointer;
  transition: background .15s, color .15s;
}
.topbar-btn:hover { background: var(--paper); color: var(--ink); }
.topbar-btn svg { width: 18px; height: 18px; }
.topbar-btn .dot {
  position: absolute; top: 7px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand-red); border: 1.5px solid var(--surface);
}
.topbar-divider { width: 1px; height: 24px; background: var(--line); margin: 0 6px; }
.topbar-user { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 4px 6px; border-radius: 8px; transition: background .15s; }
.topbar-user:hover { background: var(--paper); }
.topbar-user .user-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.topbar-user .user-role { font-size: 11px; color: var(--ink-faint); }

/* Marke: Wordmark wie im echten Dharma-Logo (rotes „ma") + Ring */
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 10px 20px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: conic-gradient(from 210deg, var(--brand-red) 0 88deg, rgba(255,255,255,.85) 88deg 360deg);
  -webkit-mask: radial-gradient(circle, transparent 0 9px, #000 9.5px);
          mask: radial-gradient(circle, transparent 0 9px, #000 9.5px);
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -.01em; color: #fff; line-height: 1.1; }
.brand-name em { font-style: normal; color: #FF4B36; }
.brand-sub { font-size: 9.5px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: #7FA6AB; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-label {
  font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: #5E8489; padding: 14px 12px 6px;
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 8px;
  color: #A7C4C8; text-decoration: none; font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.10); color: #fff; font-weight: 600; }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 7px; bottom: 7px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--brand-red);
}
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }
.nav-icon svg { width: 18px; height: 18px; display: block; }

.ki-badge {
  margin-left: auto;
  font-size: 9.5px; font-weight: 700; letter-spacing: .08em;
  padding: 2px 6px; border-radius: 4px;
  background: var(--ki); color: #fff;
}

.sidebar-foot { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.10); }
.demo-badge {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 600; letter-spacing: .04em;
  color: #EFD9A6;
  background: rgba(201,151,31,.14);
  border: 1px solid rgba(239,217,166,.22);
  padding: 6px 10px; border-radius: 6px;
}
.demo-dot { width: 7px; height: 7px; border-radius: 50%; background: #E4C270; animation: pulse 2.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.sidebar-version { font-size: 10.5px; color: #5E8489; padding: 0 4px; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #0B7A88, var(--petrol-deep));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}

.main { flex: 1; overflow-y: auto; padding: 26px 32px 60px; }

/* ---------- Typo & Bausteine ---------- */

.page-head { margin-bottom: 22px; }
.page-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--petrol); margin-bottom: 6px;
}
.page-title { font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: -.01em; }
.page-sub { color: var(--ink-soft); margin-top: 5px; font-size: 13.5px; max-width: 640px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 18px 20px; }

.section-title {
  font-family: var(--font-display); font-size: 15px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}

/* KI-Signatur: alles KI-Generierte ist violett markiert */
.ki-panel {
  background: var(--ki-bg);
  border: 1px solid var(--ki-line);
  border-radius: var(--radius);
  position: relative;
}
.ki-panel-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px 0;
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ki-deep);
}
.ki-hint { font-size: 11.5px; color: var(--ki-deep); opacity: .75; font-style: italic; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-body); font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: background .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--petrol); color: #fff; }
.btn-primary:hover { background: var(--petrol-deep); }
.btn-ki { background: var(--ki); color: #fff; }
.btn-ki:hover { background: var(--ki-deep); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--paper); }
.btn-sm { font-size: 12px; padding: 5px 10px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
}
.chip-ok   { background: var(--ok-bg);   color: var(--ok); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-bad  { background: var(--bad-bg);  color: var(--bad); }
.chip-neutral { background: var(--paper); color: var(--ink-soft); border: 1px solid var(--line); }
.chip-petrol { background: var(--petrol-bg); color: var(--petrol); }
.chip-gold { background: var(--gold-bg); color: var(--gold); }
.chip-ki { background: var(--ki-bg); color: var(--ki-deep); border: 1px solid var(--ki-line); }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- Tabellen ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-faint); padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #FAFBFC; }

/* ---------- Formulare ---------- */

.field { display: flex; flex-direction: column; gap: 5px; }
.field-label {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-faint);
}
.field-label .req { color: var(--brand-red); margin-left: 2px; }
.input, .select, .textarea {
  font-family: var(--font-body); font-size: 13.5px; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 11px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--petrol);
  box-shadow: 0 0 0 3px var(--petrol-bg);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-faint); }
.textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
.input.invalid, .select.invalid { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
.field-error { font-size: 11.5px; color: var(--bad); }
.field-hint { font-size: 11.5px; color: var(--ink-faint); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.form-section { padding: 16px 0; border-top: 1px solid var(--line); }
.form-section:first-of-type { border-top: none; padding-top: 4px; }
.form-section-title {
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--petrol); margin-bottom: 12px;
}

.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; }
.check input { margin-top: 2px; accent-color: var(--petrol); width: 15px; height: 15px; flex-shrink: 0; }

/* ---------- Modal / Drawer ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(6, 40, 45, .38);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 20px;
  overflow-y: auto;
  animation: modalIn .18s ease both;
}
.modal {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(6, 40, 45, .28);
  width: 100%; max-width: 720px;
  animation: modalUp .22s cubic-bezier(.2, .8, .2, 1) both;
}
.modal-lg { max-width: 940px; }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.modal-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.modal-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }
.modal-body { padding: 18px 22px; }
.modal-foot {
  display: flex; align-items: center; gap: 10px; justify-content: flex-end;
  padding: 14px 22px; border-top: 1px solid var(--line);
  background: var(--paper); border-radius: 0 0 14px 14px;
}
.modal-foot .spacer { margin-right: auto; }
.modal-close {
  border: none; background: transparent; cursor: pointer;
  color: var(--ink-faint); font-size: 20px; line-height: 1;
  width: 30px; height: 30px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--paper); color: var(--ink); }
@keyframes modalIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Tabs ---------- */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab {
  position: relative;
  padding: 9px 14px; border: none; background: transparent; cursor: pointer;
  font-family: var(--font-body); font-size: 13.5px; font-weight: 500; color: var(--ink-soft);
  transition: color .15s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--petrol); font-weight: 600; }
.tab.active::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px;
  height: 2px; background: var(--petrol); border-radius: 2px 2px 0 0;
}
.tab-count {
  display: inline-block; margin-left: 6px;
  font-size: 11px; font-weight: 600;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 6px; color: var(--ink-faint);
}
.tab.active .tab-count { background: var(--petrol-bg); border-color: transparent; color: var(--petrol); }

/* ---------- Toast ---------- */

.toast-host {
  position: fixed; bottom: 22px; right: 22px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: #fff;
  font-size: 13px; font-weight: 500;
  padding: 11px 15px; border-radius: 9px;
  box-shadow: 0 8px 28px rgba(6, 40, 45, .28);
  animation: toastIn .22s cubic-bezier(.2,.8,.2,1) both;
  max-width: 420px;
}
.toast.leaving { animation: toastOut .2s ease both; }
.toast-ico {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  background: var(--ok); color: #fff;
}
.toast-ico.auto { background: var(--petrol); }
.toast-ico.ki { background: var(--ki); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* ---------- Info-Tooltip ---------- */

.info-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  font-size: 9.5px; font-weight: 700; cursor: help;
  background: var(--line); color: var(--ink-soft);
  vertical-align: middle; margin-left: 5px;
  transition: background .15s, color .15s;
}
.info-tip:hover { background: var(--petrol); color: #fff; }

/* ---------- Empty state ---------- */

.empty {
  text-align: center; padding: 40px 20px; color: var(--ink-faint);
}
.empty-title { font-size: 14px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.empty-sub { font-size: 12.5px; }

/* ---------- „NEU" Marker für Datensätze aus dieser Demo-Sitzung ---------- */

.neu-badge {
  font-size: 9.5px; font-weight: 700; letter-spacing: .08em;
  padding: 2px 6px; border-radius: 4px;
  background: var(--brand-red); color: #fff;
}

/* ---------- Utility ---------- */

.grid { display: grid; gap: 16px; }
.flex { display: flex; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: 12px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 2px solid var(--paper); }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--petrol); outline-offset: 2px;
}
