/* ============================================================================
   XBRL Data Explorer (BI) — baut auf justreporting-design-system.css auf.
   ============================================================================ */
:root {
  --chart-1: var(--jr-finance);
  --chart-2: var(--jr-primary);
  --chart-3: #7C3AED;
  --chart-4: #64748B;
  --sidebar-w: 280px;
  --header-h: 64px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font-body); font-size: var(--text-body); line-height: 1.5;
  letter-spacing: var(--tracking-normal); color: var(--text-primary); background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 700; letter-spacing: var(--tracking-tight); margin: 0; }
.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); }

/* Header */
.app-header {
  position: sticky; top: 0; z-index: 60; height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-2xl); border-bottom: 1px solid var(--border-light);
}
.brand { display: flex; align-items: center; gap: var(--space-md); }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-md); color: white; background: var(--jr-finance-gradient); box-shadow: var(--jr-finance-shadow); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--font-heading); font-weight: 800; font-size: 16px; }
.brand-sub { font-size: var(--text-xs); color: var(--text-muted); }
.header-actions { display: flex; align-items: center; gap: var(--space-md); }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--border-light); border-radius: var(--radius-md); background: var(--bg-elevated); color: var(--text-secondary); cursor: pointer; transition: transform var(--jr-duration-fast) var(--jr-ease-out); }
.icon-btn:hover { transform: translateY(-2px); color: var(--text-primary); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
.pill-count { padding: 5px 14px; border-radius: var(--radius-pill); background: var(--jr-finance-bg); color: var(--jr-finance); font-size: var(--text-sm); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Layout */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; align-items: start; }
.filters {
  position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h));
  overflow-y: auto; padding: var(--space-2xl); border-right: 1px solid var(--border-light);
  background: var(--bg-elevated);
}
.filters-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-lg); }
.filters-head h2 { font-size: var(--text-title); }
.link-btn { background: none; border: none; color: var(--jr-primary-text); font-weight: 600; font-size: var(--text-sm); cursor: pointer; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.search-field { position: relative; display: flex; align-items: center; margin-bottom: var(--space-lg); }
.search-field svg { position: absolute; left: 12px; color: var(--text-tertiary); pointer-events: none; }
.search-field .input { padding-left: 36px; }
.input { width: 100%; padding: var(--space-sm) var(--space-md); font-size: var(--text-caption); font-family: var(--font-body); border: 1.5px solid var(--border-light); border-radius: var(--radius-md); background: var(--bg-elevated); color: var(--text-primary); }
.input:focus { outline: none; border-color: var(--jr-finance); }
.select { cursor: pointer; }

/* Filter groups */
.fgroup { border-top: 1px solid var(--border-light); padding: var(--space-md) 0; }
.fgroup-head { display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; font-weight: 600; font-size: var(--text-caption); }
.fgroup-head .chev { transition: transform var(--jr-duration-fast); color: var(--text-tertiary); }
.fgroup.collapsed .chev { transform: rotate(-90deg); }
.fgroup.collapsed .fgroup-body { display: none; }
.fgroup-body { margin-top: var(--space-sm); max-height: 220px; overflow-y: auto; }
.fopt { display: flex; align-items: center; gap: var(--space-sm); padding: 4px 2px; font-size: var(--text-caption); cursor: pointer; border-radius: var(--radius-sm); }
.fopt:hover { background: var(--bg-secondary); }
.fopt input { accent-color: var(--jr-finance); cursor: pointer; }
.fopt .lbl { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fopt .cnt { color: var(--text-tertiary); font-variant-numeric: tabular-nums; font-size: var(--text-xs); }
.fopt.zero { opacity: 0.4; }

/* Content */
.content { padding: var(--space-2xl) var(--space-3xl); min-width: 0; max-width: 1280px; }
.kpi-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--space-md); margin-bottom: var(--space-2xl); }
.kpi { background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: var(--space-lg) var(--space-xl); box-shadow: var(--shadow-xs); }
.kpi-value { font-family: var(--font-heading); font-weight: 800; font-size: 24px; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--text-muted); font-size: var(--text-xs); margin-top: 2px; }

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-bottom: var(--space-xl); border-bottom: 1px solid var(--border-light); }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: var(--space-md) var(--space-lg); border: none; background: none; color: var(--text-secondary); font-weight: 600; font-size: var(--text-caption); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--jr-finance); border-bottom-color: var(--jr-finance); }

/* Panels / cards */
.card { background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius-xl); padding: var(--space-2xl); box-shadow: var(--shadow-sm); margin-bottom: var(--space-xl); }
.card h3 { font-size: var(--text-headline); }
.card .sub { color: var(--text-muted); font-size: var(--text-caption); margin: 2px 0 var(--space-lg); }
.controls { display: flex; flex-wrap: wrap; gap: var(--space-md); align-items: end; margin-bottom: var(--space-lg); }
.ctrl { display: flex; flex-direction: column; gap: 4px; }
.ctrl label { font-size: var(--text-xs); color: var(--text-muted); font-weight: 600; }
.ctrl .input { min-width: 150px; }
.btn-mini { padding: var(--space-sm) var(--space-lg); border-radius: var(--radius-md); border: 1px solid var(--border-light); background: var(--bg-elevated); color: var(--text-secondary); font-weight: 600; font-size: var(--text-caption); cursor: pointer; }
.btn-mini:hover { color: var(--text-primary); border-color: var(--text-tertiary); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-light); border-radius: var(--radius-lg); }
table.data { width: 100%; border-collapse: collapse; font-size: var(--text-caption); }
table.data th { position: sticky; top: 0; background: var(--bg-secondary); color: var(--text-secondary); font-weight: 600; font-size: var(--text-sm); text-align: left; padding: var(--space-sm) var(--space-md); white-space: nowrap; cursor: pointer; user-select: none; }
table.data th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data th .arrow { color: var(--jr-finance); }
table.data td { padding: var(--space-sm) var(--space-md); border-top: 1px solid var(--border-light); white-space: nowrap; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: var(--bg-secondary); }
.cell-name { font-weight: 600; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 600; }
.tag.SEC { background: var(--jr-finance-bg); color: var(--jr-finance); }
.tag.ESEF { background: rgba(39,193,63,.12); color: var(--jr-primary-dark); }
.tag.flag { background: var(--color-error-bg); color: var(--color-error); }

/* Pivot heatmap */
.heat td.val { position: relative; color: var(--text-primary); text-align: right; }
.heat td .heatbar { position: absolute; inset: 0; opacity: 0.16; background: var(--jr-finance); z-index: 0; }
.heat td span { position: relative; z-index: 1; }

/* Charts */
svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
.axis-text { fill: var(--text-muted); font-size: 11px; font-family: var(--font-body); }
.grid-line { stroke: var(--border-light); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-lg); margin-top: var(--space-md); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--text-secondary); }
.legend-sw { width: 12px; height: 12px; border-radius: 3px; }
.dot { cursor: pointer; transition: opacity var(--jr-duration-fast); }
.dot:hover { opacity: 0.7; }

/* Drawer (drill-down) */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 80; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(520px, 92vw); z-index: 90; background: var(--bg-elevated); border-left: 1px solid var(--border-light); box-shadow: var(--shadow-xl); overflow-y: auto; padding: var(--space-2xl); animation: slideIn var(--jr-duration-moderate) var(--jr-ease-out); }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: none; } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-lg); }
.drawer-title { font-size: var(--text-title); font-weight: 800; }
.drawer-id { color: var(--text-muted); font-size: var(--text-caption); margin-top: 2px; }
.drawer-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); margin-bottom: var(--space-xl); }
.dm { background: var(--bg-secondary); border-radius: var(--radius-md); padding: var(--space-md); }
.dm .v { font-family: var(--font-heading); font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.dm .l { color: var(--text-muted); font-size: var(--text-xs); }
.src-link { display: inline-flex; align-items: center; gap: 4px; color: var(--jr-finance); text-decoration: none; font-size: var(--text-sm); font-weight: 600; }
.src-link:hover { text-decoration: underline; }

/* Tooltip */
.chart-tooltip { position: fixed; z-index: 100; pointer-events: none; opacity: 0; transform: translate(-50%, -120%); transition: opacity var(--jr-duration-fast); background: var(--text-primary); color: var(--bg-elevated); padding: 8px 12px; border-radius: var(--radius-md); font-size: var(--text-sm); box-shadow: var(--shadow-lg); white-space: nowrap; }
.chart-tooltip.show { opacity: 1; }
.chart-tooltip b { font-weight: 700; }

/* Regime switch */
.regime-bar { display: flex; gap: var(--space-md); margin-bottom: var(--space-xl); }
.regime-btn { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; padding: var(--space-md) var(--space-xl); border: 1.5px solid var(--border-light); border-radius: var(--radius-lg); background: var(--bg-elevated); color: var(--text-secondary); cursor: pointer; transition: all var(--jr-duration-fast) var(--jr-ease-out); }
.regime-btn:hover { transform: translateY(-2px); }
.regime-btn.active { border-color: var(--jr-finance); background: var(--jr-finance-bg); color: var(--jr-finance); }
.regime-btn .rg-name { font-family: var(--font-heading); font-weight: 800; font-size: var(--text-headline); }
.regime-btn .rg-sub { font-size: var(--text-xs); color: var(--text-muted); }
.regime-btn.active .rg-sub { color: var(--jr-finance); }

/* Compare picker */
.compare-picker { position: relative; max-width: 420px; margin-bottom: var(--space-md); }
.picker-list { position: absolute; z-index: 20; top: 100%; left: 0; right: 0; background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); max-height: 240px; overflow-y: auto; margin-top: 4px; }
.picker-list:empty { display: none; }
.picker-item { padding: var(--space-sm) var(--space-md); font-size: var(--text-caption); cursor: pointer; }
.picker-item:hover { background: var(--bg-secondary); }
.picker-item .src { color: var(--text-tertiary); font-size: var(--text-xs); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-bottom: var(--space-lg); }
.chip-sel { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border-radius: var(--radius-pill); background: var(--bg-secondary); font-size: var(--text-caption); font-weight: 600; }
.chip-sel button { display: grid; place-items: center; width: 18px; height: 18px; border: none; border-radius: 50%; background: var(--bg-tertiary); color: var(--text-secondary); cursor: pointer; font-size: 12px; line-height: 1; }
.chip-sel button:hover { background: var(--color-error-bg); color: var(--color-error); }
.cmp-note { display: flex; gap: var(--space-md); align-items: flex-start; background: var(--color-info-bg); border: 1px solid rgba(0,119,204,.2); border-radius: var(--radius-md); padding: var(--space-md); margin-bottom: var(--space-lg); color: var(--text-secondary); font-size: var(--text-caption); }
.minibar-wrap { position: relative; height: 18px; background: var(--bg-secondary); border-radius: 4px; overflow: hidden; min-width: 90px; }
.minibar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--jr-finance); opacity: 0.8; border-radius: 4px; }
.minibar-neg { background: var(--color-error); }

/* Zugangs-Gate (nur im Deploy aktiv) */
.gate-overlay { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; background: var(--bg-primary); padding: var(--space-xl); }
.gate-card { width: min(380px, 92vw); background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); padding: var(--space-4xl) var(--space-3xl); text-align: center; display: flex; flex-direction: column; gap: var(--space-md); }
.gate-mark { width: 56px; height: 56px; margin: 0 auto var(--space-sm); display: grid; place-items: center; border-radius: var(--radius-lg); background: var(--jr-finance-gradient); color: white; box-shadow: var(--jr-finance-shadow); }
.gate-card h1 { font-size: var(--text-title); }
.gate-card p { color: var(--text-muted); font-size: var(--text-caption); margin: 0; }
.gate-input { padding: var(--space-md); font-size: var(--text-headline); text-align: center; letter-spacing: 0.3em; border: 1.5px solid var(--border-light); border-radius: var(--radius-md); background: var(--bg-elevated); color: var(--text-primary); font-family: var(--font-mono); }
.gate-input:focus { outline: none; border-color: var(--jr-finance); }
.gate-btn { padding: var(--space-md); border: none; border-radius: var(--radius-md); background: var(--jr-finance-gradient); color: white; font-weight: 600; font-size: var(--text-body); cursor: pointer; box-shadow: var(--jr-finance-shadow); }
.gate-btn:hover { transform: translateY(-1px); }
.gate-err { color: var(--color-error); font-size: var(--text-caption); font-weight: 600; }
.gate-busy { color: var(--text-muted); font-size: var(--text-caption); }

.bi-footer { margin-top: var(--space-3xl); padding-top: var(--space-xl); border-top: 1px solid var(--border-light); color: var(--text-muted); font-size: var(--text-caption); }
.empty { text-align: center; color: var(--text-muted); padding: var(--space-4xl); }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .filters { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border-light); }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .content { padding: var(--space-xl); }
}
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } }
