/* --- Algo Vienna Shadow — dashboard styles --- */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: ui-monospace, "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  background: #0d1117;
  color: #c9d1d9;
  font-size: 14px;
  line-height: 1.4;
}

.hidden { display: none !important; }
.muted  { color: #8b949e; }
.err    { color: #f85149; padding: 0.4rem 0; }
.profit { color: #3fb950; }
.loss   { color: #f85149; }
.warn   { color: #d29922; }

/* Monitors tab styling */
.mon-badge {
  display: inline-block;
  background: #f85149; color: #fff;
  border-radius: 9px; padding: 1px 6px;
  font-size: 0.75em; margin-left: 4px;
}
.mon-action { background: #2d1f1f; }
.mon-msg { white-space: normal; max-width: 540px; }

/* Tier 3 readiness card */
.tier3-card {
  background: #161b22; border: 1px solid #30363d;
  border-radius: 6px; padding: 0.8rem 1rem; margin-bottom: 1rem;
}
.tier3-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.tier3-col ul { margin: 0.3rem 0; padding-left: 1.2rem; }
.tier3-col li { line-height: 1.4; }
.long   { color: #3fb950; }
.short  { color: #f85149; }
.running { color: #3fb950; font-weight: bold; }
.stopped { color: #f85149; font-weight: bold; }

code {
  background: #161b22;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.9em;
}

/* --- Login --- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d1117;
}
.login-card {
  background: #161b22;
  border: 1px solid #30363d;
  padding: 2rem;
  border-radius: 8px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.login-card h2 { margin: 0; }
.login-card form { display: flex; flex-direction: column; gap: 0.6rem; }
.login-card input,
input, select {
  background: #0d1117;
  color: #c9d1d9;
  border: 1px solid #30363d;
  padding: 6px 8px;
  border-radius: 4px;
  font-family: inherit;
}
button {
  background: #21262d;
  color: #c9d1d9;
  padding: 6px 14px;
  border: 1px solid #30363d;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}
button:hover:not(:disabled) { background: #30363d; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.danger { background: #4d1f23; border-color: #f85149; color: #f85149; }
button.danger:hover { background: #5a2429; }
.btn-link {
  background: none;
  border: none;
  color: #58a6ff;
  cursor: pointer;
  padding: 0;
}

/* --- Header --- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.2rem;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  gap: 1rem;
  flex-wrap: wrap;
}
header h1 { margin: 0; font-size: 1.15rem; flex: 1; }
.header-actions {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

/* --- Nav tabs --- */
nav {
  display: flex;
  gap: 4px;
  padding: 0.6rem 1rem 0;
  background: #0d1117;
  border-bottom: 1px solid #30363d;
}
button.tab {
  border-radius: 4px 4px 0 0;
  border-bottom: none;
}
button.tab.active {
  background: #0d1117;
  color: #58a6ff;
  border-bottom: 2px solid #58a6ff;
}

/* --- Main content --- */
main { padding: 1rem; }

/* --- Strategy cards --- */
.strat-card {
  border: 1px solid #30363d;
  border-left-width: 4px;
  padding: 1rem;
  margin: 0.6rem 0;
  border-radius: 6px;
  background: #0d1117;
}
.strat-C1 { border-left-color: #3fb950; }
.strat-C2 { border-left-color: #58a6ff; }
.strat-C3 { border-left-color: #ffa657; }
.strat-C4 { border-left-color: #fdcb6e; }   /* gold — Tier2 5m market-broad */
.strat-C5 { border-left-color: #00b894; }   /* emerald — Tier2 5m market-magnitude */
.strat-C6 { border-left-color: #e84393; }   /* hot pink — Tier2 5m market-concentrated */
.strat-C7 { border-left-color: #d2a8ff; }   /* lavender — v6 SMC max-Sharpe */
.strat-C8 { border-left-color: #f778ba; }   /* pink — v6 SMC max-return */
.strat-C9 { border-left-color: #ff7b72; }   /* red — v6 SMC aggressive */
.strat-C10 { border-left-color: #79c0ff; }  /* sky-blue — Tier1 aggr OI+xsect */
.strat-C11 { border-left-color: #56d4dd; }  /* cyan — Tier1 aggr LSR+funding */
.strat-C12 { border-left-color: #7ee787; }  /* mint — Tier1 aggr all-gates */
.strat-C13 { border-left-color: #f0883e; }  /* amber — Tier1 tight OI+xsect */
.strat-C14 { border-left-color: #ffdfb6; }  /* peach — Tier1 tight LSR+funding */
.strat-C15 { border-left-color: #c9d1d9; }  /* slate — Tier1 tight all-gates */
.strat-C16 { border-left-color: #a371f7; }  /* purple — Tier2 meta-broad */
.strat-C17 { border-left-color: #5dd5fb; }  /* aqua — Tier2 meta+magnitude */
.strat-C18 { border-left-color: #ff66b8; }  /* magenta — Tier2 concentrated */
.strat-C19 { border-left-color: #b388eb; }  /* lilac — Tier2 5m broad */
.strat-C20 { border-left-color: #38d9a9; }  /* teal — Tier2 5m magnitude */
.strat-C21 { border-left-color: #ff8b3d; }  /* orange — Tier2 5m concentrated */
.strat-C22 { border-left-color: #b3e5fc; }  /* sky-blue — Tier2 15m broad */
.strat-C23 { border-left-color: #80deea; }  /* aqua-teal — Tier2 15m magnitude */
.strat-C24 { border-left-color: #ffb74d; }  /* warm-amber — Tier2 15m concentrated */
.strat-S1 { border-left-color: #ffd60a; }   /* gold-yellow — funding carry / mean-reversion */
.strat-S2 { border-left-color: #6e5cff; }   /* indigo — cross-sectional momentum */
.strat-S3 { border-left-color: #22d3ee; }   /* cyan — volume-profile bounce */
.strat-S4 { border-left-color: #f43f5e; }   /* rose-red — D3c smart-vs-dumb divergence */

.strat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
  cursor: pointer;
  user-select: none;
}
.strat-head:hover { opacity: 0.85; }
.strat-head h3 { margin: 0; font-size: 1rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.caret { display: inline-block; width: 14px; color: #8b949e; font-size: 0.8em; }
.strat-inline-stats { font-size: 0.85em; color: #c9d1d9; margin-left: 0.5rem; }
.strat-inline-stats .muted { font-size: 0.92em; }
/* Collapsed strategy card: leaderboard-row density (5px vertical padding, 13px font) */
.strat-card.collapsed { padding: 5px 10px; margin: 3px 0; border-radius: 4px; }
.strat-card.collapsed .strat-body { display: none; }
.strat-card.collapsed .strat-head { margin-bottom: 0; }
.strat-card.collapsed .strat-head h3 { font-size: 13px; gap: 0.4rem; }
.strat-card.collapsed .strat-inline-stats { font-size: 12px; }
.strat-card.collapsed .strat-badge { font-size: 0.78em; padding: 1px 6px; }

.strat-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: bold;
  color: #0d1117;
  font-size: 0.85em;
}
.strat-badge-C1 { background: #3fb950; }
.strat-badge-C2 { background: #58a6ff; }
.strat-badge-C3 { background: #ffa657; }
.strat-badge-C4 { background: #fdcb6e; color: #0d1117; }
.strat-badge-C5 { background: #00b894; }
.strat-badge-C6 { background: #e84393; }
.strat-badge-C7 { background: #d2a8ff; }
.strat-badge-C8 { background: #f778ba; }
.strat-badge-C9 { background: #ff7b72; }
.strat-badge-C10 { background: #79c0ff; }
.strat-badge-C11 { background: #56d4dd; }
.strat-badge-C12 { background: #7ee787; }
.strat-badge-C13 { background: #f0883e; }
.strat-badge-C14 { background: #ffdfb6; color: #0d1117; }
.strat-badge-C15 { background: #c9d1d9; color: #0d1117; }
.strat-badge-C16 { background: #a371f7; }
.strat-badge-C17 { background: #5dd5fb; color: #0d1117; }
.strat-badge-C18 { background: #ff66b8; }
.strat-badge-C19 { background: #b388eb; }
.strat-badge-C20 { background: #38d9a9; color: #0d1117; }
.strat-badge-C21 { background: #ff8b3d; }
.strat-badge-C22 { background: #b3e5fc; color: #0d1117; }
.strat-badge-C23 { background: #80deea; color: #0d1117; }
.strat-badge-C24 { background: #ffb74d; color: #0d1117; }
.strat-badge-S1 { background: #ffd60a; color: #0d1117; }
.strat-badge-S2 { background: #6e5cff; }
.strat-badge-S3 { background: #22d3ee; color: #0d1117; }
.strat-badge-S4 { background: #f43f5e; }

/* tinted row backgrounds */
.strat-row-C1 td:first-child { border-left: 3px solid #3fb950; }
.strat-row-C2 td:first-child { border-left: 3px solid #58a6ff; }
.strat-row-C3 td:first-child { border-left: 3px solid #ffa657; }
.strat-row-C4 td:first-child { border-left: 3px solid #fdcb6e; }
.strat-row-C5 td:first-child { border-left: 3px solid #00b894; }
.strat-row-C6 td:first-child { border-left: 3px solid #e84393; }
.strat-row-C7 td:first-child { border-left: 3px solid #d2a8ff; }
.strat-row-C8 td:first-child { border-left: 3px solid #f778ba; }
.strat-row-C9 td:first-child { border-left: 3px solid #ff7b72; }
.strat-row-C10 td:first-child { border-left: 3px solid #79c0ff; }
.strat-row-C11 td:first-child { border-left: 3px solid #56d4dd; }
.strat-row-C12 td:first-child { border-left: 3px solid #7ee787; }
.strat-row-C13 td:first-child { border-left: 3px solid #f0883e; }
.strat-row-C14 td:first-child { border-left: 3px solid #ffdfb6; }
.strat-row-C15 td:first-child { border-left: 3px solid #c9d1d9; }
.strat-row-C16 td:first-child { border-left: 3px solid #a371f7; }
.strat-row-C17 td:first-child { border-left: 3px solid #5dd5fb; }
.strat-row-C18 td:first-child { border-left: 3px solid #ff66b8; }
.strat-row-C19 td:first-child { border-left: 3px solid #b388eb; }
.strat-row-C20 td:first-child { border-left: 3px solid #38d9a9; }
.strat-row-C21 td:first-child { border-left: 3px solid #ff8b3d; }
.strat-row-C22 td:first-child { border-left: 3px solid #b3e5fc; }
.strat-row-C23 td:first-child { border-left: 3px solid #80deea; }
.strat-row-C24 td:first-child { border-left: 3px solid #ffb74d; }
.strat-row-S1 td:first-child { border-left: 3px solid #ffd60a; }
.strat-row-S2 td:first-child { border-left: 3px solid #6e5cff; }
.strat-row-S3 td:first-child { border-left: 3px solid #22d3ee; }
.strat-row-S4 td:first-child { border-left: 3px solid #f43f5e; }

.strat-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.4rem 1.2rem;
  margin-bottom: 0.7rem;
  padding: 0.6rem 0;
  border-top: 1px solid #21262d;
  border-bottom: 1px solid #21262d;
}
.strat-stats > div { white-space: nowrap; }

.positions-table { margin-top: 0.5rem; }

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  border-bottom: 1px solid #21262d;
  padding: 5px 8px;
  text-align: left;
  white-space: nowrap;
}
th {
  background: #161b22;
  color: #8b949e;
  font-weight: normal;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
}
tbody tr:hover { background: #161b22; }

/* --- Filter form --- */
.filter-form {
  background: #161b22;
  border: 1px solid #30363d;
  padding: 0.8rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}
.filter-row {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-row label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.filter-row input,
.filter-row select {
  width: 130px;
}

/* --- Control tab --- */
.control-card .control-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

/* --- Discrepancies summary --- */
.disc-summary {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  background: #161b22;
  border: 1px solid #30363d;
  padding: 0.8rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

/* --- Pending limit orders (under each strategy card) --- */
.pending-orders { margin-top: 0.5rem; }
.pending-header {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0.4rem 0 0.2rem;
}
.pending-table { width: 100%; font-size: 0.83rem; border-collapse: collapse; }
.pending-table th,
.pending-table td {
  padding: 0.18rem 0.4rem;
  border-bottom: 1px dashed #30363d;
  text-align: left;
}
.pending-table th { color: #8b949e; font-weight: 500; }

/* --- Misc --- */
h2 { margin-top: 0.5rem; font-size: 1.1rem; }
h3 { margin-top: 1.5rem; font-size: 0.95rem; color: #8b949e; }
#action-log { margin-top: 0.4rem; }

/* CoinMarketCap-style subscript for sub-$0.0001 prices in table cells.
   Smaller and shifted down without disturbing line height. */
td sub, .strat-card sub, .positions-table sub {
  font-size: 0.72em;
  vertical-align: baseline;
  position: relative;
  bottom: -0.25em;
  color: #8b949e;
  font-weight: normal;
  margin: 0 0.5px;
}

/* --- Leaderboard PnL graph --- */
#leaderboard-pnl-card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 0.8rem 1rem 0.6rem;
  margin-top: 1.2rem;
}
.pnl-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}
.pnl-card-head h3 {
  margin: 0;
  font-size: 0.95rem;
  color: #c9d1d9;
}
.pnl-range-selector {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.pnl-range-selector button {
  background: #0d1117;
  border: 1px solid #30363d;
  color: #8b949e;
  padding: 3px 10px;
  font-size: 12px;
  border-radius: 3px;
  cursor: pointer;
}
.pnl-range-selector button:hover { background: #21262d; color: #c9d1d9; }
.pnl-range-selector button.active {
  background: #1f6feb;
  border-color: #1f6feb;
  color: #fff;
}
#pnl-chart {
  width: 100%;
  min-height: 320px;
  position: relative;
}
#pnl-chart svg { display: block; width: 100%; height: 320px; }
#pnl-chart .pnl-axis { stroke: #30363d; stroke-width: 1; }
#pnl-chart .pnl-grid { stroke: #21262d; stroke-width: 1; stroke-dasharray: 2,3; }
#pnl-chart .pnl-axis-label { fill: #8b949e; font-size: 10px; }
#pnl-chart .pnl-zero { stroke: #484f58; stroke-width: 1; stroke-dasharray: 4,4; }
#pnl-chart .pnl-line { fill: none; stroke-width: 1.4; }
#pnl-chart .pnl-line.faded { opacity: 0.18; }
#pnl-chart .pnl-line.highlight { stroke-width: 2.4; opacity: 1; }
#pnl-chart .pnl-cursor {
  stroke: #58a6ff;
  stroke-width: 1;
  stroke-dasharray: 3,3;
  pointer-events: none;
  opacity: 0.7;
}
#pnl-chart .pnl-empty {
  color: #8b949e;
  font-size: 13px;
  padding: 1.5rem;
  text-align: center;
}
.pnl-tooltip {
  position: absolute;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  color: #c9d1d9;
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.pnl-tooltip .pnl-tt-row { display: flex; gap: 0.4rem; align-items: center; }
.pnl-tooltip .pnl-tt-swatch {
  display: inline-block; width: 8px; height: 8px; border-radius: 1px;
}
.pnl-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
  font-size: 11px;
}
.pnl-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
}
.pnl-legend-item:hover { border-color: #30363d; }
.pnl-legend-item.dim { opacity: 0.35; }
.pnl-legend-item.selected { border-color: #58a6ff; background: #0d1117; }
.pnl-legend-clear {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
  background: #21262d;
  color: #c9d1d9;
  font-size: 11px;
  border: 1px solid #30363d;
}
.pnl-legend-clear:hover { background: #30363d; }
.pnl-legend-item .pnl-legend-swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
}
.pnl-legend-item .pnl-legend-pnl { color: #8b949e; }
.pnl-legend-item .pnl-legend-pnl.profit { color: #3fb950; }
.pnl-legend-item .pnl-legend-pnl.loss { color: #f85149; }
