:root {
  color-scheme: dark;
  --bg: #030304;
  --surface: #0f1115;
  --surface-2: #151922;
  --text: #ffffff;
  --muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
  --orange: #f7931a;
  --gold: #ffd600;
  --danger: #f05a5a;
  --success: #19a974;
  --input: rgba(0, 0, 0, 0.5);
  --shadow: 0 0 40px -18px rgba(247, 147, 26, 0.45);
}

body.light {
  color-scheme: light;
  --bg: #f3f0e8;
  --surface: #fffdfa;
  --surface-2: #f1ede3;
  --text: #19212f;
  --muted: #68707d;
  --border: rgba(64, 48, 26, 0.16);
  --orange: #b65f00;
  --gold: #9b7100;
  --danger: #d33f49;
  --success: #12805c;
  --input: #fffaf3;
  --shadow: 0 20px 48px -36px rgba(75, 55, 24, 0.46);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(30, 41, 59, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30, 41, 59, 0.14) 1px, transparent 1px),
    radial-gradient(circle at top right, rgba(247, 147, 26, 0.14), transparent 34rem),
    var(--bg);
  background-size: 48px 48px, 48px 48px, auto, auto;
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", Arial, sans-serif;
}
body.light {
  background:
    linear-gradient(rgba(182, 95, 0, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(25, 33, 47, 0.055) 1px, transparent 1px),
    linear-gradient(135deg, rgba(255, 214, 0, 0.12) 0%, transparent 34%),
    linear-gradient(180deg, #fffaf1 0%, #f3f0e8 42%, #e9eef4 100%);
  background-size: 48px 48px, 48px 48px, auto, auto;
}

button, input, textarea { font: inherit; }
button {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 16px;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
}
button.primary {
  border-color: rgba(247, 147, 26, 0.55);
  background: linear-gradient(90deg, #ea580c, #f7931a);
  color: #1b1100;
  font-weight: 700;
  box-shadow: 0 0 24px -10px rgba(247, 147, 26, 0.8);
}
button.danger {
  border-color: rgba(211, 63, 73, 0.55);
  color: var(--danger);
}
button:disabled { opacity: 0.55; cursor: not-allowed; }
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(247, 147, 26, 0.75);
  outline-offset: 2px;
}
input, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--input);
  color: var(--text);
}
body.light input,
body.light textarea,
body.light select {
  border-color: rgba(84, 63, 34, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 249, 239, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}
select {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 34px 7px 10px;
  background: var(--input);
  color: var(--text);
}
textarea { min-height: 420px; font-family: "JetBrains Mono", Consolas, monospace; font-size: 12px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.shell:not(.auth-shell) .main { grid-column: 2; }
.shell.auth-shell { grid-template-columns: 1fr; }
.auth-shell .sidebar { display: none; }
.auth-shell .topbar {
  background: transparent;
  border-bottom: 0;
  box-shadow: none;
  backdrop-filter: none;
}
.auth-shell .content {
  min-height: calc(100vh - 64px);
  place-items: center;
  padding: 32px 20px 56px;
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 240px;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: rgba(15, 17, 21, 0.82);
  backdrop-filter: blur(12px);
  padding: 20px 14px;
}
body.light .sidebar {
  background:
    linear-gradient(180deg, rgba(255, 252, 246, 0.94), rgba(239, 235, 226, 0.88)),
    linear-gradient(90deg, rgba(247, 147, 26, 0.10), transparent 42%);
  box-shadow: 14px 0 42px -34px rgba(75, 55, 24, 0.58);
}
.brand { padding: 8px 10px 20px; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: 0; }
.brand span { color: var(--orange); }
.nav { display: grid; gap: 8px; }
.nav button {
  width: 100%;
  justify-content: flex-start;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}
.nav button.active {
  color: var(--orange);
  background: rgba(247, 147, 26, 0.12);
  border-color: rgba(247, 147, 26, 0.35);
}
body.light .nav button {
  color: #58616f;
}
body.light .nav button:hover {
  color: #263143;
  background: rgba(255, 255, 255, 0.58);
  border-color: rgba(182, 95, 0, 0.20);
}
body.light .nav button.active {
  color: #7f4300;
  background:
    linear-gradient(90deg, rgba(247, 147, 26, 0.18), rgba(255, 214, 0, 0.10)),
    rgba(255, 255, 255, 0.68);
  border-color: rgba(182, 95, 0, 0.34);
  box-shadow: inset 3px 0 0 rgba(182, 95, 0, 0.86);
}
.main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 18;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(3, 3, 4, 0.86);
  backdrop-filter: blur(14px);
}
body.light .topbar {
  background:
    linear-gradient(90deg, rgba(255, 253, 249, 0.94), rgba(248, 244, 236, 0.86));
  box-shadow: 0 16px 42px -36px rgba(75, 55, 24, 0.45);
}
.content { padding: 24px; display: grid; gap: 18px; }
.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}
body.light .card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 250, 242, 0.94));
  border-color: rgba(88, 66, 35, 0.16);
}
.card h2, .card h3 { margin: 0 0 14px; }
.settings-page {
  display: grid;
  gap: 18px;
}
.settings-overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.78fr);
  gap: 18px;
  align-items: end;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(247, 147, 26, 0.11), rgba(255, 255, 255, 0.035) 46%, rgba(255, 214, 0, 0.045)),
    var(--surface);
  box-shadow: var(--shadow);
}
.settings-overview h1 {
  margin: 5px 0 7px;
  font-size: 26px;
  line-height: 1.18;
  letter-spacing: 0;
}
.settings-overview p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}
.settings-overview-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.settings-overview-metrics div {
  min-width: 0;
  min-height: 66px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}
.settings-overview-metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.settings-overview-metrics strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 18px;
  align-items: start;
}
.strategy-family-card {
  padding: 16px 18px;
}
.strategy-family-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
button.strategy-family-item {
  position: relative;
  min-height: 72px;
  display: grid;
  gap: 5px;
  align-content: center;
  justify-items: start;
  border-radius: 8px;
  padding: 12px 82px 12px 18px;
  text-align: left;
  background: var(--surface-2);
  box-shadow: none;
  opacity: 0.76;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease, transform 0.16s ease;
}
button.strategy-family-item::before {
  content: "";
  position: absolute;
  top: 16px;
  left: 8px;
  width: 4px;
  height: calc(100% - 32px);
  border-radius: 999px;
  background: transparent;
}
button.strategy-family-item span {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
}
button.strategy-family-item small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
button.strategy-family-item:hover {
  opacity: 0.92;
  border-color: rgba(247, 147, 26, 0.42);
}
button.strategy-family-item.active,
button.strategy-family-item[aria-pressed="true"] {
  opacity: 1;
  border-color: rgba(247, 147, 26, 1);
  background:
    linear-gradient(90deg, rgba(247, 147, 26, 0.32), rgba(255, 214, 0, 0.11)),
    var(--surface-2);
  box-shadow:
    inset 5px 0 0 rgba(247, 147, 26, 1),
    0 0 0 2px rgba(247, 147, 26, 0.22),
    0 14px 34px -26px rgba(247, 147, 26, 0.95);
  transform: translateY(-1px);
}
button.strategy-family-item.active::before,
button.strategy-family-item[aria-pressed="true"]::before {
  background: linear-gradient(180deg, #ffd600, #f7931a);
  box-shadow: 0 0 14px rgba(247, 147, 26, 0.56);
}
button.strategy-family-item.active span,
button.strategy-family-item[aria-pressed="true"] span {
  color: #ffd96a;
}
button.strategy-family-item.active small,
button.strategy-family-item[aria-pressed="true"] small {
  color: rgba(255, 255, 255, 0.82);
}
button.strategy-family-item.active::after,
button.strategy-family-item[aria-pressed="true"]::after {
  content: "\5F53\524D";
  position: absolute;
  top: 12px;
  right: 12px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(247, 147, 26, 0.52);
  border-radius: 999px;
  padding: 2px 9px;
  color: #1c1306;
  background: linear-gradient(180deg, #ffd96a, #f7931a);
  font-size: 12px;
  font-weight: 800;
}
body.light button.strategy-family-item {
  background: rgba(255, 250, 241, 0.82);
  border-color: rgba(84, 63, 34, 0.16);
}
body.light button.strategy-family-item:hover {
  border-color: rgba(184, 95, 0, 0.36);
  background: rgba(255, 255, 255, 0.88);
}
body.light button.strategy-family-item.active,
body.light button.strategy-family-item[aria-pressed="true"] {
  color: #22160b;
  border-color: rgba(184, 95, 0, 0.92);
  background:
    linear-gradient(90deg, rgba(247, 147, 26, 0.34), rgba(255, 255, 255, 0.82)),
    rgba(255, 250, 241, 0.88);
  box-shadow:
    inset 5px 0 0 rgba(184, 95, 0, 1),
    0 0 0 2px rgba(184, 95, 0, 0.18),
    0 14px 34px -28px rgba(184, 95, 0, 0.55);
}
body.light button.strategy-family-item.active::before,
body.light button.strategy-family-item[aria-pressed="true"]::before {
  background: linear-gradient(180deg, #f7b032, #b85f00);
  box-shadow: 0 0 12px rgba(184, 95, 0, 0.34);
}
body.light button.strategy-family-item.active span,
body.light button.strategy-family-item[aria-pressed="true"] span {
  color: #6f3a00;
}
body.light button.strategy-family-item.active small,
body.light button.strategy-family-item[aria-pressed="true"] small {
  color: #4d5663;
}
body.light button.strategy-family-item.active::after,
body.light button.strategy-family-item[aria-pressed="true"]::after {
  color: #1f1609;
  background: linear-gradient(180deg, #ffd879, #f2a23a);
  border-color: rgba(184, 95, 0, 0.46);
}
.settings-main-column,
.settings-side-column {
  display: grid;
  gap: 18px;
  min-width: 0;
}
.settings-side-column {
  position: sticky;
  top: 82px;
  align-self: start;
}
.settings-page .card h2 {
  margin-bottom: 8px;
}
.settings-page .settings-groups {
  gap: 10px;
}
.settings-page .settings-fieldset {
  padding: 14px;
}
.settings-page .settings-fieldset legend {
  font-size: 13px;
}
.settings-page .settings-fieldset-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.settings-page .wide-fieldset .settings-fieldset-grid {
  grid-template-columns: repeat(3, minmax(132px, 1fr));
}
.settings-page .strategy-mode-switch,
.settings-page .strategy-mode-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(154px, 1fr));
  gap: 8px;
}
.settings-page .strategy-mode-btn {
  min-height: 48px;
  padding: 8px 10px;
  border-radius: 8px;
  gap: 3px;
  justify-content: center;
  box-shadow: none;
}
.settings-page .strategy-mode-btn span,
.settings-page .strategy-mode-btn strong {
  font-size: 13px;
  line-height: 1.25;
}
.settings-page .strategy-mode-btn small {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.settings-page .strategy-mode-btn.active {
  border-color: rgba(247, 147, 26, 0.95);
  background:
    linear-gradient(90deg, rgba(247, 147, 26, 0.24), rgba(255, 214, 0, 0.08)),
    var(--surface-2);
  box-shadow:
    inset 4px 0 0 rgba(247, 147, 26, 0.95),
    0 0 0 1px rgba(247, 147, 26, 0.18);
}
.settings-page .actions button,
.settings-page .fieldset-actions button,
.settings-page .sell-profile-save-row button {
  min-height: 38px;
  border-radius: 8px;
}
.settings-page .settings-check {
  min-height: 38px;
  padding: 0 10px;
}
.settings-side-column .settings-groups,
.settings-side-column .settings-fieldset-grid {
  grid-template-columns: 1fr;
}
.settings-side-column .settings-fieldset-grid .wide-setting {
  grid-column: auto;
}
.settings-runtime-card .strategy-summary {
  margin-top: 14px;
}
.settings-runtime-note {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}
.settings-runtime-note span {
  color: var(--muted);
}
.settings-json-card {
  padding: 0;
  overflow: hidden;
}
.settings-json-card summary {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
}
.settings-json-card summary::-webkit-details-marker {
  display: none;
}
.settings-json-card summary span {
  color: var(--text);
  font-weight: 800;
}
.settings-json-card summary small {
  color: var(--muted);
  line-height: 1.5;
}
.settings-json-card[open] summary {
  border-bottom: 1px solid var(--border);
}
.settings-json-card > .muted {
  margin: 14px 18px 0;
}
.settings-json-card textarea {
  width: calc(100% - 36px);
  min-height: 360px;
  margin: 12px 18px 0;
}
.settings-json-actions {
  margin: 12px 18px 18px;
}
body.light .settings-overview {
  background:
    linear-gradient(135deg, rgba(247, 147, 26, 0.14), rgba(255, 255, 255, 0.82) 44%, rgba(255, 214, 0, 0.10)),
    #fffaf1;
  border-color: rgba(84, 63, 34, 0.16);
}
body.light .settings-overview-metrics div,
body.light .settings-runtime-note {
  background: rgba(255, 253, 249, 0.72);
  border-color: rgba(84, 63, 34, 0.13);
}
body.light .settings-page .strategy-mode-btn.active {
  box-shadow: inset 3px 0 0 rgba(184, 95, 0, 0.78);
}
.render-failure {
  max-width: 760px;
  width: 100%;
  border-color: rgba(240, 90, 90, 0.35);
}
.render-failure pre {
  margin: 14px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.24);
  color: var(--danger);
  white-space: pre-wrap;
  word-break: break-word;
}
body.light .render-failure pre {
  background: rgba(255, 245, 245, 0.92);
}

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}
.settings-grid .wide-setting {
  grid-column: span 2;
}
.settings-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.settings-fieldset {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.018));
}
.settings-fieldset legend {
  padding: 0 8px;
  color: var(--orange);
  font-size: 14px;
  font-weight: 700;
}
.settings-fieldset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
}
.settings-fieldset-grid .wide-setting {
  grid-column: span 2;
}
.settings-fieldset .settings-check {
  align-self: end;
}
.settings-subgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.settings-subgrid > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}
.settings-subgrid.single-subgrid {
  grid-template-columns: minmax(0, 1fr);
}
.minute-mode-note {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
}
.settings-subtitle {
  margin-bottom: 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}
body.light .settings-subgrid > div,
body.light .minute-mode-note {
  background: rgba(255, 255, 255, 0.58);
  border-color: rgba(84, 63, 34, 0.13);
}
.wide-fieldset {
  grid-column: 1 / -1;
}
.backtest-run-actions {
  margin-top: 14px;
}
body.light .settings-fieldset {
  background:
    linear-gradient(180deg, rgba(255, 250, 241, 0.76), rgba(255, 255, 255, 0.70));
  border-color: rgba(84, 63, 34, 0.16);
}
.settings-card-actions {
  margin-top: 14px;
}
.fieldset-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}
.fieldset-actions button {
  min-height: 40px;
}
.sell-profile-save-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.sell-profile-save-row .muted {
  min-width: 220px;
  flex: 1 1 260px;
}
.sell-profile-save-row button {
  flex: 0 0 auto;
}
.strategy-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.strategy-mode-btn {
  position: relative;
  width: 100%;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  text-align: left;
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}
.strategy-mode-btn span {
  font-weight: 800;
}
.strategy-mode-btn strong {
  font-weight: 800;
}
.strategy-mode-btn small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.strategy-mode-btn.active {
  color: var(--text);
  border-color: rgba(247, 147, 26, 0.95);
  background:
    linear-gradient(90deg, rgba(247, 147, 26, 0.24), rgba(255, 214, 0, 0.08)),
    var(--surface-2);
  box-shadow:
    inset 4px 0 0 rgba(247, 147, 26, 0.95),
    0 0 0 1px rgba(247, 147, 26, 0.18);
}
.strategy-mode-btn.active::after,
.strategy-mode-btn[aria-pressed="true"]::after {
  content: "\5F53\524D";
  position: absolute;
  top: 8px;
  right: 8px;
  min-height: 20px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(247, 147, 26, 0.5);
  border-radius: 999px;
  padding: 1px 7px;
  color: #1c1306;
  background: linear-gradient(180deg, #ffd96a, #f7931a);
  font-size: 11px;
  font-weight: 800;
}
.strategy-mode-btn.active small {
  color: var(--muted);
}
body.light .strategy-mode-btn {
  color: var(--text);
  background: rgba(255, 250, 241, 0.82);
  border-color: rgba(84, 63, 34, 0.16);
}
body.light .strategy-mode-btn.active {
  color: #22160b;
  border-color: rgba(184, 95, 0, 0.82);
  background:
    linear-gradient(90deg, rgba(247, 147, 26, 0.28), rgba(255, 250, 241, 0.88)),
    rgba(255, 250, 241, 0.84);
  box-shadow:
    inset 4px 0 0 rgba(184, 95, 0, 0.95),
    0 0 0 1px rgba(184, 95, 0, 0.14);
}
.settings-check {
  min-height: 42px;
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.settings-check input {
  width: auto;
  min-height: auto;
  margin: 0;
}
body.light .settings-check {
  background: rgba(255, 250, 241, 0.82);
  border-color: rgba(84, 63, 34, 0.16);
}
.user-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 1fr) 150px auto;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
}
.screening-controls {
  display: flex;
  align-items: end;
  gap: 14px;
  flex-wrap: wrap;
}
.screening-run-row {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}
.screening-date-field {
  width: 190px;
  flex: 0 0 190px;
}
.screening-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  padding-bottom: 1px;
}
.screening-actions button,
.screening-run-row .force-run-option {
  white-space: nowrap;
}
.backtest-controls {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
}
.backtest-controls .screening-date-field {
  width: auto;
  flex: initial;
}
.backtest-controls .screening-actions {
  align-self: end;
}
.backtest-minute-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015));
}
.backtest-minute-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.backtest-minute-head .force-run-option {
  min-width: 168px;
}
.backtest-minute-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}
body.light .backtest-minute-panel {
  background:
    linear-gradient(180deg, rgba(255, 250, 241, 0.86), rgba(255, 255, 255, 0.74)),
    linear-gradient(90deg, rgba(247, 147, 26, 0.08), transparent 64%);
  border-color: rgba(84, 63, 34, 0.14);
}
.sim-status-card .flat-head {
  margin-bottom: 12px;
}
.sim-status-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.016)),
    var(--surface-2);
}
.sim-status-primary {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(247, 147, 26, 0.12), rgba(25, 169, 116, 0.05)),
    rgba(255, 255, 255, 0.022);
}
.sim-status-kicker {
  display: none;
}
.sim-status-kicker,
.sim-info-item span,
.sim-status-date span,
.sim-time-strip em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.25;
}
.sim-status-main {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sim-status-main strong {
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
}
.sim-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(247, 147, 26, 0.13);
}
.sim-status-dot.good {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(25, 169, 116, 0.13);
}
.sim-status-dot.bad {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(240, 90, 90, 0.14);
}
.sim-status-date {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 0;
  white-space: nowrap;
}
.sim-status-date strong {
  color: var(--gold);
  font-size: 13px;
}
.sim-info-grid {
  min-width: 0;
  flex: 1 1 420px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.sim-info-item {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.026);
}
.sim-info-item strong {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sim-time-strip {
  flex: 1 1 260px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 0;
}
.sim-time-strip span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.022);
}
.sim-time-strip strong {
  color: var(--text);
  font-size: 12px;
}
.sim-controls {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 12px;
  align-items: end;
}
.sim-controls.account-controls {
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  margin-top: 14px;
}
.sim-controls select,
.sim-controls input {
  min-height: 40px;
}
.sim-controls label {
  min-width: 0;
}
.sim-controls .wide-control {
  grid-column: span 2;
}
.sim-controls .check-row {
  min-height: 40px;
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.sim-controls .check-row input {
  width: auto;
  min-height: auto;
  margin: 0;
}
body.light .sim-controls .check-row {
  background: rgba(255, 250, 241, 0.82);
  border-color: rgba(84, 63, 34, 0.16);
}
body.light .sim-status-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 250, 241, 0.92)),
    linear-gradient(90deg, rgba(247, 147, 26, 0.10), transparent 60%);
}
body.light .sim-status-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 250, 241, 0.74)),
    var(--surface-2);
  border-color: rgba(84, 63, 34, 0.14);
}
body.light .sim-status-primary {
  background:
    linear-gradient(135deg, rgba(247, 147, 26, 0.13), rgba(25, 169, 116, 0.06)),
    rgba(255, 255, 255, 0.62);
  border-color: rgba(84, 63, 34, 0.12);
}
body.light .sim-info-item,
body.light .sim-time-strip span {
  background: rgba(255, 253, 249, 0.72);
  border-color: rgba(84, 63, 34, 0.12);
}
.soft-hidden {
  opacity: 0.48;
}
.soft-hidden input,
.soft-hidden select,
.soft-hidden textarea {
  pointer-events: none;
}
.force-run-option {
  min-height: 40px;
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-2);
}
.force-run-option input {
  width: auto;
  min-height: auto;
  margin: 0;
}
body.light .force-run-option {
  background: rgba(255, 250, 241, 0.82);
  border-color: rgba(84, 63, 34, 0.16);
}
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
  background: var(--surface-2);
}
body.light .status-pill {
  background: rgba(255, 250, 241, 0.82);
  border-color: rgba(84, 63, 34, 0.16);
}
.status-pill.good { color: var(--success); border-color: rgba(25, 169, 116, 0.4); }
.status-pill.warn { color: var(--orange); border-color: rgba(247, 147, 26, 0.4); }
.status-pill.bad { color: var(--danger); border-color: rgba(240, 90, 90, 0.45); }
.muted { color: var(--muted); }
.mono { font-family: "JetBrains Mono", Consolas, monospace; }
.result-hero {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(210px, 0.8fr) minmax(260px, 1.3fr);
  gap: 14px;
  align-items: stretch;
}
.result-status,
.score-card,
.summary-card,
.risk-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.035);
}
body.light .result-status,
body.light .score-card,
body.light .summary-card,
body.light .risk-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 249, 240, 0.72));
  border-color: rgba(84, 63, 34, 0.14);
}
.result-status.good { border-color: rgba(25, 169, 116, 0.45); }
.result-status.watch { border-color: rgba(247, 147, 26, 0.5); }
.result-status.bad { border-color: rgba(240, 90, 90, 0.5); }
.eyebrow {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}
.result-title {
  margin-top: 10px;
  font-size: 28px;
  font-weight: 800;
  color: var(--orange);
}
.result-status.good .result-title { color: var(--success); }
.result-status.bad .result-title { color: var(--danger); }
.result-reason {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}
.score-card {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at top right, rgba(255, 214, 0, 0.16), transparent 55%),
    rgba(255, 255, 255, 0.035);
}
body.light .score-card {
  background:
    radial-gradient(circle at top right, rgba(184, 135, 0, 0.14), transparent 55%),
    #fffaf0;
}
.score-value {
  margin-top: 8px;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 40px;
  font-weight: 800;
  color: var(--gold);
}
body.light .score-value { color: #9a6400; }
.score-note {
  margin-top: 6px;
  color: var(--muted);
}
.score-good { border-color: rgba(25, 169, 116, 0.45); }
.score-watch { border-color: rgba(247, 147, 26, 0.55); }
.score-low { border-color: rgba(240, 90, 90, 0.45); }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 16px;
}
.risk-panel {
  grid-column: 1 / -1;
}
.risk-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.risk-head h3 { margin: 0; }
.risk-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.risk-chip {
  border: 1px solid rgba(247, 147, 26, 0.28);
  border-radius: 8px;
  padding: 10px;
  background: rgba(247, 147, 26, 0.08);
}
body.light .risk-chip {
  background: #fff7e8;
}
.risk-title {
  font-weight: 700;
  color: var(--orange);
}
.risk-desc {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 12px;
}
.risk-code {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  word-break: break-all;
}
.ledger {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.ledger-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.ledger-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
}
body.light .ledger-section {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(246, 241, 232, 0.72));
  border-color: rgba(84, 63, 34, 0.14);
}
.ledger-section h4 {
  margin: 0 0 12px;
  color: var(--orange);
  font-size: 17px;
}
.ledger-section dl {
  display: grid;
  gap: 9px;
  margin: 0;
}
.ledger-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  min-height: 24px;
}
.ledger-row dt {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.ledger-row dd {
  margin: 0;
  color: var(--text);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 14px;
  word-break: break-word;
}
.metric {
  min-height: 72px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
}
body.light .metric {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(246, 241, 232, 0.74));
  border-color: rgba(84, 63, 34, 0.14);
}
.metric .k { color: var(--muted); font-size: 12px; }
.metric .v { margin-top: 8px; font-size: 17px; font-family: "JetBrains Mono", Consolas, monospace; }
.chart-wrap { position: relative; min-height: 580px; }
#stockChart { width: 100%; height: 580px; display: block; cursor: grab; touch-action: none; }
#stockChart:active { cursor: grabbing; }
.backtest-chart-wrap {
  position: relative;
  min-height: 360px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
}
.backtest-chart-wrap canvas {
  width: 100%;
  height: 360px;
  display: block;
  cursor: crosshair;
}
.backtest-live-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}
.backtest-live-wide {
  grid-column: 1 / -1;
}
.sim-chart-wrap {
  position: relative;
  min-height: 360px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
}
#simIntradayChart {
  width: 100%;
  height: 360px;
  display: block;
  cursor: crosshair;
}
body.light .backtest-chart-wrap {
  background: rgba(255, 253, 249, 0.72);
  border-color: rgba(84, 63, 34, 0.12);
}
body.light .sim-chart-wrap {
  background: rgba(255, 253, 249, 0.72);
  border-color: rgba(84, 63, 34, 0.12);
}
.chart-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.chart-title-row h3 { margin: 0; }
.chart-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.chart-stock-name {
  color: var(--orange);
  font-weight: 800;
}
.select-inline {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  display: none;
  max-width: 260px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 12px;
}
.screening-result-groups {
  display: grid;
  gap: 18px;
}
.screening-result-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
}
body.light .screening-result-block {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.66), rgba(255, 249, 240, 0.72));
  border-color: rgba(84, 63, 34, 0.14);
}
.result-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
}
.result-section-head h4 {
  margin: 0 0 4px;
  font-size: 16px;
}
.flat-head {
  padding: 0 0 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.flat-head h3 {
  margin: 0 0 8px;
}
.compact-head {
  padding-bottom: 10px;
  margin-bottom: 10px;
}
.compact-head h4 {
  margin: 0 0 4px;
}
.status-title-row h3 {
  margin: 0;
}
.live-positions {
  margin-top: 16px;
}
.profit-up {
  color: var(--success);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-weight: 700;
}
.profit-down {
  color: var(--danger);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-weight: 700;
}
.trade-name-profit,
.trade-name-loss,
.trade-name-flat {
  font-weight: 700;
}
.trade-name-profit {
  color: var(--success);
}
.trade-name-loss {
  color: var(--danger);
}
.trade-name-flat {
  color: var(--muted);
}
.backtest-compare {
  margin-top: 16px;
}
.backtest-compare h4 {
  margin: 0 0 10px;
  color: var(--orange);
}
.screening-table {
  border: 0;
  border-radius: 0;
}
.screening-result-block .table-scroll {
  border: 0;
  border-radius: 0;
}
.screening-table td:nth-child(5),
.screening-table td:nth-child(6) {
  font-family: "JetBrains Mono", Consolas, monospace;
}
.signal-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  font-weight: 700;
  white-space: nowrap;
}
.signal-good {
  color: var(--success);
  background: rgba(25, 169, 116, 0.10);
  border-color: rgba(25, 169, 116, 0.36);
}
.signal-strong {
  color: var(--gold);
  background: rgba(255, 214, 0, 0.10);
  border-color: rgba(255, 214, 0, 0.34);
}
.signal-watch {
  color: var(--orange);
  background: rgba(247, 147, 26, 0.10);
  border-color: rgba(247, 147, 26, 0.36);
}
.signal-danger {
  color: var(--danger);
  background: rgba(240, 90, 90, 0.10);
  border-color: rgba(240, 90, 90, 0.34);
}
.signal-neutral {
  color: #62a8ff;
  background: rgba(98, 168, 255, 0.10);
  border-color: rgba(98, 168, 255, 0.32);
}
.signal-muted {
  color: var(--muted);
  background: var(--surface-2);
}
body.light .signal-strong { color: #8a6200; }
body.light .signal-neutral { color: #1f68b3; }
.score-badge {
  display: inline;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-weight: 800;
}
.score-top {
  color: var(--gold);
}
.score-high {
  color: var(--success);
}
.score-mid {
  color: var(--orange);
}
.score-low-badge {
  color: var(--danger);
}
.score-muted {
  color: var(--muted);
}
body.light .score-top { color: #8a6200; }
.risk-cell {
  display: inline-block;
  max-width: 360px;
  white-space: normal;
  line-height: 1.45;
}
.concept-cell {
  display: inline-block;
  max-width: 320px;
  white-space: normal;
  line-height: 1.45;
  color: var(--muted);
}
.empty-result {
  padding: 16px 14px;
}
.users-table select,
.users-table input {
  min-height: 36px;
}
.users-table td:nth-child(1) {
  font-weight: 700;
}
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th, td { border-bottom: 1px solid var(--border); padding: 10px 8px; text-align: left; white-space: nowrap; }
th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--muted);
  font-weight: 600;
  background: var(--surface);
}
.table-scroll {
  max-height: min(620px, 68vh);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  scrollbar-gutter: stable;
}
.table-scroll table {
  min-width: max-content;
}
.tasks-table {
  max-height: min(720px, 74vh);
}
.tasks-table table {
  min-width: 1128px;
  table-layout: fixed;
}
.tasks-table th:nth-child(1), .tasks-table td:nth-child(1) { width: 80px; }
.tasks-table th:nth-child(2), .tasks-table td:nth-child(2) { width: 64px; }
.tasks-table th:nth-child(3), .tasks-table td:nth-child(3) { width: 80px; }
.tasks-table th:nth-child(4), .tasks-table td:nth-child(4) { width: 220px; }
.tasks-table th:nth-child(5), .tasks-table td:nth-child(5) { width: 78px; }
.tasks-table th:nth-child(6), .tasks-table td:nth-child(6) { width: 120px; }
.tasks-table th:nth-child(7), .tasks-table td:nth-child(7) { width: 76px; }
.tasks-table th:nth-child(8), .tasks-table td:nth-child(8) { width: 170px; }
.tasks-table th:nth-child(9), .tasks-table td:nth-child(9) { width: 240px; }
.tasks-table td:nth-child(4) {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tasks-table .task-error-cell {
  color: var(--danger);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tasks-table td:nth-child(6) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.light .table-scroll {
  border-color: rgba(84, 63, 34, 0.12);
  background: rgba(255, 253, 249, 0.72);
}
body.light th {
  background: rgba(241, 237, 227, 0.82);
  color: #566170;
}
body.light tr:nth-child(even) td {
  background: rgba(249, 245, 237, 0.52);
}
body.light tr:hover td {
  background: rgba(247, 147, 26, 0.075);
}
.task-status {
  display: grid;
  gap: 10px;
}
.compact-task-status {
  grid-template-columns: minmax(220px, 1.05fr) minmax(260px, 1fr) minmax(280px, 1.1fr);
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018)),
    var(--surface-2);
}
body.light .compact-task-status {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(255, 250, 241, 0.74));
  border-color: rgba(84, 63, 34, 0.14);
}
.task-status-left {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.task-status-title {
  min-width: 0;
  color: var(--text);
  font-size: 17px;
  line-height: 1.25;
}
.task-status-progress {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.task-status-progress span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(255, 255, 255, 0.026);
}
body.light .task-status-progress span {
  background: rgba(255, 253, 249, 0.76);
  border-color: rgba(84, 63, 34, 0.12);
}
.task-status-progress em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}
.task-status-progress strong {
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
}
body.light .task-status-progress strong { color: #8a6200; }
.task-status-inline-metrics {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.task-status-inline-metrics span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(255, 255, 255, 0.026);
}
body.light .task-status-inline-metrics span {
  background: rgba(255, 253, 249, 0.76);
  border-color: rgba(84, 63, 34, 0.12);
}
.task-status-inline-metrics em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}
.task-status-inline-metrics strong {
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}
.task-status-inline-metrics strong.strong {
  font-weight: 800;
}
.task-status-error {
  grid-column: 1 / -1;
  margin-top: 0;
}
.task-status-error {
  grid-column: 1 / -1;
  margin-top: 0;
}
.progress { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, #ea580c, #ffd600); transition: width 0.2s ease; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(8px);
}
body.light .modal-backdrop { background: rgba(15, 23, 42, 0.32); }
.modal {
  width: min(430px, 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 70px -28px rgba(247, 147, 26, 0.55);
  overflow: hidden;
}
.modal-head,
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
}
.modal-head { border-bottom: 1px solid var(--border); }
.modal-foot { border-top: 1px solid var(--border); }
.modal-head h2 { margin: 0 0 4px; }
.modal-head p { margin: 0; color: var(--muted); font-size: 13px; }
.modal-body { display: grid; gap: 14px; padding: 18px; }
.notice-message {
  color: var(--text);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.icon-btn {
  width: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 8px;
  font-size: 24px;
  line-height: 1;
}
.form-error {
  border: 1px solid rgba(240, 90, 90, 0.35);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--danger);
  background: rgba(240, 90, 90, 0.08);
  font-size: 13px;
}
.task-error {
  margin-top: 12px;
}
.hidden { display: none !important; }

.login-stage {
  width: min(420px, 100%);
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  align-items: center;
  justify-self: center;
}
.login-intro,
.login-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 17, 21, 0.84);
  box-shadow: var(--shadow);
}
body.light .login-intro,
body.light .login-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 249, 239, 0.90));
  border-color: rgba(84, 63, 34, 0.16);
  box-shadow: 0 24px 70px -44px rgba(75, 55, 24, 0.55);
}
.login-intro {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 420px;
  padding: 34px;
}
.brand-mark {
  width: fit-content;
  border: 1px solid rgba(247, 147, 26, 0.38);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--orange);
  background: rgba(247, 147, 26, 0.09);
  font-weight: 800;
  letter-spacing: 0;
}
.login-intro h1 {
  max-width: 560px;
  margin: 22px 0 12px;
  font-size: 34px;
  line-height: 1.18;
  letter-spacing: 0;
}
.login-intro p {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}
.login-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
}
.login-badges span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 13px;
}
body.light .login-badges span {
  background: rgba(255, 250, 241, 0.78);
  border-color: rgba(84, 63, 34, 0.15);
}
.login-card {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 24px;
}
.login-card-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  padding-bottom: 4px;
}
.login-card h2 {
  margin: 6px 0 0;
  font-size: 26px;
}
.login-form {
  display: grid;
  gap: 14px;
}
.login-form input {
  min-height: 46px;
  border-radius: 8px;
}
.login-submit {
  width: 100%;
  min-height: 46px;
  border-radius: 8px;
}
.login-note {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

@media (max-width: 1180px) {
  .settings-overview,
  .settings-layout {
    grid-template-columns: 1fr;
  }
  .settings-side-column {
    position: static;
  }
  .settings-page .wide-fieldset .settings-fieldset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .shell:not(.auth-shell) .main { grid-column: auto; }
  .shell.auth-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: auto; height: auto; overflow: visible; border-right: 0; border-bottom: 1px solid var(--border); }
  .auth-shell .sidebar { display: none; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid, .grid.two, .settings-grid, .settings-groups, .ledger, .ledger-sections, .result-hero, .summary-grid, .risk-list, .backtest-live-grid { grid-template-columns: 1fr; }
  .strategy-family-list { grid-template-columns: 1fr; }
  .compact-task-status { grid-template-columns: 1fr; align-items: start; }
  .task-status-inline-metrics { justify-content: flex-start; }
  .settings-fieldset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-subgrid { grid-template-columns: 1fr; }
  .backtest-controls { grid-template-columns: 1fr; }
  .backtest-minute-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .backtest-minute-head { align-items: flex-start; }
  .sim-status-panel { align-items: stretch; }
  .sim-status-primary,
  .sim-info-grid,
  .sim-time-strip { flex: 1 1 100%; }
  .sim-time-strip { justify-content: flex-start; }
  .sim-controls,
  .sim-controls.account-controls { grid-template-columns: 1fr; }
  .settings-grid .wide-setting,
  .settings-fieldset-grid .wide-setting,
  .sim-controls .wide-control { grid-column: auto; }
  .user-form { grid-template-columns: 1fr; }
  .login-stage { grid-template-columns: 1fr; }
  .login-intro { min-height: 0; padding: 24px; }
  .login-intro h1 { font-size: 28px; }
  .topbar { height: auto; min-height: 64px; gap: 12px; flex-wrap: wrap; padding: 12px 16px; }
  .content { padding: 16px; }
}
@media (max-width: 640px) {
  .backtest-minute-grid { grid-template-columns: 1fr; }
  .settings-overview {
    padding: 16px;
  }
  .settings-overview-metrics {
    grid-template-columns: 1fr;
  }
  .settings-fieldset-grid,
  .settings-page .settings-fieldset-grid,
  .settings-page .wide-fieldset .settings-fieldset-grid {
    grid-template-columns: 1fr;
  }
  .strategy-mode-switch,
  .settings-page .strategy-mode-switch,
  .settings-page .strategy-mode-options { grid-template-columns: 1fr; }
  .settings-json-card summary {
    flex-direction: column;
    align-items: flex-start;
  }
  .screening-date-field { width: 100%; flex-basis: 100%; }
  .screening-actions { width: 100%; flex-wrap: wrap; }
  .compact-task-status { grid-template-columns: 1fr; }
  .task-status-inline-metrics { justify-content: flex-start; }
}

.backtest-status-card {
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 16px;
}
.backtest-status-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.backtest-status-title-block {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.status-eyebrow {
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}
.backtest-status-card .task-status-title {
  font-size: 22px;
  line-height: 1.25;
  font-weight: 800;
}
.backtest-status-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.status-date {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}
.backtest-status-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.backtest-status-stat {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.028);
}
body.light .backtest-status-stat {
  background: rgba(255, 253, 249, 0.72);
  border-color: rgba(84, 63, 34, 0.13);
}
.backtest-status-stat span {
  color: var(--muted);
  font-size: 13px;
}
.backtest-status-stat strong {
  color: var(--text);
  font-size: 20px;
  line-height: 1.15;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.backtest-status-stat strong.primary {
  color: var(--gold);
}
body.light .backtest-status-stat strong.primary {
  color: #8a6200;
}
@media (max-width: 1180px) {
  .backtest-status-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .backtest-status-head { display: grid; }
  .backtest-status-meta { justify-content: flex-start; }
  .backtest-status-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .backtest-status-card .task-status-title { font-size: 20px; }
  .backtest-status-stat strong { font-size: 18px; }
}
.screening-chart-toggle {
  min-height: 38px;
}
.screening-charts-card {
  margin-top: 18px;
}
.screening-chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.screening-chart-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
}
.screening-chart-panel.muted-panel {
  padding: 16px;
}
body.light .screening-chart-panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.66), rgba(255, 249, 240, 0.72));
  border-color: rgba(84, 63, 34, 0.14);
}
.compact-head {
  padding: 12px 14px;
}
.screening-chart-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
}
.screening-chart-item {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.026);
  overflow: hidden;
}
body.light .screening-chart-item {
  background: rgba(255, 253, 249, 0.7);
  border-color: rgba(84, 63, 34, 0.12);
}
.screening-chart-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.screening-chart-item-head strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
  word-break: break-word;
}
.screening-mini-chart-wrap {
  position: relative;
  min-height: 280px;
  background: rgba(0, 0, 0, 0.04);
}
body.light .screening-mini-chart-wrap {
  background: rgba(255, 255, 255, 0.34);
}
.screening-mini-chart-wrap canvas {
  width: 100%;
  height: 280px;
  display: block;
  cursor: crosshair;
}
.chart-skeleton {
  height: 320px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.1), rgba(255,255,255,0.04));
  background-size: 220% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}
body.light .chart-skeleton {
  background: linear-gradient(90deg, rgba(80,60,32,0.04), rgba(80,60,32,0.1), rgba(80,60,32,0.04));
  background-size: 220% 100%;
}
.chart-more-actions {
  padding: 0 12px 12px;
}
@keyframes shimmer {
  0% { background-position: 120% 0; }
  100% { background-position: -120% 0; }
}
@media (max-width: 640px) {
  .screening-chart-list {
    grid-template-columns: 1fr;
  }
}
.strategy-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin: 12px 0 4px;
}

.strategy-summary div {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
}

.strategy-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.strategy-summary strong {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  line-height: 1.5;
}

.strategy-summary-compact {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 0;
}

.strategy-summary-compact div {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
}

.strategy-summary-compact span,
.strategy-summary-compact strong {
  display: inline;
  margin-top: 0;
  line-height: 1.25;
  white-space: nowrap;
}

.strategy-summary-compact span {
  font-size: 12px;
}

.strategy-summary-compact strong {
  font-size: 13px;
}
