/*
  NEURAL DESIGN SYSTEM — monolithisches CSS fuer den gesamten Gemini-/REPLIT-PUSH-Stack.
  Ein File, ueberall injiziert (<link rel="stylesheet" href="/shared/css/neural.css">).

  Herkunft: passend zur bestehenden Genitus-Inc.-Markenwelt (genitus.org, celestiaos.com,
  globalfintech.net) -- dunkles Navy/Schwarz, Cyan-Glow-Akzente, Orbitron fuer Marke/
  Ueberschriften, Inter fuer Fliesstext. Zusaetzlich ein Gold-Akzent-Preset fuer
  Fintech-Tools (siehe GlobalFintech/GoldShield-Branding).

  Struktur dieser Datei:
    1. Tokens (Light + Dark via prefers-color-scheme + data-theme-Override, Gold-Preset)
    2. Reset + Basis-Typografie
    3. Barrierefreiheit (Fokus, prefers-reduced-motion, Skip-Link, sr-only)
    4. Layout: App-Shell, Navbar mit Hamburger/Mobile-Drawer
    5. Komponenten: Buttons, Cards, Inputs, Badges, Chat (Bubble/Input-Bar), Daten-Kacheln,
       Tabellen, Modal, Toast, Spinner
    6. Utilities: Flex/Grid/Spacing/Text
    7. Ambient-Hintergrund (optionales Neural-Node-Canvas, dezent, respektiert reduced-motion)

  Einbindung + Verhalten (Theme-Toggle, Hamburger, Ambient-Canvas): siehe neural.js.
*/

/* ===================================================================
   1. TOKENS
   =================================================================== */
:root {
  /* Typografie */
  --font-display: 'Orbitron', 'Segoe UI', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;

  /* Spacing-Skala */
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
  --space-5: 1.5rem; --space-6: 2rem; --space-7: 2.5rem; --space-8: 3rem; --space-9: 4rem;

  /* Radius / Schatten */
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 16px; --radius-full: 999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.35);
  --glow-accent: 0 0 20px -4px var(--accent-glow);

  /* Type-Skala */
  --text-xs: 0.75rem; --text-sm: 0.85rem; --text-base: 1rem; --text-lg: 1.15rem;
  --text-xl: 1.5rem; --text-2xl: 2rem; --text-3xl: 2.75rem;
  --leading-normal: 1.6; --leading-tight: 1.25;

  /* Breakpoint-Referenz (nur als Kommentar nutzbar, CSS kennt keine Var-Breakpoints) */
  /* mobile: <640px, tablet: 640-1024px, desktop: >1024px */

  --transition-fast: 0.15s ease;
  --transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* ---- Farb-Tokens: Dark ist Standard (Marken-Kern), Light per prefers-color-scheme/data-theme ---- */
  --bg: #060a12;
  --bg-grad: radial-gradient(ellipse at 50% -10%, rgba(34,211,238,0.10), transparent 60%), #060a12;
  --surface: #0d1420;
  --surface-2: #131b2c;
  --surface-hover: #182233;
  --border: rgba(34,211,238,0.16);
  --border-strong: rgba(34,211,238,0.32);
  --text: #e7edf5;
  --text-muted: #a3aec2;
  --text-faint: #7a86a0;

  --accent: #22d3ee;
  --accent-strong: #67e8f9;
  --accent-contrast: #04141a;
  --accent-glow: rgba(34,211,238,0.45);

  --success: #34d399; --success-bg: rgba(52,211,153,0.12);
  --danger: #f87171; --danger-bg: rgba(248,113,113,0.12);
  --warning: #fbbf24; --warning-bg: rgba(251,191,36,0.12);

  color-scheme: dark;
}

/* Light-Theme (OS-Praeferenz) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f7fb;
    --bg-grad: radial-gradient(ellipse at 50% -10%, rgba(8,145,178,0.07), transparent 60%), #f4f7fb;
    --surface: #ffffff;
    --surface-2: #eef2f8;
    --surface-hover: #e3e9f2;
    --border: rgba(8,145,178,0.18);
    --border-strong: rgba(8,145,178,0.34);
    --text: #101826;
    --text-muted: #4b5870;
    --text-faint: #7d879c;

    --accent: #0e7490;
    --accent-strong: #0891b2;
    --accent-contrast: #ffffff;
    --accent-glow: rgba(8,145,178,0.25);

    --success: #059669; --success-bg: rgba(5,150,105,0.10);
    --danger: #dc2626; --danger-bg: rgba(220,38,38,0.10);
    --warning: #b45309; --warning-bg: rgba(180,83,9,0.10);
    color-scheme: light;
  }
}

/* Manuelle Toggle-Overrides (immer staerker als OS-Praeferenz, in beide Richtungen) */
:root[data-theme="dark"] {
  --bg: #060a12;
  --bg-grad: radial-gradient(ellipse at 50% -10%, rgba(34,211,238,0.10), transparent 60%), #060a12;
  --surface: #0d1420; --surface-2: #131b2c; --surface-hover: #182233;
  --border: rgba(34,211,238,0.16); --border-strong: rgba(34,211,238,0.32);
  --text: #e7edf5; --text-muted: #a3aec2; --text-faint: #7a86a0;
  --accent: #22d3ee; --accent-strong: #67e8f9; --accent-contrast: #04141a; --accent-glow: rgba(34,211,238,0.45);
  --success: #34d399; --success-bg: rgba(52,211,153,0.12);
  --danger: #f87171; --danger-bg: rgba(248,113,113,0.12);
  --warning: #fbbf24; --warning-bg: rgba(251,191,36,0.12);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f7fb;
  --bg-grad: radial-gradient(ellipse at 50% -10%, rgba(8,145,178,0.07), transparent 60%), #f4f7fb;
  --surface: #ffffff; --surface-2: #eef2f8; --surface-hover: #e3e9f2;
  --border: rgba(8,145,178,0.18); --border-strong: rgba(8,145,178,0.34);
  --text: #101826; --text-muted: #4b5870; --text-faint: #7d879c;
  --accent: #0e7490; --accent-strong: #0891b2; --accent-contrast: #ffffff; --accent-glow: rgba(8,145,178,0.25);
  --success: #059669; --success-bg: rgba(5,150,105,0.10);
  --danger: #dc2626; --danger-bg: rgba(220,38,38,0.10);
  --warning: #b45309; --warning-bg: rgba(180,83,9,0.10);
  color-scheme: light;
}

/* Gold-Preset (Fintech-Tools, GlobalFintech/GoldShield-Branding) --
   auf <body class="theme-gold"> setzen, ueberschreibt nur den Akzent, Rest bleibt Marken-konsistent. */
.theme-gold {
  --accent: #f5b942;
  --accent-strong: #ffd370;
  --accent-contrast: #241a02;
  --accent-glow: rgba(245,185,66,0.4);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-gold,
  .theme-gold:not([data-theme="dark"]) {
    --accent: #92650c;
    --accent-strong: #a9760f;
    --accent-contrast: #ffffff;
    --accent-glow: rgba(146,101,12,0.25);
  }
}
:root[data-theme="light"] .theme-gold { --accent: #92650c; --accent-strong: #a9760f; --accent-contrast: #ffffff; --accent-glow: rgba(146,101,12,0.25); }
:root[data-theme="dark"] .theme-gold { --accent: #f5b942; --accent-strong: #ffd370; --accent-contrast: #241a02; --accent-glow: rgba(245,185,66,0.4); }

/* ===================================================================
   2. RESET + BASIS-TYPOGRAFIE
   =================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}
h1, h2, h3, .neural-display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: var(--leading-tight);
  text-wrap: balance;
}
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
p { max-width: 68ch; }
a { color: var(--accent-strong); }
a:hover { color: var(--accent); }
img, svg { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }
/* Translucent statt solide Akzentfarbe: die urspruengliche Textfarbe bleibt darunter
   sichtbar, unabhaengig davon, ob der Browser die "color"-Eigenschaft auf ::selection
   zuverlaessig anwendet -- ein solides --accent als Hintergrund + Textfarben-Swap hatte
   in der Praxis Kontrast-Faelle von 1.5:1-1.7:1 erzeugt, wenn die Textfarbe nicht mitzog. */
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }

/* ===================================================================
   3. BARRIEREFREIHEIT
   =================================================================== */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 2000;
  background: var(--accent); color: var(--accent-contrast);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm);
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { left: var(--space-3); top: var(--space-3); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

:focus-visible {
  outline: 3px solid var(--accent-strong);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===================================================================
   4. LAYOUT: APP-SHELL + NAVBAR
   =================================================================== */
.neural-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.neural-navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  padding-top: max(var(--space-3), env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.neural-brand {
  display: flex; align-items: center; gap: var(--space-2);
  font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg);
  color: var(--text); text-decoration: none; letter-spacing: 0.06em; text-transform: uppercase;
}
.neural-brand:hover { color: var(--text); }
.neural-brand .brand-mark {
  width: 2rem; height: 2rem; border-radius: var(--radius-full);
  border: 2px solid var(--accent); display: flex; align-items: center; justify-content: center;
  color: var(--accent); box-shadow: var(--glow-accent); flex-shrink: 0;
}
.neural-brand .brand-accent { color: var(--accent); }

.neural-nav-links { display: flex; align-items: center; gap: var(--space-5); list-style: none; margin: 0; padding: 0; }
.neural-nav-links a {
  color: var(--text-muted); text-decoration: none; font-size: var(--text-sm); font-weight: 500;
  padding: var(--space-2) 0; border-bottom: 2px solid transparent; transition: color var(--transition-fast), border-color var(--transition-fast);
}
.neural-nav-links a:hover, .neural-nav-links a.active { color: var(--text); border-bottom-color: var(--accent); }

.neural-burger {
  display: none; width: 2.75rem; height: 2.75rem; border-radius: var(--radius-md);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.neural-burger svg { width: 1.35rem; height: 1.35rem; }

.neural-drawer-overlay {
  display: none; position: fixed; inset: 0; z-index: 150;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(2px);
}
.neural-drawer-overlay.open { display: block; }

@media (max-width: 860px) {
  .neural-nav-links {
    position: fixed; top: 0; right: 0; height: 100vh; height: 100dvh; z-index: 200;
    width: min(78vw, 320px); flex-direction: column; align-items: stretch;
    background: var(--surface); border-left: 1px solid var(--border);
    padding: var(--space-6) var(--space-5); padding-top: max(var(--space-6), env(safe-area-inset-top));
    gap: var(--space-1);
    transform: translateX(100%); transition: transform var(--transition-base);
    overflow-y: auto;
  }
  .neural-nav-links.open { transform: translateX(0); }
  .neural-nav-links a { padding: var(--space-3) var(--space-2); border-bottom: 1px solid var(--border); border-radius: var(--radius-sm); min-height: 44px; display: flex; align-items: center; }
  .neural-nav-links a:hover, .neural-nav-links a.active { background: var(--surface-2); border-bottom: 1px solid var(--border); }
  .neural-burger { display: flex; }
}

.neural-main { flex: 1; width: 100%; }
.neural-container { max-width: 1200px; margin: 0 auto; padding: var(--space-6) var(--space-5); }
@media (max-width: 640px) { .neural-container { padding: var(--space-5) var(--space-4); } }

/* ===================================================================
   5. KOMPONENTEN
   =================================================================== */

/* -- Buttons -- */
.n-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md); border: 1px solid transparent;
  font-family: var(--font-body); font-weight: 600; font-size: var(--text-sm);
  cursor: pointer; text-decoration: none; transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  white-space: nowrap;
}
.n-btn:active { transform: scale(0.97); }
.n-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.n-btn-primary { background: var(--accent); color: var(--accent-contrast); }
.n-btn-primary:hover:not(:disabled) { background: var(--accent-strong); box-shadow: var(--glow-accent); }
.n-btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.n-btn-secondary:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); }
.n-btn-ghost { background: transparent; color: var(--text-muted); }
.n-btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.n-btn-danger { background: var(--danger); color: #fff; }
.n-btn-sm { min-height: 36px; padding: var(--space-2) var(--space-4); font-size: var(--text-xs); }
.n-btn-icon { min-width: 44px; padding: var(--space-2); }

/* -- Cards / Panels -- */
.n-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-5); box-shadow: var(--shadow-sm);
}
.n-card-hover { transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast); }
.n-card-hover:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.n-card-title { font-family: var(--font-display); font-size: var(--text-lg); margin: 0 0 var(--space-2); }
.n-card-desc { color: var(--text-muted); font-size: var(--text-sm); margin: 0; }

/* -- Inputs -- */
.n-field { display: flex; flex-direction: column; gap: var(--space-2); }
.n-label { font-size: var(--text-sm); font-weight: 600; color: var(--text-muted); }
.n-input, .n-textarea, .n-select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-3) var(--space-4);
  color: var(--text); font-size: 16px; /* 16px verhindert Safari-iOS-Auto-Zoom bei Fokus */
  min-height: 44px; transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.n-input:focus, .n-textarea:focus, .n-select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}
.n-input::placeholder, .n-textarea::placeholder { color: var(--text-faint); }
.n-textarea { min-height: 96px; resize: vertical; font-family: var(--font-body); }

/* -- Badges / Pills -- */
.n-badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 3px var(--space-3); border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 600; background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border);
}
.n-badge-accent { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-strong); border-color: transparent; }
.n-badge-success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.n-badge-danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.n-badge-warning { background: var(--warning-bg); color: var(--warning); border-color: transparent; }

/* -- Status-Dot -- */
.n-status { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--text-muted); }
.n-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 8px var(--success); }
.n-status-dot.n-pulse { animation: n-pulse 2s infinite; }
@keyframes n-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* -- Chat: Nachrichtenliste + Bubbles (app-/chatbot-spezifisch) -- */
.n-chat { display: flex; flex-direction: column; height: 100%; }
.n-chat-messages { flex: 1; overflow-y: auto; padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.n-msg-row { display: flex; gap: var(--space-3); max-width: 760px; margin: 0 auto; width: 100%; }
.n-msg-row.n-msg-user { justify-content: flex-end; }
.n-bubble {
  max-width: 82%; padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg);
  line-height: var(--leading-normal); white-space: pre-wrap; font-size: var(--text-base);
}
.n-msg-user .n-bubble { background: var(--accent); color: var(--accent-contrast); border-bottom-right-radius: var(--radius-sm); }
.n-msg-assistant .n-bubble { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: var(--radius-sm); }
.n-avatar {
  width: 2rem; height: 2rem; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-family: var(--font-display);
  font-size: var(--text-xs); font-weight: 700; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--accent-strong);
}

.n-chat-inputbar {
  display: flex; align-items: flex-end; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--surface);
}
.n-chat-inputbar .n-textarea { max-height: 160px; min-height: 44px; }

/* -- Daten-Kacheln (Dashboards/Fintech) -- */
.n-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-4); }
.n-stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-4); }
.n-stat-label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: var(--space-1); }
.n-stat-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--text-xl); font-weight: 700; color: var(--text); }
.n-stat-value.n-up { color: var(--success); } .n-stat-value.n-down { color: var(--danger); }

/* -- Tabellen -- */
.n-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.n-table { font-size: var(--text-sm); }
.n-table th { text-align: left; padding: var(--space-3) var(--space-4); color: var(--text-muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
.n-table td { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }

/* -- Modal -- */
.n-modal-overlay { position: fixed; inset: 0; z-index: 500; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; padding: var(--space-4); }
.n-modal-overlay.open { display: flex; }
.n-modal { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); max-width: 560px; width: 100%; box-shadow: var(--shadow-md); }
.n-modal-header { display: flex; justify-content: space-between; align-items: center; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
.n-modal-body { padding: var(--space-5); }

/* -- Toast -- */
.n-toast-region { position: fixed; bottom: var(--space-5); right: var(--space-5); z-index: 600; display: flex; flex-direction: column; gap: var(--space-2); max-width: min(90vw, 360px); }
.n-toast { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); box-shadow: var(--shadow-md); font-size: var(--text-sm); animation: n-toast-in 0.25s ease; }
@keyframes n-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* -- Spinner -- */
.n-spinner { width: 1.25rem; height: 1.25rem; border: 2.5px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: n-spin 0.7s linear infinite; display: inline-block; }
@keyframes n-spin { to { transform: rotate(360deg); } }

/* ===================================================================
   6. UTILITIES
   =================================================================== */
.n-flex { display: flex; } .n-flex-col { display: flex; flex-direction: column; }
.n-items-center { align-items: center; } .n-justify-between { justify-content: space-between; } .n-justify-center { justify-content: center; }
.n-gap-1{gap:var(--space-1);} .n-gap-2{gap:var(--space-2);} .n-gap-3{gap:var(--space-3);} .n-gap-4{gap:var(--space-4);} .n-gap-5{gap:var(--space-5);}
.n-grid { display: grid; }
.n-w-full { width: 100%; }
.n-text-muted { color: var(--text-muted); } .n-text-sm { font-size: var(--text-sm); } .n-text-xs { font-size: var(--text-xs); }
.n-text-center { text-align: center; }
.n-mt-2{margin-top:var(--space-2);} .n-mt-4{margin-top:var(--space-4);} .n-mb-2{margin-bottom:var(--space-2);} .n-mb-4{margin-bottom:var(--space-4);}
.n-hidden { display: none !important; }
@media (max-width: 640px) { .n-hide-mobile { display: none !important; } }
@media (min-width: 641px) { .n-hide-desktop { display: none !important; } }

/* ===================================================================
   7. AMBIENT NEURAL-HINTERGRUND (optional, per JS aktiviert, siehe neural.js)
   =================================================================== */
.n-ambient-canvas { position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0.5; }
@media (prefers-reduced-motion: reduce) { .n-ambient-canvas { display: none; } }
