/* ==========================================================================
   Trading dashboard
   --------------------------------------------------------------------------
   Layered on theme.css, which already supplies cards, buttons, forms, tables,
   pills and the stat grid. Only what is specific to reading a chart and a
   verdict lives here.

   The working surface is denser and quieter than the marketing page: no drifting
   light, no reveal animations, nothing that moves while a number is being read.
   ========================================================================== */

.icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ==========================================================================
   Header
   ========================================================================== */

header {
  position: sticky; top: 0;
  z-index: var(--z-header);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 13px 24px;
  background: rgba(5, 7, 13, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
header h1 { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; }
.tagline {
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-3);
}

.header-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.price-block { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.price {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 20px; font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--gold-bright);
  line-height: 1.1;
}

.paused-pill { background: var(--sell-wash); border-color: rgba(239, 68, 68, 0.3); color: var(--sell); }
.pill.ok { background: var(--buy-wash); border-color: rgba(34, 197, 94, 0.3); color: var(--buy); }
.pill.warn { background: var(--warn-wash); border-color: rgba(245, 158, 11, 0.3); color: var(--warn); }
.icon-btn.on { color: var(--gold); background: var(--gold-wash); }

/* ==========================================================================
   Shell
   ========================================================================== */

.tabs {
  position: relative; z-index: var(--z-base);
  max-width: 1440px;
  margin: 18px auto 0;
  width: calc(100% - 48px);
}

main {
  position: relative; z-index: var(--z-base);
  display: grid;
  gap: 16px;
  padding: 16px 24px 8px;
  max-width: 1440px;
  margin-inline: auto;
  /* History sits under the chart rather than spanning the full width: the
     sidebar is much taller than the chart, and a full-width history row leaves
     a large dead gap beside it. */
  grid-template-columns: minmax(0, 1fr) 348px;
  grid-template-areas: "chart side" "history side";
  align-items: start;   /* the chart card must not stretch to the sidebar's height */
}
.chart-card { grid-area: chart; }
.side-col { grid-area: side; display: flex; flex-direction: column; gap: 16px; }
.history-card { grid-area: history; }

/* The report and backtest views are single-column: they have no sidebar. */
#view-backtest, #view-report {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: none;
}

/* ==========================================================================
   Chart
   ========================================================================== */

#chart { height: 520px; width: 100%; }

/* ==========================================================================
   Signal card
   ========================================================================== */

.signal-card { position: relative; overflow: hidden; }

/* A hairline that takes the verdict's colour, so direction is legible from the
   edge of vision without reading the word. */
.signal-card::before {
  content: "";
  position: absolute; inset: 0 0 auto;
  height: 2px;
  background: var(--wait);
  opacity: 0.7;
  transition: background var(--t);
}
.signal-card:has(.signal-side.buy)::before { background: var(--buy); }
.signal-card:has(.signal-side.sell)::before { background: var(--sell); }

.signal-side {
  font-family: var(--mono);
  font-size: 34px; font-weight: 600;
  letter-spacing: 0.09em;
  text-align: center;
  padding: 12px 0 14px;
  color: var(--wait);
}
.signal-side.buy { color: var(--buy); text-shadow: 0 0 28px rgba(34, 197, 94, 0.38); }
.signal-side.sell { color: var(--sell); text-shadow: 0 0 28px rgba(239, 68, 68, 0.38); }

.signal-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.signal-grid > div {
  display: flex; flex-direction: column; gap: 4px;
  padding: 11px 13px;
  background: var(--surface);
}
.signal-grid .mono { font-size: 15px; font-weight: 500; }
.signal-grid small { font-size: 9px; letter-spacing: 0.06em; opacity: 0.8; }

.tp { color: var(--buy); }
.sl { color: var(--sell); }

.blocked-note {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 9px 12px;
  margin-bottom: 12px;
  border-radius: var(--r-sm);
  background: var(--warn-wash);
  border: 1px solid rgba(245, 158, 11, 0.28);
  color: #fcd34d;
  font-size: 12.5px;
  line-height: 1.5;
}

.htf-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.bias-chip {
  display: inline-flex; align-items: center;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-2);
}
.bias-chip.bull, .bias-chip.buy {
  background: var(--buy-wash); border-color: rgba(34, 197, 94, 0.32); color: var(--buy);
}
.bias-chip.bear, .bias-chip.sell {
  background: var(--sell-wash); border-color: rgba(239, 68, 68, 0.32); color: var(--sell);
}

/* --- reasons --------------------------------------------------------------
   Split by direction. A WAIT card listing bullish and bearish evidence in one
   undifferentiated row reads as self-contradictory, and a reader scanning it
   cannot tell which way the engine is leaning. */
.reason-groups { display: flex; flex-direction: column; gap: 12px; margin: 14px 0 4px; }
.reason-heading {
  display: block;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 7px;
}
.reason-heading.bull { color: var(--buy); }
.reason-heading.bear { color: var(--sell); }

.reasons { display: flex; flex-wrap: wrap; gap: 5px; }
.reasons span {
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--text-2);
}
#reasons-bull-group .reasons span {
  background: var(--buy-wash); border-color: rgba(34, 197, 94, 0.2); color: #a7f3c0;
}
#reasons-bear-group .reasons span {
  background: var(--sell-wash); border-color: rgba(239, 68, 68, 0.2); color: #fca5a5;
}

.signal-card .btn { width: 100%; margin-top: 14px; }

/* --- countdown ring -------------------------------------------------------
   The one piece of continuous motion on the page, and it is load-bearing: it
   says how long until the next verdict can exist at all. */
.countdown { position: relative; width: 42px; height: 42px; display: grid; place-items: center; }
.countdown svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface-3); stroke-width: 3; }
.ring {
  fill: none; stroke: var(--gold); stroke-width: 3; stroke-linecap: round;
  stroke-dasharray: 119.4; stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}
.countdown span {
  font-family: var(--mono);
  font-size: 9.5px; font-weight: 600;
  color: var(--gold-bright);
}

/* ==========================================================================
   Lot calculator
   ========================================================================== */

.calc { display: flex; flex-direction: column; gap: 12px; }
.calc label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-3);
}
.calc-out {
  padding: 11px 13px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
}
.calc-out .mono { font-size: 17px; font-weight: 600; color: var(--gold-bright); }

/* ==========================================================================
   Report view
   ========================================================================== */

.inline-form { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.result-box {
  padding: 11px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
}
.result-box.ok, .result-box.granted {
  background: var(--buy-wash); border-color: rgba(34, 197, 94, 0.28); color: #86efac;
}
.result-box.error {
  background: var(--sell-wash); border-color: rgba(239, 68, 68, 0.28); color: #fca5a5;
}
.result-box.warn {
  background: var(--warn-wash); border-color: rgba(245, 158, 11, 0.28); color: #fcd34d;
}

.report-body { font-size: 14px; line-height: 1.75; max-width: 78ch; }
.report-body h2, .report-body h3 {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--gold);
  margin: 26px 0 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.report-body h2:first-child, .report-body h3:first-child {
  margin-top: 0; padding-top: 0; border-top: none;
}
.report-body p { margin-bottom: 11px; color: var(--text-2); }
.report-body ul { margin: 0 0 13px; padding-left: 19px; }
.report-body li { margin-bottom: 6px; color: var(--text-2); }
.report-body strong { color: var(--text); font-weight: 600; }
.report-body em { color: var(--text-3); font-style: italic; }
.report-body code {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--gold-wash);
  color: var(--gold-bright);
}

/* ==========================================================================
   Backtest view
   ========================================================================== */

.bt-form { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.bt-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-3);
}
.bt-form label.check { flex-direction: row; align-items: center; text-transform: none; letter-spacing: 0; font-size: 13px; }
.bt-form select { min-width: 116px; }
.bt-form .btn { margin-left: auto; }

#bt-equity { margin-top: 18px; height: 240px; }

.caveats { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.caveat {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-2);
}
.warn-box {
  padding: 11px 14px;
  border-radius: var(--r-sm);
  background: var(--warn-wash);
  border: 1px solid rgba(245, 158, 11, 0.28);
  color: #fcd34d;
  font-size: 12.5px;
  line-height: 1.55;
}

/* Direction colouring for history and backtest rows. */
.side-buy { color: var(--buy); font-weight: 600; }
.side-sell { color: var(--sell); font-weight: 600; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--surface-3);
  color: var(--text-2);
}

/* ==========================================================================
   Admin modal (the small in-dashboard one)
   ========================================================================== */

.admin-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.admin-sub {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-3);
  margin: 22px 0 10px;
}
.admin-signals { display: flex; flex-direction: column; gap: 10px; }
.admin-signal {
  padding: 13px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.admin-signal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
  font-size: 13px;
}
.admin-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 11px; }
.admin-fields label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3);
}
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-error {
  margin-top: 14px;
  padding: 10px 13px;
  border-radius: var(--r-sm);
  background: var(--sell-wash);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 13px;
}
#admin-login { display: flex; flex-direction: column; gap: 12px; }
#admin-login .btn { width: 100%; }

.error { color: var(--sell); }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1100px) {
  main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "chart" "side" "history";
  }
  #chart { height: 420px; }
}

@media (max-width: 720px) {
  header { padding: 11px 16px; gap: 12px; }
  header .tagline { display: none; }
  .tabs { width: calc(100% - 32px); margin-top: 14px; }
  main { padding: 14px 16px 8px; }
  #chart { height: 340px; }
  .signal-grid { grid-template-columns: 1fr; }
  .admin-fields { grid-template-columns: 1fr; }
  .bt-form .btn { margin-left: 0; width: 100%; }
  .price { font-size: 17px; }
}


/* Instrument switch. Shares the timeframe switch's shape so the two read as
   one control group, but sits first because it scopes everything below it. */
.pair-switch {
  margin-right: auto;
}
.pair-switch button {
  font-weight: 600;
  letter-spacing: 0.02em;
}
