/* ═══════════════════════════════════════════════════════════════════
   FIORI.CSS – Design-Tokens für den Umbau auf SAP-Fiori-Horizon-Stil.
   Schritt 1 des Fiori-Umbaus (siehe docs/fiori-entwurf.html als Vorlage).

   Überschreibt NUR die Custom Properties aus shared.css's :root-Block
   (gleiche Variablennamen) - dadurch re-themen sich alle bestehenden
   Komponenten (.card, .btn-*, .inp, Tabellen, KPIs, …), die bereits
   ausschliesslich über var(--...) auf diese Tokens zugreifen, ohne dass
   deren eigenes CSS in shared.css/app.css angefasst werden muss.
   Muss daher NACH shared.css und app.css geladen werden (Ladereihenfolge
   in index.html), damit diese Werte gewinnen.

   Farben/Schatten/Schrift 1:1 aus docs/fiori-entwurf.html übernommen
   (Fiori-Horizon-Palette). "72"/"72full" ist SAP's proprietäre
   Hausschrift - wird hier wie in der Vorlage nur benannt (kein Font-
   Ladevorgang möglich/lizenziert); Browser überspringen sie automatisch
   und fallen auf die System-Schriftkette zurück, wie von SAP selbst so
   vorgesehen, wenn "72" nicht installiert ist. Die zuvor für "Direction
   A" geladene Google-Font Manrope entfällt dafür (siehe index.html).

   Noch NICHT Teil dieses Schritts: Shell Bar / Workflow-Tabs (Rahmen,
   Schritt 2) und die Seiten-für-Seite-Anpassung (Schritt 3) - beides
   folgt in separaten Commits.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* Backgrounds */
  --bg:           #f5f6f7;
  --bg-sidebar:   #ffffff;
  --bg-card:      #ffffff;
  --bg-input:     #eaecee;
  --bg-hover:     #eaecee;
  --bg-active:    #dde0e3;

  /* Text */
  --text:           #1d2d3e;
  --text-secondary: #32465c;
  --text-muted:     #556b82;
  --text-dim:       #7a8ea3;
  --text-on-accent: #ffffff;

  /* Borders (Fiori nutzt durchgehend sichtbare, nicht halbtransparente
     Trennlinien statt des bisherigen weichen rgba-Rahmens) */
  --border:        #d9d9d9;
  --border-light:  #e4e5e6;
  --border-strong: #b9bcc0;

  /* Accent (SAP Fiori "Blue Horizon") */
  --accent:       #0070f2;
  --accent-hover: #0040b0;
  --accent-glow:  rgba(0,112,242,.18);
  --accent-soft:  #ebf8ff;

  /* Status (Fiori Horizon Semantic Colors) */
  --positive:         #256f3a;
  --positive-bg:      #f5fae5;
  --positive-border:  #c2d989;
  --negative:         #aa0808;
  --negative-bg:      #ffeaf4;
  --negative-border:  #e7a3bb;
  --warning:          #e76500;
  --warning-bg:       #fff8d6;
  --warning-border:   #ebcd99;
  --info:             #0070f2;
  --info-bg:          #ebf8ff;
  --info-border:      #9bd1f9;

  /* Radius - Fiori ist flacher/rechtwinkliger als das bisherige "weiche"
     Apple-Design (kleinere Radien, Buttons fast rechteckig). */
  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows - Fiori-Elevation (zwei gestapelte, sehr flache Schatten
     statt eines einzelnen weichen) */
  --shadow-sm: 0 0 .0625rem rgba(34,53,72,.16), 0 .0625rem .125rem rgba(34,53,72,.1);
  --shadow:    0 0 .125rem rgba(34,53,72,.2), 0 .125rem .5rem rgba(34,53,72,.15);
  --shadow-md: 0 0 .125rem rgba(34,53,72,.22), 0 .25rem .75rem rgba(34,53,72,.16);
  --shadow-lg: 0 0 .1875rem rgba(34,53,72,.26), 0 .5rem 1.5rem rgba(34,53,72,.18);
  --shadow-xl: 0 0 .25rem rgba(34,53,72,.3), 0 1rem 2.5rem rgba(34,53,72,.2);

  /* Typography - SAP "72"/"72full" (proprietär, nicht ladbar) mit
     identischer Fallback-Kette wie im Fiori-Entwurf. */
  --font-display: "72", "72full", -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-body:    "72", "72full", -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono:    "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Monaco, Consolas, monospace;

  /* Fiori-spezifischer Zusatz-Token (von shared.css's Tabellen-Sticky-Header
     bereits per var(--topbar-h, 57px) konsumiert) - Shell Bar ist mit 52px
     niedriger als die bisherige Topbar (57px), daher hier überschrieben. */
  --topbar-h: 52px;
  /* Shell Bar UND Seitenkopf (Workflow-Tabs) sind jetzt beide sticky
     (Nutzer-Wunsch) - Tabellen mit eigenem sticky-Header (z.B. Dashboard)
     muessen daher unter BEIDEN einrasten, nicht nur unter der Shell Bar. */
  --content-sticky-top: calc(var(--topbar-h) + 57px);
}

/* ═══════════════════════════════════════════════════════════════════
   FIORI-UMBAU SCHRITT 2: RAHMEN (Shell Bar + Workflow-Tabs)
   Ersetzt die bisherige linke Sidebar + obere Topbar (siehe shared.css,
   dortige Regeln dafür entfernt) durch eine sticky Shell Bar oben
   (Logo, Marktdaten/Backups/Einstellungen) und darunter einen nicht-
   sticky Seitenkopf mit Titel+Aktionen sowie einer horizontalen Icon-
   Tab-Bar für die Haupt-Navigation (vormals Sidebar-Items) - exakt das
   Strukturmuster aus docs/fiori-entwurf.html (.shell / .header / .tabs).
   Die Buttons behalten die Klasse .tab-btn und data-tab-Attribute, damit
   switchTab() in app.js unveraendert funktioniert.
   ═══════════════════════════════════════════════════════════════════ */
#app { min-height: 100vh; }

.shell {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 100;
  background: var(--bg-card);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: var(--topbar-h);
}
.shell-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; white-space: nowrap; font-family: var(--font-display); }
.shell-logo-mark {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.shell-logo-text { display: flex; align-items: baseline; gap: 8px; }
.shell-logo-text small { font-weight: 400; color: var(--text-dim); font-size: 11px; }
.shell-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.shell-icon-btn, .shell-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 15px;
  transition: background .15s, color .15s;
}
.shell-icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.shell-avatar { background: var(--accent-soft); color: var(--accent); border-radius: 50%; }
.shell-avatar:hover { background: var(--accent-glow); }

/* Seitenkopf: nur noch Workflow-Tabs + Aktionen in einer Zeile - der
   bis v3.06 zusaetzlich links stehende <h1>-Seitentitel entfernt
   (Nutzer-Feedback: redundant, der aktive Tab zeigt die aktuelle Seite
   bereits per fett+Unterstrich an; der Titel lebt jetzt stattdessen im
   Browser-Tab-Titel weiter, siehe document.title weiter unten). */
.fiori-header {
  position: sticky;
  top: calc(env(safe-area-inset-top, 0px) + var(--topbar-h));
  z-index: 90;
  background: var(--bg-card);
  padding: 8px 20px;
  box-shadow: 0 1px 0 var(--border);
}
.fiori-header .title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.fiori-header #topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; flex-shrink: 0; margin-left: auto; }

.wf-tabs { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.wf-tabs::-webkit-scrollbar { display: none; }
.wf-tab {
  border: 0; background: transparent;
  padding: 8px 12px 9px;
  display: flex; align-items: center; gap: 7px;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  font-size: 13.5px; font-weight: 500;
  flex: none;
  white-space: nowrap;
}
.wf-tab-icon { font-size: 14px; }
.wf-tab:hover { color: var(--accent); }
.wf-tab.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }

/* Content-Bereich auf grossen Bildschirmen zentrieren (Fiori-Konvention),
   statt wie bisher randlos die volle verbleibende Breite zu fuellen.
   1600px statt 1280px, da 1280px auf breiten Monitoren unnoetig viel
   Leerflaeche links/rechts liess (Shell Bar/Menueband sind bewusst
   randlos - nur der eigentliche Seiteninhalt wird begrenzt). */
.content-area { max-width: 1600px; margin: 0 auto; width: 100%; }
.content-area.content-voll { max-width: none; }   /* alle Seiten ausser Dashboard: ganze Fensterbreite (wie PortfolioWatch v2.60) */

@media (max-width: 768px) {
  .shell { padding: 0 14px; }
  .shell-logo-text small { display: none; }
  .fiori-header { padding: 8px 14px; }
}

/* ═══════════════════════════════════════════════════════════════════
   FIORI-UMBAU SCHRITT 3: SEITE FÜR SEITE
   Komponenten-Feinschliff, der alle Seiten gleichzeitig betrifft (KPI-
   Zahlen, Tabellenköpfe, Kartentitel) - wird hier zentral einmal
   definiert statt auf jeder Seite einzeln nachgezogen, da Dashboard/
   Portfolio/Analyse/etc. alle dieselben .kpi/.card/table-Klassen aus
   shared.css nutzen. Los ging's mit dem Dashboard als erster Seite.
   ═══════════════════════════════════════════════════════════════════ */

/* Fiori-KPI-Zahlen sind duenn (font-weight 300) statt fett - markantes
   SAP-Erkennungsmerkmal (siehe .kpi .val in der Vorlage). */
.kpi-value, .dash-stat-value {
  font-weight: 300;
  font-size: 30px;
  letter-spacing: -.01em;
}

/* Kartentitel etwas groesser/fetter (Fiori-Vorlage: font-size 16px/700). */
.card-title { font-size: 16px; font-weight: 700; }

/* Dezent eingefaerbte KPI-Hintergruende statt reinem Weiss (Nutzer-Wunsch,
   "Variante A" aus docs/fiori-color-varianten.html) - 5%ige Tönung in der
   Akzentfarbe als Standard. Modifier-Klassen .kpi-pos/.kpi-warn/.kpi-neg
   fuer Kacheln mit erkennbar positiver/warnender/kritischer Aussage (z.B.
   Barrierebruch-Risiko) - bislang nicht an bestehende Kacheln angehaengt,
   stehen aber bereit. .card bewusst NICHT eingefaerbt (bleibt die neutrale
   Flaeche fuer Tabellen/Inhalte, nur die "grossen Zahlen"-Kacheln stechen
   farblich hervor). */
.kpi, .dash-stat {
  background: color-mix(in srgb, var(--accent) 5%, var(--bg-card));
}
.kpi-pos  { background: color-mix(in srgb, var(--positive) 5%, var(--bg-card)); }
.kpi-warn { background: color-mix(in srgb, var(--warning)  5%, var(--bg-card)); }
.kpi-neg  { background: color-mix(in srgb, var(--negative) 5%, var(--bg-card)); }

/* Tabellenköpfe in Fiori sind normale Gross-/Kleinschreibung (keine
   Versalien/Letter-Spacing) - ersetzt den "Direction A"-Stil (v2.80). */
table th {
  font-weight: 600;
  font-size: 12px;
  letter-spacing: normal;
  text-transform: none;
  color: var(--text-muted);
}

/* Status-Pills (Fiori .status aus der Vorlage) - ersetzt reinen farbigen
   Text (.risk-low/-med/-high) dort, wo ein Zustand (nicht ein Zahlenwert)
   angezeigt wird, z.B. Portfolio-Status. .status.neutral zusaetzlich (in
   der Vorlage nicht vorhanden) fuer Zwischenzustaende ohne Ampel-Aussage
   (z.B. "vorzeitig (Autocall)", "zum Ende zurück"). */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.status.ok      { color: var(--positive); background: var(--positive-bg); }
.status.cr      { color: var(--warning);  background: var(--warning-bg); }
.status.ng      { color: var(--negative); background: var(--negative-bg); }
.status.neutral { color: var(--text-muted); background: var(--bg-hover); }

/* Meter-Balken (Fiori .meter aus der Vorlage) - fuer Abstandswerte, bei
   denen eine Balkenlaenge die Grössenordnung schneller erfassbar macht
   als die reine Zahl (z.B. Abstand zur Barriere). */
.meter {
  width: 64px;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-hover);
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
  overflow: hidden;
}
.meter i { display: block; height: 100%; }

/* ── Spalten ein-/ausblenden & verschieben (assets/js/tablecols.js) ──
   Urspruengliche Ausrichtung je Zelle festhalten, damit die globale
   :first-child-Linksregel eine verschobene Zahlenspalte nicht umstellt. */
table.cm-table th.cm-l, table.cm-table td.cm-l { text-align: left; }
table.cm-table th.cm-r, table.cm-table td.cm-r { text-align: right; }
table.cm-table th.cm-c, table.cm-table td.cm-c { text-align: center; }
table.cm-table th.cm-dragging { opacity: .4; }
table.cm-table th.cm-drop-before { box-shadow: inset 3px 0 0 var(--accent); }
table.cm-table th.cm-drop-after  { box-shadow: inset -3px 0 0 var(--accent); }
table.cm-table th[draggable="true"] { cursor: grab; }

.cm-menu {
  position: fixed; z-index: 300; width: 250px; max-height: 70vh; overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px 10px;
}
.cm-menu-head { display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; font-weight: 600; color: var(--text-muted); padding: 2px 2px 6px; }
.cm-reset { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.cm-reset:hover { text-decoration: underline; }
.cm-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 0; }
.cm-row label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; cursor: pointer; flex: 1; min-width: 0; }
.cm-move { display: flex; gap: 2px; flex-shrink: 0; }
.cm-move button { border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
  font-size: 10px; padding: 2px 5px; border-radius: var(--radius-sm); }
.cm-move button:hover:not(:disabled) { background: var(--bg-hover); color: var(--accent); }
.cm-move button:disabled { opacity: .25; cursor: default; }

/* Seitenkopf mit Titel, Filtern und "☰ Spalten"-Button bleibt beim Scrollen
   unter Shell Bar + Menüband stehen, die Tabelle scrollt darunter in ihrem
   eigenen Bereich (Tabellenkopf klebt oben am Bereich). Positionen/Risiko-
   Analyse: Kopf liegt in derselben Karte wie die Tabelle; Aufträge/Analysen/
   Cash-Flow: eigene Kopf-Karte. Deren Höhe misst assets/js/misc.js als
   --sticky-head-h, damit die Tabelle genau den Rest der Fensterhöhe füllt.
   (overflow-y:clip aus shared.css wird vom Browser bei overflow-x:auto zu
   "hidden" - die Tabellenköpfe haften daher nie am Fenster, sondern nur
   an einem eigenen Scroll-Bereich.) */
#tab-portfolio > .card > .card-header,
#tab-sellanalysis > .card > .card-header {
  position: sticky; top: var(--content-sticky-top); z-index: 20; background: var(--bg-card);
}
#tab-orders > .card:first-child,
#tab-analysen > .card:first-child,
#tab-cashflow > .card:first-child {
  position: sticky; top: var(--content-sticky-top); z-index: 20;
}
#tab-portfolio .table-wrap, #tab-sellanalysis .table-wrap,
#tab-orders .table-wrap, #tab-analysen .table-wrap, #tab-cashflow .table-wrap,
.table-wrap:has(> table.cm-table) {
  max-height: calc(100vh - var(--content-sticky-top) - var(--sticky-head-h, 0px) - 70px) !important;
  overflow-y: auto !important;
}

/* Shell Bar + Menüband stehen oberhalb von .main - dessen 100vh-Mindesthöhe
   würde die Seite sonst immer um deren Höhe scrollbar machen. */
.main { min-height: calc(100vh - var(--content-sticky-top)); }

/* Chart-Zoom-Dialog (Analyse): Kennzahlen unter dem vergroesserten Kursverlauf */
.cz-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 20px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-light); }
.cz-k { font-size: 11px; color: var(--text-muted); }
.cz-v { font-size: 13px; font-weight: 600; color: var(--text); }

/* Szenarien & Auszahlung (Analyse) */
.scen-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 24px 28px; }
.scen-box { min-width: 0; }
.scen-title { font-size: 13px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; flex-wrap: wrap; }
.scen-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; min-height: 2.6em; }
.scen-chart { position: relative; height: 270px; }

/* Grafik-Ansicht statt Tabelle (Positionen, Risiko-Analyse) */
.chart-view { padding: 12px 20px 20px; overflow-y: auto;
  max-height: calc(100vh - var(--content-sticky-top) - var(--sticky-head-h, 0px) - 70px); }
.chart-view-note { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
#port-chart-inner, #sa-chart-inner { position: relative; }
#sa-chart-inner { height: max(340px, calc(100vh - var(--content-sticky-top) - var(--sticky-head-h, 0px) - 170px)); }

/* Reiter "Vergleich" */
.vg-matrix { overflow-x: auto; }
.vg-table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.vg-table th, .vg-table td { text-align: center; padding: 8px 12px; border-bottom: 1px solid var(--border-light); font-size: 13px; vertical-align: top; min-width: 170px; max-width: 230px; position: static; }
.vg-table .vg-first { position: sticky; left: 0; z-index: 3; background: var(--bg-card); text-align: left; min-width: 230px; max-width: 260px; box-shadow: 1px 0 0 var(--border-light); }
.vg-table thead th { background: var(--bg-card); font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text); }
.vg-table thead th.vg-ex { opacity: .6; }
.vg-lbl { color: var(--text-secondary); font-size: 12.5px; }
.vg-name { font-weight: 700; font-size: 13.5px; white-space: normal; margin-top: 4px; }
.vg-sub { font-size: 11px; color: var(--text-muted); white-space: normal; }
.vg-score { height: 6px; background: var(--bg-hover); border-radius: 3px; overflow: hidden; margin: 6px 0 2px; }
.vg-score i { display: block; height: 100%; background: var(--accent); }
.vg-actions { margin-top: 6px; display: flex; gap: 4px; justify-content: center; }
.vg-grp td { background: var(--bg); font-weight: 700; font-size: 12px; color: var(--text-muted); text-align: left; padding: 6px 12px; position: static; }
.vg-best { background: var(--positive-bg); font-weight: 600; color: var(--positive); }
.vg-worst { background: var(--negative-bg); color: var(--negative); }
.vg-text { font-size: 12px; white-space: normal; text-align: left; }
.vg-sw { font-size: 12px; white-space: normal; text-align: left; }
.vg-pro { color: var(--positive); } .vg-con { color: var(--negative); }
.vg-w { display: inline-block; font-size: 10px; background: var(--bg-hover); color: var(--text-muted); border-radius: 8px; padding: 0 6px; margin-left: 4px; }
.vg-row { cursor: pointer; } .vg-row:hover td { background: var(--bg-hover); } .vg-sel td { background: var(--accent-soft); }
.vg-cfg { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; padding: 4px 20px 18px; }
.vg-cfgtitle { font-weight: 600; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.vg-cfgrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 12.5px; padding: 3px 0; }
.vg-cfgrow select, .vg-cfgrow input[type=number] { width: 110px; }
.vg-ordered td { background: var(--warning-bg); }
.vg-ordered.vg-sel td { background: var(--accent-soft); }

.vg-note { margin: 0 20px 10px; padding: 8px 12px; font-size: 12px; background: var(--warning-bg); color: var(--text); border-radius: var(--radius); border: 1px solid var(--warning-border); }

/* Kontextabhaengige Hilfe */
.help-body { font-size: 13px; line-height: 1.55; }
.help-body h3 { font-size: 13px; font-weight: 700; margin: 14px 0 4px; color: var(--text); }
.help-body h3:first-child { margin-top: 0; }
.help-body p { color: var(--text-muted); margin-bottom: 6px; }
.help-body ul { margin: 0 0 6px 18px; padding: 0; color: var(--text-muted); }
.help-body li { margin-bottom: 4px; }
.help-body strong { color: var(--text); }

/* Untermenue in der Menueleiste (assets/js/tabgroups.js) */
.wf-tab-caret { font-size: 10px; margin-left: 4px; opacity: .7; }
.tabgroup-menu { position: fixed; z-index: 300; min-width: 180px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 4px; }
.tabgroup-menu button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 9px 12px;
  border-radius: var(--radius-sm); font-size: 13.5px; color: var(--text); }
.tabgroup-menu button:hover { background: var(--bg-hover); }
.tabgroup-menu button.active { color: var(--accent); font-weight: 600; background: var(--accent-soft); }

/* Zeitraum-Umschalter direkt im Chart (Analyse: Kursverlauf) */
.chart-range { position: absolute; top: 0; right: 0; z-index: 3; display: inline-flex; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.chart-range button { border: 0; background: transparent; font-size: 11px; padding: 2px 8px; color: var(--text-muted); cursor: pointer; }
.chart-range button + button { border-left: 1px solid var(--border); }
.chart-range button.active { background: var(--accent); color: var(--text-on-accent); }
#chart-zoom-range .chart-range { top: 0; right: 0; }


/* Verdichtete Tabellen (v3.70): weniger Zellen-Polster, Daten (.dt) nie umbrochen.
   Die Vergleichs-Matrix (.vg-table) behält ihr eigenes Polster. */
.dt { white-space: nowrap; font-variant-numeric: tabular-nums; }
.table-wrap table:not(.vg-table) th { padding: 9px 10px; white-space: normal; line-height: 1.25; vertical-align: bottom; }
.table-wrap table:not(.vg-table) td { padding: 8px 10px; }


/* Verdichtete Formulare (v3.72): kleine Felder (Datum, Zahlen) teilen sich eine Zeile,
   statt je ein Drittel/die Hälfte der Breite zu belegen. */
.form-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 14px; margin-bottom: 14px; }
.form-grid-4 > .form-group { margin-bottom: 0; }
@media (max-width: 899px) {
  #tab-analyze .form-row-3 > .form-group:has(#f-underlyings) { grid-column: 1 / -1; }
}
@media (min-width: 900px) {
  #tab-analyze .form-row-3 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  #tab-analyze .form-row-3 > .form-group { grid-column: span 1; }
  #tab-analyze .form-row-3 > .form-group:has(#f-isin),
  #tab-analyze .form-row-3 > .form-group:has(#f-product),
  #tab-analyze .form-row-3 > .form-group:has(#f-emitent),
  #tab-analyze .form-row-3 > .form-group:has(#f-barrier-type),
  #tab-analyze .form-row-3 > .form-group:has(#f-struktur),
  #tab-analyze .form-row-3 > .form-group:has(#f-coupon-freq),
  #tab-analyze .form-row-3 > .form-group:has(#f-underlyings) { grid-column: span 2; }
  #tab-analyze .form-row-3 > .form-group:has(#f-barrier-type) { grid-column: span 3; }
}
@media (max-width: 640px) {
  .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Sortierpfeil nur an der sortierten Spalte (statt ' ↕' an jeder): spart ~14 px je Spalte. */
th.sort-col::after { content: none; }
th.sort-col.sort-asc::after  { content: ' ↑'; }
th.sort-col.sort-desc::after { content: ' ↓'; }

/* iOS/iPadOS-Safari: Datumsfelder haben eine feste Mindestbreite und ragen sonst in die
   Nachbarfelder (Letzter Handel / Rückzahlung überlappen). Dialog etwas breiter, Datumsfelder
   dürfen schrumpfen und brauchen weniger Innenabstand. */
#edit-modal .modal-lg { max-width: 920px; }
.form-grid-4 > .form-group { min-width: 0; }
.form-grid-4 input[type="date"] {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  padding-left: 10px;
  padding-right: 6px;
  -webkit-appearance: none;
  appearance: none;
  min-height: 38px;
}
.form-grid-4 input[type="date"]::-webkit-date-and-time-value { text-align: left; min-width: 0; margin: 0; }
.form-grid-4 input[type="date"]::-webkit-datetime-edit { padding: 0; }

/* Fixierte Spalten (tablecols: pinned) */
th.cm-pin { background: #f6f6f7; }
td.cm-pin { background: var(--bg-card); }
tr:hover td.cm-pin { background: #f7f8f9; }

/* Neuemissionen: Aktionsspalte bleibt rechts sichtbar (Tabelle ist breit und scrollt seitlich) */
#of-table td:last-child, #of-table th:last-child, #os-table td:last-child, #os-table th:last-child { position: sticky; right: 0; z-index: 3; background: var(--bg-card); box-shadow: -1px 0 0 var(--border-light); }
#of-table th:last-child, #os-table th:last-child { background: #f6f6f7; z-index: 9; }
#of-table tr:hover td:last-child, #os-table tr:hover td:last-child { background: #f7f8f9; }
#of-table .col-product { max-width: 260px; }

/* ---------- Trichter (funnel.js) ---------- */
.funnel { display: flex; flex-direction: column; gap: 12px; }
.funnel { gap: 0; }
.funnel-row { display: grid; grid-template-columns: minmax(150px, 34%) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.funnel-cone { padding: 2px 0; display: flex; }
.funnel-seg { flex: 1; min-height: 62px; border: 0; padding: 0; cursor: pointer; background: var(--accent); color: var(--text-on-accent); display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 600; }
.funnel-seg.ok { background: var(--positive); }
.funnel-seg:hover { filter: brightness(1.12); }
.funnel-seg span { pointer-events: none; }
.funnel-label { font-size: 13px; line-height: 1.35; padding: 8px 0; align-self: center; }
.funnel-label b { display: block; font-weight: 600; color: var(--text); }
.funnel-label span { display: block; color: var(--text-muted); font-size: 12px; }
.funnel-label span.funnel-note { margin: 2px 0 0; }
.funnel-note { font-size: 12px; color: var(--text-muted); margin-left: 8px; }
.funnel-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.funnel-chip, .funnel-more { border: 1px solid var(--border); background: var(--bg-card); font-size: 12px; color: var(--text-secondary); cursor: pointer; padding: 1px 7px; line-height: 1.6; }
.funnel-chip { border-radius: var(--radius-sm); }
.funnel-chip:hover { border-color: var(--accent); color: var(--accent); }
#of-funnel-card, #gm-funnel-card, #of-funnel-list, #gs-funnel-list, #of-view-bar, #gs-view-card { scroll-margin-top: calc(var(--content-sticky-top, 110px) + 8px); }
.funnel-chip.top { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.jump-flash { animation: jumpflash 2s ease-out; border-radius: var(--radius-sm); }
@keyframes jumpflash { 0%, 55% { outline: 3px solid var(--accent); outline-offset: 3px; background-color: var(--accent-soft); } 100% { outline: 3px solid transparent; outline-offset: 3px; } }
@media (max-width: 700px) { .funnel-row { grid-template-columns: minmax(110px, 38%) minmax(0, 1fr); gap: 10px; } .funnel-seg { font-size: 16px; } }

/* ---------- Filter-Schaltflaechen in der Titelleiste (funnel.js filterbar) ---------- */
.filterbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 20px; border-top: 1px solid var(--border-light); }
.filterbar-label { font-size: 12px; color: var(--text-muted); margin-right: 2px; }
.filterbtn { border: 1px solid var(--border); background: var(--bg-card); border-radius: var(--radius); padding: 5px 12px; font-size: 13px; color: var(--text-secondary); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.filterbtn:hover { border-color: var(--accent); color: var(--accent); }
.filterbtn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.filterbtn .fcount { background: var(--accent); color: var(--text-on-accent); border-radius: 9px; font-size: 11px; padding: 0 6px; min-width: 18px; text-align: center; line-height: 1.5; font-weight: 600; }
.filterbar-sep { width: 1px; align-self: stretch; background: var(--border-light); margin: 0 4px; }


/* Neuemissionen: Kopf der Ansicht, Abgleich-Status, Zusammenfassung und Tabelle/Top 10 bilden EINE Karte (#of-list-card) */
#of-list-card, #of-view-bar { scroll-margin-top: calc(var(--content-sticky-top, 110px) + 8px); }
#of-list-card #of-status { margin: 0; padding: 12px 20px 0; }
#of-list-card #of-summary { margin: 0; padding: 6px 20px 12px; font-size: 13px; color: var(--text-secondary); }
#of-list-card #of-view-bar { border-bottom: 1px solid var(--border-light); }
#of-list-card #of-view-bar .card-header { border-bottom: 0; }
#of-list-card #of-table-card, #of-list-card #of-top-card { border-top: 1px solid var(--border-light); }
#of-list-card #of-top-card .card { box-shadow: none; border: 0; border-radius: 0; margin: 0 !important; }

/* Kopf einer geoeffneten Trichter-Liste in der Stufenfarbe (funnel.js tint) */
.stage-tint { --tint-fg: #fff; }
#of-view-bar.stage-tint { background: var(--stage-bg); border-bottom: 0; }
#gs-view-card.stage-tint > .card-header { background: var(--stage-bg); border-bottom: 0; }
.stage-tint .card-title, .stage-tint .card-header p { color: var(--tint-fg) !important; }
.stage-tint .card-header p { opacity: .9; }

/* Filterknoepfe in der Titelleiste: Nummer und Farbe der zugehoerigen Trichterstufe */
.filterbtn .fstage { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }

.funnel-label span.funnel-elems { margin: 2px 0 0; font-size: 11.5px; color: var(--text-dim); }

/* Analysieren: Kopfleiste mit Speichern/Drucken/Einschaetzung bleibt beim Scrollen sichtbar */
#analyze-bar { position: sticky; top: var(--content-sticky-top); z-index: 20; }

/* ─────────────  Dashboard im Aufbau von PortfolioWatch (Statuszeile, Gesamtkarte, Kacheln)  ─────────────
   Klassen und Masse aus portfoliowatch/frontend/style.css übernommen, damit beide Apps gleich aussehen. */
#tab-dashboard > .card { margin-bottom: 0; }
.dash-statuszeile { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.dash-chip { font: inherit; font-size: 12.5px; color: var(--text-muted); background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.dash-chip:hover { background: var(--bg-hover); }
.dash-chip b { color: var(--text); font-weight: 600; }
.dash-chip.warn { color: var(--warning); background: var(--warning-bg); border-color: var(--warning-border); }
.dash-chip.warn b { color: inherit; }
.dash-abschnitt { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin: 28px 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--border); }
.dash-abschnitt-titel { font-size: 16px; font-weight: 700; color: var(--text); }
.dash-abschnitt-hinweis { font-size: 12px; color: var(--text-muted); }
.dash-grid-breit { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); margin-bottom: 16px; }
.pf-inhalt { padding: 16px 20px 18px; display: flex; flex-direction: column; gap: 18px; }
.pf-kopf { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 16px; }
.pf-zahl { font-family: var(--font-display); font-size: 30px; font-weight: 300; letter-spacing: -.01em; font-feature-settings: "tnum"; }
.pf-aufteilung { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 16px 28px; }
.pf-titel { font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.pf-titel-zusatz { text-transform: none; letter-spacing: 0; font-weight: 400; }
.pf-stapel { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--border); }
.pf-stapel > span { display: block; height: 100%; }
.pf-legende { margin-top: 8px; font-size: 12.5px; }
.pf-legende > div { display: grid; grid-template-columns: 12px 1fr 110px 56px; gap: 8px; align-items: center; line-height: 1.8; }
.pf-legende i { width: 10px; height: 10px; border-radius: 2px; }
.pf-legende .mono { text-align: right; }
.pf-herleitung { font-size: 12.5px; color: var(--text-muted); border-top: 1px solid var(--border); padding-top: 10px; line-height: 1.8; }
.pf-klumpen > div { display: grid; grid-template-columns: minmax(0, 1fr) 90px 52px 80px; gap: 8px; align-items: center; font-size: 12.5px; line-height: 1.8; }
.pf-klumpen > div > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-klumpen .mono { text-align: right; }
.pf-pal-0 { background: var(--accent); } .pf-pal-1 { background: #7858ff; } .pf-pal-2 { background: color-mix(in srgb, var(--positive) 60%, var(--accent)); }
.pf-pal-3 { background: #e76500; } .pf-pal-4 { background: #0aa7a0; } .pf-pal-5 { background: #c0399f; }
.pf-pal-6 { background: #5b738b; } .pf-pal-7 { background: #9bb0c4; } .pf-pal-8 { background: #c8d3de; }
.dash-wg-balken { height: 8px; border-radius: 2px; background: var(--border); overflow: hidden; }
.dash-wg-balken > span { display: block; height: 100%; background: var(--accent); }
#tab-dashboard .dash-stat-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tab-dashboard .dash-stat-value { font-weight: 300; }
.dash-tage { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; }
.dash-tag-balken { position: relative; height: 8px; }
.dash-tag-balken::before { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; border-left: 1px solid var(--border); }
.dash-tag-balken > span { position: absolute; top: 0; bottom: 0; border-radius: 2px; background: currentColor; min-width: 1px; }
.dash-mover { display: grid; grid-template-columns: minmax(0, 1fr) 60px 64px 58px 60px; gap: 8px; align-items: center; line-height: 1.9; }
.dash-mover > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-mover .mono { text-align: right; }
.dash-mover.kopf { color: var(--text-dim); font-size: 11px; line-height: 1.4; }
.dash-faellig { display: grid; grid-template-columns: 62px minmax(0, 1fr) 44px 64px; gap: 8px; align-items: center; line-height: 1.9; }
.dash-faellig > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-faellig .mono { text-align: right; }

/* ─────────────  Ziehbare Spaltenbreite (wie PortfolioWatch, tablecols.js)  ───────────── */
.col-resize-handle { position: absolute; top: 0; right: -3px; bottom: 0; width: 8px; cursor: col-resize; z-index: 20; user-select: none; touch-action: none; }
.col-resize-handle::before { content: ""; position: absolute; top: 25%; bottom: 25%; left: 3px; width: 2px; background: var(--border); border-radius: 1px; opacity: 0; transition: opacity .12s; }
th:hover > .col-resize-handle::before { opacity: 1; }
.col-resize-handle:hover::before, body.col-resizing .col-resize-handle::before { opacity: 1; background: var(--accent); }
body.col-resizing { cursor: col-resize; user-select: none; }
table.cm-table th:not(.cm-pin) { position: sticky; }

/* ─────────────  Trichter in der Form von PortfolioWatch (funnel.js)  ─────────────
   Durchgehender Küchentrichter (nicht massstäblich): gerader Kegel, gerundeter Hals, schmales Rohr;
   je Stufe ein farbig abgesetzter Abschnitt mit der Anzahl, Glanz-Verlauf wie in PortfolioWatch. */
.funnel-seg.funnel-abschnitt { background-image: linear-gradient(90deg, rgba(255,255,255,.22), rgba(255,255,255,0) 35%, rgba(0,0,0,0) 65%, rgba(0,0,0,.18)); }
.funnel-seg.funnel-dunkel { color: #3a2a00; }
.funnel-cone { padding: 0; }

/* Wechsel zu Portfolio Watch (Kopfzeile): breiter als die Symbol-Knöpfe, Text statt Symbol */
.shell-icon-btn.shell-link { width: auto; padding: 0 10px; font-size: 12.5px; font-weight: 600; text-decoration: none; }

/* Ticker-Zuordnungen (tickerdialog.js): Reiter der Verwaltung und Tabelle der Vorschläge */
.td-reiter { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 12px; }
.td-reiter button { padding: 6px 14px; font-size: 13px; background: var(--bg-card); color: var(--text-muted); }
.td-reiter button + button { border-left: 1px solid var(--border); }
.td-reiter button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.td-tabelle td, .td-tabelle th { padding: 6px 10px; font-size: 12.5px; white-space: nowrap; }
.td-tabelle td:nth-child(2) { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
#ticker-dialog-modal { z-index: 1100; }

/* Feine weisse Trennlinie zwischen den Werten (wie in den Chart.js-Grafiken, siehe core.js) */
.pf-stapel > span + span { box-shadow: inset 1px 0 0 #fff; }
.funnel-row + .funnel-row .funnel-seg { box-shadow: inset 0 1px 0 #fff; }
