/* ============================================================
   Design tokens
   ============================================================ */
:root {
  /* Light palette */
  --bg-base:       #EEF3FB;
  --bg-surface:    #FFFFFF;
  --bg-elevated:   #E6EDF8;
  --bg-input:      #F5F8FF;
  --border-subtle: #D8E2F2;
  --border-default:#BDC9DF;
  --text-primary:  #0A1628;
  --text-secondary:#3A527A;
  --text-muted:    #7A90B2;
  --accent:        #1A6ECC;
  --accent-dim:    rgba(26, 110, 204, 0.08);
  --accent-glow:   rgba(26, 110, 204, 0.18);
  --call:          #0A8F6A;
  --call-dim:      rgba(10, 143, 106, 0.09);
  --call-glow:     rgba(10, 143, 106, 0.22);
  --put:           #C42B2B;
  --put-dim:       rgba(196, 43, 43, 0.09);
  --put-glow:      rgba(196, 43, 43, 0.22);
  --positive:      #0A8F6A;
  --negative:      #C42B2B;
  --shadow-sm:     0 1px 4px rgba(10,22,50,0.08);
  --shadow-md:     0 4px 18px rgba(10,22,50,0.10);
  --shadow-lg:     0 8px 32px rgba(10,22,50,0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-base:       #060B14;
    --bg-surface:    #0B1525;
    --bg-elevated:   #101E34;
    --bg-input:      #0D1828;
    --border-subtle: #172540;
    --border-default:#213352;
    --text-primary:  #D2E2FF;
    --text-secondary:#6080AA;
    --text-muted:    #2E4060;
    --accent:        #3D9EFF;
    --accent-dim:    rgba(61, 158, 255, 0.10);
    --accent-glow:   rgba(61, 158, 255, 0.22);
    --call:          #2DD4A0;
    --call-dim:      rgba(45, 212, 160, 0.10);
    --call-glow:     rgba(45, 212, 160, 0.25);
    --put:           #FF6B6B;
    --put-dim:       rgba(255, 107, 107, 0.10);
    --put-glow:      rgba(255, 107, 107, 0.25);
    --positive:      #2DD4A0;
    --negative:      #FF6B6B;
    --shadow-sm:     0 1px 4px rgba(0,0,0,0.30);
    --shadow-md:     0 4px 18px rgba(0,0,0,0.40);
    --shadow-lg:     0 8px 32px rgba(0,0,0,0.50);
  }
}

:root[data-theme="light"] {
  --bg-base:       #EEF3FB;
  --bg-surface:    #FFFFFF;
  --bg-elevated:   #E6EDF8;
  --bg-input:      #F5F8FF;
  --border-subtle: #D8E2F2;
  --border-default:#BDC9DF;
  --text-primary:  #0A1628;
  --text-secondary:#3A527A;
  --text-muted:    #7A90B2;
  --accent:        #1A6ECC;
  --accent-dim:    rgba(26, 110, 204, 0.08);
  --accent-glow:   rgba(26, 110, 204, 0.18);
  --call:          #0A8F6A;
  --call-dim:      rgba(10, 143, 106, 0.09);
  --call-glow:     rgba(10, 143, 106, 0.22);
  --put:           #C42B2B;
  --put-dim:       rgba(196, 43, 43, 0.09);
  --put-glow:      rgba(196, 43, 43, 0.22);
  --positive:      #0A8F6A;
  --negative:      #C42B2B;
  --shadow-sm:     0 1px 4px rgba(10,22,50,0.08);
  --shadow-md:     0 4px 18px rgba(10,22,50,0.10);
  --shadow-lg:     0 8px 32px rgba(10,22,50,0.12);
}

:root[data-theme="dark"] {
  --bg-base:       #060B14;
  --bg-surface:    #0B1525;
  --bg-elevated:   #101E34;
  --bg-input:      #0D1828;
  --border-subtle: #172540;
  --border-default:#213352;
  --text-primary:  #D2E2FF;
  --text-secondary:#6080AA;
  --text-muted:    #2E4060;
  --accent:        #3D9EFF;
  --accent-dim:    rgba(61, 158, 255, 0.10);
  --accent-glow:   rgba(61, 158, 255, 0.22);
  --call:          #2DD4A0;
  --call-dim:      rgba(45, 212, 160, 0.10);
  --call-glow:     rgba(45, 212, 160, 0.25);
  --put:           #FF6B6B;
  --put-dim:       rgba(255, 107, 107, 0.10);
  --put-glow:      rgba(255, 107, 107, 0.25);
  --positive:      #2DD4A0;
  --negative:      #FF6B6B;
  --shadow-sm:     0 1px 4px rgba(0,0,0,0.30);
  --shadow-md:     0 4px 18px rgba(0,0,0,0.40);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.50);
}

/* ============================================================
   Base reset & typography
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang TC',
               'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code',
               ui-monospace, 'Courier New', monospace;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: 54px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  z-index: 10;
}

.header-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.header-divider {
  width: 1px;
  height: 22px;
  background: var(--border-subtle);
  flex-shrink: 0;
}

.model-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 3px;
}

.model-tab {
  padding: 5px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.model-tab:hover:not(.active) {
  background: var(--border-subtle);
  color: var(--text-primary);
}

.model-tab.active {
  background: var(--bg-surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.header-spacer { flex: 1; }

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

.theme-toggle svg { width: 16px; height: 16px; }

/* ============================================================
   App layout
   ============================================================ */
.app-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ============================================================
   Sidebar / Inputs
   ============================================================ */
.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-inner {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-section-title {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 12px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.input-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

.input-label .param-sym {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  padding: 1px 6px;
  border-radius: 4px;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.num-input {
  width: 80px;
  flex-shrink: 0;
  padding: 6px 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  text-align: right;
  transition: border-color 0.15s, box-shadow 0.15s;
  -moz-appearance: textfield;
}

.num-input::-webkit-inner-spin-button,
.num-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.num-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Range slider */
.slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border-default);
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
}

.slider:hover::-webkit-slider-thumb {
  transform: scale(1.2);
  box-shadow: 0 0 0 4px var(--accent-dim);
}

/* Option type & exercise toggles */
.toggle-group {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 3px;
}

.toggle-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 12.5px;
  font-weight: 500;
  text-align: center;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.toggle-btn:hover:not(.active) {
  background: var(--border-subtle);
  color: var(--text-primary);
}

.toggle-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.toggle-btn.call-btn.active { color: var(--call); }
.toggle-btn.put-btn.active  { color: var(--put);  }

/* IV Calculator section */
.iv-section {
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
}

.iv-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.iv-result {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  min-width: 70px;
}

.btn-calc {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--bg-surface);
  background: var(--accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.btn-calc:hover { opacity: 0.88; }
.btn-calc:active { transform: scale(0.97); }

.btn-apply {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  display: none;
}

.btn-apply.visible { display: inline-flex; }
.btn-apply:hover { background: var(--accent-dim); opacity: 0.8; }

/* ============================================================
   Results panel
   ============================================================ */
.results-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px;
  gap: 14px;
  background: var(--bg-base);
}

/* Price card */
.price-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.type-exercise-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 180px;
  flex-shrink: 0;
}

.price-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.price-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.price-value {
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 42px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -1px;
  color: var(--text-primary);
  transition: color 0.2s;
}

.price-value.call-active { color: var(--call); text-shadow: 0 0 24px var(--call-glow); }
.price-value.put-active  { color: var(--put);  text-shadow: 0 0 24px var(--put-glow);  }

@keyframes priceFlash {
  0%   { opacity: 0.5; transform: scale(0.98); }
  100% { opacity: 1;   transform: scale(1); }
}

.price-value.flash { animation: priceFlash 0.18s ease-out; }

.price-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.moneyness-badge {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
}

.moneyness-badge.itm { background: var(--call-dim); color: var(--call); }
.moneyness-badge.atm { background: var(--accent-dim); color: var(--accent); }
.moneyness-badge.otm { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border-subtle); }

.parity-label {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.price-stats-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 130px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.stat-value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  text-align: right;
}

/* ============================================================
   Greeks grid
   ============================================================ */
.greeks-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  flex-shrink: 0;
}

.greek-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s;
}

.greek-card:hover {
  border-color: var(--border-default);
}

.greek-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.greek-symbol {
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
}

.greek-name {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.greek-value {
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  line-height: 1;
}

.greek-desc {
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

.greek-bar-track {
  height: 3px;
  background: var(--border-subtle);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.greek-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.greek-card.delta .greek-bar-fill { background: var(--accent); }
.greek-card.gamma .greek-bar-fill { background: #A78BFA; }
.greek-card.theta .greek-bar-fill { background: var(--put); }
.greek-card.vega  .greek-bar-fill { background: #38BDF8; }
.greek-card.rho   .greek-bar-fill { background: #FB923C; }

/* ============================================================
   Chart area
   ============================================================ */
.chart-area {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  min-height: 0;
}

.chart-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.chart-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  flex: 1;
}

.chart-tabs {
  display: flex;
  gap: 2px;
}

.chart-tab {
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
}

.chart-tab:hover:not(.active) {
  color: var(--text-secondary);
  background: var(--bg-elevated);
}

.chart-tab.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: var(--accent);
}

.sensitivity-controls {
  display: none;
  align-items: center;
  gap: 8px;
}

.sensitivity-controls.visible { display: flex; }

.sens-label {
  font-size: 11px;
  color: var(--text-muted);
}

.sens-select {
  padding: 3px 8px;
  font-size: 11.5px;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  cursor: pointer;
}

.sens-select:focus {
  outline: none;
  border-color: var(--accent);
}

.chart-canvas-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
}

#mainChart {
  display: block;
  width: 100%;
  height: 100%;
}

/* ============================================================
   Scrollbar styling
   ============================================================ */
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 3px;
}

/* ============================================================
   Responsive — tablet/mobile
   ============================================================ */
@media (max-width: 900px) {
  body { overflow: auto; }

  .app-layout {
    flex-direction: column;
    overflow: visible;
    height: auto;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    overflow: visible;
  }

  .results-panel {
    overflow: visible;
    padding: 12px;
  }

  .price-card {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .type-exercise-col { width: 100%; }

  .price-main { align-items: flex-start; }

  .price-value { font-size: 36px; }

  .greeks-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .price-stats-col { flex-direction: row; flex-wrap: wrap; }

  .chart-area {
    min-height: 320px;
  }
}

@media (max-width: 560px) {
  .greeks-grid { grid-template-columns: repeat(2, 1fr); }
  .price-value { font-size: 30px; }
  .brand-sub { display: none; }
}

/* ============================================================
   Misc utilities
   ============================================================ */
.positive { color: var(--positive); }
.negative { color: var(--negative); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

[hidden] { display: none !important; }

/* ============================================================
   Options chain panel
   ============================================================ */
.chain-section {
  flex-shrink: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}

.chain-toggle-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
}

#chainToggle {
  background: none;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

#chainToggle:hover {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

.chain-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  flex-wrap: wrap;
}

.chain-spot {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.chain-status {
  font-size: 11.5px;
  color: var(--text-muted);
}

.chain-expiry-wrap {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.chain-open .chain-expiry-wrap { display: flex; }

.chain-expiry-select {
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  cursor: pointer;
}

.chain-expiry-select:focus {
  outline: none;
  border-color: var(--accent);
}

.chain-body {
  display: none;
  border-top: 1px solid var(--border-subtle);
  max-height: 400px;
  overflow: hidden;
}

.chain-open .chain-body { display: block; }

.chain-scroll-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 400px;
}

.chain-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chain-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  padding: 6px 10px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-subtle);
  z-index: 2;
}

.chain-header-call { color: var(--call) !important; }
.chain-header-put  { color: var(--put)  !important; }
.chain-header-strike { background: var(--bg-surface) !important; }

.chain-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.1s;
}

.chain-table tbody tr:hover { background: var(--accent-dim); }

.chain-table tbody td {
  padding: 5px 10px;
  text-align: center;
  color: var(--text-secondary);
}

.chain-table td.num { text-align: right; }
.chain-table td.dim { color: var(--text-muted); }

.chain-table td.call-last {
  color: var(--call);
  font-weight: 600;
}
.chain-table td.call-last:hover { background: var(--call-dim); }

.chain-table td.put-last {
  color: var(--put);
  font-weight: 600;
}
.chain-table td.put-last:hover { background: var(--put-dim); }

.chain-table td.itm-cell {
  background: var(--call-dim);
}

.chain-table td.strike-col {
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  position: sticky;
  /* Not sticky by default on mobile */
}

.chain-table td.atm-strike {
  background: var(--accent-dim) !important;
  color: var(--accent) !important;
}

.chain-table tr.atm-row td { background: var(--accent-dim) !important; }

.chain-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.chain-hint {
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 20px 8px;
  border-top: 1px solid var(--border-subtle);
}

/* ============================================================
   Individual Stock Futures Analysis Panel
   ============================================================ */
.ssf-section {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.ssf-toggle-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  flex-wrap: wrap;
  min-height: 44px;
}

.ssf-toggle-bar > button {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.ssf-toggle-bar > button:hover { color: var(--accent); }

.ssf-arrow {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.ssf-meta {
  flex: 1;
  min-width: 0;
}

.ssf-status {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Filter buttons */
.ssf-filters {
  display: flex;
  gap: 4px;
  align-items: center;
}

.ssf-filter-btn {
  padding: 3px 11px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: 20px;
  border: 1px solid var(--border-default);
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
}

.ssf-filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.ssf-filter-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Body */
.ssf-body {
  display: none;
  border-top: 1px solid var(--border-subtle);
}

.ssf-open .ssf-body { display: block; }

.ssf-scroll-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 420px;
}

/* Table */
.ssf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ssf-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  padding: 6px 12px;
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-subtle);
  z-index: 2;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.ssf-table thead th:first-child { text-align: left; }
.ssf-table thead th:hover { color: var(--accent); }
.ssf-table thead th.col-sorted { color: var(--accent); }

.sort-ind {
  margin-left: 4px;
  font-size: 9px;
  vertical-align: middle;
}

.ssf-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.1s;
  cursor: pointer;
}

.ssf-table tbody tr:hover { background: var(--accent-dim); }

.ssf-table tbody td {
  padding: 5px 12px;
  color: var(--text-secondary);
  text-align: right;
}

.ssf-table tbody td:first-child { text-align: left; }
.ssf-table td.dim { color: var(--text-muted); }

.ssf-code {
  font-weight: 700;
  color: var(--text-primary) !important;
  font-size: 12.5px;
}

.ssf-name {
  color: var(--text-secondary) !important;
  font-size: 11.5px;
  text-align: left !important;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ssf-table .inst-header {
  text-align: center;
}

/* Price change colours */
.ssf-table .pos { color: var(--positive); }
.ssf-table .neg { color: var(--negative); }

/* Signal badges */
.sig-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  font-family: inherit;
}

.sig-bull-strong { background: var(--call-dim);    color: var(--call);     border: 1px solid var(--call-glow); }
.sig-bull-unwind { background: var(--accent-dim);  color: var(--accent);   border: 1px solid var(--accent-glow); }
.sig-bear-strong { background: var(--put-dim);     color: var(--put);      border: 1px solid var(--put-glow); }
.sig-bear-cover  { background: rgba(251,146,60,.1);color: #FB923C;         border: 1px solid rgba(251,146,60,.3); }
.sig-up          { background: var(--call-dim);    color: var(--call);     border: 1px solid var(--call-glow); }
.sig-down        { background: var(--put-dim);     color: var(--put);      border: 1px solid var(--put-glow); }
.sig-flat        { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border-subtle); }

/* Institutional chips */
.inst-cell {
  display: table-cell;
  white-space: nowrap;
  text-align: center !important;
}

.inst-chip {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  margin: 0 2px;
}

.inst-chip.long    { background: var(--call-dim); color: var(--call); }
.inst-chip.short   { background: var(--put-dim);  color: var(--put);  }
.inst-chip.neutral { background: var(--bg-elevated); color: var(--text-muted); }

.ssf-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.ssf-hint {
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 20px 8px;
  border-top: 1px solid var(--border-subtle);
}

/* Spot vs Futures Alignment Badges */
.align-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  font-family: inherit;
  white-space: nowrap;
}

.align-same-long  { background: var(--call-dim);           color: var(--call);       border: 1px solid var(--call-glow); }
.align-same-short { background: var(--put-dim);            color: var(--put);        border: 1px solid var(--put-glow); }
.align-hedge      { background: rgba(251,146,60,.12);      color: #FB923C;           border: 1px solid rgba(251,146,60,.35); }
.align-diverge    { background: rgba(168,85,247,.12);      color: #A855F7;           border: 1px solid rgba(168,85,247,.35); }
.align-neutral    { background: var(--bg-elevated);        color: var(--text-muted); border: 1px solid var(--border-subtle); }

/* ============================================================
   Page Navigation (shared between index.html and ssf.html)
   ============================================================ */
.page-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.page-nav-link {
  display: inline-block;
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}

.page-nav-link:hover  { background: var(--bg-elevated); color: var(--text-primary); }
.page-nav-link.active { background: var(--accent-dim);  color: var(--accent); font-weight: 600; }

/* ============================================================
   SSF Standalone Page Layout
   ============================================================ */
.ssf-page-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.ssf-page-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-surface);
}

/* Top controls bar */
.ssf-page-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 44px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Page-level tabs */
.ssf-page-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
}

.ssf-page-tab {
  padding: 5px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}

.ssf-page-tab:hover  { background: var(--bg-surface); color: var(--text-primary); }
.ssf-page-tab.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }

.ssf-status-inline {
  flex: 1;
  font-size: 11.5px;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tab panes */
.ssf-tab-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ssf-tab-hidden { display: none !important; }

/* Make the scroll wrap fill remaining height on SSF page */
.ssf-tab-pane .ssf-scroll-wrap {
  flex: 1;
  max-height: none;
}

/* ============================================================
   Accuracy Panel
   ============================================================ */
.acc-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.8;
}

.acc-empty-icon { font-size: 40px; margin-bottom: 16px; }
.acc-empty p    { margin: 0 0 8px; }
.acc-empty strong { color: var(--text-primary); }

.acc-empty-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px !important;
}

/* Summary bar */
.acc-summary-bar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.acc-summary-total {
  display: flex;
  align-items: center;
  gap: 16px;
}

.acc-total-pct {
  font-size: 40px;
  font-weight: 700;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  line-height: 1;
}

.acc-total-info { display: flex; flex-direction: column; gap: 2px; }
.acc-total-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.acc-total-sub   { font-size: 11.5px; color: var(--text-muted); }

/* Stats cards */
.acc-cards {
  display: flex;
  gap: 16px;
  padding: 16px 24px;
  flex-wrap: wrap;
}

.acc-card {
  flex: 1;
  min-width: 260px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 14px 16px;
}

.acc-card-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.acc-stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.acc-stat-label {
  width: 100px;
  flex-shrink: 0;
  font-size: 11.5px;
}

.acc-bar-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.acc-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--bg-surface);
  border-radius: 3px;
  overflow: hidden;
}

.acc-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.acc-pct   { font-size: 11px; font-weight: 700; font-family: 'JetBrains Mono', monospace; width: 42px; text-align: right; }
.acc-count { font-size: 10.5px; color: var(--text-muted); white-space: nowrap; }
.acc-na    { font-size: 11px; color: var(--text-muted); }

/* Detail table */
.acc-detail {
  padding: 0 24px 24px;
}

.acc-detail-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-top: 4px;
}

.acc-detail-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 380px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.acc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.acc-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  padding: 7px 12px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

.acc-table thead th.num { text-align: right; }

.acc-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.1s;
}

.acc-table tbody tr:hover { background: var(--accent-dim); }

.acc-table tbody td {
  padding: 5px 12px;
  color: var(--text-secondary);
}

.acc-table td.num { text-align: right; }
.acc-table .pos   { color: var(--positive); }
.acc-table .neg   { color: var(--negative); }

.acc-correct { color: var(--call);     font-weight: 700; }
.acc-wrong   { color: var(--put);      font-weight: 700; }

/* ── Load history button ─────────────────────── */
.btn-load-hist {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  padding: 8px 20px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-glow);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-load-hist:hover:not(:disabled) {
  background: var(--accent-glow);
  border-color: var(--accent);
}
.btn-load-hist:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-load-hist-sm {
  margin-top: 0;
  padding: 4px 12px;
  font-size: 11.5px;
  flex-shrink: 0;
}
.acc-hist-note {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 8px;
}
.acc-summary-bar .acc-hist-note {
  margin-top: 0;
  margin-left: 6px;
}
