@import url('https://fonts.googleapis.com/css2?family=Overpass:wght@300;400;600;700&family=Source+Code+Pro:wght@400;500&display=swap');

:root {
  --bg: #0d0f14;
  --surface: #161920;
  --surface2: #1e2230;
  --border: #2a2f3e;
  --accent: #4aa8ff;
  --accent-dim: #2a4a8a;
  --text: #e2e6f0;
  --text-muted: #8890a4;
  --green: #5bd67b;
  --orange: #f29e3f;
  --red: #f76f6f;
  --yellow: #f7c948;
  --font-sans: 'Overpass', system-ui, sans-serif;
  --font-mono: 'Source Code Pro', monospace;
  --radius: 10px;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Layout ─────────────────────────────────────────────── */
.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

/* ── Header ─────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 48px;
}

.logo-mark {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent) 0%, #7b5cf7 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.logo-company {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.logo-product {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* ── Hero ────────────────────────────────────────────────── */
.hero { margin-bottom: 40px; }

.hero h1 {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--text) 40%, var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 17px;
  color: var(--text-muted);
  max-width: 680px;
  line-height: 1.7;
}

/* ── Input card ──────────────────────────────────────────── */
.input-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 32px;
}

.input-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ticker-input {
  flex: 1;
  min-width: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.ticker-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74, 168, 255, 0.12);
}

.btn-analyze {
  background: var(--accent);
  color: #071422;
  border: none;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  padding: 12px 28px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

.btn-analyze:hover { background: #6cb9ff; }
.btn-analyze:active { transform: scale(0.97); }
.btn-analyze:disabled {
  background: var(--accent-dim);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}

.hint {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Progress ────────────────────────────────────────────── */
#progress-area {
  display: none;
  margin-bottom: 32px;
}

.progress-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  padding: 6px 0;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.done-icon { color: var(--green); font-size: 14px; font-weight: 700; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Debug panel ─────────────────────────────────────────── */
#debug-panel {
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: var(--surface2);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  user-select: none;
}

.debug-header:hover { color: var(--text); }

#debug-toggle-label {
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.debug-log {
  margin: 0;
  padding: 12px 14px;
  background: #0a0c10;
  color: #5a8a5a;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Section titles ──────────────────────────────────────── */
.section-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 40px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Charts grid ─────────────────────────────────────────── */
#charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 20px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.chart-canvas-wrap {
  position: relative;
  height: 280px;
}

.chart-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.chart-cuts {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.chart-cut { color: var(--text-muted); }

.chart-cut strong {
  color: var(--text);
  font-weight: 600;
  margin-left: 4px;
}

.cut-up strong { color: var(--green); }
.cut-down strong { color: var(--red); }

.chart-source {
  color: var(--text-muted);
  font-size: 10px;
  text-align: right;
}

/* ── Backtest ────────────────────────────────────────────── */
#backtest-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}

#backtest-summary .headline {
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 4px;
}

#backtest-summary .sub {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 12px;
}

#backtest-summary .band { color: var(--text-muted); }

#backtest-summary .delta-up { color: var(--green); }
#backtest-summary .delta-down { color: var(--red); }
#backtest-summary .delta-flat { color: var(--text-muted); }

#backtest-chart-wrap .chart-card { margin-bottom: 16px; }

.per-signal-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
}

.per-signal-table th,
.per-signal-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.per-signal-table th {
  background: var(--surface2);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
}

.per-signal-table tr:last-child td { border-bottom: none; }

.per-signal-table td.num { text-align: right; }

/* ── Result (memo) ───────────────────────────────────────── */
#result-area { display: none; }

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 40px;
}

.result-card h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  color: var(--text);
}

.result-card h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 24px 0 12px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.result-card em {
  color: var(--text-muted);
  font-style: normal;
  font-size: 14px;
}

.result-card p { margin: 10px 0; color: var(--text); line-height: 1.75; }

.result-card strong { color: var(--accent); font-weight: 700; }

.result-card hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.result-card ul { padding-left: 20px; margin: 8px 0; }
.result-card li { margin: 4px 0; color: var(--text); }

.result-card code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 4px;
}

.result-card table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 20px;
  font-size: 13px;
}

.result-card table th,
.result-card table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.result-card table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface2);
}

/* ── Error ───────────────────────────────────────────────── */
.error-box {
  background: rgba(247, 111, 111, 0.08);
  border: 1px solid var(--red);
  border-radius: 8px;
  padding: 16px 20px;
  color: var(--red);
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

/* ── Footer ─────────────────────────────────────────────── */
footer {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { color: var(--text); }

.footer-disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  opacity: 0.7;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 720px) {
  .page { padding: 32px 16px 64px; }
  .input-row { flex-direction: column; }
  .btn-analyze { width: 100%; }
  .result-card { padding: 24px 20px; }
  #charts-grid { grid-template-columns: 1fr; }
  .chart-canvas-wrap { height: 240px; }
}
