:root {
  color-scheme: dark;
  --bg: #2b2b2b;
  --panel: #353535;
  --rail: #303030;
  --border: #4a4a4a;
  --text: #e8e8e8;
  --muted: #a0a0a0;
  --accent: #4a9eff;
  --cell-size: 28px;
  --sticky-col-width: 140px;
  --trail-width: 302px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.app-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.top-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.75rem;
  background: #252525;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 5001;
  min-height: 52px;
}

.top-bar-logo {
  display: flex;
  align-items: center;
  z-index: 2;
}

.top-bar-logo img {
  height: 56px;
  width: auto;
  display: block;
}

.top-bar-title {
  font-weight: 600;
  text-align: center;
  justify-self: center;
  pointer-events: none;
}

.top-bar .top-nav {
  position: absolute;
  left: 88px;
  display: flex;
  gap: 0.35rem;
}

.icon-btn {
  background: transparent;
  color: #00bcd4;
  border: none;
  padding: 0.1rem 0.35rem;
  font-size: 0.7rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-width: 48px;
}

.icon-btn img {
  width: 25px;
  height: 25px;
  display: block;
}

.icon-btn:hover {
  filter: brightness(1.15);
}

.top-bar-title .title-delayed {
  margin-left: 0.55rem;
  font-weight: 500;
  font-size: 0.78rem;
  color: #ffb74d;
  letter-spacing: 0.02em;
}

.nav-btn {
  background: #404040;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

#resetBtn {
  position: relative;
  z-index: 5002;
  pointer-events: auto;
}

.nav-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.nav-btn.settings-cog {
  font-size: 1.1rem;
  padding: 0.25rem 0.55rem;
  line-height: 1;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-self: end;
  z-index: 2;
}

.settings-panel .auth-signout {
  width: 100%;
  margin-top: 0.85rem;
  justify-content: center;
  background: #2a3338;
  color: #cfe8ec;
}

.settings-panel {
  position: absolute;
  top: 44px;
  right: 0.75rem;
  z-index: 40;
  width: 280px;
  padding: 0.75rem 0.9rem 0.9rem;
  background: #37474f;
  border: 1px solid #90a4ae;
  border-radius: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  color: #80deea;
}

.settings-panel.hidden {
  display: none;
}

.settings-panel-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.65rem;
  color: #b2ebf2;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.settings-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.settings-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.settings-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.settings-toggle-track {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.6rem;
  padding: 0.2rem 0.45rem;
  border: 1px solid #80deea;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #80deea;
}

.settings-toggle-track::after {
  content: attr(data-off);
}

.settings-toggle input:checked + .settings-toggle-track::after {
  content: attr(data-on);
}

select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}

.badge {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

button:disabled { opacity: 0.55; cursor: wait; }

.main-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.left-rail {
  width: 148px;
  flex-shrink: 0;
  background: var(--rail);
  border-right: 1px solid var(--border);
  padding: 0.5rem 0.6rem;
  overflow-y: auto;
  font-size: 0.72rem;
}

.rail-group {
  margin-bottom: 0.85rem;
}

.rail-label {
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.25rem;
  letter-spacing: 0.05em;
}

.toggle-row, .radio-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.2rem 0;
  cursor: pointer;
}

.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chart-splitter {
  box-sizing: border-box;
  flex: 0 0 8px;
  flex-shrink: 0;
  min-height: 8px;
  height: 8px;
  margin: 3px 0;
  padding: 0;
  background: #333;
  cursor: ns-resize;
  z-index: 5;
  user-select: none;
  touch-action: none;
  overflow: visible;
  position: relative;
}

.chart-splitter::before {
  content: ". . . .";
  position: absolute;
  left: 0;
  right: 0;
  top: 12%;
  transform: translateY(-58%);
  color: #d3d3d3;
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0.14em;
  text-align: center;
  pointer-events: none;
}

.chart-splitter:hover,
.chart-splitter.dragging {
  background: #3e3e3e;
}

.chart-splitter.hidden {
  display: none;
}

body.chart-resizing {
  cursor: row-resize;
  user-select: none;
}

.grid-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.grid-panel.chart-hidden {
  flex: 1;
}

.grid-split {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.grid-scroll {
  flex: 1;
  min-width: 0;
  overflow: auto;
  position: relative;
  scrollbar-color: #607d8b #2a2a2a;
}

.grid-scroll::-webkit-scrollbar {
  height: 10px;
}

.grid-scroll::-webkit-scrollbar-track {
  background: linear-gradient(180deg, #3d5059 25%, #455a64 75%);
  border-radius: 6px;
}

.grid-scroll::-webkit-scrollbar-thumb {
  background: #607d8b;
  border-radius: 5px;
  border: 1px solid #303f46;
}

.grid-scroll::-webkit-scrollbar-thumb:hover {
  background: #7a96a8;
}

/* Warn when scrolled into past time (not at most-recent columns). */
.grid-scroll.viewing-past {
  scrollbar-color: #c44 #2a2a2a;
}

.grid-scroll.viewing-past::-webkit-scrollbar-thumb {
  background: #c44;
}

.grid-scroll.viewing-past::-webkit-scrollbar-thumb:hover {
  background: #d55;
}

.grid-trail-panel {
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: #323232;
  border-left: 1px solid #1a1a1a;
  scrollbar-width: none;
}

.grid-trail-panel::-webkit-scrollbar {
  display: none;
}

.heatmap-dates {
  width: max-content;
}

.heatmap-trail {
  width: max-content;
}
.heatmap th.heat-date,
.heatmap td.heat-date {
  width: var(--cell-size);
  min-width: var(--cell-size);
  max-width: var(--cell-size);
  padding: 0 !important;
  overflow: hidden;
  font-size: 0.55rem;
  line-height: 1.1;
  white-space: nowrap;
}

.heatmap td.heat-date.heat-cell {
  text-align: center;
  vertical-align: middle;
  white-space: normal;
  font-weight: 700;
  font-size: 0.58rem;
  line-height: 1;
}

.heatmap td.heat-date .heat-num {
  display: block;
  pointer-events: none;
}

.heatmap td.heat-date.is-grey,
.heatmap td.heat-date.is-grey .heat-num {
  color: #999;
}

.heatmap th.heat-date {
  white-space: normal;
  vertical-align: bottom;
  padding: 0 !important;
  font-weight: 600;
  color: #c8d0d4;
  text-align: center;
  line-height: 1;
}

.heatmap th.heat-date .heat-day,
.heatmap th.heat-date .heat-mon,
.heatmap th.heat-date .heat-time {
  display: block;
  line-height: 1.05;
  margin: 0;
  padding: 0;
}

.heatmap th.heat-date .heat-time {
  font-weight: 500;
  color: #8a9aa0;
  font-size: 0.5rem;
}

.heatmap {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.7rem;
}

.heatmap th,
.heatmap td {
  border: 0.5px solid #000;
  padding: 0;
  text-align: center;
  vertical-align: middle;
}

.heatmap th {
  background: #2a2a2a;
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 28px;
  height: auto;
  padding: 1px 4px;
  vertical-align: bottom;
  line-height: 1.1;
  box-sizing: border-box;
}

.heatmap-trail thead th {
  vertical-align: bottom;
  padding-bottom: 4px;
}

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #323232;
  min-width: 140px;
  max-width: 140px;
  text-align: left;
  padding: 0 6px !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heatmap thead .sticky-col { z-index: 4; }

.heatmap-trail th,
.heatmap-trail td {
  background: #323232;
}

.trail-status { min-width: 72px; }
.trail-dot { min-width: 28px; text-align: center; font-size: 0.68rem; vertical-align: middle; }

/* Desktop AlgoScoreCircleStyle: 12px, 16px when AlgoScore > 24.999 */
.algo-score-circle {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #444444;
  border: 1.25px solid #101010;
  vertical-align: middle;
  box-sizing: border-box;
}

.algo-score-circle.large {
  width: 16px;
  height: 16px;
  border-width: 1.5px;
}

.trend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #111;
  border: 1px solid #888;
  vertical-align: middle;
  box-sizing: border-box;
}

.trend-dot.up { background: #6ecfff; }
.trend-dot.down { background: #ff8a8a; }

.trail-value {
  min-width: 88px;
  max-width: 110px;
  font-variant-numeric: tabular-nums;
  padding: 2px 4px !important;
  font-size: 0.68rem;
}
.trail-spark { min-width: 120px; padding: 2px 4px !important; font-size: 0.68rem; }

.trail-progress {
  position: relative;
  display: flex;
  align-items: center;
  height: calc(var(--cell-size) - 8px);
  min-height: 16px;
  background: #455a64;
  overflow: hidden;
}

.trail-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  opacity: 0.85;
  pointer-events: none;
}

.trail-progress-label {
  position: relative;
  z-index: 1;
  padding: 0 4px;
  font-size: 0.68rem;
  font-weight: 600;
  color: #c3c3c3;
  line-height: 1;
  white-space: nowrap;
}

.trail-progress-fallback {
  font-size: 0.72rem;
  color: var(--muted);
}

.heatmap-trail tbody td {
  height: var(--cell-size);
  box-sizing: border-box;
}

.data-row.selected .heatmap-trail td:not(.trail-status) {
  background: #3d4a5c;
}

.data-row:hover .heatmap-trail td:not(.trail-status) {
  background: #3a3a3a;
}

.heat-cell {
  width: var(--cell-size);
  min-width: var(--cell-size);
  height: var(--cell-size);
  cursor: pointer;
}

.heat-cell.selected {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

.data-row {
  cursor: pointer;
}

.data-row.selected td.sticky-col {
  background: #3d4a5c;
}

.data-row:hover td.sticky-col {
  background: #3a3a3a;
}

.sparkline {
  display: flex;
  gap: 1px;
  height: 14px;
  align-items: stretch;
}

.spark-seg {
  position: relative;
  flex: 1;
  min-width: 10px;
  border-radius: 1px;
}

/* Desktop MTF ellipse: 10×10, white stroke, ByteToDot fill */
.spark-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  border: 0.5px solid #fff;
  box-sizing: border-box;
  pointer-events: none;
}

.spark-dot.up { background: rgb(80, 80, 255); }
.spark-dot.down { background: rgb(255, 80, 80); }

.chart-panel {
  flex: 0 0 var(--chart-height, 38%);
  height: auto;
  min-height: 160px;
  max-height: calc(100% - 88px);
  border-top: none;
  background: #2a2a2a;
  display: flex;
  flex-direction: column;
}

.chart-panel.hidden {
  display: none;
}

.mtf-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.mtf-heatmap .sticky-col {
  min-width: 90px;
  max-width: 110px;
}

.mtf-heatmap .mtf-value {
  min-width: 110px;
  max-width: 140px;
  text-align: left;
  padding: 2px 4px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.mtf-heatmap .heat-cell {
  cursor: pointer;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  background: #252525;
  border-bottom: 1px solid var(--border);
  cursor: ns-resize;
}

.chart-close {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

.chart-container-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chart-container {
  flex: 1;
  min-height: 0;
  width: 100%;
}

.chart-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}

.chart-marker {
  position: absolute;
  transform: translate(0, -50%);
}

.chart-marker__dot {
  position: absolute;
  left: 0;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: #f5a623;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.chart-marker__triangle {
  position: absolute;
  left: 0;
  top: 50%;
  width: 0;
  height: 0;
  margin-top: -5px;
  margin-left: -1px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 8px solid #ff6464;
}

.chart-marker__triangle--blue {
  border-right-color: rgb(100, 100, 255);
}

.chart-marker__triangle--red {
  border-right-color: rgb(255, 100, 100);
}

.chart-marker__label {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  padding: 1px 4px;
  font: 10px/1.25 Tahoma, Arial, sans-serif;
  color: #fff;
  white-space: nowrap;
  background: rgb(30, 43, 54);
}

.chart-marker__leader {
  position: absolute;
  top: 50%;
  height: 0;
  border-top: 1px dotted rgba(255, 255, 255, 0.85);
  transform: translateY(-50%);
}

.chart-marker--momentum {
  transform: translate(-50%, -50%);
  z-index: 3;
}

.chart-marker--momentum .chart-marker__label {
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0 3px;
  font: 700 10px/1.2 Tahoma, Arial, sans-serif;
  background: transparent;
  text-shadow: 0 0 3px #000, 0 1px 2px #000;
}

.chart-marker--momentum.chart-marker--above .chart-marker__label {
  transform: translate(-50%, calc(-100% - 4px));
}

.chart-marker--momentum.chart-marker--below .chart-marker__label {
  transform: translate(-50%, 4px);
}

.chart-marker--price .chart-marker__label {
  left: 10px;
}

.chart-marker--reversal .chart-marker__label {
  left: 48px;
}

.chart-marker--reversal .chart-marker__leader {
  left: 8px;
  width: 36px;
}

.portfolio-dialog {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
  max-width: 480px;
  width: 90%;
}

.portfolio-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.dialog-inner {
  padding: 1rem;
}

.dialog-inner h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.hint {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

textarea {
  width: 100%;
  background: #1e1e1e;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem;
  font-family: Consolas, monospace;
  font-size: 0.85rem;
}

.dialog-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.dialog-actions button {
  background: #404040;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}

.dialog-actions button[type="submit"] {
  margin-left: auto;
}

.error-msg {
  color: #ff8a8a;
  padding: 1rem;
}

.heat-cell.heat-error {
  color: #ff8a8a;
  font-size: 0.72rem;
  text-align: left;
  padding: 0 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #3a2a2a;
}

.data-row.row-error td.sticky-col {
  color: #ffb4b4;
}

/* —— Portfolios management page —— */
body.portfolios-page {
  overflow: auto;
}

.nav-btn.active {
  border-color: #2ec4d6;
  color: #2ec4d6;
}

.pf-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0.75rem 1rem 1rem;
  gap: 0.5rem;
}

.pf-section-title {
  color: #2ec4d6;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.02em;
  padding: 0 0.15rem;
}

/* Tab strip + content share one continuous panel (folder-tab look). */
.pf-workspace {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.pf-groups-bar {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  flex-wrap: nowrap;
  padding: 0 0.15rem;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

.pf-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.2rem;
  flex: 1;
  min-width: 0;
  margin-bottom: -1px; /* overlap workspace border so active tab joins panel */
}

.pf-tab {
  position: relative;
  background: #2f2f2f;
  color: #9a9a9a;
  border: 1px solid var(--border);
  border-bottom-color: transparent;
  border-radius: 10px 10px 0 0;
  padding: 0.45rem 0.95rem 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.2;
  margin-bottom: 0;
  transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.pf-tab:hover:not(.active) {
  background: #3a3a3a;
  color: var(--text);
}

.pf-tab.active {
  background: var(--panel);
  border-color: var(--border);
  border-bottom-color: var(--panel);
  color: #2ec4d6;
  font-weight: 600;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
  z-index: 2;
  box-shadow: inset 0 2px 0 #2ec4d6;
}

.pf-tab-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  padding-bottom: 0.35rem;
}

.pf-icon-btn {
  background: #404040;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  flex-shrink: 0;
}

.pf-columns {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.4fr);
  gap: 1rem;
  min-height: 0;
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 8px 8px 8px;
  padding: 0.85rem;
}

@media (max-width: 900px) {
  .pf-columns {
    grid-template-columns: 1fr;
  }
}

.pf-col {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 420px;
  max-height: calc(100vh - 160px);
}

.pf-col-left {
  border-right: 1px solid var(--border);
  padding-right: 0.85rem;
}

@media (max-width: 900px) {
  .pf-col-left {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0.15rem;
    padding-bottom: 0.85rem;
    max-height: none;
  }
}

.pf-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.pf-field input,
.pf-field select {
  background: #1e1e1e;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.45rem 0.5rem;
  font-size: 0.9rem;
}

.pf-search-row {
  display: flex;
  gap: 0.35rem;
}

.pf-search-row input {
  flex: 1;
}

.pf-lookup {
  position: relative;
}

.pf-suggest {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 2.4rem;
  top: 100%;
  margin: 0.15rem 0 0;
  padding: 0;
  list-style: none;
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 4px;
  max-height: 220px;
  overflow: auto;
}

.pf-suggest li {
  padding: 0.4rem 0.55rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  border-bottom: 1px solid #2a2a2a;
}

.pf-suggest li:hover {
  background: #2a3a40;
}

.pf-suggest strong {
  color: #2ec4d6;
  font-size: 0.85rem;
}

.pf-suggest span {
  color: var(--muted);
  font-size: 0.75rem;
}

.pf-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #2a2a2a;
}

.pf-list-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid #3a3a3a;
  cursor: pointer;
}

.pf-list-item:hover {
  background: #333;
}

.pf-list-item.active {
  background: #1a4a55;
  color: #2ec4d6;
}

.pf-list-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.pf-list-name {
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pf-list-sub {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pf-list-ds {
  font-size: 0.68rem;
  color: #8a9aa0;
  letter-spacing: 0.02em;
}

.pf-list-item.active .pf-list-ds {
  color: #b8e8ef;
}

.pf-coverage {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
  text-transform: uppercase;
}

.pf-coverage-verified {
  background: rgba(40, 120, 80, 0.35);
  color: #9fd9b5;
}

.pf-coverage-estimated {
  background: rgba(140, 110, 30, 0.35);
  color: #e6d28a;
}

.pf-coverage-weak {
  background: rgba(150, 70, 30, 0.4);
  color: #f0b090;
}

.pf-coverage-none {
  background: rgba(120, 40, 40, 0.4);
  color: #f0a0a0;
}

.pf-bloomberg-panel {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.pf-bloomberg-summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}

.pf-bloomberg-summary::-webkit-details-marker {
  display: none;
}

.pf-bloomberg-summary::before {
  content: '▸ ';
  color: #2ec4d6;
}

.pf-bloomberg-panel[open] .pf-bloomberg-summary::before {
  content: '▾ ';
}

.pf-bloomberg-summary:hover {
  color: var(--text);
}

.pf-bloomberg-body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.65rem;
}

.pf-bloomberg-title {
  margin: 0;
  font-size: 0.85rem;
}

.pf-bloomberg-hint {
  margin: 0;
}

.pf-bloomberg-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.pf-datasource-badge.bloomberg {
  background: #1f4d3a;
  color: #b6f0cf;
}

.import-drop.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.pf-list-item.active .pf-list-sub {
  color: #8fd5e0;
}

.pf-add-portfolio {
  background: transparent;
  border: 1px dashed var(--border);
  color: #2ec4d6;
  border-radius: 4px;
  padding: 0.55rem;
  cursor: pointer;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.pf-add-portfolio:hover {
  border-color: #2ec4d6;
  background: #2a3538;
}

.pf-right-top {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  align-items: start;
}

.pf-currency {
  display: none;
}

.pf-name-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
}

.pf-bench-field .pf-search-row {
  min-width: 0;
}

.pf-bench-field #portfolioBenchmarkInput:disabled {
  opacity: 0.55;
}

.pf-clear-bench:not(:disabled) {
  color: #f0a0a0;
  border-color: #6a4040;
}

.pf-clear-bench:not(:disabled):hover {
  color: #fff;
  background: #5a3030;
  border-color: #c06060;
}

@media (max-width: 900px) {
  .pf-name-row {
    grid-template-columns: 1fr;
  }
}

.pf-benchmark-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.pf-muted {
  color: var(--muted);
}

.import-dialog {
  max-width: 520px;
}

.import-mode-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.75rem 0;
  font-size: 0.85rem;
}

.import-drop {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  margin-bottom: 0.75rem;
  background: #2a2a2a;
}

.import-drop.dragover {
  border-color: #2ec4d6;
  background: #1a3035;
}

.import-drop p {
  margin: 0.35rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.import-drop input[type="file"] {
  width: 100%;
  font-size: 0.8rem;
}

.import-drop code {
  color: #2ec4d6;
  font-size: 0.78rem;
}

.local-sources-toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0.5rem 0;
}

.go-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.go-btn.ready {
  background: #1a4a55;
  border-color: #2ec4d6;
  color: #2ec4d6;
  font-weight: 600;
}

.go-btn.ready:hover:not(:disabled) {
  background: #215864;
}

.run-portfolio-go {
  min-width: 4.5rem;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.local-sources-list {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
  max-height: 160px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #1e1e1e;
}

.local-source-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  border-bottom: 1px solid #2a2a2a;
}

.local-source-item:last-child {
  border-bottom: none;
}

.local-source-item:hover {
  background: #2a3538;
}

.local-source-item.selected {
  background: #1a4a55;
  outline: 1px solid #2ec4d6;
}

.local-source-kind {
  color: #2ec4d6;
  font-size: 0.75rem;
  font-weight: 600;
}

.local-source-path {
  color: var(--muted);
  font-size: 0.72rem;
  word-break: break-all;
}

/* Desktop-like refresh progress overlay */
.rp-refresh-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 4000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  background: rgba(0, 0, 0, 0.45);
  cursor: wait;
  pointer-events: auto;
}

.rp-refresh-overlay.hidden {
  display: none;
}

body.rp-refresh-busy {
  cursor: wait;
}

body.rp-refresh-busy #resetBtn {
  pointer-events: auto;
  cursor: pointer;
}

.rp-refresh-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  min-width: 200px;
  padding: 1.25rem 1.5rem 1rem;
  background: rgba(40, 40, 40, 0.92);
  border: 1px solid #555;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.rp-refresh-spinner {
  position: relative;
  width: 72px;
  height: 72px;
}

.rp-refresh-spinner span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  margin: -6px;
  border-radius: 50%;
  background: #fff;
  animation: rp-spin-fade 1s linear infinite;
}

.rp-refresh-spinner span:nth-child(1) { transform: rotate(0deg) translate(28px); animation-delay: -0.875s; opacity: 1; }
.rp-refresh-spinner span:nth-child(2) { transform: rotate(45deg) translate(28px); animation-delay: -0.75s; opacity: 0.9; }
.rp-refresh-spinner span:nth-child(3) { transform: rotate(90deg) translate(28px); animation-delay: -0.625s; opacity: 0.8; }
.rp-refresh-spinner span:nth-child(4) { transform: rotate(135deg) translate(28px); animation-delay: -0.5s; opacity: 0.7; }
.rp-refresh-spinner span:nth-child(5) { transform: rotate(180deg) translate(28px); animation-delay: -0.375s; opacity: 0.6; }
.rp-refresh-spinner span:nth-child(6) { transform: rotate(225deg) translate(28px); animation-delay: -0.25s; opacity: 0.5; }
.rp-refresh-spinner span:nth-child(7) { transform: rotate(270deg) translate(28px); animation-delay: -0.125s; opacity: 0.4; }
.rp-refresh-spinner span:nth-child(8) { transform: rotate(315deg) translate(28px); animation-delay: 0s; opacity: 0.3; }

@keyframes rp-spin-fade {
  0%, 39%, 100% { opacity: 0.15; }
  40% { opacity: 1; }
}

.rp-refresh-caption {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  min-height: 1.25rem;
}

.rp-refresh-sub {
  color: #a8a8a8;
  font-size: 0.78rem;
  text-align: center;
}
