/* ---- Spread Chart ---- */
.sc-wrapper {
  display: flex;
  height: 100%;
  background: #0d0d0d;
  color: #ccc;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
}

.sc-sidebar {
  width: 220px;
  height: 100%;
  background: #141414;
  border-right: 1px solid #222;
  display: block;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 20px;
}

.sc-favorites-section {
  padding: 10px;
  border-bottom: 1px solid #222;
}

.sc-favorites-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.sc-favorites-header span {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
}

.sc-fav-btns {
  display: flex;
  gap: 4px;
}

.sc-fav-add-btn, .sc-fav-del-btn {
  width: 20px;
  height: 20px;
  border: 1px solid #444;
  background: #222;
  color: #888;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sc-fav-add-btn:hover {
  background: #333;
  color: #fff;
  border-color: #666;
}

.sc-fav-del-btn:hover {
  background: #7f1d1d;
  color: #f87171;
  border-color: #991b1b;
}

@keyframes favAdded {
  0% { background: #222; }
  30% { background: #166534; border-color: #22c55e; }
  100% { background: #222; }
}

.sc-fav-add-btn.added {
  animation: favAdded 0.6s ease-out;
}

@keyframes favFlash {
  0% { border-color: #333; }
  30% { border-color: #22c55e; box-shadow: 0 0 8px rgba(34,197,94,0.3); }
  100% { border-color: #333; box-shadow: none; }
}

.sc-favorites-select.flash {
  animation: favFlash 0.6s ease-out;
}

.sc-favorites-select {
  width: 100%;
  padding: 6px 8px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  color: #ccc;
  font-size: 11px;
  cursor: pointer;
}

.sc-favorites-select:hover {
  border-color: #444;
}

.sc-stats-panel {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(20, 20, 20, 0.9);
  border: 1px solid #333;
  border-radius: 6px;
  padding: 10px 12px;
  z-index: 10;
  min-width: 140px;
}

.sc-stats-title {
  font-size: 10px;
  color: #666;
  text-transform: uppercase;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.sc-stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.sc-stats-row:last-child {
  margin-bottom: 0;
}

.sc-stats-label {
  font-size: 10px;
  color: #888;
}

.sc-stats-value {
  font-size: 11px;
  color: #fff;
  font-family: monospace;
}

.sc-header {
  padding: 12px 16px;
  border-bottom: 1px solid #222;
}

.sc-logo {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 10px;
}

.sc-symbol-selector {
  position: relative;
}

.sc-symbol-input {
  width: 100%;
  padding: 10px 12px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  outline: none;
}

.sc-symbol-input:focus {
  border-color: #444;
}

.sc-symbol-input::placeholder {
  color: #555;
  font-weight: 400;
}

.sc-symbol-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #1a1a1a;
  border: 1px solid #333;
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.sc-symbol-suggestions.open {
  display: block;
}

.sc-symbol-suggestion {
  padding: 8px 12px;
  font-size: 12px;
  color: #ccc;
  cursor: pointer;
}

.sc-symbol-suggestion:hover {
  background: #222;
}

.sc-panel {
  padding: 12px;
  border-bottom: 1px solid #222;
}

.sc-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.sc-panel-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.sc-panel-indicator.in { background: #22c55e; }
.sc-panel-indicator.out { background: #ef4444; }

.sc-exchange-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.sc-exchange-btn:hover { border-color: #444; }

.sc-ex-name {
  font-size: 13px;
  color: #fff;
  font-weight: 500;
}

.sc-ex-type {
  font-size: 11px;
  color: #666;
}

.sc-ex-arrow {
  margin-left: auto;
  color: #666;
  font-size: 10px;
}

.sc-symbol-row {
  position: relative;
  margin: 8px 0;
}

.sc-symbol-row .sc-symbol-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
}

.sc-symbol-row .sc-symbol-suggestions {
  top: 100%;
  left: 0;
  right: 0;
}

.sc-panel-price-row {
  margin-bottom: 8px;
}

.sc-panel-price {
  font-family: monospace;
  font-size: 14px;
  color: #fff;
  font-weight: 500;
}

.sc-panel-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sc-stat {
  display: flex;
  align-items: center;
  font-size: 11px;
}

.sc-stat-label {
  color: #555;
  min-width: 65px;
}

.sc-stat-value {
  color: #999;
  font-family: monospace;
}

.sc-dw-status {
  display: inline-block;
  width: 14px;
  height: 14px;
  line-height: 14px;
  text-align: center;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 2px;
  margin-right: 8px;
}

.sc-dw-status.ok { background: #166534; color: #4ade80; }
.sc-dw-status.no { background: #7f1d1d; color: #f87171; }
.sc-dw-status { background: #333; color: #666; }

.sc-exchange-link {
  color: #3b82f6;
  text-decoration: none;
  font-size: 11px;
}

.sc-exchange-link:hover {
  text-decoration: underline;
}

.sc-fund-time {
  color: #666;
  font-size: 10px;
  margin-left: 4px;
}

.sc-chains-section {
  margin-top: 6px;
}

.sc-chains-label {
  font-size: 10px;
  color: #555;
  margin-bottom: 4px;
}

.sc-chains-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.sc-chain-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  background: #1a1a1a;
  border-radius: 3px;
  font-size: 10px;
  color: #999;
}

.sc-chain-badge .d, .sc-chain-badge .w {
  width: 12px;
  height: 12px;
  line-height: 12px;
  text-align: center;
  border-radius: 2px;
  font-size: 8px;
  font-weight: 600;
}

.sc-chain-badge .d.ok { background: #166534; color: #4ade80; }
.sc-chain-badge .d.no { background: #7f1d1d; color: #f87171; }
.sc-chain-badge .w.ok { background: #166534; color: #4ade80; }
.sc-chain-badge .w.no { background: #7f1d1d; color: #f87171; }

.sc-index-section {
  margin-top: 6px;
}

.sc-index-label {
  font-size: 10px;
  color: #555;
  margin-bottom: 4px;
}

.sc-index-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.sc-index-badge {
  display: inline-block;
  padding: 2px 5px;
  background: #1f2937;
  border-radius: 3px;
  font-size: 9px;
  color: #9ca3af;
  text-transform: capitalize;
}

/* Modal */
.sc-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.sc-modal-overlay.show {
  display: flex;
}

.sc-modal {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 16px 24px;
  max-width: 300px;
  text-align: center;
  animation: modalIn 0.15s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.sc-modal-text {
  font-size: 13px;
  color: #ccc;
  line-height: 1.5;
}

.sc-modal-btns {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: center;
}

.sc-modal-btn {
  padding: 6px 16px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.sc-modal-cancel {
  background: #333;
  color: #aaa;
}

.sc-modal-cancel:hover {
  background: #444;
}

.sc-modal-confirm {
  background: #dc2626;
  color: #fff;
}

.sc-modal-confirm:hover {
  background: #b91c1c;
}

/* Main chart area */
.sc-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #141414;
  border-bottom: 1px solid #222;
}

.sc-toolbar-left {
  display: flex;
  gap: 16px;
}

.sc-price-label {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 3px;
  font-family: monospace;
}

.sc-price-label.in { background: rgba(34,197,94,0.15); color: #22c55e; }
.sc-price-label.out { background: rgba(239,68,68,0.15); color: #ef4444; }

.sc-toolbar-right {
  display: flex;
  gap: 12px;
}

.sc-time-btns, .sc-mode-btns, .sc-timeframe-btns {
  display: flex;
  gap: 2px;
}

.sc-time-btn, .sc-mode-btn, .sc-tf-btn {
  padding: 5px 10px;
  background: #1a1a1a;
  border: 1px solid #333;
  color: #888;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.sc-time-btn:first-child, .sc-mode-btn:first-child, .sc-tf-btn:first-child { border-radius: 4px 0 0 4px; }
.sc-time-btn:last-child, .sc-mode-btn:last-child, .sc-tf-btn:last-child { border-radius: 0 4px 4px 0; }

.sc-time-btn:hover, .sc-mode-btn:hover, .sc-tf-btn:hover { background: #222; color: #ccc; }
.sc-time-btn.active, .sc-mode-btn.active, .sc-tf-btn.active { background: #333; color: #fff; border-color: #444; }

.sc-chart-container {
  flex: 3;
  position: relative;
  min-height: 0;
}

.sc-chart-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #555;
  font-size: 1.1rem;
  text-align: center;
  z-index: 10;
  pointer-events: none;
}

.sc-chart-divider {
  height: 5px;
  background: #333;
  flex-shrink: 0;
  cursor: ns-resize;
  position: relative;
}

.sc-chart-divider:hover,
.sc-chart-divider.dragging {
  background: #eab308;
}

.sc-funding-pane {
  position: relative;
  min-height: 100px;
  height: 180px;
}

.sc-tooltip {
  position: absolute;
  padding: 8px 12px;
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid #333;
  border-radius: 4px;
  font-size: 12px;
  color: #ccc;
  pointer-events: none;
  z-index: 10;
  display: none;
  line-height: 1.5;
  white-space: nowrap;
}

.sc-tooltip.visible {
  display: block;
}

.sc-tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.sc-tooltip-label {
  color: #888;
}

.sc-tooltip-value {
  font-family: monospace;
  font-weight: 500;
}

.sc-tooltip-value.in { color: #22c55e; }
.sc-tooltip-value.out { color: #ef4444; }
.sc-tooltip-value.spread { color: #3b82f6; }

.sc-chart-legend {
  position: absolute;
  bottom: 40px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

.sc-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 3px;
  font-size: 11px;
}

.sc-legend-item.in { background: rgba(34,197,94,0.9); color: #fff; }
.sc-legend-item.out { background: rgba(239,68,68,0.9); color: #fff; }

.sc-legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.sc-legend-dot.in { background: #fff; }
.sc-legend-dot.out { background: #fff; }

.sc-legend-val {
  margin-left: auto;
  font-family: monospace;
  font-weight: 600;
}

/* Exchange Dropdown */
.sc-dropdown {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  z-index: 1000;
  display: none;
}

.sc-dropdown.open { display: block; }

.sc-dropdown-tabs {
  display: flex;
  border-bottom: 1px solid #333;
}

.sc-dropdown-tab {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  color: #666;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.sc-dropdown-tab:hover { color: #aaa; background: #222; }
.sc-dropdown-tab.active { color: #fff; background: #333; }

.sc-dropdown-list {
  max-height: 300px;
  overflow-y: auto;
}

.sc-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.1s;
}

.sc-dropdown-item:hover { background: #222; }
.sc-dropdown-item.selected { background: #2563eb; }

.sc-dropdown-item span {
  font-size: 13px;
  color: #ddd;
}

.sc-dropdown-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  display: none;
}

.sc-dropdown-backdrop.open { display: block; }

/* Mobile header */
.sc-mobile-header {
  display: none;
  flex-direction: column;
  background: #141414;
  border-bottom: 1px solid #222;
}

.sc-mobile-summary {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 12px;
  cursor: pointer;
}

.sc-mobile-summary:hover {
  background: #1a1a1a;
}

.sc-mobile-rows {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sc-mobile-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.sc-mobile-row.in .sc-mobile-symbol { color: #4ade80; }
.sc-mobile-row.out .sc-mobile-symbol { color: #f87171; }

.sc-mobile-symbol {
  font-weight: 600;
  min-width: 70px;
}

.sc-mobile-cex {
  color: #888;
  font-size: 11px;
}

.sc-mobile-price {
  margin-left: auto;
  font-family: monospace;
  color: #ccc;
}

.sc-mobile-toggle {
  color: #666;
  font-size: 12px;
  transition: transform 0.2s;
  padding: 4px;
}

.sc-mobile-header.open .sc-mobile-toggle {
  transform: rotate(180deg);
}

@media (max-width: 900px) {
  .sc-mobile-header {
    display: flex;
  }

  .sc-wrapper {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow-x: hidden;
  }

  .sc-sidebar {
    width: 100%;
    height: auto;
    max-height: 0;
    overflow: hidden;
    border-right: none;
    border-bottom: 1px solid #222;
    transition: max-height 0.3s ease;
    padding-bottom: 0;
  }

  .sc-sidebar.open {
    max-height: 600px;
    overflow-y: auto;
    padding-bottom: 12px;
  }

  .sc-panel {
    border-radius: 0;
    margin: 0;
  }

  .sc-panel-in, .sc-panel-out {
    display: inline-block;
    width: calc(50% - 6px);
    vertical-align: top;
    margin: 6px 3px;
  }

  .sc-favorites-section {
    padding: 8px 12px;
  }

  .sc-main {
    width: 100%;
    flex: 1;
    min-height: 400px;
  }

  .sc-chart-container {
    height: calc(100vh - 180px);
    min-height: 350px;
  }

  .sc-toolbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
  }

  .sc-toolbar-left {
    display: none;
  }

  .sc-toolbar-right {
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    justify-content: center;
  }

  .sc-chart-legend {
    bottom: 50px;
    font-size: 10px;
  }

  .sc-stats-panel {
    display: none !important;
  }

  .sc-panel-stats {
    font-size: 11px;
  }

  .sc-chains-list {
    font-size: 10px;
  }
}
