*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --surface: #111118;
  --card: #16161f;
  --border: rgba(255,255,255,0.07);
  --primary: #6366f1;
  --accent: #a78bfa;
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --text: #f1f5f9;
  --muted: #64748b;
  --radius: 12px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
}

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 24px;
}
.logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.logo-text { font-weight: 800; font-size: 18px; }
.logo-sub { font-size: 10px; color: var(--primary); text-transform: uppercase; letter-spacing: 2px; }

nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-link:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-link.active { background: rgba(99,102,241,0.15); color: var(--primary); }

.status-pill {
  margin-top: auto;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 12px;
}
.status-dot {
  display: inline-block; width: 8px; height: 8px;
  background: var(--success); border-radius: 50%;
  animation: pulse 2s infinite;
  margin-right: 6px;
  vertical-align: middle;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── Main ── */
main {
  flex: 1;
  padding: 40px;
  overflow-y: auto;
}

/* ── Pages ── */
.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }
@keyframes fadeIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:none} }

/* ── Dashboard ── */
.hero-text {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #fff 40%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}
.hero-sub { color: var(--muted); font-size: 16px; max-width: 600px; margin-bottom: 40px; }

.metrics-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 40px; }
.metric-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s;
}
.metric-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  height: 2px; width: 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.4s ease;
}
.metric-card:hover::after { width: 100%; }
.metric-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; }
.metric-value { font-size: 30px; font-weight: 800; font-family: monospace; margin-bottom: 4px; }
.metric-value.success { color: var(--success); }
.metric-sub { font-size: 12px; color: var(--muted); }

.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.tool-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  transition: border-color 0.3s, transform 0.2s;
  position: relative;
  overflow: hidden;
}
.tool-card:hover { transform: translateY(-2px); }
.primary-glow:hover { border-color: rgba(99,102,241,0.4); }
.accent-glow:hover { border-color: rgba(167,139,250,0.4); }
.tool-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin-bottom: 20px;
}
.primary-icon { background: rgba(99,102,241,0.15); border: 1px solid rgba(99,102,241,0.3); color: var(--primary); }
.accent-icon  { background: rgba(167,139,250,0.15); border: 1px solid rgba(167,139,250,0.3); color: var(--accent); }
.tool-card h2 { font-size: 20px; font-weight: 800; margin-bottom: 10px; }
.tool-card p { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 24px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #4f52e0; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #8b72f0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.w-full { width: 100%; }

/* ── Page layout ── */
.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 36px;
}
.page-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.page-title { font-size: 26px; font-weight: 900; letter-spacing: -0.5px; }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ── Two-col layout ── */
.two-col { display: grid; grid-template-columns: 320px 1fr; gap: 28px; align-items: start; }
.sticky-card { position: sticky; top: 0; }

/* ── Card ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.card-sub { font-size: 12px; color: var(--muted); margin-bottom: 24px; }

/* ── Form ── */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.field input, .field select {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--primary); }
.field select option { background: #1e1e2e; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Toggle ── */
.toggle-row {
  display: flex;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}
.toggle-btn {
  flex: 1;
  padding: 8px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s;
}
.toggle-btn.active { background: var(--accent); color: #fff; }

/* ── Empty state ── */
.results-area { min-height: 360px; }
.empty-state {
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(255,255,255,0.08);
  border-radius: 20px;
  text-align: center;
  padding: 40px;
}
.empty-icon { font-size: 48px; opacity: 0.2; margin-bottom: 16px; }
.empty-title { font-size: 18px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.empty-sub { font-size: 13px; color: var(--muted); opacity: 0.6; max-width: 300px; line-height: 1.6; }

/* ── Loading ── */
.loading-state {
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(99,102,241,0.2);
  border-radius: 20px;
  text-align: center;
  padding: 40px;
  background: rgba(99,102,241,0.04);
}
.spinner {
  width: 48px; height: 48px;
  border: 3px solid rgba(99,102,241,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-title { font-size: 18px; font-weight: 700; color: var(--primary); margin-bottom: 6px; }
.loading-sub { font-size: 13px; color: rgba(99,102,241,0.6); font-family: monospace; }

/* ── Result grids ── */
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s;
}
.result-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  height: 2px; width: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.result-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.result-value { font-size: 26px; font-weight: 800; font-family: monospace; margin-bottom: 4px; }
.result-value.up { color: var(--success); }
.result-value.down { color: var(--danger); }
.result-sub { font-size: 12px; color: var(--muted); }

.range-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.range-card {
  border-radius: 16px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.range-card.down-card { background: rgba(248,113,113,0.07); border: 1px solid rgba(248,113,113,0.2); }
.range-card.up-card   { background: rgba(52,211,153,0.07); border: 1px solid rgba(52,211,153,0.2); }
.range-label { font-size: 11px; margin-bottom: 8px; font-weight: 700; }
.down-card .range-label { color: var(--danger); }
.up-card   .range-label { color: var(--success); }
.range-value { font-size: 24px; font-weight: 800; font-family: monospace; margin-bottom: 4px; }
.range-sub { font-size: 12px; color: var(--muted); }

.stat-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.stat-value { font-size: 18px; font-weight: 700; font-family: monospace; }

/* ── Option results ── */
.price-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.price-box {
  border-radius: 20px;
  padding: 28px;
  position: relative;
  overflow: hidden;
}
.price-box.bs  { background: rgba(99,102,241,0.08); border: 1px solid rgba(99,102,241,0.2); }
.price-box.mc  { background: rgba(167,139,250,0.08); border: 1px solid rgba(167,139,250,0.2); }
.price-box-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 14px; }
.bs .price-box-label { color: var(--primary); }
.mc .price-box-label { color: var(--accent); }
.price-big { font-size: 44px; font-weight: 900; font-family: monospace; color: #fff; margin-bottom: 6px; }
.price-box-sub { font-size: 12px; color: var(--muted); }

.contract-summary {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  font-family: monospace;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.contract-badge {
  background: rgba(255,255,255,0.1);
  padding: 3px 10px;
  border-radius: 6px;
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text);
}

.divergence-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.divergence-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.divergence-sub { font-size: 12px; color: var(--muted); }
.divergence-value { font-size: 28px; font-weight: 900; font-family: monospace; margin-bottom: 2px; }
.divergence-value.low { color: var(--success); }
.divergence-value.mid { color: var(--warning); }
.divergence-value.high { color: var(--danger); }
.divergence-abs { font-size: 12px; color: var(--muted); font-family: monospace; }

/* ── Error box ── */
.error-box {
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.3);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .metrics-row { grid-template-columns: 1fr 1fr; }
  .tool-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  main { padding: 24px 16px; }
}
@media (max-width: 540px) {
  .metrics-row { grid-template-columns: 1fr 1fr; }
  .result-grid, .range-row, .price-grid { grid-template-columns: 1fr; }
}