/* ChartPulse - Pro Backtesting page. Self-contained so it cannot clash with the
   rest of the site's CSS, but uses the same type and colour system. */

.btp {
  --bg: #0a0e14;
  --panel: #111722;
  --panel2: #161d2b;
  --raise: #1b2436;
  --line: #1f2838;
  --line2: #2b3447;
  --text: #e6edf6;
  --muted: #8b9bb4;
  --dim: #5e6e86;
  --blue: #2962ff;
  --blue-dim: #1e49bf;
  --orange: #ff9800;
  --up: #26a69a;
  --down: #ef5350;
  --gold: #f4b740;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;

  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.btp *, .btp *::before, .btp *::after { box-sizing: border-box; }
.btp h1, .btp h2, .btp h3 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; margin: 0; }
.btp .wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.btp .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- header */
.btp-nav {
  position: sticky; top: 0; z-index: 40;
  background: rgba(10, 14, 20, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.btp-nav .wrap { display: flex; align-items: center; gap: 18px; height: 56px; }
.btp-brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); }
.btp-brand b { font-family: var(--serif); font-size: 20px; font-weight: 400; letter-spacing: 0.2px; }
.btp-ring { width: 20px; height: 20px; flex: 0 0 20px; }
.btp-links { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.btp-links a {
  color: var(--muted); text-decoration: none; font-size: 13.5px;
  padding: 7px 11px; border-radius: 7px;
}
.btp-links a:hover { color: var(--text); background: var(--panel2); }
.btp-links a.on { color: var(--text); background: var(--raise); }
.btp-links .free { color: var(--up); }

/* ------------------------------------------------------------------ hero */
.btp-hero { padding: 42px 0 26px; border-bottom: 1px solid var(--line); background:
  radial-gradient(900px 300px at 15% -10%, rgba(41, 98, 255, 0.14), transparent 70%),
  radial-gradient(700px 280px at 85% -20%, rgba(255, 152, 0, 0.09), transparent 70%); }
.btp-hero h1 { font-size: clamp(30px, 5vw, 48px); line-height: 1.08; }
.btp-hero p { color: var(--muted); max-width: 70ch; margin: 12px 0 0; font-size: 15.5px; }
.btp-tag {
  display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--up); border: 1px solid rgba(38, 166, 154, 0.35);
  background: rgba(38, 166, 154, 0.1); padding: 4px 10px; border-radius: 999px; margin-bottom: 14px;
  font-family: var(--mono);
}
.btp-hero ul { display: flex; gap: 20px; flex-wrap: wrap; list-style: none; padding: 0; margin: 18px 0 0; }
.btp-hero ul li { color: var(--dim); font-size: 13px; }
.btp-hero ul li b { color: var(--text); font-weight: 500; display: block; font-size: 14px; }

/* ----------------------------------------------------------------- panel */
.btp-grid { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 18px; padding: 22px 0 60px; align-items: start; }
.btp-grid > * { min-width: 0; }
.btp-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.btp-card > header {
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.btp-card > header h2 { font-size: 17px; }
.btp-card > header .run { margin-left: auto; }
.btp-card > header .step {
  font-family: var(--mono); font-size: 11px; color: var(--blue);
  border: 1px solid rgba(41, 98, 255, 0.4); border-radius: 5px; padding: 2px 6px;
}
.btp-card > .body { padding: 16px; }
.btp-side { display: grid; gap: 14px; position: sticky; top: 72px; }

.btp-field { display: block; margin-bottom: 12px; }
.btp-field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.btp-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btp-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

.btp input, .btp select, .btp textarea {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font: inherit; font-size: 13.5px; outline: none;
}
.btp input.num, .btp select.num { font-family: var(--mono); }
.btp input:focus, .btp select:focus, .btp textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(41, 98, 255, 0.16); }
.btp select { appearance: none; background-image:
  linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 26px; }
.btp input[type=checkbox] { width: auto; }

.btp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--blue); color: #fff; border: 1px solid var(--blue);
  border-radius: 9px; padding: 10px 16px; font: inherit; font-weight: 500; font-size: 14px;
  cursor: pointer; justify-content: center;
}
.btp-btn:hover { background: #3b74ff; }
.btp-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btp-btn.wide { width: 100%; padding: 12px; font-size: 15px; }
.btp-btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btp-btn.ghost:hover { background: var(--panel2); }
.btp-btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 7px; }

.btp-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.btp-chip {
  background: var(--panel2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; font: inherit;
  font-size: 12.5px;
}
.btp-chip:hover { color: var(--text); border-color: var(--dim); }
.btp-chip.on { background: rgba(41, 98, 255, 0.16); border-color: var(--blue); color: #cfe0ff; }

/* ------------------------------------------------------------ rule rows */
.btp-bucket { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; overflow: hidden; }
.btp-bucket > h3 {
  font-family: var(--sans); font-size: 12px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted); background: var(--panel2);
  padding: 9px 12px; display: flex; align-items: center; gap: 8px;
}
.btp-bucket.long > h3 { border-left: 3px solid var(--up); }
.btp-bucket.short > h3 { border-left: 3px solid var(--down); }
.btp-bucket > h3 .hint { margin-left: auto; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--dim); font-size: 11.5px; }
.btp-bucket > div { padding: 10px 12px; }
.btp-rule { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 8px 0; border-top: 1px dashed var(--line); }
.btp-rule > .btp-operand { grid-column: 1 / -1; }
.btp-rule:first-child { border-top: 0; }
.btp-operand { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 6px; }
.btp-operand select { width: auto; min-width: 96px; flex: 1 1 96px; font-size: 12.5px; padding: 5px 24px 5px 7px; }
.btp-operand input { width: 62px; font-size: 12.5px; padding: 5px 6px; text-align: right; font-family: var(--mono); }
.btp-operand .tf { min-width: 78px; flex: 0 1 86px; }
.btp-op { width: 100% !important; font-size: 12.5px; }
.btp-x { background: transparent; border: 0; color: var(--dim); cursor: pointer; font-size: 15px; padding: 4px 6px; line-height: 1; }
.btp-x:hover { color: var(--down); }
.btp-opt {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; color: var(--dim);
  border: 1px solid var(--line); background: transparent; border-radius: 5px;
  padding: 3px 5px; cursor: pointer;
}
.btp-opt.on { color: var(--gold); border-color: rgba(244, 183, 64, 0.5); background: rgba(244, 183, 64, 0.1); }

/* ---------------------------------------------------------------- result */
.btp-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(126px, 1fr)); gap: 1px; background: var(--line); border-radius: 10px; overflow: hidden; }
@media (min-width: 760px) { .btp-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1320px) { .btp-kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.btp-kpi { background: var(--panel); padding: 13px 14px; }
.btp-kpi span { display: block; font-size: 11px; color: var(--muted); letter-spacing: 0.03em; }
.btp-kpi b { font-family: var(--mono); font-size: 20px; font-weight: 500; display: block; margin-top: 3px; letter-spacing: -0.02em; }
.btp-kpi b.up { color: var(--up); }
.btp-kpi b.down { color: var(--down); }
.btp-kpi small { color: var(--dim); font-size: 11px; font-family: var(--mono); }

.btp-chartbox { position: relative; margin-top: 16px; }
.btp-chartbox canvas { display: block; width: 100%; height: 320px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); }
.btp-legend { display: flex; gap: 16px; align-items: center; margin: 10px 0 0; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.btp-legend i { display: inline-block; width: 11px; height: 2px; vertical-align: middle; margin-right: 6px; }
.btp-tip {
  position: absolute; pointer-events: none; background: #060a11; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; font-family: var(--mono);
  white-space: nowrap; opacity: 0; transition: opacity 0.1s; z-index: 5;
}

.btp-notes { margin-top: 16px; display: grid; gap: 8px; }
.btp-note { display: flex; gap: 10px; font-size: 13px; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); }
.btp-note.warn { border-color: rgba(244, 183, 64, 0.32); background: rgba(244, 183, 64, 0.07); color: #e9d6a7; }
.btp-note b { color: var(--text); }

.btp-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 20px 0 0; flex-wrap: wrap; }
.btp-tab {
  background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted);
  padding: 9px 13px; font: inherit; font-size: 13.5px; cursor: pointer;
}
.btp-tab.on { color: var(--text); border-bottom-color: var(--blue); }
.btp-pane { display: none; padding-top: 14px; }
.btp-pane.on { display: block; }

.btp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.btp-table th {
  text-align: right; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--panel); white-space: nowrap;
}
.btp-table th:first-child, .btp-table td:first-child { text-align: left; }
.btp-table td { padding: 7px 10px; border-bottom: 1px solid rgba(31, 40, 56, 0.6); font-family: var(--mono); white-space: nowrap; }
.btp-table td.t { font-family: var(--sans); color: var(--muted); }
.btp-table tbody tr:hover { background: var(--panel2); }
.btp-table .up { color: var(--up); }
.btp-table .down { color: var(--down); }
.btp-scroll { max-width: 100%; max-height: 440px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.btp-pill { font-size: 10.5px; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.05em; border-radius: 4px; padding: 2px 5px; border: 1px solid var(--line); color: var(--muted); }
.btp-pill.stop { color: var(--down); border-color: rgba(239, 83, 80, 0.4); }
.btp-pill.target { color: var(--up); border-color: rgba(38, 166, 154, 0.4); }

.btp-mc { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.btp-mc div { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 12px; }
.btp-mc span { display: block; font-size: 11px; color: var(--muted); }
.btp-mc b { font-family: var(--mono); font-size: 16px; font-weight: 500; }

.btp-empty { text-align: center; padding: 56px 20px; color: var(--dim); }
.btp-empty h3 { font-size: 20px; color: var(--muted); margin-bottom: 8px; }

.btp-err { border: 1px solid rgba(239, 83, 80, 0.4); background: rgba(239, 83, 80, 0.08); color: #ffc7c5; border-radius: 10px; padding: 12px 14px; font-size: 13.5px; margin-top: 14px; }

.btp-spin { display: inline-block; width: 13px; height: 13px; border: 2px solid rgba(255, 255, 255, 0.3); border-top-color: #fff; border-radius: 50%; animation: btp-rot 0.7s linear infinite; }
@keyframes btp-rot { to { transform: rotate(360deg); } }
.btp-bar { height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 10px; }
.btp-bar i { display: block; height: 100%; width: 35%; background: var(--blue); animation: btp-slide 1.1s ease-in-out infinite; }
@keyframes btp-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(330%); } }

.btp-risk {
  border: 1px solid rgba(244, 183, 64, 0.3); background: rgba(244, 183, 64, 0.06);
  border-radius: 10px; padding: 14px 16px; margin: 0 0 22px; font-size: 13px; color: #d9c9a4;
}
.btp-risk b { color: var(--gold); }

.btp-foot { border-top: 1px solid var(--line); padding: 26px 0 40px; color: var(--dim); font-size: 12.5px; }
.btp-foot a { color: var(--muted); }

.btp-help { font-size: 12px; color: var(--dim); margin: 6px 0 0; }
.btp-wfgrid { display: grid; gap: 9px; }
.btp-wfrow { display: grid; grid-template-columns: minmax(0, 1fr) 62px 62px 62px; gap: 7px; align-items: center; font-size: 12.5px; }
.btp-wfrow label { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btp-wfrow input { padding: 6px; font-size: 12.5px; text-align: right; font-family: var(--mono); }

@media (max-width: 1000px) {
  .btp-grid { grid-template-columns: minmax(0, 1fr); }
  .btp-side { position: static; }
}
@media (max-width: 560px) {
  .btp .wrap { padding: 0 14px; }
  .btp-hero { padding: 30px 0 20px; }
  .btp-kpi b { font-size: 17px; }
  .btp-operand select { min-width: 94px; }
}
