:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-2: #f0f7ff;
  --text: #0f172a;
  --muted: #64748b;
  --sub: #334155;
  --light: #94a3b8;
  --line: #e2e8f0;
  --blue: #3b82f6;
  --blue-dark: #1d4ed8;
  --blue-deep: #1e3a8a;
  --green: #10b981;
  --green-bg: #ecfdf5;
  --red: #ef4444;
  --red-bg: #fef2f2;
  --amber: #f59e0b;
  --amber-bg: #fffbeb;
  --sidebar: #f0f7ff;
}

* { box-sizing: border-box; }

html { overflow-x: hidden; }

body {
  margin: 0;
  font: 13px/1.45 "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.app {
  height: calc(100vh - 50px);
  display: flex;
  overflow: hidden;
}

aside {
  width: 340px;
  flex-shrink: 0;
  height: calc(100vh - 50px);
  overflow: auto;
  padding: 18px 16px 20px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  transition: margin-left .25s ease, opacity .2s ease;
}

body.sb-collapsed aside {
  margin-left: -340px;
  opacity: 0;
  pointer-events: none;
}

main {
  flex: 1;
  min-width: 0;
  height: calc(100vh - 50px);
  overflow: auto;
  padding: 22px 26px 36px;
  max-width: 1300px;
  transition: padding-left .25s ease;
}

body.sb-collapsed main {
  padding-left: 60px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 1.8rem; font-weight: 700; }
h2 { margin: 22px 0 12px; font-size: 0.86rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
h3 { margin: 0 0 10px; font-size: 1rem; font-weight: 600; }

.topbar {
  height: 50px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: rgb(42, 74, 120);
  border-bottom: 1px solid rgba(59, 130, 246, 0.15);
  color: #e2e8f0;
}

.back-link {
  border: 0;
  background: transparent;
  color: rgba(191, 219, 254, 0.72);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
}

.bar-divider {
  width: 1px;
  height: 16px;
  background: rgba(147, 197, 253, 0.24);
}

.brand-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.brand-main { font-size: 13px; font-weight: 700; }
.brand-sub { color: rgba(191, 219, 254, 0.55); font-size: 12px; }
.brand-site { margin-left: auto; color: rgba(191, 219, 254, 0.4); font-size: 11px; font-style: italic; }

.sb-toggle {
  position: fixed;
  top: 58px;
  left: 14px;
  z-index: 60;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--blue-deep);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transition: left .25s ease, background .15s, border-color .15s;
}

.sb-toggle:hover {
  background: #f0f7ff;
  border-color: var(--blue);
}

.sb-toggle svg { width: 18px; height: 18px; }

body:not(.sb-collapsed) .sb-toggle { left: 308px; }

.hero {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-radius: 12px;
  padding: 22px 28px;
  margin-bottom: 22px;
  background: linear-gradient(120deg, #0a1628 0%, #0d2a6e 55%, #1540a0 100%);
  border: 1px solid rgba(57, 94, 156, 0.6);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 20px;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.06;
  background-image:
    linear-gradient(rgba(255,255,255,0.8) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.8) 1px, transparent 1px);
  background-size: 30px 30px;
  pointer-events: none;
}

.hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: rgba(99, 155, 255, 0.15);
  animation: scanline 4s linear infinite;
  pointer-events: none;
}

@keyframes scanline {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(400px); }
}

.hero-icon {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 0 12px rgba(59, 130, 246, 0.55));
}

.hero-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 520px;
}

.eyebrow {
  margin-bottom: 8px;
  color: rgba(191, 219, 254, 0.68);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 5px;
  letter-spacing: -0.3px;
}

.hero-text {
  max-width: 430px;
  color: rgba(191, 219, 254, 0.82);
  font-size: 12.5px;
  line-height: 1.65;
  margin: 0;
}

.caption, .hint, footer {
  color: var(--muted);
  font-size: 0.8rem;
}

.section-title {
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.info-tip {
  display: inline-block;
  margin-left: 4px;
  width: 13px;
  height: 13px;
  line-height: 13px;
  text-align: center;
  border-radius: 50%;
  background: #cbd5e1;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  font-style: normal;
  cursor: help;
  vertical-align: 1px;
}

.info-tip:hover { background: var(--blue); }

label {
  display: block;
  margin: 0 0 13px;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}

input[type="number"], input[type="text"], input[type="date"], select {
  width: 100%;
  margin-top: 5px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 500;
}

input[type="number"]:focus,
input[type="text"]:focus,
input[type="date"]:focus,
select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

input[type="range"] { width: 100%; accent-color: var(--blue); margin-top: 5px; }

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.check input { accent-color: var(--blue); }

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(360px, 3fr) minmax(280px, 2fr);
  gap: 18px;
  align-items: stretch;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.card {
  border: 1px solid var(--line);
  border-top: 2px solid var(--blue);
  border-left: 0;
  border-radius: 10px;
  background: #fff;
  padding: 14px 16px;
  min-width: 0;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}

.card .label {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .02em;
}

.card .value {
  color: var(--blue-deep);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.card.danger { border-top-color: var(--red); }
.card.danger .value { color: var(--red); }

.card.success { border-top-color: #10b981; }
.card.success .value { color: #10b981; }

.card.neutral { border-top-color: var(--muted); }
.card.neutral .value { color: var(--blue-dark); }

.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
  padding: 16px 18px;
  min-width: 0;
  overflow: hidden;
}

.chart {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 300px;
}

.js-plotly-plot, .plot-container, .svg-container { max-width: 100%; }

.chart.small { height: 260px; }
.chart.tall { height: 360px; }

hr { margin: 24px 0; border: 0; border-top: 1px solid var(--line); }

table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 0.85rem;
  table-layout: fixed;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 8px 7px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: normal;
}

th {
  background: #f0f7ff;
  color: var(--blue-deep);
  font-weight: 700;
}

td.num, th.num {
  text-align: right;
  white-space: nowrap;
  overflow-wrap: normal;
}

tr.total td {
  background: #f0f7ff;
  font-weight: 700;
  border-top: 2px solid var(--blue);
}

tr.minus td { color: var(--muted); }
tr.eigenanteil td {
  background: #eff6ff;
  font-weight: 700;
  color: var(--blue-dark);
  border-top: 1px solid var(--blue);
}

.metric-section {
  margin-bottom: 18px;
}

.metric-section h2 {
  margin-top: 0;
}

.tabs {
  display: flex;
  background: #f0f7ff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin: 0 0 22px;
  flex-wrap: wrap;
}

.tab-button {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  padding: 11px 8px;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.2;
  color: #334155;
  font-weight: 500;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  hyphens: auto;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.tab-button:last-child { border-right: none; }
.tab-button:hover { background: #dbeafe; }

.tab-button.active {
  background: var(--blue-dark);
  color: #fff;
  font-weight: 600;
}

.tab { display: none; }
.tab.active { display: block; }

.notice {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid #dbeafe;
  border-radius: 7px;
  background: #eff6ff;
  color: #1d4ed8;
}

.warning {
  border: 1px solid #f2c785;
  background: #fff7e8;
  color: #6b4100;
  padding: 10px 12px;
  border-radius: 7px;
  margin-bottom: 12px;
}

details {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0 16px 16px;
}

summary {
  padding: 13px 0;
  font-weight: 700;
  cursor: pointer;
}

button.primary, button.secondary {
  min-height: 38px;
  padding: 9px 13px;
  border-radius: 6px;
  border: 1px solid var(--blue);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button.primary {
  background: var(--blue);
  color: #fff;
}

button.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }

button.secondary {
  background: #fff;
  color: var(--blue);
}

.page-footer {
  text-align: center;
  margin-top: 24px;
}

@media (max-width: 980px) {
  .topbar { padding: 0 12px; }
  .brand-sub, .brand-site { display: none; }
  .app {
    height: auto;
    min-height: calc(100vh - 50px);
    display: block;
    overflow: visible;
  }
  aside {
    position: static;
    width: 100%;
    height: auto;
    padding-top: 58px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  body.sb-collapsed aside { margin-left: -100%; }
  body:not(.sb-collapsed) .sb-toggle { left: calc(100% - 48px); }
  main {
    height: auto;
    overflow: visible;
    padding: 20px 16px 30px;
  }
  body.sb-collapsed main { padding-left: 60px; }
  .hero::after { opacity: 0.25; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .tab-button {
    flex: 1 1 33.333%;
    min-width: 132px;
    padding: 10px 8px;
    font-size: 0.86rem;
  }
  table { font-size: 0.78rem; }
  th, td { padding: 7px 5px; }
}

@media (max-width: 600px) {
  .hero-title { font-size: 1.35rem; line-height: 1.18; }
  .hero-text { font-size: 0.9rem; }
  .hero { padding: 22px 18px; align-items: flex-start; }
  .hero-icon { width: 46px; height: 46px; }
  h2 { font-size: 0.82rem; }
  h3 { font-size: 0.95rem; }
  .card .value { font-size: 1.15rem; }
  .card .label { font-size: 0.72rem; }
  .grid-4 { gap: 8px; }
  main { padding: 16px 10px 24px; }
}

@media (max-width: 380px) {
  .grid-4 { grid-template-columns: 1fr; }
}

@media print {
  body { background: #fff; }
  .app { display: block; }
  aside, .topbar, .sb-toggle, .tabs, .tab-button, details, .no-print { display: none !important; }
  main { padding: 0; }
  .panel, .card { box-shadow: none; break-inside: avoid; }
  .tab { display: block !important; }
  hr { margin: 14px 0; }
}
