* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Consolas', 'Courier New', monospace;
  background: #0a0a0a;
  color: #e0e0e0;
  min-height: 100vh;
  padding: 12px;
  font-size: 14px;
}

.container { max-width: 1400px; margin: 0 auto; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: #1a1a1a;
  border: 1px solid #ffd700;
  border-radius: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

h1 { color: #ffd700; font-size: 1.4rem; }

.status-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.85rem;
  color: #aaa;
}

.badge {
  background: #2a4a2a;
  color: #66ff66;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
}


.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -4px 0 16px;
  padding: 10px 12px;
  background: #111;
  border: 1px solid #333;
  border-radius: 8px;
  color: #aaa;
  flex-wrap: wrap;
}

.toolbar label {
  color: #ffd700;
  font-weight: bold;
}

.sort-select {
  min-width: 240px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #555;
  background: #0f0f0f;
  color: #fff;
  font-family: inherit;
}

.sort-select:focus {
  outline: none;
  border-color: #ffd700;
}

.sort-note {
  font-size: 0.8rem;
  color: #888;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.account-card {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.account-card:hover {
  transform: translateY(-2px);
  border-color: #ffd700;
}

.account-card.offline { opacity: 0.5; border-color: #555; }
.account-card.emergency { border-color: #ff3333; box-shadow: 0 0 12px rgba(255, 51, 51, 0.3); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #444;
}

.account-id {
  font-weight: bold;
  color: #ffd700;
  font-size: 1.05rem;
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  background: #66ff66;
  box-shadow: 0 0 6px #66ff66;
}
.online-dot.offline { background: #666; box-shadow: none; }

.broker { color: #aaa; font-size: 0.8rem; }

.row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.9rem;
}

.row .label { color: #aaa; }
.row .value { color: #fff; font-weight: 500; }
.value.green { color: #66ff66; }
.value.red { color: #ff6666; }

/* Profit/Loss colors */
.green, .money-primary.green, .money-muted.green { color: #66ff66 !important; }
.red, .money-primary.red, .money-muted.red { color: #ff6666 !important; }

/* Chart range selector */
.dashboard-title-row { align-items: center; }
.range-selector { margin-left: auto; }
.value.gold { color: #ffd700; }

.section-divider {
  border-top: 1px dashed #333;
  margin: 8px 0;
}

.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: bold;
}
.status-pill.trading { background: #1a3a1a; color: #66ff66; }
.status-pill.stopped { background: #3a1a1a; color: #ff6666; }
.status-pill.out-of-hours { background: #3a2a0a; color: #ffaa44; }
.status-pill.emergency { background: #5a0000; color: #ff3333; }

.loading {
  grid-column: 1 / -1;
  text-align: center;
  color: #888;
  padding: 40px;
}

/* Modal Detail View */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  overflow-y: auto;
}

.modal.hidden { display: none; }

.modal-content {
  background: #1a1a1a;
  border: 1px solid #ffd700;
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 700px;
  position: relative;
  margin: 20px 0;
}

.close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #333;
  color: #fff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
}

.detail-section {
  margin: 16px 0;
  padding: 12px;
  background: #0f0f0f;
  border-radius: 6px;
}

.detail-section h3 {
  color: #ffd700;
  margin-bottom: 8px;
  font-size: 1rem;
  border-bottom: 1px dashed #444;
  padding-bottom: 4px;
}

.btn-group {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-weight: bold;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-stop { background: #8b0000; color: #fff; }
.btn-stop:hover:not(:disabled) { background: #a00000; }

.btn-resume { background: #1a5a1a; color: #fff; }
.btn-resume:hover:not(:disabled) { background: #1f7a1f; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: #fff;
  padding: 12px 24px;
  border-radius: 6px;
  border: 1px solid #ffd700;
  z-index: 200;
  animation: slideUp 0.3s;
}

@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.85rem;
}

.history-table th,
.history-table td {
  padding: 6px 8px;
  text-align: right;
  border-bottom: 1px solid #2a2a2a;
}
.history-table th {
  color: #ffd700;
  border-bottom: 1px solid #555;
}
.history-table td:first-child,
.history-table th:first-child {
  text-align: left;
}


.history-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.history-table .history-date {
  white-space: nowrap;
}

@media (max-width: 600px) {
  .history-table-wrap {
    overflow-x: hidden;
    padding-bottom: 0;
  }

  .history-table {
    display: table;
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    font-size: 0.68rem;
  }

  .history-table thead {
    display: table-header-group;
  }

  .history-table tbody {
    display: table-row-group;
  }

  .history-table tr {
    display: table-row;
  }

  .history-table th,
  .history-table td {
    display: table-cell;
    width: auto;
    padding: 5px 2px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
  }

  .history-table th:nth-child(1),
  .history-table td:nth-child(1) { width: 16%; }
  .history-table th:nth-child(2),
  .history-table td:nth-child(2) { width: 20%; }
  .history-table th:nth-child(3),
  .history-table td:nth-child(3) { width: 13%; }
  .history-table th:nth-child(4),
  .history-table td:nth-child(4) { width: 17%; }
  .history-table th:nth-child(5),
  .history-table td:nth-child(5) { width: 18%; }
  .history-table th:nth-child(6),
  .history-table td:nth-child(6) { width: 16%; }

  .history-table th:first-child,
  .history-table td:first-child {
    text-align: left;
  }

  .history-table td::before {
    content: none;
  }
}

@media (max-width: 380px) {
  .history-table {
    width: 100%;
    min-width: 0;
    font-size: 0.62rem;
  }

  .history-table th,
  .history-table td {
    padding: 4px 1px;
  }
}


.legend-bar {
  display: flex;
  gap: 14px;
  align-items: center;
  margin: -4px 0 16px;
  padding: 10px 12px;
  background: #111;
  border: 1px solid #333;
  border-radius: 8px;
  color: #cfcfcf;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  vertical-align: -1px;
}
.legend-green { background: #22c55e; box-shadow: 0 0 8px rgba(34, 197, 94, 0.75); }
.legend-yellow { background: #eab308; box-shadow: 0 0 8px rgba(234, 179, 8, 0.75); }
.legend-red { background: #ef4444; box-shadow: 0 0 8px rgba(239, 68, 68, 0.75); }

.account-card.tone-positive {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(26, 26, 26, 0.96) 58%);
  border-color: rgba(34, 197, 94, 0.55);
}
.account-card.tone-warning {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.16), rgba(26, 26, 26, 0.96) 58%);
  border-color: rgba(234, 179, 8, 0.55);
}
.account-card.tone-danger {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.17), rgba(26, 26, 26, 0.96) 58%);
  border-color: rgba(239, 68, 68, 0.60);
}
.account-card.tone-positive:hover { border-color: #22c55e; }
.account-card.tone-warning:hover { border-color: #eab308; }
.account-card.tone-danger:hover { border-color: #ef4444; }

.config-view { margin-top: 4px; }
.config-card {
  background: #151515;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 18px;
}
.config-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: 1px dashed #444;
  margin-bottom: 16px;
}
.config-header h2 { color: #ffd700; font-size: 1.25rem; }
.config-header p { color: #aaa; margin-top: 4px; line-height: 1.45; }
.config-section {
  background: #0f0f0f;
  border: 1px solid #292929;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
}
.config-section h3 {
  color: #ffd700;
  margin-bottom: 12px;
  font-size: 1rem;
}
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.config-field span {
  display: block;
  color: #e0e0e0;
  margin-bottom: 6px;
}
.config-field input,
.config-field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #555;
  background: #0a0a0a;
  color: #fff;
  font-family: inherit;
}
.config-field input:focus,
.config-field select:focus {
  outline: none;
  border-color: #ffd700;
}
.config-field small {
  display: block;
  color: #888;
  margin-top: 6px;
  line-height: 1.4;
}
.status-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.status-preview {
  border-radius: 10px;
  padding: 14px;
  border: 1px solid #333;
}
.status-preview strong { display: block; margin-bottom: 5px; }
.status-preview span { color: #cfcfcf; font-size: 0.85rem; line-height: 1.45; }
.preview-green { background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.45); color: #66ff66; }
.preview-yellow { background: rgba(234, 179, 8, 0.12); border-color: rgba(234, 179, 8, 0.45); color: #ffd700; }
.preview-red { background: rgba(239, 68, 68, 0.14); border-color: rgba(239, 68, 68, 0.45); color: #ff6666; }
.config-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.config-actions .login-btn { margin-top: 0; max-width: 240px; }
.btn-secondary {
  padding: 13px 16px;
  border-radius: 6px;
  border: 1px solid #666;
  background: #222;
  color: #fff;
  font-family: inherit;
  cursor: pointer;
}
.btn-secondary:hover { border-color: #ffd700; }

@media (max-width: 600px) {
  body { padding: 8px; font-size: 13px; }
  h1 { font-size: 1.15rem; }
  .toolbar, .config-header, .config-actions { align-items: stretch; flex-direction: column; }
  .sort-select { width: 100%; min-width: 0; }
  .config-actions .login-btn { max-width: none; }
  .account-grid { grid-template-columns: 1fr; }
  .modal-content { padding: 16px; }
  .btn { padding: 16px 12px; }
}

.hidden { display: none !important; }

.login-screen {
  min-height: calc(100vh - 24px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #1a1a1a;
  border: 1px solid #ffd700;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.08);
}

.login-card h1 {
  text-align: center;
  margin-bottom: 8px;
}

.login-note {
  color: #aaa;
  text-align: center;
  line-height: 1.45;
  margin-bottom: 20px;
}

.login-card label {
  display: block;
  color: #ffd700;
  margin: 12px 0 6px;
  font-size: 0.9rem;
}

.login-card input {
  width: 100%;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #444;
  background: #0f0f0f;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
}

.login-card input:focus {
  outline: none;
  border-color: #ffd700;
}

.login-btn {
  width: 100%;
  margin-top: 18px;
  padding: 13px;
  border: none;
  border-radius: 6px;
  background: #ffd700;
  color: #111;
  font-weight: bold;
  font-family: inherit;
  cursor: pointer;
}

.login-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.login-error {
  min-height: 20px;
  color: #ff6666;
  text-align: center;
  margin-top: 12px;
  font-size: 0.9rem;
}

.login-info {
  color: #888;
  font-size: 0.8rem;
  margin-top: 4px;
}

.logout-btn {
  background: #333;
  color: #fff;
  border: 1px solid #666;
  border-radius: 6px;
  padding: 6px 10px;
  font-family: inherit;
  cursor: pointer;
}

.logout-btn:hover {
  border-color: #ffd700;
}

/* =====================
   Multi-account dashboard chart + portfolio table
   Settings-theme dashboard style
   ===================== */
.floating-dashboard,
.portfolio-panel {
  background: #151515;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 18px 45px rgba(0,0,0,0.28), inset 0 0 0 1px rgba(255,255,255,0.015);
}

.floating-dashboard:hover,
.portfolio-panel:hover {
  border-color: #444;
}

.dashboard-title-row,
.portfolio-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
}

.dashboard-title-row h2,
.portfolio-head h2 {
  color: #ffd700;
  font-size: 1.12rem;
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-title-row h2::before { content: '⚙'; font-size: 0.95rem; }
.portfolio-head h2::before { content: '💼'; font-size: 0.95rem; }

.dashboard-title-row h2 span,
.portfolio-head p {
  color: #aaa;
}

.dashboard-title-row p,
.portfolio-head p {
  margin-top: 3px;
  color: #aaa;
  font-size: 0.82rem;
}

.range-selector button,
.status-filter {
  border: 0;
  border-radius: 7px;
  color: #fff;
  font-family: inherit;
  font-weight: 700;
}

.range-selector {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 9px;
  border: 1px solid #333;
  background: #111;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}

.range-selector button {
  min-width: 44px;
  padding: 8px 10px;
  background: transparent;
  color: #e0e0e0;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  border: 1px solid transparent;
}

.range-selector button:hover {
  background: #222;
  border-color: #555;
}

.range-selector button.active {
  color: #111;
  background: #ffd700;
  border-color: #ffd700;
  box-shadow: none;
}

.status-filter {
  padding: 11px 18px;
  background: #333;
  border: 1px solid #666;
  cursor: default;
}

.chart-wrap {
  width: 100%;
  height: 330px;
  position: relative;
  background: #0f0f0f;
  border: 1px solid #292929;
  border-radius: 10px;
  overflow: hidden;
}

#floatingChart {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 22px;
  flex-wrap: wrap;
  padding-top: 10px;
  color: #cfcfcf;
  font-size: 0.88rem;
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.chart-legend-line {
  width: 24px;
  height: 4px;
  border-radius: 999px;
  display: inline-block;
  box-shadow: none;
}

.portfolio-table-wrap {
  overflow-x: auto;
  border: 1px solid #292929;
  border-radius: 10px;
  background: #0f0f0f;
}

.portfolio-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.portfolio-table th,
.portfolio-table td {
  padding: 15px 18px;
  border-bottom: 1px solid #242424;
  text-align: right;
  vertical-align: middle;
}

.portfolio-table th:first-child,
.portfolio-table td:first-child {
  text-align: left;
}

.portfolio-table th {
  color: #cfcfcf;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.015);
}

.portfolio-table tbody tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

.portfolio-table tbody tr:hover {
  background: rgba(255, 215, 0, 0.055);
}

.portfolio-table tbody tr:last-child td {
  border-bottom: 0;
}

.account-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-cell.no-avatar { gap: 0; }

.account-main {
  color: #ffd700;
  font-weight: 800;
  font-size: 1rem;
}

.account-sub {
  color: #aaa;
  font-size: 0.78rem;
  margin-top: 2px;
}

.mini-bar {
  width: 190px;
  height: 7px;
  background: #2a2a2a;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}

.mini-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  box-shadow: none;
}

.money-primary {
  color: #f4f4f4;
  font-weight: 800;
  font-size: 1rem;
}

.money-muted {
  color: #aaa;
  font-size: 0.78rem;
  margin-top: 3px;
}

.actions-cell {
  color: #aaa;
  letter-spacing: 0.5em;
  white-space: nowrap;
}

.table-footer {
  padding: 13px 18px;
  color: #aaa;
  border-top: 1px solid #242424;
}

@media (max-width: 800px) {
  .floating-dashboard, .portfolio-panel { padding: 14px; }
  .dashboard-title-row, .portfolio-head { flex-direction: column; }
  .chart-wrap { height: 280px; }
}

.config-note {
  color: #aeb3d8;
  line-height: 1.55;
  margin: -2px 0 12px;
}
.config-note strong { color: #f4f4ff; }
.bar-rule-table {
  border: 1px solid rgba(130, 150, 255, 0.14);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(5, 8, 12, 0.38);
}
.bar-rule-head,
.bar-rule-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 110px minmax(180px, 1.4fr);
  gap: 12px;
  align-items: center;
  padding: 11px 13px;
  border-bottom: 1px solid rgba(130, 150, 255, 0.10);
}
.bar-rule-head {
  color: #c8c8db;
  font-size: 0.76rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.02);
}
.bar-rule-row:last-child { border-bottom: 0; }
.bar-rule-row input[type="color"] {
  width: 64px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
}
.preview-example { grid-column: 1 / -1; }
.sample-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(105, 116, 150, 0.22);
  overflow: hidden;
  margin-top: 10px;
}
.sample-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
}
.bar-pct {
  color: #cfd2ff;
  margin-left: 8px;
  font-size: 0.72rem;
}

@media (max-width: 700px) {
  .bar-rule-head, .bar-rule-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

/* Dashboard table revision: remove Equity and Floating columns, move online next to account */
.compact-portfolio-table {
  min-width: 760px;
}

.account-main-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.account-online {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: none;
}

.account-online.trading {
  color: #66ff66;
}

.account-online.stopped {
  color: #ff6666;
}

.account-online.out-of-hours {
  color: #ffaa44;
}

.account-online.emergency {
  color: #ff3333;
}

.account-online.unknown {
  color: #888;
}

.account-online.online-green {
  color: #66ff66;
}

.account-online.offline-gray {
  color: #888;
}


/* Fix: account utilization percent placed to the right of the bar */
.account-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  width: 260px;
  max-width: 100%;
}
.account-bar-row .mini-bar {
  margin-top: 0;
  flex: 1 1 auto;
  width: auto;
  min-width: 120px;
}
.account-bar-row .bar-pct {
  margin-left: 0;
  min-width: 58px;
  text-align: right;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

/* Responsive dashboard + mobile friendly chart tooltip */
.floating-dashboard,
.portfolio-panel {
  width: 100%;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 142px;
  padding: 9px 11px;
  border: 1px solid #ffd700;
  border-radius: 9px;
  background: rgba(8, 8, 8, 0.94);
  color: #f5f5f5;
  box-shadow: 0 8px 20px rgba(0,0,0,0.42);
  pointer-events: none;
  font-size: 0.78rem;
  line-height: 1.35;
  backdrop-filter: blur(4px);
}

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

.chart-touch-marker {
  position: absolute;
  z-index: 4;
  width: 16px;
  height: 16px;
  border: 2px solid #6ee84f;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  background: rgba(8, 8, 8, 0.72);
  animation: chartTouchPulse 1.25s ease-out infinite;
}

.chart-touch-marker span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  background: #6ee84f;
}

.chart-touch-marker.hidden { display: none; }

@keyframes chartTouchPulse {
  0% { transform: translate(-50%, -50%) scale(0.92); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1.20); opacity: 0.86; }
  100% { transform: translate(-50%, -50%) scale(0.92); opacity: 1; }
}

.tip-id {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #fff;
  font-weight: 800;
  margin-bottom: 3px;
}

.tip-color {
  width: 18px;
  height: 4px;
  border-radius: 999px;
  display: inline-block;
}

.tip-value {
  font-size: 0.95rem;
  font-weight: 900;
  margin-bottom: 2px;
}

.tip-time { color: #cfcfcf; }

@media (min-width: 1200px) {
  .container { max-width: 1500px; }
  .chart-wrap { height: clamp(330px, 32vh, 430px); }
}

@media (max-width: 900px) {
  :root { --dashboard-layout-width: 100%; /* mobile */ }
  body { padding: 8px; font-size: 13px; }
  .container { max-width: 100%; }
  header {
    padding: 12px;
    align-items: flex-start;
  }
  h1 { font-size: 1.12rem; }
  .status-bar {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }
  .dashboard-title-row,
  .portfolio-head {
    align-items: stretch;
    gap: 10px;
  }
  .range-selector {
    width: 100%;
    margin-left: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
  }
  .range-selector button {
    width: 100%;
    padding: 9px 8px;
  }
  .chart-wrap { height: clamp(260px, 48vh, 350px); }
  .chart-legend {
    justify-content: flex-start;
    gap: 10px 14px;
    font-size: 0.78rem;
    max-height: 74px;
    overflow-y: auto;
  }
  .chart-legend-line {
    width: 18px;
    height: 3px;
  }
}

@media (max-width: 520px) {
  body { padding: 6px; }
  .floating-dashboard,
  .portfolio-panel { padding: 10px; }
  .chart-wrap {
    height: 300px;
    border-radius: 8px;
  }
  .chart-tooltip {
    min-width: 126px;
    font-size: 0.72rem;
    padding: 8px 9px;
  }
  .tip-value { font-size: 0.86rem; }
  .portfolio-table th,
  .portfolio-table td { padding: 11px 12px; }
  .compact-portfolio-table { min-width: 690px; }
}


/* Icon-only header buttons */
.logout-btn.icon-btn {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.18rem;
  line-height: 1;
  border-radius: 10px;
}

.logout-btn.icon-btn:hover {
  color: #ffd700;
  background: #3a3a3a;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.16);
}

@media (max-width: 520px) {
  .logout-btn.icon-btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
    font-size: 1.08rem;
  }
}

/* Portfolio Tracking compact layout: closer columns, easier to read on desktop + mobile */
.portfolio-panel {
  padding: 16px 18px;
}

.portfolio-head {
  align-items: center;
  margin-bottom: 10px;
}

.portfolio-head > div {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.portfolio-head h2 {
  margin: 0;
  white-space: nowrap;
}

.portfolio-head p {
  margin: 0;
  text-align: right;
  white-space: nowrap;
  font-size: 0.74rem;
  letter-spacing: 0.05em;
}

.portfolio-table-wrap {
  overflow-x: visible;
}

.portfolio-table,
.compact-portfolio-table {
  min-width: 0;
  width: 100%;
  table-layout: fixed;
}

.portfolio-table th,
.portfolio-table td {
  padding: 13px 14px;
}

.portfolio-table th:nth-child(1),
.portfolio-table td:nth-child(1) { width: 36%; }
.portfolio-table th:nth-child(2),
.portfolio-table td:nth-child(2) { width: 24%; }
.portfolio-table th:nth-child(3),
.portfolio-table td:nth-child(3) { width: 18%; }
.portfolio-table th:nth-child(4),
.portfolio-table td:nth-child(4) { width: 22%; }

.account-cell.no-avatar > div {
  width: 100%;
  min-width: 0;
}

.account-main-row {
  gap: 8px;
  line-height: 1.2;
}

.account-bar-row {
  width: min(220px, 100%);
  gap: 7px;
}

.account-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.money-primary {
  line-height: 1.15;
}

.money-muted {
  line-height: 1.2;
}

@media (max-width: 700px) {
  .portfolio-panel {
    padding: 12px;
  }

  .portfolio-head > div {
    align-items: flex-end;
    gap: 8px;
  }

  .portfolio-head h2 {
    font-size: 1rem;
  }

  .portfolio-head p {
    font-size: 0.56rem;
    letter-spacing: 0.03em;
  }

  .portfolio-table th,
  .portfolio-table td {
    padding: 10px 8px;
  }

  .portfolio-table th {
    font-size: 0.58rem;
    letter-spacing: 0.04em;
  }

  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) { width: 34%; }
  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) { width: 25%; }
  .portfolio-table th:nth-child(3),
  .portfolio-table td:nth-child(3) { width: 18%; }
  .portfolio-table th:nth-child(4),
  .portfolio-table td:nth-child(4) { width: 23%; }

  .account-main {
    font-size: 0.86rem;
  }

  .account-online {
    font-size: 0.55rem;
  }

  .account-sub {
    font-size: 0.58rem;
  }

  .account-bar-row {
    width: 100%;
    gap: 5px;
    margin-top: 5px;
  }

  .account-bar-row .mini-bar {
    min-width: 42px;
    height: 5px;
  }

  .account-bar-row .bar-pct {
    min-width: 35px;
    font-size: 0.52rem;
  }

  .money-primary {
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .money-muted {
    font-size: 0.56rem;
    white-space: nowrap;
  }

  .table-footer {
    padding: 9px 8px;
    font-size: 0.58rem;
  }
}

@media (max-width: 420px) {
  .portfolio-panel {
    padding: 10px;
  }

  .portfolio-table th,
  .portfolio-table td {
    padding: 9px 5px;
  }

  .portfolio-head h2 {
    font-size: 0.92rem;
  }

  .portfolio-head p {
    font-size: 0.5rem;
  }

  .account-main {
    font-size: 0.78rem;
  }

  .account-online {
    display: block;
    margin-top: 2px;
  }

  .account-main-row {
    display: block;
  }

  .account-sub {
    display: none;
  }

  .money-primary {
    font-size: 0.72rem;
  }

  .money-muted {
    font-size: 0.51rem;
  }
}

/* Mobile Portfolio readability: enlarge Balance and Lot numbers only. */
@media (max-width: 700px) {
  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) { width: 30%; }
  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) { width: 25%; }
  .portfolio-table th:nth-child(3),
  .portfolio-table td:nth-child(3) { width: 16%; }
  .portfolio-table th:nth-child(4),
  .portfolio-table td:nth-child(4) { width: 13%; }
  .portfolio-table th:nth-child(5),
  .portfolio-table td:nth-child(5) { width: 16%; }

  .portfolio-table td:nth-child(2) .money-primary,
  .portfolio-table td:nth-child(4) .money-primary {
    font-size: 1.02rem;
    font-weight: 900;
    letter-spacing: -0.02em;
  }

  .portfolio-table td:nth-child(2) .money-muted {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: -0.01em;
  }
}

@media (max-width: 420px) {
  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) { width: 28%; }
  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) { width: 27%; }
  .portfolio-table th:nth-child(3),
  .portfolio-table td:nth-child(3) { width: 15%; }
  .portfolio-table th:nth-child(4),
  .portfolio-table td:nth-child(4) { width: 14%; }
  .portfolio-table th:nth-child(5),
  .portfolio-table td:nth-child(5) { width: 16%; }

  .portfolio-table td:nth-child(2) .money-primary,
  .portfolio-table td:nth-child(4) .money-primary {
    font-size: 0.96rem;
  }

  .portfolio-table td:nth-child(2) .money-muted {
    font-size: 0.68rem;
  }
}


/* Clickable sort headers */
.sort-header {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.sort-header:hover,
.sort-header.active {
  color: #ffd700;
}
.sort-header span {
  font-size: 0.7rem;
  opacity: 0.9;
}

/* Portfolio Tracking desktop spacing tweak: keep the same table data, but pull columns closer together on wide PC screens. */
@media (min-width: 901px) {
  .portfolio-head,
  .portfolio-table-wrap {
    max-width: 1080px;
    margin-left: auto;
    margin-right: auto;
  }

  .portfolio-table,
  .compact-portfolio-table {
    width: 100%;
    table-layout: fixed;
  }

  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) { width: 40%; }
  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) { width: 22%; }
  .portfolio-table th:nth-child(3),
  .portfolio-table td:nth-child(3) { width: 18%; }
  .portfolio-table th:nth-child(4),
  .portfolio-table td:nth-child(4) { width: 20%; }
}
/* Equal center layout: make chart and Portfolio Tracking use the same inner width */
:root {
  --dashboard-content-max: 1400px;
  --dashboard-layout-width: 100%;
}

.container {
  width: min(var(--dashboard-layout-width), 100%);
  max-width: var(--dashboard-content-max);
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 1200px) {
  .container {
    max-width: var(--dashboard-content-max);
  }
}

@media (min-width: 901px) {
  .floating-dashboard,
  .portfolio-panel {
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
  }

  .portfolio-head,
  .portfolio-table-wrap {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }
}


/* Layout size slider setting */
.layout-config-section {
  margin-top: 18px;
}

.layout-size-control {
  display: grid;
  grid-template-columns: auto 1fr auto 72px;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 215, 0, 0.18);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
}

.layout-size-control input[type=range] {
  width: 100%;
  accent-color: #ffd700;
}

.layout-size-control strong {
  color: #ffd700;
  text-align: right;
  font-size: 0.95rem;
}

.layout-step-btn {
  min-width: 42px;
  height: 38px;
  padding: 0 10px;
  font-size: 1.25rem;
  line-height: 1;
}

@media (max-width: 600px) {
  .layout-size-control {
    grid-template-columns: auto 1fr auto;
  }

  .layout-size-control strong {
    grid-column: 1 / -1;
    text-align: center;
  }
}


/* Active / Inactive account view */
.account-view-tabs {
  display: flex;
  gap: 10px;
  margin: 0;
  flex-wrap: wrap;
}

.view-tab {
  border: 1px solid #4a4a00;
  background: #111;
  color: #aaa;
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
}

.view-tab.active {
  border-color: #ffd700;
  color: #ffd700;
  background: rgba(255, 215, 0, 0.08);
}

.view-tab[data-account-view="inactive"].active {
  border-color: #888;
  color: #bbb;
  background: rgba(160, 160, 160, 0.08);
}

.tab-count {
  display: inline-block;
  min-width: 22px;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #222;
  color: inherit;
}

.neutral,
.inactive-mode,
.inactive-mode .green,
.inactive-mode .red,
.inactive-mode .gold,
.inactive-mode .money-primary,
.inactive-mode .money-muted,
.inactive-mode .account-main,
.inactive-mode .bar-pct,
.inactive-mode .value,
.inactive-mode .label,
.inactive-mode .history-date {
  color: #888 !important;
}

.inactive-mode .portfolio-table,
.portfolio-table.inactive-mode,
.inactive-mode .detail-section,
.inactive-row {
  border-color: #555 !important;
}

.inactive-row,
.inactive-mode tr {
  filter: grayscale(1);
  opacity: 0.78;
}

.inactive-mode .mini-bar span {
  background: #777 !important;
}

.account-online.inactive,
.status-pill.inactive {
  color: #aaa !important;
  border-color: #666 !important;
  background: #2a2a2a !important;
}

.inactive-mode .btn,
.inactive-mode .btn-stop,
.inactive-mode .btn-resume {
  filter: grayscale(1);
}

/* Header Active / Inactive tabs replace old green online badge */
.status-bar .account-view-tabs,
.account-view-tabs.header-tabs {
  margin: 0;
  gap: 8px;
  flex-wrap: nowrap;
}

.account-view-tabs.header-tabs .view-tab {
  padding: 6px 12px;
  font-size: 0.82rem;
  line-height: 1;
}

.account-view-tabs.header-tabs .tab-count {
  min-width: 20px;
  padding: 1px 6px;
}

@media (max-width: 900px) {
  .status-bar .account-view-tabs,
  .account-view-tabs.header-tabs {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    margin-top: 2px;
  }
}

/* Mobile portfolio update: show Floating as main Balance value and allow horizontal scroll */
.portfolio-table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.portfolio-table,
.compact-portfolio-table {
  min-width: 760px;
}

@media (max-width: 700px) {
  .portfolio-table-wrap {
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .portfolio-table,
  .compact-portfolio-table {
    min-width: 690px;
    table-layout: fixed;
  }

  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) { width: 42%; }
  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) { width: 24%; }
  .portfolio-table th:nth-child(3),
  .portfolio-table td:nth-child(3) { width: 17%; }
  .portfolio-table th:nth-child(4),
  .portfolio-table td:nth-child(4) { width: 17%; }
}

@media (max-width: 420px) {
  .portfolio-table,
  .compact-portfolio-table {
    min-width: 660px;
  }

  .portfolio-table th,
  .portfolio-table td {
    padding: 10px 8px;
  }
}

/* Mobile Portfolio: keep ACCOUNT + BALANCE visible first, with Profit/Max DD reachable by horizontal scroll */
@media (max-width: 700px) {
  .portfolio-table-wrap {
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .portfolio-table,
  .compact-portfolio-table {
    min-width: 560px !important;
    table-layout: fixed !important;
  }

  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) { width: 42% !important; }
  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) { width: 28% !important; }
  .portfolio-table th:nth-child(3),
  .portfolio-table td:nth-child(3) { width: 15% !important; }
  .portfolio-table th:nth-child(4),
  .portfolio-table td:nth-child(4) { width: 15% !important; }

  .account-bar-row {
    width: 100% !important;
    max-width: 180px !important;
  }

  .account-bar-row .mini-bar {
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }

  .money-primary,
  .money-muted {
    white-space: nowrap;
  }
}

@media (max-width: 420px) {
  .portfolio-table,
  .compact-portfolio-table {
    min-width: 520px !important;
  }

  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) { width: 40% !important; }
  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) { width: 30% !important; }
  .portfolio-table th:nth-child(3),
  .portfolio-table td:nth-child(3) { width: 15% !important; }
  .portfolio-table th:nth-child(4),
  .portfolio-table td:nth-child(4) { width: 15% !important; }

  .account-bar-row {
    max-width: 155px !important;
  }

  .account-bar-row .bar-pct {
    min-width: 32px !important;
    font-size: 0.5rem !important;
  }

  .money-primary {
    font-size: 0.68rem !important;
  }

  .money-muted {
    font-size: 0.49rem !important;
  }
}


/* Mobile readability update v5: widen Portfolio Tracking area and make Balance easier to read */
@media (max-width: 700px) {
  body {
    padding: 3px !important;
  }

  .container {
    width: 100% !important;
    max-width: none !important;
  }

  .floating-dashboard,
  .portfolio-panel {
    width: 100% !important;
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .portfolio-panel {
    padding: 12px 8px 14px !important;
    border-radius: 20px !important;
  }

  .portfolio-head {
    padding-inline: 2px !important;
  }

  .portfolio-head h2 {
    font-size: 1.08rem !important;
  }

  .portfolio-table-wrap {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .portfolio-table,
  .compact-portfolio-table {
    min-width: 470px !important;
    width: 470px !important;
    table-layout: fixed !important;
  }

  .portfolio-table th,
  .portfolio-table td {
    padding: 12px 8px !important;
  }

  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) { width: 45% !important; }
  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) { width: 35% !important; }
  .portfolio-table th:nth-child(3),
  .portfolio-table td:nth-child(3) { width: 10% !important; }
  .portfolio-table th:nth-child(4),
  .portfolio-table td:nth-child(4) { width: 10% !important; }

  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) {
    text-align: left !important;
  }

  .account-main {
    font-size: 0.94rem !important;
    line-height: 1.15 !important;
  }

  .account-online {
    font-size: 0.62rem !important;
  }

  .account-sub {
    display: none !important;
  }

  .account-main-row {
    gap: 4px !important;
  }

  .account-bar-row {
    width: 100% !important;
    max-width: 128px !important;
    gap: 6px !important;
  }

  .account-bar-row .mini-bar {
    min-width: 0 !important;
    height: 8px !important;
    flex: 1 1 auto !important;
  }

  .account-bar-row .bar-pct {
    min-width: 42px !important;
    font-size: 0.62rem !important;
  }

  .money-primary,
  .money-muted {
    display: block !important;
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: nowrap !important;
  }

  .money-primary {
    font-size: 0.98rem !important;
    line-height: 1.1 !important;
  }

  .money-muted {
    font-size: 0.72rem !important;
    line-height: 1.15 !important;
  }

  .table-footer {
    padding: 10px 8px !important;
    font-size: 0.74rem !important;
  }
}

@media (max-width: 420px) {
  body {
    padding: 2px !important;
  }

  .portfolio-panel {
    padding: 11px 6px 13px !important;
  }

  .portfolio-head h2 {
    font-size: 1rem !important;
  }

  .portfolio-table,
  .compact-portfolio-table {
    min-width: 450px !important;
    width: 450px !important;
  }

  .portfolio-table th,
  .portfolio-table td {
    padding: 11px 6px !important;
  }

  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) { width: 46% !important; }
  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) { width: 34% !important; }
  .portfolio-table th:nth-child(3),
  .portfolio-table td:nth-child(3) { width: 10% !important; }
  .portfolio-table th:nth-child(4),
  .portfolio-table td:nth-child(4) { width: 10% !important; }

  .account-main {
    font-size: 0.9rem !important;
  }

  .account-bar-row {
    max-width: 118px !important;
  }

  .account-bar-row .bar-pct {
    min-width: 40px !important;
    font-size: 0.58rem !important;
  }

  .money-primary {
    font-size: 0.9rem !important;
  }

  .money-muted {
    font-size: 0.68rem !important;
  }
}


/* Mobile option A v6: show ACCOUNT + BALANCE fully without horizontal scrolling */
@media (max-width: 700px) {
  body {
    padding: 4px !important;
  }

  .container {
    width: 100% !important;
    max-width: none !important;
  }

  .portfolio-panel {
    width: 100% !important;
    max-width: none !important;
    padding: 12px 8px 14px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    border-radius: 18px !important;
  }

  .portfolio-table-wrap {
    width: 100% !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
  }

  .portfolio-table,
  .compact-portfolio-table {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    table-layout: fixed !important;
  }

  /* Keep only Account and Balance visible on mobile. Profit and Max DD remain on desktop. */
  .portfolio-table th:nth-child(3),
  .portfolio-table td:nth-child(3),
  .portfolio-table th:nth-child(4),
  .portfolio-table td:nth-child(4) {
    display: none !important;
  }

  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) {
    width: 58% !important;
    max-width: 58% !important;
    text-align: left !important;
  }

  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) {
    width: 42% !important;
    max-width: 42% !important;
    text-align: right !important;
  }

  .portfolio-table th,
  .portfolio-table td {
    padding: 13px 8px !important;
    vertical-align: middle !important;
  }

  .portfolio-table th {
    font-size: 0.72rem !important;
    letter-spacing: 0.05em !important;
  }

  .portfolio-head h2 {
    font-size: 1.08rem !important;
  }

  .account-main {
    font-size: 0.98rem !important;
    line-height: 1.12 !important;
    letter-spacing: 0.03em !important;
  }

  .account-online {
    display: block !important;
    margin-top: 3px !important;
    font-size: 0.62rem !important;
  }

  .account-sub {
    display: none !important;
  }

  .account-main-row {
    display: block !important;
  }

  .account-bar-row {
    width: 100% !important;
    max-width: 100% !important;
    gap: 6px !important;
    margin-top: 9px !important;
  }

  .account-bar-row .mini-bar {
    min-width: 0 !important;
    height: 9px !important;
    flex: 1 1 auto !important;
  }

  .account-bar-row .bar-pct {
    min-width: 45px !important;
    font-size: 0.62rem !important;
    text-align: right !important;
  }

  .money-primary,
  .money-muted {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: nowrap !important;
    text-align: right !important;
  }

  .money-primary {
    font-size: 0.98rem !important;
    line-height: 1.12 !important;
    letter-spacing: 0.01em !important;
  }

  .money-muted {
    font-size: 0.72rem !important;
    line-height: 1.18 !important;
    margin-top: 5px !important;
    opacity: 0.85 !important;
  }

  .table-footer {
    padding: 11px 8px !important;
    font-size: 0.72rem !important;
  }
}

@media (max-width: 420px) {
  body {
    padding: 3px !important;
  }

  .portfolio-panel {
    padding: 11px 6px 13px !important;
  }

  .portfolio-table th,
  .portfolio-table td {
    padding: 12px 6px !important;
  }

  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) {
    width: 56% !important;
    max-width: 56% !important;
  }

  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) {
    width: 44% !important;
    max-width: 44% !important;
  }

  .account-main {
    font-size: 0.9rem !important;
  }

  .account-online {
    font-size: 0.58rem !important;
  }

  .account-bar-row .bar-pct {
    min-width: 42px !important;
    font-size: 0.56rem !important;
  }

  .money-primary {
    font-size: 0.88rem !important;
  }

  .money-muted {
    font-size: 0.65rem !important;
  }
}

/* v8: make mobile BALANCE numbers fill the cell, based on stable v6 layout */
@media (max-width: 700px) {
  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) {
    width: 50% !important;
    max-width: 50% !important;
  }

  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) {
    width: 50% !important;
    max-width: 50% !important;
    padding-left: 4px !important;
    padding-right: 4px !important;
    text-align: right !important;
    vertical-align: middle !important;
  }

  .portfolio-table td:nth-child(2) .money-primary {
    font-size: clamp(1.28rem, 6.4vw, 1.78rem) !important;
    line-height: 1.02 !important;
    font-weight: 900 !important;
    letter-spacing: -0.045em !important;
    width: 100% !important;
    max-width: 100% !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    text-align: right !important;
  }

  .portfolio-table td:nth-child(2) .money-muted {
    font-size: clamp(0.76rem, 3.4vw, 0.96rem) !important;
    line-height: 1.08 !important;
    font-weight: 700 !important;
    letter-spacing: -0.035em !important;
    margin-top: 6px !important;
    width: 100% !important;
    max-width: 100% !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    text-align: right !important;
  }
}

@media (max-width: 420px) {
  .portfolio-table th,
  .portfolio-table td {
    padding-top: 13px !important;
    padding-bottom: 13px !important;
  }

  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) {
    width: 49% !important;
    max-width: 49% !important;
  }

  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) {
    width: 51% !important;
    max-width: 51% !important;
  }

  .portfolio-table td:nth-child(2) .money-primary {
    font-size: clamp(1.22rem, 6.7vw, 1.55rem) !important;
    letter-spacing: -0.055em !important;
  }

  .portfolio-table td:nth-child(2) .money-muted {
    font-size: clamp(0.72rem, 3.5vw, 0.86rem) !important;
    letter-spacing: -0.045em !important;
  }
}

/* Portfolio Total Lots update: add Total Lots as a first-page Dashboard Portfolio column. */
.portfolio-table,
.compact-portfolio-table {
  min-width: 860px;
}

.portfolio-table th:nth-child(1),
.portfolio-table td:nth-child(1) { width: 34% !important; }
.portfolio-table th:nth-child(2),
.portfolio-table td:nth-child(2) { width: 21% !important; }
.portfolio-table th:nth-child(3),
.portfolio-table td:nth-child(3) { width: 16% !important; }
.portfolio-table th:nth-child(4),
.portfolio-table td:nth-child(4) { width: 13% !important; }
.portfolio-table th:nth-child(5),
.portfolio-table td:nth-child(5) { width: 16% !important; }

@media (max-width: 700px) {
  .portfolio-table,
  .compact-portfolio-table {
    min-width: 860px !important;
  }

  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) {
    width: 48% !important;
    max-width: 48% !important;
  }
  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) {
    width: 52% !important;
    max-width: 52% !important;
  }
  .portfolio-table th:nth-child(3),
  .portfolio-table td:nth-child(3),
  .portfolio-table th:nth-child(4),
  .portfolio-table td:nth-child(4),
  .portfolio-table th:nth-child(5),
  .portfolio-table td:nth-child(5) {
    display: none !important;
  }
}

/* Mobile Dashboard Portfolio fix: show Account + Balance + Total Lots on first screen. */
@media (max-width: 700px) {
  .portfolio-table,
  .compact-portfolio-table {
    width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed !important;
  }

  .portfolio-table th,
  .portfolio-table td {
    padding: 10px 5px !important;
    vertical-align: middle !important;
  }

  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) {
    display: table-cell !important;
    width: 42% !important;
    max-width: 42% !important;
  }

  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) {
    display: table-cell !important;
    width: 35% !important;
    max-width: 35% !important;
    text-align: left !important;
  }

  .portfolio-table th:nth-child(4),
  .portfolio-table td:nth-child(4) {
    display: table-cell !important;
    width: 23% !important;
    max-width: 23% !important;
    text-align: right !important;
  }

  .portfolio-table th:nth-child(3),
  .portfolio-table td:nth-child(3),
  .portfolio-table th:nth-child(5),
  .portfolio-table td:nth-child(5) {
    display: none !important;
  }

  .portfolio-table th:nth-child(4) .sortable,
  .portfolio-table td:nth-child(4) .money-primary,
  .portfolio-table td:nth-child(4) .money-muted {
    text-align: right !important;
  }

  .account-cell,
  .account-cell.no-avatar > div {
    min-width: 0 !important;
  }

  .account-main-row {
    flex-wrap: wrap !important;
    gap: 3px !important;
  }

  .account-main {
    font-size: 0.82rem !important;
    letter-spacing: -0.03em !important;
  }

  .account-online {
    font-size: 0.48rem !important;
    padding: 2px 4px !important;
  }

  .account-bar-row {
    max-width: 105px !important;
    gap: 4px !important;
  }

  .account-bar-row .bar-pct {
    min-width: 34px !important;
    font-size: 0.52rem !important;
  }

  .portfolio-table td:nth-child(2) .money-primary,
  .portfolio-table td:nth-child(4) .money-primary {
    font-size: 0.76rem !important;
    letter-spacing: -0.05em !important;
  }

  .portfolio-table td:nth-child(2) .money-muted,
  .portfolio-table td:nth-child(4) .money-muted {
    font-size: 0.58rem !important;
    letter-spacing: -0.04em !important;
  }
}

@media (max-width: 380px) {
  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) {
    width: 40% !important;
    max-width: 40% !important;
  }

  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) {
    width: 36% !important;
    max-width: 36% !important;
  }

  .portfolio-table th:nth-child(4),
  .portfolio-table td:nth-child(4) {
    width: 24% !important;
    max-width: 24% !important;
  }
}

/* Mobile Dashboard Portfolio v10: make Balance and Lot numbers fill their cells. */
@media (max-width: 700px) {
  .portfolio-table-wrap {
    padding-left: 0 !important;
    padding-right: 0 !important;
    overflow-x: hidden !important;
  }

  .portfolio-table,
  .compact-portfolio-table {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed !important;
  }

  .portfolio-table th,
  .portfolio-table td {
    padding-left: 2px !important;
    padding-right: 2px !important;
  }

  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) {
    width: 30% !important;
    max-width: 30% !important;
  }

  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) {
    width: 46% !important;
    max-width: 46% !important;
    text-align: right !important;
  }

  .portfolio-table th:nth-child(4),
  .portfolio-table td:nth-child(4) {
    width: 24% !important;
    max-width: 24% !important;
    text-align: right !important;
  }

  .portfolio-table th:nth-child(2) .sortable,
  .portfolio-table th:nth-child(4) .sortable {
    justify-content: flex-end !important;
    width: 100% !important;
    font-size: 0.62rem !important;
    letter-spacing: -0.04em !important;
  }

  .portfolio-table td:nth-child(2) .money-primary,
  .portfolio-table td:nth-child(4) .money-primary {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    font-size: clamp(17px, 4.9vw, 22px) !important;
    line-height: 1.02 !important;
    font-weight: 900 !important;
    letter-spacing: -0.095em !important;
    text-align: right !important;
    white-space: nowrap !important;
    overflow: visible !important;
  }

  .portfolio-table td:nth-child(2) .money-muted,
  .portfolio-table td:nth-child(4) .money-muted {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    font-size: clamp(12px, 3.5vw, 15px) !important;
    line-height: 1.05 !important;
    font-weight: 800 !important;
    letter-spacing: -0.075em !important;
    text-align: right !important;
    white-space: nowrap !important;
    overflow: visible !important;
  }

  .account-main {
    font-size: 0.72rem !important;
    letter-spacing: -0.06em !important;
  }

  .account-online {
    font-size: 0.42rem !important;
    padding: 1px 3px !important;
  }

  .account-bar-row {
    max-width: 82px !important;
  }

  .account-bar-row .bar-pct {
    min-width: 28px !important;
    font-size: 0.46rem !important;
  }
}

@media (max-width: 380px) {
  .portfolio-table th,
  .portfolio-table td {
    padding-left: 1px !important;
    padding-right: 1px !important;
  }

  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) {
    width: 28% !important;
    max-width: 28% !important;
  }

  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) {
    width: 48% !important;
    max-width: 48% !important;
  }

  .portfolio-table th:nth-child(4),
  .portfolio-table td:nth-child(4) {
    width: 24% !important;
    max-width: 24% !important;
  }

  .portfolio-table td:nth-child(2) .money-primary,
  .portfolio-table td:nth-child(4) .money-primary {
    font-size: clamp(16px, 5.2vw, 20px) !important;
    letter-spacing: -0.1em !important;
  }
}

/* Mobile Dashboard Portfolio v11: hide monitoring text and enlarge Account number, bar, and percent. */
@media (max-width: 700px) {
  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) {
    width: 34% !important;
    max-width: 34% !important;
  }

  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) {
    width: 43% !important;
    max-width: 43% !important;
  }

  .portfolio-table th:nth-child(4),
  .portfolio-table td:nth-child(4) {
    width: 23% !important;
    max-width: 23% !important;
  }

  .account-main-row {
    display: block !important;
    width: 100% !important;
  }

  .account-main {
    display: block !important;
    width: 100% !important;
    font-size: clamp(15px, 4.5vw, 19px) !important;
    line-height: 1.02 !important;
    font-weight: 900 !important;
    letter-spacing: -0.07em !important;
    white-space: nowrap !important;
  }

  .account-online {
    display: none !important;
  }

  .account-bar-row {
    width: 100% !important;
    max-width: 100% !important;
    gap: 4px !important;
    margin-top: 7px !important;
  }

  .account-bar-row .mini-bar {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    height: 11px !important;
    margin-top: 0 !important;
  }

  .account-bar-row .bar-pct {
    flex: 0 0 auto !important;
    min-width: 34px !important;
    font-size: clamp(10px, 3vw, 13px) !important;
    line-height: 1 !important;
    font-weight: 900 !important;
    letter-spacing: -0.055em !important;
    text-align: right !important;
  }
}

@media (max-width: 380px) {
  .portfolio-table th:nth-child(1),
  .portfolio-table td:nth-child(1) {
    width: 34% !important;
    max-width: 34% !important;
  }

  .portfolio-table th:nth-child(2),
  .portfolio-table td:nth-child(2) {
    width: 42% !important;
    max-width: 42% !important;
  }

  .portfolio-table th:nth-child(4),
  .portfolio-table td:nth-child(4) {
    width: 24% !important;
    max-width: 24% !important;
  }

  .account-main {
    font-size: clamp(14px, 4.8vw, 17px) !important;
  }

  .account-bar-row .mini-bar {
    height: 10px !important;
  }

  .account-bar-row .bar-pct {
    min-width: 32px !important;
    font-size: clamp(9px, 3vw, 12px) !important;
  }
}
