:root {
  --bg: #f6f8fb;
  --ink: #111827;
  --muted: #647084;
  --line: #d9e0ea;
  --panel: #ffffff;
  --panel-soft: #f1f5f9;
  --nav: #0d1522;
  --nav-soft: #172235;
  --teal: #0f9f9a;
  --blue: #2869e6;
  --amber: #b87508;
  --rose: #ca3f58;
  --green: #17865f;
  --shadow: 0 18px 50px rgba(20, 31, 50, 0.12);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(40, 105, 230, 0.05), transparent 260px),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 24px 18px;
  background: var(--nav);
  color: #dbe7f7;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #e9fbff, #8fd6cc 48%, #2d75e8);
  color: #0b1524;
  font-size: 13px;
  font-weight: 800;
}

.brand p,
.brand span {
  margin: 0;
}

.brand p {
  font-size: 15px;
  font-weight: 800;
}

.brand span {
  color: #92a4bd;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #b9c6d8;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  border-color: rgba(255, 255, 255, 0.12);
  background: var(--nav-soft);
  color: #ffffff;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: var(--radius);
  color: #9cadc4;
  font-size: 12px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 159, 154, 0.16);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.topbar h1,
.topbar p {
  margin: 0;
}

.topbar h1 {
  font-size: 30px;
  line-height: 1.08;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
}

.topbar-controls,
.run-actions,
.tag-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-controls label,
.strategy-input,
.idea-input,
.journal-field {
  display: grid;
  gap: 6px;
}

label span,
.strategy-input label,
.idea-input label,
.journal-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

select,
input {
  height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 76px;
  padding: 10px 11px;
  line-height: 1.45;
  resize: vertical;
}

select:focus,
input:focus,
textarea:focus {
  border-color: rgba(40, 105, 230, 0.55);
  box-shadow: 0 0 0 3px rgba(40, 105, 230, 0.11);
}

.segmented {
  display: flex;
  height: 40px;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.segment {
  min-width: 54px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.segment.active {
  background: var(--ink);
  color: #ffffff;
}

.command-strip {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(260px, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 12px 36px rgba(20, 31, 50, 0.07);
}

.primary-btn,
.dark-btn,
.ghost-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-btn {
  border: 1px solid rgba(15, 159, 154, 0.2);
  background: var(--teal);
  color: #ffffff;
}

.dark-btn {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #ffffff;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.small {
  min-height: 34px;
  padding: 0 11px;
}

.gate-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  gap: 14px;
  margin-bottom: 14px;
}

.gate-card,
.panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(20, 31, 50, 0.06);
}

.gate-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 118px;
  padding: 18px;
}

.gate-card.quiet {
  display: block;
  background: #f9fbfd;
}

.gate-card h2,
.gate-card p {
  margin: 0;
}

.gate-card h2 {
  margin-top: 5px;
  font-size: 22px;
  line-height: 1.15;
}

.gate-card p {
  max-width: 620px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.gate-card.pass {
  border-color: rgba(23, 134, 95, 0.34);
  background: linear-gradient(135deg, rgba(23, 134, 95, 0.1), #ffffff 58%);
}

.gate-card.warn {
  border-color: rgba(184, 117, 8, 0.34);
  background: linear-gradient(135deg, rgba(184, 117, 8, 0.11), #ffffff 58%);
}

.gate-card.fail {
  border-color: rgba(202, 63, 88, 0.34);
  background: linear-gradient(135deg, rgba(202, 63, 88, 0.1), #ffffff 58%);
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric-card {
  display: grid;
  gap: 6px;
  min-height: 112px;
  padding: 16px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric-card strong {
  font-size: 30px;
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
  font-size: 12px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr);
  gap: 14px;
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.chart-panel,
.checklist-panel,
.candidates-panel,
.journal-panel {
  min-height: 350px;
}

.candidates-panel,
.journal-panel {
  grid-column: span 1;
}

.journal-panel {
  grid-row: span 2;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header h3 {
  margin: 4px 0 0;
  font-size: 17px;
  line-height: 1.2;
}

.panel-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(40, 105, 230, 0.1);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.panel-chip.amber {
  background: rgba(184, 117, 8, 0.12);
  color: var(--amber);
}

.chart {
  display: block;
  width: 100%;
  height: 290px;
  overflow: visible;
}

.axis-line,
.grid-line {
  stroke: #dfe6ef;
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: var(--blue);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-area {
  fill: rgba(40, 105, 230, 0.12);
}

.drawdown-area {
  fill: rgba(202, 63, 88, 0.18);
}

.drawdown-line {
  fill: none;
  stroke: var(--rose);
  stroke-width: 2.5;
}

.mc-band {
  fill: rgba(15, 159, 154, 0.12);
}

.mc-line {
  fill: none;
  stroke: var(--teal);
  stroke-width: 3;
}

.bar {
  fill: rgba(40, 105, 230, 0.72);
}

.bar.loss {
  fill: rgba(202, 63, 88, 0.7);
}

.chart-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.checklist {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdff;
}

.check-symbol {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.check-item.pass .check-symbol {
  background: rgba(23, 134, 95, 0.12);
  color: var(--green);
}

.check-item.fail .check-symbol {
  background: rgba(202, 63, 88, 0.12);
  color: var(--rose);
}

.check-title {
  margin: 0;
  font-size: 13px;
  font-weight: 850;
}

.check-copy {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

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

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 9px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  font-weight: 700;
}

tr.selected {
  background: rgba(15, 159, 154, 0.08);
}

.robust {
  color: var(--green);
}

.fragile {
  color: var(--amber);
}

.journal-panel {
  display: grid;
  gap: 12px;
}

.journal-panel .panel-header {
  margin-bottom: 0;
}

.journal-field textarea {
  min-height: 148px;
}

.tag-row {
  flex-wrap: wrap;
}

.tag-row span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfdff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.journal-list {
  display: grid;
  gap: 10px;
  max-height: 240px;
  overflow: auto;
}

.journal-entry {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdff;
}

.journal-entry h4,
.journal-entry p {
  margin: 0;
}

.journal-entry h4 {
  font-size: 13px;
}

.journal-entry p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    flex-direction: row;
    align-items: center;
    height: auto;
    padding: 14px;
    overflow-x: auto;
  }

  .nav-list {
    display: flex;
  }

  .nav-item {
    width: auto;
  }

  .sidebar-footer {
    margin-left: auto;
    margin-top: 0;
  }

  .command-strip,
  .content-grid,
  .gate-row {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .topbar-controls,
  .run-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .gate-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .chart {
    height: 240px;
  }
}

/* 2026-06-25 site-wide minimal color pass */
body[data-page="backtester-hub"] {
  --zl-black: #020303;
  --zl-ink: #f1f1ee;
  --zl-muted: rgba(241, 241, 238, 0.62);
  --zl-line: rgba(241, 241, 238, 0.13);
  --zl-panel: rgba(255, 255, 255, 0.046);
  --zl-panel-strong: rgba(255, 255, 255, 0.072);
  --zl-accent: #85f2a4;
  --zl-danger: #ff8f9d;
  background:
    radial-gradient(circle at 84% 12%, rgba(133, 242, 164, 0.12), transparent 24%),
    linear-gradient(90deg, rgba(241, 241, 238, 0.034) 1px, transparent 1px),
    linear-gradient(rgba(241, 241, 238, 0.024) 1px, transparent 1px),
    var(--zl-black);
  background-size: auto, 76px 76px, 76px 76px, auto;
  color: var(--zl-ink);
}

body[data-page="backtester-hub"] .motion-progress {
  display: none !important;
}

body[data-page="backtester-hub"] .app-shell {
  width: min(100% - 48px, 1280px);
  margin: 0 auto;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 18px;
  padding: 16px 0 72px;
}

body[data-page="backtester-hub"] .sidebar {
  top: 16px;
  height: calc(100svh - 32px);
  border: 1px solid var(--zl-line);
  border-radius: 8px;
  background:
    linear-gradient(145deg, var(--zl-panel-strong), rgba(255, 255, 255, 0.018)),
    rgba(2, 3, 3, 0.56);
  color: var(--zl-ink);
  box-shadow: none;
}

body[data-page="backtester-hub"] .brand-mark {
  border-color: rgba(133, 242, 164, 0.58);
  border-radius: 0;
  background: transparent;
  color: transparent;
  box-shadow: none;
}

body[data-page="backtester-hub"] .brand-mark::before {
  content: "Z/L";
  color: var(--zl-accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 900;
}

body[data-page="backtester-hub"] .brand p,
body[data-page="backtester-hub"] .brand span,
body[data-page="backtester-hub"] .nav-item,
body[data-page="backtester-hub"] .sidebar-footer,
body[data-page="backtester-hub"] label span,
body[data-page="backtester-hub"] .strategy-input label,
body[data-page="backtester-hub"] .idea-input label,
body[data-page="backtester-hub"] .journal-field span,
body[data-page="backtester-hub"] .eyebrow,
body[data-page="backtester-hub"] .panel-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

body[data-page="backtester-hub"] .brand p {
  color: var(--zl-ink);
  font-size: 0.76rem;
  letter-spacing: 0.16em;
}

body[data-page="backtester-hub"] .brand span,
body[data-page="backtester-hub"] .sidebar-footer,
body[data-page="backtester-hub"] .nav-item {
  color: var(--zl-muted);
  font-size: 0.72rem;
}

body[data-page="backtester-hub"] .nav-item {
  min-height: 42px;
  border-radius: 4px;
}

body[data-page="backtester-hub"] .nav-item:hover,
body[data-page="backtester-hub"] .nav-item.active {
  border-color: rgba(133, 242, 164, 0.38);
  background: rgba(133, 242, 164, 0.08);
  color: var(--zl-ink);
}

body[data-page="backtester-hub"] .sidebar-footer {
  border-color: var(--zl-line);
  border-radius: 4px;
  background: transparent;
}

body[data-page="backtester-hub"] .status-dot {
  background: var(--zl-accent);
  box-shadow: 0 0 0 4px rgba(133, 242, 164, 0.12);
}

body[data-page="backtester-hub"] .workspace {
  padding: clamp(24px, 5vw, 54px) 0 0;
}

body[data-page="backtester-hub"] .topbar {
  align-items: end;
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--zl-line);
}

body[data-page="backtester-hub"] .topbar h1 {
  max-width: 780px;
  color: var(--zl-ink);
  font-size: clamp(4rem, 9vw, 9rem);
  font-weight: 950;
  letter-spacing: -0.075em;
  line-height: 0.78;
}

body[data-page="backtester-hub"] .topbar p {
  max-width: 560px;
  margin-top: 20px;
  color: var(--zl-muted);
  font-size: clamp(1rem, 1.35vw, 1.18rem);
  line-height: 1.55;
}

body[data-page="backtester-hub"] :where(.command-strip, .gate-card, .metric-card, .panel, .check-item, .journal-entry, .tag-row span, .empty-state) {
  border: 1px solid var(--zl-line);
  border-radius: 8px;
  background:
    linear-gradient(145deg, var(--zl-panel-strong), rgba(255, 255, 255, 0.018)),
    rgba(2, 3, 3, 0.42);
  box-shadow: none;
}

body[data-page="backtester-hub"] :where(button, .primary-btn, .ghost-btn, .dark-btn, .segment, select, input, textarea) {
  border-radius: 4px;
  box-shadow: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

body[data-page="backtester-hub"] :where(select, input, textarea) {
  border: 1px solid var(--zl-line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--zl-ink);
}

body[data-page="backtester-hub"] .primary-btn {
  border-color: var(--zl-ink);
  background: var(--zl-ink);
  color: var(--zl-black);
}

body[data-page="backtester-hub"] .ghost-btn,
body[data-page="backtester-hub"] .dark-btn,
body[data-page="backtester-hub"] .segment {
  border-color: var(--zl-line);
  background: transparent;
  color: var(--zl-ink);
}

body[data-page="backtester-hub"] .segment.active,
body[data-page="backtester-hub"] .segment:hover {
  border-color: rgba(133, 242, 164, 0.46);
  background: rgba(133, 242, 164, 0.08);
}

body[data-page="backtester-hub"] :where(h2, h3, h4, strong, td) {
  color: var(--zl-ink);
}

body[data-page="backtester-hub"] :where(p, small, th, .check-copy, .chart-label) {
  color: var(--zl-muted);
}

body[data-page="backtester-hub"] .eyebrow,
body[data-page="backtester-hub"] .metric-card span,
body[data-page="backtester-hub"] .panel-chip,
body[data-page="backtester-hub"] .robust {
  color: var(--zl-accent);
}

body[data-page="backtester-hub"] .fragile {
  color: #f0e880;
}

body[data-page="backtester-hub"] .chart {
  border-color: var(--zl-line);
  background: rgba(0, 0, 0, 0.24);
}

body[data-page="backtester-hub"] tr.selected {
  background: rgba(133, 242, 164, 0.08);
}

@media (max-width: 1180px) {
  body[data-page="backtester-hub"] .app-shell {
    grid-template-columns: 1fr;
  }

  body[data-page="backtester-hub"] .sidebar {
    position: relative;
    top: auto;
    height: auto;
  }
}

@media (max-width: 720px) {
  body[data-page="backtester-hub"] .app-shell {
    width: min(100% - 28px, 1280px);
  }

  body[data-page="backtester-hub"] .topbar {
    align-items: stretch;
  }

  body[data-page="backtester-hub"] .topbar h1 {
    font-size: clamp(3.4rem, 17vw, 6.6rem);
  }
}

/* 2026-06-25 revised palette */
body[data-page="backtester-hub"] {
  --zl-accent: #d9b66f;
  background:
    radial-gradient(circle at 84% 12%, rgba(217, 182, 111, 0.11), transparent 24%),
    linear-gradient(90deg, rgba(241, 241, 238, 0.032) 1px, transparent 1px),
    linear-gradient(rgba(241, 241, 238, 0.022) 1px, transparent 1px),
    var(--zl-black);
  background-size: auto, 76px 76px, 76px 76px, auto;
}

body[data-page="backtester-hub"] .brand-mark {
  border-color: rgba(217, 182, 111, 0.5);
}

body[data-page="backtester-hub"] .segmented {
  border-color: var(--zl-line);
  background: rgba(0, 0, 0, 0.28);
}

body[data-page="backtester-hub"] .gate-card.quiet {
  background:
    linear-gradient(145deg, var(--zl-panel-strong), rgba(255, 255, 255, 0.018)),
    rgba(2, 3, 3, 0.42);
}

body[data-page="backtester-hub"] .nav-item:hover,
body[data-page="backtester-hub"] .nav-item.active,
body[data-page="backtester-hub"] .segment.active,
body[data-page="backtester-hub"] .segment:hover {
  border-color: rgba(217, 182, 111, 0.42);
  background: rgba(217, 182, 111, 0.08);
}
