:root {
  --ink: #16202f;
  --muted: #667386;
  --line: #d9e1ec;
  --panel: #ffffff;
  --bg: #f4f7fb;
  --soft-bg: #eef3f8;
  --accent: #1769aa;
  --accent-strong: #0f5f9e;
  --success: #16824c;
  --danger: #b42318;
  --shadow: 0 10px 26px rgba(24, 39, 75, 0.07);
}

body {
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

.app-nav {
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(22, 32, 47, 0.03);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
}

.app-shell {
  max-width: 1480px;
}

.dashboard-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.dashboard-hero h1 {
  font-weight: 750;
  letter-spacing: 0;
}

.dashboard-actions {
  text-align: right;
}

.status-strip {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.login-shell {
  min-height: 70vh;
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
}

.metric,
.panel,
.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

.metric-value {
  font-size: clamp(1.18rem, 1.4vw, 1.55rem);
  font-weight: 750;
  margin-top: 12px;
  line-height: 1.15;
}

.panel {
  padding: 20px;
  min-height: 100%;
}

.panel h2 {
  font-size: 1.02rem;
  font-weight: 750;
  margin-bottom: 16px;
}

.tile {
  padding: 16px;
  font-weight: 600;
  min-height: 72px;
}

.log-view {
  background: #111827;
  color: #e5e7eb;
  border-radius: 8px;
  padding: 14px;
  max-height: 360px;
  overflow: auto;
  font-size: 0.82rem;
  white-space: pre-wrap;
}

.mini-stat,
.risk-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 74px;
  background: #fbfdff;
}

.mini-stat span,
.risk-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.mini-stat strong,
.risk-grid strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.dashboard-table {
  min-width: 760px;
}

.bar-chart,
.prediction-list,
.screener-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(92px, 1.1fr) minmax(140px, 2fr) minmax(86px, auto) minmax(72px, auto);
  align-items: center;
  gap: 14px;
  font-size: 0.9rem;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.bar-detail {
  color: var(--muted);
  font-size: 0.76rem;
  grid-column: 2 / -1;
  margin-top: -8px;
}

.trade-exit-button {
  justify-self: end;
  min-height: 34px;
  min-width: 64px;
}

.bar-row:last-child {
  border-bottom: 0;
}

.bar-symbol {
  display: block;
  font-weight: 750;
}

.bar-meta {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  margin-top: 2px;
}

.bar-track {
  height: 18px;
  background: var(--soft-bg);
  border: 1px solid #d5dfeb;
  border-radius: 8px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 8px;
  background: linear-gradient(90deg, var(--success), #36b36f);
  border-radius: 7px;
}

.bar-fill.negative {
  background: linear-gradient(90deg, var(--danger), #f04438);
}

.line-chart {
  min-height: 420px;
}

.analytics-panel {
  padding: 0;
  overflow: hidden;
}

.analytics-header {
  align-items: flex-start;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 28px 28px 10px;
}

.analytics-header h2 {
  font-size: clamp(1.85rem, 3vw, 2.6rem);
  font-weight: 250;
  letter-spacing: 0;
  line-height: 1;
  margin: 0 0 10px;
}

.analytics-header p {
  color: var(--muted);
  font-size: 1rem;
  margin: 0;
}

.analytics-periods {
  display: grid;
  gap: 8px;
  min-width: 150px;
}

.analytics-period {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #334155;
  cursor: pointer;
  min-height: 54px;
  padding: 9px 13px;
  text-align: left;
  transition: background-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.analytics-period:hover,
.analytics-period:focus-visible {
  box-shadow: 0 10px 22px rgba(24, 39, 75, 0.11);
  transform: translateY(-1px);
}

.analytics-period.active {
  background: #111827;
  border-color: #111827;
  color: #ffffff;
}

.analytics-period span,
.analytics-period strong {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.analytics-period span {
  font-size: 0.78rem;
  font-weight: 750;
  margin-bottom: 3px;
}

.analytics-period strong {
  font-size: 0.78rem;
  font-weight: 550;
}

.analytics-period i,
.analytics-legend i {
  border-radius: 999px;
  display: inline-block;
  height: 9px;
  width: 9px;
}

.period-green {
  background: #16a34a;
}

.period-blue,
.legend-long {
  background: #3b82f6;
}

.period-orange {
  background: #f97316;
}

.period-purple {
  background: #7c3aed;
}

.legend-short {
  background: #374151;
}

.analytics-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 8px 28px 0;
}

.analytics-legend span {
  align-items: center;
  color: #334155;
  display: inline-flex;
  gap: 8px;
}

.analytics-legend strong {
  color: var(--ink);
}

.analytics-chart-shell {
  padding: 4px 20px 0;
}

.analytics-chart {
  display: block;
  min-height: 280px;
  width: 100%;
}

.analytics-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.6;
}

.analytics-line-long {
  stroke: #3b82f6;
}

.analytics-line-short {
  stroke: #374151;
}

.analytics-point {
  cursor: pointer;
  transition: r 160ms ease;
}

.analytics-hit-line {
  opacity: 0;
  stroke: #cbd5e1;
  stroke-dasharray: 4 5;
}

.analytics-hit-target {
  cursor: pointer;
  fill: transparent;
}

.analytics-axis-label {
  fill: #8a97a8;
  font-size: 13px;
  font-weight: 500;
}

.analytics-tooltip rect {
  fill: #ffffff;
  stroke: #e5e7eb;
  filter: drop-shadow(0 12px 18px rgba(15, 23, 42, 0.14));
}

.analytics-tooltip text {
  font-size: 11px;
  font-weight: 650;
}

.tooltip-title {
  fill: #1f2937;
}

.tooltip-long {
  fill: #2563eb;
}

.tooltip-short {
  fill: #374151;
}

.analytics-bottom {
  align-items: flex-end;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 0 28px 28px;
}

.analytics-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.analytics-metric {
  background: #ffffff;
  border: 2px solid #dbeafe;
  border-radius: 8px;
  min-width: 122px;
  padding: 14px;
}

.analytics-metric div {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.analytics-metric i {
  background: currentColor;
  border-radius: 999px;
  height: 8px;
  opacity: 0.62;
  width: 8px;
}

.analytics-metric span,
.analytics-metric small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.analytics-metric strong {
  color: var(--ink);
  display: block;
  font-size: 1.42rem;
  line-height: 1.1;
  margin-bottom: 4px;
}

.metric-blue {
  border-color: #3b82f6;
  color: #3b82f6;
}

.metric-orange {
  border-color: #f97316;
  color: #f97316;
}

.metric-green {
  border-color: #16a34a;
  color: #16a34a;
}

.analytics-bundle {
  background: #111827;
  border-radius: 8px;
  color: #ffffff;
  min-width: 240px;
  padding: 14px 18px;
}

.analytics-bundle div:first-child {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.analytics-bundle span {
  color: #cbd5e1;
  font-weight: 650;
}

.analytics-progress {
  background: #374151;
  border-radius: 999px;
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
}

.analytics-progress span {
  background: linear-gradient(90deg, #3b82f6, #16a34a, #f97316);
  border-radius: inherit;
  display: block;
  height: 100%;
  width: 100%;
}

.pnl-chart-block {
  border-top: 1px solid var(--line);
  padding: 22px 28px 26px;
}

.pnl-chart-header {
  align-items: flex-start;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.pnl-chart-header h2 {
  font-size: 1.05rem;
  font-weight: 750;
  margin: 0 0 4px;
}

.pnl-chart-header p {
  color: var(--muted);
  margin: 0;
}

.pnl-total {
  display: grid;
  font-size: 1.5rem;
  font-weight: 800;
  justify-items: end;
  line-height: 1;
  white-space: nowrap;
}

.pnl-total span {
  color: currentColor;
  font-size: 0.86rem;
  font-weight: 750;
  margin-top: 6px;
}

.pnl-positive {
  color: var(--success);
}

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

.pnl-chart {
  display: block;
  min-height: 220px;
  width: 100%;
}

.pnl-zero-line {
  stroke: #cbd5e1;
  stroke-dasharray: 5 5;
}

.pnl-line {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.prediction-item,
.feature-row {
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.prediction-item:last-child,
.feature-row:last-child {
  border-bottom: 0;
}

.feature-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.feature-row strong {
  min-width: 0;
}

.feature-row span {
  color: var(--muted);
  text-align: right;
  overflow-wrap: anywhere;
}

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

.screener-list {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.screener-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--muted);
  background: #f9fbfd;
  font-size: 0.82rem;
}

.screener-chip.active {
  border-color: #1f7a4d;
  color: #155d3a;
  background: #eef8f2;
}

.btn {
  min-height: 38px;
}

.badge {
  font-weight: 700;
}

@media (max-width: 767.98px) {
  .dashboard-hero {
    align-items: stretch;
    flex-direction: column;
  }

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

  .dashboard-actions .btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .dashboard-actions .btn {
    border-radius: 8px !important;
  }

  .dashboard-actions .btn-danger {
    grid-column: 1 / -1;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .bar-detail {
    grid-column: auto;
    margin-top: 0;
  }

  .bar-row strong {
    text-align: left;
  }

  .trade-exit-button {
    justify-self: start;
    min-height: 44px;
  }

  .analytics-header,
  .analytics-bottom {
    flex-direction: column;
  }

  .analytics-header,
  .analytics-bottom {
    padding-left: 18px;
    padding-right: 18px;
  }

  .analytics-periods,
  .analytics-bundle {
    min-width: 0;
    width: 100%;
  }

  .line-chart {
    min-height: 560px;
  }

  .feature-row {
    display: grid;
  }

  .feature-row span {
    text-align: left;
  }
}
