/* ============================================================
   Trader-FX dashboard — "Modern Quant" theme
   Layered on top of Bootstrap 5 dark; redefines design tokens
   so existing template Bootstrap classes pick up the new look
   without rewriting the templates.
   ============================================================ */

:root {
  --bg-0: #0a0d12;
  --bg-1: #0f1218;
  --bg-2: #161a23;
  --bg-3: #1d2230;
  --bg-elevated: #1a1f2c;
  --line: #232936;
  --line-soft: #1b212c;
  --line-bright: #2c3445;
  --text-1: #f4f6f9;
  --text-2: #a8b1c4;
  --text-3: #6e7891;
  --green: #2bd28a;
  --green-bg: #2bd28a18;
  --red: #ff5f6d;
  --red-bg: #ff5f6d18;
  --amber: #ffb454;
  --amber-bg: #ffb45418;
  --blue: #6da7ff;
  --blue-bg: #6da7ff18;
  --violet: #a47bff;
  --violet-bg: #a47bff18;

  /* Bootstrap variable overrides */
  --bs-body-bg: var(--bg-0);
  --bs-body-color: var(--text-1);
  --bs-body-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --bs-body-font-size: 14px;
  --bs-border-color: var(--line);
  --bs-secondary-bg: var(--bg-2);
  --bs-dark: var(--bg-1);
  --bs-tertiary-bg: var(--bg-2);
}

/* ---------- Base ---------- */
html, body {
  background:
    radial-gradient(ellipse at top, #131826 0%, var(--bg-0) 60%) fixed;
  color: var(--text-1);
  font-family: var(--bs-body-font-family);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}
body.bg-dark { background: transparent !important; }

.mono, .num, [data-field], #quotes-tbody td:not(:first-child),
.text-end, td.text-end, .form-control,
input[type=number], input[type=text],
.value, .stat-card .value {
  font-family: 'JetBrains Mono', ui-monospace, monospace !important;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

h1, h2, h3, h4, h5 {
  letter-spacing: -0.02em;
  color: var(--text-1);
  font-weight: 700;
}
h3 { font-size: 22px; margin-top: 4px; }
h5 { font-size: 14px; font-weight: 600; }

.text-muted, .text-secondary { color: var(--text-3) !important; }
.text-light { color: var(--text-1) !important; }
.text-info { color: var(--blue) !important; }
.text-success, .text-success * { color: var(--green) !important; }
.text-danger, .text-danger * { color: var(--red) !important; }
.text-warning { color: var(--amber) !important; }

/* ---------- NAVBAR ---------- */
.navbar.navbar-dark, .navbar.bg-black {
  background: rgba(15, 18, 24, 0.85) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft) !important;
  padding: 12px 24px;
  position: sticky; top: 0; z-index: 30;
}
.navbar-brand {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.015em;
  color: var(--text-1) !important;
  display: flex; align-items: center; gap: 10px;
}
.navbar-brand::before {
  content: 'F';
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--green) 0%, var(--blue) 100%);
  display: inline-flex; align-items: center; justify-content: center;
  color: #0a0d12;
  font-weight: 800;
  font-size: 14px;
  margin-right: 4px;
}
.navbar .nav-link {
  color: var(--text-2) !important;
  padding: 8px 14px !important;
  border-radius: 8px;
  font-weight: 500;
  font-size: 13.5px;
  transition: all 0.15s ease;
  margin: 0 2px;
}
.navbar .nav-link:hover {
  color: var(--text-1) !important;
  background: var(--bg-2);
}
.navbar .nav-link.active,
.navbar .nav-link[aria-current=page] {
  color: var(--text-1) !important;
  background: var(--bg-2);
  box-shadow: inset 0 0 0 1px var(--line-bright);
}

/* ---------- LAYOUT ---------- */
main.container-fluid { padding: 24px 28px !important; max-width: 1480px; margin: 0 auto; }

/* ---------- CARDS ---------- */
.card, .card-body, .card.bg-black {
  background: var(--bg-1) !important;
  border: 1px solid var(--line-soft) !important;
  border-radius: 16px !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
  color: var(--text-1);
}
.card-header {
  background: transparent !important;
  border-bottom: 1px solid var(--line-soft) !important;
  padding: 16px 20px !important;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card-body { padding: 18px 20px !important; }

/* ---------- TABLES ---------- */
.table, .table-dark {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text-1);
  --bs-table-border-color: var(--line-soft);
  --bs-table-hover-bg: var(--bg-2);
  margin-bottom: 0;
}
.table > :not(caption) > * > * {
  background: transparent !important;
  color: var(--text-1) !important;
  border-bottom: 1px solid var(--line-soft) !important;
}
.table thead th {
  font-weight: 500 !important;
  font-size: 11px !important;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-3) !important;
  padding: 12px 16px !important;
  background: var(--bg-1) !important;
}
.table tbody td {
  padding: 13px 16px !important;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0 !important; }
.table-hover tbody tr:hover td { background: var(--bg-2) !important; }

.table-responsive { background: var(--bg-1); border: 1px solid var(--line-soft); border-radius: 16px; overflow: hidden; }

/* Symbol column shouldn't be mono */
.table tbody td.fw-bold:first-child {
  font-family: 'Inter', sans-serif !important;
  font-weight: 700 !important;
  letter-spacing: -0.01em;
  font-size: 14px;
}

/* ---------- BUTTONS ---------- */
.btn {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13px;
  border-radius: 8px;
  padding: 8px 16px;
  letter-spacing: -0.005em;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}
.btn-primary {
  background: linear-gradient(180deg, var(--green) 0%, #1fb074 100%) !important;
  color: #0a0d12 !important;
  border: 0 !important;
  box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 4px 12px rgba(43,210,138,0.25);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger {
  background: linear-gradient(180deg, var(--red) 0%, #d1424d 100%) !important;
  color: #fff !important;
  border: 0 !important;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset, 0 6px 20px rgba(255,95,109,0.35);
}
.btn-danger:hover { filter: brightness(1.08); }
#kill-btn {
  padding: 14px 24px !important;
  font-size: 14px !important;
  border-radius: 12px !important;
}
#kill-btn:hover { transform: scale(1.02); }

.btn-outline-warning {
  color: var(--amber) !important;
  background: var(--amber-bg) !important;
  border: 0 !important;
}
.btn-outline-warning:hover { background: var(--amber) !important; color: #0a0d12 !important; }

.btn-outline-info {
  color: var(--blue) !important;
  background: var(--bg-2) !important;
  border: 1px solid var(--line) !important;
}
.btn-outline-info:hover { background: var(--bg-3) !important; border-color: var(--line-bright) !important; }
.btn-check:checked + .btn-outline-info {
  background: var(--blue-bg) !important;
  color: var(--blue) !important;
  border-color: var(--blue) !important;
}

/* ---------- BADGES ---------- */
.badge {
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.3px;
}
.badge.bg-success { background: var(--green-bg) !important; color: var(--green) !important; }
.badge.bg-danger  { background: var(--red-bg)   !important; color: var(--red)   !important; }
.badge.bg-warning { background: var(--amber-bg) !important; color: var(--amber) !important; }
.badge.bg-secondary { background: var(--bg-3) !important; color: var(--text-3) !important; }

/* ---------- FORMS ---------- */
.form-control, .form-select {
  background: var(--bg-2) !important;
  border: 1px solid var(--line) !important;
  border-radius: 8px !important;
  color: var(--text-1) !important;
  padding: 9px 12px !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 13px !important;
  transition: all 0.15s ease;
}
.form-control:focus, .form-select:focus {
  background: var(--bg-2) !important;
  border-color: var(--blue) !important;
  box-shadow: 0 0 0 3px var(--blue-bg) !important;
  color: var(--text-1) !important;
}
.form-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}
.form-text { color: var(--text-3) !important; font-size: 11px; }

.form-check-input {
  background-color: var(--bg-3);
  border-color: var(--line);
  width: 18px; height: 18px; border-radius: 6px;
}
.form-check-input:checked {
  background-color: var(--green);
  border-color: var(--green);
}
.form-check-input:focus { box-shadow: 0 0 0 3px var(--green-bg); border-color: var(--green); }
.form-check-label { font-size: 13px; color: var(--text-1); }

/* ---------- ALERTS ---------- */
.alert {
  border: 1px solid var(--line-soft) !important;
  border-radius: 12px !important;
  padding: 12px 16px !important;
  font-size: 13px;
}
.alert-info {
  background: linear-gradient(90deg, var(--blue-bg), transparent) !important;
  color: var(--blue) !important;
  border-color: var(--blue-bg) !important;
}
.alert-danger {
  background: linear-gradient(90deg, var(--red-bg), transparent) !important;
  color: var(--red) !important;
  border-color: var(--red-bg) !important;
}
.alert-warning {
  background: linear-gradient(90deg, var(--amber-bg), transparent) !important;
  color: var(--amber) !important;
  border-color: var(--amber-bg) !important;
}

/* ---------- SECTION HEADERS in command_center ---------- */
h5.mb-2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  margin-top: 26px !important;
  margin-bottom: 12px !important;
  letter-spacing: -0.01em;
}

/* ---------- KPI-LIKE STATS in command_center ---------- */
.row.g-3.align-items-center.mb-3 {
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 18px 20px !important;
  margin: 0 0 18px 0 !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.row.g-3.align-items-center.mb-3 .small.text-muted .col-md-3 {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px 14px;
}
#acct-netliq, #acct-funds, #acct-bp, #acct-cash {
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 22px !important;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-1);
  display: block;
  margin-bottom: 2px;
}

/* ---------- KILL SWITCH STATE BADGE ---------- */
#kill-state {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
}
#kill-state.bg-success {
  background: var(--green-bg) !important;
  color: var(--green) !important;
}
#kill-state.bg-success::before {
  content: ''; display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); margin-right: 6px;
  box-shadow: 0 0 0 3px var(--green-bg), 0 0 6px var(--green);
  animation: pulse-dot 2s infinite;
}
#kill-state.bg-danger {
  background: var(--red-bg) !important;
  color: var(--red) !important;
}
#kill-state.bg-danger::before {
  content: ''; display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red); margin-right: 6px;
  box-shadow: 0 0 0 3px var(--red-bg), 0 0 8px var(--red);
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ---------- POSITION CARDS (injected by JS) ---------- */
#positions-grid .card {
  border-radius: 14px !important;
  border: 1px solid var(--line-soft) !important;
  background: var(--bg-1) !important;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
#positions-grid .card:hover {
  border-color: var(--line-bright) !important;
  transform: translateY(-2px);
}
#positions-grid .card.border-success {
  border-left: 3px solid var(--green) !important;
}
#positions-grid .card.border-danger {
  border-left: 3px solid var(--red) !important;
}
#positions-grid .card-header.bg-success.bg-opacity-25 {
  background: var(--green-bg) !important;
  border-bottom-color: var(--line-soft) !important;
}
#positions-grid .card-header.bg-danger.bg-opacity-25 {
  background: var(--red-bg) !important;
  border-bottom-color: var(--line-soft) !important;
}

/* ---------- PAIRS ACCORDION (assignments page) ---------- */
.accordion { background: transparent; }
.accordion-item {
  background: var(--bg-1) !important;
  border: 1px solid var(--line-soft) !important;
  border-radius: 14px !important;
  margin-bottom: 10px !important;
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.accordion-item:hover { border-color: var(--line-bright) !important; }
.accordion-button {
  background: transparent !important;
  color: var(--text-1) !important;
  padding: 14px 18px !important;
  font-weight: 500;
  border-radius: 14px !important;
  box-shadow: none !important;
}
.accordion-button:not(.collapsed) {
  background: var(--bg-2) !important;
  color: var(--text-1) !important;
  border-bottom: 1px solid var(--line-soft) !important;
  border-radius: 14px 14px 0 0 !important;
}
.accordion-button::after {
  filter: invert(0.6) brightness(2);
}
.accordion-body { padding: 16px 18px !important; background: var(--bg-1); }
.accordion-button .fw-bold { font-size: 16px; letter-spacing: -0.015em; }

/* Pair-row range strip (added in pairs.html) */
.accordion-button .progress {
  height: 8px !important;
  background: var(--bg-3) !important;
  border-radius: 999px !important;
  overflow: visible;
  position: relative;
}
.accordion-button .progress-bar.bg-info {
  background: linear-gradient(90deg, var(--blue) 0%, #6da7ff 100%) !important;
  border-radius: 999px;
  position: relative;
}
.accordion-button .progress-bar.bg-info::after {
  content: '';
  position: absolute;
  right: -7px; top: -3px; bottom: -3px;
  width: 14px;
  background: var(--text-1);
  border-radius: 999px;
  box-shadow: 0 0 0 3px var(--bg-1), 0 2px 8px rgba(109, 167, 255, 0.6);
}

/* ---------- LOGIN PAGE ---------- */
body.bg-dark.text-light.d-flex {
  background: radial-gradient(ellipse at top, #131826 0%, #07090b 70%) !important;
}
.container .card.bg-black.border-secondary {
  background: var(--bg-1) !important;
  border: 1px solid var(--line-soft) !important;
  border-radius: 16px !important;
  padding: 28px !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

/* ---------- SETTINGS BTN-GROUP ---------- */
.btn-group { gap: 6px; }
.btn-group .btn {
  border-radius: 8px !important;
  border: 1px solid var(--line) !important;
}

/* ---------- FOOTER SPACING ---------- */
main { padding-bottom: 60px !important; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
  main.container-fluid { padding: 16px !important; }
  h3 { font-size: 18px; }
  #acct-netliq, #acct-funds, #acct-bp, #acct-cash { font-size: 18px !important; }
}

/* ============================================================
   Bid/Ask boxes with tick-flash animation.
   Static border colour signals which side of the book the cell
   represents (blue=bid, red=ask). Background flash fires every
   time the SSE stream pushes a new value.
   ============================================================ */
.bid-cell,
.ask-cell {
  /* display:block + width:100% makes the box fill its td. HTML table
     layout already guarantees every td in a column shares the same
     width, so all bid boxes auto-align vertically with each other and
     all ask boxes auto-align vertically with each other — no JS
     measurement, no first-render flicker. */
  display: block;
  width: 50%;
  margin-left: auto;  /* sit at the right edge of the td */
  box-sizing: border-box;
  border-radius: 3px;
  padding: 2px 8px;
  /* tabular-nums keeps every digit the same width so the price text
     itself does not shift horizontally as digits change. */
  font-variant-numeric: tabular-nums;
  text-align: right;
  transition: background-color 350ms ease-out;
}
.bid-cell { border: 1px solid var(--blue); }
.ask-cell { border: 1px solid var(--red); }

/* The flash class is added briefly when a new value arrives, then
   removed by JS so the next change can fire the animation again. */
.bid-cell.flash { animation: flash-bid 400ms ease-out; }
.ask-cell.flash { animation: flash-ask 400ms ease-out; }

@keyframes flash-bid {
  0%   { background-color: var(--blue); color: #fff; }
  100% { background-color: transparent; }
}
@keyframes flash-ask {
  0%   { background-color: var(--red); color: #fff; }
  100% { background-color: transparent; }
}


/* ============================================================
   Live tab — per-pair row with two 45% halves: live data on the
   left, strategy assignment form on the right. The 10% gap in
   between matches the user's "45% / 45% of the line each" spec.
   ============================================================ */
.quotes-list { display: flex; flex-direction: column; gap: 6px; }
.pair-row {
  display: flex;
  gap: 10%;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--line-soft);
}
.pair-row.pair-header { border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.live-half, .strategy-half, .range-half { flex: 0 0 45%; max-width: 45%; }
.live-grid {
  display: grid;
  grid-template-columns: 70px repeat(5, 1fr);
  gap: 8px;
  align-items: center;
}
/* Inside the live-grid, .bid-cell / .ask-cell were styled for table cells
   (display:block, width:100%, margin-left:auto). In the grid they want
   to be plain block elements that fill their grid track from the right
   edge. Reuse the same fill-the-cell logic. */
.live-grid .bid-cell,
.live-grid .ask-cell { width: 100%; margin-left: 0; }


/* Range bar row sits below the live-grid inside each pair's live-half. */
.range-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 0 4px;
}
.range-row .progress { min-width: 40px; }


/* ============================================================
   Entry-condition traffic lights — small label-bearing dots
   sitting at the end of each pair's range row.
   ============================================================ */
.cond-dots { display: inline-flex; gap: 4px; margin-left: 6px; }
.cond-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #0a0d12;
  cursor: help;
  /* Chips that carry a value (e.g. "RSI 54") need a touch more room
     than label-only chips ("RNG", "ADX"). The flex children will grow
     individually thanks to inline-flex on the parent .cond-dots. */
  white-space: nowrap;
}
.cond-green  { background-color: #2bd28a; }
.cond-yellow { background-color: #ffb454; }
.cond-red    { background-color: #ff5f6d; color: #fff; }


/* ============================================================
   Top-row buttons: KILL SWITCH and ALERTS toggle pinned to the
   exact same physical size (pixel parity). Bootstrap's outline
   vs solid variants normally render with the same height, but
   we force-pin everything that affects box geometry so the user
   measurement comes out identical.
   ============================================================ */
#kill-btn, #alerts-btn {
  height: 64px;
  width: 100%;
  padding: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-width: 1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Compact account-stat boxes — about half the visual footprint of the
   default Bootstrap row (smaller value font, tighter line-height). */
.acct-box {
  font-size: 10px;
  line-height: 1.15;
  color: var(--text-3);
}
.acct-box .acct-value {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 1px;
}


/* ============================================================
   Fit-to-screen pass: prevent horizontal scroll on the body,
   tighten the standard component paddings, allow internal
   sections (positions list, etc.) to scroll when content
   exceeds the viewport rather than the page itself scrolling.
   ============================================================ */
html, body {
  margin: 0;
  overflow-x: hidden;
}
body {
  /* Allow vertical scroll for now — kiosk-style 100vh kills usability when
     many positions are open. Just ensure horizontal stays contained. */
  min-height: 100vh;
}

/* Compact pair rows (live quotes / range) — was ~36px tall, now ~28px */
.pair-row {
  padding: 2px 0;
  font-size: 13px;
}
.pair-header { padding-bottom: 4px; }
.live-grid { gap: 6px; }
.range-row { gap: 6px; margin-top: 2px; }

/* Tighten position card body */
.card-body { padding: 0.5rem 0.75rem; }
.card-header { padding: 0.3rem 0.6rem; }

/* Buttons inside cards stay compact */
.card .btn-sm { padding: 0.15rem 0.5rem; font-size: 12px; }

/* Navbar shorter */
.navbar { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.navbar-brand { font-size: 15px; }
.nav-link { padding-top: 0.3rem !important; padding-bottom: 0.3rem !important; }

/* Top buttons retain their 64px height (already pinned) — no change there */


/* ============================================================
   Fluid grids: layout reflows continuously with window width.
   Replaces Bootstrap's row-cols-md-* / row-cols-lg-* / col-md-3
   discrete breakpoints. The minmax(MIN, 1fr) idiom packs as many
   columns as fit while each is at least MIN wide; once a card
   would be narrower than MIN the grid wraps to the next row.
   ============================================================ */
.positions-grid-fluid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.5rem;
}
.pos-card-cell { display: flex; }
.pos-card-cell > .card { width: 100%; }

.acct-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.5rem;
}


/* ============================================================
   TRULY DYNAMIC LAYER — scales smoothly across all screen sizes.
   Uses clamp() for fluid sizing, flex-basis for wrap-capable
   pair rows, and container queries for component-level responsiveness.
   Last block in the file so its specificity wins.
   ============================================================ */
:root {
  --content-pad:    clamp(0.4rem, 0.7vw, 1rem);
  --base-fs:        clamp(11px, 0.55vw + 8px, 14px);
  --small-fs:       clamp(9px,  0.45vw + 7px, 12px);
  --card-min:       clamp(220px, 25vw, 330px);
  --acct-min:       clamp(80px,  10vw, 130px);
  --pair-half-min:  clamp(280px, 38vw, 480px);
  --gap-row:        clamp(2px,   0.4vw, 8px);
  --kill-h:         clamp(44px,  4vw + 28px, 72px);
}

body { font-size: var(--base-fs); }

main { padding: var(--content-pad) !important; }

/* Top row: KILL / ALERTS height scales with viewport, never below 44px
   (touch-friendly minimum) and never above 72px (avoids domination on
   ultrawide). Replaces the hard-pinned 64px from earlier. */
#kill-btn, #alerts-btn {
  height: var(--kill-h);
  font-size: clamp(0.9rem, 0.6vw + 0.6rem, 1.5rem);
}

/* Pair row: flex-wrap so halves stack vertically when their basis
   no longer fits side-by-side. Both halves can grow AND shrink. */
.pair-row {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: var(--content-pad);
  padding: var(--gap-row) 0;
  font-size: var(--base-fs);
}
.live-half,
.range-half,
.strategy-half {
  flex: 1 1 var(--pair-half-min) !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

/* Live grid (Pair | Bid | Ask | Spread | High | Low) — the first
   column was 70px fixed. Make it auto-size so on narrow screens it
   doesn't waste space. */
.live-grid {
  grid-template-columns: minmax(60px, 1fr) repeat(5, minmax(0, 1fr));
  gap: clamp(2px, 0.4vw, 8px);
}

/* Position cards — minimum width scales with viewport. */
.positions-grid-fluid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr)) !important;
  gap: var(--content-pad) !important;
}

/* Account stat boxes adapt their min-width too. */
.acct-stats-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(var(--acct-min), 1fr)) !important;
  gap: var(--content-pad) !important;
}
.acct-box       { font-size: var(--small-fs); }
.acct-box .acct-value { font-size: calc(var(--small-fs) + 1px); }

/* Container query on the quotes list: when the LIST itself is < 720px
   wide (regardless of viewport), force pair-row halves to stack
   vertically. This handles narrow embeds, sidebars, etc. */
.quotes-list {
  container-type: inline-size;
  container-name: quotes;
}
@container quotes (max-width: 720px) {
  .live-half, .range-half {
    flex: 1 1 100%;
    max-width: 100%;
  }
}

/* Cond-dot chips scale slightly with viewport */
.cond-dot {
  font-size: clamp(8px, 0.4vw + 6px, 11px);
  min-width: clamp(22px, 2vw + 16px, 32px);
}

/* Bid/ask cells inherit base font but stay tabular */
.bid-cell, .ask-cell {
  font-size: var(--base-fs);
}

/* Flash-saved animation for the stop/target click-edit confirmation. */
@keyframes flash-saved-keys {
  0%   { background-color: rgba(43, 210, 138, 0.55); color: #fff; }
  100% { background-color: transparent; }
}
.flash-saved {
  animation: flash-saved-keys 600ms ease-out;
  border-radius: 3px;
  padding: 0 4px;
}

.editable-price:hover {
  background-color: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}
.editable-price::after {
  content: " ✎";
  font-size: 0.75em;
  opacity: 0.5;
}
.editable-price:hover::after {
  opacity: 1;
}


/* ============================================================
   Stop / Target inline price inputs on each open-position card.
   Always editable, no click-to-reveal — the user can see they're
   inputs and just type.
   ============================================================ */
.price-input {
  width: 9ch;
  padding: 1px 4px;
  border: 1px solid var(--line-bright);
  border-radius: 3px;
  background: var(--bg-1);
  font-family: inherit;
  font-size: inherit;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
  /* Hide the browser spinner buttons — too visually noisy on small inputs. */
  -moz-appearance: textfield;
}
.price-input::-webkit-outer-spin-button,
.price-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.price-input.price-stop   { color: var(--red); border-color: var(--red); }
.price-input.price-target { color: var(--green); border-color: var(--green); }
.price-input:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
  background: var(--bg-2);
}
.price-input-pending { opacity: 0.55; }
.price-input-saved {
  animation: price-saved-keys 700ms ease-out;
}
@keyframes price-saved-keys {
  0%   { background-color: rgba(43, 210, 138, 0.45); }
  100% { background-color: var(--bg-1); }
}

/* ============================================================
   Pixel-uniform condition chips and compact live-data row.
   Goal: every chip across every pair row is exactly the same
   width so they form clean vertical columns, and the bid/ask/
   spread/high/low cells are tight so the chips have room.
   ============================================================ */

/* Chip container: CSS Grid with 5 fixed-width tracks. Every cell
   the same width regardless of content -> chips align vertically
   across all pair rows. */
.cond-dots {
  display: inline-grid !important;
  grid-template-columns: repeat(5, 56px);
  gap: 4px;
  margin-left: 8px;
}

/* Each chip fills its grid cell. min-width 0 lets the grid track
   width win over the old min-width: 26px. */
.cond-dot {
  min-width: 0 !important;
  width: 100%;
  padding: 1px 2px;
  font-size: 9px;
}

/* Compact live-grid: smaller font + tighter gap + fixed-width cells
   for Bid/Ask/Spread/High/Low so they no longer eat width that the
   chips on the right could use. */
.live-grid {
  grid-template-columns: 64px repeat(5, 64px) !important;
  gap: 3px !important;
  font-size: 12px;
}
.live-grid .bid-cell,
.live-grid .ask-cell {
  padding: 1px 4px;
  font-size: 11px;
}

/* Range-row: progress bar takes the leftover space; everything else
   is auto-sized. The chips render after .range-rows content via the


/* ============================================================
   Pixel-uniform condition chips and compact live-data row.
   Every chip across every pair row is exactly the same width so
   they form clean vertical columns, and the bid/ask/spread/high/
   low cells are tight so the chips have room.
   ============================================================ */

/* Chip container: CSS Grid with 5 fixed-width tracks. Every cell
   the same width regardless of content -> chips align vertically
   across all pair rows. */
.cond-dots {
  display: inline-grid !important;
  grid-template-columns: repeat(5, 56px);
  gap: 4px;
  margin-left: 8px;
}

/* Each chip fills its grid cell. min-width 0 lets the grid track
   width win over the old min-width: 26px. */
.cond-dot {
  min-width: 0 !important;
  width: 100%;
  padding: 1px 2px;
  font-size: 9px;
}

/* Compact live-grid: smaller font + tighter gap + fixed-width cells
   for Bid/Ask/Spread/High/Low so they no longer eat width the chips
   on the right could use. */
.live-grid {
  grid-template-columns: 64px repeat(5, 64px) !important;
  gap: 3px !important;
  font-size: 12px;
}
.live-grid .bid-cell,
.live-grid .ask-cell {
  padding: 1px 4px;
  font-size: 11px;
}

.range-row { gap: 6px; }


/* ============================================================
   Pro-trading-platform layout: spread the live-data row across
   the full width of live-half, headers centered above columns,
   numeric data right-aligned (financial convention). Pair name
   slightly narrower so the price columns get equal share.
   ============================================================ */

/* Live-grid: 1fr columns so cells stretch evenly across live-half.
   Pair name takes a touch less width than the price columns. */
.live-grid {
  grid-template-columns: 0.7fr repeat(5, 1fr) !important;
  gap: clamp(6px, 0.7vw, 14px) !important;
  font-size: 13px;
  align-items: center;
}

/* Header row: centered labels above the columns. .pair-header is
   the class on the header pair-row at the top of the quotes list. */
.pair-header .live-grid > span,
.pair-header .live-grid > strong {
  text-align: center !important;
}

/* Numeric data cells stay right-aligned (financial convention).
   The bid-cell / ask-cell already do this via their own rule. */
.live-grid [data-field="spread"],
.live-grid [data-field="high"],
.live-grid [data-field="low"] {
  text-align: right !important;
}

/* Pair name on data rows: bold, left-aligned, padding for breathing */
.live-grid > strong:first-child { padding-left: 2px; }

/* Range row gets a small left padding so the L price isn't flush
   against the live-half edge. */
.range-row { padding-left: 4px; }

/* Range section labels (centered above the range bar elements). */
.pair-header .range-half > div {
  text-align: center !important;
}

/* Subtle alternating-row tint for the data rows (not the header).
   Pro trading platforms use this for readability. */
.pair-row:not(.pair-header):nth-child(even) {
  background-color: rgba(255, 255, 255, 0.015);
}
