/* ─────────────────────────────────────────────────────────────────────────────
   OptionsDesk · Paper Trading Platform · style.css
   Aesthetic: Dark terminal / Bloomberg-style trading terminal
   Fonts: Syne (headings) + IBM Plex Mono (data/numbers)
   ───────────────────────────────────────────────────────────────────────────── */

/* ── Reset & Variables ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0a0c0f;
  --bg2:         #10131a;
  --bg3:         #161b25;
  --border:      #1e2535;
  --border2:     #2a3349;
  --text:        #c8d0e0;
  --text-dim:    #5a6480;
  --text-bright: #edf2ff;
  --accent:      #00d4aa;        /* teal – profit / buy */
  --accent2:     #4f7fff;        /* blue – neutral */
  --loss:        #ff4d6a;        /* red – loss / sell */
  --warn:        #ffa94d;        /* orange – warning */
  --atm-bg:      rgba(79,127,255,.08);
  --atm-border:  #4f7fff;
  --font-head:   'Syne', sans-serif;
  --font-mono:   'IBM Plex Mono', monospace;
  --radius:      6px;
  --radius-lg:   10px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Subtle grid texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.015) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* ── Top Bar ────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: rgba(10,12,15,.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.logo {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--text-bright);
}
.logo em {
  font-style: normal;
  color: var(--accent);
}

.tag {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--accent2);
  background: rgba(79,127,255,.1);
  border: 1px solid rgba(79,127,255,.3);
  border-radius: 4px;
  padding: 2px 8px;
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 0;
}

.index-ticker {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 0 20px;
}

.ticker-label {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--text-dim);
}

.ticker-price {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-bright);
  min-width: 80px;
}

.ticker-atm {
  font-size: 11px;
  color: var(--accent2);
  background: rgba(79,127,255,.1);
  padding: 1px 6px;
  border-radius: 3px;
}

.ticker-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Pulsing dot */
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.pulse-dot.live {
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(0,212,170,.4);
  animation: pulse-ring 2s infinite;
}
.pulse-dot.error { background: var(--loss); }

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(0,212,170,.4); }
  70%  { box-shadow: 0 0 0 8px rgba(0,212,170,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,212,170,0); }
}

.status-text { font-size: 11px; color: var(--text-dim); letter-spacing: .04em; }
.clock       { font-size: 12px; color: var(--text-bright); letter-spacing: .06em; }

/* ── Main Grid ──────────────────────────────────────────────────────────── */
.grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  min-height: calc(100vh - 56px);
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.card-title {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-title-row .card-title { margin-bottom: 0; }

/* ── Strategy Rows ──────────────────────────────────────────────────────── */
.strategy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--bg2);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  transition: border-color .2s;
}
.strategy-row.active { border-color: var(--accent); }

.strat-info { display: flex; align-items: center; gap: 10px; }
.strat-label { font-size: 12px; font-weight: 600; color: var(--text-bright); letter-spacing: .06em; }

.strat-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(90,100,128,.2);
  color: var(--text-dim);
}
.strat-badge.on {
  background: rgba(0,212,170,.12);
  color: var(--accent);
  border: 1px solid rgba(0,212,170,.3);
}

/* Toggle Switch */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  inset: 0;
  background: var(--border2);
  border-radius: 22px;
  transition: background .2s;
}
.slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform .2s, background .2s;
}
.toggle input:checked + .slider { background: rgba(0,212,170,.25); }
.toggle input:checked + .slider::before {
  transform: translateX(18px);
  background: var(--accent);
}

/* ── Checkbox / Radio Groups ────────────────────────────────────────────── */
.check-group, .radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.check-row, .radio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.check-row input, .radio-row input { accent-color: var(--accent); cursor: pointer; }

/* ── Form Elements ──────────────────────────────────────────────────────── */
.input-select, .input-field {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text-bright);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 7px 10px;
  outline: none;
  transition: border-color .2s;
  width: 100%;
}
.input-select:focus, .input-field:focus { border-color: var(--accent2); }
.input-select { cursor: pointer; }
.input-field.sm, .input-select.sm { font-size: 11px; padding: 5px 8px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.form-grid .btn-execute { grid-column: 1 / -1; }

.settings-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  align-items: center;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-execute {
  background: linear-gradient(135deg, rgba(0,212,170,.2), rgba(0,212,170,.05));
  border: 1px solid rgba(0,212,170,.4);
  color: var(--accent);
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  padding: 9px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .2s, box-shadow .2s;
  width: 100%;
}
.btn-execute:hover {
  background: rgba(0,212,170,.2);
  box-shadow: 0 0 12px rgba(0,212,170,.2);
}

.btn-save {
  background: rgba(79,127,255,.1);
  border: 1px solid rgba(79,127,255,.3);
  color: var(--accent2);
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  width: 100%;
  transition: background .2s;
}
.btn-save:hover { background: rgba(79,127,255,.2); }

.btn-close-trade {
  background: rgba(255,77,106,.1);
  border: 1px solid rgba(255,77,106,.3);
  color: var(--loss);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
  font-family: var(--font-mono);
}
.btn-close-trade:hover { background: rgba(255,77,106,.2); }

/* ── Content Area ───────────────────────────────────────────────────────── */
.content {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

/* ── Stats Row ──────────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card.highlight-pnl { border-color: var(--border2); }

.stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--text-dim);
}

.stat-value {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-bright);
  line-height: 1.2;
}
.stat-value.profit { color: var(--accent); }
.stat-value.loss   { color: var(--loss); }

/* ── Chart ──────────────────────────────────────────────────────────────── */
.chart-card { }
.chart-sub { font-size: 10px; color: var(--text-dim); letter-spacing: .06em; }
.chart-wrap { height: 220px; position: relative; }

/* ── Option Chain Snapshot ──────────────────────────────────────────────── */
.chain-tabs { display: flex; gap: 6px; }
.tab {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text-dim);
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all .15s;
}
.tab.active {
  background: rgba(79,127,255,.12);
  border-color: var(--accent2);
  color: var(--accent2);
}

.chain-table-wrap {
  overflow-x: auto;
  max-height: 280px;
  overflow-y: auto;
}

.chain-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.chain-table th {
  position: sticky;
  top: 0;
  background: var(--bg2);
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: .06em;
  font-size: 10px;
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  z-index: 2;
}
.chain-table th.strike-col, .chain-table td.strike-col {
  text-align: center;
  background: var(--bg2);
  color: var(--text-bright);
  font-weight: 600;
}
.chain-table th.price-col, .chain-table td.price-col {
  color: var(--text-bright);
  font-weight: 500;
}

.chain-table td {
  padding: 6px 10px;
  text-align: right;
  border-bottom: 1px solid rgba(30,37,53,.6);
  color: var(--text);
}

.chain-table tr.atm-row { background: var(--atm-bg); }
.chain-table tr.atm-row td { border-top: 1px solid var(--atm-border); border-bottom: 1px solid var(--atm-border); }
.chain-table tr.atm-row td.strike-col { color: var(--accent2); }

.chain-table tr:hover td { background: rgba(255,255,255,.02); }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.trade-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.trade-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--text-dim);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.trade-table td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(30,37,53,.6);
  vertical-align: middle;
  white-space: nowrap;
}
.trade-table tr:last-child td { border-bottom: none; }
.trade-table tr:hover td { background: rgba(255,255,255,.018); }

.pnl-pos { color: var(--accent); font-weight: 600; }
.pnl-neg { color: var(--loss);   font-weight: 600; }
.pnl-zero { color: var(--text-dim); }

.type-ce { color: var(--accent);  font-weight: 600; }
.type-pe { color: var(--warn);    font-weight: 600; }

.strategy-a { color: var(--accent2); font-size: 11px; }
.strategy-b { color: var(--warn);    font-size: 11px; }
.strategy-m { color: var(--text-dim); font-size: 11px; }

.loading-cell {
  text-align: center;
  color: var(--text-dim);
  padding: 24px !important;
  font-size: 12px;
  letter-spacing: .04em;
}

.count-badge {
  background: rgba(79,127,255,.15);
  color: var(--accent2);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 24px;
  text-align: center;
}

.filter-row { display: flex; gap: 8px; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  font-size: 12px;
  color: var(--text-bright);
  z-index: 999;
  opacity: 0;
  transform: translateY(12px);
  transition: all .25s;
  pointer-events: none;
  max-width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: rgba(0,212,170,.4); color: var(--accent); }
.toast.error   { border-color: rgba(255,77,106,.4); color: var(--loss); }
.toast.info    { border-color: rgba(79,127,255,.4);  color: var(--accent2); }

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a4560; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .grid { grid-template-columns: 260px 1fr; }
  .stats-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .topbar-center { display: none; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}