:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: #1c2128;
  --border: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent-green: #3fb950;
  --accent-red: #f85149;
  --accent-blue: #58a6ff;
  --accent-orange: #f0883e;
  --accent-yellow: #d29922;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon { font-size: 2rem; }
.logo h1 { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; }
.logo-link { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }

.header-nav { display: flex; gap: 12px; }
.nav-link-top {
  color: var(--text-secondary); text-decoration: none; font-size: 0.85rem;
  padding: 6px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); transition: all 0.2s;
}
.nav-link-top:hover { color: var(--accent-orange); border-color: var(--accent-orange); }

.subtitle { font-size: 0.8rem; color: var(--text-secondary); }

.cards {
  max-width: 1200px; margin: 20px auto; padding: 0 24px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px;
}

.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; transition: border-color 0.2s;
}
.card:hover { border-color: var(--accent-orange); }
.card-label { font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em; }
.card-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.card-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.positive { color: var(--accent-green); }
.negative { color: var(--accent-red); }

.chart-section { max-width: 1200px; margin: 24px auto; padding: 0 24px; }
.chart-section h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 16px; }
.chart-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; height: 400px; position: relative; }

.table-wrapper { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th { background: var(--bg-secondary); color: var(--text-secondary); font-weight: 600; text-align: left; padding: 12px 16px; white-space: nowrap; border-bottom: 1px solid var(--border); }
.data-table td { padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table tbody tr:hover { background: rgba(240, 136, 62, 0.05); }

.cta-section { max-width: 1200px; margin: 40px auto; padding: 0 24px; text-align: center; }
.cta-section h2 { font-size: 1.4rem; margin-bottom: 12px; }
.cta-section p { color: var(--text-secondary); margin-bottom: 20px; font-size: 0.95rem; }
.btn-cta { display: inline-block; background: var(--accent-orange); color: #fff; text-decoration: none; padding: 12px 32px; border-radius: var(--radius-sm); font-size: 1rem; font-weight: 600; transition: all 0.2s; }
.btn-cta:hover { background: #f0a050; transform: translateY(-1px); }

.footer { max-width: 1200px; margin: 0 auto; padding: 24px; border-top: 1px solid var(--border); text-align: center; font-size: 0.75rem; color: var(--text-muted); line-height: 1.8; }

/* Chart viewer styles */
.chart-toolbar {
  max-width: 1400px; margin: 0 auto; padding: 8px 24px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--bg-secondary); border-bottom: 1px solid var(--border);
}
.toolbar-group { display: flex; align-items: center; gap: 6px; }
.toolbar-label { font-size: 0.8rem; color: var(--text-secondary); margin-right: 4px; }
.toolbar-btn { background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border); padding: 5px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.8rem; font-weight: 500; transition: all 0.15s; white-space: nowrap; }
.toolbar-btn:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.toolbar-btn.active { color: #fff; background: var(--accent-orange); border-color: var(--accent-orange); }
.trade-toggle.active[data-show="on"] { background: rgba(255, 235, 59, 0.2); border-color: rgba(255, 235, 59, 0.5); color: #ffeb3b; }
.trade-toggle.active[data-show="loss"] { background: rgba(88, 166, 255, 0.2); border-color: rgba(88, 166, 255, 0.5); color: var(--accent-blue); }
.trade-toggle.active[data-show="markers"] { background: rgba(240, 136, 62, 0.2); border-color: rgba(240, 136, 62, 0.5); color: var(--accent-orange); }
.color-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.dot-win { background: #ffeb3b; }
.dot-loss { background: var(--accent-blue); }
.toolbar-info { margin-left: auto; gap: 16px; }
.toolbar-info .info-item { font-size: 0.8rem; white-space: nowrap; }
.toolbar-info .info-label { color: var(--text-muted); margin-right: 4px; }
.toolbar-info .info-item span:not(.info-label) { color: var(--text-primary); font-weight: 500; }

#chart-wrapper { max-width: 1400px; margin: 0 auto; }
#chart-container { width: 100%; height: calc(100vh - 220px); min-height: 400px; position: relative; background: var(--bg-primary); }
#trade-overlay, #zoom-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
#trade-overlay { z-index: 5; }
#zoom-overlay { z-index: 10; }
#chart-container.selecting { cursor: crosshair; }
#chart-container.selecting #zoom-overlay { pointer-events: auto; }

.chart-stats {
  max-width: 1400px; margin: 20px auto; padding: 0 24px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px;
}
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem; flex-shrink: 0; }
.win-bg { background: rgba(255, 235, 59, 0.15); color: #ffeb3b; }
.loss-bg { background: rgba(88, 166, 255, 0.15); color: var(--accent-blue); }
.neutral-bg { background: rgba(240, 136, 62, 0.15); color: var(--accent-orange); }
.stat-num { font-size: 1.3rem; font-weight: 700; color: var(--text-primary); }
.stat-desc { font-size: 0.78rem; color: var(--text-secondary); }

.legend-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.legend-item { display: flex; align-items: flex-start; gap: 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; }
.legend-color { width: 32px; height: 24px; border-radius: 4px; flex-shrink: 0; margin-top: 2px; }
.legend-item strong { display: block; font-size: 0.85rem; margin-bottom: 4px; }
.legend-item p { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.5; }

/* Status Grid */
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.status-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.status-header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.status-title { font-weight: 600; font-size: 0.95rem; }
.status-badge { font-size: 0.72rem; font-weight: 700; padding: 3px 10px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-live { background: rgba(63, 185, 80, 0.2); color: var(--accent-green); border: 1px solid var(--accent-green); }
.badge-dryrun { background: rgba(210, 153, 34, 0.2); color: var(--accent-yellow); border: 1px solid var(--accent-yellow); }
.badge-backtest { background: rgba(88, 166, 255, 0.2); color: var(--accent-blue); border: 1px solid var(--accent-blue); }
.badge-waiting { background: rgba(139, 148, 158, 0.2); color: var(--text-secondary); border: 1px solid var(--text-secondary); }
.status-body { padding: 14px 18px; }
.status-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 0.85rem; border-bottom: 1px solid rgba(48, 54, 61, 0.5); }
.status-row:last-child { border-bottom: none; }
.status-key { color: var(--text-secondary); font-size: 0.8rem; flex-shrink: 0; margin-right: 12px; }

@media (max-width: 768px) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .card-value { font-size: 1.3rem; }
  .chart-toolbar { padding: 8px 12px; gap: 8px; }
  .toolbar-info { display: none; }
  #chart-container { height: calc(100vh - 180px); min-height: 300px; }
  .chart-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) { .cards { grid-template-columns: 1fr; } }
