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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #0f0f1a;
  color: #e0e0e0;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

body[data-theme="light"] {
  background: #f5f5f5;
  color: #333333;
}

#app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
#header {
  text-align: center;
  padding: 20px 0;
  border-bottom: 1px solid #2a2a3a;
  margin-bottom: 20px;
}

body[data-theme="light"] #header {
  border-bottom-color: #ddd;
}

#header h1 {
  font-size: 28px;
  color: #fff;
  margin-bottom: 5px;
}

body[data-theme="light"] #header h1 {
  color: #333;
}

#header .subtitle {
  color: #888;
  font-size: 14px;
}

/* Controls */
#controls {
  background: #1a1a2e;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid #2a2a3a;
}

body[data-theme="light"] #controls {
  background: #ffffff;
  border-color: #ddd;
}

.control-row {
  display: flex;
  gap: 20px;
  margin-bottom: 15px;
  align-items: flex-end;
  flex-wrap: wrap;
}

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

.input-group {
  flex: 1;
  min-width: 300px;
}

.presets-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.presets-group label {
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-group label {
  font-size: 12px;
  color: #888;
}

label {
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
  display: block;
}

body[data-theme="light"] label {
  color: #666;
}

textarea {
  width: 100%;
  padding: 12px;
  background: #0f0f1a;
  border: 1px solid #3a3a4a;
  border-radius: 6px;
  color: #e0e0e0;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  resize: vertical;
}

body[data-theme="light"] textarea {
  background: #ffffff;
  border-color: #ddd;
  color: #333;
}

textarea:focus {
  outline: none;
  border-color: #4a9eff;
}

select {
  padding: 10px 12px;
  background: #0f0f1a;
  border: 1px solid #3a3a4a;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 13px;
  cursor: pointer;
}

body[data-theme="light"] select {
  background: #ffffff;
  border-color: #ddd;
  color: #333;
}

select:focus {
  outline: none;
  border-color: #4a9eff;
}

.checkbox-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #ccc;
  cursor: pointer;
}

body[data-theme="light"] .checkbox-label {
  color: #555;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #4a9eff;
}

button {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.preset-btn {
  background: #2a2a3a;
  color: #ccc;
  padding: 5px 10px;
  font-size: 11px;
}

body[data-theme="light"] .preset-btn {
  background: #e8e8e8;
  color: #555;
}

.preset-btn:hover {
  background: #3a3a4a;
  color: #fff;
}

body[data-theme="light"] .preset-btn:hover {
  background: #d0d0d0;
  color: #333;
}

.preset-btn.active {
  background: #4a9eff;
  color: #fff;
}

.primary-btn {
  background: #4a9eff;
  color: #fff;
  padding: 10px 24px;
}

.primary-btn:hover {
  background: #3a8eef;
}

.primary-btn:disabled {
  background: #2a2a3a;
  color: #666;
  cursor: not-allowed;
}

body[data-theme="light"] .primary-btn:disabled {
  background: #ccc;
  color: #999;
}

/* Status Bar */
#status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #1a1a2e;
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 13px;
  border: 1px solid #2a2a3a;
}

body[data-theme="light"] #status {
  background: #ffffff;
  border-color: #ddd;
}

#status-text {
  color: #aaa;
}

body[data-theme="light"] #status-text {
  color: #666;
}

#loading-progress {
  color: #4a9eff;
}

/* Charts Container */
#charts-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Chart Card */
.chart-card {
  background: #1a1a2e;
  border-radius: 8px;
  border: 1px solid #2a2a3a;
  overflow: hidden;
}

body[data-theme="light"] .chart-card {
  background: #ffffff;
  border-color: #ddd;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #12121f;
  border-bottom: 1px solid #2a2a3a;
}

body[data-theme="light"] .chart-header {
  background: #f8f8f8;
  border-bottom-color: #ddd;
}

.full-chart-btn {
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid #4a9eff;
  border-radius: 4px;
  background: transparent;
  color: #4a9eff;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.full-chart-btn:hover {
  background: #4a9eff;
  color: #fff;
}

body[data-theme="light"] .full-chart-btn {
  border-color: #2563eb;
  color: #2563eb;
}

body[data-theme="light"] .full-chart-btn:hover {
  background: #2563eb;
  color: #fff;
}

.chart-symbol {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

body[data-theme="light"] .chart-symbol {
  color: #333;
}

.chart-info {
  font-size: 12px;
  color: #888;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

body[data-theme="light"] .chart-info {
  color: #666;
}

.price-info {
  font-weight: 500;
}

.fundamental-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.fundamental-tag {
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(74, 158, 255, 0.15);
  border: 1px solid rgba(74, 158, 255, 0.3);
  border-radius: 3px;
  color: #4a9eff;
  white-space: nowrap;
}

body[data-theme="light"] .fundamental-tag {
  background: rgba(74, 158, 255, 0.1);
  border-color: rgba(74, 158, 255, 0.2);
  color: #2563eb;
}

.chart-container {
  width: 100%;
  position: relative;
}

/* Skeleton Loading */
.skeleton {
  height: 400px;
  background: linear-gradient(90deg, #1a1a2e 25%, #2a2a3a 50%, #1a1a2e 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

body[data-theme="light"] .skeleton {
  background: linear-gradient(90deg, #e8e8e8 25%, #f0f0f0 50%, #e8e8e8 75%);
  background-size: 200% 100%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Error State */
.chart-error {
  padding: 20px;
  text-align: center;
  color: #ff6b6b;
}

/* Pagination */
#pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 20px 0;
}

.page-btn {
  padding: 8px 14px;
  background: #1a1a2e;
  border: 1px solid #2a2a3a;
  border-radius: 4px;
  color: #ccc;
  cursor: pointer;
  font-size: 13px;
}

body[data-theme="light"] .page-btn {
  background: #ffffff;
  border-color: #ddd;
  color: #555;
}

.page-btn:hover:not(:disabled) {
  background: #2a2a3a;
  color: #fff;
}

body[data-theme="light"] .page-btn:hover:not(:disabled) {
  background: #e8e8e8;
  color: #333;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-btn.active {
  background: #4a9eff;
  border-color: #4a9eff;
  color: #fff;
}

.page-info {
  color: #888;
  font-size: 13px;
  padding: 0 12px;
}

body[data-theme="light"] .page-info {
  color: #666;
}

/* Footer */
#footer {
  text-align: center;
  padding: 20px 0;
  margin-top: 20px;
  border-top: 1px solid #2a2a3a;
  color: #666;
  font-size: 12px;
}

body[data-theme="light"] #footer {
  border-top-color: #ddd;
}

/* Indicator Builder */
.indicator-group {
  min-width: 320px;
}

.indicator-builder {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.indicator-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.indicator-row select {
  padding: 6px 8px;
  font-size: 12px;
}

.indicator-row input[type="number"] {
  width: 60px;
  padding: 6px 8px;
  background: #0f0f1a;
  border: 1px solid #3a3a4a;
  border-radius: 4px;
  color: #e0e0e0;
  font-size: 12px;
  text-align: center;
}

body[data-theme="light"] .indicator-row input[type="number"] {
  background: #ffffff;
  border-color: #ddd;
  color: #333;
}

.ind-btn {
  padding: 6px 12px;
  background: #4a9eff;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.ind-btn:hover {
  background: #3a8eef;
}

.indicator-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 24px;
}

.ind-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #2a2a3a;
  border: 1px solid #3a3a4a;
  border-left: 3px solid #4a9eff;
  border-radius: 4px;
  font-size: 12px;
  color: #ccc;
}

body[data-theme="light"] .ind-chip {
  background: #e8e8e8;
  border-color: #ddd;
  color: #555;
}

.ind-remove {
  background: none;
  border: none;
  color: #ff6b6b;
  cursor: pointer;
  font-size: 11px;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.7;
}

.ind-remove:hover {
  opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
  #app {
    padding: 8px;
  }

  header h1 {
    font-size: 18px;
  }

  .subtitle {
    font-size: 12px;
  }

  .control-row {
    flex-direction: column;
    gap: 12px;
  }

  .input-group {
    min-width: 100%;
  }

  .input-group textarea {
    rows: 4;
  }

  .presets-group {
    flex-direction: column;
    width: 100%;
  }

  .preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  .preset-btn {
    padding: 4px 8px;
    font-size: 10px;
  }

  .control-group {
    width: 100%;
  }

  .control-group select {
    width: 100%;
    padding: 8px;
  }

  .indicator-row {
    flex-wrap: wrap;
  }

  .indicator-row select,
  .indicator-row input[type="number"] {
    flex: 1;
    min-width: 0;
  }

  .indicator-row input[type="number"] {
    width: 50px;
  }

  #load-btn {
    width: 100%;
    padding: 12px;
  }

  .chart-card {
    margin-bottom: 12px;
  }

  .chart-header {
    padding: 8px 10px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .chart-symbol {
    font-size: 14px;
  }

  .chart-info {
    font-size: 11px;
    width: 100%;
    text-align: right;
  }

  .full-chart-btn {
    font-size: 10px;
    padding: 3px 8px;
  }

  .price-info {
    font-size: 12px;
  }

  .fundamental-tags {
    gap: 4px;
    justify-content: flex-start;
  }

  .fundamental-tag {
    font-size: 9px;
    padding: 1px 4px;
  }

  #status {
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
  }

  .page-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
}
