/* ============================================================
   Tingler Advisory — Sektor-Allokation V2 (Modul-Einbettung)
   Vollständig auf .ta-sector-allocation-v2 gescopt.

   WICHTIG: Die Farb-Tokens (--ta-* und semantische Farben) werden hier
   NICHT mehr fest gesetzt, damit V2 dein bestehendes Theme erbt
   (dunkel/teal, wie V1). Falls dein Theme die Variablen NICHT global
   auf :root definiert, sondern nur auf dem V1-Wrapper, kopiere einfach
   deinen --ta-*-Block aus der laufenden V1-CSS in den Block unten.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=IBM+Plex+Sans:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

.ta-sector-allocation-v2 {
  /* --- Theme-FARBEN (--ta-*) werden vom Theme geerbt (auf :root). Falls dein
         Theme sie NICHT global definiert, hier eintragen. Beispiel dunkel/teal:
  --ta-bg:             #0F1620;
  --ta-bg-card:        #18212C;
  --ta-text-primary:   #E8EDF2;
  --ta-text-secondary: #8B97A4;
  --ta-text-muted:     #6B7682;
  --ta-accent:         #2DD4BF;
  --ta-accent-dark:    #0D9488;
  --ta-border:         #2A333D;
  --ta-border-subtle:  #1E262E;
  --- */

  /* App-eigene Akzentfarben (NICHT Teil des Themes) — für Slider-Verlauf,
     Kauf/Verkauf-Text und die Faktor-Kacheln. Kachel-Hintergründe sind
     halbtransparent, damit sie sich ins dunkle Theme einfügen. */
  --positive:   #3DAE8B;
  --negative:   #C9605A;
  --pos-strong: rgba(61, 174, 139, 0.30);
  --pos-mid:    rgba(61, 174, 139, 0.15);
  --neg-strong: rgba(201, 96, 90, 0.30);
  --neg-mid:    rgba(201, 96, 90, 0.15);

  /* Schriften mit generischem Fallback (brechen nicht, falls nicht im Theme) */
  --ta-font-display: var(--ta-font-display, 'Fraunces', Georgia, serif);
  --ta-font-body:    var(--ta-font-body, 'IBM Plex Sans', system-ui, sans-serif);
  --ta-font-mono:    var(--ta-font-mono, 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace);

  font-family: var(--ta-font-body);
  background: var(--ta-bg);
  color: var(--ta-text-primary);
  padding: 24px 18px 50px;
  max-width: 820px;
  margin: 0 auto;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
}
.ta-sector-allocation-v2 *,
.ta-sector-allocation-v2 *::before,
.ta-sector-allocation-v2 *::after { box-sizing: border-box; }

.ta-sector-allocation-v2 .section { margin-bottom: 36px; }
.ta-sector-allocation-v2 .section:first-child { margin-top: 0; }
.ta-sector-allocation-v2 .section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  border-bottom: 1px solid var(--ta-border);
  padding-bottom: 7px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.ta-sector-allocation-v2 .section-number {
  font-family: var(--ta-font-mono);
  font-size: 9px;
  color: var(--ta-text-secondary);
  letter-spacing: 0.18em;
}
.ta-sector-allocation-v2 .section-title {
  font-family: var(--ta-font-display);
  font-weight: 500;
  font-size: 18px;
  line-height: 1.2;
}
.ta-sector-allocation-v2 .section-hint {
  font-family: var(--ta-font-body);
  font-size: 10px;
  color: var(--ta-text-secondary);
  font-style: italic;
  text-align: right;
}

/* Toolbar */
.ta-sector-allocation-v2 .toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.ta-sector-allocation-v2 .toolbar .field { display: flex; align-items: baseline; gap: 8px; }
.ta-sector-allocation-v2 .toolbar label {
  font-family: var(--ta-font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ta-text-secondary);
  white-space: nowrap;
}
.ta-sector-allocation-v2 .toolbar input[type="text"] {
  font-family: var(--ta-font-mono);
  font-size: 14px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ta-border);
  padding: 3px 5px;
  color: var(--ta-text-primary);
  width: 110px;
}
.ta-sector-allocation-v2 .toolbar input:focus { outline: none; border-color: var(--ta-accent); }
.ta-sector-allocation-v2 .file-import-btn {
  display: inline-flex;
  align-items: center;
  font-family: var(--ta-font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 7px 12px;
  border: 1px solid var(--ta-border);
  cursor: pointer;
  color: var(--ta-text-primary);
  background: var(--ta-bg-card);
  user-select: none;
}
.ta-sector-allocation-v2 .file-import-btn:hover { background: var(--ta-text-primary); color: var(--ta-bg); }
.ta-sector-allocation-v2 .import-feedback {
  font-family: var(--ta-font-mono);
  font-size: 9px;
  color: var(--ta-text-secondary);
}

/* Horizontal bars — gesamte Bar = 100% */
.ta-sector-allocation-v2 .h-chart { display: flex; flex-direction: column; gap: 6px; }
.ta-sector-allocation-v2 .h-row {
  display: grid;
  grid-template-columns: 120px 1fr 105px;
  align-items: center;
  gap: 10px;
}
.ta-sector-allocation-v2 .h-label {
  font-family: var(--ta-font-body);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ta-text-primary);
}
.ta-sector-allocation-v2 .h-bar-track {
  height: 22px;
  background: var(--ta-bg-card);
  border: 1px solid var(--ta-border-subtle);
  position: relative;
}
.ta-sector-allocation-v2 .h-bar-fill {
  height: 100%;
  background: var(--ta-text-primary);
  transition: width 0.18s ease;
  min-width: 1px;
}
.ta-sector-allocation-v2 .h-bar-fill.suggested { background: var(--ta-accent); }

/* Min/Max markers */
.ta-sector-allocation-v2 .h-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 4px;
  margin-left: -2px;
  z-index: 3;
  cursor: ew-resize;
  touch-action: none;
}
.ta-sector-allocation-v2 .h-marker::before {
  content: '';
  position: absolute;
  top: -4px; bottom: -4px;
  left: -6px; right: -6px;
}
.ta-sector-allocation-v2 .h-marker.min { background: var(--ta-text-primary); border-radius: 1px; }
.ta-sector-allocation-v2 .h-marker.max { background: var(--ta-accent-dark); border-radius: 1px; }
.ta-sector-allocation-v2 .h-marker.max::after {
  content: '';
  position: absolute;
  inset: 0;
  border-left: 1px dashed var(--ta-bg);
  border-right: 1px dashed var(--ta-bg);
}
.ta-sector-allocation-v2 .h-marker:hover,
.ta-sector-allocation-v2 .h-marker.dragging { background: var(--ta-accent); }

.ta-sector-allocation-v2 .h-value {
  font-family: var(--ta-font-mono);
  font-size: 10px;
  text-align: right;
  color: var(--ta-text-primary);
}
.ta-sector-allocation-v2 .h-value .pct { font-weight: 500; outline: none; padding: 1px 2px; }
.ta-sector-allocation-v2 .h-value .pct[contenteditable="true"] {
  border-bottom: 1px dotted var(--ta-border-subtle);
  cursor: text;
}
.ta-sector-allocation-v2 .h-value .pct[contenteditable="true"]:hover,
.ta-sector-allocation-v2 .h-value .pct[contenteditable="true"]:focus {
  border-bottom-color: var(--ta-accent);
  color: var(--ta-accent);
}
.ta-sector-allocation-v2 .h-value .abs {
  display: block;
  color: var(--ta-text-secondary);
  font-size: 9px;
  margin-top: 1px;
}

/* Legende */
.ta-sector-allocation-v2 .bar-legend {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  font-family: var(--ta-font-mono);
  font-size: 9px;
  color: var(--ta-text-secondary);
  flex-wrap: wrap;
}
.ta-sector-allocation-v2 .bar-legend .item { display: flex; align-items: center; gap: 6px; }
.ta-sector-allocation-v2 .bar-legend .swatch { width: 4px; height: 14px; border-radius: 1px; }
.ta-sector-allocation-v2 .bar-legend .swatch.min { background: var(--ta-text-primary); }
.ta-sector-allocation-v2 .bar-legend .swatch.max { background: var(--ta-accent-dark); }
.ta-sector-allocation-v2 .bar-legend .swatch.fill { width: 16px; background: var(--ta-accent); }

/* Faktor-Wirkung */
.ta-sector-allocation-v2 .impact-block { margin-top: 18px; }
.ta-sector-allocation-v2 .impact-title {
  font-family: var(--ta-font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ta-text-secondary);
  margin-bottom: 8px;
}
.ta-sector-allocation-v2 .impact-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}
.ta-sector-allocation-v2 .impact-cell {
  border: 1px solid var(--ta-border);
  padding: 12px 10px 10px;
  text-align: center;
  background: var(--ta-bg-card);
}
.ta-sector-allocation-v2 .impact-cell.pos-strong { background: var(--pos-strong); }
.ta-sector-allocation-v2 .impact-cell.pos-mid    { background: var(--pos-mid); }
.ta-sector-allocation-v2 .impact-cell.neg-strong { background: var(--neg-strong); }
.ta-sector-allocation-v2 .impact-cell.neg-mid    { background: var(--neg-mid); }
.ta-sector-allocation-v2 .impact-label {
  font-family: var(--ta-font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ta-text-secondary);
  margin-bottom: 6px;
}
.ta-sector-allocation-v2 .impact-value {
  font-family: var(--ta-font-mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--ta-text-primary);
}
.ta-sector-allocation-v2 .impact-note {
  font-family: var(--ta-font-body);
  font-size: 9px;
  color: var(--ta-text-muted);
  font-style: italic;
  margin-top: 7px;
}

/* Sliders */
.ta-sector-allocation-v2 .sliders-block { margin-top: 20px; }
.ta-sector-allocation-v2 .sliders-title {
  font-family: var(--ta-font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ta-text-secondary);
  margin-bottom: 8px;
}
.ta-sector-allocation-v2 .sliders {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.ta-sector-allocation-v2 .slider-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid var(--ta-border);
  background: var(--ta-bg-card);
}
.ta-sector-allocation-v2 .slider-group .head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.ta-sector-allocation-v2 .slider-group .label {
  font-family: var(--ta-font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ta-text-secondary);
}
.ta-sector-allocation-v2 .slider-group .readout {
  font-family: var(--ta-font-mono);
  font-size: 16px;
  font-weight: 500;
  color: var(--ta-text-primary);
}
.ta-sector-allocation-v2 .slider-group .readout.pos { color: var(--positive); }
.ta-sector-allocation-v2 .slider-group .readout.neg { color: var(--negative); }
.ta-sector-allocation-v2 input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: linear-gradient(to right, var(--negative) 0%, var(--ta-text-secondary) 50%, var(--positive) 100%);
  outline: none;
  border-radius: 2px;
  cursor: pointer;
}
.ta-sector-allocation-v2 input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px;
  background: var(--ta-text-primary);
  cursor: grab;
  border-radius: 50%;
  border: 2px solid var(--ta-bg);
  box-shadow: 0 0 0 1px var(--ta-border);
}
.ta-sector-allocation-v2 input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  background: var(--ta-text-primary);
  cursor: grab;
  border-radius: 50%;
  border: 2px solid var(--ta-bg);
  box-shadow: 0 0 0 1px var(--ta-border);
}
.ta-sector-allocation-v2 .slider-bounds {
  display: flex;
  justify-content: space-between;
  font-family: var(--ta-font-mono);
  font-size: 8px;
  color: var(--ta-text-muted);
}

/* Tabelle */
.ta-sector-allocation-v2 .table-wrap { overflow: visible; }
.ta-sector-allocation-v2 .rebal-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--ta-font-body);
  font-size: 15px;
  min-width: 280px;
  color: var(--ta-text-primary);
}
.ta-sector-allocation-v2 .rebal-table th {
  text-align: center;
  font-family: var(--ta-font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ta-text-secondary);
  padding: 9px 8px;
  border-bottom: 2px solid var(--ta-border);
  font-weight: 500;
  white-space: nowrap;
}
.ta-sector-allocation-v2 .rebal-table th.num,
.ta-sector-allocation-v2 .rebal-table td.num {
  text-align: center;
  font-family: var(--ta-font-mono);
  white-space: nowrap;
}
.ta-sector-allocation-v2 .rebal-table td {
  padding: 11px 8px;
  border-bottom: 1px solid var(--ta-border-subtle);
  text-align: center;
}
.ta-sector-allocation-v2 .rebal-table tr:last-child td { border-bottom: none; }
.ta-sector-allocation-v2 .buy  { color: var(--positive); font-weight: 500; }
.ta-sector-allocation-v2 .sell { color: var(--negative); font-weight: 500; }
.ta-sector-allocation-v2 .hold { color: var(--ta-text-muted); }
.ta-sector-allocation-v2 .rebal-table td.action { font-weight: 600; }
.ta-sector-allocation-v2 .rebal-table td.act-pos-strong { background: var(--pos-strong); color: var(--ta-text-primary); }
.ta-sector-allocation-v2 .rebal-table td.act-pos-mid    { background: var(--pos-mid);    color: var(--ta-text-primary); }
.ta-sector-allocation-v2 .rebal-table td.act-neg-strong { background: var(--neg-strong); color: var(--ta-text-primary); }
.ta-sector-allocation-v2 .rebal-table td.act-neg-mid    { background: var(--neg-mid);    color: var(--ta-text-primary); }

/* Info-Icon & Tooltip */
.ta-sector-allocation-v2 .info-wrap { position: relative; display: inline-flex; align-items: center; gap: 7px; }
.ta-sector-allocation-v2 .sektor-name { white-space: nowrap; }
.ta-sector-allocation-v2 .info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border: 1px solid var(--ta-border-subtle);
  border-radius: 50%;
  font-family: var(--ta-font-display);
  font-style: italic;
  font-size: 11px;
  line-height: 1;
  color: var(--ta-text-secondary);
  cursor: help;
  user-select: none;
  flex: 0 0 auto;
}
.ta-sector-allocation-v2 .info-icon:hover,
.ta-sector-allocation-v2 .info-icon:focus {
  background: var(--ta-text-primary);
  color: var(--ta-bg);
  border-color: var(--ta-text-primary);
  outline: none;
}
.ta-sector-allocation-v2 .info-tip {
  display: none;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 190px;
  padding: 12px 16px;
  background: var(--ta-bg);
  border: 1px solid var(--ta-border);
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  font-family: var(--ta-font-mono);
  font-size: 14px;
  color: var(--ta-text-primary);
  white-space: nowrap;
  text-align: left;
}
.ta-sector-allocation-v2 .info-icon:hover + .info-tip,
.ta-sector-allocation-v2 .info-icon:focus + .info-tip { display: block; }
.ta-sector-allocation-v2 .tip-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 3px 0;
  white-space: nowrap;
  color: var(--ta-text-secondary);
}
.ta-sector-allocation-v2 .tip-row strong { color: var(--ta-text-primary); font-weight: 500; }
.ta-sector-allocation-v2 .tip-row strong.tip-pos { color: var(--positive); }
.ta-sector-allocation-v2 .tip-row strong.tip-neg { color: var(--negative); }

@media (max-width: 700px) {
  .ta-sector-allocation-v2 { padding: 16px 10px 40px; }
  .ta-sector-allocation-v2 .h-row { grid-template-columns: 84px 1fr 78px; gap: 6px; }
  .ta-sector-allocation-v2 .h-label { font-size: 10px; }
  .ta-sector-allocation-v2 .h-value { font-size: 9px; }
  .ta-sector-allocation-v2 .impact-row { grid-template-columns: 1fr; }
  .ta-sector-allocation-v2 .sliders { grid-template-columns: 1fr; }
  .ta-sector-allocation-v2 .section-hint { font-size: 9px; width: 100%; text-align: left; }
}

/* Sensitivitäten-Toggle (Standard / Eigene) */
.ta-sector-allocation-v2 .sens-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.ta-sector-allocation-v2 .sens-toggle-label {
  font-family: var(--ta-font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ta-text-secondary);
  white-space: nowrap;
}
.ta-sector-allocation-v2 .toggle-segmented {
  display: inline-flex;
  border: 1px solid var(--ta-border);
}
.ta-sector-allocation-v2 .toggle-segmented button {
  font-family: var(--ta-font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 7px 12px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--ta-border);
  cursor: pointer;
  color: var(--ta-text-secondary);
}
.ta-sector-allocation-v2 .toggle-segmented button:last-child { border-right: none; }
.ta-sector-allocation-v2 .toggle-segmented button.active {
  background: var(--ta-text-primary);
  color: var(--ta-bg);
}
.ta-sector-allocation-v2 .sens-source-note {
  font-family: var(--ta-font-body);
  font-size: 10px;
  font-style: italic;
  color: var(--ta-text-muted);
}

/* ============================================================
   V2-Feinschliff: etwas größere Schrift + sichtbarer Slider-Balken.
   (Überschreibt die kleineren Ausgangswerte; schmale Breite bleibt.)
   ============================================================ */
.ta-sector-allocation-v2 .section-number   { font-size: 10px; }
.ta-sector-allocation-v2 .section-title    { font-size: 21px; }
.ta-sector-allocation-v2 .section-hint     { font-size: 11px; }

.ta-sector-allocation-v2 .toolbar label    { font-size: 10px; }
.ta-sector-allocation-v2 .toolbar input[type="text"] { font-size: 15px; }
.ta-sector-allocation-v2 .file-import-btn  { font-size: 10px; }
.ta-sector-allocation-v2 .import-feedback  { font-size: 10px; }

.ta-sector-allocation-v2 .sens-toggle-label { font-size: 10px; }
.ta-sector-allocation-v2 .toggle-segmented button { font-size: 10px; }
.ta-sector-allocation-v2 .sens-source-note { font-size: 11px; }

.ta-sector-allocation-v2 .h-label          { font-size: 13px; }
.ta-sector-allocation-v2 .h-value          { font-size: 12px; }
.ta-sector-allocation-v2 .h-value .abs      { font-size: 11px; }
.ta-sector-allocation-v2 .bar-legend        { font-size: 10px; }

.ta-sector-allocation-v2 .impact-title      { font-size: 10px; }
.ta-sector-allocation-v2 .impact-label      { font-size: 10px; }
.ta-sector-allocation-v2 .impact-value      { font-size: 22px; }
.ta-sector-allocation-v2 .impact-note       { font-size: 10px; }

.ta-sector-allocation-v2 .sliders-title     { font-size: 10px; }
.ta-sector-allocation-v2 .slider-group .label   { font-size: 10px; }
.ta-sector-allocation-v2 .slider-group .readout { font-size: 19px; }
.ta-sector-allocation-v2 .slider-bounds     { font-size: 9px; }

.ta-sector-allocation-v2 .rebal-table       { font-size: 16px; }
.ta-sector-allocation-v2 .rebal-table th    { font-size: 11px; }

/* Slider-Balken wieder sichtbar + etwas kräftiger */
.ta-sector-allocation-v2 input[type="range"] {
  height: 5px;
  background: linear-gradient(to right,
    var(--negative) 0%,
    var(--ta-text-secondary) 50%,
    var(--positive) 100%);
}

/* Live-%-Label am gezogenen Marker (Min/Max) */
.ta-sector-allocation-v2 .h-bar-track { overflow: visible; }
.ta-sector-allocation-v2 .marker-readout {
  position: absolute;
  top: 50%;
  z-index: 6;
  padding: 1px 6px;
  font-family: var(--ta-font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  border-radius: 2px;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.ta-sector-allocation-v2 .marker-readout.max {
  background: var(--ta-accent);
  color: var(--ta-bg);
}
.ta-sector-allocation-v2 .marker-readout.min {
  background: var(--ta-text-primary);
  color: var(--ta-bg);
}

/* Portfoliowert als Anzeige (kein Eingabefeld) */
.ta-sector-allocation-v2 .field-label {
  font-family: var(--ta-font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ta-text-secondary);
  white-space: nowrap;
}
.ta-sector-allocation-v2 .field-value {
  font-family: var(--ta-font-mono);
  font-size: 16px;
  font-weight: 500;
  color: var(--ta-text-primary);
}
