/* ============================================================
   Colorffy dark theme — Dash apps (Bootstrap 5 / DARKLY)
   Primary:  #E0B773  (warm gold)
   Surface:  msci.darkBackground (muted ink navy), see ms-theme.css

   Single stylesheet for all MS_master Dash apps. Was previously split across
   dark.css + more_styles.css with a few rules unintentionally overlapping
   (.card, form inputs, h1-h6) whose winner depended on Dash's alphabetical
   asset-load order; consolidated here as single, explicit rules instead.
   ============================================================ */

/* Palette colours generated from msci.themeCss() (MS_master route /ms-theme.css) */
@import url("https://tools.minussinus.de/ms-theme.css");

/* ---- Palette tokens ---------------------------------------- */
:root {
  --ms-primary:          #E0B773;
  --ms-primary-dark:     #c49a55;
  --ms-primary-rgb:      224, 183, 115;
  --ms-primary-subtle:   rgba(224, 183, 115, 0.12);

  /* --ms-bg, --ms-surface-1..3, --ms-border, --ms-text-muted (+ *-rgb): from msci via ms-theme.css */
  --ms-border-subtle:    rgba(var(--ms-border-rgb), 0.5);

  --ms-text:             #C2C5D5;  /* msci.Silver */

  --ms-success:          #3E806C;
  --ms-success-light:    #76C3AB;
  --ms-warning:          #BB864B;
  --ms-warning-light:    #ECA758;
  --ms-danger:           #883835;
  --ms-danger-light:     #CC6660;
  --ms-info:             #21498A;
  --ms-info-light:       #4077d1;
}

/* ---- Bootstrap 5 variable overrides ----------------------- */
:root,
[data-bs-theme="dark"] {
  --bs-body-bg:                    var(--ms-bg);
  --bs-body-bg-rgb:                var(--ms-bg-rgb);
  --bs-body-color:                 var(--ms-text);
  --bs-body-color-rgb:             194, 197, 213;
  --bs-secondary-bg:               var(--ms-surface-1);
  --bs-secondary-bg-rgb:           var(--ms-surface-1-rgb);
  --bs-tertiary-bg:                var(--ms-surface-2);
  --bs-tertiary-bg-rgb:            var(--ms-surface-2-rgb);
  --bs-secondary-color:            rgba(194, 197, 213, 0.75);
  --bs-tertiary-color:             rgba(194, 197, 213, 0.5);
  --bs-emphasis-color:             var(--ms-primary);
  --bs-emphasis-color-rgb:         var(--ms-primary-rgb);

  --bs-primary:                    var(--ms-primary);
  --bs-primary-rgb:                224, 183, 115;
  --bs-secondary:                  #3d4580;
  --bs-secondary-rgb:              61, 69, 128;
  --bs-success:                    var(--ms-success);
  --bs-success-rgb:                62, 128, 108;
  --bs-info:                       var(--ms-info);
  --bs-info-rgb:                   33, 73, 138;
  --bs-warning:                    var(--ms-warning);
  --bs-warning-rgb:                187, 134, 75;
  --bs-danger:                     var(--ms-danger);
  --bs-danger-rgb:                 136, 56, 53;
  --bs-light:                      var(--ms-text);
  --bs-dark:                       var(--ms-bg);

  --bs-border-color:               var(--ms-border);
  --bs-border-color-translucent:   var(--ms-border-subtle);

  --bs-link-color:                 var(--ms-primary);
  --bs-link-hover-color:           var(--ms-primary-dark);
  --bs-link-color-rgb:             224, 183, 115;
  --bs-link-hover-color-rgb:       196, 154, 85;

  --bs-heading-color:              var(--ms-text);
  --bs-code-color:                 var(--ms-primary);
  --bs-highlight-bg:               var(--ms-surface-3);

  /* card */
  --bs-card-bg:                    var(--ms-surface-1);
  --bs-card-cap-bg:                var(--ms-surface-2);
  --bs-card-border-color:          var(--ms-border);

  /* table */
  --bs-table-bg:                   transparent;
  --bs-table-color:                var(--ms-text);
  --bs-table-border-color:         var(--ms-border);
  --bs-table-striped-bg:           rgba(var(--ms-surface-1-rgb), 0.6);
  --bs-table-hover-bg:             rgba(224, 183, 115, 0.07);

  /* form */
  --bs-form-valid-color:           var(--ms-success-light);
  --bs-form-valid-border-color:    var(--ms-success);
  --bs-form-invalid-color:         var(--ms-danger-light);
  --bs-form-invalid-border-color:  var(--ms-danger);
}

/* ---- Base / reset -------------------------------------------
   10px root sizing (Skeleton-framework convention) so the rem
   values in the heading rules below read as 1rem = 10px. */
html {
  font-size: 62.5%;
}
body {
  background-color: var(--ms-bg) !important;
  color:            var(--ms-text) !important;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
  font-size: 1.5em;
  line-height: 1.6;
  font-weight: 400;
  margin: 2%;
}

/* ---- Headings ------------------------------------------------ */
h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  margin-bottom: 0;
  font-weight: 300;
  color: var(--ms-text);
}
h1 { font-size: 2.4rem; line-height: 1.2;  margin-bottom: 2rem; }
h2 { font-size: 2.0rem; line-height: 1.25; margin-top: 1rem; }
h3 { font-size: 1.8rem; line-height: 1.3;  margin-bottom: 1.5rem; margin-top: 1.5rem; }
h4 { font-size: 1.6rem; line-height: 1.35; margin-bottom: 1.2rem; }
h5 { font-size: 1.4rem; line-height: 1.5;  margin-bottom: 0.6rem; margin-top: 0.6rem; }
h6 { font-size: 1.0rem; line-height: 1.6;  margin-bottom: 0.75rem; margin-top: 0.75rem; }

/* Grid resets - also restored from the old remote dark.css */
.row { padding-left: 0; padding-bottom: 0; margin-bottom: 0; }
.col { margin-right: 0; }

/* ---- Navbar ------------------------------------------------ */
.navbar,
.navbar-dark,
nav.bg-dark,
.bg-dark:not(.card):not(.dropdown-menu):not(.modal-content) {
  background-color: var(--ms-surface-1) !important;
  border-bottom: 1px solid var(--ms-border);
}
.navbar-brand,
.navbar-dark .navbar-brand { color: var(--ms-primary) !important; font-weight: 600; }
.navbar-dark .nav-link      { color: var(--ms-text) !important; }
.navbar-dark .nav-link:hover,
.navbar-dark .nav-link:focus { color: var(--ms-primary) !important; }
.navbar-toggler             { border-color: var(--ms-border) !important; }
.navbar-toggler-icon        { filter: brightness(0.7) sepia(1) hue-rotate(180deg) saturate(0.5); }

/* ---- Buttons ----------------------------------------------- */
.btn-primary {
  background-color: var(--ms-primary) !important;
  border-color:     var(--ms-primary) !important;
  color:            var(--ms-bg)      !important;
  font-weight: 500;
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
  background-color: var(--ms-primary-dark) !important;
  border-color:     var(--ms-primary-dark) !important;
  color:            var(--ms-bg)           !important;
  box-shadow:       0 0 0 0.25rem rgba(224, 183, 115, 0.25) !important;
}
.btn-outline-primary {
  color:            var(--ms-primary) !important;
  border-color:     var(--ms-primary) !important;
}
.btn-outline-primary:hover,
.btn-outline-primary:active {
  background-color: var(--ms-primary) !important;
  color:            var(--ms-bg)       !important;
}
.btn-outline-secondary {
  color:        var(--ms-text-muted) !important;
  border-color: var(--ms-border)     !important;
}
.btn-outline-secondary:hover {
  background-color: var(--ms-surface-2) !important;
  border-color:     var(--ms-border)    !important;
  color:            var(--ms-text)      !important;
}
.btn-success   { background-color: var(--ms-success) !important; border-color: var(--ms-success) !important; color: #fff !important; }
.btn-warning   { background-color: var(--ms-warning) !important; border-color: var(--ms-warning) !important; color: #fff !important; }
.btn-danger    { background-color: var(--ms-danger)  !important; border-color: var(--ms-danger)  !important; color: #fff !important; }
.btn-info      { background-color: var(--ms-info)    !important; border-color: var(--ms-info)    !important; color: #fff !important; }
.btn-secondary { background-color: var(--ms-surface-3) !important; border-color: var(--ms-border) !important; color: var(--ms-text) !important; }
.btn-dark      { background-color: var(--ms-surface-2) !important; border-color: var(--ms-border) !important; color: var(--ms-text) !important; }
.btn-light     { background-color: var(--ms-surface-2) !important; border-color: var(--ms-border) !important; color: var(--ms-text) !important; }

/* Icon buttons (font-awesome): smooth hover fade */
.fas { transition: opacity 0.15s ease; }
.fas:hover { opacity: 0.65; }

/* Plain <button> elements (html.Button without a Bootstrap className) - also
   restored from the old remote am.minussinus.de/assets/dark.css; the .btn-*
   classed rules above already win over this via specificity, so it only
   affects unclassed buttons. */
button {
  color: var(--ms-bg);
  background-color: var(--ms-primary);
  border-radius: 8px;
  border-style: none;
  margin: 5px;
  padding-inline: 0.75rem;
  padding-block: 0.375rem;
}

/* Links: no underline, matches the flat icon/tile/dropdown-link aesthetic
   used throughout - also restored from the old remote dark.css. */
a { text-decoration: none; }

/* ---- Cards --------------------------------------------------
   Borderless with a subtle radius - this was the accidental winner
   of a load-order conflict before consolidation; kept intentionally.
   margin-bottom restores spacing between stacked cards that used to
   come from the old remote am.minussinus.de/assets/dark.css, before
   that URL was symlinked to this consolidated file. */
.card {
  background-color: var(--ms-surface-1) !important;
  border: none !important;
  border-radius: 6px !important;
  margin-bottom: 10px !important;
  padding: 10px;
  height: 95%;
}
.card-header {
  background-color: var(--ms-surface-2) !important;
  border-color:     var(--ms-border)    !important;
  color:            var(--ms-text)      !important;
}
.card-body  { color: var(--ms-text); }
.card-title { color: var(--ms-text) !important; }

/* Tile section headers — used via className='snap-header' */
.snap-header {
  font-size: 1.2rem;
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ms-text);
  margin-bottom: 6px;
  margin-top: 2px;
}

/* ---- Forms --------------------------------------------------- */
.form-control,
.form-select,
.Select-control,
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea {
  background-color: var(--ms-surface-1) !important;
  border-style:     solid                !important;
  border-width:     1px                  !important;
  border-color:     var(--ms-border)    !important;
  color:            var(--ms-text)      !important;
  border-radius: 4px !important;
  transition: border-color 0.15s ease;
}
.form-control:focus,
.form-select:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
textarea:focus {
  background-color: var(--ms-surface-2)                    !important;
  border-color:     var(--ms-primary)                      !important;
  box-shadow:       0 0 0 0.25rem rgba(224, 183, 115, 0.2) !important;
  color:            var(--ms-text)                         !important;
}
.form-control::placeholder { color: var(--ms-text-muted) !important; opacity: 1; }

/* app_snap: Fair Multiple scenario inputs — per-metric border colors
   (msci.darkBlue/Red/LightGray/Orange). ID selectors outrank the
   input[type=...] rule above on specificity even though both sides are
   !important, so these colors win over the generic theme border. */
#equityCosts,
#fair_pe       { border-color: #8C939F !important; } /* darkBlue */
#fair_pb       { border-color: #CC6660 !important; } /* Red */
#fair_ev_ebit  { border-color: #A6AEBC !important; } /* LightGray */
#fair_ev_sales { border-color: #ECA758 !important; } /* Orange */
.form-check-input:checked {
  background-color: var(--ms-primary) !important;
  border-color:     var(--ms-primary) !important;
}
.form-check-input:focus {
  box-shadow: 0 0 0 0.25rem rgba(224, 183, 115, 0.2) !important;
  border-color: var(--ms-primary) !important;
}
.form-switch .form-check-input:checked {
  background-color: var(--ms-primary) !important;
  border-color:     var(--ms-primary) !important;
}
.input-group-text {
  background-color: var(--ms-surface-2) !important;
  border-color:     var(--ms-border)    !important;
  color:            var(--ms-text-muted)!important;
}

/* ---- Dropdowns --------------------------------------------- */
.dropdown-menu {
  background-color: var(--ms-surface-2) !important;
  border-color:     var(--ms-border)    !important;
}
.dropdown-item          { color: var(--ms-text) !important; }
.dropdown-item:hover,
.dropdown-item:focus    { background-color: var(--ms-surface-3) !important; color: var(--ms-text) !important; }
.dropdown-divider       { border-color: var(--ms-border) !important; }

/* ---- Tables ------------------------------------------------ */
.table                  { color: var(--ms-text) !important; }
.table > :not(caption) > * > * { border-color: var(--ms-border) !important; }
.table-dark             { background-color: var(--ms-surface-1) !important; }
.table thead th,
.table thead td         { color: var(--ms-text-muted) !important; border-color: var(--ms-border) !important; }
.table-hover > tbody > tr:hover > * { background-color: rgba(224, 183, 115, 0.07) !important; color: var(--ms-text) !important; }
.table-striped > tbody > tr:nth-of-type(odd) > * { background-color: rgba(var(--ms-surface-1-rgb), 0.5) !important; }
.table-bordered > :not(caption) > * { border-color: var(--ms-border) !important; }

/* ---- Badges ------------------------------------------------ */
.badge.bg-primary        { background-color: var(--ms-primary) !important; color: var(--ms-bg) !important; }
.badge.bg-success        { background-color: var(--ms-success) !important; }
.badge.bg-warning        { background-color: var(--ms-warning) !important; }
.badge.bg-danger         { background-color: var(--ms-danger)  !important; }
.badge.bg-info           { background-color: var(--ms-info)    !important; }
.badge.bg-secondary      { background-color: var(--ms-surface-3) !important; color: var(--ms-text) !important; }

/* ---- Tabs -------------------------------------------------- */
.nav-tabs                { border-color: var(--ms-border); }
.nav-tabs .nav-link      { color: var(--ms-text-muted); border-color: transparent; }
.nav-tabs .nav-link:hover { color: var(--ms-text); border-color: var(--ms-border) var(--ms-border) transparent; }
.nav-tabs .nav-link.active {
  background-color: var(--ms-surface-2) !important;
  border-color:     var(--ms-primary) var(--ms-primary) var(--ms-surface-2) !important;
  color:            var(--ms-text) !important;
}
.nav-pills .nav-link.active {
  background-color: var(--ms-primary) !important;
  color:            var(--ms-bg)       !important;
}
.nav-pills .nav-link     { color: var(--ms-text-muted); }
.nav-pills .nav-link:hover { color: var(--ms-text); }

/* ---- Modals ------------------------------------------------ */
.modal-content  { background-color: var(--ms-surface-1) !important; border-color: var(--ms-border) !important; }
.modal-header   { border-color: var(--ms-border) !important; }
.modal-footer   { border-color: var(--ms-border) !important; }
.modal-title    { color: var(--ms-text) !important; }

/* ---- Alerts ------------------------------------------------ */
.alert-success  { background-color: rgba(62, 128, 108, 0.15) !important; border-color: var(--ms-success) !important; color: var(--ms-success-light) !important; }
.alert-warning  { background-color: rgba(187, 134, 75, 0.15) !important; border-color: var(--ms-warning) !important; color: var(--ms-warning-light) !important; }
.alert-danger   { background-color: rgba(136, 56, 53, 0.15)  !important; border-color: var(--ms-danger)  !important; color: var(--ms-danger-light)  !important; }
.alert-info     { background-color: rgba(33, 73, 138, 0.15)  !important; border-color: var(--ms-info)    !important; color: var(--ms-info-light)    !important; }
.alert-primary  { background-color: rgba(224, 183, 115, 0.12)!important; border-color: var(--ms-primary) !important; color: var(--ms-primary)       !important; }

/* ---- List groups ------------------------------------------- */
.list-group-item {
  background-color: var(--ms-surface-1) !important;
  border-color:     var(--ms-border)    !important;
  color:            var(--ms-text)      !important;
}
.list-group-item:hover,
.list-group-item:focus { background-color: var(--ms-surface-2) !important; }
.list-group-item.active { background-color: var(--ms-primary) !important; border-color: var(--ms-primary) !important; color: var(--ms-bg) !important; }

/* ---- Accordion --------------------------------------------- */
.accordion-item   { background-color: var(--ms-surface-1) !important; border-color: var(--ms-border) !important; }
.accordion-button { background-color: var(--ms-surface-1) !important; color: var(--ms-text) !important; }
.accordion-button:not(.collapsed) { background-color: var(--ms-surface-2) !important; color: var(--ms-text) !important; box-shadow: inset 0 -1px 0 var(--ms-border) !important; }
.accordion-button:focus { box-shadow: 0 0 0 0.25rem rgba(224, 183, 115, 0.2) !important; }
.accordion-button::after { filter: brightness(0.6) sepia(1) hue-rotate(10deg) saturate(3); }
.accordion-body { background-color: var(--ms-surface-1) !important; color: var(--ms-text) !important; }

/* ---- Progress ---------------------------------------------- */
.progress       { background-color: var(--ms-surface-2) !important; }
.progress-bar   { background-color: var(--ms-primary)   !important; color: var(--ms-bg) !important; }

/* ---- Tooltips & popovers ----------------------------------- */
.tooltip-inner      { background-color: var(--ms-surface-3); color: var(--ms-text); border: 1px solid var(--ms-border); }
.popover            { background-color: var(--ms-surface-2) !important; border-color: var(--ms-border) !important; }
.popover-header     { background-color: var(--ms-surface-3) !important; border-color: var(--ms-border) !important; color: var(--ms-text) !important; }
.popover-body       { color: var(--ms-text) !important; }

/* ---- Misc Bootstrap helpers -------------------------------- */
.text-muted         { color: var(--ms-text-muted) !important; }
.text-primary       { color: var(--ms-primary)    !important; }
.text-success       { color: var(--ms-success-light) !important; }
.text-warning       { color: var(--ms-warning-light) !important; }
.text-danger        { color: var(--ms-danger-light)  !important; }
.text-info          { color: var(--ms-info-light)    !important; }
.text-light         { color: var(--ms-text)          !important; }
.bg-primary         { background-color: var(--ms-primary)    !important; color: var(--ms-bg)   !important; }
.bg-success         { background-color: var(--ms-success)    !important; color: #fff !important; }
.bg-warning         { background-color: var(--ms-warning)    !important; color: #fff !important; }
.bg-danger          { background-color: var(--ms-danger)     !important; color: #fff !important; }
.bg-info            { background-color: var(--ms-info)       !important; color: #fff !important; }
.bg-secondary       { background-color: var(--ms-surface-2)  !important; }
.bg-dark            { background-color: var(--ms-surface-1)  !important; }
.border             { border-color: var(--ms-border) !important; }
.border-primary     { border-color: var(--ms-primary) !important; }
hr                  { border-color: var(--ms-border); opacity: 0.5; }

/* MS logo: slightly muted */
img[src*="ms_logo"] { opacity: 0.8; }

/* ---- Dash-specific: Select / Dropdown ---------------------- */
.Select-control,
.Select-menu-outer,
.VirtualizedSelectFocusedOption,
.VirtualizedSelectOption {
  background-color: var(--ms-surface-1) !important;
  border-color:     var(--ms-border)    !important;
  color:            var(--ms-text)      !important;
}
.Select--single > .Select-control .Select-value,
.Select-placeholder          { color: var(--ms-text-muted) !important; }
.Select-value,
.Select-value-label          { color: var(--ms-text) !important; } /* multi-select chips */
.Select-input > input        { color: var(--ms-text) !important; } /* text typed while searching */
.Select-option.is-focused    { background-color: var(--ms-surface-2) !important; color: var(--ms-text) !important; }
.Select-option.is-selected   { background-color: var(--ms-surface-3) !important; color: var(--ms-text) !important; }
.Select-arrow                { border-top-color: var(--ms-text-muted) !important; }
.Select-control:hover        { border-color: var(--ms-primary) !important; }

/* Dash dcc.Dropdown (newer) */
.dash-dropdown .Select-control  { background-color: var(--ms-surface-1) !important; border-color: var(--ms-border) !important; }
.dash-dropdown .Select-menu-outer { background-color: var(--ms-surface-2) !important; border-color: var(--ms-border) !important; }

/* ddheading dropdowns: large text-only appearance, matching h1's size, no border/background */
.ddheading {
  font-weight: 400;
  font-size: 2.4rem;
  height: 45px;
  padding: 5px;
}
.ddheading .Select-control {
  background-color: transparent !important;
  border-color:     transparent !important;
  box-shadow:       none        !important;
}
.ddheading .Select-control:hover {
  border-color: var(--ms-border) !important;
}

/* ---- Dash slider --------------------------------------------- */
.rc-slider-rail     { background-color: var(--ms-border)    !important; }
.rc-slider-track    { background-color: var(--ms-primary)   !important; }
.rc-slider-handle   { border-color:     var(--ms-primary)   !important; background-color: var(--ms-primary) !important; }
.rc-slider-handle:hover,
.rc-slider-handle:active { border-color: var(--ms-primary-dark) !important; box-shadow: 0 0 0 5px rgba(224, 183, 115, 0.2) !important; }
.rc-slider-dot-active { border-color: var(--ms-primary) !important; }

/* iQPerf: sailor range slider — red active track/handles to match sailor color */
#rangeSliderRacingFrame .rc-slider-track { background-color: #c0392b !important; }
#rangeSliderRacingFrame .rc-slider-handle { border-color: #c0392b !important; background-color: #c0392b !important; }
#rangeSliderRacingFrame .rc-slider-handle:hover,
#rangeSliderRacingFrame .rc-slider-handle:active {
  border-color:     #e74c3c !important;
  background-color: #e74c3c !important;
  box-shadow:       0 0 5px #e74c3c !important;
}

/* ---- Scrollbars -------------------------------------------- */
::-webkit-scrollbar              { width: 7px; height: 7px; }
::-webkit-scrollbar-track        { background: var(--ms-bg); }
::-webkit-scrollbar-thumb        { background: var(--ms-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover  { background: var(--ms-surface-3); }

/* ---- Selection --------------------------------------------- */
::selection { background: rgba(224, 183, 115, 0.22); color: var(--ms-text); }

/* ---- AG Grid (ag-theme-balham) dark overrides -------------- */
.ag-theme-balham {
  --ag-background-color:            var(--ms-bg);
  --ag-foreground-color:            var(--ms-text);
  --ag-header-background-color:     var(--ms-surface-2);
  --ag-header-foreground-color:     var(--ms-text);
  --ag-odd-row-background-color:    var(--ms-surface-1);
  --ag-row-hover-color:             rgba(224, 183, 115, 0.07);
  --ag-selected-row-background-color: rgba(224, 183, 115, 0.12);
  --ag-border-color:                var(--ms-border);
  --ag-secondary-border-color:      var(--ms-border);
  --ag-row-border-color:            var(--ms-border);
  --ag-cell-horizontal-border:      solid var(--ms-border);
  --ag-input-border-color:          var(--ms-border);
  --ag-input-background-color:      var(--ms-surface-1);
  --ag-disabled-foreground-color:   var(--ms-text-muted);
  --ag-chip-background-color:       var(--ms-surface-3);
  --ag-input-focus-border-color:    var(--ms-primary);
  --ag-range-selection-border-color: var(--ms-primary);
  --ag-checkbox-checked-color:      var(--ms-primary);
  --ag-icon-color:                  var(--ms-text);
}

/* AG Grid header icons — invert black SVG icons to light for dark theme */
.ag-theme-balham .ag-header-icon .ag-icon,
.ag-theme-balham .ag-header-cell-menu-button .ag-icon {
  filter: invert(1) opacity(0.6);
}

/* Pagination panel */
.ag-theme-balham .ag-paging-panel {
  background-color: var(--ms-surface-1) !important;
  color:            var(--ms-text)      !important;
  border-top:       1px solid var(--ms-border) !important;
}
.ag-theme-balham .ag-paging-button .ag-icon,
.ag-theme-balham .ag-paging-button {
  color: var(--ms-text) !important;
}
.ag-theme-balham .ag-paging-button:hover .ag-icon,
.ag-theme-balham .ag-paging-button:hover {
  color: var(--ms-primary) !important;
}
.ag-theme-balham .ag-paging-button[disabled] .ag-icon,
.ag-theme-balham .ag-paging-button[disabled] {
  color: var(--ms-text-muted) !important;
}

/* Header */
.ag-theme-balham .ag-header {
  background-color: var(--ms-surface-2) !important;
  border-bottom:    1px solid var(--ms-border) !important;
}
.ag-theme-balham .ag-header-cell,
.ag-theme-balham .ag-header-group-cell {
  color: var(--ms-text) !important;
}
.ag-theme-balham .ag-header-cell:hover {
  background-color: var(--ms-surface-3) !important;
}
.ag-theme-balham .ag-header-cell-resize::after {
  background-color: var(--ms-border) !important;
}
.ag-theme-balham .ag-sort-indicator-icon .ag-icon {
  color: var(--ms-text-muted) !important;
}
.ag-theme-balham .ag-icon-filter {
  color: var(--ms-text-muted) !important;
}

/* Filter / floating filter */
.ag-theme-balham .ag-floating-filter-input input,
.ag-theme-balham .ag-text-field-input {
  background-color: var(--ms-surface-1) !important;
  color:            var(--ms-text)      !important;
  border-color:     var(--ms-border)    !important;
}

/* Icons throughout (sort, filter, menu) */
.ag-theme-balham .ag-icon {
  color: var(--ms-text) !important;
}
.ag-theme-balham .ag-icon:hover {
  color: var(--ms-primary) !important;
}

/* Column menu */
.ag-theme-balham .ag-menu {
  background-color: var(--ms-surface-2) !important;
  border-color:     var(--ms-border)    !important;
  color:            var(--ms-text)      !important;
}
.ag-theme-balham .ag-menu-option:hover {
  background-color: var(--ms-surface-3) !important;
}

/* Tooltip */
.ag-theme-balham .ag-tooltip {
  background-color: var(--ms-surface-3) !important;
  border-color:     var(--ms-border)    !important;
  color:            var(--ms-text)      !important;
  white-space:      pre-line;   /* honour \n in multi-line tooltips (e.g. tableFairMult calculation notes) */
  max-width:        420px;
}

/* Specific grids (FairMult/PnL/EBIT/PtfD/Sailor/Screen/Diary/... tables):
   transparent background + no border, to match the surrounding dark tile.
   :is() collapses what was previously ~50 lines of one selector per table ID. */
:is(#tableFairMult, #tb_rev, #tb_ebit, #ptfd_table, #tableSailor, #screenTable,
    #tb, #table, #t1, #tableOptions, #diary_table).ag-theme-balham
  :is(.ag-root-wrapper, .ag-header, .ag-header-row, .ag-header-cell, .ag-body-viewport) {
  background-color: transparent !important;
  border-color: transparent !important;
}
:is(#tableFairMult, #tb_rev, #tb_ebit, #ptfd_table, #tableSailor, #screenTable,
    #tb, #table, #t1, #tableOptions, #diary_table).ag-theme-balham .ag-root-wrapper {
  border: none !important;
}
:is(#tableFairMult, #tb_rev, #tb_ebit, #ptfd_table, #tableSailor, #screenTable,
    #tb, #table, #t1, #tableOptions, #diary_table).ag-theme-balham .ag-header-cell-label {
  color: var(--ms-text-muted);
}

/* ---- Swipe carousel ------------------------------------------ */
#carousel-container {
  width: 400px;
  overflow: hidden;
  margin: auto;
  touch-action: pan-y; /* allow horizontal swipes */
}
#carousel-track {
  display: flex;
  transition: transform 0.5s ease-in-out;
  width: 100%;
}
.carousel-image {
  width: 400px;
  flex-shrink: 0;
  user-select: none;
  pointer-events: none; /* image doesn't block swipe */
}

/* ---- News app (app_news) ------------------------------------- */
.ms-news {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1400px;
  margin: 0 auto;
}
.news-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}
.news-stock { flex: 1 1 320px; max-width: 460px; }
.news-eyebrow {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ms-text-muted);
  margin-bottom: 4px;
}
.news-stock-dd .Select-control {
  background-color: var(--ms-tile) !important;
  border: 1px solid var(--ms-tile-highlight) !important;
  border-radius: 8px !important;
  height: 46px;
}
.news-stock-dd .Select-value-label,
.news-stock-dd .Select-placeholder,
.news-stock-dd .Select-input > input {
  font-size: 20px;
  font-weight: 600;
  line-height: 44px;
}
.news-stock-dd .Select-value-label { color: var(--ms-primary) !important; }
.news-stock-dd .Select-placeholder,
.news-stock-dd .Select--single > .Select-control .Select-value { line-height: 44px; }

.news-weblinks { flex: 1 1 300px; }
.news-weblinks > div > div { display: flex !important; flex-wrap: wrap; gap: 6px; }
.news-weblinks a,
.news-weblinks span:has(> i) {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background-color: var(--ms-tile);
  text-decoration: none;
}
.news-weblinks a:hover,
.news-weblinks span:has(> i):hover { background-color: var(--ms-tile-highlight); }
.news-weblinks a:hover i { color: var(--ms-primary) !important; }
.news-weblinks i { padding: 0 !important; font-size: 15px; }
.news-weblinks img { margin: 0 !important; }

.news-logo { margin-left: auto; align-self: center; }
.news-logo img { height: 44px; width: auto; display: block; }

.news-tile {
  background-color: var(--ms-tile);
  border: 1px solid var(--ms-tile-highlight);
  border-radius: 12px;
  overflow: hidden;
}
.news-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ms-tile-highlight);
}
.news-title { display: flex; align-items: baseline; gap: 10px; margin-right: auto; }
.news-title h2 { margin: 0; font-size: 20px; font-weight: 600; color: var(--ms-text); }
.news-title span { font-size: 13px; color: var(--ms-text-muted); }

/* Segmented controls: News/Alerts checklist and period buttons */
.news-seg {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 8px;
  background-color: var(--ms-bg);
}
.news-seg label,
.news-seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  margin: 0 !important;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ms-text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.news-seg label:hover,
.news-seg-btn:hover { color: var(--ms-text); }
.news-seg input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }
.news-seg label { display: inline-flex !important; }  /* dcc.Checklist sets an inline display */
.news-seg label span { display: inline-flex; align-items: center; gap: 6px; }
.news-seg label:has(input:checked),
.news-seg-btn.active { background-color: var(--ms-primary); color: var(--ms-bg); }
.news-seg label:has(input:focus-visible),
.news-seg-btn:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }

/* Date range picker */
.news-dates .DateRangePickerInput {
  background-color: var(--ms-bg) !important;
  border: 1px solid var(--ms-tile-highlight) !important;
  border-radius: 8px;
  overflow: hidden;
}
.news-dates .DateInput,
.news-dates .DateInput_input {
  background-color: transparent !important;
  color: var(--ms-text) !important;
  border: 0 !important;
  font-size: 14px;
  width: 112px;
  height: 38px;
  line-height: 38px;
  padding: 0 12px;
}
.news-dates .DateRangePickerInput { display: inline-flex; align-items: center; }
.news-dates .DateInput_input__focused { border-bottom: 2px solid var(--ms-primary) !important; }
.news-dates .DateRangePickerInput_arrow_svg { fill: var(--ms-text-muted); }

/* Headline filter */
.news-search {
  flex: 1 1 200px;
  max-width: 280px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--ms-tile-highlight);
  border-radius: 8px;
  background-color: var(--ms-bg);
  color: var(--ms-text-muted);
}
.news-search:focus-within { border-color: var(--ms-primary); }
.news-search input {
  flex: 1;
  min-width: 0;
  height: 38px;
  border: 0 !important;
  background: transparent !important;
  color: var(--ms-text) !important;
  font-size: 14px;
  outline: none;
  box-shadow: none !important;
}

/* News grid */
#newsTable.ag-theme-balham :is(.ag-root-wrapper, .ag-body-viewport, .ag-center-cols-viewport) {
  background-color: transparent !important;
  border: none !important;
}
#newsTable.ag-theme-balham .ag-header {
  background-color: rgba(var(--ms-bg-rgb), 0.35) !important;
  border-bottom: 1px solid var(--ms-tile-highlight) !important;
}
#newsTable.ag-theme-balham .ag-header-cell-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ms-text-muted);
}
#newsTable.ag-theme-balham .ag-row {
  background-color: var(--ms-tile) !important;
  border-color: rgba(var(--ms-border-rgb), 0.45) !important;
  font-size: 14px;
}
#newsTable.ag-theme-balham .ag-row-odd { background-color: #1a2030 !important; }
#newsTable.ag-theme-balham .ag-row:hover { background-color: var(--ms-tile-highlight) !important; }
#newsTable.ag-theme-balham .ag-cell { display: flex; align-items: center; padding-left: 20px; }
#newsTable .news-cell-muted { color: var(--ms-text-muted); font-variant-numeric: tabular-nums; }
#newsTable .news-cell-title,
#newsTable .news-cell-title p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; }
#newsTable .news-cell-title a { color: #E6E7EE; font-weight: 500; text-decoration: none; }
#newsTable .news-cell-title a:hover { color: var(--ms-primary); }
#newsTable .news-cell-title a:visited { color: var(--ms-text-muted); }
#newsTable .ag-cell p { margin: 0; }
.news-chip {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
}
.news-chip-news  { background-color: rgba(64, 119, 209, 0.18); color: #8fb0ea; }
.news-chip-alert { background-color: var(--ms-primary-subtle); color: var(--ms-primary); }
#newsTable.ag-theme-balham .ag-paging-panel {
  border-top: 1px solid var(--ms-tile-highlight) !important;
  height: 48px;
  padding: 0 20px;
}
.news-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--ms-text-muted);
  font-size: 15px;
}
.news-empty i { font-size: 32px; opacity: 0.6; }

@media (max-width: 640px) {
  .ms-news { padding: 12px 16px 24px; }
  .news-toolbar { padding: 12px 16px; }
  .news-title { flex-basis: 100%; }
  .news-search { max-width: none; }
}

/* ---- Stock dossier app (app_dossier) ------------------------- */
/* Header, toolbars and segmented controls reuse the .news-* classes above. */
.ms-dossier {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1400px;
  margin: 0 auto;
}
.ms-dossier .news-seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.ms-dossier .pos { color: var(--ms-success-light); }
.ms-dossier .neg { color: var(--ms-danger-light); }
.hist-muted { color: var(--ms-text-muted); }
.hist-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* KPI strip */
.hist-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.hist-kpi-tiles { display: contents; }
.hist-kpi {
  min-width: 0;
  padding: 12px 16px;
  background-color: var(--ms-tile);
  border: 1px solid var(--ms-tile-highlight);
  border-radius: 12px;
}
.hist-kpi-v {
  font-size: 22px;
  font-weight: 650;
  color: var(--ms-text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-kpi-v small { font-size: 15px; font-weight: 600; }
.hist-kpi-s { font-size: 12px; color: var(--ms-text-muted); font-variant-numeric: tabular-nums; }
.hist-irr-neg { border-color: rgba(204, 102, 96, 0.55); background-color: rgba(136, 56, 53, 0.18); }
.hist-irr-pos { border-color: rgba(118, 195, 171, 0.55); background-color: rgba(62, 128, 108, 0.18); }

/* Main grid: chart + news left, journal right */
.hist-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 16px;
  align-items: start;
}
.hist-grid .news-tile .js-plotly-plot { padding: 4px 8px 0; }
.hist-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 6px 20px 8px;
  font-size: 12px;
  color: var(--ms-text-muted);
}
.hist-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.hist-sw { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.hist-sw-band { height: 8px; background-color: var(--ms-primary); opacity: 0.35; }
.hist-range-note { padding: 0 20px 14px; font-size: 12px; color: var(--ms-text-muted); }
.hist-range-note i { color: var(--ms-primary); margin-right: 6px; }

/* News */
.hist-news { margin-top: 16px; }
.hist-link { font-size: 13px; color: var(--ms-primary); text-decoration: none; }
.hist-link:hover { color: var(--ms-text); }
.hist-news-list { list-style: none; margin: 0; padding: 0; }
.hist-news-list li {
  display: flex;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--ms-tile-highlight);
  font-size: 13px;
}
.hist-news-list li:last-child { border-bottom: 0; }
.hist-news-list a { color: #E6E7EE; text-decoration: none; }
.hist-news-list a:hover { color: var(--ms-primary); }
.hist-when { flex: 0 0 90px; color: var(--ms-text-muted); font-size: 12px; }
.hist-src { margin-left: auto; color: var(--ms-text-muted); font-size: 12px; white-space: nowrap; }
.hist-empty { padding: 20px; color: var(--ms-text-muted); font-size: 13px; }

/* Journal */
.hist-add { padding: 14px 20px; border-bottom: 1px solid var(--ms-tile-highlight); }
.hist-textarea {
  width: 100%;
  min-height: 64px;
  resize: vertical;
  padding: 10px 12px;
  background-color: var(--ms-bg) !important;
  color: var(--ms-text) !important;
  border: 1px solid var(--ms-border) !important;
  border-radius: 8px;
  font-size: 14px;
}
.hist-textarea:focus { outline: none; border-color: var(--ms-primary) !important; }
.hist-add-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--ms-text-muted);
}
.hist-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background-color: var(--ms-primary);
  color: var(--ms-bg);
  font-size: 13px;
  font-weight: 600;
}
.hist-btn:hover { background-color: var(--ms-primary-dark); }
.hist-entries { max-height: 1000px; overflow-y: auto; }
.hist-entry {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--ms-tile-highlight);
  cursor: pointer;
}
.hist-entry:hover { background-color: rgba(255, 255, 255, 0.02); }
.hist-entry.hl { background-color: var(--ms-primary-subtle); }
.hist-ico {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background-color: var(--ms-bg);
  font-size: 13px;
}
.hist-entry-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.hist-kind { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.hist-date { font-size: 12px; color: var(--ms-text-muted); }
.hist-num { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ms-text); }
.hist-num small { font-size: 12px; }
.hist-c-val  { color: #ECA758; }
.hist-c-note { color: #8fa8ff; }
.hist-c-buy  { color: #76C3AB; }
.hist-c-sell { color: var(--ms-danger-light); }
.hist-c-div  { color: var(--ms-success-light); }
.hist-md { margin-top: 4px; font-size: 13px; color: var(--ms-text); }
.hist-md p { margin: 0 0 4px; }
.hist-entry p.hist-muted { margin: 4px 0 0; font-size: 13px; }
.hist-metrics { margin-top: 4px; font-size: 12px; color: var(--ms-text-muted); }
.hist-del { color: var(--ms-text-muted); visibility: hidden; padding: 0 2px; }
.hist-entry:hover .hist-del { visibility: visible; }
.hist-del:hover { color: var(--ms-danger-light); }

@media (max-width: 1100px) {
  .hist-grid { grid-template-columns: minmax(0, 1fr); }
  .hist-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .ms-dossier { padding: 12px 16px 24px; }
  .hist-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hist-del { visibility: visible; }
}
/* Layer toggles keep their colour dot visible, so they use a subtle active state */
#hist-layers label:has(input:checked) { background-color: var(--ms-tile-highlight); color: var(--ms-primary); }
#hist-layers label:not(:has(input:checked)) .hist-dot { opacity: 0.35; }
#hist-layers label > span { display: inline-flex; align-items: center; gap: 6px; }
.ms-dossier .news-title h2 { white-space: nowrap; }

/* ---- Trend app (app_trend) ----------------------------------- */
/* Header, tiles, toolbars, KPI tiles and segmented controls reuse .news-* / .hist-* above. */
.ms-trend {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1600px;
  margin: 0 auto;
}
.ms-trend .news-seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.ms-trend .news-header { align-items: center; }
.ms-trend .snap-stock { align-self: flex-end; }  /* stock selector + currency line */
.ms-trend .news-title h2 { white-space: nowrap; }

/* Header actions: pause pills, alert toggle, delete */
.trend-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.trend-actions a { text-decoration: none; }
.trend-actions .news-seg,
.trend-actions .trend-icon-btn { background-color: var(--ms-tile); border: 1px solid var(--ms-tile-highlight); }
.trend-actions .trend-icon-btn { width: 40px; height: 40px; }
.trend-alert-comment:empty { display: none; }
.trend-alert-comment { font-size: 12px; color: var(--ms-text-muted); max-width: 220px; }

.trend-icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background-color: var(--ms-bg);
  color: var(--ms-text-muted);
  cursor: pointer;
}
.trend-icon-btn:hover { background-color: var(--ms-tile-highlight); color: var(--ms-primary); }
.trend-icon-btn.trend-icon-danger:hover { color: var(--ms-danger-light); }
.trend-icon-btn:focus-visible,
.trend-save-btn:focus-visible,
.trend-pipe-step:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }

/* Pipeline stepper */
.trend-pipeline { display: flex; flex-direction: column; }
.trend-pipe-steps {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 8px;
  background-color: var(--ms-tile);
  border: 1px solid var(--ms-tile-highlight);
}
.trend-pipe-step {
  width: 32px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ms-text-muted);
  cursor: pointer;
}
.trend-pipe-step:hover { color: var(--ms-text); }
.trend-pipe-step.active { background-color: var(--ms-success); color: #fff; }
.trend-pipe-step.rejected { background-color: var(--ms-danger); color: #fff; }
.trend-pipe-sep { font-size: 9px; color: var(--ms-tile-highlight); }

/* KPI strip */
.trend-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.trend-q-good { border-color: rgba(118, 195, 171, 0.55); background-color: rgba(62, 128, 108, 0.18); }
.trend-q-good .hist-kpi-v { color: var(--ms-success-light); }
.trend-q-mid  { border-color: rgba(236, 167, 88, 0.55);  background-color: rgba(187, 134, 75, 0.18); }
.trend-q-mid .hist-kpi-v { color: var(--ms-warning-light); }
.trend-q-bad  { border-color: rgba(204, 102, 96, 0.55);  background-color: rgba(136, 56, 53, 0.18); }
.trend-q-bad .hist-kpi-v { color: var(--ms-danger-light); }

/* Main grid: chart left, trend-channel settings right */
.trend-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}
/* Fixed-size box for the chart; padding must stay off .js-plotly-plot (Plotly measures it -> chart grows on each redraw) */
.trend-graph { height: 800px; padding: 4px 8px 8px; box-sizing: border-box; }
.trend-seg > div { display: contents; }          /* four dcc.Checklists act as one pill group */
.trend-bm:empty, .trend-bm:not(:has(label)) { display: none; }

/* Right column: trend settings, below them the diary comments */
.trend-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.trend-comments .hist-textarea { display: block; width: 100%; min-height: 110px; }
.trend-comments .hist-add-row .hist-btn { margin-left: auto; }
.trend-comments .hist-add-row .trend-confirm { margin-left: 0; }
.trend-comment-list { max-height: 520px; overflow-y: auto; }
.trend-comment { padding: 10px 20px; border-bottom: 1px solid var(--ms-tile-highlight); }
.trend-comment:last-child { border-bottom: 0; }
.trend-comment .hist-md { overflow-wrap: anywhere; }

/* Channel alerts tile: four set buttons, then the stock's alerts (waiting / fired) */
.trend-alert-btns { display: flex; flex-wrap: wrap; margin-bottom: 8px; }
.trend-alert-btns .news-seg-btn { flex: 1 1 auto; justify-content: center; padding: 0 10px; }
.trend-alerts .trend-block .hist-empty { padding-left: 0; padding-right: 0; }
.trend-alert-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.trend-alert-row .fa-bell { color: var(--ms-primary); }
.trend-alert-row .fa-check { color: var(--ms-success-light); }
.trend-alert-row code { color: var(--ms-text-muted); background: none; }
.trend-alert-row .news-seg-btn { min-height: 28px; padding: 0 10px; font-size: 12px; }

/* Settings tile */
.trend-confirm { margin-left: auto; font-size: 12px; color: var(--ms-success-light); }
.trend-confirm:empty { display: none; }
.trend-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background-color: var(--ms-primary);
  color: var(--ms-bg);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.trend-save-btn:hover { background-color: var(--ms-primary-dark); }
.trend-block { padding: 14px 20px 16px; border-bottom: 1px solid var(--ms-tile-highlight); }
.trend-block:last-child { border-bottom: 0; }
.trend-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  margin-bottom: 8px;
}
.trend-block-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ms-text);
}
.trend-block-actions { display: flex; gap: 6px; }
.trend-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.trend-field { display: block; min-width: 0; margin: 0; }
.trend-input {
  display: flex;
  align-items: center;
  height: 38px;
  border-radius: 8px;
  background-color: var(--ms-bg);
  border: 1px solid var(--ms-tile-highlight);
  overflow: hidden;
}
.trend-input:focus-within { border-color: var(--ms-primary); }
.trend-input input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0 8px 0 12px;
  border: 0 !important;
  background: transparent !important;
  color: var(--ms-text) !important;
  text-align: right;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.trend-input span { padding: 0 12px 0 2px; font-size: 12px; color: var(--ms-text-muted); white-space: nowrap; }
.trend-slider { padding: 34px 6px 18px; }           /* room for the daq handle label above */
.trend-slider .rc-slider-mark-text { color: var(--ms-text-muted); font-size: 11px; }
.trend-slider .rc-slider-handle .label,
.trend-slider .rc-slider-handle .value { color: var(--ms-bg) !important; font-weight: 600; }

@media (max-width: 1100px) {
  .trend-grid { grid-template-columns: minmax(0, 1fr); }
  .trend-graph { height: 640px; }
  .trend-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .ms-trend { padding: 12px 16px 24px; }
  .trend-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Stock screener (app_screen) ----------------------------- */
/* Header, tiles, toolbars and segmented controls reuse .news-* above. */
.ms-screen {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1600px;
  margin: 0 auto;
}
.ms-screen .news-header { align-items: center; }
.screen-heading h1 { margin: 0; font-size: 26px; font-weight: 650; color: var(--ms-text); }
.ms-screen .news-tile { margin-bottom: 16px; }
.ms-screen .news-title h2 { white-space: nowrap; }

.screen-icon-btn {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--ms-tile-highlight);
  border-radius: 8px;
  background-color: var(--ms-bg);
  color: var(--ms-text-muted);
  text-decoration: none;
  cursor: pointer;
}
.screen-icon-btn:hover { background-color: var(--ms-tile-highlight); color: var(--ms-primary); }
.screen-icon-btn.active { color: var(--ms-success-light); border-color: rgba(118, 195, 171, 0.55); background-color: rgba(62, 128, 108, 0.18); }
.screen-icon-btn:focus-visible,
.screen-save-btn:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }

/* Filter bar */
.screen-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 16px 28px;
  padding: 14px 20px 16px;
  overflow: visible;   /* .news-tile clips; dropdown menus must hang out of the card */
}
.screen-filter { display: flex; flex-direction: column; justify-content: space-between; gap: 6px; min-width: 0; }
.screen-quality { flex: 0 1 240px; }
.screen-quality .rc-slider { margin: 10px 6px 0; }
.screen-quality .rc-slider-mark-text { color: var(--ms-text-muted) !important; font-size: 11px; }
.screen-tags { flex: 1 1 320px; }
.screen-tags-row { display: flex; gap: 8px; align-items: center; }
.screen-tags-row > .dash-dropdown { flex: 1 1 auto; min-width: 0; }
.ms-screen .news-seg label { min-height: 32px; padding: 0 12px; }
.screen-strategy { flex: 1 1 480px; }
.screen-strategy .screen-tags-row > .dash-dropdown { flex: 1 1 200px; min-width: 270px; }   /* option rows have a fixed height: wide enough for 'Temporarily Unloved (UNLOV, draft)' */
.screen-strategy .news-seg { flex: 0 0 auto; }
.screen-info { min-height: 16px; font-size: 11.5px; color: var(--ms-text-muted); }
.news-seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }

/* Matrix + details */
.screen-main {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;   /* matrix tile grows to the height of the details tile */
}
.screen-matrix { display: flex; flex-direction: column; }
/* dcc.Loading's wrapper divs pass the stretch down to the graph box */
.screen-matrix div:has(.screen-graph) { flex: 1 1 auto; display: flex; flex-direction: column; }
.screen-details { align-self: start; }
.screen-axes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 12px 20px 4px;
}
.screen-axis { display: block; min-width: 0; margin: 0; }
.screen-axis .news-eyebrow i { margin-right: 6px; }
/* Matrix box: at least 560px, stretches with the row. The graph is absolutely positioned so its own
   size never feeds back into the row height (no growth loop; shrinks again for a shorter detail panel). */
.screen-graph { flex: 1 1 auto; position: relative; min-height: 560px; }
.screen-graph > .dash-graph { position: absolute; inset: 4px 8px 8px; }

.screen-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 280px;
  padding: 24px;
  text-align: center;
  color: var(--ms-text-muted);
}
.screen-empty i { font-size: 26px; color: var(--ms-tile-highlight); }
.screen-empty p { margin: 0; max-width: 260px; }

.screen-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ms-tile-highlight);
}
.screen-detail-title { min-width: 0; }
.screen-detail-title h2 { margin: 0; font-size: 20px; font-weight: 600; color: var(--ms-primary); }
.screen-detail-actions { display: flex; align-items: center; gap: 8px; }
.screen-pause-dd { width: 160px; }
.screen-weblinks { padding: 12px 20px 0; }
.screen-detail-body { padding: 14px 20px 18px; display: flex; flex-direction: column; gap: 14px; }
.screen-swipe { display: block; width: 100%; max-width: 600px; height: auto; margin: 0 auto; border-radius: 8px; }
.screen-comment { display: block; margin: 0; }
.screen-comment textarea {
  display: block;
  width: 100%;
  min-height: 120px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--ms-tile-highlight);
  background-color: var(--ms-bg);
  color: var(--ms-text);
  resize: vertical;
}
.screen-comment textarea:focus { outline: none; border-color: var(--ms-primary); }
.screen-comment-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.screen-confirm { font-size: 12px; color: var(--ms-success-light); }
.screen-confirm p { margin: 0; }
.screen-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background-color: var(--ms-primary);
  color: var(--ms-bg);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.screen-save-btn:hover { background-color: var(--ms-primary-dark); }

/* Screening list */
.screen-toolbar-actions { display: flex; gap: 8px; margin-left: auto; }
.screen-cols { padding: 10px 20px 0; }
.screen-cols summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ms-text-muted);
  cursor: pointer;
  list-style: none;
}
.screen-cols summary::-webkit-details-marker { display: none; }
.screen-cols summary:hover,
.screen-cols[open] summary { color: var(--ms-primary); }
.screen-cols .dash-dropdown { margin-top: 10px; }
.screen-grid-wrap { padding: 12px 12px 14px; }

@media (max-width: 1100px) {
  .screen-main { grid-template-columns: minmax(0, 1fr); }
  .screen-graph { min-height: 480px; }
}
@media (max-width: 640px) {
  .ms-screen { padding: 12px 16px 24px; }
  .screen-axes { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Portfolio Designer (app_ptfd) --------------------------- */
/* Header, tiles, toolbars, KPI tiles and segmented controls reuse .news-* / .hist-* above. */
.ms-ptfd {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1600px;
  margin: 0 auto;
}
.ms-ptfd .news-header { align-items: center; }
.ms-ptfd .news-tile { margin-bottom: 16px; }
.ms-ptfd .news-title h2 { white-space: nowrap; }
.ms-ptfd .news-seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.ms-ptfd .news-seg label { min-height: 32px; padding: 0 12px; }
.ms-ptfd .news-seg label:has(input:checked) { background-color: var(--ms-primary); color: var(--ms-bg); }
.ptfd-heading h1 { margin: 0; font-size: 26px; font-weight: 650; color: var(--ms-text); }
.ptfd-mode { background-color: var(--ms-tile) !important; border: 1px solid var(--ms-tile-highlight); }
.ptfd-info { padding: 12px 20px 4px; font-size: 13px; color: var(--ms-text-muted); }

.ptfd-icon-btn {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--ms-tile-highlight);
  border-radius: 8px;
  background-color: var(--ms-bg);
  color: var(--ms-text-muted);
  cursor: pointer;
}
.ptfd-icon-btn:hover { background-color: var(--ms-tile-highlight); color: var(--ms-primary); }
.ptfd-icon-btn.active { color: var(--ms-success-light); border-color: rgba(118, 195, 171, 0.55); background-color: rgba(62, 128, 108, 0.18); }
.ptfd-icon-btn:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }
.news-header .ptfd-icon-btn { background-color: var(--ms-tile); }

/* KPI strip */
.ptfd-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.ptfd-kpis .hist-kpi-s { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Matrix + details */
.ptfd-main {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;   /* matrix tile grows to the height of the details tile */
}
.ptfd-matrix { display: flex; flex-direction: column; }
/* dcc.Loading's wrapper divs pass the stretch down to the graph box */
.ptfd-matrix div:has(.ptfd-graph) { flex: 1 1 auto; display: flex; flex-direction: column; }
.ptfd-details { align-self: start; }
.ptfd-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  padding: 12px 20px 4px;
}
.ptfd-quality { flex: 0 1 220px; display: flex; flex-direction: column; }
.ptfd-quality .rc-slider { margin: 10px 6px 0; }
.ptfd-quality .rc-slider-mark-text { color: var(--ms-text-muted) !important; font-size: 11px; }
/* Graph box: at least 640px; the graph is absolutely positioned so its size never feeds back into the row */
.ptfd-graph { flex: 1 1 auto; position: relative; min-height: 640px; }
.ptfd-graph > .dash-graph { position: absolute; inset: 4px 8px 8px; }

.ptfd-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 280px;
  padding: 24px;
  text-align: center;
  color: var(--ms-text-muted);
}
.ptfd-empty i { font-size: 26px; color: var(--ms-tile-highlight); }
.ptfd-empty p { margin: 0; max-width: 260px; }
.ptfd-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ms-tile-highlight);
}
.ptfd-detail-title { min-width: 0; }
.ptfd-detail-title h2 { margin: 0; font-size: 20px; font-weight: 600; color: var(--ms-primary); }
.ptfd-detail-actions { display: flex; align-items: center; gap: 8px; }
.ptfd-pause-dd { width: 160px; }
.ptfd-weblinks { padding: 12px 20px 0; }
.ptfd-detail-body { padding: 14px 20px 18px; }
.ptfd-swipe { display: block; width: 100%; max-width: 600px; height: auto; margin: 0 auto; border-radius: 8px; }

/* Table */
.ptfd-table .news-toolbar .news-stock { max-width: 340px; }
.ptfd-table .news-stock-dd .Select-control { height: 38px; }
.ptfd-table .news-stock-dd .Select-value-label,
.ptfd-table .news-stock-dd .Select-placeholder,
.ptfd-table .news-stock-dd .Select-input > input { font-size: 14px; font-weight: 500; line-height: 36px; }
.ptfd-table .news-stock-dd .Select--single > .Select-control .Select-value { line-height: 36px; }
.ptfd-grid-wrap { padding: 12px 12px 14px; }

@media (max-width: 1100px) {
  .ptfd-main { grid-template-columns: minmax(0, 1fr); }
  .ptfd-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ptfd-graph { min-height: 520px; }
}
@media (max-width: 640px) {
  .ms-ptfd { padding: 12px 16px 24px; }
  .ptfd-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Asset assistant (app_assetassistant) -------------------- */
/* Header, tiles, toolbars and eyebrow labels reuse .news-* above. */
.ms-assist {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1400px;
  margin: 0 auto;
}
.ms-assist .news-header { align-items: center; }
.ms-assist .news-tile { margin-bottom: 16px; }
.ms-assist .news-title { flex-wrap: wrap; }
.ms-assist .news-title h2 { white-space: nowrap; }
.assist-heading h1 { margin: 0; font-size: 26px; font-weight: 650; color: var(--ms-text); }
.assist-heading .news-eyebrow { margin-bottom: 2px; }

/* Search: name + button left, matches right */
.assist-search {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
  align-items: start;
  padding: 16px 20px 18px;
}
.assist-search-row { display: flex; gap: 8px; }
.assist-search-row .assist-input { flex: 1 1 auto; min-width: 0; }
/* No dropdown yet: hint/message sit level with the search field, same height as label + dropdown */
.assist-matches .assist-hint,
#WKN_dropdown_div > .assist-msg { display: flex; align-items: center; height: 57px; padding-top: 19px; }

/* Form */
.assist-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 16px;
  align-items: stretch;
}
.assist-col { display: flex; flex-direction: column; min-width: 0; }
.assist-col > .news-tile:last-child { flex: 1 1 auto; }   /* both columns end on the same line */
.assist-desc .assist-fields { grid-template-columns: minmax(0, 1fr); }
.assist-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
  align-content: start;
  padding: 16px 20px 18px;
}
.assist-field { min-width: 0; }
.assist-wide { grid-column: 1 / -1; }
.assist-required { color: var(--ms-primary); }

.assist-input,
.assist-textarea {
  display: block;
  width: 100%;
  padding: 0 12px;
  background-color: var(--ms-bg) !important;
  border-color: var(--ms-tile-highlight) !important;
  border-radius: 8px !important;
  font-size: 14px;
}
.assist-input { height: 38px; }
.assist-textarea { min-height: 200px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
.ms-assist .dash-dropdown .Select-control {
  height: 38px;
  background-color: var(--ms-bg) !important;
  border-color: var(--ms-tile-highlight) !important;
  border-radius: 8px !important;
}
.ms-assist .Select--single.has-value > .Select-control .Select-value { padding-right: 52px; }  /* long GICS labels stop before the clear/arrow icons */
.ms-assist .news-eyebrow { line-height: 1.4; }

.assist-loading { position: relative; }
.assist-feedback { font-size: 12px; margin-top: 4px; color: var(--ms-warning-light); }
.assist-feedback:empty { display: none; }
.assist-feedback p { margin: 0; }
.assist-hint { font-size: 13px; color: var(--ms-text-muted); }

.assist-btn {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  margin: 0;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background-color: var(--ms-primary);
  color: var(--ms-bg);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.assist-btn:hover { background-color: var(--ms-primary-dark); }
.assist-btn:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }

/* Submit bar: result message left, button right */
.assist-submit { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 14px 20px; }
.assist-result { flex: 1 1 280px; min-width: 0; min-height: 38px; display: flex; align-items: center; }
.assist-msg { display: inline-flex; align-items: baseline; gap: 8px; font-size: 14px; }
.assist-msg-ok { color: var(--ms-success-light); }
.assist-msg-warn { color: var(--ms-warning-light); }
.assist-msg-err { color: var(--ms-danger-light); }

@media (max-width: 900px) {
  .assist-grid,
  .assist-search { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .ms-assist { padding: 12px 16px 24px; }
  .assist-fields { grid-template-columns: minmax(0, 1fr); }
  .assist-submit .assist-btn { width: 100%; }
}

/* Valuation history (app_valhistory) */
.ms-valhist { max-width: 1480px; margin: 0 auto; padding: 20px 24px 40px; font-size: 14px; }
.ms-valhist .news-seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.ms-valhist .news-seg label:has(input:disabled) { opacity: .45; cursor: not-allowed; }
.vh-row { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 16px; }
.vh-tile { background-color: var(--ms-tile); border-radius: 10px; padding: 14px 16px; min-width: 0; box-sizing: border-box; }
.ms-valhist > div > .vh-tile, #vh-content > .vh-tile { margin-bottom: 16px; }
.vh-grow { flex: 999 1 560px; }
.vh-side { flex: 1 1 340px; display: flex; flex-direction: column; gap: 10px; }
.vh-tile h3 { margin: 0; font-size: 15px; font-weight: 600; color: #EAEFFF; }
.vh-tile h4 { margin: 0 0 2px; font-size: 13px; font-weight: 600; color: var(--ms-text); }
.vh-tile-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 16px; margin-bottom: 8px; }
.vh-muted { color: var(--ms-text-muted); font-size: 12px; }
.vh-text { margin: 0; font-size: 13px; line-height: 1.45; color: var(--ms-text); }
.vh-footnote { margin: 10px 0 0; font-size: 12px; line-height: 1.5; color: var(--ms-text-muted); }
.vh-notice { margin-bottom: 16px; padding: 8px 14px; border-left: 3px solid var(--ms-primary); background-color: var(--ms-tile); border-radius: 6px; }
.vh-notice p { margin: 2px 0; font-size: 13px; color: var(--ms-text); }
.vh-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.vh-kpi { background-color: #151C2C; border-radius: 8px; padding: 9px 10px; min-width: 0; }
.vh-kpi-value { font-size: 16px; font-weight: 600; color: #EAEFFF; margin-top: 2px; }
.vh-kpi-note { font-size: 12px; color: #A6AEBC; margin-top: 2px; }
.vh-comment { border-top: 1px solid #39435A; padding-top: 10px; font-size: 13px; line-height: 1.45; color: var(--ms-text); }
.vh-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.vh-chart { min-width: 0; }
.vh-table-wrap { overflow-x: auto; }
.vh-table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.vh-table th, .vh-table td { padding: 6px 10px; border-bottom: 1px solid #222B3F; white-space: nowrap; }
.vh-table thead th { color: var(--ms-text-muted); font-weight: 500; font-size: 12px; border-bottom: 1px solid #39435A; vertical-align: bottom; }
.vh-table td { color: var(--ms-text); }
.vh-table td.vh-muted { color: var(--ms-text-muted); }
.vh-table .vh-small { font-size: 12px; }
.vh-num { text-align: right; }
.vh-left { text-align: left; }
.vh-row-head { font-weight: 500; color: var(--ms-text); }
.vh-table .vh-gold, .vh-table thead .vh-gold { color: var(--ms-primary); }
.vh-th-sub { color: var(--ms-text); }
.vh-hl { background-color: #222B3F; }
.vh-group { padding-top: 12px !important; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ms-text-muted); font-weight: 500; text-align: left; }
.vh-var { font-weight: 600; }
.vh-table td.vh-pos { color: var(--ms-success-light); }
.vh-table td.vh-neg { color: var(--ms-danger-light); }
.vh-arrow { margin-right: 5px; color: #A6AEBC; }
.vh-pick { all: unset; display: block; box-sizing: border-box; width: 100%; min-height: 28px; line-height: 28px; cursor: pointer; color: #EAEFFF; border-radius: 4px; }
.vh-pick:hover { color: var(--ms-primary); }
.vh-pick:focus-visible { outline: 2px solid var(--ms-primary); }
.vh-selected-row { background-color: #313849; }
.vh-selected-row .vh-pick { color: #6EFACC; font-weight: 600; }
@media (max-width: 640px) { .ms-valhist { padding: 12px 16px 24px; } }

/* Expectations investing (app_expectationbased) */
.ms-expinv { max-width: 1480px; margin: 0 auto; padding: 20px 24px 48px; font-size: 14px; color: var(--ms-text); }
.ms-expinv .news-seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.ms-expinv .news-header { margin-bottom: 16px; }
.ei-saved { align-self: center; }
#ei-content > * + * { margin-top: 16px; }
.ei-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.ei-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 18px; font-size: 13px;
           text-decoration: none; white-space: nowrap; background: var(--ms-tile); border: 1px solid #39435A; color: #EAEFFF; }
a.ei-chip:hover { border-color: var(--ms-primary); color: #EAEFFF; }
a.ei-chip:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }
.ei-chip-n { color: var(--ms-primary); font-weight: 600; }
.ei-chip-later { background: transparent; border-style: dashed; color: var(--ms-text-muted); }
.ei-chip-later .ei-chip-n { color: var(--ms-text-muted); }
.ei-later { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.ei-tile { background-color: var(--ms-tile); border-radius: 10px; padding: 14px 16px; box-sizing: border-box; min-width: 0; scroll-margin-top: 12px; }
.ei-tile h2 { margin: 2px 0 12px; font-size: 15px; font-weight: 600; color: #EAEFFF; }
.ei-tile-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 10px 16px; margin-bottom: 12px; }
.ei-tile-head h2 { margin-bottom: 0; }
.ei-eyebrow { margin: 0; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ms-text-muted); }
.ei-eyebrow-row { display: flex; align-items: center; gap: 12px; }
.ei-help { display: inline-flex; align-items: center; gap: 5px; min-height: 24px; font-size: 12px; color: var(--ms-text-muted); text-decoration: none; }
.ei-help:hover, .ei-guide:hover { color: var(--ms-primary); }
.ei-help:focus-visible, .ei-guide:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }
.ei-guide { display: inline-flex; align-items: center; gap: 6px; align-self: center; min-height: 36px; padding: 0 12px; border-radius: 8px;
            background: var(--ms-tile); border: 1px solid #39435A; color: var(--ms-text); font-size: 13px; text-decoration: none; }
.ei-headline { margin: 4px 0 14px; font-size: 19px; line-height: 1.45; color: #EAEFFF; max-width: 1100px; }
.ei-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.ei-kpi, .ei-card { background: #151C2C; border-radius: 8px; padding: 10px 12px; min-width: 0; }
.ei-kpi-value { font-size: 22px; font-weight: 600; margin-top: 2px; }
.ei-kpi-sub { font-size: 12px; color: #A6AEBC; margin-top: 2px; line-height: 1.45; }
.ei-big { font-size: 24px; font-weight: 600; margin-top: 2px; }
.ei-muted { color: var(--ms-text-muted); font-size: 13px; }
.ei-sub { font-size: 11px; color: var(--ms-text-muted); }
.ei-gold { color: var(--ms-primary) !important; }
.ei-strong { font-weight: 600; }
.ei-white { color: #EAEFFF !important; }
.ei-neg { color: #ECA758 !important; }
.ei-text { margin: 0 0 10px; font-size: 13px; line-height: 1.45; color: #A6AEBC; }
.ei-footnote { margin: 10px 0 0; font-size: 12px; line-height: 1.6; color: #A6AEBC; }
.ei-warn { margin: 8px 0 0; font-size: 12px; color: #ECA758; }
.ei-warn:empty { display: none; }
.ei-notice { padding: 8px 14px; border-left: 3px solid var(--ms-primary); background-color: var(--ms-tile); border-radius: 6px; font-size: 13px; }
.ei-split { display: flex; flex-wrap: wrap; gap: 16px; }
.ei-main { flex: 999 1 560px; min-width: 0; }
.ei-side { flex: 1 1 280px; max-width: 360px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.ei-side-wide { max-width: none; flex-basis: 300px; }
.ei-side-cons { flex-basis: 400px; max-width: 460px; }
.ei-side-cons .ei-table th, .ei-side-cons .ei-table td { padding: 6px 6px; }
.ei-h3 { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: #EAEFFF; }
.ei-gap { margin-top: 12px; }
.ei-line, .ei-field { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0;
                      border-bottom: 1px solid #222B3F; font-size: 13px; font-variant-numeric: tabular-nums; }
.ei-line > span:last-child { color: #EAEFFF; text-align: right; }
.ei-field label { margin: 0; font-size: 13px; color: var(--ms-text); line-height: 1.3; }
.ei-num { width: 76px; height: 36px; box-sizing: border-box; padding: 0 8px; background: #151C2C; border: 1px solid #39435A;
          border-radius: 6px; color: var(--ms-primary); font: inherit; font-size: 13px; text-align: right; }
.ei-num:focus, .ei-txt:focus, .ei-textarea:focus { outline: 2px solid var(--ms-primary); outline-offset: -1px; }
.ei-txt { width: 100%; min-width: 220px; min-height: 36px; box-sizing: border-box; padding: 0 8px; background: #151C2C;
          border: 1px solid #39435A; border-radius: 6px; color: var(--ms-text); font: inherit; font-size: 13px; }
.ei-txt::placeholder, .ei-textarea::placeholder { color: #7A8295; }
.ei-inline { display: flex; align-items: center; gap: 8px; }
.ei-link { all: unset; cursor: pointer; font-size: 12px; color: var(--ms-text-muted); text-decoration: underline; min-height: 36px; line-height: 36px; }
.ei-link:hover { color: var(--ms-primary); }
.ei-link:focus-visible { outline: 2px solid var(--ms-primary); }
.ei-hint { font-size: 12px; color: #A6AEBC; padding: 4px 0; }
.ei-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ei-table-wrap { overflow-x: auto; }
.ei-table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.ei-table th { padding: 6px 10px; color: var(--ms-text-muted); font-weight: 500; font-size: 12px; border-bottom: 1px solid #39435A; white-space: nowrap; }
.ei-table td { padding: 6px 10px; border-bottom: 1px solid #222B3F; white-space: nowrap; color: var(--ms-text); }
.ei-table tbody th { border-bottom: 1px solid #222B3F; }
.ei-table td.ei-muted { color: var(--ms-text-muted); }
.ei-table .ei-row-head { text-align: left; color: var(--ms-text); font-weight: 400; font-size: 13px; }
.ei-table .ei-head-cell { color: #EAEFFF; }
.ei-table .ei-why { min-width: 260px; }
.ei-r { text-align: right; }
.ei-l { text-align: left; }
.ei-excl-hint { margin: 10px 0 0; font-size: 12px; }
/* Value cells of the driver history: a tick per value, unticked = left out of the averages (shown muted) */
.ei-inc label { display: inline-flex; align-items: center; justify-content: flex-end; gap: 5px; margin: 0 !important; cursor: pointer; color: inherit; font-size: inherit; }
.ei-inc input { width: 12px; height: 12px; margin: 0 6px 0 0 !important; flex: none; accent-color: #A6AEBC; cursor: pointer; opacity: .35; transition: opacity .12s; }
.ei-table tr:hover .ei-inc input, .ei-inc input:focus-visible, .ei-inc input:not(:checked) { opacity: 1; }
.ei-table td.ei-excluded { color: var(--ms-text-muted); }
.ei-table .ei-cons-col { border-left: 1px solid #39435A; }  /* Consensus apart from the historical averages */
.ei-table .ei-small { font-size: 11px; }
#ei-hist .ei-table th, #ei-hist .ei-table td { padding-left: 7px; padding-right: 7px; }  /* 12 columns: keep them on screen */
#ei-hist .ei-table .ei-row-head { white-space: normal; min-width: 150px; }
.ei-table td.ei-excluded label { text-decoration: line-through; text-decoration-color: rgba(132, 140, 158, .6); }
.ei-notes { margin: 10px 0 0; padding-left: 18px; font-size: 12px; color: #A6AEBC; line-height: 1.6; }
.ei-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.ei-cards .ei-card { padding: 12px 14px; border: 1px solid #313849; }
.ei-cards .ei-card-used { border-color: #6B5A3A; }
.ei-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.ei-card-head h3 { margin: 0; font-size: 14px; font-weight: 600; color: #EAEFFF; }
.ei-card-used .ei-card-head h3 { color: var(--ms-primary); }
.ei-tag { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ms-text-muted); }
.ei-total { display: flex; justify-content: space-between; gap: 12px; padding-top: 8px; font-weight: 600; color: #EAEFFF; }
.ei-total span:last-child { font-size: 18px; }
.ei-solve { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; background: #151C2C; border-radius: 8px; padding: 3px 3px 3px 10px; }
.ei-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; margin-bottom: 4px; }
.ei-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ei-key { display: inline-block; width: 18px; height: 0; }
.ei-bridge { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.ei-ev { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; align-items: center; }
.ei-ev-card { min-width: 180px; padding: 10px 14px; }
.ei-ev .ei-warn { margin: 0; font-size: 13px; }
.ei-fieldset { border: 0; margin: 0 0 10px; padding: 0; }
.ei-fieldset legend { float: none; width: auto; margin-bottom: 6px; padding: 0; }
.ei-radios { display: flex; flex-wrap: wrap; gap: 8px; }
.ei-radios label { display: inline-flex !important; align-items: center; gap: 8px; min-height: 44px; margin: 0 !important; padding: 0 14px;
                   border-radius: 8px; border: 1px solid #39435A; cursor: pointer; font-size: 14px; color: var(--ms-text); }
.ei-radios label:has(input:checked) { background: #313849; color: #EAEFFF; border-color: var(--ms-primary); }
.ei-radios input { accent-color: var(--ms-primary); }
.ei-block { display: block; margin-bottom: 4px; }
.ei-textarea { width: 100%; min-height: 96px; box-sizing: border-box; padding: 8px 10px; background: #151C2C; border: 1px solid #39435A;
               border-radius: 6px; color: var(--ms-text); font: inherit; font-size: 13px; resize: vertical; }
.ei-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.ei-btn { min-height: 44px; padding: 0 18px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
          background: transparent; border: 1px solid #39435A; color: var(--ms-text); }
.ei-btn:hover { border-color: var(--ms-primary); }
.ei-btn:focus-visible { outline: 2px solid #EAEFFF; outline-offset: 2px; }
.ei-btn-primary { background: var(--ms-primary); border-color: var(--ms-primary); color: #0F1524; }
.ei-btn-primary:hover { filter: brightness(1.08); }
.ei-action-msg { font-size: 13px; }
.ei-ok { color: #6EFACC; }
.ei-err { color: #ECA758; }
@media (max-width: 640px) { .ms-expinv { padding: 12px 16px 24px; } .ei-side { max-width: none; } }

/* ---- Fundamentals snapshot (app_snap) ------------------------ */
/* Header, tiles, toolbars, fields and the pipeline stepper reuse .news-* / .hist-* / .trend-* above. */
.ms-snap {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1760px;
  margin: 0 auto;
}
.ms-snap .news-header { align-items: flex-start; }
/* All header eyebrows (Stock, Pipeline, Swipe) on one top line: fixed eyebrow height (16px + 4px margin),
   items without an eyebrow drop to the control row, the logo sits highest at top right */
.ms-snap .news-header .news-eyebrow { line-height: 16px; }
.ms-snap .news-header .snap-head-btn,
.ms-snap .news-header .snap-chat-btn { margin-top: 23px; }       /* 40px buttons centred on the 46px control row */
.ms-snap .news-header .news-weblinks { margin-top: 20px; }
.ms-snap .news-header .news-logo { align-self: flex-start; margin-top: 0; }
.ms-snap .news-title { flex-wrap: wrap; row-gap: 2px; }
.ms-snap .news-title h2 { font-size: 16px; white-space: nowrap; }
.ms-snap .news-title span { font-size: 12px; }
.ms-snap .news-toolbar { padding: 12px 16px; }
.ms-snap .trend-block { padding: 12px 16px 14px; }
.ms-snap .trend-input input:focus { box-shadow: none !important; background: transparent !important; }
.ms-snap .trend-input input[type="number"] { -moz-appearance: textfield; }
.ms-snap .trend-input input::-webkit-inner-spin-button,
.ms-snap .trend-input input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ms-snap .trend-icon-btn:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }

/* Header: stock + period, delete, pipeline, swipe score, weblinks, chat, logo */
.snap-stock { flex: 1 1 320px; max-width: 460px; display: flex; flex-direction: column; }
.snap-stock .news-stock { flex: none; max-width: none; }  /* column flex: the 320px basis would become a height */
.snap-period { min-height: 18px; margin-top: 4px; font-size: 12px; color: var(--ms-text-muted); }
.snap-period p { margin: 0; }
.snap-meta { display: flex; align-items: baseline; gap: 14px; }
.snap-currency:empty { display: none; }
.snap-currency .fas { margin-right: 2px; color: var(--ms-primary); }
.ms-snap .news-header .snap-head-btn { width: 40px; height: 40px; background-color: var(--ms-tile); border: 1px solid var(--ms-tile-highlight); }
.ms-snap .news-weblinks { flex: 1 1 260px; }
.snap-scorecard:empty { display: none; }
.snap-score { display: flex; flex-direction: column; text-decoration: none; }
a.snap-score:hover .snap-score-boxes { border-color: var(--ms-primary); }
.snap-score-boxes {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  min-height: 38px;
  padding: 4px 10px;
  border-radius: 8px;
  background-color: var(--ms-tile);
  border: 1px solid var(--ms-tile-highlight);
}
.snap-score-box { display: inline-flex; align-items: center; gap: 4px; }
.snap-score-box.total { padding-right: 10px; border-right: 1px solid var(--ms-tile-highlight); }
.snap-score-v {
  min-width: 30px;
  padding: 1px 5px;
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.snap-score-box.total .snap-score-v { font-size: 14px; }
.snap-score-l { font-size: 11px; color: var(--ms-text-muted); }
.snap-score-none { font-size: 12px; color: var(--ms-text-muted); }

.snap-btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--ms-tile-highlight);
  background-color: var(--ms-tile);
  color: var(--ms-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.snap-btn-secondary:hover { background-color: var(--ms-tile-highlight); color: var(--ms-primary); }
.snap-btn-secondary:focus-visible,
.ms-snap .trend-save-btn:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }
.snap-chat-btn { min-height: 40px; }

/* Tile grid */
.snap-row { display: grid; gap: 16px; margin-bottom: 16px; }
.snap-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.snap-row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.snap-tile { display: flex; flex-direction: column; min-width: 0; }
.snap-graph { padding: 4px 8px 8px; }
.snap-mcev { padding-bottom: 4px; }
.snap-copy {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--ms-text-muted);
  font-size: 13px;
  cursor: pointer;
}
.snap-copy:hover { background-color: var(--ms-tile-highlight); color: var(--ms-primary); }
.snap-copy:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }
.snap-grid-box { padding: 8px 10px 10px; }
.snap-valhist .ag-cell { padding-top: 5px; padding-bottom: 5px; line-height: 1.45; }
.snap-valhist .ag-cell p { margin: 0 0 4px; }
.snap-valhist .ag-cell p:last-child { margin-bottom: 0; }
.snap-scenarios #Debugging:empty { display: none; }

/* Fair multiples tile */
.snap-fields-1 { grid-template-columns: minmax(0, 1fr); }
.snap-field-label { display: inline-flex; align-items: center; gap: 6px; }
.snap-sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.snap-mults .trend-input { height: 34px; }
.snap-mult-range { margin-top: 6px; }

/* Lower part: KPI table left, sensitivity + save + diary right */
.snap-lower { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.snap-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.snap-body { padding: 8px 16px 16px; }
.snap-h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ms-text);
}
.snap-block-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 8px; }
.snap-sub { font-size: 12px; color: var(--ms-text-muted); }

.snap-kpi-row {
  display: grid;
  grid-template-columns: minmax(96px, 1.1fr) 88px 34px minmax(120px, 1.5fr) minmax(100px, 1.1fr);
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.snap-kpi-row .trend-input { height: 34px; }
.snap-kpi-row .trend-input input { font-size: 14px; }
.snap-kpi-head {
  padding: 6px 0;
  border-bottom: 1px solid var(--ms-tile-highlight);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ms-text-muted);
}
.snap-kpi-name { font-size: 13px; color: var(--ms-text); }
.snap-kpi-spark { height: 40px; overflow: hidden; }
.snap-kpi-result { border-bottom: 0; border-top: 1px solid var(--ms-tile-highlight); margin-top: 4px; padding-top: 8px; }
.snap-kpi-result .snap-kpi-name { font-weight: 600; }
.snap-kpi-result .trend-input input { color: var(--ms-primary) !important; }
.snap-kpi-row .trend-input:has(input[readonly]) { border-style: dashed; background: transparent; }
.snap-kpi-row .trend-input input[readonly] { color: var(--ms-text-muted) !important; cursor: default; }
.snap-projections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.snap-projection { min-width: 0; }

/* Toggle switches with labels left/right */
.snap-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ms-text-muted); }

/* Save valuation */
.snap-fields-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.snap-fields-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.snap-mt { margin-top: 12px; }
.ms-snap .hist-textarea { display: block; width: 100%; }
.snap-textarea { min-height: 160px; }
.snap-textarea-sm { min-height: 80px; }
.snap-submit { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.snap-msgs { flex: 1 1 240px; min-width: 0; }
.snap-msgs .alert { margin: 4px 0 !important; }
.snap-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.snap-link { display: inline-flex; align-items: center; gap: 6px; }

/* Chat panel */
.snap-chat-history {
  height: 75vh;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--ms-tile-highlight);
  border-radius: 8px;
  background-color: var(--ms-bg);
}
.snap-chat-input { display: flex; gap: 8px; margin-top: 10px; }
.snap-chat-input input { flex: 1 1 auto; min-width: 0; height: 38px; }
.snap-chat-input .trend-save-btn { height: 38px; }

@media (max-width: 1400px) {
  .snap-row-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .snap-row-3 { grid-template-columns: minmax(0, 1fr); }
  .snap-lower { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .ms-snap { padding: 12px 16px 24px; }
  .snap-row-4 { grid-template-columns: minmax(0, 1fr); }
  .snap-fields-3, .snap-fields-4, .snap-projections { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .snap-kpi-row { grid-template-columns: minmax(80px, 1fr) 34px minmax(100px, 1.4fr) minmax(90px, 1fr); }
  .snap-kpi-spark { display: none; }
}

/* ---- Performance app (app_performance) ----------------------- */
/* Header, tiles, toolbars, KPI tiles and segmented controls reuse .news-* / .hist-* above. */
.ms-perf {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1600px;
  margin: 0 auto;
}
.ms-perf .news-header { align-items: flex-end; }
.ms-perf .news-seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.ms-perf .news-seg label:has(input:checked) { background-color: var(--ms-primary); color: var(--ms-bg); }
.ms-perf .pos { color: var(--ms-success-light); }
.ms-perf .neg { color: var(--ms-danger-light); }
.perf-heading h1 { margin: 0; white-space: nowrap; }
.perf-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.perf-controls .news-seg { background-color: var(--ms-tile); border: 1px solid var(--ms-tile-highlight); }
.perf-period label { padding: 0 12px; }

/* Main grid: history left, bridge right */
.perf-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 16px;
  align-items: start;
}
/* Fixed-size box for the history chart; padding stays off .js-plotly-plot (Plotly measures it) */
.perf-graph { height: 640px; padding: 4px 8px 0; box-sizing: border-box; }
.perf-bridge-graph { padding: 4px 8px 0; }
.perf-history .hist-legend { padding-top: 10px; }
.perf-sw-dot { height: 0; border-top: 2px dotted; border-radius: 0; background: none; }
.perf-bridge .news-title span { font-variant-numeric: tabular-nums; }
.perf-bridge .hist-range-note { padding-top: 8px; }

@media (max-width: 1100px) {
  .perf-grid { grid-template-columns: minmax(0, 1fr); }
  .perf-graph { height: 520px; }
}
@media (max-width: 640px) {
  .ms-perf { padding: 12px 16px 24px; }
  .perf-period label { padding: 0 8px; }
}

/* ---- Profit & Loss comparison (app_pnl) ---------------------- */
/* Header, tiles, toolbars, KPI tiles and segmented controls reuse .news-* / .hist-* / .trend-* above. */
.ms-pnl {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1600px;
  margin: 0 auto;
}
.ms-pnl .news-header { align-items: flex-end; }
.ms-pnl .news-header > .trend-icon-btn {
  width: 46px;
  height: 46px;
  background-color: var(--ms-tile);
  border: 1px solid var(--ms-tile-highlight);
}
.ms-pnl .trend-icon-btn:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }
.ms-pnl .news-seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.ms-pnl .news-seg label:has(input:checked) { background-color: var(--ms-primary); color: var(--ms-bg); }
.ms-pnl .news-title h2 { white-space: nowrap; }
.ms-pnl .pos { color: var(--ms-success-light); }
.ms-pnl .neg { color: var(--ms-danger-light); }

/* Period controls */
.pnl-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.pnl-controls .news-seg { background-color: var(--ms-tile); border: 1px solid var(--ms-tile-highlight); }
.pnl-period { width: 130px; }
.pnl-period-dd .Select-control {
  background-color: var(--ms-tile) !important;
  border: 1px solid var(--ms-tile-highlight) !important;
  border-radius: 8px !important;
  height: 40px;
}
.pnl-period-dd .Select-value-label { color: var(--ms-primary) !important; font-weight: 600; }
.pnl-period-dd .Select--single > .Select-control .Select-value,
.pnl-period-dd .Select-placeholder { line-height: 38px; }
.pnl-vs { color: var(--ms-text-muted); font-size: 12px; padding-bottom: 14px; }

/* Download notice */
.pnl-notice:empty { display: none; }
.pnl-notice-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(236, 167, 88, 0.55);
  background-color: rgba(187, 134, 75, 0.18);
  color: var(--ms-warning-light);
  font-size: 14px;
}

/* KPI strip */
.pnl-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.pnl-kpis .hist-kpi-s span { font-weight: 600; }

/* Main grid: bridge left, time series right */
.pnl-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: start;
}
.pnl-bridge .news-title span { font-variant-numeric: tabular-nums; }
/* Fixed-size box for the bridge; padding stays off .js-plotly-plot (Plotly measures it) */
.pnl-graph { height: 640px; padding: 8px 16px 8px 12px; box-sizing: border-box; }
.pnl-bridge .hist-range-note:empty { display: none; }

.pnl-legend { padding: 0; }
.pnl-sw-up    { height: 8px; background-color: var(--ms-success-light); }
.pnl-sw-down  { height: 8px; background-color: var(--ms-danger-light); }
.pnl-sw-total { height: 8px; background-color: #8f9099; }
.pnl-series-legend { padding: 12px 20px 0; }
.pnl-sw-cy  { background-color: var(--ms-primary); }
.pnl-sw-py  { background-color: #8f9099; }
.pnl-sw-ttm { height: 0; border-top: 2px dotted var(--ms-text); border-radius: 0; background: none; }

.pnl-spark { padding: 12px 20px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
.pnl-spark:last-child { border-bottom: 0; padding-bottom: 12px; }
.pnl-spark .snap-h3 { margin-bottom: 4px; }
.pnl-spark-graph { height: 110px; }

@media (max-width: 1200px) {
  .pnl-grid { grid-template-columns: minmax(0, 1fr); }
  .pnl-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .ms-pnl { padding: 12px 16px 24px; }
  .pnl-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pnl-scroll { overflow-x: auto; }
  .pnl-graph { min-width: 760px; }
}

/* ---- Sector scorecard (app_screen_sectors) ------------------- */
/* Header, tiles, toolbars, KPI tiles and segmented controls reuse .news-* / .hist-* above. */
.ms-sectors {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1800px;
  margin: 0 auto;
}
.ms-sectors .news-header { align-items: center; }
.sectors-heading h1 { margin: 0; font-size: 26px; font-weight: 650; color: var(--ms-text); }
.ms-sectors .news-seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.ms-sectors .news-seg label { min-height: 32px; padding: 0 12px; }
.ms-sectors .news-seg label:has(input:checked) { background-color: var(--ms-primary); color: var(--ms-bg); }
.ms-sectors .news-seg label span { display: inline-flex; align-items: center; gap: 6px; }
.ms-sectors .news-title h2 { white-space: nowrap; }

/* Filter tile */
.sectors-filters { margin-bottom: 16px; }
.sectors-ctrl { display: flex; flex-direction: column; gap: 4px; }
.sectors-ctrl .news-eyebrow { margin-bottom: 0; }
.sectors-toggle {
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--ms-tile-highlight);
  border-radius: 8px;
  background-color: var(--ms-bg);
  color: var(--ms-text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.sectors-toggle:hover { background-color: var(--ms-tile-highlight); color: var(--ms-primary); }
.sectors-toggle:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }
.sectors-pick { padding: 14px 20px 16px; }
.sectors-sliders {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px 24px;
  padding: 14px 20px 22px;
  border-top: 1px solid var(--ms-tile-highlight);
}
.sectors-slider { min-width: 0; }
.sectors-slider .news-eyebrow i { margin-right: 6px; }
.sectors-dist { height: 34px; margin: 4px 19px 0 31px; overflow: hidden; }   /* aligned to the slider rail like .mon-dist */
.sectors-slider .rc-slider { margin: 0 6px; }
.sectors-slider .rc-slider-tooltip-inner {
  background-color: var(--ms-bg);
  color: var(--ms-text);
  border: 1px solid var(--ms-tile-highlight);
  box-shadow: none;
  font-size: 11px;
  min-width: 0;
  padding: 2px 6px;
  height: auto;
}
.sectors-slider .rc-slider-tooltip-arrow { display: none; }

/* KPI strip */
.sectors-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.sectors-kpis .hist-kpi-s { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Kanban board: one column per industry group */
.sectors-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
  align-items: start;
}
.sectors-col-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ms-tile-highlight);
}
.sectors-col-head h3 {
  margin: 0 auto 0 0;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ms-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sectors-count {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background-color: var(--ms-primary-subtle);
  color: var(--ms-primary);
}
.sectors-col-body { display: flex; flex-direction: column; gap: 8px; padding: 10px; }

/* Stock card */
.sectors-stock {
  padding: 8px 12px 10px;
  border-radius: 8px;
  border-left: 10px solid var(--ms-tile-highlight);
  background-color: var(--ms-bg);
}
.sectors-stock:hover { background-color: rgba(var(--ms-bg-rgb), 0.6); box-shadow: inset 0 0 0 1px var(--ms-tile-highlight); }
.sectors-stock-top { display: flex; align-items: center; justify-content: space-between; }
.sectors-stock-top .news-eyebrow { margin: 0; font-variant-numeric: tabular-nums; }
.sectors-stock-actions { display: flex; gap: 2px; }
.sectors-stock-actions a {
  width: 26px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--ms-text-muted);
  font-size: 12px;
}
.sectors-stock-actions a:hover { background-color: var(--ms-tile-highlight); color: var(--ms-primary); }
.sectors-stock-head { display: flex; align-items: center; gap: 8px; margin: 2px 0 8px; }
.sectors-stock-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  color: #E6E7EE;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sectors-stock-name:hover { color: var(--ms-primary); }
.sectors-score {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sectors-score i { font-size: 10px; opacity: 0.7; }
.sectors-metrics { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px 10px; }
.sectors-metric {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  color: var(--ms-text);
  cursor: default;
}
.sectors-metric i { width: 12px; text-align: center; font-size: 11px; color: var(--ms-text-muted); }
.sectors-metric .hist-dot { flex: 0 0 auto; }
.sectors-metric-v { font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sectors-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 240px;
  color: var(--ms-text-muted);
  background-color: var(--ms-tile);
  border: 1px dashed var(--ms-tile-highlight);
  border-radius: 12px;
}
.sectors-empty i { font-size: 26px; color: var(--ms-tile-highlight); }
.sectors-empty p { margin: 0; }

@media (max-width: 1200px) {
  .sectors-sliders { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sectors-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .ms-sectors { padding: 12px 16px 24px; }
  .sectors-sliders, .sectors-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Options ROI simulation (app_options) -------------------- */
/* Header, tiles, toolbars, KPI tiles, inputs and segmented controls reuse .news-* / .hist-* / .trend-* above. */
.ms-options {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1600px;
  margin: 0 auto;
}
.ms-options .news-header { align-items: flex-end; }
.ms-options .news-seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.ms-options .news-toolbar a { text-decoration: none; }
.ms-options .news-toolbar .news-seg { background-color: var(--ms-bg); }
.opt-heading h1 { margin: 0; white-space: nowrap; }

/* KPI strip: four tiles + implied-vol sparkline */
.opt-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.3fr); }
.opt-kpis .hist-kpi-s { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opt-iv { padding-bottom: 8px; }
.opt-iv-legend { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 11px; color: var(--ms-text-muted); }
.opt-iv-legend > span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.opt-iv-legend b { color: var(--ms-text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Portfolio + assumptions */
.opt-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}
.opt-grid-wrap { padding: 0; }
.opt-grid-wrap .ag-theme-balham :is(.ag-root-wrapper, .ag-body-viewport, .ag-center-cols-viewport) {
  background-color: transparent !important;
  border: none !important;
}
.opt-grid-wrap .ag-theme-balham .ag-header {
  background-color: rgba(var(--ms-bg-rgb), 0.35) !important;
  border-bottom: 1px solid var(--ms-tile-highlight) !important;
}
.opt-grid-wrap .ag-theme-balham .ag-header-cell-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ms-text-muted);
}
.opt-grid-wrap .ag-theme-balham .ag-row {
  background-color: var(--ms-tile) !important;
  border-color: rgba(var(--ms-border-rgb), 0.45) !important;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.opt-grid-wrap .ag-theme-balham .ag-row:hover { background-color: var(--ms-tile-highlight) !important; }
.opt-grid-wrap .ag-theme-balham .ag-cell { display: flex; align-items: center; }
.opt-grid-wrap .ag-theme-balham .ag-cell.ag-right-aligned-cell { justify-content: flex-end; }
.opt-grid-wrap .opt-cell-muted { color: var(--ms-text-muted); }
.opt-grid-wrap .opt-cell-value { color: var(--ms-primary); font-weight: 600; }
.opt-settings .trend-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ROI map: heatmap + price cross-section right, time cross-section below */
.opt-map-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  grid-template-areas: "main side" "bottom .";
  gap: 8px 12px;
  padding: 8px 12px 0;
}
.opt-map-main { grid-area: main; }
.opt-side { grid-area: side; display: flex; flex-direction: column; height: 620px; }
.opt-bottom { grid-area: bottom; display: flex; flex-direction: column; height: 220px; }
.opt-side .js-plotly-plot, .opt-bottom .js-plotly-plot { flex: 1 1 auto; min-height: 0; }
.opt-side .news-eyebrow, .opt-bottom .news-eyebrow { padding-left: 8px; margin: 4px 0 0; }
/* Fixed-size box; padding stays off .js-plotly-plot (Plotly measures it) */
.opt-map-graph { height: 620px; box-sizing: border-box; }
.opt-map .hist-legend { padding-top: 12px; }
.opt-sw-dot { height: 0; border-top: 2px dotted; border-radius: 0; background: none; }
.opt-sw-grad {
  width: 42px;
  height: 8px;
  background: linear-gradient(90deg, rgba(204, 102, 96, 0.75), rgba(236, 167, 88, 0.6), rgba(118, 195, 171, 0.75));
}

@media (max-width: 1200px) {
  .opt-top { grid-template-columns: minmax(0, 1fr); }
  .opt-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .opt-map-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "bottom" "side"; }
  .opt-side { height: 260px; }
  .opt-map-graph { height: 480px; }
}
@media (max-width: 640px) {
  .ms-options { padding: 12px 16px 24px; }
  .opt-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .opt-settings .trend-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Portfolio monitor (app_monitor) ------------------------- */
/* Header, tiles, toolbars, KPI tiles and segmented controls reuse .news-* / .hist-* above. */
.ms-monitor {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1800px;
  margin: 0 auto;
}
.ms-monitor .news-header { align-items: center; }
.mon-heading { flex: 1 1 0; min-width: 0; }
.mon-heading h1 { margin: 0; font-size: 26px; font-weight: 650; color: var(--ms-text); white-space: nowrap; }
.ms-monitor .news-tile { margin-bottom: 16px; }
.ms-monitor .news-title h2 { white-space: nowrap; }
.ms-monitor .news-seg input[type="radio"],
.ms-monitor .news-seg input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }
.ms-monitor .news-seg { flex-wrap: wrap; }
.ms-monitor .news-seg label { min-height: 32px; padding: 0 12px; }
.ms-monitor .news-seg label:has(input:checked) { background-color: var(--ms-primary); color: var(--ms-bg); }
.ms-monitor .news-seg label span { display: inline-flex; align-items: center; gap: 6px; }
.ms-monitor .pos { color: var(--ms-success-light); }
.ms-monitor .neg { color: var(--ms-danger-light); }
.mon-ctrl { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mon-ctrl .news-eyebrow { margin-bottom: 0; }
.mon-quality { flex: 0 1 260px; }
.mon-quality .rc-slider { margin: 10px 6px 14px; }
.mon-quality .rc-slider-mark-text { color: var(--ms-text-muted) !important; font-size: 11px; }
.mon-dist { margin: 4px 19px -8px 31px; }   /* lines up with the rail: wrapper padding 25px + rail margin-left 6px; the rail is 100% wide, so it ends 19px from the right */
.mon-dist-n { margin-left: 8px; color: var(--ms-text-muted); text-transform: none; letter-spacing: 0; font-weight: 400; }

/* Sharing link */
.mon-share {
  flex: 0 1 340px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  margin-left: auto;
  padding: 0 6px 0 12px;
  border: 1px solid var(--ms-tile-highlight);
  border-radius: 8px;
  background-color: var(--ms-tile);
  color: var(--ms-text-muted);
  font-size: 13px;
}
.mon-share:focus-within { border-color: var(--ms-primary); }
.mon-share input {
  flex: 1 1 auto;
  min-width: 0;
  height: 36px;
  border: 0 !important;
  background: transparent !important;
  color: var(--ms-text) !important;
  font-size: 12px;
  outline: none;
  box-shadow: none !important;
  text-overflow: ellipsis;
}
.mon-copy {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
}
.mon-copy:hover { background-color: var(--ms-tile-highlight); color: var(--ms-primary); }
.ms-monitor .news-logo { margin-left: 8px; }

/* Selection tile */
.mon-lists { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 20px 4px; }
.mon-list-btn {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--ms-tile-highlight);
  border-radius: 8px;
  background-color: var(--ms-bg);
  color: var(--ms-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.mon-list-btn i { font-size: 12px; color: var(--ms-text-muted); }
.mon-list-btn:hover { background-color: var(--ms-tile-highlight); color: var(--ms-primary); }
.mon-list-btn:hover i { color: var(--ms-primary); }
.mon-list-btn:focus-visible,
.mon-copy:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }
.mon-rank {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto 200px minmax(0, 1.2fr);
  gap: 12px 16px;
  align-items: end;
  padding: 14px 20px 4px;
}
.mon-rank .news-seg { flex-wrap: nowrap; }
.mon-pager { display: flex; align-items: center; gap: 6px; }
.mon-pager > div { flex: 1 1 auto; min-width: 0; }
.mon-busy-chip {
  display: none; align-self: center; margin-right: auto;
  align-items: center; gap: 8px;
  padding: 4px 12px; border-radius: 999px;
  background-color: rgba(224, 183, 115, 0.14); color: var(--ms-primary);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.mon-charts:has(#chartMonitor[data-dash-is-loading="true"]) .mon-busy-chip { display: inline-flex; }
.mon-page-btn {
  margin: 0;
  flex: 0 0 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--ms-tile-highlight);
  border-radius: 8px;
  background-color: var(--ms-bg);
  color: var(--ms-text-muted);
  font-size: 12px;
  cursor: pointer;
}
.mon-page-btn:hover { background-color: var(--ms-tile-highlight); color: var(--ms-primary); }
.mon-page-btn:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }
.mon-stocks { padding: 14px 20px 18px; }

/* KPI strip */
.mon-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.mon-kpis .hist-kpi-s { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Chart tile */
.mon-show { display: flex; flex-wrap: wrap; gap: 6px; }
.mon-bm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 20px 0;
}
.mon-bm .news-eyebrow { margin: 0; }
.mon-notes:empty { display: none; }
.mon-notes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 4px 20px;
  padding: 12px 20px 0;
}
.mon-note { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 12px; color: var(--ms-text-muted); }
.mon-note-name { flex: 0 0 auto; max-width: 45%; color: var(--ms-text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mon-note-miss { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mon-note-q { margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }

.mon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  padding: 14px 20px 6px;
}
.mon-card {
  min-width: 0;
  padding: 8px 10px 4px 12px;
  border-radius: 8px;
  background-color: var(--ms-bg);
  border: 1px solid transparent;
}
.mon-card:hover { border-color: var(--ms-tile-highlight); }
.mon-card-bm { border-left: 3px solid var(--ms-primary); }
.mon-card-top { display: flex; align-items: center; gap: 8px; }
.mon-card-top .news-eyebrow { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mon-card-bm .mon-card-top .news-eyebrow { color: var(--ms-primary); }
.mon-chg { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mon-card-actions { display: flex; gap: 0; margin-left: auto; }
.mon-card-actions a {
  width: 24px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--ms-text-muted);
  font-size: 11px;
  text-decoration: none;
}
.mon-card-actions a:hover { background-color: var(--ms-tile-highlight); color: var(--ms-primary); }
.mon-card-actions a.mon-watch { opacity: 0.45; }
.mon-card-actions a.mon-watch.on { opacity: 1; color: var(--ms-primary); }
.mon-card-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 2px 0 2px;
  font-size: 15px;
  font-weight: 600;
  color: #E6E7EE;
  text-decoration: none;
}
.mon-card-name-t { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mon-card-name .hist-dot { flex: 0 0 auto; }
.mon-card-name:hover { color: var(--ms-primary); }
.mon-card-graph { width: 100%; }

.mon-legend { padding: 8px 20px 14px; }
.mon-sw-price { background-color: var(--ms-text); }
.mon-sw-up { background-color: var(--ms-success-light); }
.mon-sw-down { background-color: var(--ms-danger-light); }
.mon-sw-buy { height: 10px; background-color: rgba(118, 195, 171, 0.3); }
.mon-sw-fv { height: 10px; background-color: rgba(204, 102, 96, 0.3); }
.mon-sw-chip {
  padding: 0 4px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  color: var(--ms-success-light);
  background-color: rgba(118, 195, 171, 0.16);
}

.mon-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 220px;
  color: var(--ms-text-muted);
  border: 1px dashed var(--ms-tile-highlight);
  border-radius: 12px;
}
.mon-empty i { font-size: 26px; color: var(--ms-tile-highlight); }
.mon-empty p { margin: 0; }

/* List view grid */
.mon-table { padding: 0; }
.mon-table .ag-theme-balham :is(.ag-root-wrapper, .ag-body-viewport, .ag-center-cols-viewport, .ag-pinned-left-cols-container) {
  background-color: transparent !important;
  border: none !important;
}
.mon-table .ag-theme-balham .ag-header {
  background-color: rgba(var(--ms-bg-rgb), 0.35) !important;
  border-bottom: 1px solid var(--ms-tile-highlight) !important;
}
.mon-table .ag-theme-balham .ag-header-cell-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ms-text-muted);
}
.mon-table .ag-theme-balham .ag-row {
  border-color: rgba(var(--ms-border-rgb), 0.45) !important;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.mon-table .ag-theme-balham .ag-row:hover { background-color: var(--ms-tile-highlight) !important; }
.mon-table .ag-theme-balham .ag-cell { display: flex; align-items: center; }
.mon-table .ag-theme-balham .ag-cell.ag-right-aligned-cell { justify-content: flex-end; }
.mon-table .ag-theme-balham .ag-cell p { margin: 0; }
.mon-table .ag-theme-balham .ag-pinned-left-cols-container .ag-cell { color: #E6E7EE; font-weight: 600; }

@media (max-width: 1200px) {
  .mon-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mon-rank { grid-template-columns: minmax(0, 1fr) auto 200px; }
  .mon-rank-set { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .ms-monitor { padding: 12px 16px 24px; }
  .mon-heading h1 { font-size: 22px; }
  .mon-share { flex-basis: 100%; order: 3; margin-left: 0; }
  .ms-monitor .news-logo img { height: 36px; }
  .mon-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mon-rank { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .mon-rank-var { grid-column: 1 / -1; }
  .mon-grid { grid-template-columns: minmax(0, 1fr); padding: 12px; }
}

/* ---- Portfolio overview (app_ptf) ---------------------------- */
/* Header, tiles, toolbars, KPI tiles and segmented controls reuse .news-* / .hist-* / .trend-* above. */
.ms-ptf {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1600px;
  margin: 0 auto;
}
.ms-ptf .news-header { align-items: center; }
.ms-ptf .news-tile { margin-bottom: 16px; }
.ms-ptf .news-title h2 { white-space: nowrap; }
.ms-ptf .pos { color: var(--ms-success-light); }
.ms-ptf .neg { color: var(--ms-danger-light); }
.ms-ptf .mut { color: var(--ms-text-muted); }
.ms-ptf .r { text-align: right; }
.ptf-heading h1 { margin: 0; font-size: 26px; font-weight: 650; color: var(--ms-text); white-space: nowrap; }
.ptf-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ptf-stamp { font-size: 12px; color: var(--ms-text-muted); font-variant-numeric: tabular-nums; }
.ptf-actions .trend-icon-btn { width: 40px; height: 40px; background-color: var(--ms-tile); border: 1px solid var(--ms-tile-highlight); }
.ptf-empty { padding: 40px 20px; text-align: center; color: var(--ms-text-muted); }

.hist-kpis.ptf-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Toolbars: strategy filter, range buttons, new category */
.ptf-seg { flex-wrap: wrap; }
.ptf-seg .news-seg-btn { min-height: 32px; padding: 0 12px; }
.ptf-newcat { display: flex; align-items: center; gap: 8px; }
.ptf-newcat .trend-save-btn i { font-size: 11px; }
.ms-ptf .ptf-newcat-input {
  width: 170px;
  height: 34px;
  padding: 0 12px;
  background-color: var(--ms-bg) !important;
  border: 1px solid var(--ms-tile-highlight) !important;
  border-radius: 8px;
  color: var(--ms-text) !important;
  font-size: 13px;
  box-shadow: none !important;
}
.ms-ptf .ptf-newcat-input:focus { border-color: var(--ms-primary) !important; }

/* Positions table (desktop) */
.ptf-scroll { overflow-x: auto; }
.ptf-table { min-width: 1080px; font-variant-numeric: tabular-nums; }
.ptf-grid {
  display: grid;
  grid-template-columns: 30px minmax(240px, 3fr) 62px 80px 82px 96px 112px 126px 86px 104px;
  align-items: center;
  padding: 8px 20px;
  border-bottom: 1px solid rgba(var(--ms-border-rgb), 0.45);
  font-size: 13.5px;
  color: var(--ms-text);
}
.ptf-head {
  padding: 10px 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ms-text-muted);
  border-bottom: 1px solid var(--ms-tile-highlight);
}
.ptf-cat {
  padding: 9px 20px 7px;
  background-color: rgba(var(--ms-primary-rgb), 0.06);
  border-top: 1px solid var(--ms-tile-highlight);
  border-bottom: 1px solid var(--ms-tile-highlight);
}
.ptf-head + .ptf-cat { border-top: 0; }
.ptf-row:hover { background-color: var(--ms-tile-highlight); }
.ptf-cash { color: var(--ms-text-muted); }
.ptf-total { padding: 11px 20px; border-bottom: 0; background-color: var(--ms-bg); font-weight: 600; }
.ptf-strong { font-weight: 600; font-size: 14.5px; }
.ptf-total .ptf-strong { font-size: 16px; }
.ptf-name { min-width: 0; padding-right: 12px; }
.ptf-name-main { font-weight: 500; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ptf-check { margin-left: 8px; color: inherit; opacity: .55; text-decoration: none; }
.ptf-check:hover { opacity: 1; color: var(--ms-primary); }
.ptf-check-checked { color: var(--ms-success-light); opacity: .9; }
.ptf-check-missing { color: var(--ms-warning-light); opacity: 1; }
.ptf-check-outdated { color: var(--ms-info-light); opacity: 1; }
.ptf-sub { font-size: 11.5px; color: var(--ms-text-muted); }
.ptf-small { font-size: 11.5px; }
.ptf-cat-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ms-ptf .ptf-cat-name {
  flex: 0 1 260px;
  min-width: 80px;
  height: auto;
  padding: 1px 0;
  background: transparent !important;
  border: 0 !important;
  border-bottom: 1px solid transparent !important;
  border-radius: 0;
  color: var(--ms-text) !important;
  font-weight: 600;
  font-size: 14.5px;
  box-shadow: none !important;
}
.ms-ptf .ptf-cat-name:hover { border-bottom-color: var(--ms-tile-highlight) !important; }
.ms-ptf .ptf-cat-name:focus { border-bottom-color: var(--ms-primary) !important; }
.ptf-cat-count { font-size: 11.5px; color: var(--ms-text-muted); white-space: nowrap; }
.ptf-weight { text-align: right; font-size: 12.5px; color: var(--ms-text-muted); }
.ptf-weight-bar { height: 3px; margin-top: 3px; border-radius: 2px; background-color: var(--ms-tile-highlight); overflow: hidden; }
.ptf-weight-bar span { display: block; height: 100%; background-color: var(--ms-primary); }
.ptf-spark { display: flex; justify-content: flex-end; }
.ptf-spark-img { width: 88px; height: 26px; display: block; }

/* Small icon buttons: collapse, move up/down, remove */
.ptf-toggle,
.ptf-remove,
.ptf-move button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ms-text-muted);
  cursor: pointer;
}
.ptf-toggle { width: 22px; height: 22px; font-size: 11px; color: var(--ms-primary); }
.ptf-remove { width: 22px; height: 22px; font-size: 12px; }
.ptf-move { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.ptf-cat-head .ptf-move { flex-direction: row; gap: 2px; }
.ptf-move button { width: 20px; height: 16px; font-size: 9px; }
.ptf-toggle:hover { background-color: var(--ms-tile-highlight); color: var(--ms-primary); }
/* Move/remove buttons are rarely used: dark, low-contrast icons that never
   take the accent colour. Direct hover only lifts them to muted text on a
   slightly raised surface; remove turns a dim red so it still reads as destructive. */
.ptf-move button,
.ptf-remove { color: rgba(var(--ms-border-rgb), 0.9); }
.ptf-move button:hover { background-color: var(--ms-surface-2); color: var(--ms-text-muted); }
.ptf-remove:hover { background-color: var(--ms-surface-2); color: rgba(204, 102, 96, 0.7); }
.ptf-toggle:focus-visible,
.ptf-remove:focus-visible,
.ptf-move button:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 1px; }
/* Move/remove buttons stay quiet until the row is hovered or focused */
@media (hover: hover) {
  .ptf-row .ptf-move,
  .ptf-cat .ptf-move,
  .ptf-cat .ptf-remove { opacity: 0.25; transition: opacity 0.12s; }
  .ptf-row:hover .ptf-move,
  .ptf-cat:hover .ptf-move,
  .ptf-cat:hover .ptf-remove { opacity: 0.6; }
  .ptf-move button:hover,
  .ptf-remove:hover,
  .ptf-move:focus-within,
  .ptf-remove:focus-visible { opacity: 1; }
}

/* Positions list (mobile) */
.ptf-mobile { display: none; font-variant-numeric: tabular-nums; }
.ptf-mcat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background-color: rgba(var(--ms-primary-rgb), 0.06);
  border-bottom: 1px solid var(--ms-tile-highlight);
}
.ms-ptf .ptf-mcat .ptf-cat-name { flex: 1 1 auto; }
.ptf-mrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 24px;
  gap: 10px;
  align-items: center;
  padding: 9px 16px;
  border-bottom: 1px solid rgba(var(--ms-border-rgb), 0.45);
  font-size: 14px;
  color: var(--ms-text);
}
.ptf-mcash,
.ptf-mtotal { display: flex; justify-content: space-between; align-items: center; padding: 9px 16px; }
.ptf-mcash { color: var(--ms-text-muted); border-bottom: 1px solid rgba(var(--ms-border-rgb), 0.45); }
.ptf-mtotal { background-color: var(--ms-bg); font-weight: 600; color: var(--ms-text); }

/* Performance chart */
.ptf-perf-change { font-weight: 600; }
.ptf-chart { padding: 8px 12px 0; }
.ptf-chart-dates {
  display: flex;
  justify-content: space-between;
  padding: 6px 20px 14px;
  font-size: 11.5px;
  color: var(--ms-text-muted);
}

@media (max-width: 1100px) {
  .hist-kpis.ptf-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 780px) {
  .ptf-scroll { display: none; }
  .ptf-mobile { display: block; }
}
@media (max-width: 640px) {
  .ms-ptf { padding: 12px 16px 24px; }
  .ptf-heading h1 { font-size: 22px; }
  .ms-ptf .news-logo img { height: 36px; }
  .ptf-newcat { flex-basis: 100%; }
  .ms-ptf .ptf-newcat-input { flex: 1 1 auto; width: auto; }
}

/* ---- iQFoil performance evaluation (app_iqperf) -------------- */
/* Header, tiles, toolbars and segmented controls reuse .news-* / .hist-* / .trend-* above. */
.ms-iq {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1600px;
  margin: 0 auto;
}
.ms-iq .news-header { align-items: flex-end; }
.ms-iq .news-title h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-iq .pos { color: var(--ms-success-light); }
.ms-iq .neg { color: var(--ms-danger-light); }
.iq-heading h1 { margin: 0; font-size: 26px; font-weight: 650; color: var(--ms-text); white-space: nowrap; }
.iq-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.iq-wind { display: flex; align-items: center; gap: 8px; }
.ms-iq .iq-doc { width: auto; gap: 8px; padding: 0 12px; font-size: 13px; }
.iq-wind-input { width: 120px; margin: 0; background-color: var(--ms-tile); }
.iq-wind-input input { -moz-appearance: textfield; }
.iq-wind-input input::-webkit-inner-spin-button,
.iq-wind-input input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.iq-controls .trend-icon-btn { width: 40px; height: 40px; background-color: var(--ms-tile); border: 1px solid var(--ms-tile-highlight); text-decoration: none; }
.iq-seg { background-color: var(--ms-tile); border: 1px solid var(--ms-tile-highlight); }
.iq-seg label { min-height: 32px; }
.iq-seg label i { font-size: 12px; }
.iq-dot { width: 10px; height: 10px; flex: 0 0 auto; align-self: center; }
.iq-track-title { align-items: center; min-width: 0; }

/* Track tiles: upload, map, trim slider */
.iq-tracks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.iq-track-upload { padding: 14px 20px 0; }
.iq-upload {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 8px 16px;
  border: 1px dashed var(--ms-tile-highlight);
  border-left: 4px solid;
  border-radius: 8px;
  background-color: var(--ms-bg);
  color: var(--ms-text-muted);
  font-size: 13px;
  cursor: pointer;
}
.iq-upload:hover { border-color: var(--ms-primary); color: var(--ms-text); }
.iq-upload > div { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; }
.iq-upload i { font-size: 16px; color: var(--ms-primary); }
.iq-upload-file { font-weight: 600; color: var(--ms-text); overflow-wrap: anywhere; }
.iq-upload-hint { font-size: 12px; color: var(--ms-text-muted); }
.iq-map { min-height: 400px; padding: 12px 12px 0; box-sizing: border-box; }  /* the figure sets its own height */
.iq-trim { padding: 8px 20px 14px; }
.iq-trim .rc-slider { margin: 6px 0 4px; }
.iq-trim .rc-slider-mark-text { color: var(--ms-text-muted); font-size: 10px; }

.iq-legend { padding: 12px 4px 4px; }
.iq-legend .iq-dot { width: 8px; height: 8px; }
.iq-whisker { width: 14px; height: 8px; border: 2px solid var(--ms-text-muted); border-top: 0; border-bottom: 0; position: relative; display: inline-block; }
.iq-whisker::after { content: ''; position: absolute; left: 0; right: 0; top: 3px; border-top: 2px solid var(--ms-text-muted); }

/* Analysis row: polar + four metrics */
.iq-analysis {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 8px;
  align-items: stretch;
}
.iq-metric .news-title { flex-wrap: wrap; row-gap: 2px; }
.iq-metric .news-title h2 { font-size: 18px; }
.iq-verdicts { padding: 10px 20px 0; min-height: 30px; }
.iq-verdict { font-size: 13px; font-weight: 600; line-height: 1.5; }
.iq-verdict i { margin-right: 6px; }
.iq-graph { padding: 4px 8px 8px; }
.iq-graph-polar { padding: 12px; }

/* Maneuver tables */
.iq-tables {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}
.iq-tables > div:empty { display: none; }
.iq-table .ag-theme-balham,
.iq-table [class*="ag-theme"] { border: 0 !important; }

@media (max-width: 1300px) {
  .iq-analysis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .iq-polar { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .iq-tracks,
  .iq-tables { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .ms-iq { padding: 12px 16px 24px; }
  .iq-heading h1 { font-size: 22px; white-space: normal; }
  .ms-iq .news-logo img { height: 36px; }
  .iq-analysis { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Investment swipe (app_swipe) ---------------------------- */
/* Header, tiles, toolbars, segmented control, pipeline stepper and score strip reuse
   .news-* / .trend-* / .snap-* above. */
.ms-swipe {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1500px;
  margin: 0 auto;
}
.ms-swipe .news-header { align-items: flex-end; }
.ms-swipe .news-header .news-weblinks { flex: 1 1 260px; }
.ms-swipe .news-tile { margin-bottom: 16px; }
.ms-swipe .news-title { flex-wrap: wrap; row-gap: 2px; }
.ms-swipe .news-title h2 { white-space: nowrap; }
.ms-swipe .news-seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.ms-swipe .news-seg label:has(input:checked) { background-color: var(--ms-primary); color: var(--ms-bg); }
.swipe-heading h1 { margin: 0; font-size: 26px; font-weight: 650; color: var(--ms-text); white-space: nowrap; }
.swipe-muted { margin: 0; font-size: 13px; color: var(--ms-text-muted); }

/* Navigation row: order + prev/next */
.swipe-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 16px;
}
.swipe-seg { flex-wrap: wrap; background-color: var(--ms-tile); border: 1px solid var(--ms-tile-highlight); }
.swipe-seg label { min-height: 32px; padding: 0 12px; }
.swipe-steps { display: flex; gap: 8px; }
.swipe-step { min-height: 40px; max-width: 220px; }
.swipe-step i { font-size: 12px; color: var(--ms-primary); }
.swipe-nav-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main grid: chart left, decision column right */
.swipe-grid {
  display: grid;
  grid-template-columns: minmax(0, 780px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.swipe-chart { padding: 12px; }
.swipe-chart-img {
  display: block;
  width: 100%;
  max-width: 750px;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  cursor: pointer;
}
.swipe-chart-img:not([src]), .swipe-chart-img[src=""] { min-height: 300px; }
.swipe-chart-tile .trend-icon-btn { text-decoration: none; }
.ms-swipe .news-toolbar .trend-icon-btn { background-color: var(--ms-bg); border: 1px solid var(--ms-tile-highlight); }

/* Decision tile: score, pipeline, mute */
.swipe-decision { display: flex; flex-direction: column; gap: 14px; }
.swipe-decision .snap-scorecard:empty { display: none; }
.swipe-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.swipe-actions i { font-size: 12px; }
.swipe-feedback { font-size: 12px; color: var(--ms-success-light); }

/* Comment */
.ms-swipe .hist-textarea { display: block; width: 100%; }
.swipe-textarea { min-height: 120px; margin-bottom: 10px; }

/* AI summary */
.swipe-summary { font-size: 13.5px; color: var(--ms-text); }
.swipe-md p { margin: 4px 0 10px; line-height: 1.5; }
.swipe-md ul { padding-left: 18px; }
.swipe-subhead {
  margin: 6px 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ms-text-muted);
}
.swipe-questions { list-style: none; margin: 0; padding: 0; }
.swipe-questions li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid rgba(var(--ms-border-rgb), 0.45);
  font-size: 13px;
  color: var(--ms-text);
}
.ms-swipe .swipe-ask { flex: 0 0 auto; min-height: 28px; padding: 0 10px; font-size: 12px; }

@media (max-width: 1100px) {
  .swipe-grid { grid-template-columns: minmax(0, 1fr); }
  .swipe-chart-tile { max-width: 780px; width: 100%; margin-left: auto; margin-right: auto; }
}
@media (max-width: 640px) {
  .ms-swipe { padding: 12px 12px 24px; }
  .swipe-heading h1 { font-size: 22px; }
  .ms-swipe .news-logo img { height: 36px; }
  .swipe-nav { flex-direction: column; align-items: stretch; }
  .swipe-steps { width: 100%; }
  .swipe-step { flex: 1 1 0; max-width: none; justify-content: center; }
  .swipe-chart { padding: 6px; }
  .swipe-questions li { flex-direction: column; }
  .ms-swipe .news-toolbar { flex-wrap: nowrap; align-items: flex-start; }
  .ms-swipe .news-title { flex: 1 1 auto; flex-basis: auto; min-width: 0; }
}

/* ---- Peer group comparison (app_peers) ----------------------- */
/* Header, tiles, toolbars and inputs reuse .news-* / .hist-* / .trend-* above. */
.ms-peers {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1700px;
  margin: 0 auto;
}
.ms-peers .news-header { align-items: flex-end; }
.ms-peers .news-title { flex-wrap: wrap; row-gap: 2px; }
.ms-peers .news-title h2 { white-space: nowrap; }
.peers-heading h1 { margin: 0; font-size: 26px; font-weight: 650; color: var(--ms-text); white-space: nowrap; }

/* Header: peer set + new set */
.peers-set { flex: 1 1 380px; max-width: 520px; }
.peers-set-row { display: flex; align-items: center; gap: 8px; }
.peers-set-dd { flex: 1 1 auto; min-width: 0; }
.peers-set-dd > div { width: 100%; }
.peers-set-row .trend-icon-btn { width: 40px; height: 40px; flex: 0 0 auto; background-color: var(--ms-tile); border: 1px solid var(--ms-tile-highlight); }
.peers-newset-input { width: 180px; height: 40px; background-color: var(--ms-tile); }
.peers-newset-input input { text-align: left; font-weight: 500; font-size: 14px; padding: 0 12px; }
.peers-newset .trend-save-btn { min-height: 40px; }
.peers-newset .trend-save-btn i { font-size: 11px; }

/* Tile grid: tables left, matrices right */
.peers-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}
.peers-tile { display: flex; flex-direction: column; min-width: 0; }

/* Peer tables: dot | peer | 3 x (sparkline + TTM bar) */
.peers-scroll { overflow-x: auto; }
.peers-table { min-width: 860px; padding: 4px 0 10px; }
.peers-row {
  display: grid;
  grid-template-columns: 26px minmax(200px, 1.6fr) repeat(6, minmax(80px, 1fr));
  align-items: center;
  column-gap: 8px;
  padding: 4px 20px;
  border-bottom: 1px solid rgba(var(--ms-border-rgb), 0.45);
}
.peers-row:last-child { border-bottom: 0; }
.peers-head { padding-top: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--ms-tile-highlight); }
.peers-head .news-eyebrow { margin: 0; }
.peers-group { grid-column: span 2; display: flex; flex-direction: column; line-height: 1.25; }
.peers-group span { font-size: 13px; font-weight: 600; color: var(--ms-text); }
.peers-group small { font-size: 11px; color: var(--ms-text-muted); }
.peers-dot { width: 10px; height: 10px; justify-self: center; }
.peers-row .news-stock { flex: none; max-width: none; min-width: 0; }
.peers-row .news-stock-dd .Select-control { height: 38px; }
.peers-row .news-stock-dd .Select-value-label,
.peers-row .news-stock-dd .Select-placeholder,
.peers-row .news-stock-dd .Select-input > input { font-size: 14px; line-height: 36px; }
.peers-row .news-stock-dd .Select--single > .Select-control .Select-value { line-height: 36px; }
.peers-name { min-width: 0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peers-name p { margin: 0; overflow: hidden; text-overflow: ellipsis; }
.peers-cell { height: 44px; min-width: 0; }
.peers-cell-graph { height: 44px; width: 100%; }

/* Matrices */
.peers-matrix { padding: 4px 8px 8px; }
.peers-matrix-graph { height: 330px; }

@media (max-width: 1300px) {
  .peers-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .ms-peers { padding: 12px 12px 24px; }
  .peers-heading h1 { font-size: 22px; }
  .ms-peers .news-logo img { height: 36px; }
  .peers-set, .peers-newset { flex-basis: 100%; max-width: none; }
  .peers-newset-input { flex: 1 1 auto; width: auto; }
}

/* ---- Clinuvel DCF dashboard (app_cuv, public) ---------------- */
/* Header, tiles, toolbars and KPI tiles reuse .news-* / .hist-* / .trend-* / .snap-* above. */
.ms-cuv {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1800px;
  margin: 0 auto;
}
.ms-cuv .news-header { align-items: flex-start; flex-wrap: nowrap; }   /* title | share | logo on one row */
.ms-cuv .news-tile { margin-bottom: 16px; }
.ms-cuv .news-title { flex-wrap: wrap; row-gap: 2px; }
.ms-cuv .news-title h2 { white-space: nowrap; }
.cuv-heading { flex: 1 1 auto; min-width: 0; }
.cuv-heading h1 { margin: 0 0 6px; font-size: 26px; font-weight: 650; color: var(--ms-text); }
.cuv-legal { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; font-size: 12px; color: var(--ms-text-muted); }
.cuv-legal > span { flex-basis: 100%; }
.cuv-legal-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ms-primary); text-decoration: none; }
.cuv-legal-link:hover span:not(.cuv-lang) { text-decoration: underline; }
.cuv-legal-link i { font-size: 12px; }
.cuv-lang {
  padding: 0 5px;
  border-radius: 4px;
  border: 1px solid var(--ms-tile-highlight);
  background-color: var(--ms-tile);
  color: var(--ms-text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 16px;
}

/* Grid: assumptions | results | ad */
.cuv-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
}

/* Assumptions: two columns of slider groups */
.cuv-levers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; padding: 4px 4px 12px; }
.cuv-lever-col { min-width: 0; }
.cuv-group { padding: 12px 16px 6px; border-bottom: 1px solid rgba(var(--ms-border-rgb), 0.45); }
.cuv-group h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ms-primary);
}
.cuv-lever {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  align-items: center;
  gap: 8px;
  min-height: 30px;
}
.cuv-lever label { margin: 0; font-size: 12.5px; color: var(--ms-text); line-height: 1.25; }
.cuv-lever > div { padding: 0 !important; }          /* Dash wraps the slider in a div with 25px bottom padding */
.cuv-lever .rc-slider { margin: 0 52px 0 6px; }     /* room for the value tooltip on the right */
.cuv-lever .rc-slider-tooltip-inner {
  min-width: 36px;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: var(--ms-bg) !important;
  color: var(--ms-text) !important;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  box-shadow: none;
}
.cuv-lever .rc-slider-tooltip-arrow { display: none; }

/* Results */
.hist-kpis.cuv-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cuv-kpi-hero { border-color: rgba(var(--ms-primary-rgb), 0.6); background-color: rgba(var(--ms-primary-rgb), 0.10); }
.cuv-kpi-hero .hist-kpi-v { font-size: 30px; color: var(--ms-primary); }
.cuv-graph { padding: 4px 8px 8px; }
.cuv-value-legend { padding: 0 20px 12px; }
.cuv-sw-front { height: 8px; background-color: var(--ms-primary); }
.cuv-sw-shadow { height: 10px; background-color: rgba(166, 174, 188, 0.18); border: 1px solid rgba(166, 174, 188, 0.55); }
/* Share link: header slot between title and logo */
.cuv-share { flex: 0 1 360px; min-width: 240px; align-self: center; }
.cuv-share:empty { display: none; }
.cuv-share-label { display: flex; align-items: center; gap: 6px; }
.cuv-share-label i { color: var(--ms-primary); }
.cuv-share-row { display: flex; align-items: center; gap: 8px; }
.ms-cuv .cuv-share-input {
  flex: 1 1 200px;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--ms-tile-highlight);
  background-color: var(--ms-bg);
  color: var(--ms-text-muted);
  font-size: 12px;
}
.cuv-copy { width: 34px; height: 34px; border: 1px solid var(--ms-tile-highlight); }

/* Ad column: own content keeps its inline styles */
.cuv-ad {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--ms-tile-highlight);
  background-color: var(--ms-tile);
  font-size: 13px;
  text-align: center;
}
.cuv-ad, .cuv-ad * { box-sizing: border-box; }
.cuv-ad div, .cuv-ad p, .cuv-ad a { max-width: 100%; }
.cuv-ad img { max-width: 100%; height: auto; }

/* Data table */
.cuv-table { padding: 12px 16px 16px; }
.cuv-table-actions { margin-bottom: 10px; }
.cuv-table-actions i, .cuv-table-tile .news-toolbar i { font-size: 12px; }
.cuv-footnote { margin: 10px 0 0; font-size: 12px; color: var(--ms-text-muted); }

@media (max-width: 1400px) {
  .cuv-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .cuv-ad { grid-column: 1 / -1; }
}
@media (max-width: 1000px) {
  .cuv-grid { grid-template-columns: minmax(0, 1fr); }
  .cuv-results { order: -1; }   /* fair value first on small screens, sliders below */
}
@media (max-width: 640px) {
  .ms-cuv { padding: 12px 12px 24px; }
  .cuv-heading h1 { font-size: 21px; }
  .ms-cuv .news-logo img { height: 36px; }
  .cuv-levers { grid-template-columns: minmax(0, 1fr); }
  .ms-cuv .news-header { flex-wrap: wrap; }
  .cuv-share { flex-basis: 100%; order: 3; }
}

/* ---- LCOE sensitivity (app_lcoe) ------------------------------ */
/* Header, tiles, toolbars, KPI tiles and legend reuse .news-* / .hist-* above. */
.ms-lcoe {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1600px;
  margin: 0 auto;
}
.ms-lcoe .news-header { align-items: flex-start; flex-wrap: nowrap; }   /* title | logo on one row */
.lcoe-heading { flex: 1 1 auto; min-width: 0; }
.lcoe-heading h1 { margin: 0 0 6px; font-size: 26px; font-weight: 650; color: var(--ms-text); }
.lcoe-heading p { margin: 0; max-width: 760px; font-size: 13px; color: var(--ms-text-muted); }

/* KPI strip */
.hist-kpis.lcoe-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lcoe-kpis:empty { display: none; }
.lcoe-kpi-label { display: flex; align-items: center; gap: 6px; }
.lcoe-kpi-hero { border-color: rgba(var(--ms-primary-rgb), 0.6); background-color: rgba(var(--ms-primary-rgb), 0.10); }
.lcoe-kpi-hero .hist-kpi-v { color: var(--ms-primary); }

/* Grid: inputs | sensitivity map */
.lcoe-grid {
  display: grid;
  grid-template-columns: minmax(380px, 0.8fr) minmax(0, 1.6fr);
  gap: 16px;
  align-items: start;
}

/* Parameter table: label | unit | scenario 1 | scenario 2 */
.lcoe-params {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 6px 10px;
  padding: 12px 20px 18px;
}
.lcoe-th {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--ms-tile-highlight);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ms-text-muted);
}
.lcoe-num { text-align: right; }
.lcoe-scn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.lcoe-label { margin: 0; font-size: 13px; color: var(--ms-text); }
.lcoe-unit { font-size: 12px; color: var(--ms-text-muted); }
.ms-lcoe .lcoe-input {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--ms-tile-highlight);
  background-color: var(--ms-bg);
  color: var(--ms-text);
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.ms-lcoe .lcoe-input::-webkit-outer-spin-button,
.ms-lcoe .lcoe-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ms-lcoe .lcoe-input:focus { outline: none; border-color: var(--ms-primary); }
.ms-lcoe .lcoe-input:invalid { border-color: var(--ms-danger-light); }

/* Sensitivity map: axis pickers + ranges, chart, legend */
.lcoe-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 110px 110px;
  gap: 12px;
  padding: 14px 20px 4px;
}
.lcoe-axis { min-width: 0; }
.lcoe-axis .news-eyebrow { display: flex; align-items: center; gap: 6px; }
.lcoe-axis .news-eyebrow i { color: var(--ms-primary); font-size: 11px; }
.lcoe-dd .Select-control {
  background-color: var(--ms-bg) !important;
  border: 1px solid var(--ms-tile-highlight) !important;
  border-radius: 8px !important;
  height: 34px;
}
.lcoe-dd .Select-value-label { color: var(--ms-text) !important; font-size: 13px; }
.lcoe-bw-field { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ms-text-muted); }
.lcoe-bw-field .lcoe-input { height: 34px; }
.lcoe-graph { height: 560px; padding: 4px 8px 0; }
.lcoe-map .hist-legend .lcoe-scn { gap: 6px; }

@media (max-width: 1100px) {
  .lcoe-grid { grid-template-columns: minmax(0, 1fr); }
  .lcoe-map { order: -1; }   /* map first, parameter table below */
}
@media (max-width: 640px) {
  .ms-lcoe { padding: 12px 12px 24px; }
  .lcoe-heading h1 { font-size: 21px; }
  .hist-kpis.lcoe-kpis { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .ms-lcoe .news-logo img { height: 36px; }
  .lcoe-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .lcoe-params { padding: 10px 12px 14px; gap: 6px 8px; }
  .lcoe-graph { height: 420px; }
}

/* ---- Investment diary (app_diary) ----------------------------- */
/* Header, tiles, toolbars, segmented toggle and inputs reuse .news-* / .hist-* / .trend-* above. */
.ms-diary {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1700px;
  margin: 0 auto;
}
.ms-diary .news-header { align-items: center; }
.ms-diary .news-title { flex-wrap: wrap; row-gap: 2px; }
.ms-diary .news-title h2 { white-space: nowrap; }
.ms-diary .news-seg input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }
.diary-heading h1 { margin: 0; font-size: 26px; font-weight: 650; color: var(--ms-text); white-space: nowrap; }

/* Grid: editor left, timeline right */
.diary-grid {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.diary-editor { position: sticky; top: 16px; }

/* Editor */
.diary-form { display: flex; flex-direction: column; gap: 14px; }
.diary-meta { display: flex; flex-direction: column; gap: 12px; }
.diary-meta-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 12px; }
.diary-mode {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background-color: rgba(var(--ms-primary-rgb), 0.12);
  color: var(--ms-primary);
  font-size: 12px;
  font-weight: 700;
}
.diary-mode.edit { background-color: rgba(118, 195, 171, 0.14); color: var(--ms-success-light); }
.diary-mode i { font-size: 11px; }
.diary-field { display: flex; flex-direction: column; min-width: 0; }
.diary-value { font-size: 14px; font-weight: 600; color: var(--ms-text); font-variant-numeric: tabular-nums; }
.ms-diary .hist-textarea { display: block; width: 100%; }
.diary-textarea { min-height: 180px; resize: vertical; }
.diary-dd .Select-control {
  background-color: var(--ms-bg) !important;
  border: 1px solid var(--ms-tile-highlight) !important;
  border-radius: 8px !important;
}
.diary-reminder .SingleDatePickerInput {
  background-color: var(--ms-bg) !important;
  border: 1px solid var(--ms-tile-highlight) !important;
  border-radius: 8px;
  overflow: hidden;
}
.diary-reminder .DateInput,
.diary-reminder .DateInput_input {
  background-color: transparent !important;
  color: var(--ms-text) !important;
  border: 0 !important;
  font-size: 14px;
  height: 38px;
  line-height: 38px;
}
.diary-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.diary-actions .trend-save-btn i { font-size: 12px; }
.diary-alert { font-size: 12px; color: var(--ms-success-light); }
.diary-alert:empty { display: none; }

/* Timeline */
.diary-seg { background-color: var(--ms-bg); }
.diary-seg label { min-height: 32px; padding: 0 12px; }
.diary-seg label i { font-size: 11px; }
.diary-table { padding: 8px 12px 12px; }
.diary-table .ag-cell { line-height: 1.45; }
.diary-table .ag-cell p { margin: 0 0 4px; }
.diary-type-comment { color: var(--ms-text); }
.diary-type-transaction { color: var(--ms-info-light); }
.diary-type-valuation { color: var(--ms-primary); }
.diary-pin { color: var(--ms-tile-highlight); cursor: pointer; }
.diary-pin.on { color: var(--ms-primary); }
.diary-del { color: var(--ms-text-muted); cursor: pointer; }
.diary-del:hover { color: var(--ms-danger-light); }

@media (max-width: 1100px) {
  .diary-grid { grid-template-columns: minmax(0, 1fr); }
  .diary-editor { position: static; }
}
@media (max-width: 900px) {
  .diary-table { overflow-x: auto; }
  .diary-table .ag-theme-balham { min-width: 760px; }   /* keep the entry column readable, scroll sideways */
}
@media (max-width: 640px) {
  .ms-diary { padding: 12px 12px 24px; }
  .diary-heading h1 { font-size: 22px; }
  .ms-diary .news-logo img { height: 36px; }
}

/* ---- Task trigger (app_tasks, mobile first) -------------------- */
/* Header, stock selector, tiles and toolbars reuse .news-* / .hist-* / .trend-* above. */
.ms-tasks {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1100px;
  margin: 0 auto;
}
.ms-tasks .news-header { align-items: center; margin-bottom: 12px; }
.ms-tasks .news-title { flex-wrap: wrap; row-gap: 2px; }
.ms-tasks .news-title h2 { white-space: nowrap; font-size: 18px; }
.tasks-heading h1 { margin: 0; font-size: 26px; font-weight: 650; color: var(--ms-text); white-space: nowrap; }

/* Stock selector + status line */
.tasks-stock { margin-bottom: 16px; }
.tasks-stock .news-stock { max-width: none; }
.tasks-msg { min-height: 24px; margin-top: 10px; font-size: 14px; }
.tasks-ok, .tasks-err {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid;
}
.tasks-ok { color: var(--ms-text); border-color: rgba(118, 195, 171, 0.55); background-color: rgba(62, 128, 108, 0.18); }
.tasks-ok > i { color: var(--ms-success-light); margin-top: 3px; }
.tasks-err { color: var(--ms-text); border-color: rgba(204, 102, 96, 0.55); background-color: rgba(136, 56, 53, 0.18); }
.tasks-err > i { color: var(--ms-danger-light); margin-top: 3px; }
.tasks-err small { color: var(--ms-text-muted); }
.tasks-md p { margin: 0; }
.tasks-md a, .tasks-link { color: var(--ms-primary); text-decoration: none; }
.tasks-link { display: inline-flex; align-items: center; gap: 6px; }
.tasks-link i { font-size: 11px; }
.tasks-muted { color: var(--ms-text-muted); }

/* Tiles */
.tasks-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.tasks-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.tasks-comment { grid-column: 1 / -1; }
.tasks-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tasks-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;           /* thumb-sized on phones */
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--ms-tile-highlight);
  background-color: var(--ms-bg);
  color: var(--ms-text);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.tasks-btn i { width: 18px; text-align: center; color: var(--ms-primary); font-size: 15px; }
.tasks-btn:hover:not(:disabled) { border-color: var(--ms-primary); background-color: var(--ms-tile-highlight); }
.tasks-btn:active:not(:disabled) { transform: translateY(1px); }
.tasks-btn:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }
.tasks-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tasks-btn.secondary i { color: var(--ms-text-muted); }
.tasks-btn.primary { background-color: var(--ms-primary); border-color: var(--ms-primary); color: var(--ms-bg); }
.tasks-btn.primary i { color: var(--ms-bg); }
.tasks-btn.primary:hover:not(:disabled) { background-color: var(--ms-primary-dark); }
.tasks-btn-label { min-width: 0; line-height: 1.25; }
.tasks-btn-sub { display: block; font-size: 11px; font-weight: 500; color: var(--ms-text-muted); }
.tasks-notebook { font-size: 13px; }
.tasks-notebook:empty { display: none; }
.ms-tasks .hist-textarea { display: block; width: 100%; }
.tasks-textarea { min-height: 160px; resize: vertical; }

@media (max-width: 760px) {
  .tasks-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .ms-tasks { padding: 12px 12px 24px; }
  .tasks-heading h1 { font-size: 22px; }
  .ms-tasks .news-logo img { height: 36px; }
  .tasks-btns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Fair multiple sensitivities (app_fairmult) ---------------- */
/* Header, tiles, toolbars, legend reuse .news-* / .hist-*; lever rows reuse .cuv-group / .cuv-lever. */
.ms-fairmult {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1920px;
  margin: 0 auto;
}
.ms-fairmult .news-header { align-items: flex-start; flex-wrap: nowrap; }
.fm-heading { flex: 1 1 auto; min-width: 0; }
.fm-heading h1 { margin: 0 0 6px; font-size: 26px; font-weight: 650; color: var(--ms-text); }
.fm-heading p { margin: 0; max-width: 820px; font-size: 13px; color: var(--ms-text-muted); }

/* Grid: assumptions | sensitivity | business KPIs | ad */
.fm-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1.6fr) minmax(320px, 1fr) 270px;
  gap: 16px;
  align-items: start;
}

/* Assumptions */
.fm-levers .cuv-group:last-child { border-bottom: 0; }
.fm-lever label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; }
.fm-lever label small { font-size: 11px; color: var(--ms-text-muted); }
.fm-lever-range { min-height: 52px; padding: 4px 0; margin: 2px -8px; padding-left: 8px; padding-right: 8px;
                  border-radius: 8px; background-color: rgba(var(--ms-primary-rgb), 0.07); }
.fm-lever-range .rc-slider { margin: 0 22px 22px 10px; }   /* tooltips below, no room needed on the right */
.fm-badge {
  padding: 1px 6px;
  border-radius: 4px;
  background-color: var(--ms-primary);
  color: var(--ms-bg);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Sensitivity: axis pickers, chart, legend */
.fm-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 14px 20px 4px; }
.fm-axis { min-width: 0; }
.fm-axis .news-eyebrow { display: flex; align-items: center; gap: 6px; }
.fm-axis .news-eyebrow i { color: var(--ms-primary); font-size: 11px; }
.fm-dd .Select-control {
  background-color: var(--ms-bg) !important;
  border: 1px solid var(--ms-tile-highlight) !important;
  border-radius: 8px !important;
  height: 34px;
}
.fm-dd .Select-value-label { color: var(--ms-text) !important; font-size: 13px; }
.fm-graph { padding: 4px 8px 0; }
.fm-hint-i { color: var(--ms-primary); font-size: 11px; }

/* Ad column: own content keeps its inline styles */
.fm-ad {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--ms-tile-highlight);
  background-color: var(--ms-tile);
  font-size: 13px;
  text-align: center;
}
.fm-ad, .fm-ad * { box-sizing: border-box; }
.fm-ad div, .fm-ad p, .fm-ad a { max-width: 100%; }
.fm-ad img { max-width: 100%; height: auto; }

@media (max-width: 1700px) {
  .fm-grid { grid-template-columns: 340px minmax(0, 1.6fr) minmax(300px, 1fr); }
  .fm-ad { grid-column: 1 / -1; justify-self: center; width: 300px; }
}
@media (max-width: 1300px) {
  .fm-grid { grid-template-columns: 340px minmax(0, 1fr); }
  .fm-sens { grid-column: 1 / -1; order: -1; }   /* grid on top, assumptions | business below */
}
@media (max-width: 900px) {
  .fm-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .ms-fairmult { padding: 12px 12px 24px; }
  .fm-heading h1 { font-size: 21px; }
  .ms-fairmult .news-logo img { height: 36px; }
  .fm-controls { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Inverses KGV (app_reverse_pe_pub, public) ---------------- */
/* Uses .ms-cuv for header, legal links, share box, ad column and chart tile; only the grid and inputs here. */
.rpe-grid {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr) 260px;
  gap: 16px;
  align-items: start;
}
.rpe-form { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px 16px; }
.rpe-group { padding-top: 10px; border-top: 1px solid rgba(var(--ms-border-rgb), 0.45); margin-top: 8px; }
.rpe-group h3 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ms-primary);
}
.rpe-field {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 40px;
}
.rpe-field label { margin: 0; font-size: 13px; color: var(--ms-text); line-height: 1.25; }
.rpe-field-text { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.5fr); }
.rpe-input-box { height: 34px; }
.ms-rpe .rpe-input-box input { font-size: 14px; }
.ms-rpe .rpe-input-box input[type="number"] { -moz-appearance: textfield; }
.ms-rpe .rpe-input-box input::-webkit-inner-spin-button,
.ms-rpe .rpe-input-box input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ms-rpe .rpe-chart-tile .news-title h2 { white-space: normal; }   /* headline changes with P/E and stock name */
.rpe-field.computed .rpe-input-box { background-color: transparent; border-style: dashed; }
.rpe-computed-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 4px;
  border: 1px solid var(--ms-tile-highlight);
  font-size: 10px;
  color: var(--ms-text-muted);
}
.rpe-field.key label { font-weight: 700; color: var(--ms-primary); }
.rpe-field.key .rpe-input-box { border-color: rgba(var(--ms-primary-rgb), 0.6); background-color: rgba(var(--ms-primary-rgb), 0.10); border-style: solid; }
.ms-rpe .rpe-field.key .rpe-input-box input { color: var(--ms-primary) !important; font-size: 16px; font-weight: 700; }
.rpe-slider > div { padding: 0 !important; }   /* Dash wraps the slider in a padded div */
.rpe-slider .rc-slider { margin: 8px 6px 18px; }
.rpe-slider .rc-slider-mark-text { color: var(--ms-text-muted); font-size: 11px; }

@media (max-width: 1400px) {
  .rpe-grid { grid-template-columns: 360px minmax(0, 1fr); }
  .rpe-ad { grid-column: 1 / -1; }
}
@media (max-width: 1000px) {
  .rpe-grid { grid-template-columns: minmax(0, 1fr); }
  .rpe-chart-tile { order: -1; }   /* chart first on small screens, inputs below */
}

/* ---- Reverse P/E, internal (app_reverse_pe) --------------------- */
/* Same inputs/curves as app_reverse_pe_pub (.ms-rpe above); stock selector in the header, three tiles. */
.rpea-stock { flex: 0 1 460px; min-width: 260px; align-self: center; }
.rpea-stock .news-stock { max-width: none; }
.rpea-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.rpe-group.first { border-top: 0; margin-top: 0; padding-top: 4px; }
.rpea-ebit .rpe-form { padding-bottom: 4px; }

@media (max-width: 1400px) {
  .rpea-grid { grid-template-columns: 360px minmax(0, 1fr); }
  .rpea-ebit { grid-column: 1 / -1; }
}
@media (max-width: 1000px) {
  .rpea-grid { grid-template-columns: minmax(0, 1fr); }
  .ms-rpe .news-header { flex-wrap: wrap; }
  .rpea-stock { flex-basis: 100%; order: 3; }
}

/* ---- Asset manager (app_assetmgr) ------------------------------- */
/* Header, stock selector, tiles, toolbars and inputs reuse .news-* / .hist-* / .trend-* above. */
.ms-assetmgr {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1500px;
  margin: 0 auto;
}
.ms-assetmgr .news-header { align-items: flex-end; }
.ms-assetmgr .news-title { flex-wrap: wrap; row-gap: 2px; }
.ms-assetmgr .news-title h2 { white-space: nowrap; font-size: 18px; }
.am-heading h1 { margin: 0; font-size: 26px; font-weight: 650; color: var(--ms-text); white-space: nowrap; }
.am-stock { flex: 1 1 380px; max-width: 520px; display: flex; align-items: flex-end; gap: 8px; }
.am-stock .news-stock { flex: 1 1 auto; max-width: none; }
.am-steps { display: flex; gap: 6px; padding-bottom: 3px; }
.am-steps .trend-icon-btn { width: 40px; height: 40px; background-color: var(--ms-tile); border: 1px solid var(--ms-tile-highlight); }
.ms-assetmgr .news-weblinks { flex: 1 1 200px; }
.am-msg { min-height: 22px; margin-bottom: 12px; font-size: 13px; color: var(--ms-success-light); }
.am-msg:empty { display: none; }

/* Tiles */
.am-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.am-wide { grid-column: 1 / -1; }
.am-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.am-field { display: flex; flex-direction: column; min-width: 0; }
.am-names { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.am-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ms-assetmgr .am-input {
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--ms-tile-highlight);
  background-color: var(--ms-bg);
  color: var(--ms-text);
  font-size: 14px;
}
.ms-assetmgr .am-input:focus { outline: none; border-color: var(--ms-primary); }
.ms-assetmgr .hist-textarea { display: block; width: 100%; }
.am-textarea { min-height: 150px; resize: vertical; }
.am-dd .Select-control {
  background-color: var(--ms-bg) !important;
  border: 1px solid var(--ms-tile-highlight) !important;
  border-radius: 8px !important;
}

/* Status blocks */
.am-status:empty { display: none; }
.am-info { display: flex; flex-direction: column; gap: 4px; }
.am-info-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--ms-text-muted); }
.am-info-v { color: var(--ms-text); font-weight: 600; font-variant-numeric: tabular-nums; }
.am-badge {
  display: inline-block;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--ms-tile-highlight);
  font-size: 12px;
  font-weight: 700;
  color: var(--ms-text-muted);
}
.am-badge.on { border-color: rgba(118, 195, 171, 0.55); background-color: rgba(62, 128, 108, 0.18); color: var(--ms-success-light); }

/* Buttons */
.am-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.am-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--ms-tile-highlight);
  background-color: var(--ms-bg);
  color: var(--ms-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.am-btn i { font-size: 12px; color: var(--ms-primary); }
.am-btn:hover { border-color: var(--ms-primary); background-color: var(--ms-tile-highlight); }
.am-btn:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }
.am-btn.primary { background-color: var(--ms-primary); border-color: var(--ms-primary); color: var(--ms-bg); }
.am-btn.primary i { color: var(--ms-bg); }
.am-btn.primary:hover { background-color: var(--ms-primary-dark); }
.am-btn.danger i { color: var(--ms-danger-light); }
.am-btn.danger:hover { border-color: var(--ms-danger-light); background-color: rgba(136, 56, 53, 0.25); }

@media (max-width: 900px) {
  .am-grid { grid-template-columns: minmax(0, 1fr); }
  .am-names { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .ms-assetmgr { padding: 12px 12px 24px; }
  .am-heading h1 { font-size: 22px; }
  .ms-assetmgr .news-logo img { height: 36px; }
  .am-stock { flex-basis: 100%; max-width: none; }
}

/* ---- Tag manager (app_tagmgr) ----------------------------------- */
/* Reuses .ms-assetmgr / .am-* above (header, tiles, fields, buttons). */
.ms-tagmgr { max-width: 1300px; }
.tm-grid { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 16px; align-items: start; }
.tm-new { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end;
          padding-top: 12px; border-top: 1px solid rgba(var(--ms-border-rgb), 0.45); }
.tm-stocks .Select-control { min-height: 120px; align-items: flex-start; }
.tm-save-msg { font-size: 13px; color: var(--ms-success-light); }
.tm-save-msg:empty { display: none; }

@media (max-width: 900px) {
  .tm-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Option comparison (app_opcomp) ----------------------------- */
/* Header, tiles, toolbars, segmented control and input rows reuse .news-* / .trend-* / .rpe-* above. */
.ms-opcomp, .ms-opsen {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1700px;
  margin: 0 auto;
}
.ms-opcomp .news-header, .ms-opsen .news-header { align-items: center; }
.ms-opcomp .news-tile, .ms-opsen .news-tile { margin-bottom: 16px; }
.ms-opcomp .news-title, .ms-opsen .news-title { flex-wrap: wrap; row-gap: 2px; }
.ms-opcomp .news-title h2, .ms-opsen .news-title h2 { white-space: nowrap; font-size: 18px; }
.oc-heading h1 { margin: 0; font-size: 26px; font-weight: 650; color: var(--ms-text); white-space: nowrap; }
.oc-grid { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 16px; align-items: start; }
.oc-table { padding: 8px 12px 0; }
.oc-actions { padding: 10px 16px 14px; }
.oc-actions i { font-size: 11px; }
.ms-opcomp .news-seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.ms-opcomp .news-seg label:has(input:checked) { background-color: var(--ms-primary); color: var(--ms-bg); }
.oc-seg { flex-wrap: wrap; background-color: var(--ms-bg); }
.oc-seg label { min-height: 30px; padding: 0 10px; font-size: 12px; }
.oc-slider { padding: 0 24px 18px; }
.oc-slider { padding-top: 26px !important; }        /* room for the value bubble above the handle */
.oc-slider .news-eyebrow { margin: 6px 0 0; text-align: right; }
.oc-slider > div { padding-bottom: 0 !important; }
.oc-price { display: grid; grid-template-columns: 74px minmax(0, 1fr); align-items: start; }
.oc-vslider { display: flex; flex-direction: column; align-items: center; padding: 12px 0 0 12px; }
.oc-vslider .news-eyebrow { margin-bottom: 8px; }
.oc-axis-note { margin: 0; padding: 0 20px 14px; text-align: right; font-size: 12px; color: var(--ms-text-muted); }

/* ---- Options sensitivity (app_opsen) ---------------------------- */
.os-grid { display: grid; grid-template-columns: 520px minmax(0, 1fr); gap: 16px; align-items: start; }
.os-table { padding: 10px 16px 6px; }
.os-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) 64px minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 42px;
  font-size: 13px;
  color: var(--ms-text);
}
.os-head { min-height: 30px; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ms-text-muted); }
.os-head > span { display: inline-flex; align-items: center; gap: 6px; }
.os-dot { width: 9px; height: 9px; flex: 0 0 auto; }
.os-units { font-size: 12px; color: var(--ms-text-muted); }
.os-row.key { margin-top: 6px; padding-top: 8px; border-top: 1px solid rgba(var(--ms-border-rgb), 0.45); }
.os-row.key .os-label { font-weight: 700; color: var(--ms-primary); }
.os-row.key .rpe-input-box { border-color: rgba(var(--ms-primary-rgb), 0.6); background-color: rgba(var(--ms-primary-rgb), 0.10); }
.ms-opsen .os-row.key .rpe-input-box input { color: var(--ms-primary) !important; font-weight: 700; }
.os-settings { padding: 10px 16px 14px; border-top: 1px solid rgba(var(--ms-border-rgb), 0.45); }
.os-settings h3 {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ms-primary);
}
.os-dd .Select-control { height: 34px; background-color: var(--ms-bg) !important; border: 1px solid var(--ms-tile-highlight) !important; border-radius: 8px !important; }
.os-axes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 12px 16px 0; }
.os-axis { display: flex; flex-direction: column; }
.os-legend { padding: 4px 20px 14px; }
.os-scale { width: 54px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #883835, #E0B773, #3E806C); }

@media (max-width: 1150px) {
  .oc-grid, .os-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .ms-opcomp, .ms-opsen { padding: 12px 12px 24px; }
  .oc-heading h1 { font-size: 22px; }
  .ms-opcomp .news-logo img, .ms-opsen .news-logo img { height: 36px; }
  .os-row { grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr) minmax(0, 1fr); }
}

/* ---- Company KPIs (app_kpis) ------------------------------------ */
/* Header, tiles, toolbars and the stat strip reuse .news-* / .hist-kpi* / .cuv-graph above. */
.ms-kpis {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1800px;
  margin: 0 auto;
}
.ms-kpis .news-header { align-items: center; }
.kp-heading h1 { margin: 0; font-size: 26px; font-weight: 650; color: var(--ms-text); white-space: nowrap; }
.kp-stock { display: flex; align-items: flex-end; gap: 8px; flex: 1 1 360px; max-width: 520px; }
.kp-stock .news-stock { flex: 1 1 auto; max-width: none; }
.kp-refresh { width: 46px; height: 46px; padding: 0; justify-content: center; flex: 0 0 auto; }
.ms-kpis .news-weblinks { flex: 1 1 200px; }
.kp-message:not(:empty) {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(204, 102, 96, 0.55);
  background-color: rgba(136, 56, 53, 0.18);
  color: var(--ms-danger-light);
  font-size: 13px;
}
.hist-kpis.kp-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 10px; }
.kp-legend { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0 4px 14px; font-size: 12px; color: var(--ms-text-muted); }
.kp-legend > span { display: inline-flex; align-items: center; gap: 8px; }
.kp-key { display: inline-block; width: 22px; height: 0; border-top: 2px solid; }
.kp-key-q   { border-color: var(--ms-primary); border-top-width: 3px; }
.kp-key-py  { border-color: #8A8FA3; }
.kp-key-ttm { border-color: var(--ms-text); border-top-style: dotted; }
.kp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.kp-tile .news-toolbar { padding: 12px 16px; flex-wrap: nowrap; }
.kp-tile .news-title { flex-direction: column; gap: 2px; min-width: 0; }
.kp-tile .news-title h2 { font-size: 16px; white-space: nowrap; }
.kp-tile .news-title span { font-size: 12px; }
.kp-head { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 0 0 auto; }
.kp-value { font-size: 20px; font-weight: 650; color: var(--ms-text); font-variant-numeric: tabular-nums; }
.kp-delta { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.kp-delta.kp-pos { background-color: rgba(62, 128, 108, 0.22); }
.kp-delta.kp-neg { background-color: rgba(136, 56, 53, 0.25); }
.kp-delta.kp-mut { background-color: var(--ms-tile-highlight); color: var(--ms-text-muted); }
.kp-pos { color: var(--ms-success-light); }
.kp-neg { color: var(--ms-danger-light); }

@media (max-width: 1250px) {
  .kp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .ms-kpis { padding: 12px 12px 24px; }
  .kp-heading h1 { font-size: 22px; }
  .ms-kpis .news-logo img { height: 36px; }
  .kp-grid { grid-template-columns: minmax(0, 1fr); }
  .hist-kpis.kp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Executive assistant (app_exass) ---------------------------- */
/* Header, tiles, toolbars, segmented control, KPI strip and chat panel reuse .news-* / .hist-kpi* / .snap-* above. */
.ms-exass {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1800px;
  margin: 0 auto;
}
.ms-exass .news-header { align-items: center; flex-wrap: nowrap; }
.ex-avatar { width: 56px; height: 56px; flex: 0 0 auto; border-radius: 50%; border: 2px solid var(--ms-primary); object-fit: cover; }
/* Avatar links to the CV (assistant_avatar in app/utils.py); -chat: in the title of the chat panels (snapshot, swipe, exass) */
.assistant-cv { flex: 0 0 auto; display: block; border-radius: 50%; }
.assistant-cv img { display: block; }
.assistant-cv:hover img { border-color: var(--ms-text); }
.assistant-cv:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }
.assistant-avatar-chat { width: 40px; height: 40px; border-radius: 50%; border: 2px solid #ECA758; }
.ex-heading { flex: 1 1 auto; min-width: 0; }
.ex-heading h1 { margin: 0; font-size: 26px; font-weight: 650; color: var(--ms-text); white-space: nowrap; }
.ex-chat-btn { min-height: 40px; }
.ms-exass .news-tile { margin-bottom: 16px; }
.ex-tile { display: flex; flex-direction: column; min-width: 0; }

/* Briefing + KPI strip */
.ex-brief { padding: 16px 20px 18px; }
.ex-brief-head { display: flex; align-items: center; gap: 8px; }
.ex-brief-head .news-eyebrow { margin: 0; color: var(--ms-primary); }
.ex-brief-head .news-eyebrow i { margin-right: 8px; }
.ex-narrative { margin: 8px 0 0; max-width: 1100px; font-size: 15px; line-height: 1.55; color: var(--ms-text); }
.hist-kpis.ex-kpis { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.ex-kpi-pos .hist-kpi-v { color: var(--ms-success-light); }
.ex-kpi-neg .hist-kpi-v { color: var(--ms-danger-light); }
.ex-kpi-gold .hist-kpi-v { color: var(--ms-primary); }
.ex-kpi-today { border-color: rgba(255, 138, 92, 0.55); }
.ex-kpi-today .hist-kpi-v { color: #FF8A5C; }
.ex-kpi-muted .hist-kpi-v { color: var(--ms-text-muted); }

/* Rows */
.ex-row { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 16px; align-items: start; }
.ex-row-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ex-row > .news-tile { margin-bottom: 16px; }
.ex-filter { flex: 0 1 260px; min-width: 180px; }
.ex-filter .Select-control { height: 34px; background-color: var(--ms-bg) !important; border: 1px solid var(--ms-tile-highlight) !important; border-radius: 8px !important; }
.ex-list { max-height: 600px; overflow-y: auto; padding: 12px 16px 4px; }
.ex-foot { padding: 0 16px 12px; }
.ex-more { min-height: 30px; font-size: 12px; }
.ex-empty { padding: 10px 2px; font-size: 13px; color: var(--ms-text-muted); }
.ex-grid { padding: 8px 10px 10px; }

/* Cards (alerts and tasks) */
.ex-card {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--ms-tile-highlight);
  border-left: 3px solid var(--ex-cat, var(--ms-tile-highlight));
  background-color: var(--ms-bg);
}
.ex-alert { --ex-cat: #76C3AB; }
.ex-alert.rerating { --ex-cat: #CC6660; }
.ex-card-today { border-color: rgba(255, 138, 92, 0.7); border-left-color: var(--ex-cat); }
.ex-card-hibernated { opacity: 0.6; }
.ex-card-hibernated:hover { opacity: 1; }
.ex-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.ex-tag {
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background-color: #2a2f55;
  color: #C9CCE6;
}
.ex-tag-holding  { background-color: #1d3b5a; color: #9fd0ff; }
.ex-tag-large    { background-color: #5a3a12; color: var(--ms-primary); }
.ex-tag-wkf      { background-color: #10414a; color: #7fe3f0; }
.ex-tag-watch    { background-color: #3a2d5a; color: #cdb8ff; }
.ex-tag-alert    { background-color: #173a3a; color: #7DDCBF; }
.ex-tag-rerating { background-color: #4a1f2a; color: #F8C4BF; }
.ex-card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-top: 6px; }
.ex-card-title { margin-top: 6px; font-size: 14px; font-weight: 650; color: #EAEFFF; }
.ex-card-head .ex-card-title { margin-top: 0; }
.ex-card-text { margin-top: 2px; font-size: 12.5px; line-height: 1.5; color: #A9B0C0; }
.ex-meta { font-size: 11px; color: var(--ms-text-muted); font-variant-numeric: tabular-nums; }
.ex-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 6px; }
.ex-link { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ms-primary); text-decoration: none; }
.ex-link:hover { text-decoration: underline; }
.ex-link.muted { color: var(--ms-text-muted); }
.ex-link i { font-size: 11px; }
.ex-ask { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 6px; color: var(--ms-primary); font-size: 12px; cursor: pointer; }
.ex-ask:hover { background-color: var(--ms-tile-highlight); }
.ex-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.ex-ops { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.ex-ops:empty { display: none; }
.ex-op {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid var(--ms-tile-highlight);
  background-color: var(--ms-tile);
  color: var(--ms-text);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.ex-op, .ex-more, .ex-chat-btn { margin: 0; }
.ex-op:hover { background-color: var(--ms-tile-highlight); color: var(--ms-primary); }
.ex-op-primary { border-color: var(--ms-primary); background-color: var(--ms-primary); color: var(--ms-bg); }
.ex-op-primary:hover { background-color: var(--ms-primary-dark); color: var(--ms-bg); }
.ex-op:focus-visible, .ex-ask:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 2px; }
.ex-sleep { display: inline-flex; align-items: center; gap: 5px; margin-right: 4px; font-size: 11px; color: var(--ms-text-muted); }

/* Movers & buy zone */
.ex-perf-body { padding: 12px 20px 16px; }
.ex-h3 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ms-primary); }
.ex-mt { margin-top: 16px; }
.ex-table { margin-top: 6px; }
.ex-tr {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px 70px;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 13px;
}
.ex-td-name { display: inline-flex; align-items: center; gap: 2px; min-width: 0; }
.ex-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ms-text); text-decoration: none; }
a.ex-name:hover { color: var(--ms-primary); }
.ex-num { text-align: right; font-variant-numeric: tabular-nums; }
.ex-pos { color: var(--ms-success-light); }
.ex-neg { color: var(--ms-danger-light); }
.ex-muted { color: var(--ms-text-muted); font-size: 12px; }
.ex-source { cursor: help; font-size: 14px; }
.ex-perf-link { margin-top: 14px; }
/* Mover bars: diverging from the zero line in the middle; --ex-bar = share (0..1) of the largest move shown */
.ex-tr-mover { grid-template-columns: minmax(0, 1fr) minmax(80px, 34%) 56px 48px; }
.ex-bar-track { position: relative; align-self: stretch; }
.ex-bar-track::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background-color: var(--ms-text-muted); opacity: 0.5; }
.ex-bar { position: absolute; top: 50%; height: 12px; width: calc(50% * var(--ex-bar, 0)); min-width: 2px; transform: translateY(-50%); }
.ex-bar-pos { left: 50%; border-radius: 0 4px 4px 0; background-color: var(--ms-success-light); }
.ex-bar-neg { right: 50%; border-radius: 4px 0 0 4px; background-color: var(--ms-danger-light); }

/* Tasks kanban */
.ex-tasks .news-toolbar { row-gap: 10px; }
.ex-op-message { font-size: 12px; }
.ex-op-message i { margin-right: 6px; }
.ex-seg { flex-wrap: wrap; }
.ex-seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.ex-seg label { min-height: 30px; padding: 0 12px; font-size: 12px; }
.ex-kanban { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: start; padding: 14px 16px 16px; }
.ex-lane { min-width: 0; padding: 10px; border-radius: 10px; background-color: rgba(var(--ms-bg-rgb), 0.55); }
.ex-lane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 2px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ms-primary);
}
.ex-count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; text-align: center; background-color: var(--ms-tile-highlight); color: var(--ms-text); font-size: 11px; letter-spacing: 0; }
.ex-lane-today .ex-lane-head { color: #FF8A5C; }
.ex-lane-hibernated .ex-lane-head { color: var(--ms-text-muted); }
.ex-lane-body { max-height: 760px; overflow-y: auto; }
.ex-lane .ex-card { background-color: var(--ms-tile); }
.ex-mutes { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 0 20px 16px; }
.ex-mutes:empty { display: none; }
.ex-mutes > .news-eyebrow { margin: 0; }
.ex-mutes > .news-eyebrow i { margin-right: 6px; }
.ex-mute { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; }

/* Chat panel */
.ex-chat-scope { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; }
.ex-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 2px 8px; border-radius: 4px; font-size: 11px; background-color: #2a2f55; color: #C9CCE6; }
.ex-unscope { cursor: pointer; color: var(--ms-text-muted); }
.ex-unscope:hover { color: var(--ms-primary); }
.ex-msg { margin: 6px 0; padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; }
.ex-msg p:last-child { margin-bottom: 0; }
.ex-msg-user { margin-left: 15%; background-color: #173a3a; text-align: right; }
.ex-msg-bot { margin-right: 8%; background-color: var(--ms-tile); }

@media (max-width: 1400px) {
  .hist-kpis.ex-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ex-kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .ex-row, .ex-row-even { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .ms-exass { padding: 12px 12px 24px; }
  .ex-heading h1 { font-size: 22px; }
  .ex-avatar { width: 44px; height: 44px; }
  .ms-exass .news-logo img { height: 36px; }
  .ex-chat-btn span, .ex-chat-btn { font-size: 0; gap: 0; }
  .ex-chat-btn i { font-size: 14px; }
  .hist-kpis.ex-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ex-kanban { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Chart export (app_charts) ---------------------------------- */
/* Header, tiles, toolbars and the segmented control reuse .news-* / .snap-btn-secondary above. */
.ms-charts {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1800px;
  margin: 0 auto;
}
.cx-heading h1 { margin: 0; font-size: 26px; font-weight: 650; color: var(--ms-text); white-space: nowrap; }
.cx-mode { display: flex; flex-direction: column; }
.cx-seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.cx-seg { background-color: var(--ms-tile); }
.cx-seg label { min-height: 40px; }
.cx-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.cx-wide { grid-column: 1 / -1; }
.cx-tile { min-width: 0; }
.cx-dls { display: flex; gap: 8px; }
.cx-dl { min-height: 32px; margin: 0; font-size: 12px; text-decoration: none; }
.cx-dl i { font-size: 11px; }
.cx-frame { display: flex; justify-content: center; padding: 16px; }
.cx-frame.cx-light { background-color: #ffffff; }
.cx-img { display: block; width: 100%; height: auto; }
.cx-empty { grid-column: 1 / -1; padding: 32px 4px; font-size: 14px; color: var(--ms-text-muted); }
.cx-error { margin: 0; font-size: 13px; color: var(--ms-danger-light); }

@media (max-width: 1100px) {
  .cx-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .ms-charts { padding: 12px 12px 24px; }
  .cx-heading h1 { font-size: 22px; }
  .ms-charts .news-logo img { height: 36px; }
  .cx-frame { padding: 8px; }
}

/* ---- CUV Monitoring (app_db, /db_monitoring) ------------------- */
/* Header, tiles, toolbars, KPI tiles and legend reuse .news-* / .hist-* above. */
.ms-dbmon {
  min-height: 100vh;
  padding: 20px 24px 32px;
  max-width: 1600px;
  margin: 0 auto;
}
.ms-dbmon .news-header { align-items: flex-start; flex-wrap: nowrap; }
.dbmon-heading { flex: 1 1 auto; min-width: 0; }
.dbmon-heading h1 { margin: 0 0 6px; font-size: 26px; font-weight: 650; color: var(--ms-text); }
.dbmon-heading p { margin: 0; max-width: 760px; font-size: 13px; color: var(--ms-text-muted); }
.ms-dbmon .news-tile { margin-bottom: 16px; }

/* KPI strip */
.hist-kpis.dbmon-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.dbmon-kpis:empty { display: none; }
.dbmon-kpi-hero { border-color: rgba(var(--ms-primary-rgb), 0.6); background-color: rgba(var(--ms-primary-rgb), 0.10); }
.dbmon-kpi-hero .hist-kpi-v { color: var(--ms-primary); }
.dbmon-kpis .hist-kpi-s { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Usage | most active */
.dbmon-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.dbmon-grid .news-tile { margin-bottom: 0; }
.dbmon-grid { margin-bottom: 16px; }
.dbmon-graph { padding: 4px 8px 0; }
.dbmon-sw-bar { height: 8px; background-color: rgba(var(--ms-primary-rgb), 0.25); border: 1px solid var(--ms-primary); }

/* Single user */
.dbmon-user-pick { flex: 1 1 420px; max-width: 640px; }
.dbmon-dd .Select-control {
  background-color: var(--ms-bg) !important;
  border: 1px solid var(--ms-tile-highlight) !important;
  border-radius: 8px !important;
  height: 36px;
}
.dbmon-dd .Select-value-label { color: var(--ms-text) !important; font-size: 13px; }
.dbmon-dd .Select-placeholder { font-size: 13px; }
.dbmon-user-body { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 0 16px; align-items: start; padding: 8px 12px 16px; }
.dbmon-user-left, .dbmon-user-right { min-width: 0; }
.dbmon-sub { padding: 14px 8px 0; }
.dbmon-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 8px 0; }
.dbmon-chips:empty { display: none; }
.dbmon-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background-color: var(--ms-bg);
  border: 1px solid var(--ms-tile-highlight);
  font-size: 12px;
  color: var(--ms-text);
}
.dbmon-chip i { color: var(--ms-primary); font-size: 11px; }
.dbmon-table { padding: 8px 8px 4px; }
.dbmon-recent .dbmon-table { padding: 12px 16px 16px; }
.dbmon-note { margin: 0; padding: 8px; font-size: 13px; color: var(--ms-text-muted); }
.ms-dbmon .ag-paging-panel { color: var(--ms-text-muted); }
.ms-dbmon .ag-paging-panel .ag-picker-field-wrapper {
  background-color: var(--ms-bg);
  border: 1px solid var(--ms-tile-highlight);
  color: var(--ms-text);
}

@media (max-width: 1100px) {
  .dbmon-grid, .dbmon-user-body { grid-template-columns: minmax(0, 1fr); }
  .hist-kpis.dbmon-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .ms-dbmon { padding: 12px 12px 24px; }
  .dbmon-heading h1 { font-size: 21px; }
  .ms-dbmon .news-logo img { height: 36px; }
  .hist-kpis.dbmon-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .dbmon-table { overflow-x: auto; }
  .dbmon-table .ag-theme-balham { min-width: 600px; }
}

/* ===== app_reports: financial reports + earnings call transcripts (/reports/<WKN>) =====
   Header, tiles and toolbars reuse .news-*; buttons .trend-save-btn. */
.ms-reports .news-header { align-items: center; }
.rp-heading h1 { margin: 0; font-size: 26px; font-weight: 600; color: var(--ms-text); white-space: nowrap; }
.rp-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 16px; align-items: start; }
.rp-status:not(:empty) { padding: 10px 20px; font-size: 13px; color: var(--ms-text-muted);
                         border-bottom: 1px solid var(--ms-tile-highlight); }
.rp-status a { color: var(--ms-primary); }
.rp-err { color: var(--ms-danger-light); }
.rp-row { display: flex; align-items: center; gap: 12px; padding: 12px 20px;
          border-bottom: 1px solid var(--ms-border-subtle); }
.rp-row:last-child { border-bottom: 0; }
.rp-row-top { align-items: flex-start; }
.rp-main { flex: 1 1 auto; min-width: 0; }
.rp-title { color: #E6E7EE; font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.rp-meta { color: var(--ms-text-muted); font-size: 12px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.rp-bullets { margin: 6px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.5; color: var(--ms-text); }
.rp-chip { flex: 0 0 auto; min-width: 76px; text-align: center; white-space: nowrap; }
.rp-chip-0 { background-color: var(--ms-primary-subtle); color: var(--ms-primary); }       /* Annual */
.rp-chip-1 { background-color: rgba(118, 195, 171, 0.15); color: var(--ms-success-light); } /* Half-year */
.rp-chip-2, .rp-chip-3 { background-color: rgba(64, 119, 209, 0.18); color: #8fb0ea; }    /* Quarterly / other */
.rp-chip-t { background-color: rgba(var(--ms-border-rgb), 0.6); color: var(--ms-text); }
.rp-acts { display: flex; flex: 0 0 auto; gap: 6px; }
.rp-act { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 8px;
          border: 1px solid var(--ms-tile-highlight); background-color: var(--ms-tile); color: var(--ms-text);
          font-size: 12px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.rp-act:hover { background-color: var(--ms-tile-highlight); color: var(--ms-primary); }
.rp-act:focus-visible { outline: 2px solid var(--ms-primary); outline-offset: 1px; }
.rp-act-icon { width: 32px; justify-content: center; padding: 0; color: var(--ms-text-muted); }
.rp-act-icon:hover { color: var(--ms-danger-light); }
.rp-bad { border-top: 1px solid var(--ms-tile-highlight); }
.rp-bad summary { padding: 10px 20px; font-size: 12px; color: var(--ms-text-muted); cursor: pointer; }
.rp-row-bad .rp-title { color: var(--ms-text-muted); text-decoration: line-through; }
@media (max-width: 1100px) { .rp-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) {
  .ms-reports .rp-row { flex-wrap: wrap; padding: 12px 16px; }
  .ms-reports .rp-acts { width: 100%; justify-content: flex-end; }
  .rp-act span { display: none; }
  .rp-act { width: 36px; justify-content: center; padding: 0; }
}
