/* TradeHouse Forex Bot v0.7.0 dashboard
   Gold accent matching Ngene's brand (Champagne Gold #D4AF37)
   Mobile-first; tables scroll horizontally INSIDE their own card. */

:root {
  --bg: #0d0e10;
  --card: #16181c;
  --card-2: #1d1f24;
  --text: #e6e6e6;
  --text-dim: #8a8d94;
  --gold: #D4AF37;
  --pos: #4ade80;
  --neg: #f87171;
  --warn: #fbbf24;
  --border: #2a2d33;
}

* { box-sizing: border-box; }

/* Lock the document to viewport width so nothing ever overflows the page */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
header h1 {
  margin: 0;
  font-size: 16px;
  color: var(--gold);
}
.header-meta {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.pill {
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 11px;
}
.pill.running { background: rgba(74, 222, 128, 0.15); color: var(--pos); }
.pill.stopped { background: rgba(248, 113, 113, 0.15); color: var(--neg); }

@media (min-width: 600px) {
  header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
  }
  header h1 { font-size: 18px; }
}

.actions {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
@media (min-width: 600px) { .actions { padding: 16px 24px; } }

button {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  white-space: nowrap;
}
button:hover { border-color: var(--gold); }
button.primary { background: var(--gold); color: #000; border-color: var(--gold); font-weight: 600; }
button.danger { background: rgba(248, 113, 113, 0.15); color: var(--neg); border-color: var(--neg); }

.broker-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 0 16px 12px;
}
@media (min-width: 600px) {
  .broker-cards {
    grid-template-columns: repeat(2, 1fr);
    padding: 0 24px 16px;
    gap: 12px;
  }
}
.broker-card {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.b-code { font-weight: 600; color: var(--gold); }
.b-state { font-size: 11px; font-weight: 600; }
.b-state.connected { color: var(--pos); }
.b-state.failed { color: var(--neg); }
.b-bal { font-size: 18px; font-weight: 600; word-break: break-word; }
@media (min-width: 600px) { .b-bal { font-size: 20px; } }

/* Stats: 2 cols on mobile, 4 on desktop */
.grid-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 0 16px 12px;
}
@media (min-width: 600px) {
  .grid-row {
    grid-template-columns: repeat(4, 1fr);
    padding: 0 24px 16px;
    gap: 12px;
  }
}
.stat-card {
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.stat-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
@media (min-width: 600px) { .stat-label { font-size: 11px; } }
.stat-value {
  font-size: 22px;
  font-weight: 600;
  overflow-wrap: break-word;
}
@media (min-width: 600px) { .stat-value { font-size: 28px; } }
.stat-value.pos { color: var(--pos); }
.stat-value.neg { color: var(--neg); }
.stat-sub { font-size: 10px; color: var(--text-dim); margin-top: 4px; word-break: break-word; }
.stat-help {
  font-size: 10px;
  color: var(--text-dim);
  opacity: 0.7;
  margin-top: 4px;
  line-height: 1.3;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0 16px 12px;
  padding: 12px;
  min-width: 0;
  overflow: hidden;
}
@media (min-width: 600px) {
  .card {
    margin: 0 24px 16px;
    padding: 16px;
  }
}
.card h2 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--gold);
}
.help {
  font-size: 11px;
  color: var(--text-dim);
  margin: 0 0 12px;
  line-height: 1.4;
}
@media (min-width: 600px) { .help { font-size: 12px; } }

/* TABLES: scrollable INSIDE their card. The card has overflow:hidden
   so the table cannot push the page wider than viewport. */
.card table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}
@media (min-width: 600px) { .card table { font-size: 13px; } }

th, td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
@media (min-width: 600px) { th, td { padding: 8px 10px; } }
th {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}
@media (min-width: 600px) { th { font-size: 11px; } }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--text-dim); opacity: 0.7; }
.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 20px;
  font-style: italic;
  white-space: normal;
}

.status-filled { color: var(--pos); font-weight: 600; }
.status-rejected { color: var(--neg); font-weight: 600; }
.status-accepted { color: var(--warn); }
.status-submitted { color: var(--text-dim); }
.reason {
  font-size: 10px;
  color: var(--text-dim);
  max-width: 240px;
  white-space: normal;
  word-break: break-word;
}

#locks ul { padding-left: 16px; margin: 0; }
#locks li { padding: 4px 0; font-size: 12px; word-break: break-word; white-space: normal; }

#bootReport {
  background: var(--card-2);
  padding: 10px;
  border-radius: 4px;
  font-size: 10px;
  color: var(--text-dim);
  overflow: auto;
  max-height: 240px;
  white-space: pre;
}
@media (min-width: 600px) {
  #bootReport { font-size: 11px; padding: 12px; }
}

/* Manual paste-to-trade panel (v0.9.7) */
#manualCard textarea {
  width: 100%; box-sizing: border-box; font-family: monospace; font-size: 13px;
  padding: 8px; border: 1px solid #ccc; border-radius: 6px; resize: vertical;
}
.manual-controls { display: flex; align-items: center; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
.manual-result {
  white-space: pre-wrap; font-family: monospace; font-size: 13px; padding: 10px;
  border-radius: 6px; background: #f5f5f5; min-height: 12px; margin: 0;
}
.manual-result.good { background: #e8f5e9; color: #1b5e20; }
.manual-result.bad  { background: #ffebee; color: #b71c1c; }

/* Panic button (v0.9.8) */
button.panic {
  background: #b71c1c; color: #fff; font-weight: bold; border: none;
  padding: 8px 18px; border-radius: 6px; cursor: pointer; margin-left: auto;
}
button.panic:hover { background: #d32f2f; }
.panic-result { font-family: monospace; font-size: 13px; padding: 0; margin: 6px 0 0; }
.panic-result.active { padding: 8px; background: #fff3e0; color: #e65100; border-radius: 6px; }
.panic-result.good { padding: 8px; background: #e8f5e9; color: #1b5e20; border-radius: 6px; }
.panic-result.bad  { padding: 8px; background: #ffebee; color: #b71c1c; border-radius: 6px; font-weight: bold; }

/* Reset history button (v0.9.16) */
button.reset-btn {
  background: #37474f; color: #fff; border: none; padding: 6px 14px;
  border-radius: 6px; cursor: pointer; font-size: 13px;
}
button.reset-btn:hover { background: #455a64; }

/* Manual-only badge (v0.9.17) */
.manual-only-badge {
  display: inline-block; background: #1b3a2f; color: #6ee7a8; padding: 8px 14px;
  border-radius: 6px; font-size: 13px; font-weight: 600; border: 1px solid #2e5e4a;
}

/* Live open trades card */
.live-trades { display: flex; flex-direction: column; gap: 12px; }
.live-trade {
  background: #11161c; border: 1px solid #243040; border-radius: 10px;
  padding: 14px 16px; border-left: 4px solid #3b82f6;
}
.live-trade.long { border-left-color: #34d399; }
.live-trade.short { border-left-color: #f87171; }
.lt-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.lt-sym { font-size: 16px; font-weight: 700; color: #e6edf3; }
.lt-dir { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 4px; margin-left: 6px; vertical-align: middle; }
.lt-dir.long { background: #0e3a2a; color: #34d399; }
.lt-dir.short { background: #3a1416; color: #f87171; }
.lt-pnl { font-size: 18px; font-weight: 700; }
.lt-pnl.pos { color: #34d399; }
.lt-pnl.neg { color: #f87171; }
.lt-prices { display: flex; gap: 16px; font-size: 13px; color: #9aa7b5; margin-bottom: 10px; }
.lt-prices b { color: #e6edf3; }
.lt-bar { height: 6px; background: #1f2937; border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.lt-bar-fill { height: 100%; background: linear-gradient(90deg, #3b82f6, #34d399); transition: width 0.6s ease; }

/* next-floor target block */
.lt-floor { margin-top: 8px; padding: 9px 11px; border-radius: 6px; font-size: 12px; border: 1px solid #2a3340; background: #12161d; }
.lt-floor.pending { border-color: rgba(212,175,55,0.4); background: rgba(212,175,55,0.06); }
.lt-floor.locked  { border-color: rgba(52,211,153,0.4); background: rgba(52,211,153,0.08); }
.lt-floor-head { font-weight: 600; color: #e8eaf0; margin-bottom: 6px; }
.lt-floor.pending .lt-floor-head b { color: var(--gold); }
.lt-floor.locked .lt-floor-head { color: #a7f3d0; }
.lt-floor-sub { color: #8b95a3; line-height: 1.45; }
.lt-floor-sub b { color: #cdd3dc; }
.lt-floor-bar { height: 6px; background: #1a1f27; border-radius: 4px; overflow: hidden; margin-bottom: 6px; }
.lt-floor-fill { height: 100%; background: linear-gradient(90deg, #d4af37, #f0d060); transition: width 0.6s ease; }

/* both-directions level lines: floor (up) and stop (down) */
.lt-lvl { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 8px; padding: 5px 0; font-size: 12px; }
.lt-lvl-k { font-weight: 600; }
.lt-lvl.up .lt-lvl-k { color: #34d399; }
.lt-lvl.down .lt-lvl-k { color: #f87171; }
.lt-lvl-v { font-weight: 700; color: #e8eaf0; font-variant-numeric: tabular-nums; }
.lt-lvl-d { color: #8b95a3; text-align: right; font-variant-numeric: tabular-nums; }
.lt-floor-prog { font-size: 11px; color: #8b95a3; margin-top: 4px; }
.lt-foot { display: flex; justify-content: space-between; font-size: 11px; color: #7d8895; }
.lt-broker { font-size: 11px; color: #5b6573; margin-top: 8px; text-transform: uppercase; letter-spacing: 0.4px; }

/* secured profit line on live trade card */
.lt-secured { margin-top: 8px; padding: 8px 10px; border-radius: 6px; font-size: 12px;
  background: #0e3a2a; color: #6ee7a8; border: 1px solid #1f5e44; }
.lt-secured b { color: #a7f3d0; font-size: 14px; }
.lt-secured.none { background: #1a1f27; color: #7d8895; border-color: #2a3340; }

/* clearer secured-profit block */
.lt-secured-big { font-size: 15px; font-weight: 700; }
.lt-secured-sub { font-size: 11px; margin-top: 3px; opacity: 0.9; }
.lt-secured.win { background: #0e3a2a; color: #6ee7a8; border: 1px solid #1f5e44; }
.lt-secured.win .lt-secured-big { color: #a7f3d0; }
.lt-secured.be { background: #10243a; color: #93c5fd; border: 1px solid #1e4060; }
.lt-secured.be .lt-secured-big { color: #bfdbfe; }
.lt-secured.none { background: #1a1f27; color: #8b95a3; border: 1px solid #2a3340; }
.lt-managed.yes { color: #6ee7a8; font-weight: 600; }
.lt-managed.no { color: #f0a868; font-weight: 600; }

/* capital line on live trade card */
.lt-capital { font-size: 12px; color: #9aa7b5; margin: 6px 0; }
.lt-capital-note { font-size: 10.5px; color: #6b7785; margin-top: 2px; font-style: italic; }
.lt-trail { font-size: 12px; color: #4ade80; margin: 6px 0; padding: 6px 9px; background: rgba(74,222,128,0.08); border-radius: 6px; border-left: 2px solid #4ade80; }
.lt-trail.idle { color: #9aa7b5; background: rgba(154,167,181,0.06); border-left-color: #5a6776; }
.lt-capital b { color: #e6edf3; }
.lt-capital .pos { color: #34d399; font-weight: 700; }
.lt-capital .neg { color: #f87171; font-weight: 700; }

/* Per-trade close button (close one trade, let others run) */
.lt-actions { margin-top: 10px; display: flex; justify-content: flex-end; }
.lt-close-btn {
  background: #7f1d1d; color: #fecaca; border: 1px solid #b91c1c;
  border-radius: 6px; padding: 7px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.lt-close-btn:hover { background: #991b1b; color: #fff; }
.lt-close-btn:disabled { opacity: .7; cursor: default; }

/* locked-in profit badge next to live P&L on the trade card */
.lt-pnl-locked {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.72em;
  font-weight: 700;
  color: #0a7d34;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 6px;
  padding: 1px 6px;
  vertical-align: middle;
}

/* three-part clarity band on the trade card: walk-away / loss-at-stop / to-floor */
.lt-clarity {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0;
  padding: 10px;
  background: rgba(15, 23, 42, 0.03);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 10px;
}
.lt-clar-item { display: flex; flex-direction: column; gap: 3px; text-align: center; }
.lt-clar-k { font-size: 0.68em; text-transform: uppercase; letter-spacing: 0.03em; color: #64748b; }
.lt-clar-v { font-size: 0.95em; }
.lt-clar-v .pos { color: #0a7d34; }
.lt-clar-v .neg { color: #b91c1c; }
.lt-clar-v .muted { color: #94a3b8; }
@media (max-width: 480px) {
  .lt-clarity { gap: 4px; padding: 8px 6px; }
  .lt-clar-k { font-size: 0.6em; }
  .lt-clar-v { font-size: 0.82em; }
}
