:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ef;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-soft: rgba(42, 120, 214, 0.10);
  --series-1: #2a78d6;
  --good: #0ca30c;
  --good-text: #006300;
  --bad: #d03b3b;
  --bad-text: #b02e2e;
  --warn: #fab219;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 4px 16px rgba(11, 11, 11, 0.04);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --line: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --series-1: #3987e5;
    --good-text: #0ca30c;
    --bad-text: #e66767;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --line: #2c2c2a;
  --axis: #383835;
  --ring: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --accent-soft: rgba(57, 135, 229, 0.16);
  --series-1: #3987e5;
  --good-text: #0ca30c;
  --bad-text: #e66767;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 16px;
  height: 60px; display: flex; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 650; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand-mark svg { width: 28px; height: 28px; display: block; }
.brand-mark rect { fill: var(--accent); }
.brand-mark path { stroke: #fff; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.tabs { display: flex; gap: 4px; }
.tabs a {
  color: var(--ink-2); padding: 7px 12px; border-radius: 8px; font-weight: 550;
}
.tabs a:hover { background: var(--surface-2); text-decoration: none; }
.tabs a.active { color: var(--ink); background: var(--surface-2); }
.theme-toggle {
  margin-left: auto; width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  display: grid; place-items: center;
}
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}

main { padding-top: 28px; padding-bottom: 40px; min-height: 60vh; }
.loading, .empty { color: var(--muted); padding: 60px 0; text-align: center; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 26px; line-height: 1.2; margin: 0; letter-spacing: -0.02em; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }

/* ---------- Filterleiste ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.search {
  flex: 1 1 260px; min-width: 0; height: 40px; padding: 0 14px 0 38px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface) no-repeat 12px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23898781' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
  color: var(--ink); font: inherit;
}
.search:focus, .seg button:focus-visible, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 3px; }
.seg button {
  border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; color: var(--ink-2); font-weight: 550; font-size: 14px;
}
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); }
.result-count { color: var(--muted); font-size: 14px; margin-left: auto; }

/* ---------- Report-Karten ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
  color: inherit; transition: transform .15s ease, border-color .15s ease;
}
.card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--axis); }
.card-media { aspect-ratio: 16 / 8; background: var(--surface-2); overflow: hidden; position: relative; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-media .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-meta { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.card-title { font-size: 16.5px; font-weight: 650; line-height: 1.35; letter-spacing: -0.01em; margin: 0; color: var(--ink); }
.card-excerpt { color: var(--ink-2); font-size: 14px; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { margin-top: auto; display: flex; gap: 6px; flex-wrap: wrap; padding-top: 4px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.badge.section-markets { background: var(--accent-soft); color: var(--accent); }
.badge.long { color: var(--good-text); }
.badge.short { color: var(--bad-text); }
.badge.good { color: var(--good-text); }
.badge.bad { color: var(--bad-text); }
.badge svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Detailansicht ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); margin-bottom: 18px; font-weight: 550; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
@media (max-width: 900px) { .detail { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius); box-shadow: var(--shadow); }
.article { padding: 0; overflow: hidden; }
.article-cover { max-height: 300px; overflow: hidden; background: var(--surface-2); }
.article-cover img { width: 100%; object-fit: cover; }
.article-inner { padding: 22px 26px 28px; }
.article h1 { font-size: 25px; line-height: 1.25; letter-spacing: -0.02em; margin: 6px 0 4px; }
.article .orig { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.summary { font-size: 15.5px; line-height: 1.7; color: var(--ink); overflow-wrap: anywhere; }
.summary b { font-weight: 650; }
.gallery { display: grid; gap: 12px; margin-top: 22px; }
.gallery figure { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.gallery img { width: 100%; cursor: zoom-in; }

.side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 80px; }
@media (max-width: 900px) { .side { position: static; } }
.side .panel { padding: 18px 18px 16px; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; font-weight: 650; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: 14.5px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 550; }
.note { color: var(--ink-2); font-size: 13.5px; margin: 12px 0 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; width: 100%;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }

/* ---------- Statistik ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--ink-2); font-size: 13.5px; font-weight: 550; }
.kpi .value { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; margin-top: 4px; white-space: nowrap; }
.kpi .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.delta-up { color: var(--good-text); }
.delta-down { color: var(--bad-text); }

.chart-panel { padding: 18px 18px 10px; margin-bottom: 18px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.chart-head h2 { margin: 0; }
.chart-head .hint { color: var(--muted); font-size: 13px; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: 280px; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .base-line { stroke: var(--axis); stroke-width: 1; }
.chart .ref-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .tick { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart .series { stroke: var(--series-1); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--series-1); opacity: .08; }
.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.chart-empty { color: var(--muted); padding: 50px 0 60px; text-align: center; font-size: 14px; }

.table-panel { padding: 6px 0 0; overflow: hidden; }
.table-panel h2 { padding: 12px 18px 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 18px; text-align: left; border-top: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; border-top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--surface-2); }
td a { font-weight: 600; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }
.split { padding: 18px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 44px; gap: 10px; align-items: center; margin: 9px 0; font-size: 14px; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ---------- Tooltip & Lightbox ---------- */
.tooltip {
  position: fixed; z-index: 50; pointer-events: none; padding: 8px 10px; border-radius: 8px;
  background: var(--ink); color: var(--page); font-size: 13px; line-height: 1.4; box-shadow: 0 6px 20px rgba(0,0,0,.18);
  font-variant-numeric: tabular-nums; max-width: 240px;
}
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.82); display: grid; place-items: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; background: #fff; }

.footer { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12.5px; padding-top: 18px; padding-bottom: 28px; border-top: 1px solid var(--line); }

@media (max-width: 560px) {
  .topbar-inner { gap: 12px; }
  .brand-text { display: none; }
  .page-head h1 { font-size: 22px; }
  .article-inner { padding: 18px 16px 22px; }
  .kpi .value { font-size: 24px; }
  .result-count { margin-left: 0; width: 100%; }
}
