:root {
  color: #16212b;
  background: #f4f7fb;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: geometricPrecision;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-strong: #f9fbfe;
  --ink: #16212b;
  --muted: #5e7182;
  --line: #d9e2ec;
  --line-strong: #b9c8d6;
  --nav: #111b26;
  --nav-2: #172637;
  --accent: #126e82;
  --accent-2: #1f8f6b;
  --accent-soft: #e6f4f1;
  --warning: #9a6b12;
  --warning-soft: #fff5d8;
  --danger: #b42318;
  --danger-2: #8f1f17;
  --danger-soft: #fff0ed;
  --success: #16714f;
  --success-soft: #e8f6ef;
  --shadow-sm: 0 1px 2px rgb(17 27 38 / 8%), 0 1px 8px rgb(17 27 38 / 5%);
  --shadow-md: 0 10px 28px rgb(17 27 38 / 10%);
  --shadow-lg: 0 18px 45px rgb(17 27 38 / 14%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  overflow-x: hidden;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #eef4f9 0, #f7f9fc 360px, #f4f7fb 100%),
    var(--bg);
}

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

button,
input,
select {
  min-width: 0;
}

button {
  position: relative;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 14px;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff, #f4f8fb);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  overflow-wrap: anywhere;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    opacity 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: #8fb0c5;
  box-shadow: var(--shadow-md);
}

button:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: 0 2px 8px rgb(17 27 38 / 12%);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgb(18 110 130 / 24%);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
  box-shadow: none;
}

.primary-action {
  border-color: #0f6476;
  color: #ffffff;
  background: linear-gradient(180deg, #167f92, #0f6476);
}

.primary-action:hover {
  border-color: #0a5262;
  background: linear-gradient(180deg, #188aa0, #0d5d6e);
}

.secondary-action {
  border-color: #9db4c7;
  color: #173247;
  background: linear-gradient(180deg, #ffffff, #edf5f8);
}

.warning-action {
  border-color: #9a6b12;
  color: #ffffff;
  background: linear-gradient(180deg, #c88a19, #9a6b12);
}

.warning-action:hover {
  border-color: #7b540d;
  background: linear-gradient(180deg, #d59624, #84590e);
}

.danger-action {
  border-color: #a5271d;
  color: #ffffff;
  background: linear-gradient(180deg, #c8372b, #9f241b);
}

.danger-action:hover {
  border-color: var(--danger-2);
  background: linear-gradient(180deg, #d23b2e, #8f1f17);
}

.is-busy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgb(255 255 255 / 45%);
  border-top-color: #ffffff;
  border-radius: 999px;
  animation: spin 800ms linear infinite;
}

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

#app {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 24px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--nav), var(--nav-2));
  border-bottom: 1px solid rgb(255 255 255 / 9%);
  box-shadow: 0 10px 30px rgb(17 27 38 / 18%);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 245px;
  max-width: 100%;
  gap: 12px;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 24%), 0 8px 18px rgb(0 0 0 / 20%);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand span:not(.brand-mark) {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.brand strong {
  line-height: 1.1;
  font-size: 15px;
  letter-spacing: 0;
}

.brand span:not(.brand-mark) {
  margin-top: 3px;
  color: #9fb8cb;
  font-size: 12px;
  text-transform: uppercase;
}

nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

nav button {
  flex: 0 1 auto;
  min-height: 34px;
  max-width: 100%;
  border-color: rgb(255 255 255 / 12%);
  color: #cbd8e3;
  background: rgb(255 255 255 / 5%);
  box-shadow: none;
}

nav button:hover {
  color: #ffffff;
  border-color: rgb(255 255 255 / 25%);
  background: rgb(255 255 255 / 10%);
}

nav button.active {
  color: #ffffff;
  border-color: rgb(55 203 163 / 42%);
  background: linear-gradient(180deg, rgb(22 143 107 / 36%), rgb(18 110 130 / 28%));
}

.content {
  width: min(100%, 1220px);
  margin: 0 auto;
  padding: 28px 24px 48px;
}

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

.page-heading > div:first-child {
  min-width: 0;
}

.page-heading h1 {
  margin: 4px 0 0;
  font-size: 30px;
  line-height: 1.12;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.page-heading p:not(.eyebrow) {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.identity-pill {
  flex: 0 1 auto;
  max-width: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: #244258;
  background: rgb(255 255 255 / 78%);
  box-shadow: var(--shadow-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.hero {
  display: flex;
  align-items: center;
  min-height: 220px;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 8px;
  padding: 32px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgb(17 27 38 / 95%), rgb(18 65 79 / 92%) 58%, rgb(30 94 74 / 90%)),
    #111b26;
  box-shadow: var(--shadow-lg);
}

.hero h1 {
  margin: 8px 0;
  font-size: 42px;
  line-height: 1.06;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.hero p:not(.eyebrow) {
  margin: 0;
  color: #c3d4df;
  line-height: 1.55;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: 16px;
  margin-top: 18px;
}

.tile,
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.tile {
  padding: 18px;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.tile:hover {
  transform: translateY(-2px);
  border-color: #b4c8d8;
  box-shadow: var(--shadow-md);
}

.tile span,
.tile small {
  display: block;
  color: var(--muted);
}

.tile span {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.tile strong {
  display: block;
  margin: 8px 0;
  font-size: 28px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.tile small {
  line-height: 1.45;
}

.panel {
  padding: 18px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-title > div {
  min-width: 0;
}

.panel-title span,
.panel-title strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.panel-title span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.panel-title strong {
  margin-top: 2px;
  font-size: 18px;
}

.list-panel {
  display: grid;
  gap: 10px;
}

.list-panel p,
.status-note p,
.login-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.list-panel p {
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  background: var(--surface-strong);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.actions button,
.form-panel button[type="submit"],
.login-panel button,
#refresh-brokers {
  flex: 1 1 150px;
  min-width: 150px;
}

form {
  display: grid;
  gap: 14px;
}

.form-panel {
  max-width: 640px;
}

.backtest-config-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
  align-items: start;
}

.backtest-config-layout .form-panel {
  max-width: none;
}

.strategy-code-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.strategy-code-summary {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px 13px;
  background: var(--surface-strong);
}

.strategy-code-summary p,
.strategy-code-summary small {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.strategy-code-summary p {
  color: #244258;
  font-weight: 700;
}

.strategy-code-summary small {
  color: var(--muted);
}

.strategy-code-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.strategy-code-fact {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  background: #fbfdff;
}

.strategy-code-fact span,
.strategy-code-fact strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.strategy-code-fact strong {
  margin-top: 5px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}

.strategy-code-block {
  min-width: 0;
  max-height: 560px;
  overflow: auto;
  margin: 0;
  border: 1px solid #25384a;
  border-radius: 8px;
  padding: 15px;
  color: #d8e8f1;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 3%), rgb(255 255 255 / 0%)),
    #101b26;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 8%);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  tab-size: 2;
}

.strategy-code-block code {
  display: block;
  min-width: max-content;
  white-space: pre;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: #31495b;
  font-size: 14px;
  font-weight: 700;
}

label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 11px;
  color: var(--ink);
  background: #ffffff;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

input:hover,
select:hover {
  border-color: #8fb0c5;
}

input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(min(320px, 100%), 430px);
  gap: 28px;
  align-items: center;
  min-height: calc(100vh - 142px);
}

.login-copy {
  max-width: 680px;
  padding: 24px 0;
}

.login-copy h1 {
  margin: 8px 0 12px;
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: 0;
}

.login-copy p:not(.eyebrow) {
  max-width: 600px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.login-panel {
  display: grid;
  gap: 16px;
  box-shadow: var(--shadow-lg);
}

.login-panel form {
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.status-note {
  max-width: 640px;
  margin-top: 14px;
  background: var(--surface-strong);
}

.status-note strong {
  display: block;
  margin-bottom: 6px;
}

.backtest-status-panel {
  display: grid;
  gap: 14px;
  max-width: none;
  margin-top: 16px;
}

.status-note-inline {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 7px;
  padding: 11px 12px;
  color: #244258;
  background: var(--surface-strong);
  line-height: 1.45;
}

.status-loading {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
}

.status-loading .spinner {
  border-color: rgb(18 110 130 / 22%);
  border-top-color: var(--accent);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  min-height: 30px;
  min-width: 112px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.panel-title > .status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.status-ok {
  border-color: #9dd7bd;
  color: var(--success);
  background: var(--success-soft);
}

.status-warn {
  border-color: #e1bd69;
  color: var(--warning);
  background: var(--warning-soft);
}

.status-bad {
  border-color: #efaaa2;
  color: var(--danger);
  background: var(--danger-soft);
}

.status-neutral {
  border-color: #b8d4df;
  color: var(--accent);
  background: var(--accent-soft);
}

.backtest-progress {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(180deg, #fbfdff 0%, #f4f9fb 100%);
}

.backtest-progress-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce9ef;
}

.backtest-progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, var(--success) 100%);
  transition: width 240ms ease;
}

.backtest-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.backtest-progress-meta strong {
  color: var(--ink);
}

.backtest-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.backtest-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  gap: 10px;
}

.backtest-metrics div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px;
  background: #fbfdff;
}

.backtest-metrics span,
.backtest-metrics strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.backtest-metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.backtest-metrics strong {
  margin-top: 6px;
  color: var(--ink);
  font-size: 18px;
}

.backtest-complete-summary {
  display: grid;
  gap: 18px;
}

.backtest-gate-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--surface-strong);
}

.backtest-gate-summary > div {
  min-width: 0;
}

.backtest-gate-summary span,
.backtest-gate-summary strong,
.backtest-gate-summary small {
  display: block;
  min-width: 0;
}

.backtest-gate-summary > .status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  min-width: 112px;
  text-align: center;
}

.backtest-gate-summary > div > span,
.backtest-section-title {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.backtest-gate-summary strong {
  margin-top: 3px;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.15;
}

.backtest-gate-summary small {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.gate-ok {
  border-left-color: var(--success);
  background: var(--success-soft);
}

.gate-bad {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.gate-neutral {
  border-left-color: var(--accent);
}

.backtest-section-title {
  margin-bottom: 8px;
}

.backtest-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.backtest-detail-item {
  display: grid;
  grid-template-columns: minmax(120px, 0.42fr) minmax(0, 1fr);
  gap: 8px 16px;
  align-items: center;
  min-width: 0;
  padding: 13px 14px;
  background: #fbfdff;
}

.backtest-detail-item span,
.backtest-detail-item small {
  color: var(--muted);
}

.backtest-detail-item span {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.backtest-detail-item strong {
  min-width: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.backtest-detail-item small {
  grid-column: 2;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.backtest-metric-item {
  border-left: 4px solid var(--accent);
}

.backtest-metric-item small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.metric-ok {
  border-left-color: var(--success);
}

.metric-warn {
  border-left-color: var(--warning);
  background: var(--warning-soft);
}

.metric-bad {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.backtest-artifacts {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fbfdff;
}

.backtest-artifacts summary {
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.backtest-artifact-body {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.backtest-artifact-body code {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: #f4f8fb;
  font-size: 12px;
}

.backtest-runs-stack {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.backtest-runs-panel {
  min-width: 0;
}

.backtest-run-table {
  display: grid;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.backtest-run-head,
.backtest-run-row {
  display: grid;
  grid-template-columns:
    minmax(112px, 0.8fr)
    minmax(70px, 0.45fr)
    minmax(210px, 1.4fr)
    minmax(90px, 0.65fr)
    minmax(180px, 1fr)
    minmax(100px, 0.65fr);
  min-width: 900px;
  gap: 10px;
  align-items: center;
}

.backtest-run-head {
  border-bottom: 1px solid var(--line);
  padding: 0 4px 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.backtest-run-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: var(--surface-strong);
}

.backtest-run-row > span,
.backtest-run-head > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.backtest-run-row > span {
  color: #263c4f;
  line-height: 1.4;
}

.artifact-link {
  margin-top: 0;
}

.route-loading {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 92%), rgb(247 251 253 / 92%)),
    var(--surface);
  box-shadow: var(--shadow-md);
}

.route-loading::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  content: "";
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.route-loading::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 4px;
  height: 2px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: route-progress 1200ms ease-in-out infinite;
}

.route-spinner {
  display: inline-grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 3px solid #d7e7ee;
  border-top-color: var(--accent);
  border-right-color: var(--accent-2);
  border-radius: 999px;
  animation: spin 820ms linear infinite;
}

.route-loading strong,
.route-loading span {
  display: block;
}

.route-loading strong {
  color: var(--ink);
  font-size: 17px;
}

.route-loading span {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.confirm-overlay {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(17 27 38 / 46%);
  backdrop-filter: blur(10px);
  animation: confirm-fade 140ms ease-out;
}

.confirm-overlay.is-closing {
  animation: confirm-fade 120ms ease-in reverse;
}

.confirm-dialog {
  position: relative;
  width: min(100%, 560px);
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 70%);
  border-radius: 8px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 98%), rgb(247 251 253 / 98%)),
    var(--surface);
  box-shadow: 0 28px 80px rgb(17 27 38 / 28%);
  animation: confirm-rise 160ms ease-out;
}

.confirm-accent {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.confirm-danger .confirm-accent {
  background: linear-gradient(180deg, #e5483d, var(--danger));
}

.confirm-warn .confirm-accent {
  background: linear-gradient(180deg, #d99822, var(--warning));
}

.confirm-success .confirm-accent {
  background: linear-gradient(180deg, #28a77f, var(--success));
}

.confirm-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.confirm-header > div {
  min-width: 0;
}

.confirm-header h2 {
  margin: 4px 0 0;
  font-size: 26px;
  line-height: 1.12;
  letter-spacing: 0;
}

.confirm-icon-button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  border-radius: 999px;
  padding: 0;
  color: var(--muted);
  background: #f4f8fb;
}

.confirm-copy {
  margin: 14px 0 18px;
  color: var(--muted);
  line-height: 1.55;
}

.confirm-details {
  display: grid;
  gap: 10px;
  margin: 0;
}

.confirm-details div {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  background: var(--surface-strong);
}

.confirm-details dt,
.confirm-details dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.confirm-details dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.confirm-details dd {
  color: #203548;
  font-weight: 700;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

@keyframes route-progress {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

@keyframes confirm-fade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes confirm-rise {
  from {
    transform: translateY(12px) scale(0.98);
  }

  to {
    transform: translateY(0) scale(1);
  }
}

.health-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.health-panel {
  display: grid;
  gap: 10px;
}

.health-row {
  display: grid;
  grid-template-columns: minmax(min(150px, 100%), 0.8fr) minmax(0, 1fr);
  gap: 8px 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 7px;
  padding: 11px 12px;
  background: var(--surface-strong);
}

.health-row span,
.health-row small {
  color: var(--muted);
}

.health-row span {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.health-row strong {
  overflow-wrap: anywhere;
  font-size: 16px;
}

.health-row small {
  grid-column: 2;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.health-ok {
  border-left-color: var(--success);
}

.health-warn {
  border-left-color: var(--warning);
  background: var(--warning-soft);
}

.health-bad {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.health-neutral {
  border-left-color: var(--accent);
}

.instance-panel {
  margin-top: 16px;
}

.instance-list {
  display: grid;
  gap: 10px;
}

.instance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px 12px;
  background: var(--surface-strong);
}

.instance-row strong,
.instance-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.instance-row span {
  color: var(--muted);
}

.data-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.data-panel {
  min-width: 0;
}

.data-panel-wide {
  grid-column: 1 / -1;
}

.strategy-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.strategy-summary-panel {
  position: relative;
  display: grid;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
  border-left: 4px solid var(--accent);
}

.strategy-summary-panel > span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.strategy-summary-panel > strong {
  color: var(--ink);
  font-size: 22px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.strategy-summary-panel > small {
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.summary-ok {
  border-left-color: var(--success);
}

.summary-warn {
  border-left-color: var(--warning);
  background: var(--warning-soft);
}

.summary-bad {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.summary-neutral {
  border-left-color: var(--accent);
}

.strategy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap: 16px;
  margin-top: 18px;
}

.strategy-card {
  display: grid;
  gap: 14px;
}

.strategy-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.strategy-card-header > div {
  min-width: 0;
}

.strategy-card-header span,
.strategy-card-header strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.strategy-card-header > div > span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.strategy-card-header strong {
  margin-top: 3px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.2;
}

.strategy-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.strategy-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.strategy-facts .backtest-detail-item {
  padding: 11px 12px;
}

.strategy-event-table {
  display: grid;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.strategy-event-head,
.strategy-event-row {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(min(150px, 100%), 1fr));
  min-width: min(100%, calc(var(--cols, 4) * 150px));
  gap: 10px;
  align-items: center;
}

.strategy-event-head {
  border-bottom: 1px solid var(--line);
  padding: 0 4px 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.strategy-event-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: var(--surface-strong);
}

.strategy-event-row > span,
.strategy-event-head > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.strategy-event-row > span {
  color: #263c4f;
  line-height: 1.4;
}

.event-details {
  grid-column: 1 / -1;
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.event-details summary {
  width: fit-content;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.event-details pre {
  max-height: 240px;
  margin: 8px 0 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: #e8f3ff;
  background: #111b26;
  font-size: 12px;
  white-space: pre-wrap;
}

.data-table {
  display: grid;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.data-table-head,
.data-table-row {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(min(150px, 100%), 1fr));
  min-width: min(100%, calc(var(--cols, 4) * 150px));
  gap: 10px;
  align-items: center;
}

.data-table-head {
  border-bottom: 1px solid var(--line);
  padding: 0 4px 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.data-table-row {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  background: var(--surface-strong);
}

.data-table-row span,
.data-table-head span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.data-table-row span {
  color: #263c4f;
  line-height: 1.4;
}

.empty-state {
  display: grid;
  gap: 5px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 16px;
  background: #fbfdff;
}

.empty-state strong {
  color: var(--ink);
}

.empty-state span,
.muted-copy {
  color: var(--muted);
  line-height: 1.55;
}

.json-preview {
  max-height: 320px;
  margin: 0;
  overflow: auto;
  border: 1px solid #d8e4ee;
  border-radius: 7px;
  padding: 13px;
  color: #173247;
  background: #f8fbfd;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.journal-panel {
  margin-top: 18px;
}

.journal-frame {
  width: 100%;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgb(17 27 38 / 5%);
}

.journal-artifact-details {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fbfdff;
}

.journal-artifact-details summary {
  width: fit-content;
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.journal-artifact-details code {
  display: block;
  margin-top: 10px;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: #f4f8fb;
  font-size: 12px;
}

.inline-link {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  margin-top: 10px;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.inline-link:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

.result-box {
  display: block;
  width: 100%;
  min-height: 82px;
  max-height: 420px;
  margin-top: 16px;
  overflow: auto;
  border: 1px solid #22364a;
  border-radius: 8px;
  padding: 16px;
  color: #e8f3ff;
  background: #111b26;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 5%);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.result-pending {
  border-color: #c7952e;
  color: #4a3512;
  background: var(--warning-soft);
}

.result-success {
  border-color: #7fc2a3;
  color: #124b35;
  background: var(--success-soft);
}

.result-error {
  border-color: #f0a49b;
  color: #7a1a13;
  background: var(--danger-soft);
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  nav {
    width: 100%;
    justify-content: flex-start;
  }

  nav button {
    flex: 1 1 138px;
  }

  .page-heading {
    flex-direction: column;
  }

  .identity-pill {
    max-width: 100%;
  }

  .login-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .login-copy h1 {
    font-size: 36px;
  }

  .health-layout {
    grid-template-columns: 1fr;
  }

  .data-layout {
    grid-template-columns: 1fr;
  }

  .backtest-config-layout {
    grid-template-columns: 1fr;
  }

  .strategy-summary-grid {
    grid-template-columns: 1fr;
  }

  .backtest-status-grid,
  .backtest-detail-grid,
  .backtest-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  nav button {
    width: 100%;
    min-width: 0;
  }

  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-pill {
    align-self: flex-start;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 14px 16px;
  }

  .brand {
    min-width: 0;
  }

  .content {
    padding: 20px 14px 36px;
  }

  .page-heading h1,
  .hero h1 {
    font-size: 30px;
  }

  .page-heading p:not(.eyebrow),
  .hero p:not(.eyebrow),
  .tile small,
  .empty-state span,
  .muted-copy {
    font-size: 14px;
  }

  .hero {
    min-height: 190px;
    padding: 22px;
  }

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

  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .actions button,
  .form-panel button[type="submit"],
  .login-panel button,
  #refresh-brokers {
    width: 100%;
    min-width: 0;
  }

  .login-copy h1 {
    font-size: 32px;
  }

  .login-copy p:not(.eyebrow) {
    font-size: 16px;
  }

  .health-row {
    grid-template-columns: 1fr;
  }

  .health-row small {
    grid-column: auto;
  }

  .backtest-status-grid,
  .backtest-detail-grid,
  .strategy-facts,
  .strategy-code-facts,
  .backtest-metrics {
    grid-template-columns: 1fr;
  }

  .strategy-code-block {
    max-height: 420px;
    font-size: 11px;
  }

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

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

  .backtest-detail-item {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .backtest-detail-item small {
    grid-column: auto;
  }

  .instance-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .data-table-head {
    display: none;
  }

  .strategy-event-head {
    display: none;
  }

  .backtest-run-head {
    display: none;
  }

  .data-table {
    overflow-x: visible;
  }

  .strategy-event-table {
    overflow-x: visible;
  }

  .backtest-run-table {
    overflow-x: visible;
  }

  .data-table-row {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .strategy-event-row {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .backtest-run-row {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .route-loading {
    align-items: flex-start;
    padding: 18px;
  }

  .confirm-overlay {
    align-items: end;
    padding: 14px;
  }

  .confirm-dialog {
    padding: 20px;
  }

  .confirm-header h2 {
    font-size: 22px;
  }

  .confirm-details div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .confirm-actions {
    display: grid;
  }

  .confirm-actions button {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .topbar {
    gap: 14px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 12px;
  }

  .brand strong {
    font-size: 14px;
  }

  nav {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 18px 12px 32px;
  }

  .page-heading h1,
  .hero h1 {
    font-size: 28px;
  }

  .tile,
  .panel {
    padding: 15px;
  }

  .tile strong {
    font-size: 24px;
  }

  .route-loading {
    flex-direction: column;
    gap: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .route-loading::after,
  .route-spinner,
  .spinner,
  .confirm-overlay,
  .confirm-dialog {
    animation: none;
  }
}
