:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d8dde6;
  --muted: #657286;
  --text: #172033;
  --accent: #1f7a5f;
  --accent-2: #2f5f9d;
  --profit-buy: #d23f3f;
  --loss-sell: #16835f;
  --error: #b23b3b;
  --warn: #9c6a16;
  --cash: #596579;
  --buy: var(--profit-buy);
  --danger: var(--loss-sell);
  --job-list-height: clamp(360px, 42vh, 560px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
  width: 100%;
  height: 2px;
  pointer-events: none;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent));
  background-size: 200% 100%;
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left center;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

body.ajax-loading::before {
  opacity: 1;
  transform: scaleX(1);
  animation: ajax-loading-slide 1.1s linear infinite;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 700;
}

h2 {
  font-size: 17px;
  font-weight: 700;
}

h3 {
  font-size: 14px;
  margin-bottom: 10px;
}

p {
  color: var(--muted);
  margin-top: 4px;
}

nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

nav a {
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
}

nav a.active,
nav a:hover {
  border-color: var(--line);
  background: #f4f6f8;
}

.layout {
  width: calc(100vw - 32px);
  max-width: 1500px;
  margin: 18px auto 40px;
  display: grid;
  gap: 18px;
}

.band {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  min-width: 0;
}

.quote-section-head {
  align-items: center;
}

.symbol-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.chart-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
}

.chart-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.chart-history-control,
.chart-research-controls,
.chart-take-profit-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-refresh-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

.quote-warning-inline {
  margin: 0;
  max-width: min(680px, 52vw);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-align: right;
  overflow-wrap: anywhere;
}

.history-refresh-countdown {
  min-width: 116px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.chart-history-control span,
.chart-take-profit-control span {
  margin: 0;
  color: var(--muted);
  white-space: nowrap;
}

.chart-history-control {
  min-height: 32px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
}

.chart-history-control input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.chart-research-controls {
  min-height: 32px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  flex-wrap: wrap;
}

.chart-research-controls span,
.chart-research-controls em {
  color: var(--muted);
  white-space: nowrap;
  font-size: 12px;
  font-style: normal;
}

.chart-research-field {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chart-research-field input {
  width: 50px;
  height: 28px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
}

.chart-research-consensus input {
  width: 44px;
}

.chart-amplitude-toggle {
  min-height: 28px;
  padding: 0 5px;
  border-radius: 5px;
  white-space: nowrap;
}

.chart-amplitude-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.chart-research-controls select {
  width: 150px;
  max-width: min(150px, 48vw);
  height: 28px;
  padding: 3px 7px;
  font-size: 12px;
}

.chart-research-consensus select {
  width: 138px;
  max-width: min(138px, 48vw);
}

.chart-research-controls .button {
  height: 28px;
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.chart-take-profit-control select {
  width: 132px;
  max-width: min(132px, 48vw);
  height: 32px;
  padding: 4px 8px;
}

.chart-mode-control {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.chart-mode-control > span {
  color: var(--muted);
  white-space: nowrap;
}

.chart-mode-option {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 0 5px;
  border-radius: 5px;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text);
}

.chart-mode-option input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.chart-mode-option:has(input:disabled) {
  color: var(--muted);
  background: #f5f7fa;
}

.take-profit-recalc-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 250, 252, 0.58);
  backdrop-filter: blur(2px);
}

.take-profit-recalc-box {
  width: min(360px, calc(100vw - 36px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.16);
}

.take-profit-recalc-box b {
  display: block;
  margin-bottom: 10px;
  color: var(--text);
  font-size: 14px;
}

.take-profit-recalc-box small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.take-profit-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}

.take-profit-progress span {
  display: block;
  height: 100%;
  width: 8%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ef4444, #f59e0b);
  transition: width 0.45s ease;
}

.chart-tool {
  width: 34px;
  height: 32px;
  padding: 0;
  text-align: center;
  font-weight: 700;
}

.chart-tool-text {
  width: auto;
  min-width: 48px;
  padding: 0 10px;
  font-weight: 600;
}

.chart-range {
  min-height: 20px;
  margin: -6px 0 10px;
  font-size: 12px;
}

.chart-range:empty {
  display: none;
}

.symbol-tabs button,
.button,
select,
input {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
}

.symbol-tabs button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: #eef8f3;
}

.button {
  cursor: pointer;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.button.secondary {
  background: #f7f8fa;
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.chart-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(300px, 26vw, 380px);
  gap: 12px;
  align-items: stretch;
}

.chart-wrap {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fbfcfd;
}

#kline-canvas {
  width: 100%;
  height: 480px;
  display: block;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#kline-canvas.dragging {
  cursor: grabbing;
}

.chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(251, 252, 253, 0.86);
  backdrop-filter: blur(2px);
  z-index: 2;
}

.chart-loading.error .loading-inline {
  color: #b3261e;
}

.day-panel {
  width: auto;
  max-height: 482px;
  overflow: auto;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.day-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.day-panel-head h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.day-panel-head span {
  flex: 0 1 160px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: right;
}

.day-panel table {
  margin-top: 10px;
}

.day-panel-empty {
  display: flex;
  min-height: 180px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.day-ohlc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.day-ohlc-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.day-ohlc-row b {
  flex: 0 0 auto;
}

.day-marker-summary {
  margin-top: 10px;
}

.day-marker-summary > b {
  display: inline-block;
  color: var(--accent-2);
}

.day-panel td:first-child,
.day-panel th:first-child {
  text-align: left;
}

.hidden {
  display: none !important;
}

.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #526173;
  font-weight: 600;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #d7dde5;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: 0 0 auto;
}

.spinner.tiny {
  width: 12px;
  height: 12px;
  border-width: 2px;
}

.loading-cell {
  height: 96px;
  text-align: center !important;
  background: #fbfcfd;
}

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

@keyframes ajax-loading-slide {
  to {
    background-position: 200% 0;
  }
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  max-width: 100%;
  min-width: 0;
}

#quote-warning,
#home-meta {
  overflow-wrap: anywhere;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  background: #ffffff;
}

th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

th {
  position: sticky;
  top: 0;
  background: #f2f5f8;
  z-index: 1;
  font-weight: 700;
  color: #2b3748;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

.text-left {
  text-align: left;
}

#quote-table th,
#quote-table td {
  text-align: right;
}

#quote-table .text-left {
  text-align: left;
}

.advice-buy-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: #fff1f1;
  color: #c01818;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

tr:hover td {
  background: #fafbfc;
}

.buy {
  color: var(--buy);
  font-weight: 700;
}

.cash {
  color: var(--cash);
}

.sell {
  color: var(--loss-sell);
  font-weight: 700;
}

.danger {
  color: var(--danger);
}

.warn {
  color: var(--warn);
}

.tooltip-host {
  cursor: help;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.custom-tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  width: min(520px, calc(100vw - 24px));
  max-height: min(620px, calc(100vh - 24px));
  overflow: auto;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  border: 1px solid #cfd7e3;
  border-radius: 7px;
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(25, 38, 59, 0.18);
  padding: 8px;
  color: var(--text);
  text-align: left;
  white-space: normal;
}

.custom-tooltip.compact {
  width: max-content;
  max-width: calc(100vw - 24px);
  padding: 6px 8px;
  overflow: visible;
  white-space: nowrap;
}

.custom-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.tooltip-strategy + .tooltip-strategy {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e4e8ee;
}

.tooltip-kicker {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 3px;
}

.tooltip-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.tooltip-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tooltip-title-row .tooltip-title {
  min-width: 0;
}

.tooltip-title-rate {
  flex: 0 0 auto;
  padding: 2px 6px;
  border: 1px solid #f0c3c3;
  border-radius: 999px;
  background: #fff1f1;
  color: var(--profit-buy);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.tooltip-subtitle {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.tooltip-compact {
  display: inline-block;
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
}

.tooltip-method {
  margin-top: 6px;
  padding: 6px;
  border: 1px solid #e1e6ed;
  border-radius: 6px;
  background: #f8fafc;
}

.tooltip-method-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.35;
}

.tooltip-rank {
  flex: 0 0 auto;
  min-width: 30px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #edf4ff;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.tooltip-method-head b {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.tooltip-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 6px;
  margin-top: 0;
}

.tooltip-metrics span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.tooltip-metrics small {
  color: var(--muted);
  font-size: 11px;
}

.tooltip-metrics b {
  color: #243246;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.tooltip-empty {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.tooltip-distribution {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.tooltip-distribution-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 48px 68px;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid #e1e6ed;
  border-radius: 6px;
  background: #f8fafc;
}

.tooltip-distribution-row span {
  overflow-wrap: anywhere;
}

.tooltip-distribution-row b,
.tooltip-distribution-row em {
  text-align: right;
  font-style: normal;
}

.tooltip-distribution-row em {
  color: var(--muted);
}

.source-temp {
  color: var(--warn);
}

.train-grid {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.selection-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.history-band {
  display: flex;
  flex-direction: column;
}

.train-controls {
  position: static;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.train-settings-head {
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.train-settings-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.train-settings-title p {
  margin-top: 0;
  white-space: nowrap;
}

.train-settings-tools {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.model-filter-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.model-filter-field span {
  flex: 0 0 auto;
  margin: 0;
  white-space: nowrap;
}

.model-filter-field input {
  flex: 1 1 auto;
}

.train-settings-tools .inline-model-actions {
  align-self: end;
  justify-content: flex-start;
  flex-wrap: nowrap;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "filter filter"
    "start end"
    "earliest actions";
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.train-filter-grid {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}

.train-filter-grid > label {
  flex: 0 1 360px;
  max-width: 360px;
}

.train-filter-grid .inline-model-actions {
  flex: 0 0 auto;
}

.form-grid > label {
  min-width: 0;
}

.form-grid > label:nth-child(1) {
  grid-area: filter;
}

.form-grid > label:nth-child(2) {
  grid-area: start;
}

.form-grid > label:nth-child(3) {
  grid-area: earliest;
}

.form-grid > label:nth-of-type(4) {
  grid-area: end;
}

.inline-model-actions {
  grid-area: actions;
  align-self: center;
  margin: 0;
}

.train-filter-grid > label,
.train-filter-grid .inline-model-actions {
  grid-area: auto;
}

.compact-form-grid {
  grid-template-areas: none;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  align-items: center;
  margin-bottom: 0;
}

.compact-form-grid > label,
.compact-form-grid > div {
  grid-area: auto;
}

.observation-help {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

label span {
  display: block;
  color: var(--muted);
  margin-bottom: 5px;
}

label input {
  width: 100%;
  min-width: 0;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.checkline input {
  width: auto;
}

.checkline span {
  margin: 0;
  color: var(--text);
}

.model-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin: 12px 0 8px;
}

.model-actions.inline-model-actions {
  margin: 0;
}

.train-pool-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.candidate-model-panel,
.train-symbol-pool {
  display: flex;
  flex-direction: column;
  height: 520px;
  min-width: 0;
  padding: 12px;
  border: 1px solid #e1e6ee;
  border-radius: 8px;
  background: #fbfcfd;
}

.candidate-panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, auto);
  align-items: center;
  gap: 10px;
  min-height: 40px;
  margin-bottom: 8px;
}

.candidate-panel-head > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
}

.candidate-panel-head h3 {
  flex: 0 0 auto;
  margin: 0;
  white-space: nowrap;
}

.candidate-panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.candidate-panel-head #model-count {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate-panel-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.candidate-panel-tools .model-filter-field {
  flex: 1 1 220px;
  max-width: 280px;
}

.candidate-panel-tools .inline-model-actions {
  flex: 0 0 auto;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.model-list {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.model-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #e6eaf0;
}

.model-row small {
  color: var(--muted);
}

.model-row .tag {
  color: var(--accent-2);
}

.symbol-pool {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.train-symbol-pool {
  margin-top: 0;
}

.symbol-pool-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.symbol-pool-head > div:first-child,
.section-title-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.symbol-pool-head h3,
.section-title-line h2 {
  flex: 0 0 auto;
}

.symbol-pool-head p,
.section-title-line p {
  margin-top: 0;
  font-size: 13px;
}

#backtest-symbol-meta {
  white-space: nowrap;
}

.symbol-pool-head > .train-symbol-title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
}

.train-symbol-title-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.train-symbol-title-line h3 {
  flex: 0 0 auto;
  margin: 0;
  white-space: nowrap;
}

.train-symbol-title-line p {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.symbol-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.train-date-controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: end;
  flex: 0 0 auto;
  min-width: 0;
}

.train-date-controls label {
  min-width: 0;
}

.train-date-controls .date-input-field,
.train-date-controls > label {
  width: 138px;
}

.date-with-earliest {
  min-width: 0;
}

.date-input-field {
  min-width: 0;
}

.date-input-field input:disabled {
  color: #8b98aa;
  border-color: #d6dde7;
  background: #eef2f6;
  cursor: not-allowed;
  opacity: 1;
}

.date-label-line {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 5px;
  min-height: 20px;
}

.date-label-line > span {
  margin: 0;
  color: var(--muted);
  white-space: nowrap;
}

.date-with-earliest .earliest-toggle {
  flex: 0 0 auto;
  min-height: 0;
}

.date-label-line .earliest-toggle span {
  color: var(--text);
  font-size: 13px;
}

.train-symbol-actions {
  justify-content: flex-start;
  margin: 8px 0 4px;
}

.train-symbol-title .symbol-stress-toggle {
  min-height: 22px;
  max-width: 100%;
  font-size: 13px;
}

.train-symbol-title .symbol-stress-toggle span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.symbol-add-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.symbol-add-form input[type="text"] {
  width: 180px;
  max-width: 100%;
}

.symbol-stress-toggle,
.take-profit-toggle,
.stop-loss-toggle {
  margin: 0;
  color: var(--text);
}

.symbol-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  max-height: 360px;
  overflow: auto;
}

.train-symbol-pool #backtest-symbol-list {
  flex: 1 1 auto;
  max-height: none;
  min-height: 0;
  padding-right: 2px;
}

.rule-list {
  max-height: 340px;
}

.symbol-row {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 7px;
  align-items: center;
  padding: 8px 9px;
  border: 1px solid #e1e6ee;
  border-radius: 6px;
  background: #fbfcfd;
}

.symbol-row input {
  width: auto;
}

.symbol-row span,
.symbol-row small {
  min-width: 0;
  overflow: hidden;
  overflow-wrap: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.symbol-row small {
  grid-column: 2;
  color: var(--muted);
}

.symbol-row .symbol-row-flags {
  grid-column: 3;
  grid-row: 1 / span 2;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.symbol-row .symbol-row-flags input {
  width: 14px;
  height: 14px;
}

.train-symbol-pool .symbol-row {
  grid-template-columns: 20px minmax(0, 1fr) minmax(86px, auto) auto;
  min-height: 36px;
  padding: 6px 9px;
}

.train-symbol-pool .symbol-row small {
  grid-column: auto;
}

.train-symbol-pool .symbol-row .symbol-row-flags {
  grid-column: auto;
  grid-row: auto;
}

.rule-row span {
  font-weight: 650;
}

.rule-row {
  grid-template-columns: 20px minmax(0, 1fr);
}

.train-workflow-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.train-workflow-grid .progress-band,
.entry-rules-band {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.train-workflow-grid .progress-band {
  height: 520px;
  min-height: 0;
}

.entry-rules-band {
  height: 520px;
}

.entry-rules-band .symbol-pool-head {
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.entry-rules-band .symbol-pool-head > div:first-child {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  gap: 0 10px;
  flex: 1 1 auto;
}

.entry-rules-band #entry-rule-meta {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-rules-band .symbol-actions {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 6px;
}

.entry-rules-band .checkline {
  gap: 5px;
  min-height: 30px;
  white-space: nowrap;
}

.entry-rules-band .rule-list {
  flex: 1 1 auto;
  gap: 4px;
  max-height: none;
  min-height: 0;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 10px;
}

.cache-estimate {
  margin-right: auto;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.entry-rules-band .cache-estimate {
  grid-column: 1 / -1;
  margin-top: -1px;
  margin-right: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.25;
}

.entry-rules-band .rule-row {
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 6px;
  min-height: 32px;
  padding: 5px 8px;
}

.entry-rules-band .rule-row input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.progress {
  height: 16px;
  background: #edf1f5;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s ease;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfd;
}

.metric b {
  display: block;
  font-size: 18px;
  margin-top: 4px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f7f8fa;
  color: var(--muted);
}

.status-pill.running {
  color: var(--accent-2);
  background: #edf4ff;
  border-color: #b9ccec;
}

.status-pill.succeeded {
  color: var(--accent);
  background: #eef8f3;
  border-color: #b7dccf;
}

.status-pill.failed {
  color: var(--error);
  background: #fff1f1;
  border-color: #efc0c0;
}

.status-pill.loading {
  color: var(--accent-2);
  background: #edf4ff;
  border-color: #b9ccec;
}

.metric-loading b {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 16px;
}

.job-list {
  position: relative;
  height: var(--job-list-height);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.history-band .job-list {
  flex: 1 1 0;
  height: auto;
  min-height: 0;
  max-height: none;
}

.job-list.is-loading::before {
  content: "";
  position: sticky;
  top: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent));
  background-size: 200% 100%;
  animation: ajax-loading-slide 1.1s linear infinite;
}

.job-list.is-loading::after {
  content: "任务历史更新中...";
  position: sticky;
  bottom: 0;
  display: block;
  padding: 8px 12px;
  border-top: 1px solid #dfe6ef;
  background: rgba(248, 250, 252, 0.94);
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  backdrop-filter: blur(4px);
}

.job-list-state {
  padding: 14px 12px;
  color: var(--muted);
  font-size: 13px;
}

.job-list-state.error {
  color: var(--error);
  background: #fff7f7;
}

.job-parent {
  display: grid;
  grid-template-columns: 30px 70px minmax(0, 1fr) 82px;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-bottom: 1px solid #dfe6ef;
  background: #f7f9fb;
  cursor: pointer;
}

.job-parent.active {
  background: #edf4ff;
}

.job-parent span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.job-parent small {
  color: var(--muted);
  text-align: right;
}

.job-parent-toggle {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

.job-item {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 56px 220px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #e6eaf0;
  cursor: pointer;
}

.job-child {
  padding-left: 28px;
  background: #ffffff;
}

.table-loading {
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  background: #fbfcfd;
  font-weight: 650;
}

.job-item.is-deleting,
.job-item.is-stopping {
  opacity: 0.68;
  pointer-events: none;
  background: #fbfcfd;
}

.job-item.is-loading {
  opacity: 0.72;
  pointer-events: none;
  background: #f7f9fb;
}

.job-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-item:hover {
  background: #fafbfc;
}

.job-item.active {
  background: #edf4ff;
}

.job-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
}

.job-delete,
.job-stop,
.job-save-artifacts,
.job-save-prediction-cache,
.job-delete-local,
.job-delete-remote {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid #efc0c0;
  border-radius: 6px;
  background: #fff7f7;
  color: var(--error);
  cursor: pointer;
  white-space: nowrap;
}

.job-delete:hover:not(:disabled),
.job-stop:hover:not(:disabled),
.job-save-artifacts:hover:not(:disabled),
.job-save-prediction-cache:hover:not(:disabled),
.job-delete-local:hover:not(:disabled),
.job-delete-remote:hover:not(:disabled) {
  background: #fff1f1;
}

.job-delete:disabled,
.job-stop:disabled,
.job-save-artifacts:disabled,
.job-save-prediction-cache:disabled,
.job-delete-local:disabled,
.job-delete-remote:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.job-stop {
  border-color: #e5b557;
  background: #fff8e6;
  color: #8a5a00;
}

.job-stop:hover:not(:disabled) {
  background: #fff1c7;
}

.job-save-artifacts,
.job-save-prediction-cache,
.job-delete-local,
.job-delete-remote {
  border-color: #c9d7e8;
  background: #f7fafc;
  color: var(--text);
}

.job-save-artifacts:hover:not(:disabled),
.job-save-prediction-cache:hover:not(:disabled),
.job-delete-local:hover:not(:disabled),
.job-delete-remote:hover:not(:disabled) {
  background: #eef4fa;
}

.job-item.is-deleting .job-delete,
.job-item.is-stopping .job-stop {
  opacity: 1;
}

.app-toast {
  position: fixed;
  top: 74px;
  right: 24px;
  z-index: 100;
  max-width: min(360px, calc(100vw - 32px));
  padding: 10px 14px;
  border: 1px solid #b7dccf;
  border-radius: 8px;
  background: #eef8f3;
  color: var(--accent);
  box-shadow: 0 14px 34px rgba(20, 35, 60, 0.16);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.app-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.app-toast.error {
  border-color: #efc0c0;
  background: #fff1f1;
  color: var(--error);
}

.results-band {
  grid-column: 1 / -1;
}

.practice-results-band {
  margin-top: 0;
}

.practice-results-band .section-head {
  align-items: center;
  flex-wrap: wrap;
  row-gap: 10px;
}

.practice-results-band .section-title-line {
  align-items: center;
  flex-wrap: nowrap;
}

.practice-title-line {
  flex: 1 1 260px;
  min-width: 0;
}

#practice-result-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.practice-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1 1 100%;
  min-width: 0;
}

.practice-consensus-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  justify-content: stretch;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.practice-consensus-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  min-width: 0;
}

.practice-consensus-field span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.practice-consensus-field select {
  width: 100%;
  min-width: 0;
}

.practice-consensus-rule-field select {
  min-width: 0;
}

.practice-combo-summary {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  flex: 0 1 auto;
  min-width: 0;
  margin: 0 0 0 auto;
}

.combo-mode-toggle {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border: 1px solid #d9e2ee;
  border-radius: 7px;
  background: #f7f9fb;
}

.combo-mode-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 52px;
  height: 30px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.combo-mode-button.is-loading {
  min-width: 68px;
  color: var(--accent-2);
}

.combo-mode-button.active {
  background: #ffffff;
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(20, 35, 60, 0.12);
}

.practice-combo-summary p {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.result-pair {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.result-pair .results-band {
  grid-column: auto;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.observation-band {
  display: flex;
  flex-direction: column;
}

.observation-settings-head {
  align-items: center;
  margin-bottom: 10px;
}

.observation-title-line {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.observation-title-line p {
  margin-top: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.observation-rebacktest-button {
  flex: 0 0 auto;
}

.settings-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.observation-band .settings-list {
  grid-template-columns:
    minmax(104px, 0.66fr)
    minmax(104px, 0.66fr)
    minmax(180px, 0.95fr)
    minmax(248px, 1.45fr);
  align-items: stretch;
  margin-top: 0;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(116px, 0.42fr) minmax(0, 0.58fr);
  align-items: center;
  gap: 10px;
  min-height: 38px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #d9e2ee;
  border-radius: 6px;
  background: #ffffff;
}

.observation-band .settings-row {
  min-height: 38px;
  padding: 6px 9px;
}

.settings-row.checkline {
  grid-template-columns: 22px minmax(0, 1fr);
}

.settings-row span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.settings-row.checkline span {
  color: var(--text);
}

.settings-submit-row .button {
  justify-self: end;
}

.observation-option-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.settings-date-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.settings-row.settings-date-field,
.settings-row.result-threshold-field {
  display: grid;
}

.settings-date-field span {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.settings-date-field input {
  width: 150px;
  min-width: 0;
}

.settings-row.settings-date-field input {
  width: 100%;
}

.result-actions {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.result-actions label {
  display: grid;
  gap: 5px;
  min-width: 180px;
}

.baseline-panel {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  background: transparent;
}

.baseline-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.baseline-title .button {
  margin-left: 0;
}

.baseline-stress-toggle {
  margin-left: 0;
}

.baseline-pool-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.baseline-pool-head > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.baseline-pool-head span {
  color: var(--muted);
  font-size: 13px;
}

.baseline-stress-toggle,
.baseline-take-profit-toggle,
.baseline-stop-loss-toggle {
  white-space: nowrap;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #d9e2ee;
  border-radius: 6px;
  background: #ffffff;
}

.baseline-take-profit-toggle {
  margin-left: 0;
}

.baseline-stop-loss-toggle {
  margin-left: 0;
}

.baseline-title span {
  color: var(--muted);
  font-size: 13px;
}

.baseline-title .checkline span {
  color: var(--text);
}

.result-rule-picker {
  display: grid;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
}

.result-rule-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.result-rule-picker-head > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.result-rule-picker-head span,
.result-rule-meta {
  color: var(--muted);
  font-size: 13px;
}

.result-rule-meta {
  margin: 0;
}

.result-threshold-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.settings-row.result-threshold-field {
  display: grid;
  grid-template-columns: minmax(116px, 0.42fr) minmax(0, 0.58fr);
  justify-content: stretch;
}

.settings-row.result-threshold-field .result-threshold-input {
  justify-self: end;
}

.observation-band .settings-row.result-threshold-field,
.observation-band .settings-row.settings-date-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.observation-band .settings-row.result-threshold-field .result-threshold-input {
  flex: 0 0 auto;
  justify-self: auto;
  margin-right: 8px;
}

.observation-band .settings-row.settings-date-field input {
  flex: 0 0 150px;
  width: 150px;
}

.result-threshold-input {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid #d9e2ee;
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
}

.result-threshold-input input {
  width: 64px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: right;
}

.result-threshold-input em {
  color: var(--muted);
  font-style: normal;
}

.result-title-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  margin-left: auto;
}

.result-title-actions .button {
  white-space: nowrap;
}

.observation-results-band .section-head {
  align-items: center;
  flex-wrap: nowrap;
}

.observation-results-band .section-title-line {
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
}

.observation-results-band #result-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.consensus-inline-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #fff1f1;
  color: var(--profit-buy);
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}

.consensus-result-row {
  background: #fff8f8;
}

.consensus-result-row td {
  border-top-color: #f1d8d8;
}

.result-rule-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 8px;
}

.rule-chip {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  height: 36px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid #d9e2ee;
  border-radius: 6px;
  background: #ffffff;
  font-size: 13px;
  cursor: pointer;
}

.rule-chip:hover {
  border-color: var(--accent);
  background: #f9fbff;
}

.rule-chip input {
  margin: 0;
}

.rule-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rebacktest-progress {
  display: grid;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid #d9e2ee;
  border-radius: 6px;
  background: #f8fbff;
}

.rebacktest-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rebacktest-progress-status,
.rebacktest-progress-phase,
.rebacktest-progress-meta {
  color: var(--muted);
  font-size: 13px;
}

.rebacktest-progress-bar {
  height: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: #edf1f5;
}

.rebacktest-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s ease;
}

.baseline-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  height: var(--job-list-height);
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.baseline-item {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(254px, auto);
  align-items: center;
  column-gap: 12px;
  width: auto;
  min-height: 44px;
  overflow: hidden;
  padding: 8px 10px;
  border: 1px solid #e4e8ee;
  border-radius: 6px;
  background: #fafbfc;
  cursor: pointer;
}

.baseline-symbol-line {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 22px;
  min-width: 0;
  line-height: 1.35;
}

.baseline-item-static .baseline-symbol-line {
  grid-template-columns: minmax(0, 1fr);
}

.baseline-symbol-line input {
  width: auto;
}

.baseline-symbol-line span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.baseline-metrics {
  display: grid;
  grid-template-columns: minmax(70px, auto) minmax(78px, auto) minmax(100px, auto);
  align-items: center;
  justify-content: end;
  gap: 8px;
  min-height: 22px;
  min-width: 0;
  padding-left: 0;
  line-height: 1.35;
}

.baseline-item-static .baseline-metrics {
  padding-left: 0;
}

.baseline-metrics b,
.baseline-metrics small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.baseline-grid-placeholder .baseline-item {
  cursor: default;
  color: var(--muted);
}

#result-table th.sortable {
  cursor: pointer;
  white-space: nowrap;
}

#result-table th.sortable::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 5px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid transparent;
  vertical-align: middle;
}

#result-table th.sortable.active {
  color: var(--accent);
}

#result-table th.sortable.active::after {
  border-top-color: var(--accent);
}

.result-table-wrap {
  max-height: 620px;
}

#result-table tbody tr.result-row-hover,
#practice-result-table tbody tr.result-row-hover {
  background: #fff7e6;
  outline: 1px solid #f4b95f;
  outline-offset: -1px;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
}

.topbar-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.topbar-button:hover {
  border-color: var(--accent);
}

.email-alert-button {
  border-color: #f3c58a;
  background: #fff8ec;
  color: #8a4b0f;
}

.email-alert-button.enabled {
  border-color: var(--line);
  background: #f4f6f8;
  color: var(--muted);
}

.email-alert-button:disabled {
  opacity: 0.68;
  cursor: wait;
}

.email-alert-monitor-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
}

.email-alert-button + .email-alert-monitor-status {
  margin-left: 2px;
}

.email-alert-monitor-status + a {
  margin-left: 8px;
}

.job-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.danger-button {
  border-color: #7f1d1d;
  color: #7f1d1d;
  background: #fff7f7;
}

.danger-button:disabled {
  border-color: var(--line);
  color: var(--muted);
  background: #f4f6f8;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f4f7fb;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(20, 35, 60, 0.12);
}

.login-card h1 {
  margin: 0;
  font-size: 24px;
}

.login-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.login-card label {
  display: grid;
  gap: 7px;
}

.login-card .remember-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.login-card .remember-row input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
}

.login-card .remember-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.login-error {
  min-height: 20px;
  color: #7f1d1d;
  font-size: 13px;
}

@media (max-width: 1000px) {
  :root {
    --job-list-height: clamp(300px, 48vh, 440px);
  }

  .topbar,
  .section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .chart-side,
  .symbol-tabs,
  .chart-toolbar,
  .history-refresh-actions {
    align-items: stretch;
    justify-content: flex-start;
  }

  .history-refresh-actions {
    flex-wrap: wrap;
  }

  .quote-warning-inline {
    max-width: none;
    text-align: left;
    flex: 1 1 100%;
  }

  .chart-detail-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .day-panel {
    max-height: 320px;
  }

  .train-grid,
  .selection-grid,
  .train-pool-layout,
  .train-workflow-grid,
  .form-grid,
  .split,
  .metric-row,
  .result-pair,
  .result-actions {
    grid-template-columns: 1fr;
  }

  .settings-actions,
  .settings-list,
  .result-actions,
  .practice-head-actions,
  .practice-consensus-controls {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
  }

  .observation-band .settings-list {
    grid-template-columns: 1fr;
  }

  .observation-title-line p {
    white-space: normal;
  }

  .observation-band .settings-row.result-threshold-field,
  .observation-band .settings-row.settings-date-field {
    justify-content: flex-start;
  }

  .observation-band .settings-row.settings-date-field input {
    flex: 1 1 150px;
    width: 100%;
  }

  .practice-results-band .section-title-line {
    flex-wrap: wrap;
  }

  .practice-consensus-controls {
    grid-template-columns: 1fr;
  }

  #practice-result-meta {
    white-space: normal;
  }

  .baseline-stress-toggle {
    margin-left: 0;
  }

  .form-grid {
    grid-template-areas:
      "filter"
      "start"
      "earliest"
      "actions"
      "end";
  }

  .train-filter-grid {
    display: grid;
    grid-template-areas: none;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .train-filter-grid > label {
    max-width: none;
  }

  .train-filter-grid .inline-model-actions {
    justify-content: flex-start;
  }

  .train-settings-head,
  .candidate-panel-head {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .train-settings-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .model-filter-field {
    max-width: none;
    min-width: 0;
  }

  .model-filter-field {
    flex-direction: column;
    align-items: stretch;
  }

  .candidate-panel-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .candidate-panel-tools .model-filter-field {
    max-width: none;
  }

  .candidate-panel-tools .inline-model-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .job-head-actions {
    justify-content: flex-start;
  }

  .entry-rules-band {
    height: auto;
  }

  .entry-rules-band .symbol-pool-head > div:first-child {
    grid-template-columns: 1fr;
  }

  .entry-rules-band #entry-rule-meta,
  .entry-rules-band .cache-estimate {
    white-space: normal;
  }

  .entry-rules-band .symbol-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .train-date-controls,
  .settings-row,
  .settings-row.result-threshold-field,
  .baseline-item,
  .baseline-item-static {
    grid-template-columns: 1fr;
  }

  .date-label-line {
    justify-content: space-between;
  }

  .train-symbol-pool .symbol-row {
    grid-template-columns: 20px minmax(0, 1fr) auto;
  }

  .train-symbol-pool .symbol-row small {
    display: none;
  }

  .baseline-metrics {
    justify-content: stretch;
    grid-template-columns: minmax(70px, auto) minmax(78px, auto) minmax(100px, auto);
    padding-left: 26px;
  }

  .baseline-item-static .baseline-metrics {
    padding-left: 0;
  }

  .settings-row.checkline {
    grid-template-columns: 22px minmax(0, 1fr);
  }

  .settings-submit-row .button,
  .settings-row.result-threshold-field .result-threshold-input {
    justify-self: stretch;
  }

}
