:root{
  color-scheme: dark;
  --bg0:#05080c;
  --bg1:#07131a;
  --card: rgba(20, 35, 45, .55);
  --card2: rgba(12, 20, 28, .55);
  --stroke: rgba(255,255,255,.08);
  --text: rgba(255,255,255,.88);
  --muted: rgba(255,255,255,.55);
  --teal: #1ff2d6;
  --teal2:#00b8ff;
  --pink:#ff3fb4;
  --good:#3dff9a;
  --bad:#ff5a6a;
  --shadow: 0 20px 60px rgba(0,0,0,.55);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:var(--text);
  background:
    radial-gradient(900px 500px at 12% 10%, rgba(31,242,214,.18), transparent 60%),
    radial-gradient(900px 500px at 82% 12%, rgba(0,184,255,.14), transparent 60%),
    radial-gradient(900px 700px at 65% 80%, rgba(255,63,180,.10), transparent 60%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

.app{
  min-height:100vh;
  padding:28px;
  display:grid;
  grid-template-columns: 260px 1fr 360px;
  gap:22px;
}
.app.no-right{
  grid-template-columns: 260px 1fr;
}

.glass{
  background: var(--card);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  border-radius: 18px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.sidebar{
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:16px;
}
.brand{
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 12px;
}
.user{
  display:flex; align-items:center; gap:12px;
  padding:10px 12px;
}
.avatar{
  width:38px;height:38px;border-radius:999px;
  background: radial-gradient(circle at 30% 30%, rgba(31,242,214,.7), rgba(0,0,0,.1));
  border:1px solid var(--stroke);
}
.user small{color:var(--muted); display:block; margin-top:2px}

.nav a{
  display:flex; gap:10px; align-items:center;
  padding:10px 12px;
  text-decoration:none;
  color:var(--text);
  border-radius:12px;
  border:1px solid transparent;
}
.nav a:hover{
  border-color: var(--stroke);
  background: rgba(255,255,255,.04);
}
.nav a.active{
  background: rgba(31,242,214,.08);
  border-color: rgba(31,242,214,.20);
}

.main{
  display:flex;
  flex-direction:column;
  gap:18px;
  min-width:0;
}
.topbar{
  padding:14px 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.chips{display:flex; gap:10px; flex-wrap:wrap}
.chip{
  padding:8px 10px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.03);
  color:var(--muted);
  font-size:13px;
}
.search{
  flex:0 0 260px;
  display:flex; align-items:center; gap:10px;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.15);
}
.search input{
  width:100%;
  background:transparent;
  border:0;
  outline:0;
  color:var(--text);
}

.h1{font-size:22px; margin:0 0 4px 0}
.sub{color:var(--muted); font-size:13px}

.grid3{
  display:grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap:14px;
}
.card{
  padding:14px;
}
.cardhead{
  display:flex; justify-content:space-between; align-items:flex-start; gap:10px;
  margin-bottom:10px;
}
.kicker{font-size:12px; color:var(--muted)}
.big{font-size:26px; font-weight:700; margin-top:6px}
.badge{
  font-size:12px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.03);
  color:var(--muted);
}
.spark{height:54px; margin-top:10px}

.tablecard{padding:14px; overflow-x:auto;}
.tablehead{
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:10px;
}
table{
  width:100%;
  border-collapse: collapse;
  font-size:13px;
}
th,td{padding:10px 8px; border-bottom:1px solid rgba(255,255,255,.06)}
th{color:var(--muted); font-weight:600; text-align:left}
tr:hover td{background: rgba(255,255,255,.02)}
tbody tr:nth-child(even) td{background: rgba(255,255,255,.015)}
td a{color: var(--teal2); text-decoration:none}
td a:hover{color: var(--teal); text-decoration:underline}
td small, th small{color:var(--muted); font-weight:400}
.pill{
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--stroke);
  font-size:12px;
  display:inline-block;
}
.pill.good{color:var(--good); border-color: rgba(61,255,154,.18); background: rgba(61,255,154,.06)}
.pill.bad{color:var(--bad); border-color: rgba(255,90,106,.18); background: rgba(255,90,106,.06)}

.right{
  display:flex;
  flex-direction:column;
  gap:18px;
  min-width:0;
}
.right .card{background: var(--card2)}
.btn{
  display:inline-flex; align-items:center; justify-content:center;
  border-radius:12px;
  border:1px solid rgba(31,242,214,.25);
  background: rgba(31,242,214,.10);
  color:var(--text);
  padding:10px 12px;
  text-decoration:none;
  font-weight:600;
}
.btn:hover{background: rgba(31,242,214,.14)}

/* === Card Hover Animation === */
.card,
.tablecard,
.sidebar,
.right .card {
  transition:
    transform .35s cubic-bezier(.2,.8,.2,1),
    box-shadow .35s cubic-bezier(.2,.8,.2,1),
    border-color .35s ease;
}

.card:hover,
.tablecard:hover,
.right .card:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow:
    0 30px 80px rgba(0,0,0,.65),
    0 0 0 1px rgba(31,242,214,.15),
    0 0 40px rgba(31,242,214,.18);
  border-color: rgba(31,242,214,.35);
}

/* === Top Asset Special Glow === */
.top-asset {
  position: relative;
  overflow: hidden;
}

.top-asset::before {
  content:'';
  position:absolute;
  inset:-1px;
  border-radius:18px;
  background:
    linear-gradient(
      120deg,
      transparent 30%,
      rgba(31,242,214,.35),
      rgba(0,184,255,.25),
      transparent 70%
    );
  opacity:0;
  transition: opacity .4s ease;
  pointer-events:none;
}

.top-asset:hover::before {
  opacity:1;
}

/* === Table Row Interaction === */
tbody tr {
  transition:
    background .25s ease,
    transform .25s ease;
}

tbody tr:hover {
  background: linear-gradient(
    90deg,
    rgba(31,242,214,.08),
    rgba(255,255,255,.02)
  );
  transform: translateX(4px);
}

/* === Performance Glow === */
.percent-positive {
  color: var(--good);
  text-shadow: 0 0 12px rgba(61,255,154,.35);
}

.percent-negative {
  color: var(--bad);
  text-shadow: 0 0 12px rgba(255,90,106,.35);
}

.card:hover .percent-positive {
  animation: pulseGreen 1.6s infinite alternate;
}
.card:hover .percent-negative {
  animation: pulseRed 1.6s infinite alternate;
}

@keyframes pulseGreen {
  from { text-shadow: 0 0 6px rgba(61,255,154,.3); }
  to   { text-shadow: 0 0 16px rgba(61,255,154,.6); }
}

@keyframes pulseRed {
  from { text-shadow: 0 0 6px rgba(255,90,106,.3); }
  to   { text-shadow: 0 0 16px rgba(255,90,106,.6); }
}

/* === Sparkline Micro Animation === */
.spark {
  transition: transform .35s ease, filter .35s ease;
}

.card:hover .spark {
  transform: translateY(-2px);
  filter: drop-shadow(0 0 10px rgba(31,242,214,.45));
}

.nav a {
  position: relative;
  overflow: hidden;
}

.nav a::after {
  content:'';
  position:absolute;
  left:-100%;
  top:0;
  width:100%;
  height:100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(31,242,214,.15),
    transparent
  );
  transition: left .5s ease;
}

.nav a:hover::after {
  left:100%;
}

/* ===== Sidebar Menu (refactored menu.php) ===== */
.sidebar-menu{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.menu-link{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius:12px;
  color:var(--text);
  text-decoration:none;
  border:1px solid transparent;
  background:transparent;
  cursor:pointer;
}

.menu-link:hover{
  border-color:var(--stroke);
  background:rgba(255,255,255,.04);
}

.menu-link.active{
  background: rgba(31,242,214,.08);
  border-color: rgba(31,242,214,.20);
}

.menu-link.danger{
  margin-top:10px;
  color:var(--bad);
}

.menu-subpanel{
  display:none;
  margin:6px 0 10px 14px;
  padding:10px 12px;
  border-radius:12px;
  background:rgba(255,255,255,.03);
  border:1px solid var(--stroke);
}

.menu-subpanel.open{
  display:block;
}

.menu-subpanel a{
  display:block;
  padding:6px 0;
  color:var(--text);
  text-decoration:none;
  font-size:13px;
}

.menu-subpanel a:hover{
  text-decoration:underline;
}

/* ===== Button-Varianten ===== */
.btn-sm{ padding:6px 10px; font-size:13px; }
.btn-secondary{ border-color: var(--stroke); background: rgba(255,255,255,.04); }
.btn-secondary:hover{ background: rgba(255,255,255,.08); }
.btn-danger{ border-color: rgba(255,90,106,.35); background: rgba(255,90,106,.08); color: var(--bad); }
.btn-danger:hover{ background: rgba(255,90,106,.16); }

/* ===== Formularelemente ===== */
input[type="text"], input[type="date"], input[type="number"],
input[type="email"], input[type="password"], select, textarea{
  padding:8px 10px;
  border-radius:10px;
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.15);
  color: var(--text);
  font-family: inherit;
  font-size:14px;
}
textarea{ width:100%; resize:vertical; }

/* ===== Eigenständige Formulare (Grid statt <br>-Layout) ===== */
.form-field{
  display:block;
  margin-bottom:14px;
}
.form-field > label{
  display:block;
  margin-bottom:6px;
  font-size:13px;
  color: var(--muted);
}
.form-field input[type="text"],
.form-field input[type="date"],
.form-field input[type="number"],
.form-field select{
  width:100%;
  max-width:360px;
}
.form-row{
  display:flex;
  gap:16px;
  flex-wrap:wrap;
}
.form-row .form-field{
  flex:1 1 180px;
  min-width:160px;
}
.form-field.checkbox-field{
  display:flex;
  align-items:center;
  gap:8px;
}
.form-field.checkbox-field input{ width:auto; }
button{ font-family:inherit; }
button:not([class]){
  padding:8px 12px;
  border-radius:10px;
  border:1px solid rgba(31,242,214,.25);
  background: rgba(31,242,214,.10);
  color:var(--text);
  cursor:pointer;
}
button:not([class]):hover{ background: rgba(31,242,214,.14); }

/* ===== Hover-Tooltip (z. B. Formel-Erklärungen) ===== */
.tooltip{
  position:relative;
  display:inline-block;
  cursor:help;
  border-bottom:1px dotted var(--muted);
}
.tooltip .tooltiptext{
  visibility:hidden;
  opacity:0;
  width:220px;
  background: rgba(12,20,28,.96);
  color: var(--text);
  border:1px solid var(--stroke);
  text-align:left;
  border-radius:10px;
  padding:10px 12px;
  position:absolute;
  z-index:10;
  bottom:130%;
  left:50%;
  margin-left:-110px;
  transition: opacity .2s ease;
  font-size:.85em;
  font-weight:400;
}
.tooltip:hover .tooltiptext{
  visibility:visible;
  opacity:1;
}

/* ===== Sparplan-Badge ===== */
.sparplan-label{
  background: rgba(31,242,214,.10);
  color: var(--teal);
  font-size:.75em;
  padding:2px 8px;
  border-radius:999px;
  margin-left:6px;
  display:inline-block;
  border:1px solid rgba(31,242,214,.20);
}

/* ===== Trade-Verlauf: Dividenden-/Split-Zeilen ===== */
.row-dividend td{
  background: rgba(61,255,154,.04);
  color: var(--good);
}
.row-split td{
  background: rgba(255,255,255,.03);
  font-style: italic;
  color: var(--muted);
}

/* ===== Filter-Tabs (Portfolio/Kategorie/Jahr) ===== */
.portfolio-tabs{
  display:flex;
  gap:10px;
  margin: 0 0 14px 0;
  flex-wrap:wrap;
}
.portfolio-tabs a{
  text-decoration:none;
  color: var(--muted);
  padding:8px 14px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.03);
  font-size:13px;
  transition: all .2s ease;
}
.portfolio-tabs a:hover{
  background: rgba(255,255,255,.06);
  color: var(--text);
}
.portfolio-tabs a.active{
  background: rgba(31,242,214,.12);
  border-color: rgba(31,242,214,.30);
  color: var(--teal);
  font-weight:600;
}

/* ===== Dividenden-Status ===== */
.dividend-planned{ color: var(--muted); }
.dividend-other{ color: #ffb020; }

/* ===== Soll/Ist-Abweichung (z. B. Sparplan vs. Zielgewichtung) ===== */
.diff-over{ color: var(--teal2); }

/* ===== Tabs (z. B. Diversifikation) ===== */
.tabs{
  display:flex;
  gap:10px;
  margin-bottom:16px;
  flex-wrap:wrap;
}
.tab-btn{
  padding:8px 14px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.03);
  color: var(--muted);
  cursor:pointer;
  font-size:13px;
  font-family:inherit;
}
.tab-btn:hover{
  background: rgba(255,255,255,.06);
  color: var(--text);
}
.tab-btn.active{
  background: rgba(31,242,214,.12);
  border-color: rgba(31,242,214,.30);
  color: var(--teal);
  font-weight:600;
}
.tab-content{ display:none; }
.tab-content.active{ display:block; }

/* ===== Native <details>-Card (z. B. Positionen pro Kategorie) ===== */
details.card summary{
  cursor:pointer;
  font-weight:600;
  list-style:none;
  margin:-14px -14px 14px -14px;
  padding:14px 16px;
  border-bottom:1px solid var(--stroke);
}
details.card summary::-webkit-details-marker{ display:none; }
details.card summary::before{
  content:'▸';
  display:inline-block;
  margin-right:8px;
  color:var(--muted);
  transition:transform .2s ease;
}
details.card[open] summary::before{ transform:rotate(90deg); }

/* ===== Watchlist-Alarmzeilen ===== */
.warn-low td{ background: rgba(255,90,106,.06); }
.warn-high td{ background: rgba(61,255,154,.06); }

/* ===== Horizontal scrollende Tabellen mit fixierter erster Spalte ===== */
.table-responsive{ width:100%; overflow-x:auto; margin-bottom:1em; }
.table-responsive table{ min-width:max-content; }
.table-responsive td:first-child,
.table-responsive th:first-child{
  position: sticky;
  left:0;
  background: var(--card2);
  z-index:1;
}

/* ===== Chart-Container mit fester Höhe (verhindert Chart.js-Aspect-Ratio-Explosion bei voller Content-Breite) ===== */
.chart-container{
  position: relative;
  height: 380px;
}
.chart-container canvas{
  max-width: 100%;
}

/* ===== Ladehinweis (z. B. asynchron nachladende KI-Antworten) ===== */
.ai-loading{
  animation: aiPulse 1.6s ease-in-out infinite;
}
@keyframes aiPulse{
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}

/* ===== Stale price indicator ===== */
.old-price{
  color: var(--bad);
  font-weight:600;
}
.old-price::after{
  content: " ⚠";
}
.closed-asset{
  color: var(--muted);
  font-style: italic;
}

/* ===== Role badge (admin_users.php) ===== */
.role-badge{
  display:inline-block;
  padding:2px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:600;
}
.role-badge.role-admin{ background:rgba(31,242,214,.15); color:var(--teal); }
.role-badge.role-user{ background:rgba(255,255,255,.08); color:var(--muted); }

/* ===== Status badge variants (ai_summary.php) ===== */
.badge.good{ background: rgba(61,255,154,.12); border-color: rgba(61,255,154,.30); color: var(--good); }
.badge.warn{ background: rgba(255,204,102,.12); border-color: rgba(255,204,102,.30); color: #ffcc66; }
.badge.bad{ background: rgba(255,90,106,.12); border-color: rgba(255,90,106,.30); color: var(--bad); }

/* ===== Responsive: hide secondary columns on narrow screens ===== */
@media (max-width: 720px){
  .hide-sm{ display:none; }
}

/* ===== Collapsible notice boxes (Watchlist-Warnungen, IPO, Erinnerungen, Heatmap) ===== */
.notice{
  padding:14px 16px;
  border-left:3px solid var(--stroke);
  margin-bottom:14px;
}
.notice-toggle{
  display:flex;
  align-items:center;
  justify-content:space-between;
  width:100%;
  background:transparent;
  border:0;
  cursor:pointer;
  color:var(--text);
  font-weight:600;
  font-size:14px;
  padding:0;
  font-family: inherit;
}
.notice-toggle::after{
  content:'▸';
  color:var(--muted);
  transition: transform .2s ease;
}
.notice.open .notice-toggle::after{
  transform: rotate(90deg);
}
.notice-body{
  display:none;
  margin-top:12px;
}
.notice.open .notice-body{
  display:block;
}
.notice-warn{ border-left-color:#ffcc66; }
.notice-warn .notice-toggle{ color:#ffcc66; }
.notice-info{ border-left-color: var(--teal2); }
.notice-info .notice-toggle{ color: var(--teal2); }
.notice-success{ border-left-color: var(--good); }
.notice-success .notice-toggle{ color: var(--good); }
.notice-neutral{ border-left-color: var(--teal); }
.notice-danger{ border-left-color: var(--bad); }
.notice-danger .notice-toggle{ color: var(--bad); }
.notice-neutral .notice-toggle{ color: var(--teal); }

/* ===== Mobile: Topbar mit Hamburger + Off-Canvas-Sidebar ===== */
.mobile-topbar{
  display:none;
  align-items:center;
  gap:12px;
  padding:12px 16px;
}
.mobile-topbar .hamburger{
  background:transparent;
  border:1px solid var(--stroke);
  border-radius:10px;
  color:var(--text);
  padding:6px 12px;
  font-size:18px;
  line-height:1.4;
  cursor:pointer;
}
.sidebar-backdrop{
  display:none;
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.55);
  z-index:90;
}
.sidebar-backdrop.open{ display:block; }

/* Zwischenstufe: unter ~1200px bleiben von der Hauptspalte neben 260px Sidebar
   und 360px Panel nur gut 200px uebrig - Tabellen und Filter sind dort nicht
   mehr lesbar. Das rechte Panel rutscht deshalb unter den Inhalt, statt ihn
   zusammenzuquetschen. */
@media (min-width: 901px) and (max-width: 1200px){
  .app{
    grid-template-columns: 260px minmax(0, 1fr);
  }
  .app > .sidebar{ grid-row: 1 / -1; }
  .app > .main,
  .app > .right{ grid-column: 2; }
  /* Voll ausgestreckt saehen die schmalen Panel-Karten verloren aus. */
  .app > .right{
    display:grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content:start;
  }
}

@media (max-width: 900px){
  .app, .app.no-right{
    grid-template-columns: 1fr;
    padding:16px;
    gap:16px;
  }
  .mobile-topbar{ display:flex; }
  .sidebar{
    position:fixed;
    top:0; left:0;
    height:100vh;
    width:260px;
    max-width:80vw;
    z-index:100;
    border-radius:0;
    overflow-y:auto;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.open{
    transform: translateX(0);
  }
  .grid3{
    grid-template-columns: 1fr;
  }
}

