/* ==========================================================================
   Aura — Personal P&L dashboard
   Hand-written CSS adapted from the Figma reference (login 4:6, dashboard 4:38).
   Mobile-first; design tokens as custom properties.
   ========================================================================== */

/* --- Design tokens -------------------------------------------------------- */
:root {
  /* Surfaces */
  --bg:        #08090a;
  --surface:   #111417;
  --border:    #1e232a;
  --border-2:  #2a3138;

  /* Text */
  --text:      #ffffff;
  --muted:     #9099a8;

  /* Accents / semantics */
  --accent:    #0088ff;
  --up:        #00e676;
  --down:      #ff3860;

  /* Tints */
  --accent-tint: rgba(0, 136, 255, 0.08);
  --up-tint:     rgba(0, 230, 118, 0.10);
  --down-tint:   rgba(255, 56, 96, 0.10);

  /* Glassy control surfaces (keypad) */
  --key-bg:     rgba(255, 255, 255, 0.07);
  --key-border: rgba(255, 255, 255, 0.15);
  --key-hover:  rgba(255, 255, 255, 0.12);

  /* Type */
  --font-sans: 'Geist', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', 'Menlo', 'Consolas', monospace;

  /* Metrics */
  --sidebar-w: 240px;
  --radius:    10px;
  --radius-sm: 6px;
  --radius-pill: 999px;
}

/* --- Reset / base --------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p { margin: 0; }

a { color: inherit; text-decoration: none; }

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

svg, img { display: block; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Lock scroll while the mobile drawer is open. */
body.nav-open { overflow: hidden; }

/* --- Icon utility --------------------------------------------------------
   SVGs are recolored via mask so a single asset works in any color. The glyph
   takes the element's `color` (currentColor). Paths are relative to this file
   (assets/css/styles.css → assets/icons/*.svg).
   ------------------------------------------------------------------------- */
.icon {
  display: inline-block;
  flex: none;
  width: 16px;
  height: 16px;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
          mask: var(--icon) center / contain no-repeat;
}

.icon-terminal     { --icon: url(../icons/terminal.svg); }
.icon-activity     { --icon: url(../icons/activity.svg); }
.icon-trending-up  { --icon: url(../icons/trending-up.svg); }
.icon-chevron-down { --icon: url(../icons/chevron-down.svg); }
.icon-archive      { --icon: url(../icons/archive.svg); }
.icon-folder       { --icon: url(../icons/folder.svg); }
.icon-settings     { --icon: url(../icons/settings.svg); }
.icon-bar-chart-2  { --icon: url(../icons/bar-chart-2.svg); }
.icon-x            { --icon: url(../icons/x.svg); }
.icon-delete       { --icon: url(../icons/delete.svg); }

/* --- Tone helpers (shared) ----------------------------------------------- */
.is-up   { color: var(--up); }
.is-down { color: var(--down); }
.is-flat { color: var(--muted); }

/* --- Brand (login + sidebar) --------------------------------------------- */
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* The mark is a gradient SVG, so it ships as an <img> rather than going
   through the currentColor mask used by .icon. */
.brand__logo {
  display: block;
  width: 32px;
  height: 32px;
  flex: none;
}

.brand__name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.14em;
  color: var(--text);
}

/* Login shows the full lockup (mark + wordmark + subtitle) in place of the
   sidebar's mark + AURA pair. */
.brand-lockup {
  display: block;
  width: 168px;
  height: auto;
}

/* ==========================================================================
   LOGIN  (node 4:6)
   ========================================================================== */
.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

.login__inner {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.login__prompt {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--muted);
}

/* Keypad form: stacks dots → error → keypad → (no-JS fallback) */
.pinpad {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* PIN dot indicator */
.pin-dots {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.pin-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.pin-dot.is-filled {
  background: var(--text);
  border-color: var(--text);
  transform: scale(1.05);
}

.login__error {
  min-height: 1em;
  font-size: 12px;
  color: var(--down);
  text-align: center;
}

/* Keypad */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 20px;
  justify-content: center;
}

.key {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--key-border);
  background: var(--key-bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 24px;
  font-weight: 600;
  transition: background-color 0.12s ease, transform 0.06s ease;
}

.key:hover { background: var(--key-hover); }
.key:active { transform: scale(0.94); }

/* Action keys (clear / backspace) are icon-only. The old CANCEL / DELETE
   wordmarks kept a fixed 12px size while the circle shrank on narrow screens,
   so they overflowed and collided; a glyph scales with the key instead. */
.key--action {
  color: var(--muted);
}

.key--action .icon {
  width: 22px;
  height: 22px;
}

/* No-JS fallback: a plain input + submit (hidden when JS drives the keypad). */
.pinpad__fallback {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  width: 100%;
}

.pinpad__fallback input {
  width: 100%;
  padding: 12px 14px;
  text-align: center;
  letter-spacing: 0.4em;
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   DASHBOARD  (node 4:38)
   ========================================================================== */
.app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

/* --- Sidebar -------------------------------------------------------------- */
.sidebar {
  flex: none;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
}

.sidebar__brand { padding: 0 6px; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.nav__item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav__item.is-active {
  background: var(--accent-tint);
  color: var(--accent);
}

.nav__icon { width: 18px; height: 18px; }
.nav__label { flex: 1; }
.nav__chevron {
  width: 14px;
  height: 14px;
  opacity: 0.7;
  transition: transform 0.15s ease;
}

/* Expandable group (e.g. STRATEGIES) --------------------------------------- */
.nav__group {
  display: flex;
  flex-direction: column;
}

/* The group's parent is a <button> carrying .nav__item; strip the default
   button chrome so it lines up with the anchor items around it. */
.nav__toggle {
  width: 100%;
  border: 0;
  background: transparent;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.nav__toggle[disabled] {
  cursor: default;
  opacity: 0.5;
}

.nav__toggle[disabled]:hover {
  background: transparent;
  color: var(--muted);
}

.nav__group.is-expanded .nav__chevron { transform: rotate(180deg); }

/* Accordion reveal via the 0fr -> 1fr grid-rows technique (animates height
   without a fixed max-height); the inner wrapper clips the overflow. */
.nav__submenu {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.18s ease;
}

.nav__group.is-expanded .nav__submenu { grid-template-rows: 1fr; }

.nav__submenu-inner {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0;
}

.nav__subitem {
  display: block;
  padding: 9px 12px 9px 42px;   /* left aligns text under the parent label */
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.nav__subitem:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav__subitem.is-active {
  background: var(--accent-tint);
  color: var(--accent);
}

.nav__subitem--empty,
.nav__subitem--empty:hover {
  background: transparent;
  color: var(--muted);
  opacity: 0.6;
  cursor: default;
}

/* --- Main column ---------------------------------------------------------- */
.app__main {
  flex: 1;
  min-width: 0;               /* allow content to shrink instead of overflow */
  display: flex;
  flex-direction: column;
}

/* Topbar — pinned to the top of the viewport while the page scrolls. The
   background must stay opaque so content cannot show through underneath, and
   the z-index sits below the mobile drawer (50) and its scrim (40). */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar__menu {
  display: none;              /* shown only on mobile */
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  flex: none;
}

/* CSS hamburger glyph */
.hamburger,
.hamburger::before,
.hamburger::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.hamburger {
  position: relative;
}
.hamburger::before,
.hamburger::after {
  content: '';
  position: absolute;
  left: 0;
}
.hamburger::before { top: -6px; }
.hamburger::after  { top: 6px; }

.topbar__title {
  flex: 1;
  min-width: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

/* Status pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-pill);
}

.status-pill__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.5);
  animation: pulse 2s ease-out infinite;
}

.status-pill__text {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn--primary {
  padding: 12px 18px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
}
.btn--primary:hover { background: #1a94ff; }

.btn--ghost {
  padding: 8px 14px;
  background: transparent;
  border-color: var(--border-2);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
}
.btn--ghost:hover { color: var(--text); border-color: var(--muted); }

/* --- Content -------------------------------------------------------------- */
.content {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* KPI strip */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.kpi {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Reconciliation failure (e.g. FUNDS BALANCE != TOTAL INVESTED + TOTAL P&L). */
.kpi--alert {
  border-color: var(--down);
  background: var(--down-tint);
}

.kpi__label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.kpi__flag {
  padding: 2px 6px;
  border: 1px solid var(--down);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--down);
  width: fit-content;
}

.kpi__value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.kpi__meta {
  margin-left: 6px;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.kpi__change {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}
/* .kpi__change carries the tone class → colours the amount. */
.kpi__change-pct { color: var(--muted); }

/* Cards (chart + weekly) */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card__title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Chart */
.chart {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chart__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.chart__index {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.chart__viewport {
  display: grid;
  place-items: center;
  min-height: 260px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* Positioned box so the Chart.js canvas (maintainAspectRatio: false) can fill
   a fixed height rather than collapse. The canvas is sized by Chart.js. */
.chart__canvas-wrap {
  position: relative;
  width: 100%;
  height: 300px;
  padding: 8px;
}

.chart__canvas-wrap canvas {
  position: absolute;
  inset: 8px;
}

.chart__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px;
  text-align: center;
}

.chart__placeholder-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.chart__placeholder-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: rgba(144, 153, 168, 0.7);
}

/* Weekly P&L */
.weekly {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.weekly__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.weekly__total {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
}

.weekly__grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.day {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  /* tone class sets colour + background/border below */
}

.day.is-up {
  background: var(--up-tint);
  border-color: rgba(0, 230, 118, 0.35);
  color: var(--up);
}
.day.is-down {
  background: var(--down-tint);
  border-color: var(--down);
  color: var(--down);
}
.day.is-flat {
  background: var(--border);
  border-color: var(--border-2);
  color: var(--muted);
}

.day__name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.day__date {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
}
.day__amount {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
}

/* Data table (recent trades) */
.table-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.table-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.table-card__count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

/* Horizontal scroll on narrow viewports rather than squashing columns. */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--surface);
  border-bottom: 1px solid var(--border-2);
}

.table tbody td {
  padding: 11px 16px;
  white-space: nowrap;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover td {
  background: var(--bg);
}

/* Monospace, tabular columns. */
.table__date,
.table__time,
.table__num {
  font-family: var(--font-mono);
}

/* Numeric columns right-align and carry the tone class on P&L cells. */
.table__num {
  text-align: right;
  font-weight: 700;
}
th.table__num {
  text-align: right;
}

/* Free-text note truncates rather than stretching the row. */
.table__note {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}

.table__empty {
  padding: 24px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

/* Footer meta */
.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.meta__epoch {
  font-size: 12px;
  color: var(--muted);
}

.meta__updated {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}

.meta__pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.5);
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.5); }
  70%  { box-shadow: 0 0 0 6px rgba(0, 230, 118, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 230, 118, 0); }
}

/* --- Scrim (mobile drawer backdrop) -------------------------------------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.scrim.is-visible { opacity: 1; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

/* Tablet: KPI strip 2-up */
@media (max-width: 1023px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
}

/* Sidebar becomes an off-canvas drawer */
@media (max-width: 900px) {
  .topbar__menu { display: grid; }
  .status-pill { display: none; }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    width: min(80vw, var(--sidebar-w));
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 24px 0 48px rgba(0, 0, 0, 0.45);
  }
  .sidebar.is-open { transform: translateX(0); }
}

/* Keep the scrim off-screen on desktop even if left toggled open. */
@media (min-width: 901px) {
  .scrim { display: none !important; }
}

/* Phone: single-column KPIs, wrapping weekly grid, tighter chrome */
@media (max-width: 640px) {
  .content { padding: 16px; gap: 16px; }
  .topbar { padding: 14px 16px; }
  .topbar__title { font-size: 15px; letter-spacing: 0.04em; }

  .kpis { grid-template-columns: 1fr; }

  .weekly__grid {
    grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  }

  .meta { justify-content: flex-start; }
}

/* Small phones: compact keypad so the login fits without scrolling */
@media (max-width: 360px) {
  .keypad { grid-template-columns: repeat(3, 64px); gap: 16px; }
  .key { width: 64px; height: 64px; font-size: 22px; }
  .key--action .icon { width: 20px; height: 20px; }
}

/* ==========================================================================
   STRATEGY CALENDAR (12-month daily P&L heatmap)
   ========================================================================== */

.cal {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.cal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.cal__years {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cal__year-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.cal__year-link:hover {
  color: var(--text);
  border-color: var(--border-2);
}
.cal__year-link.is-current {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-tint);
}

/* 12 month cards, three across on desktop. */
.cal-year {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.cal-month {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.cal-month__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.cal-month__name {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}

.cal-month__total {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-grid__label {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  padding-bottom: 2px;
}

.cal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid transparent;
  overflow: hidden;
}

.cal-cell__num {
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1;
  color: var(--muted);
}

.cal-cell__val {
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1;
  font-weight: 600;
}

.cal-cell--profit {
  background: var(--up-tint);
  border-color: rgba(0, 230, 118, 0.25);
}
.cal-cell--profit .cal-cell__val { color: var(--up); }

.cal-cell--loss {
  background: var(--down-tint);
  border-color: rgba(255, 56, 96, 0.25);
}
.cal-cell--loss .cal-cell__val { color: var(--down); }

.cal-cell--carry .cal-cell__val { color: var(--muted); }

.cal-cell--neutral {
  background: var(--bg);
  opacity: 0.5;
}

.cal-cell--empty {
  background: transparent;
  border-color: transparent;
}

/* Today: accent ring with a soft pulse (distinct keyframe from .pulse). */
.cal-cell--today {
  border-color: var(--accent);
  box-shadow: 0 0 0 0 rgba(0, 136, 255, 0.5);
  animation: cal-today-pulse 2s ease-out infinite;
}
.cal-cell--today .cal-cell__num { color: var(--text); }

@keyframes cal-today-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(0, 136, 255, 0.5); }
  70%  { box-shadow: 0 0 0 5px rgba(0, 136, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 136, 255, 0); }
}

/* Tablet: two months across. */
@media (max-width: 900px) {
  .cal-year { grid-template-columns: repeat(2, 1fr); }
}

/* Phone: one month per row. */
@media (max-width: 640px) {
  .cal-year { grid-template-columns: 1fr; }
}

/* ============================================================
   Settings form
   ============================================================ */

/* Lead-in copy above the settings sections. */
.settings-intro {
  margin: 0 0 4px;
  max-width: 60ch;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.settings-intro code {
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--accent-tint);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* The form stacks titled section cards, then a sticky action bar. */
.form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* One titled group of fields (a `.card` variant). */
.settings-section {
  overflow: hidden;
}

.settings-section__head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.settings-section__desc {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.settings-section__body {
  padding: 20px;
}

/* Short fields sit two-up; wide fields span the full row. */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 20px;
}

.field--wide {
  grid-column: 1 / -1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

/* Boolean row: label/hint on the left, toggle on the right. */
.field--inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.field__text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field__label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field__input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field__input::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

.field__input:hover {
  border-color: var(--muted);
}

.field__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 136, 255, 0.22);
}

.field__input--area {
  min-height: 76px;
  resize: vertical;
}

.field__hint {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

/* Masked secret input with a SHOW/HIDE button pinned inside the field. */
.input-group {
  position: relative;
}

.input-group .field__input {
  padding-right: 64px;
}

.input-group__btn {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  padding: 5px 10px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.input-group__btn:hover {
  color: var(--text);
  border-color: var(--muted);
}

/* Toggle switch (boolean fields). */
.switch {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  cursor: pointer;
}

.switch__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch__track {
  display: block;
  width: 44px;
  height: 24px;
  padding: 2px;
  border-radius: var(--radius-pill);
  background: var(--border-2);
  transition: background 0.15s ease;
}

.switch__thumb {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.15s ease;
}

.switch__input:checked + .switch__track {
  background: var(--accent);
}

.switch__input:checked + .switch__track .switch__thumb {
  transform: translateX(20px);
}

.switch__input:focus-visible + .switch__track {
  box-shadow: 0 0 0 3px rgba(0, 136, 255, 0.35);
}

/* Sticky action bar at the bottom of the form. */
.form__bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 4px;
  padding: 14px 4px;
  background: rgba(17, 20, 23, 0.9);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}

.form__bar-note {
  margin-right: auto;
  font-size: 12px;
  color: var(--muted);
}

/* Inline status/alert banner (e.g. "Settings saved"). */
.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  font-size: 13px;
  font-weight: 600;
}

.banner::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.banner--success {
  border-color: rgba(0, 230, 118, 0.4);
  background: rgba(0, 230, 118, 0.1);
  color: var(--up);
}

.banner--error {
  border-color: rgba(255, 56, 96, 0.4);
  background: rgba(255, 56, 96, 0.1);
  color: var(--down);
}

/* Phone: single column, tighter padding, full-width save button. */
@media (max-width: 640px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-section__head,
  .settings-section__body {
    padding: 16px;
  }

  .form__bar {
    flex-wrap: wrap;
  }

  .form__bar .btn--primary {
    flex: 1;
  }
}

/* ============================================================
   Logs (strategy run log viewer)
   ============================================================ */

/* Highlight hues for report key/value pairs. Semantic ones reuse app tokens;
   margin (amber) and NOW (violet) are log-only accents. */
.logs {
  --hl-pl: var(--up);
  --hl-margin: #ffa657;
  --hl-balance: var(--accent);
  --hl-now: #d2a8ff;
  --hl-next: var(--down);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Truncation note shown when only the log's tail is rendered. */
.logs__notice {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

/* Card surface holding the mono log stream. Grows with content so the page
   scrolls to the live tail; long lines scroll horizontally inside here only,
   never the page body. */
.logs__viewport {
  padding: 16px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-width: 1px 0;
  border-radius: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* The log page runs edge to edge: drop the content shell's side padding so the
   viewport spans the full width of the main column. */
.page-logs .content {
  padding-left: 0;
  padding-right: 0;
}

/* One log line. <pre> keeps column alignment; lines can exceed the viewport
   width and scroll within it. */
.logs__line {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre;
}

/* Section separators ("====…") recede into the background. */
.logs__line--sep {
  color: var(--muted);
  opacity: 0.5;
}

/* Blank line between report blocks. */
.logs__spacer {
  height: 12px;
}

/* Report key/value highlighting: bold label, hued value. */
.hl-pl,
.hl-margin,
.hl-balance,
.hl-now,
.hl-next {
  font-weight: 600;
}

.hl-pl,
.hl-val-pl {
  color: var(--hl-pl);
}

.hl-margin,
.hl-val-margin {
  color: var(--hl-margin);
}

.hl-balance,
.hl-val-balance {
  color: var(--hl-balance);
}

.hl-now,
.hl-val-now {
  color: var(--hl-now);
}

.hl-next,
.hl-val-next {
  color: var(--hl-next);
}

/* Phone: tighter padding + smaller mono so more of each line fits. */
@media (max-width: 640px) {
  .logs__viewport {
    padding: 12px 0;
  }

  .logs__line {
    font-size: 11.5px;
    line-height: 1.6;
  }
}
