:root {
  --bg: #FAFBFC;
  --bg-card: #FFFFFF;
  --bg-hover: #F3F4F6;
  --text: #1F2937;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;
  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --accent: #10B981;
  --accent-red: #EF4444;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

[data-theme="dark"] {
  --bg: #0F172A;
  --bg-card: #1E293B;
  --bg-hover: #334155;
  --text: #E2E8F0;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --border: #334155;
  --primary: #60A5FA;
  --primary-hover: #93C5FD;
  --accent: #34D399;
  --accent-red: #F87171;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
}

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

.select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 0.2s;
  outline: none;
}

.select:hover,
.select:focus {
  border-color: var(--primary);
}

.btn-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: border-color 0.2s, background 0.2s;
}

.btn-icon:hover {
  border-color: var(--primary);
  background: var(--bg-hover);
}

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: inline; }

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.price-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.price-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.price-value {
  font-size: 3rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
}

.price-symbol,
.price-unit {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.price-meta {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.controls {
  margin-bottom: 1.5rem;
}

.control-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.chart-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.time-range {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.time-btn {
  padding: 0.375rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.time-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.time-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

.chart-container {
  position: relative;
  height: 400px;
}

.navigator-container {
  position: relative;
  height: 80px;
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  user-select: none;
}

.navigator-container canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.navigator-mask {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1;
  pointer-events: none;
}

.navigator-mask-left {
  left: 0;
}

.navigator-mask-right {
  right: 0;
}

.navigator-window {
  position: absolute;
  top: 0;
  height: 100%;
  border: 2px solid var(--primary);
  border-top: none;
  border-bottom: none;
  cursor: grab;
  z-index: 2;
}

.navigator-window:active {
  cursor: grabbing;
}

.navigator-handle {
  position: absolute;
  top: 0;
  width: 8px;
  height: 100%;
  background: var(--primary);
  cursor: ew-resize;
  z-index: 3;
}

.navigator-handle::before,
.navigator-handle::after {
  content: '';
  position: absolute;
  left: 50%;
  width: 2px;
  height: 12px;
  background: rgba(255, 255, 255, 0.6);
  transform: translateX(-50%);
}

.navigator-handle::before {
  top: calc(50% - 8px);
}

.navigator-handle::after {
  top: calc(50% + 2px);
}

.navigator-handle-left {
  left: -4px;
}

.navigator-handle-right {
  right: -4px;
}

[data-theme="dark"] .navigator-mask {
  background: rgba(0, 0, 0, 0.5);
}

.table-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.table-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.change-positive {
  color: var(--accent);
  font-weight: 500;
}

.change-negative {
  color: var(--accent-red);
  font-weight: 500;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

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

#pageInfo {
  font-size: 0.875rem;
  color: var(--text-secondary);
  min-width: 100px;
  text-align: center;
}

.page-jump input {
  width: 60px;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.page-jump input:focus {
  border-color: var(--primary);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--border);
}

[dir="rtl"] .data-table th,
[dir="rtl"] .data-table td {
  text-align: right;
}

@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    gap: 0.75rem;
  }

  .header-controls {
    width: 100%;
    justify-content: space-between;
  }

  .price-value {
    font-size: 2rem;
  }

  .chart-container {
    height: 280px;
  }

  .control-group {
    flex-direction: column;
  }

  .select {
    width: 100%;
  }

  .time-range {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .main {
    padding: 1rem;
  }

  .price-card {
    padding: 1.5rem;
  }

  .chart-section,
  .table-section {
    padding: 1rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.5rem;
    font-size: 0.8125rem;
  }
}
