/* ==========================================================================
   Antigravity Options Trader - Design System & Styling
   Glassmorphism & Sleek Dark theme aligned with FnO-Strategies
   ========================================================================== */

:root {
  --bg: #0a0e17;
  --card: rgba(22, 31, 49, 0.75);
  --card-hover: rgba(30, 42, 66, 0.85);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f1f3f9;
  --text-muted: #8a96a8;
  
  --call: #00d2ff;
  --call-bg: rgba(0, 210, 255, 0.08);
  --call-itm: rgba(0, 210, 255, 0.15);
  --put: #ff2d85;
  --put-bg: rgba(255, 45, 133, 0.08);
  --put-itm: rgba(255, 45, 133, 0.15);
  
  --green: #00e676;
  --green-bg: rgba(0, 230, 118, 0.15);
  --red: #ff1744;
  --red-bg: rgba(255, 23, 68, 0.15);
  
  --gold: #ff9100;
  --gold-bg: rgba(255, 145, 0, 0.15);
  
  --atm: #ffeb3b;
  --atm-bg: rgba(255, 235, 59, 0.1);
  
  --radius: 12px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  overflow-x: clip; /* clip: visually clips overflow without creating a scroll container,
                       so child elements (tables, tab bars) can still scroll horizontally.
                       overflow-x:hidden blocks child scroll on iOS Safari — clip does not. */
  max-width: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  min-height: 100vh;
  padding: 1.5rem;
  background-image:
    radial-gradient(circle at 10% 15%, rgba(0, 210, 255, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(255, 45, 133, 0.04) 0%, transparent 40%);
  background-attachment: fixed;
  overflow-x: clip;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.2);
}
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}

header {
  max-width: 1600px;
  margin: 0 auto 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}

.header-kpis {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.header-kpi-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  border-left: 1px solid var(--border);
  padding-left: 0.85rem;
}

.header-kpi-item:first-child {
  border-left: none;
  padding-left: 0;
}

.header-kpi-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.1rem;
}

.header-kpi-item .kpi-value {
  font-size: 0.95rem !important;
  font-weight: 700 !important;
  margin: 0 !important;
  font-feature-settings: "tnum";
}

.header-logo h1 {
  font-size: 1.75rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--call), var(--put));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.header-logo p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.ticker-container {
  display: flex;
  gap: 1rem;
}

.ticker-card {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 0.35rem 1rem;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 130px;
  transition: var(--transition);
}

.ticker-card:hover {
  transform: translateY(-1px);
  background: var(--card-hover);
  border-color: var(--text-muted);
}

.ticker-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.ticker-value {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-feature-settings: "tnum";
}

.ticker-change {
  font-size: 0.72rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.48rem 0.75rem;
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 500;
}

.user-badge span {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.user-badge strong {
  color: var(--call);
  font-weight: 700;
}


.btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn:hover {
  background: var(--card-hover);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, rgba(0, 210, 255, 0.2), rgba(255, 45, 133, 0.2));
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-primary:hover {
  background: linear-gradient(135deg, rgba(0, 210, 255, 0.3), rgba(255, 45, 133, 0.3));
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-danger {
  background: var(--red-bg);
  border-color: rgba(255, 23, 68, 0.3);
  color: #ff5274;
}

.btn-danger:hover {
  background: rgba(255, 23, 68, 0.25);
  border-color: var(--red);
}

main {
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.25rem;
}

/* Summary Card Grid */
.kpi-container {
  grid-column: span 12;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  backdrop-filter: blur(12px);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.5);
}

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

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0.4rem 0 0.2rem;
  font-feature-settings: "tnum";
}

.kpi-subtext {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Panels */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  backdrop-filter: blur(12px);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  padding-bottom: 0.5rem;
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 16px;
  background: linear-gradient(to bottom, var(--call), var(--put));
  border-radius: 2px;
}

/* Option Chain Column */
.option-chain-panel {
  grid-column: span 6;
}

/* Order & History Column */
.sidebar-panel {
  grid-column: span 6;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Table styles */
.table-container {
  overflow-x: auto;
  border-radius: 8px;
}

.chain-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  text-align: right;
}

.chain-table th {
  background: rgba(14, 21, 35, 0.95);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.4rem 0.4rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.chain-table td {
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  vertical-align: middle;
  font-feature-settings: "tnum";
}

.chain-table tr:hover {
  background: rgba(255, 255, 255, 0.015) !important;
}

.chain-table .strike-col {
  background: rgba(16, 24, 40, 0.7);
  text-align: center;
  font-weight: 700;
  color: var(--text);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  width: 80px;
}

.chain-table .call-side {
  text-align: left;
}

/* ATM Highlight */
.chain-table tr.atm-row {
  background: var(--atm-bg) !important;
}

.chain-table tr.atm-row td.strike-col {
  color: var(--atm);
  box-shadow: inset 0 0 4px rgba(255, 235, 59, 0.2);
}

/* ITM Highlights */
.chain-table td.call-itm {
  background: var(--call-itm);
}

.chain-table td.put-itm {
  background: var(--put-itm);
}

.trade-actions {
  display: flex;
  gap: 0.25rem;
  justify-content: flex-end;
}

.trade-actions-left {
  display: flex;
  gap: 0.25rem;
  justify-content: flex-start;
}

.btn-xs {
  padding: 0.2rem 0.4rem;
  font-size: 0.7rem;
  border-radius: 4px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  color: #000;
  transition: var(--transition);
}

.btn-xs-buy {
  background: #2b4478;
  color: #cbd5e1;
  border: 1px solid rgba(59, 130, 246, 0.25);
}
.btn-xs-buy:hover {
  background: #3b5a9a;
  color: #f1f5f9;
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.25);
}

.btn-xs-sell {
  background: #7f2d2d;
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.btn-xs-sell:hover {
  background: #991b1b;
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.5);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.25);
}

/* Form Styles */
.form-group {
  margin-bottom: 0.85rem;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  font-weight: 500;
}

.form-input {
  width: 100%;
  background: rgba(14, 21, 35, 0.8);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  transition: var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--call);
  box-shadow: 0 0 6px rgba(0, 210, 255, 0.2);
}

.order-summary-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
}

.order-summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.order-summary-row:last-child {
  margin-bottom: 0;
  font-weight: 600;
  border-top: 1px solid rgba(255,255,255,0.05);
  padding-top: 0.35rem;
}

/* Colors and values */
.pos { color: var(--green); }
.neg { color: var(--red); }
.warn { color: var(--gold); }

.pos-bg { background: var(--green-bg); color: #00ff88; }
.neg-bg { background: var(--red-bg); color: #ff5274; }

.fw6 {
  font-weight: 600;
}

/* Expiry Select */
.expiry-select {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

/* Positions & Trade book tables */
.pos-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  text-align: left;
}

.pos-table th {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
}

.pos-table td {
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  font-feature-settings: "tnum";
}

.pos-badge {
  display: inline-block;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 1rem;
  background: rgba(0,0,0,0.2);
  padding: 0.2rem;
  border-radius: 6px;
}

.tab {
  flex: 1;
  padding: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: var(--transition);
}

.tab.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* EOD Analytics List */
.eod-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 250px;
  overflow-y: auto;
}

.eod-item {
  background: rgba(255,255,255,0.01);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
}

/* Settings Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  justify-content: center;
  align-items: center;
}

.modal {
  background: #111827;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 90%;
  max-width: 450px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* Alerts and Banners */
.alert-banner {
  grid-column: span 12;
  background: var(--red-bg);
  border: 1px solid rgba(255, 23, 68, 0.25);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  display: none;
  align-items: center;
  justify-content: space-between;
  color: #ff5274;
}

.alert-banner button {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font-weight: 600;
}

.loader {
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border-top: 2px solid var(--call);
  width: 16px;
  height: 16px;
  animation: spin 1s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.5rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Flashing price change highlights */
@keyframes flash-up {
  0% { background: rgba(0, 230, 118, 0.25); }
  100% { background: transparent; }
}
@keyframes flash-down {
  0% { background: rgba(255, 23, 68, 0.25); }
  100% { background: transparent; }
}
.flash-up {
  animation: flash-up 1s forwards;
}
.flash-down {
  animation: flash-down 1s forwards;
}

/* Toast container & animations */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background-color: #161f31;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 320px;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: opacity 0.3s;
  font-size: 0.85rem;
}

@keyframes slideIn {
  from { transform: translateX(120%); }
  to { transform: translateX(0); }
}

.toast-success {
  border-left: 4px solid var(--green);
}

.toast-error {
  border-left: 4px solid var(--red);
}

.toast-info {
  border-left: 4px solid var(--call);
}

.toast-close {
  margin-left: auto;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
  font-size: 1rem;
}

.toast-close:hover {
  opacity: 1;
}

/* NAV growth Chart panel */
.chart-container {
  position: relative;
  height: 250px;
  width: 100%;
  margin-top: 5px;
}

/* ==========================================================================
   Backtester Styling Overrides
   ========================================================================== */
.backtester-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
  align-items: start;
}

.form-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--call);
  margin: 1.25rem 0 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.form-section-title:first-of-type {
  margin-top: 0;
}

.backtest-results-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.results-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.results-kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  backdrop-filter: blur(12px);
  transition: var(--transition);
}

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

.results-kpi-title {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.results-kpi-value {
  font-size: 1.25rem;
  font-weight: 700;
  font-feature-settings: "tnum";
}

.results-kpi-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.chart-panel {
  height: 380px;
}

.btn-run-backtest {
  background: linear-gradient(135deg, #00d2ff, #2563eb);
  color: #ffffff;
  border: none;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-run-backtest:hover {
  background: linear-gradient(135deg, #33d9ff, #3b82f6);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.btn-run-backtest:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.filter-tabs {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.2rem;
  border-radius: 6px;
  gap: 0.2rem;
}

.filter-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
}

.filter-tab.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.split-label-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.split-values {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  font-feature-settings: "tnum";
}

.form-range {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  accent-color: var(--call);
}

/* AI Recommendation Dial & News Feed Styling */
.sentiment-meter-track {
  width: 140px;
  height: 70px;
  border-top-left-radius: 70px;
  border-top-right-radius: 70px;
  border: 15px solid rgba(255, 255, 255, 0.05);
  border-bottom: 0;
  box-sizing: border-box;
  position: absolute;
  top: 15px;
  left: 0;
}

.sentiment-meter-needle {
  width: 6px;
  height: 55px;
  background: linear-gradient(to top, var(--call), var(--put));
  position: absolute;
  bottom: 55px;
  left: 67px;
  transform-origin: bottom center;
  border-radius: 3px;
  transition: transform 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 0 8px rgba(0, 210, 255, 0.4);
}

.news-card {
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.news-card:hover {
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateX(2px);
}

.news-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.news-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  text-decoration: none;
  transition: var(--transition);
}

.news-title:hover {
  color: var(--call);
}

.news-date {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.sentiment-tag {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  display: inline-block;
  white-space: nowrap;
}

.sentiment-tag.positive {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(0, 230, 118, 0.25);
}

.sentiment-tag.negative {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(255, 23, 68, 0.25);
}

.sentiment-tag.neutral {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.rec-leg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-feature-settings: "tnum";
}

.rec-leg-action {
  font-weight: 700;
  font-size: 0.72rem;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.rec-leg-action.buy {
  background: var(--green-bg);
  color: var(--green);
}

.rec-leg-action.sell {
  background: var(--red-bg);
  color: var(--red);
}

/* Connection status dot */
.connection-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  transition: background 0.3s, box-shadow 0.3s;
}

.connection-dot.connected {
  background: var(--green);
  box-shadow: 0 0 6px rgba(0, 230, 118, 0.7);
}

.connection-dot.disconnected {
  background: var(--red);
  box-shadow: 0 0 6px rgba(255, 23, 68, 0.7);
}

.connection-dot.disconnected::before,
.connection-dot.disconnected::after {
  content: '';
  position: absolute;
  width: 7px;
  height: 1.5px;
  background: #fff;
  top: 50%;
  left: 50%;
  border-radius: 1px;
}

.connection-dot.disconnected::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.connection-dot.disconnected::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* Hamburger menu button */
.hamburger-btn {
  padding: 0.35rem 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  line-height: 1;
}

.hamburger-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Dropdown user header */
.dropdown-user-header {
  padding: 0.5rem 1rem 0.45rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}

.dropdown-user-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  display: block;
}

.dropdown-user-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--call);
  margin-top: 0.1rem;
}

/* Actions Dropdown styling */
.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 115%;
  background: rgba(22, 31, 49, 0.95);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  z-index: 100;
  min-width: 175px;
  padding: 0.5rem 0;
}

.dropdown-item {
  display: flex;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0.6rem 1rem;
  text-align: left;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  align-items: center;
  gap: 0.5rem;
  box-sizing: border-box;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.dropdown-item.active {
  background: linear-gradient(135deg, rgba(0, 210, 255, 0.2), rgba(255, 45, 133, 0.2));
  color: var(--text);
  font-weight: 600;
}

.dropdown-item.active:hover {
  background: linear-gradient(135deg, rgba(0, 210, 255, 0.3), rgba(255, 45, 133, 0.3));
}

/* Compare Backtests modal */
.compare-better {
  background: rgba(0, 230, 118, 0.10);
  color: var(--green);
  font-weight: 600;
}
.compare-worse {
  color: var(--text-muted);
}
.compare-section-header td {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* Floating Nifty Spot Price Widget */
.floating-nifty-widget {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 999;
  background: rgba(14, 21, 35, 0.85);
  border: 1px solid var(--border);
  border-left: none;
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
  padding: 1rem 0.75rem 1rem 0.5rem;
  backdrop-filter: blur(16px);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transition: var(--transition);
  border-left: 3px solid var(--call);
}

.floating-nifty-widget:hover {
  background: rgba(22, 31, 49, 0.95);
  border-color: rgba(0, 210, 255, 0.3);
  border-left: 3px solid var(--call);
  transform: translateY(-50%) scale(1.03);
}

.floating-nifty-title {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.25rem;
}

.floating-nifty-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  font-feature-settings: "tnum";
  letter-spacing: 0.02em;
}

.floating-nifty-change {
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 0.15rem;
}

/* ── "What's the play?" section inside floating widget ── */
.floating-play-divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 0.55rem 0 0.45rem;
}

.floating-play-tab {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  padding: 0.1rem 0;
  width: 100%;
  user-select: none;
  transition: opacity 0.15s;
}
.floating-play-tab:hover { opacity: 0.8; }

.play-regime-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: box-shadow 0.2s;
}
.play-regime-dot.bullish { background: var(--pos); box-shadow: 0 0 5px var(--pos); }
.play-regime-dot.bearish { background: var(--neg); box-shadow: 0 0 5px var(--neg); }
.play-regime-dot.neutral { background: #f59e0b;    box-shadow: 0 0 5px #f59e0b; }

/* ── Quick play popup ── */
.play-popup {
  position: fixed;
  left: 132px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1002;
  background: rgba(11, 17, 30, 0.97);
  border: 1px solid rgba(0, 210, 255, 0.22);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  width: 310px;
  backdrop-filter: blur(22px);
  box-shadow: 6px 0 36px rgba(0,0,0,0.75);
  animation: playPopupIn 0.18s ease;
}
@keyframes playPopupIn {
  from { opacity: 0; transform: translateY(-50%) translateX(-10px); }
  to   { opacity: 1; transform: translateY(-50%) translateX(0);     }
}

.play-popup-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.popup-regime-badge {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  padding: 0.18rem 0.65rem;
  border-radius: 20px;
  text-transform: uppercase;
}
.popup-regime-badge.bullish { background: rgba(16,185,129,.18); color: var(--pos); border: 1px solid rgba(16,185,129,.35); }
.popup-regime-badge.bearish { background: rgba(239,68,68,.18);  color: var(--neg); border: 1px solid rgba(239,68,68,.35);  }
.popup-regime-badge.neutral { background: rgba(245,158,11,.18); color: #f59e0b;    border: 1px solid rgba(245,158,11,.35); }

.play-popup-summary {
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text);
  margin-bottom: 0.7rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--border);
}

.play-popup-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}

.play-metric-chip {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.35rem 0.55rem;
}
.play-metric-chip .chip-label {
  font-size: 0.58rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.play-metric-chip .chip-value {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 0.08rem;
}

.play-popup-strategy-box {
  background: rgba(0,210,255,0.05);
  border: 1px solid rgba(0,210,255,0.15);
  border-radius: 9px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.55rem;
}

.play-popup-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

/* Theoretical P&L table in recommendation page */
.paper-pnl-pos { color: var(--pos); font-weight: 700; }
.paper-pnl-neg { color: var(--neg); font-weight: 700; }
.paper-pnl-neutral { color: var(--text-muted); font-weight: 600; }

/* ==========================================================================
   Responsive — Tablet (≤ 900px) & Mobile (≤ 600px)
   ========================================================================== */

@media (max-width: 900px) {
  body { padding: 0.75rem; }

  /* Header: logo left, actions right */
  header { justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }
  .header-logo h1 { font-size: 1.3rem; }
  .header-actions { flex-shrink: 0; }

  /* Main grid → single column */
  main { grid-template-columns: 1fr; gap: 1rem; }
  /* Override inline grid-column: span N on all direct children */
  main > * { grid-column: 1 / -1 !important; }

  /* KPIs → 2 columns */
  .kpi-container { grid-template-columns: repeat(2, 1fr); }

  /* Trading view → single column, children full width */
  #trading-view { grid-template-columns: 1fr !important; gap: 1rem !important; }
  #trading-view > * { grid-column: 1 / -1 !important; }

  /* AI view → single column, children full width */
  #ai-recommendation-view { grid-template-columns: 1fr !important; gap: 1rem !important; }
  #ai-recommendation-view > div { grid-column: 1 / -1 !important; }

  /* Backtest layout */
  .backtester-layout { grid-template-columns: 1fr; }
  .results-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  body { padding: 0.5rem; }

  /* Header: single row with logo left, actions right */
  header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding-bottom: 0.6rem;
    margin-bottom: 0.6rem;
  }
  .header-logo h1 { font-size: 1.05rem; }
  .header-logo p { display: none; }

  .header-actions { width: auto; gap: 0.4rem; flex-shrink: 0; }

  main { gap: 0.6rem; }

  .kpi-container { gap: 0.5rem; }
  .kpi-card { padding: 0.75rem 0.85rem; }
  .kpi-value { font-size: 1.05rem; }
  .kpi-label { font-size: 0.6rem; }
  .kpi-subtext { font-size: 0.68rem; }

  /* Nav tabs: horizontal scroll strip */
  .nav-tabs-panel {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    padding: 0.4rem 0.6rem !important;
    gap: 0.4rem !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav-tabs-panel::-webkit-scrollbar { display: none; }
  .nav-tabs-panel .btn {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    font-size: 0.72rem !important;
    padding: 0.4rem 0.65rem !important;
  }

  .panel { padding: 0.8rem; }
  .panel-title { font-size: 0.88rem; }

  /* All scroll containers: force horizontal scroll to work on iOS */
  .table-container {
    width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
  }

  /* Option chain table: fit within viewport */
  .chain-table { font-size: 0.65rem; min-width: 540px !important; width: 100%; }
  .pos-table { min-width: 500px !important; }
  .chain-table th, .chain-table td { padding: 0.3rem 0.15rem; }
  .chain-table .call-side, .chain-table .put-side { width: 56px !important; }
  .btn-xs { padding: 0.18rem 0.28rem; font-size: 0.62rem; }
  .trade-actions, .trade-actions-left { gap: 0.15rem; }

  /* Position/trade tabs: horizontal scroll */
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: 0.2rem;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex-shrink: 0; font-size: 0.65rem; padding: 0.3rem 0.4rem; }

  /* Order form: stack 2-col field pairs */
  .form-grid-2col { grid-template-columns: 1fr !important; }

  /* All panel headers: wrap title + action button to avoid overflow */
  .panel-header { flex-wrap: wrap; gap: 0.5rem; }

  /* AI strategy card: inner legs/rationale grid → single column */
  .rec-inner-grid { grid-template-columns: 1fr !important; }

  /* Performance metrics → 2 columns (was 6) */
  .perf-metrics-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 0.5rem !important; padding: 0.75rem !important; }

  /* Floating Nifty widget: reposition to bottom-right on mobile */
  .floating-nifty-widget {
    left: auto;
    right: 0.75rem;
    top: auto;
    bottom: 4.5rem;
    transform: none;
    border-radius: 10px;
    border-left: none;
    border: 1px solid rgba(0, 210, 255, 0.2);
  }
  .floating-nifty-widget:hover { transform: none; }

  /* What's the play? popup: center on screen instead of anchored to sidebar */
  .play-popup {
    left: 50%;
    right: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: calc(100vw - 2rem);
    max-width: 340px;
    max-height: 85vh;
    overflow-y: auto;
  }

  /* Toast: anchor to bottom of screen */
  .toast-container { top: auto; bottom: 0.75rem; right: 0.5rem; left: 0.5rem; }
  .toast { min-width: unset; width: 100%; font-size: 0.8rem; }

  /* Backtester */
  .results-kpi-grid { gap: 0.5rem; }
  .results-kpi-card { padding: 0.75rem; }
  .results-kpi-value { font-size: 1.05rem; }

  /* AI Recommendation page */
  /* Shorten the Auto-Fill button text on narrow screens */
  #btn-trade-recommendation { font-size: 0.7rem !important; padding: 0.3rem 0.5rem !important; white-space: nowrap; }
  /* Hide the long subtitle in Paper Trade Tracking header */
  #ai-recommendation-view .panel-title > span { display: none; }
  /* Signal Analysis body: break long words, make pre/table blocks scrollable */
  #ai-analysis-body { overflow-wrap: break-word; word-break: break-word; }
  #ai-analysis-body pre { overflow-x: auto; white-space: pre-wrap; word-break: break-word; max-width: 100%; }
  #ai-analysis-body table { overflow-x: auto; display: block; max-width: 100%; }
  /* Recommendation strategy name: scale down for narrow screens */
  #rec-strategy-name { font-size: 1.3rem !important; }
}

/* ==========================================================================
   Option Chain ATM Sticky Row (outside scroll container — no overlap)
   ========================================================================== */
#chain-table-outer {
  display: flex;
  flex-direction: column;
}

.chain-table-sticky {
  border-collapse: collapse;
}

.spot-sticky-header {
  cursor: pointer;
  transition: filter 0.15s;
}

.spot-sticky-header:hover {
  filter: brightness(1.15);
}

#spot-sticky-top td {
  padding: 0.45rem 0.6rem !important;
  background: var(--atm-bg);
  border-top: 2px solid rgba(0, 210, 255, 0.5) !important;
  border-bottom: 2px solid rgba(255, 45, 133, 0.5) !important;
}

#spot-sticky-bottom td {
  padding: 0.45rem 0.6rem !important;
  background: var(--atm-bg);
  border-top: 2px solid rgba(255, 45, 133, 0.5) !important;
  border-bottom: 2px solid rgba(0, 210, 255, 0.5) !important;
}

.spot-sticky-header .strike-col::after {
  content: "ATM";
  display: block;
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  opacity: 0.7;
}

@media (max-width: 1100px) {
  header {
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
  }
  .header-logo {
    width: auto;
  }
  .header-kpis {
    order: 3;
    width: 100%;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.15);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    backdrop-filter: blur(8px);
  }
}

@media (max-width: 600px) {
  .header-kpis {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 0.5rem;
    padding: 0.6rem;
  }
  .header-kpi-item {
    border-left: none;
    padding-left: 0;
  }
  .header-kpi-item .kpi-value {
    font-size: 0.82rem !important;
  }
  #margin-locked-text {
    font-size: 0.58rem !important;
  }
}

/* ==========================================================================
   OI Map Modal & Insights Styling
   ========================================================================== */
.modal-lg {
  max-width: 850px;
  width: 95%;
}

.oi-insights-container {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
  max-height: 200px;
  overflow-y: auto;
}

.oi-insights-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--call);
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.35rem;
}

.oi-insights-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.8fr;
  gap: 1rem;
}

@media (max-width: 768px) {
  .oi-insights-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

.oi-insights-panel {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.oi-insights-panel h5 {
  font-size: 0.8rem;
  color: var(--text);
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.oi-insights-panel p {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.oi-insights-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.oi-insights-item {
  font-size: 0.75rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  line-height: 1.45;
}

.oi-insights-item-icon {
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.risk-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
}

.risk-high {
  background: rgba(255, 23, 68, 0.15);
  color: #ff5274;
  border: 1px solid rgba(255, 23, 68, 0.3);
}

.risk-low {
  background: rgba(0, 230, 118, 0.15);
  color: #00ff88;
  border: 1px solid rgba(0, 230, 118, 0.3);
}

.risk-warning {
  background: rgba(255, 145, 0, 0.15);
  color: #ff9100;
  border: 1px solid rgba(255, 145, 0, 0.3);
}

.risk-neutral {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ==========================================================================
   Basket Order Styling
   ========================================================================== */
.basket-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.55rem;
  font-size: 0.72rem;
}

.basket-item-info {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.basket-item-badge {
  font-size: 0.58rem;
  font-weight: 700;
  padding: 0.1rem 0.25rem;
  border-radius: 3px;
  text-transform: uppercase;
}

.basket-item-details {
  font-weight: 600;
  color: var(--text);
}

.basket-item-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.basket-item-remove:hover {
  color: #ff5274;
  transform: scale(1.1);
}





