/* Reusable pieces: buttons, badges, cards, KPI tiles, segmented controls, tables, tags and hover cards. */

/* motion: main calls to action lift a little under a fine pointer */
.lift { transition: transform 200ms var(--ease-out), box-shadow 200ms ease; }
@media (hover: hover) and (pointer: fine) { .lift:hover { transform: translateY(-1px); } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(242,242,239,.35); }
  70% { box-shadow: 0 0 0 8px rgba(242,242,239,0); }
  100% { box-shadow: 0 0 0 0 rgba(242,242,239,0); }
}
.pulse { animation: pulse 2s infinite; }
@media (prefers-reduced-motion: reduce) {
  .pulse { animation: none; }
  .lift, .lift:hover { transition: none; transform: none; }
}

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.005em;
  border-radius: var(--radius-btn);
  border: 0;
  white-space: nowrap;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--edge), 0 1px 2px rgba(17,17,19,.05);
}
.btn:hover { color: var(--ink); background: var(--paper-hi); }
.btn-ink {
  background: var(--ink);
  color: var(--on-ink);
  box-shadow: 0 1px 2px rgba(17,17,19,.2), 0 6px 16px -8px rgba(17,17,19,.45);
}
.btn-ink:hover { color: var(--on-ink); background: var(--ink-2); }
.btn-light { background: var(--night-fg); color: var(--night); box-shadow: 0 6px 18px -10px rgba(0,0,0,.8); }
.btn-light:hover { color: var(--night); background: #FFFFFF; }
.btn-lg { padding: 14px 22px; font-size: 15px; border-radius: 12px; }
.btn-lg.btn-ink { box-shadow: 0 1px 2px rgba(17,17,19,.2), 0 10px 26px -12px rgba(17,17,19,.5); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-quiet { background: transparent; box-shadow: none; }
.btn-quiet:hover { background: var(--hover); }
.btn-danger { background: var(--loss); color: #FFFFFF; box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--loss) 50%, transparent); }
.btn-danger:hover { color: #FFFFFF; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-btn);
  background: var(--card);
  box-shadow: var(--edge), 0 1px 2px rgba(17,17,19,.05);
}
.icon-btn:hover { background: var(--paper-hi); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.link-btn { border: 0; background: none; padding: 4px 6px; font-weight: 600; font-size: 13px; border-radius: 4px; }
.link-btn:hover { background: var(--hover); }
.link-btn.danger { color: var(--loss); }
.sidebar .btn-light { width: 100%; }
/* Fingers need room: on a touch screen every control is at least 40px to press, without changing how it looks.
   Links inside a line get the room as padding that does not move the text around them. */
@media (pointer: coarse) {
  .icon-btn, .icon-btn.quiet { min-width: 40px; min-height: 40px; }
  .link-btn, .btn-sm, .tool-select { min-height: 40px; }
  .link-btn { display: inline-flex; align-items: center; }
  .strategy-link, a.eyebrow { padding-block: 11px; margin-block: -11px; }
}

/* badge with live dot */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  box-shadow: var(--shadow-chip);
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); }
.badge.offline .dot { animation: none; }

/* cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--edge), var(--shadow-card);
  min-width: 0;
}
.night {
  background: var(--grad-night-card);
  color: var(--night-fg);
  box-shadow: inset 0 0 0 1px rgba(244,244,245,.06), var(--shadow-night);
}
.night .eyebrow, .night .muted { color: var(--night-muted); }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}
.card-head h3 { font-size: 15px; letter-spacing: -0.01em; }
.card-note { font-size: 12px; color: var(--muted); margin: 14px 0 0; }
@media (max-width: 640px) { .card { padding: 20px; } }

/* KPI tiles */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
  gap: 16px;
}
.kpi {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: grid;
  gap: 6px;
  align-content: start;
  box-shadow: var(--edge), var(--shadow-chip);
  min-width: 0;
}
.kpi .value { font-variant-numeric: tabular-nums; font-size: 26px; font-weight: 700; letter-spacing: -0.03em; }
.kpi .sub { font-size: 12px; color: var(--muted); }
/* The lead tile is a wide Paper card with the big number, as in the Margin mockups: P&L colours only read well on paper. */
.kpi.lead-kpi { grid-column: span 2; box-shadow: var(--shadow-card); }
.kpi.lead-kpi .value { font-size: 44px; font-weight: 800; letter-spacing: -0.04em; line-height: 1.05; }
@media (max-width: 460px) { .kpi.lead-kpi { grid-column: auto; } .kpi.lead-kpi .value { font-size: 32px; } }
/* Performance: six headline widgets that always fill whole rows. */
.kpis.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis.six .kpi.lead-kpi { grid-column: auto; }
.kpis.six .kpi.lead-kpi .value { font-size: clamp(28px, 3vw, 40px); }
.kpis.six .gauge { width: 100%; max-width: 150px; height: auto; }
@media (min-width: 1360px) { .kpis.six { grid-template-columns: minmax(0, 1.5fr) repeat(5, minmax(0, 1fr)); } }
@media (max-width: 760px) { .kpis.six { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 400px) { .kpis.six { grid-template-columns: minmax(0, 1fr); } }
/* semicircle win-rate gauge (js/gauge.js) */
.gauge { display: block; max-width: 100%; overflow: visible; }
.gauge .track, .gauge .fill { fill: none; stroke-width: 10; stroke-linecap: round; }
.gauge .track { stroke: color-mix(in srgb, var(--ink) 8%, transparent); }
/* the arc deepens from its start to its end; the knob sits on the end with a ring of the card around it */
.gauge .g-from { stop-color: color-mix(in srgb, var(--ink) 70%, var(--card)); }
.gauge .g-to { stop-color: var(--ink); }
.gauge.low .g-from { stop-color: color-mix(in srgb, var(--loss) 70%, var(--card)); }
.gauge.low .g-to { stop-color: var(--loss); }
.gauge .knob { fill: var(--ink); stroke: var(--card); stroke-width: 2.5; }
.gauge.low .knob { fill: var(--loss); }
.gauge .reading { fill: var(--ink); font-family: var(--sans); font-size: 22px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
/* Dark: loss red lifted towards Paper so the arc reads on a dark card */
:root[data-theme="dark"] .gauge.low .g-to { stop-color: color-mix(in srgb, #B91C1C 78%, #F4F4F5); }
:root[data-theme="dark"] .gauge.low .knob { fill: color-mix(in srgb, #B91C1C 78%, #F4F4F5); }
/* a gauge tile: the gauge and its W / BE / L line centred under the tile's title */
.kpi .gauge { margin: 2px auto 0; }

/* segmented control: a soft track with the chosen segment raised on it */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
}
.segmented button {
  position: relative;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] { color: var(--ink); background: var(--card); box-shadow: 0 1px 2px rgba(17,17,19,.08), 0 2px 8px -2px rgba(17,17,19,.14); }
.stepper { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stepper .label { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }

/* "Your stats": three columns of key/value lists */
.stat-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 0 36px; }
.stat-cols h4 { margin: 12px 0 2px; font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink); }
.stat-cols .facts div { padding: 9px 0; font-size: 14px; }

/* Margin score */
.score { display: grid; gap: 14px; justify-items: center; }
.score-total { display: grid; justify-items: center; gap: 2px; }
.score-total b { font-size: 44px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.score-total span { font-size: 12px; color: var(--muted); }
.score-bar { width: 100%; height: 8px; border-radius: 4px; background: var(--paper-lo); overflow: hidden; }
.score-bar i { display: block; height: 100%; background: var(--ink); border-radius: 4px; }
.score-weight { width: 100%; margin: 0; font-size: 12px; color: var(--muted); }
.score-how { width: 100%; font-size: 13px; }
.score-how summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.score-how .facts div { padding: 8px 0; align-items: start; }
.score-how dt { color: var(--ink); font-weight: 500; }
.score-how dt small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }

/* Avg win / loss bar in the KPI */
.split { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--paper-lo); }
.split .w { background: var(--gain); }
.split .l { background: var(--loss); }
.kpi .tally-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.kpi .tally-row span { white-space: nowrap; }
.kpi .tally-row b { font-weight: 600; color: var(--ink); }
.kpi .tally-row b.gain { color: var(--gain); }
.kpi .tally-row b.loss { color: var(--loss); }

/* Journal: statistics strip of the listed trades */
.journal-stats {
  display: grid;
  grid-template-columns: minmax(280px, 1.8fr) repeat(5, minmax(0, 1fr));
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-chip);
  overflow: hidden;
}
.journal-stats[hidden] { display: none; }
/* journal: trades with contracts still held */
.open-trades { display: grid; gap: 10px; margin-bottom: 20px; }
.open-trades[hidden] { display: none; }
.open-trades .card-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.open-trades .card-head h3 { margin: 0; }
.open-trades .card-head .muted { font-size: 13px; }
.open-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.open-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 16px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--paper-hi); }
.open-figs { font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; text-align: right; }
.open-figs b { color: var(--ink); }
.open-figs .sub-line { display: block; }
@media (max-width: 640px) { .open-list li { grid-template-columns: minmax(0, 1fr) auto; } .open-figs { grid-column: 1 / -1; grid-row: 2; text-align: left; } }
.js-cell { display: grid; gap: 4px; align-content: start; padding: 16px 20px; border-left: 1px solid var(--line-soft); min-width: 0; }
.js-cell:first-child { border-left: 0; }
.js-cell .value { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.js-cell .sub { font-size: 12px; color: var(--muted); }
.js-lead { grid-template-columns: minmax(0, max-content) minmax(72px, 1fr); column-gap: 16px; align-items: end; }
.js-lead .eyebrow { grid-column: 1 / -1; }
.js-lead .value { font-size: 24px; }
.js-lead .spark { justify-self: end; min-width: 0; }
@media (max-width: 1180px) {
  .journal-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .js-cell { border-top: 1px solid var(--line-soft); }
  .js-cell:nth-child(-n+3) { border-top: 0; }
  .js-cell:nth-child(3n+1) { border-left: 0; }
}
@media (max-width: 640px) {
  .journal-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .js-lead { grid-column: 1 / -1; }
  .js-cell { border-left: 1px solid var(--line-soft); border-top: 1px solid var(--line-soft); }
  .js-cell:nth-child(2n) { border-left: 0; }
  .js-cell:first-child { border-top: 0; border-left: 0; }
}

/* Journal: Win / Loss / BE status pill (the rating is a grade pill, js/grades.js) */
.status {
  display: inline-block;
  min-width: 46px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--paper-lo);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
}
/* Outlined, so the P&L colour sits on the card itself and stays readable in every theme. */
.status.gain, .status.loss { background: var(--card); color: var(--gain); box-shadow: inset 0 0 0 1.5px currentColor; }
.status.loss { color: var(--loss); }
:root[data-theme="dark"] .status.gain { box-shadow: inset 0 0 0 1.5px #15803D; }
:root[data-theme="dark"] .status.loss { box-shadow: inset 0 0 0 1.5px #B91C1C; }

/* key/value list */
.facts { margin: 0; display: grid; }
.facts div { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.facts div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }


/* trading sessions, side by side */
.sessions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: 14px; }
.session {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  padding: 18px 14px 16px;
  border-radius: var(--radius);
  background: var(--paper-hi);
  text-align: center;
}
.session-name { display: grid; gap: 2px; min-width: 0; }
.session-name strong { font-size: 16px; letter-spacing: -0.01em; }
.session-name small { font-size: 12px; color: var(--muted); }
.session .gauge { margin: 6px 0 2px; }
.session .tally { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.session .pnl { font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; }

.night .segmented { background: rgba(244,244,245,.08); }
.night .segmented button { color: var(--night-muted); }
.night .segmented button:hover { color: var(--night-fg); }
.night .segmented button[aria-pressed="true"] { color: var(--night-fg); background: rgba(244,244,245,.16); box-shadow: none; }

/* tables */
.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table.wide { font-size: 13px; }
.table.wide th, .table.wide td { padding: 11px 10px; }
.table.wide th:first-child, .table.wide td:first-child { padding-left: 16px; }
.table.wide th:last-child, .table.wide td:last-child { padding-right: 16px; }
.table .nowrap { white-space: nowrap; }
.table.wide .side { margin-left: 4px; vertical-align: 1px; }
.strat-cell { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.notes-cell { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.table.wide .sub-line { display: block; font-size: 11px; color: var(--muted); }
.table.wide .col-date .sub-line { min-width: 110px; }
.table.wide .col-actions { width: 1%; }
.table.wide.no-rules th.col-rules, .table.wide.no-rules td.col-rules, .table.one-account .symbol small { display: none; }
.icon-btn.quiet { width: 30px; height: 30px; background: transparent; box-shadow: none; color: var(--ink-3); }
.icon-btn.quiet:hover { background: var(--paper-lo); color: var(--ink); }
.icon-btn.quiet.danger:hover { color: var(--loss); }

/* The journal fits its box: columns go as the table's own space narrows (not the window's), and on phone
   widths every trade becomes a small card with labels, so nothing scrolls sideways there. */
.table-wrap { container-type: inline-size; }
@container (max-width: 1180px) { .table.wide .col-tf { display: none; } }
@container (max-width: 1120px) { .table.wide .col-rating { display: none; } }
@container (max-width: 1050px) { .table.wide .col-size { display: none; } }
@container (max-width: 930px) { .table.wide .col-rules { display: none; } }
@container (max-width: 850px) {
  .table.wide, .table.wide tbody { display: block; }
  .table.wide thead { display: none; }
  .table.wide tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
  .table.wide tbody tr:last-child { border-bottom: 0; }
  .table.wide tbody tr:hover td { background: transparent; }
  .table.wide td { display: block; padding: 0 !important; border: 0; min-width: 0; text-align: left; }
  .table.wide td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
  .table.wide td.col-tf, .table.wide td.col-size, .table.wide td.col-rating, .table.wide td.col-rules { display: block; }
  .table.wide .col-actions { grid-column: 1 / -1; width: auto; }
  .table.wide .row-actions { justify-content: flex-start; }
  .table.wide .nowrap { white-space: normal; }
  .table.wide td { overflow-wrap: anywhere; }
  .table.wide td[colspan] { grid-column: 1 / -1; }
}
.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 16px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; font-variant-numeric: tabular-nums; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--paper-hi); }
.table .r { text-align: right; }
.table.compact th, .table.compact td { padding: 10px 6px; }
.table.compact th:first-child, .table.compact td:first-child { padding-left: 0; }
.table.compact th:last-child, .table.compact td:last-child { padding-right: 0; }
.table.compact tbody tr:hover td { background: transparent; }
/* Small tables inside cards fit their card: smaller type on narrow screens, and the optional columns (.opt) go. */
.table-fit { min-width: 0; }
.table-fit .table { table-layout: auto; }
.table-fit td, .table-fit th { overflow-wrap: anywhere; }
.table-fit .r { white-space: nowrap; }
@media (max-width: 560px) {
  .table-fit .table { font-size: 12px; }
  .table-fit .table th { font-size: 10px; letter-spacing: 0.06em; }
  .table-fit .opt { display: none; }
}
@media (max-width: 420px) { .table-fit .r { white-space: normal; overflow-wrap: anywhere; } }
.symbol { font-weight: 600; }
.symbol small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }

/* entries by timeframe: one row per timeframe, bar length = number of entries */
.frames { display: grid; gap: 2px; }
.frame {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 70px 72px 96px;
  gap: 14px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-variant-numeric: tabular-nums;
}
.frame:last-child { border-bottom: 0; }
.frame.head { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding-top: 0; }
.frame .bar { position: relative; height: 22px; border-radius: 5px; background: var(--paper-hi); overflow: hidden; }
.frame .bar i { position: absolute; inset: 0 auto 0 0; border-radius: 5px; background: var(--grad-ink); transform-origin: left; }
.frame .bar span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; font-weight: 600; color: var(--on-ink); mix-blend-mode: normal; }
.frame .bar span.out { color: var(--ink-2); }
.frame .r { text-align: right; }
@media (max-width: 640px) {
  .frame { grid-template-columns: 48px minmax(0, 1fr) 56px 80px; gap: 10px; }
  .frame .share { display: none; }
}

/* contract marks themselves: css/logos.css */
.with-logo { display: flex; align-items: center; gap: 10px; min-width: 0; }
.with-logo > span { min-width: 0; }
.with-logo > .select { flex: 1; }
.session-tag { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; }
.tf { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 4px; background: var(--paper-lo); color: var(--ink-2); }

/* long = white badge, short = black badge */
.side {
  display: inline-block;
  min-width: 56px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--ink);
}
/* fixed white and black in every theme; the border keeps each visible on a background of its own colour */
.side.long { background: #FFFFFF; color: #111113; border-color: #111113; }
.side.short { background: #111113; color: #FFFFFF; border-color: var(--line-strong); }

.result-mark { display: inline-block; width: 3px; height: 28px; border-radius: 2px; background: var(--line); vertical-align: middle; }
.result-mark.gain { background: var(--gain); }
.result-mark.loss { background: var(--loss); }
.note {
  display: block;
  max-width: 260px;
  border: 0;
  background: none;
  padding: 0;
  text-align: left;
  color: var(--ink-3);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
button.note:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.thumb { padding: 0; border: 0; background: var(--paper-lo); border-radius: 4px; overflow: hidden; width: 56px; height: 35px; cursor: zoom-in; position: relative; display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .count { position: absolute; right: 2px; bottom: 2px; background: var(--ink); color: var(--on-ink); font-size: 10px; padding: 0 4px; border-radius: 3px; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.row-actions [aria-expanded="true"] { background: var(--hover); color: var(--ink); }
/* a row's "⋯" menu: one for the whole table, placed by js/journal.js */
.row-menu {
  position: fixed;
  z-index: 40;
  width: 210px;
  padding: 6px;
  display: grid;
  gap: 2px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 24px 48px -16px rgba(0,0,0,.35);
}
.row-menu[hidden] { display: none; }
.row-menu > a, .row-menu > button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-btn);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.row-menu > a:hover, .row-menu > button:hover, .row-menu > a:focus-visible, .row-menu > button:focus-visible { background: var(--hover); color: var(--ink); outline: none; }
.row-menu svg { flex: none; color: var(--muted); }
.row-menu .danger:hover, .row-menu .danger:focus-visible { color: var(--ink); }
.row-menu-gap { height: 1px; margin: 4px 6px; background: var(--line-soft); }

/* tags and chips */
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--paper-lo);
  color: var(--ink-2);
  white-space: nowrap;
}
.tag button { border: 0; background: none; padding: 0 2px; line-height: 1; font-size: 14px; color: var(--muted); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 5px 5px 12px;
  border-radius: 99px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.chip button { border: 0; background: color-mix(in srgb, var(--on-ink) 16%, transparent); color: inherit; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }

/* journal toolbar */
.toolbar-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar-row .spacer { flex: 1; }
#journalSummary:not(:empty) { background: var(--card); color: var(--muted); padding: 8px 14px; border-radius: 999px; box-shadow: var(--shadow-chip); font-size: 14px; }
.filter-btn .count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 11px;
  display: inline-grid;
  place-items: center;
}

.empty { padding: 48px 20px; text-align: center; color: var(--muted); display: grid; gap: 14px; justify-items: center; }
.table-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }

.notice {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-chip);
  border-left: 3px solid var(--loss);
}
.notice[hidden] { display: none; }
/* An empty period is information, not an error. */
.notice.period-notice { border-left-color: var(--ink); }
.notice-actions { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.notice code { font-size: 13px; background: var(--paper-lo); padding: 1px 6px; border-radius: 4px; }

/* hover card: calendar days, chart bars and equity points. A Paper card, so P&L colours keep their contrast. */
.peek {
  position: fixed;
  z-index: 90;
  width: max-content;
  min-width: 220px;
  max-width: min(360px, calc(100vw - 24px));
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow-deep);
  pointer-events: none;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.peek-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; font-weight: 800; }
.peek-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.peek-rows { display: grid; margin-top: 10px; border-top: 1px solid var(--line-soft); }
.peek-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-soft);
}
.peek-row:last-child { border-bottom: 0; }
.peek-row .time { color: var(--muted); }
.peek-row .r, .peek-row .money { text-align: right; }
.peek .facts div { border-color: var(--line-soft); padding: 6px 0; }
.peek .facts dt { color: var(--muted); }
.wl { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; padding: 2px 7px; border-radius: 999px; text-transform: uppercase; }
.wl.win { background: var(--gain); color: #FFFFFF; }
.wl.loss { background: var(--loss); color: #FFFFFF; }
.wl.even { background: var(--paper-lo); color: var(--ink-2); }
.peek .side { min-width: 0; padding: 1px 6px; font-size: 9px; }

/* Setup grades A+–F (js/grades.js). Monochrome on purpose: green and red belong to P&L only. */
.grade {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.grade-ap, .grade-a { background: var(--ink); color: var(--card); }
.grade-b { background: var(--ink-3); color: var(--card); }
.grade-c { background: var(--paper-lo); color: var(--ink); }
.grade-d { color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.grade-f { color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink-3); background: repeating-linear-gradient(135deg, transparent 0 4px, var(--paper-lo) 4px 6px); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }
@container (max-width: 520px) { .table.wide tr { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (max-width: 300px) { .table.wide tr { grid-template-columns: minmax(0, 1fr); } }
