/* ---------------------------------------------------------------------------
   Modern Design System (Dark Glassmorphism)
   --------------------------------------------------------------------------- */
:root {
  --bg-gradient-start: #0a0e17;
  --bg-gradient-end: #0f172a;
  --panel-bg: rgba(30, 41, 59, 0.9);
  --panel-border: rgba(255, 255, 255, 0.08);
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --glass-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
  font-family: 'Outfit', sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--panel-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(to right, #00f2fe, #4facfe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.brand-title i {
  color: var(--accent-cyan);
  -webkit-text-fill-color: initial;
}

.nifty-ticker-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(6, 182, 212, 0.25);
  padding: 0.3rem 0.65rem;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  -webkit-text-fill-color: initial;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.nifty-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.nifty-ltp {
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.82rem;
}

.nifty-change {
  font-size: 0.76rem;
  font-weight: 600;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ---------------------------------------------------------------------------
   Buttons & Interactive Badges
   --------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-running {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-green);
  border-color: rgba(16, 185, 129, 0.2);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.1);
}

.badge-paused {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
  border-color: rgba(239, 68, 68, 0.2);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.1);
}

.badge-outside {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.2);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.1);
}

.bg-yellow {
  background-color: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
}

/* Modal Styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.modal-overlay.active {
  opacity: 1;
}
.modal-content {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  position: relative;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}
.modal-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-main);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover {
  color: var(--text-main);
}

/* Configuration modal and touch-friendly settings descriptions */
.config-modal-content {
  width: min(540px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}

.config-modal-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem 0.85rem;
}

.config-modal-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.config-modal-field .input-cell {
  min-height: 36px;
  height: 36px;
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
  border-radius: 6px;
  text-transform: none;
}

.config-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--panel-border);
}

.config-cell-value {
  display: block;
  min-width: 4rem;
  color: var(--text-main);
}

.config-broker-value {
  font-weight: 600;
}

.settings-info-button {
  display: inline-grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-right: 0.45rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--accent-cyan);
  cursor: pointer;
  vertical-align: middle;
}

.settings-info-button:hover,
.settings-info-button:focus-visible {
  background: rgba(6, 182, 212, 0.16);
  outline: none;
}

.settings-info-popover {
  position: fixed;
  z-index: 1100;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 0.9rem;
  border: 1px solid rgba(6, 182, 212, 0.4);
  border-radius: 8px;
  background: #0f172a;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  color: var(--text-main);
  font-size: 0.86rem;
  line-height: 1.4;
}

.settings-info-popover[hidden] {
  display: none;
}

.settings-info-close {
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.btn-cyan {
  background: linear-gradient(135deg, #00f2fe, #4facfe);
  color: #0b1329;
  border: none;
}

.btn-cyan:hover {
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
  background: linear-gradient(135deg, #00e0eb, #3fa1eb);
}

.btn-red {
  background: rgba(239, 68, 68, 0.2);
  color: #ff6b6b;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-red:hover {
  background: rgba(239, 68, 68, 0.35);
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

/* ---------------------------------------------------------------------------
   Dashboard Layout
   --------------------------------------------------------------------------- */
.dashboard-container {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--glass-glow);
  transition: all 0.2s ease;
}

.metric-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.metric-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
}

.metric-positive {
  color: var(--accent-green);
}

.metric-negative {
  color: var(--accent-red);
}

/* Tabs Navigation */
.tab-bar {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.35rem;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  white-space: nowrap;
  border-radius: 6px;
  flex-shrink: 0;
}

.tab-btn:hover, .tab-btn.active {
  color: var(--accent-cyan);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -0.45rem;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-cyan);
  border-radius: 99px;
}

/* ---------------------------------------------------------------------------
   Tables & Panel UI
   --------------------------------------------------------------------------- */
.panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--glass-glow);
  margin-bottom: 2rem;
}

.panel-title {
  font-size: 1.2rem;
  font-family: 'Space Grotesk', sans-serif;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.panel-title select {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  height: 34px;
  box-sizing: border-box;
}

.panel-title .btn {
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
}

.panel-title .btn-cyan {
  font-size: 0.85rem;
  padding: 0.4rem 0.85rem;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 0.5rem 0.45rem;
  border-bottom: 1px solid var(--panel-border);
  font-weight: 600;
  white-space: nowrap;
}

td {
  padding: 0.38rem 0.45rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.82rem;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Compact Table Elements */
.config-cell-value {
  font-size: 0.82rem;
  white-space: nowrap;
}

.input-cell {
  padding: 0.25rem 0.35rem;
  font-size: 0.8rem;
}

.input-cell {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  font-family: 'Space Grotesk', sans-serif;
  width: 100%;
}

.input-cell:disabled {
  opacity: 0.85;
  background: transparent;
  border-color: transparent;
  color: var(--text-main);
  cursor: default;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.input-cell:focus {
  outline: 1px solid var(--accent-cyan);
}

/* Status Dot */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.bg-green { background-color: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }
.bg-red { background-color: var(--accent-red); box-shadow: 0 0 8px var(--accent-red); }
.bg-muted { background-color: var(--text-muted); }

/* Custom Toggles */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .3s;
  border-radius: 34px;
  border: 1px solid var(--panel-border);
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px; width: 14px;
  left: 3px; bottom: 3px;
  background-color: var(--text-main);
  transition: .3s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--accent-green);
}
input:checked + .slider:before {
  transform: translateX(22px);
}

/* ---------------------------------------------------------------------------
   Trade Logs UI
   --------------------------------------------------------------------------- */
.trade-log-row {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.trade-log-row:last-child { border-bottom: none; }

.trade-action {
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
}
.action-buy { background: rgba(16, 185, 129, 0.1); color: var(--accent-green); }
.action-sell { background: rgba(239, 68, 68, 0.1); color: var(--accent-red); }

/* Utility overlay */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 23, 0.9);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 1.5rem;
  font-family: 'Space Grotesk', sans-serif;
  transition: opacity 0.3s ease;
}
.spinner {
  width: 50px; height: 50px;
  border: 3px solid rgba(6, 182, 212, 0.1);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Calibri Font Family Override */
body, button, input, select, textarea, th, td, span, div, h1, h2, h3, h4, h5, h6, a, p, label, .brand-title, .panel-title, .card-title, .setting-key {
  font-family: 'Calibri', 'Outfit', 'Space Grotesk', sans-serif !important;
}

/* select option color styling for readability */
select option {
  background-color: #0f172a !important;
  color: #f8fafc !important;
}

/* Center align positions, sma28-chartink, config, and scanner table cells except the first column */
#tab-positions table th,
#tab-positions table td,
#tab-sma28-chartink table th,
#tab-sma28-chartink table td,
#tab-config table th,
#tab-config table td,
#tab-scanner table th,
#tab-scanner table td {
  text-align: center;
  white-space: nowrap;
}
#tab-positions table th:first-child,
#tab-positions table td:first-child,
#tab-sma28-chartink table th:first-child,
#tab-sma28-chartink table td:first-child,
#tab-config table th:first-child,
#tab-config table td:first-child,
#tab-scanner table th:first-child,
#tab-scanner table td:first-child {
  text-align: left;
}

#tab-sma28-chartink .table-wrapper table,
#tab-positions .table-wrapper table {
  min-width: 1200px;
}

/* Make input values align inherit for centering */
.input-cell {
  text-align: inherit;
}

/* Compact & Tighten Config Editor Table Spacing */
#config-editor-table th {
  padding: 0.45rem 0.3rem !important;
  font-size: 0.72rem !important;
  white-space: nowrap;
}
#config-editor-table td {
  padding: 0.3rem 0.25rem !important;
  font-size: 0.8rem !important;
}
#config-editor-table td input,
#config-editor-table td select {
  min-width: 42px;
  padding: 0.25rem 0.25rem !important;
  font-size: 0.79rem !important;
}
#config-editor-table td:nth-child(4) select,
#config-editor-table td:nth-child(4) input {
  min-width: 125px; /* AVG REF select box */
}
#config-editor-table td:nth-child(5) select,
#config-editor-table td:nth-child(5) input {
  min-width: 50px;  /* Prvnt Avg Up select box */
}
#config-editor-table td:nth-child(13) select,
#config-editor-table td:nth-child(13) input {
  min-width: 75px;  /* BROKER select box */
}
.input-cell:disabled {
  padding: 0.25rem 0.2rem !important;
}

/* ---------------------------------------------------------------------------
   Responsive dashboard layout & Global Custom Scrollbars
   --------------------------------------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.65);
}
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.4) rgba(15, 23, 42, 0.6);
}

.table-wrapper {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.4) rgba(15, 23, 42, 0.6);
}

.table-wrapper::-webkit-scrollbar {
  height: 6px;
  width: 6px;
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 999px;
}

@media (max-width: 900px) {
  header {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.9rem;
    padding: 1rem 1.25rem;
  }

  .header-controls {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.65rem;
  }

  .dashboard-container {
    margin: 1.25rem auto;
    padding: 0 1rem;
  }

  .tab-bar {
    gap: 0.25rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding-bottom: 0.65rem;
    margin: 0 -1rem 1.25rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .tab-btn {
    flex: 0 0 auto;
    font-size: 0.9rem;
    padding: 0.65rem 0.8rem;
    min-height: 44px;
  }

  .tab-bar > div:last-child {
    display: none !important;
  }

  .panel {
    padding: 1.1rem;
    margin-bottom: 1.25rem;
  }

  .panel-title {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-bottom: 1rem;
  }

  .panel-title > div {
    flex-wrap: wrap;
  }

  .table-wrapper table {
    min-width: 680px;
  }

  #tab-config .table-wrapper table {
    min-width: 900px;
  }

  #tab-settings > div,
  #holiday-modal .modal-body > div {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 600px) {
  header {
    padding: 0.9rem 1rem;
  }

  .brand-title {
    font-size: 1.15rem;
    gap: 0.5rem;
  }

  .header-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .header-controls .badge {
    justify-content: center;
    min-width: 0;
    padding: 0.5rem 0.6rem;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
  }

  #trading-mode-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-controls .btn {
    justify-content: center;
    min-height: 44px;
    padding: 0.6rem 0.75rem;
  }

  .dashboard-container {
    margin: 1rem auto;
    padding: 0 0.75rem;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
    margin-bottom: 1.15rem;
  }

  .metric-card {
    padding: 0.9rem;
  }

  .metric-label {
    font-size: 0.68rem;
    line-height: 1.2;
  }

  .metric-value {
    font-size: 1.22rem;
    line-height: 1.15;
  }

  .metric-breakdown {
    font-size: 0.64rem !important;
    line-height: 1.35;
  }

  .tab-bar {
    margin-left: -0.75rem;
    margin-right: -0.75rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .panel {
    padding: 0.9rem;
    border-radius: 10px;
  }

  .panel-title {
    font-size: 1.02rem;
  }

  .panel-title > div {
    width: 100%;
    gap: 0.5rem !important;
  }

  .panel-title select,
  .panel-title .btn {
    min-height: 42px;
  }

  .table-wrapper {
    margin: 0 -0.15rem;
  }

  th {
    padding: 0.7rem 0.75rem;
    font-size: 0.7rem;
  }

  td {
    padding: 0.6rem 0.75rem;
    font-size: 0.86rem;
  }

  .trade-log-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.85rem 0;
  }

  .modal-content,
  #holiday-modal .modal-content {
    width: calc(100% - 1.5rem) !important;
    max-width: none !important;
    max-height: calc(100vh - 1.5rem);
    overflow-y: auto;
    padding: 1rem;
  }

  #holidays-import-text {
    height: 140px !important;
  }

  /* Settings are a two-column data table, not a desktop-wide spreadsheet. */
  #tab-settings .table-wrapper {
    overflow-x: hidden;
  }

  #tab-settings .table-wrapper table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }

  #tab-settings th,
  #tab-settings td {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #tab-settings th:first-child,
  #tab-settings td:first-child {
    width: 55% !important;
  }

  #tab-settings th:last-child,
  #tab-settings td:last-child {
    width: 45% !important;
  }

  #tab-settings .input-cell {
    box-sizing: border-box;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Compact each trade into a clear heading, amount, remark, and timestamp. */
  .trade-log-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.35rem 0.65rem;
    padding: 0.85rem 0;
  }

  .trade-log-row > div:first-child {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    min-width: 0;
    gap: 0.3rem 0.45rem;
  }

  .trade-log-row > div:first-child span {
    margin-left: 0 !important;
  }

  .trade-log-row > div:first-child span:last-child {
    flex-basis: 100%;
    font-size: 0.78rem !important;
    line-height: 1.35;
  }

  .trade-log-row > div:last-child {
    min-width: 0;
    text-align: right !important;
    white-space: nowrap;
  }

  .trade-log-row > div:last-child span {
    font-size: 0.7rem !important;
  }

  /* Mobile Equal-Division Toolbars for all 5 Tabs */
  #tab-positions .panel-title > div {
    display: grid !important;
    grid-template-columns: 1fr 1fr auto !important;
    width: 100% !important;
    gap: 0.4rem !important;
  }
  #tab-positions .panel-title select,
  #tab-positions .panel-title #btn-col-picker,
  #tab-positions .panel-title > button {
    width: 100% !important;
    justify-content: center;
    min-height: 40px;
    padding: 0.4rem 0.5rem !important;
    font-size: 0.78rem !important;
  }

  #tab-config .panel-title > div {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    width: 100% !important;
    gap: 0.5rem !important;
  }
  #tab-config .panel-title select,
  #tab-config .panel-title button {
    width: 100% !important;
    justify-content: center;
    min-height: 40px;
    font-size: 0.8rem !important;
  }

  #tab-trades .panel-title > div {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    width: 100% !important;
    gap: 0.35rem !important;
  }
  #tab-trades .panel-title select {
    width: 100% !important;
    min-height: 40px;
    padding: 0.35rem 0.2rem !important;
    font-size: 0.73rem !important;
  }

  #tab-settings .panel-title > div {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    width: 100% !important;
    gap: 0.5rem !important;
  }
  #tab-settings .panel-title button {
    width: 100% !important;
    justify-content: center;
    min-height: 40px;
  }

  #tab-scanner .panel-title > div {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    width: 100% !important;
    gap: 0.5rem !important;
  }
  #tab-scanner .panel-title select,
  #tab-scanner .panel-title > div > div {
    width: 100% !important;
  }

  #tab-scanner .panel-title > div > div {
    display: flex !important;
    flex-direction: column;
    align-items: stretch !important;
    width: 100%;
    gap: 0.35rem !important;
  }

  #scanner-auto-deploy,
  #scanner-deploy-broker {
    box-sizing: border-box;
    width: 100%;
    min-height: 44px;
    font-size: 0.95rem !important;
  }

  .config-modal-fields {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .config-modal-actions {
    flex-direction: column-reverse;
  }

  .config-modal-actions .btn {
    justify-content: center;
    min-height: 44px;
  }
}

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

  .header-controls {
    grid-template-columns: 1fr;
  }
}

/* Floating Toast Notifications System */
#toast-container {
  position: fixed !important;
  top: 1rem !important;
  right: 1.25rem !important;
  z-index: 999999 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0.45rem !important;
  pointer-events: none !important;
  max-width: 480px !important;
  width: calc(100% - 2.5rem) !important;
}

.custom-toast {
  pointer-events: auto !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.75rem !important;
  padding: 0.85rem 1.1rem !important;
  background: #1e293b !important;
  color: #f8fafc !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 10px !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7) !important;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
  font-family: 'Space Grotesk', sans-serif !important;
  font-size: 0.88rem !important;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(100px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.toast-fade-out {
  animation: toastFadeOut 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

@keyframes toastFadeOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(50px);
  }
}

.toast-icon {
  font-size: 1.35rem !important;
  flex-shrink: 0 !important;
}

.toast-content {
  flex-grow: 1 !important;
  line-height: 1.35 !important;
}

.toast-title {
  font-weight: 700 !important;
  font-size: 0.88rem !important;
  margin-bottom: 0.15rem !important;
  color: #f8fafc !important;
}

.toast-message {
  font-size: 0.82rem !important;
  color: #94a3b8 !important;
}

.toast-close {
  background: none !important;
  border: none !important;
  color: #94a3b8 !important;
  font-size: 1.25rem !important;
  cursor: pointer !important;
  padding: 0 0.25rem !important;
  line-height: 1 !important;
  transition: color 0.15s ease !important;
}

.toast-close:hover {
  color: #f8fafc !important;
}

/* Traded Today Row Highlights */
.row-traded-today-buy {
  border-left: 4px solid #10b981 !important;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.14) 0%, rgba(255, 255, 255, 0.02) 100%) !important;
}

.row-traded-today-sell {
  border-left: 4px solid #f43f5e !important;
  background: linear-gradient(90deg, rgba(244, 63, 94, 0.14) 0%, rgba(255, 255, 255, 0.02) 100%) !important;
}

.row-traded-today-both {
  border-left: 4px solid #38bdf8 !important;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.14) 0%, rgba(255, 255, 255, 0.02) 100%) !important;
}

/* Static Trade Execution Toast Card - Compact Rectangular */
.execution-toast {
  pointer-events: auto !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0.35rem !important;
  padding: 0.65rem 0.95rem !important;
  background: rgba(15, 23, 42, 0.96) !important;
  backdrop-filter: blur(8px) !important;
  color: #f8fafc !important;
  border-radius: 9px !important;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.8) !important;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
  font-family: 'Space Grotesk', sans-serif !important;
  max-width: 480px !important;
  width: 100% !important;
  box-sizing: border-box !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease !important;
}

.execution-toast:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.9) !important;
}

.execution-toast-buy {
  border: 1px solid rgba(16, 185, 129, 0.35) !important;
  border-left: 4px solid #10b981 !important;
}

.execution-toast-sell {
  border: 1px solid rgba(244, 63, 94, 0.35) !important;
  border-left: 4px solid #f43f5e !important;
}

.execution-toast-paper-buy {
  border: 1px solid rgba(168, 85, 247, 0.4) !important;
  border-left: 4px solid #a855f7 !important;
}

.execution-toast-paper-sell {
  border: 1px solid rgba(244, 63, 94, 0.35) !important;
  border-left: 4px solid #f43f5e !important;
}

/* Universal White Symbol Styling across all tables & tabs */
.col-symbol a,
.col-symbol,
.col-sma28_symbol a,
.col-sma28_symbol,
.col-tenet_symbol a,
.col-tenet_symbol,
.col-btst_symbol a,
.col-btst_symbol,
.col-swing_symbol a,
.col-swing_symbol,
.config-table td:first-child a,
.config-table td:first-child,
table td a[href*="tradingview.com"],
.symbol-cell a,
.symbol-cell {
  color: #ffffff !important;
  font-weight: 700 !important;
  text-decoration: none !important;
}

table td a[href*="tradingview.com"]:hover,
.col-symbol a:hover,
.col-sma28_symbol a:hover,
.col-tenet_symbol a:hover,
.col-btst_symbol a:hover,
.col-swing_symbol a:hover {
  color: #ffffff !important;
  text-decoration: underline !important;
}

/* ---------------------------------------------------------------------------
   Analytics Hub Glassmorphism System
   --------------------------------------------------------------------------- */
.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}

@media (max-width: 1200px) {
  .analytics-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .analytics-kpi-grid {
    grid-template-columns: 1fr;
  }
}

.analytics-card {
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 1.2rem 1.35rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.analytics-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

.analytics-card-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.analytics-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.analytics-card-title {
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.analytics-card-icon {
  font-size: 1rem;
  opacity: 0.85;
}

.analytics-card-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.analytics-card-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 0.45rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.analytics-table th {
  padding: 0.8rem 1rem;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
}

.analytics-table td {
  padding: 0.85rem 1rem;
  font-size: 0.84rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

.analytics-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

/* Broker Mini Cards */
.analytics-broker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

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

.broker-mini-card {
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 0.85rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.broker-mini-card:hover {
  transform: translateY(-2px);
}

.broker-stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.28);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

@media (max-width: 520px) {
  .broker-stat-strip {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
}

/* ---------------------------------------------------------------------------
   Backtest Lab Modern KPI Cards
   --------------------------------------------------------------------------- */
.bt-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.bt-card {
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.88), rgba(30, 41, 59, 0.65));
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 1rem 1.15rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;
  transition: all 0.22s ease-in-out;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.65rem;
}

.bt-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

.bt-card.active-card {
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35), 0 8px 28px rgba(0, 0, 0, 0.5);
}

.bt-card-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.bt-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.bt-card-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bt-card-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
}

.bt-card-hero {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0.1rem 0;
}

.bt-hero-val {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.bt-hero-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bt-winrate-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.bt-winrate-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.bt-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.4rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.bt-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.bt-stat-chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 0.3rem 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.1rem;
}

.bt-stat-lbl {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.bt-stat-val {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

