
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background:
    radial-gradient(ellipse at 50% 0%, #0f140f 0%, #0a0a0a 55%, #050505 100%);
  color: #33ff33;
  font-family: "SF Mono", "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, "Courier New", Courier, monospace;
  min-height: 100vh;
  position: relative;
}

/* Faint CRT scanline texture over the whole app -- pointer-events:none so
   it never intercepts clicks, just adds atmosphere. Kept very low-opacity
   on purpose; this is meant to be felt, not seen. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(51, 255, 51, 0.035) 0px,
      rgba(51, 255, 51, 0.035) 1px,
      transparent 1px,
      transparent 3px
    );
  mix-blend-mode: screen;
}

/* ===== NAVIGATION BAR ===== */
.nav-bar {
  background: #0d0d0d;
  border-bottom: 2px solid #33ff33;
  box-shadow: 0 1px 12px #33ff3355, 0 1px 0 #000;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
}
.nav-btn {
  flex: 1;
  padding: 14px 10px;
  background: #111;
  border: none;
  border-right: 1px solid #33ff33;
  color: #33ff33;
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 0.03em;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}
.nav-btn:last-child { border-right: none; }
.nav-btn:hover { background: #1a1a1a; }
.nav-btn.active {
  background: #1a3a1a;
  font-weight: bold;
  text-decoration: underline;
  text-shadow: 0 0 8px currentColor;
  box-shadow: inset 0 -2px 0 currentColor;
}
.nav-status {
  display: block;
  font-size: 11px;
  margin-top: 2px;
}
.nav-status.on { color: #33ff33; }
.nav-status.off { color: #ff3333; }

/* Per-broker accent colors so the nav (and each page's frame) aren't all
   the same green -- Schwab=cyan, E*TRADE=magenta, Webull=orange, Console
   stays the base green since it's not a broker. */
.nav-btn-etrade { color: #cc66ff; border-right-color: #cc66ff; }
.nav-btn-etrade:hover { background: #2a1a3a; box-shadow: inset 0 0 16px #cc66ff33; }
.nav-btn-etrade.active { background: #2a1a3a; }
.nav-btn-webull { color: #ff9933; border-right-color: #ff9933; }
.nav-btn-webull:hover { background: #3a2a1a; box-shadow: inset 0 0 16px #ff993333; }
.nav-btn-webull.active { background: #3a2a1a; }
.nav-btn-schwab { color: #33ffff; border-right-color: #33ffff; }
.nav-btn-schwab:hover { background: #1a3a3a; box-shadow: inset 0 0 16px #33ffff33; }
.nav-btn-schwab.active { background: #1a3a3a; }

/* ===== PAGE CONTAINER ===== */
.page {
  display: none;
  padding: 10px 15px;
  max-width: 1400px;
  margin: 0 auto;
}
.page.active { display: block; }

/* ===== TERMINAL FRAME ===== */
.terminal-frame {
  border: 2px solid #33ff33;
  box-shadow: 0 0 24px #33ff3322, inset 0 0 40px #33ff3308;
  padding: 15px 12px 12px;
  position: relative;
  margin-top: 12px; /* space for the top label */
}
.terminal-frame::before {
  content: attr(data-title);
  position: absolute;
  top: -11px;
  left: 20px;
  background: #0a0a0a;
  padding: 0 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  color: #33ff33;
  font-weight: bold;
  text-shadow: 0 0 6px currentColor;
}

.terminal-frame-etrade { border-color: #cc66ff; box-shadow: 0 0 24px #cc66ff22, inset 0 0 40px #cc66ff08; }
.terminal-frame-etrade::before { color: #cc66ff; }
.terminal-frame-webull { border-color: #ff9933; box-shadow: 0 0 24px #ff993322, inset 0 0 40px #ff993308; }
.terminal-frame-webull::before { color: #ff9933; }
.terminal-frame-schwab { border-color: #33ffff; box-shadow: 0 0 24px #33ffff22, inset 0 0 40px #33ffff08; }
.terminal-frame-schwab::before { color: #33ffff; }

/* ===== CONTROLS ===== */
.control-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid #33ff33;
  margin-bottom: 10px;
  background: #0d0d0d;
  font-size: 11px;
}
.status-badge {
  padding: 4px 12px;
  font-weight: bold;
  font-size: 11px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: box-shadow 0.3s ease;
}
.badge-connected { background: #1a3a1a; color: #33ff33; border: 1px solid #33ff33; animation: badge-breathe-green 2.4s ease-in-out infinite; }
.badge-disconnected { background: #3a1a1a; color: #ff3333; border: 1px solid #ff3333; }
.badge-connecting { background: #3a3a1a; color: #ffff33; border: 1px solid #ffff33; animation: badge-breathe-yellow 1s ease-in-out infinite; }
.badge-not-configured { background: #3a2a1a; color: #ffaa33; border: 1px solid #ffaa33; }
@keyframes badge-breathe-green { 0%, 100% { box-shadow: 0 0 2px #33ff3355; } 50% { box-shadow: 0 0 10px #33ff33aa; } }
@keyframes badge-breathe-yellow { 0%, 100% { box-shadow: 0 0 2px #ffff3355; } 50% { box-shadow: 0 0 10px #ffff33aa; } }

button, input, select, textarea {
  background: #111;
  border: 1px solid #33ff33;
  color: #33ff33;
  font-family: inherit;
  padding: 4px 8px;
  font-size: 11px;
  margin: 0;
  vertical-align: middle;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
/* ===== CUSTOM DATE PICKER ===== */
.date-picker-wrap { display: inline-flex; align-items: center; gap: 0; }
.date-picker-wrap input { width: 95px; cursor: default; }
.cal-open-btn { padding: 4px 6px; margin: 0 0 0 2px; font-size: 11px; cursor: pointer; border-left: none; }
.cal-popup {
  display: none;
  position: fixed;
  z-index: 9999;
  background: #0a0a0a;
  border: 2px solid #33ff33;
  padding: 8px;
  min-width: 210px;
  box-shadow: 0 0 16px #33ff3333;
  font-size: 11px;
}
.cal-popup.open { display: block; }
.cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.cal-header button { padding: 2px 7px; margin: 0; font-size: 12px; font-weight: bold; }
.cal-month-label { font-weight: bold; letter-spacing: 0.05em; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-day-hdr { font-size: 9px; color: #999; padding: 2px 0; }
.cal-day {
  padding: 4px 2px;
  cursor: pointer;
  border: 1px solid transparent;
  font-size: 10px;
}
.cal-day:hover { border-color: #33ff33; background: #1a3a1a; }
.cal-day.empty { cursor: default; }
.cal-day.empty:hover { border-color: transparent; background: transparent; }
.cal-day.today { color: #ffff33; font-weight: bold; }
.cal-day.selected { background: #33ff33; color: #000; font-weight: bold; border-color: #33ff33; }
button { cursor: pointer; white-space: nowrap; }
button:hover:not(:disabled) { background: #33ff33; color: #000; box-shadow: 0 0 10px #33ff3388; }
button:active:not(:disabled) { transform: translateY(1px) scale(0.98); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.loading { animation: pulse 0.8s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #66ff66;
  box-shadow: 0 0 0 1px #66ff6655, 0 0 10px #33ff3355;
}

/* ===== SECTIONS ===== */
.section { margin: 8px 0; }
.section-header {
  border: 1px solid #33ff33;
  padding: 5px 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #111;
  user-select: none;
  font-size: 11px;
  letter-spacing: 0.05em;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.section-header:hover { background: #1a1a1a; box-shadow: inset 0 0 14px #33ff3322; }
.toggle-icon { font-size: 14px; transition: transform 0.2s; }
.section-header.collapsed .toggle-icon { transform: rotate(-90deg); }
.section-body {
  border: 1px solid #33ff33;
  border-top: none;
  padding: 8px;
  animation: section-open 0.15s ease;
}
.section-body.hidden { display: none; }
@keyframes section-open { from { opacity: 0; } to { opacity: 1; } }

/* ===== GRID LAYOUTS ===== */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.panel {
  border: 1px solid #33ff33;
  padding: 6px;
  min-height: 120px;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}
.panel:hover { box-shadow: 0 0 14px #33ff3322; }
.panel-title {
  text-align: center;
  font-weight: bold;
  letter-spacing: 0.06em;
  border-bottom: 1px dashed #33ff33;
  padding-bottom: 3px;
  margin-bottom: 5px;
  font-size: 11px;
  text-shadow: 0 0 6px #33ff3355;
}

/* ===== BALANCE ===== */
.balance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px; }
.balance-card {
  border: 1px dashed #33ff33;
  padding: 8px;
  text-align: center;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.balance-card:hover { box-shadow: 0 0 12px #33ff3333; border-style: solid; }
.bal-label { font-size: 9px; color: #999; letter-spacing: 0.04em; }
.bal-value { font-size: 16px; font-weight: bold; margin-top: 3px; text-shadow: 0 0 8px currentColor; }
.bal-value-primary { color: #33ffff; }
.positive { color: #33ff33; }
.negative { color: #ff3333; }
.not-configured { color: #ffaa33; text-align: center; padding: 10px; font-size: 10px; }

/* ===== CONSOLE: QUICK STATS / JOURNAL / LIVE QUOTES / CHART / LAST EVENT ===== */
.stats-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 6px; }
.stats-card { border: 1px dashed #33ff33; padding: 8px; text-align: center; transition: box-shadow 0.2s ease, border-style 0.2s ease; }
.stats-card:hover { box-shadow: 0 0 12px #33ff3333; border-style: solid; }
.stats-winrate { color: #ffcc33; }
/* Rotating card-border accent so the stats bar isn't a wall of identical
   dashed-green boxes. */
.stats-card:nth-child(6n+1) { border-color: #ffcc33; }
.stats-card:nth-child(6n+2) { border-color: #33ffff; }
.stats-card:nth-child(6n+3) { border-color: #ff66ff; }
.stats-card:nth-child(6n+4) { border-color: #33ff33; }
.stats-card:nth-child(6n+5) { border-color: #ff9933; }
.stats-card:nth-child(6n+6) { border-color: #66aaff; }

.journal-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.journal-filters select, .journal-filters input { font-size: 11px; }

.quotes-grid { width: 100%; border-collapse: collapse; font-size: 11px; }
.quotes-grid th, .quotes-grid td { border: 1px solid #33ff33; padding: 5px 8px; text-align: center; }
.quotes-grid th { background: #1a1a1a; }
.quotes-grid td:first-child { color: #ffcc33; font-weight: bold; }
.quotes-grid tr.tick-up td { animation: tick-flash-up 0.8s ease-out; }
.quotes-grid tr.tick-down td { animation: tick-flash-down 0.8s ease-out; }
@keyframes tick-flash-up { 0% { background: #1a3a1a; } 100% { background: transparent; } }
@keyframes tick-flash-down { 0% { background: #3a1a1a; } 100% { background: transparent; } }

.chart-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.chart-controls select { font-size: 11px; }
.chart-frame { border: 1px dashed #33ff33; background: #050505; box-shadow: inset 0 0 20px #33ff3311; width: 100%; height: 190px; display: block; }

.journal-note-cell { padding: 3px 6px !important; }
.journal-note-input { width: 160px; font-size: 10px; padding: 3px 5px; }
.journal-note-input:not(:placeholder-shown) { border-color: #ffcc33; color: #ffcc33; }

.last-event-box {
  border: 1px dashed #33ff33;
  box-shadow: inset 0 0 14px #33ff3311;
  padding: 8px;
  font-size: 11px;
  white-space: nowrap;
  overflow-x: auto;
  transition: box-shadow 0.3s ease;
}

/* ===== FORM ===== */
.form-grid { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; }
.form-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.form-row label { font-size: 10px; min-width: 80px; }

/* ===== TABLE ===== */
.table-wrap { max-height: 350px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th, table td { border: 1px solid #33ff33; padding: 6px 9px; text-align: center; white-space: nowrap; }
table th { background: #1a1a1a; position: sticky; top: 0; z-index: 1; letter-spacing: 0.03em; text-shadow: 0 0 4px #33ff3355; }
table tbody tr { transition: background 0.1s ease; }
table tbody tr:hover { background: #16241a; }
table tbody tr:nth-child(even) { background: #0d120d; }
table tbody tr:nth-child(even):hover { background: #16241a; }
.action-btns button { font-size: 9px; padding: 2px 4px; min-width: 28px; margin: 1px; }

/* Semantic colors for the per-contract action buttons -- buy/sell/trail/
   stop/cancel/remove used to all be the same green outline, making the
   row unreadable at a glance. */
.btn-buy { border-color: #33ff33; color: #33ff33; }
.btn-buy:hover:not(:disabled) { background: #33ff33; color: #000; box-shadow: 0 0 10px #33ff3388; }
.btn-sell { border-color: #ff9933; color: #ff9933; }
.btn-sell:hover:not(:disabled) { background: #ff9933; color: #000; box-shadow: 0 0 10px #ff993388; }
.btn-trail { border-color: #33ffff; color: #33ffff; }
.btn-trail:hover:not(:disabled) { background: #33ffff; color: #000; box-shadow: 0 0 10px #33ffff88; }
.btn-mult { border-color: #ffcc33; color: #ffcc33; }
.btn-mult:hover:not(:disabled) { background: #ffcc33; color: #000; box-shadow: 0 0 10px #ffcc3388; }
.btn-stop { border-color: #ff66ff; color: #ff66ff; }
.btn-stop:hover:not(:disabled) { background: #ff66ff; color: #000; box-shadow: 0 0 10px #ff66ff88; }
.btn-cancel { border-color: #ff3333; color: #ff3333; }
.btn-cancel:hover:not(:disabled) { background: #ff3333; color: #fff; box-shadow: 0 0 10px #ff333388; }
.btn-bot-on { border-color: #33ff33; color: #33ff33; font-weight: bold; }
.btn-bot-off { border-color: #999999; color: #999999; }
.btn-remove { border-color: #ff3333; color: #ff3333; }
.btn-remove:hover:not(:disabled) { background: #ff3333; color: #fff; box-shadow: 0 0 10px #ff333388; }

/* ===== ALERT CONSOLE ===== */
.alert-console {
  width: 100%;
  height: 100px;
  background: #000;
  border: 1px solid #33ff33;
  box-shadow: inset 0 0 16px #33ff3315;
  color: #33ff33;
  font-family: inherit;
  font-size: 12px;
  padding: 4px;
  resize: vertical;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ===== API RESPONSE ===== */
.response-box {
  background: #000;
  border: 1px dashed #33ff33;
  padding: 6px;
  font-size: 9px;
  height: 80px;
  min-height: 80px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  resize: vertical;
}

/* ===== SCROLLBARS ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #0a0a0a; }
::-webkit-scrollbar-thumb { background: #33ff33; box-shadow: 0 0 6px #33ff3388; }
::-webkit-scrollbar-thumb:hover { background: #66ff66; }

/* ===== CONSOLE PAGE ===== */
.console-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid #33ff33;
  margin-bottom: 10px;
  background: #0d0d0d;
  font-size: 14px;
}
.console-toolbar input { width: 200px; }
.console-section { margin-bottom: 14px; }
.console-section-title {
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 0.08em;
  border-bottom: 1px dashed #33ff33;
  padding-bottom: 4px;
  margin-bottom: 6px;
  text-shadow: 0 0 6px #33ff3355;
}
.signal-true  { color: #33ff33; font-weight: bold; }
.signal-false { color: #555; }
.val-bullish  { color: #33ff33; font-weight: bold; }
.val-bearish  { color: #ff3333; font-weight: bold; }
.val-neutral  { color: #ffff33; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .nav-btn { font-size: 12px; padding: 10px 5px; }
}
