/* Ambiorix dashboard
 *
 * Built directly rather than on the Minia admin theme. The palette and
 * type match backtest_engine.metrics.card, so this page and a strategy
 * performance card read as one system.
 *
 * Sizing is deliberate: figures are large and high contrast, labels are
 * short, and the shape of the curve carries the story without having to
 * be read.
 */

:root {
  --bg: #0B0E13;
  --raised: #12161D;
  --line: #222834;
  --line-soft: #1A1F28;
  --text: #F2F5F8;
  --dim: #8D99A8;
  --dimmer: #5C6675;
  --accent: #9799ED;
  --wash: #5D60C4;
  --loss: #FF5C5C;

  /* Inter, for numerals that are plain rather than characterful. */
  --sans: "Inter", system-ui, -apple-system, "Helvetica Neue", sans-serif;

  --gutter: clamp(20px, 4vw, 56px);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* A soft purple bloom behind the top of the page, so the ground is not
 * a flat rectangle of black. */
body::before {
  content: "";
  position: fixed;
  inset: -20% 0 auto 0;
  height: 70vh;
  background: radial-gradient(60% 60% at 50% 0%, rgba(93, 96, 196, 0.16), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* A short page -- ownership is only a donut and three rows -- would
 * otherwise leave the footer stranded halfway up the window. The shell
 * fills the viewport and a flexible spacer before the footer takes up
 * whatever is left. */
.shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.spacer { flex: 1 0 auto; }

/* ---------------------------------------------------------------- header */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 28px 0 22px;
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
}

.brand img {
  height: 50px;
  width: auto;
  display: block;
  opacity: 0.9;
}

.brand-name {
  display: block;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1;
}

.brand-tag {
  display: block;
  margin-top: 8px;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--dim);
}

/* The original header carried the run length on the right, in words. */
.uptime {
  margin: 0;
  font-size: 15px;
  color: var(--dim);
  white-space: nowrap;
}

.uptime b {
  display: inline-block;
  margin: 0 3px;
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(151, 153, 237, 0.14);
  color: var(--accent);
  font-family: var(--sans);
  font-weight: 700;
  font-size: 13px;
}

/* ------------------------------------------------------------------ nav */

.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 14px 0 0; }

.tab {
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--dim);
}

.tab:hover { color: var(--text); background: var(--line-soft); }

.tab[aria-current="page"] {
  color: var(--text);
  background: var(--raised);
  box-shadow: inset 0 0 0 1px var(--line);
}

/* ----------------------------------------------------------------- hero */

/* Two headline figures side by side: what the account is worth, then
 * what it made. */
.hero {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(24px, 5vw, 64px);
  align-items: end;
  padding: clamp(40px, 6vw, 72px) 0 clamp(24px, 3vw, 36px);
}

.hero-foot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(24px, 5vw, 64px);
  align-items: start;
  padding-bottom: clamp(28px, 4vw, 44px);
}

.eyebrow {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0 0 14px;
}

.hero-figure {
  font-family: var(--sans);
  font-size: clamp(38px, 5.1vw, 66px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1;
  margin: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hero-note {
  margin: 0;
  font-size: 15px;
  color: var(--dim);
  max-width: 46ch;
}

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

.mini { border-left: 2px solid var(--line); padding-left: 18px; }

.mini-value {
  font-family: var(--sans);
  font-size: clamp(26px, 3.4vw, 38px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mini-label {
  margin-top: 8px;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

.delta {
  display: inline-block;
  margin-top: 12px;
  padding: 4px 9px;
  border-radius: 6px;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 700;
}

.delta.up { background: rgba(151, 153, 237, 0.14); color: var(--accent); }
.delta.down { background: rgba(255, 92, 92, 0.14); color: var(--loss); }
.delta.neutral { background: rgba(141, 153, 168, 0.14); color: var(--dim); }

/* ---------------------------------------------------------------- chart */

.panel {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: clamp(20px, 3vw, 32px);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.panel-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.panel-sub {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.plot { position: relative; padding-left: 58px; }

.plot svg { display: block; width: 100%; height: 300px; overflow: visible; }

.yaxis {
  position: absolute;
  left: 0;
  top: 0;
  height: 300px;
  width: 52px;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--dimmer);
  font-variant-numeric: tabular-nums;
}

.yaxis span {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  white-space: nowrap;
}

.xaxis {
  position: relative;
  height: 26px;
  margin-top: 10px;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--dimmer);
}

.xaxis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }

.readout {
  position: absolute;
  top: -8px;
  padding: 9px 13px;
  background: var(--bg);
  border: 1px solid var(--wash);
  border-radius: 9px;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--text);
  pointer-events: none;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 2;
}

.readout b { color: var(--accent); font-weight: 700; }

/* ---------------------------------------------------------------- stats */

.section-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: clamp(44px, 6vw, 72px) 0 22px;
}

.section-head h2 {
  margin: 0;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
}

.section-head .rule { flex: 1; height: 1px; background: var(--line-soft); }

/* Column counts are set explicitly rather than left to auto-fit. Auto-fit
 * chose five columns for a six-cell row, which stranded the last cell
 * beside a wide panel of empty background. Every count below divides both
 * row lengths evenly, so a row is always full. */
.grid {
  display: grid;
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  overflow: hidden;
}

.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 1080px) {
  .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* The extremes carry a dollar figure and a percentage side by side,
   * which will not fit half a phone screen. Give them the full width. */
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
}

.cell {
  background: var(--bg);
  padding: 24px 20px;
  min-height: 132px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Sized so the longest figure on the page, a balance in the thousands,
 * still fits one column of the six-across row without clipping. */
.cell-value {
  font-family: var(--sans);
  font-size: clamp(22px, 2.3vw, 32px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The date under a figure is a sibling, not a child. Nesting it inside
 * the value meant filling the value in wiped the date out. */
.cell-date {
  margin-top: 9px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--dimmer);
}

.cell-label {
  margin-top: 16px;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

.cell-label em {
  display: block;
  margin-top: 5px;
  font-style: normal;
  letter-spacing: 0.06em;
  color: var(--dimmer);
}

.up { color: var(--accent); }
.down { color: var(--loss); }

/* ----------------------------------------------------------- strategies */

.rows {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  overflow: hidden;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line-soft);
}

.row:last-child { border-bottom: none; }

.row.retired { opacity: 0.55; }

.row-name { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }

.row-sub {
  margin-top: 5px;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dimmer);
}

.row-figure {
  text-align: right;
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row-figure span {
  display: block;
  margin-top: 5px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dimmer);
}

.tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  vertical-align: middle;
}

.tag.live { background: rgba(151, 153, 237, 0.16); color: var(--accent); }
.tag.off { background: rgba(141, 153, 168, 0.14); color: var(--dim); }

@media (max-width: 720px) {
  .row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .row-figure:nth-child(4) { display: none; }
}

/* --------------------------------------------------------------- notice */

.notice {
  margin-top: clamp(32px, 4vw, 48px);
  padding: 26px 28px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--wash);
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(93, 96, 196, 0.10), transparent 60%);
}

.notice h3 { margin: 0 0 8px; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }

.notice p { margin: 0; color: var(--dim); font-size: 15px; max-width: 64ch; }

.notice.warn { border-left-color: var(--loss); background: linear-gradient(90deg, rgba(255, 92, 92, 0.09), transparent 60%); }

/* --------------------------------------------------------------- footer */

.footer {
  margin-top: clamp(56px, 8vw, 96px);
  padding: 28px 0 44px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--dimmer);
}

/* ----------------------------------------------------------- responsive */

@media (max-width: 860px) {
  .hero-foot { grid-template-columns: minmax(0, 1fr); gap: 28px; }
}

@media (max-width: 560px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 28px; align-items: start; }
}

@media (max-width: 520px) {
  .hero-side { grid-template-columns: minmax(0, 1fr); }
  .plot { padding-left: 46px; }
  .yaxis { width: 40px; }
}

/* ------------------------------------------------------ strategy cards */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 20px;
}

@media (max-width: 900px) {
  .cards { grid-template-columns: minmax(0, 1fr); }
}

.card {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 28px 22px;
}

.card.idle { opacity: 0.6; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.card-name { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }

.card-sub {
  margin: 10px 0 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.card-headline {
  margin: 22px 0 4px;
  font-size: clamp(34px, 4vw, 48px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.card-headline-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

/* The per-card curve. Short by design: it is a shape, not a document. */
.spark { margin: 20px 0 4px; height: 90px; }
.spark svg { display: block; width: 100%; height: 90px; overflow: visible; }

.card-empty {
  margin: 26px 0;
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  text-align: center;
  font-size: 14px;
  color: var(--dim);
}

/* All of a card's statistics on one row beneath its chart. */
/* Six statistics as three by two. Auto-fit chose five columns and left
 * the sixth stranded on a row of its own. */
.card-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.card-stat-value {
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.card-stat-label {
  margin-top: 5px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dimmer);
  line-height: 1.3;
}

/* ------------------------------------------- contribution bar chart */

/* A pie cannot show a loss, and most of these are losses, so
 * contribution is drawn as bars either side of a zero line: length is
 * magnitude, side is sign. */
.bars { display: grid; gap: 12px; }

.bar-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 100px;
  gap: 14px;
  align-items: center;
}

.bar-name { font-size: 14px; font-weight: 700; }

.bar-track {
  position: relative;
  height: 26px;
  background: var(--line-soft);
  border-radius: 5px;
  overflow: hidden;
}

.bar-zero {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--dimmer);
}

.bar-fill { position: absolute; top: 4px; bottom: 4px; border-radius: 3px; }
.bar-fill.up { background: var(--accent); }
.bar-fill.down { background: var(--loss); }

.bar-value {
  text-align: right;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 620px) {
  .bar-row { grid-template-columns: 70px minmax(0, 1fr) 84px; gap: 10px; }
}

/* ------------------------------------------------------------ trades */

.trade-row {
  display: grid;
  grid-template-columns: 150px 110px minmax(0, 1fr) 110px 110px;
  gap: 16px;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line-soft);
  font-variant-numeric: tabular-nums;
}

.trade-row:last-child { border-bottom: none; }

.trade-head {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  background: var(--raised);
}

.trade-when { font-size: 13px; color: var(--dim); }
.trade-who { font-size: 14px; font-weight: 700; }
.trade-what { font-size: 13px; color: var(--dim); }
.trade-figure { text-align: right; font-size: 14px; font-weight: 700; }

@media (max-width: 760px) {
  .trade-row { grid-template-columns: minmax(0, 1fr) 92px 92px; }
  .trade-row > :nth-child(3) { display: none; }
  .trade-row > :nth-child(2) { grid-row: 2; grid-column: 1; }
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
}

.pager button {
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--raised);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.pager button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pager button:disabled { opacity: 0.35; cursor: default; }

.pager-count { font-size: 13px; color: var(--dim); }

/* --------------------------------------------------------- ownership */

.owners {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: clamp(28px, 5vw, 64px);
  align-items: center;
}

@media (max-width: 760px) {
  .owners { grid-template-columns: minmax(0, 1fr); }
}

.donut { width: 100%; max-width: 320px; margin: 0 auto; }

.owner-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  padding: 18px 0;
  border-bottom: 1px solid var(--line-soft);
}

.owner-row:last-child { border-bottom: none; }

.swatch { width: 16px; height: 16px; border-radius: 4px; }

.owner-name { font-size: 16px; font-weight: 700; }

.owner-share {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.owner-value {
  min-width: 96px;
  text-align: right;
  font-size: 15px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

/* The span every card covers, stated once at the foot of the page rather
 * than repeated on each card. */
.range {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: clamp(32px, 4vw, 44px);
  padding: 20px;
  border-top: 1px solid var(--line-soft);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

.range-arrow { color: var(--accent); font-size: 18px; }
