/* AGITQ 161-MA backtest — mobile-first styles.
 * Sections below, in order: design tokens (:root), base/reset, header,
 * cards + controls form, buttons/status, tables, charts, monthly grid,
 * footer, and a wider-screen (>=620px) responsive override at the end. */

/* Design tokens: colours, corner radius — change here to re-theme the app. */
:root {
  --bg: #0b0f17;
  --card: #131a26;
  --card2: #0f1620;
  --ink: #e6edf3;
  --muted: #8b98a9;
  --line: #223044;
  --accent: #4c8dff;
  --good: #3fb950;
  --bad: #f85149;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h1, h2 { margin: 0 0 .3em; line-height: 1.2; }
h2 { font-size: 1.1rem; }
.sub { color: var(--muted); font-weight: 400; font-size: .85rem; }

.topbar { padding: 20px 16px 8px; }
.topbar h1 { font-size: 1.35rem; }
.topbar h1 span { color: var(--accent); }
.tagline { color: var(--muted); margin: 0; font-size: .9rem; }

/* Cross-link back to the daily-signal page — reuses --accent, tappable on mobile. */
.crosslink { margin: 10px 0 0; }
.crosslink a {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 600;
  padding: 6px 0;              /* adequate vertical tap target */
}
.crosslink a:hover { text-decoration: underline; }

main { padding: 12px 16px 24px; max-width: 960px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

/* Controls: single column on mobile, wraps to rows on wider screens. */
.row { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: .82rem; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em;
}
label.check {
  flex-direction: row; align-items: center; gap: 10px;
  text-transform: none; letter-spacing: 0; font-size: .95rem;
}
input, select {
  background: var(--card2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 10px;
  padding: 12px;               /* large tap target */
  font-size: 16px;             /* prevents iOS zoom-on-focus */
  width: 100%;
}
input[type="checkbox"] { width: 22px; height: 22px; padding: 0; accent-color: var(--accent); }
select[multiple] { padding: 4px; }

.advanced { margin: 4px 0 12px; }
.advanced summary {
  cursor: pointer; color: var(--accent); font-weight: 600;
  padding: 8px 0; font-size: .9rem;
}

.run {
  width: 100%; padding: 15px; font-size: 1.05rem; font-weight: 700;
  color: #fff; background: var(--accent); border: 0; border-radius: 12px;
  cursor: pointer; margin-top: 4px;
}
.run:disabled { opacity: .5; cursor: default; }
.run:not(:disabled):active { transform: translateY(1px); }

.status { color: var(--muted); font-size: .85rem; margin: 10px 0 0; min-height: 1.2em; }
.status.error { color: var(--bad); }
.meta { color: var(--muted); font-size: .82rem; margin: 0 0 12px; }

/* Tables scroll horizontally on small screens instead of squishing. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
table { border-collapse: collapse; width: 100%; font-size: .85rem; white-space: nowrap; }
th, td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--card); }
thead th { color: var(--muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; }
tbody tr.strategy td:first-child { color: var(--accent); font-weight: 700; }
td.pos { color: var(--good); }
td.neg { color: var(--bad); }

.chart-wrap { position: relative; height: 300px; width: 100%; }

.monthly table { font-size: .78rem; }
.monthly td.foot, .monthly th.foot { border-top: 2px solid var(--line); font-weight: 700; }

footer { padding: 8px 16px 28px; max-width: 960px; margin: 0 auto; }
footer p { color: var(--muted); font-size: .74rem; margin: 0; }

.hidden { display: none !important; }

/* Wider screens: lay control rows out horizontally, taller charts. */
@media (min-width: 620px) {
  .row { flex-direction: row; flex-wrap: wrap; }
  .row > label { flex: 1 1 160px; }
  .row > label.check { flex: 0 0 auto; align-self: end; padding-bottom: 12px; }
  .chart-wrap { height: 380px; }
  .topbar h1 { font-size: 1.7rem; }
}
