/* CR2IQ V3 — Theme System */
:root {
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout-Dimensions */
  --topbar-height: 60px;
  --sidebar-width: 240px;
  --activity-width: 320px;
}

:root,
:root[data-theme="light"] {
  --bg: #f5f7fa;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-overlay: rgba(0, 0, 0, 0.04);
  --text: #1a1f2e;
  --text-muted: #5a6478;
  --text-faint: #8a92a6;
  --border: #e4e8ef;
  --border-strong: #c9d0db;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --band-low: #10b981;
  --band-moderate: #3b82f6;
  --band-elevated: #f59e0b;
  --band-high: #f97316;
  --band-critical: #ef4444;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
}

:root[data-theme="dark"] {
  --bg: #0a0d14;
  --bg-elevated: #131720;
  --bg-card: #1a1f2a;
  --bg-overlay: rgba(255, 255, 255, 0.04);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --border: #232a36;
  --border-strong: #3a4151;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft: rgba(129, 140, 248, 0.15);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --band-low: #34d399;
  --band-moderate: #60a5fa;
  --band-elevated: #fbbf24;
  --band-high: #fb923c;
  --band-critical: #f87171;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
}

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

html {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  transition: background var(--transition), color var(--transition);
}

body {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--activity-width);
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "topbar topbar topbar"
    "sidebar main activity";
  gap: 0;
  transition: grid-template-columns var(--transition);
}

body.activity-hidden {
  grid-template-columns: var(--sidebar-width) 1fr 0;
}
body.activity-hidden .activity-panel { display: none; }

a { color: var(--accent); text-decoration: none; }
button { font: inherit; background: none; border: none; cursor: pointer; color: inherit; }

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: 0 var(--space-5);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar__left { display: flex; align-items: center; }
.topbar__right { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }

.logo {
  display: flex; align-items: center; gap: var(--space-2);
  font-weight: 700; font-size: 1.05rem;
  color: var(--text);
}
.logo__mark { color: var(--accent); font-size: 1.4rem; }
.logo__version {
  font-size: 0.65rem;
  background: var(--accent);
  color: white;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  margin-left: 4px;
  font-weight: 600;
}

/* Quick-Stats Pills (Immer sichtbar) */
.topbar__stats {
  display: flex;
  gap: var(--space-2);
  flex: 1;
  margin-left: var(--space-5);
}
.stat-pill {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  transition: all var(--transition);
  cursor: pointer;
}
.stat-pill:hover { border-color: var(--accent); background: var(--accent-soft); }
.stat-pill__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 600;
}
.stat-pill__value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat-pill__delta {
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.stat-pill__delta--up { color: var(--success); }
.stat-pill__delta--down { color: var(--danger); }
.stat-pill__delta--neutral { color: var(--text-faint); }

.icon-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  color: var(--text-muted);
  transition: all var(--transition);
  position: relative;
}
.icon-btn:hover { background: var(--bg-overlay); color: var(--text); }
.icon-btn--small { width: 28px; height: 28px; }
.icon-btn__icon { font-size: 1.1rem; }
.command-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: auto;
  padding: 0 var(--space-3);
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 2px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}
.kbd--block {
  display: block;
  width: 100%;
  text-align: left;
  margin: 2px 0;
}

/* Notification-Dropdown */
.notification-wrapper { position: relative; }
.notification-badge {
  position: absolute;
  top: 4px; right: 4px;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: var(--radius-pill);
  display: flex; align-items: center; justify-content: center;
}
.notification-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-height: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.dropdown__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.dropdown__header h3 {
  font-size: 0.9rem;
  font-weight: 600;
}
.notification-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
}
.notification-item {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}
.notification-item:hover { background: var(--bg-overlay); }
.notification-item__icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.9rem;
  flex-shrink: 0;
}
.notification-item__body { flex: 1; }
.notification-item__title { font-weight: 600; font-size: 0.85rem; }
.notification-item__text { color: var(--text-muted); font-size: 0.8rem; margin-top: 2px; }
.notification-item__time { color: var(--text-faint); font-size: 0.7rem; margin-top: 4px; }
.notification-empty {
  padding: var(--space-6);
  text-align: center;
  color: var(--text-faint);
  font-style: italic;
  font-size: 0.85rem;
}

/* Live-Status-Indicator */
.status-indicator {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: var(--radius);
}
.status-indicator__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
  animation: pulse 2s infinite;
}
.status-indicator--stale .status-indicator__dot {
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15);
  animation: none;
}
.status-indicator--error .status-indicator__dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
  animation: none;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  grid-area: sidebar;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  overflow-y: auto;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.sidebar__item:hover {
  background: var(--bg-overlay);
  color: var(--text);
}
.sidebar__item--active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.sidebar__icon { font-size: 1.1rem; flex-shrink: 0; }
.sidebar__label { flex: 1; }
.sidebar__badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-overlay);
  color: var(--text-muted);
}
.sidebar__item--active .sidebar__badge {
  background: var(--accent);
  color: white;
}

.sidebar__divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-3) 0;
}

.sidebar__section { margin-top: var(--space-3); }
.sidebar__heading {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
}

.brain-mini-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-2);
  padding: 0 var(--space-2);
}
.brain-mini {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 1.1rem;
  cursor: pointer;
  position: relative;
  transition: all var(--transition);
}
.brain-mini:hover { transform: translateY(-2px); border-color: var(--accent); }
.brain-mini__pulse {
  position: absolute;
  top: 4px; right: 4px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 2px var(--bg-elevated);
}
.brain-mini__pulse--warning { background: var(--warning); }
.brain-mini__pulse--off { background: var(--text-faint); }

.sidebar__footer {
  margin-top: auto;
  padding: var(--space-3);
  font-size: 0.75rem;
  color: var(--text-faint);
}

/* ── Main Content ────────────────────────────────────────── */
.main {
  grid-area: main;
  padding: var(--space-5) var(--space-6);
  overflow-y: auto;
  height: calc(100vh - var(--topbar-height));
}

/* ── Activity-Panel ──────────────────────────────────────── */
.activity-panel {
  grid-area: activity;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.activity-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.activity-panel__header h3 {
  font-size: 0.9rem;
  font-weight: 600;
}
.activity-panel__list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
}
.activity-item {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius);
  font-size: 0.8rem;
  transition: background var(--transition);
  cursor: pointer;
}
.activity-item:hover { background: var(--bg-overlay); }
.activity-item__icon {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.activity-item__icon--score { background: var(--accent-soft); color: var(--accent); }
.activity-item__icon--brain { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.activity-item__icon--event { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.activity-item__icon--trade { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.activity-item__body { flex: 1; min-width: 0; }
.activity-item__title { font-weight: 600; color: var(--text); }
.activity-item__text {
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.activity-item__time {
  color: var(--text-faint);
  font-size: 0.7rem;
  margin-top: 4px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
}
.btn:hover { background: var(--bg-overlay); }
.btn--primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost { background: transparent; border: none; }
.btn--small { padding: 4px 10px; font-size: 0.75rem; }

/* ── Reduced Motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1100px) {
  body { grid-template-columns: var(--sidebar-width) 1fr; }
  body.activity-hidden { grid-template-columns: var(--sidebar-width) 1fr; }
  .activity-panel { display: none; }
}

@media (max-width: 720px) {
  body { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .sidebar { display: none; }
  .topbar__stats { display: none; }
  .main { padding: var(--space-4); }
}
/* ── WS-E: Honesty-UI (Risiko ≠ Richtung) ─────────────────── */
.honesty-hero {
  max-width: 640px;
  margin: 2rem auto;
  padding: 2rem;
  text-align: center;
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 16px;
  background: var(--surface, #16181d);
}
.honesty-hero__score {
  font-family: var(--font-mono, monospace);
  font-size: 4rem;
  font-weight: 700;
  line-height: 1;
}
.honesty-hero__score[data-band="Critical"] { color: var(--danger, #ef4444); }
.honesty-hero__score[data-band="High"] { color: #f97316; }
.honesty-hero__score[data-band="Elevated"] { color: var(--warning, #f59e0b); }
.honesty-hero__score[data-band="Moderate"] { color: #3b82f6; }
.honesty-hero__score[data-band="Low"] { color: var(--success, #10b981); }
.honesty-hero__max { font-size: 1.5rem; color: var(--text-muted, #888); }
.honesty-hero__band { margin-top: .25rem; color: var(--text-muted, #888); font-size: .95rem; }
.honesty-hero__disclaimer {
  margin: 1rem 0;
  padding: .6rem .9rem;
  border-radius: 10px;
  background: rgba(245, 158, 11, .12);
  color: var(--warning, #f59e0b);
  font-size: .9rem;
}
.honesty-chips { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.honesty-chip {
  font-family: var(--font-mono, monospace);
  font-size: .8rem;
  padding: .35rem .7rem;
  border-radius: 999px;
  border: 1px solid var(--border, #2a2a2a);
  color: var(--text, #ddd);
}
.honesty-trend { margin-top: 1rem; font-size: .85rem; color: var(--text-muted, #888); }
