html {
  font-size: 15px;
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 40px;
  background: var(--bp-page-bg);
}

/* Light and dark mode (theme.js sets data-bs-theme on <html>). Bootstrap 5.3 recolours its
   own parts; these are the site's own colours. */
:root, [data-bs-theme=light] {
  --bp-page-bg: #f7f8fa;
  --bp-up: #1b7f3b;
  --bp-down: #c62828;
  --bp-paper: #1f6feb;
  --bp-avatar-bg: #dde3ea;
  --bp-avatar-fg: #5b6673;
}

[data-bs-theme=dark] {
  --bp-page-bg: #16181b;
  --bp-up: #3fb950;
  --bp-down: #ff6b6b;
  --bp-paper: #58a6ff;
  --bp-avatar-bg: #3a4048;
  --bp-avatar-fg: #c9d1d9;
}

/* Bootstrap keeps its coloured table rows (table-danger and so on) pale in dark mode, which
   left light text on a pale row. In dark mode they become a dark tint of the colour instead. */
[data-bs-theme=dark] .table-primary {
  --bs-table-color: var(--bs-body-color);
  --bs-table-bg: var(--bs-primary-bg-subtle);
  --bs-table-border-color: var(--bs-primary-border-subtle);
  --bs-table-striped-bg: color-mix(in srgb, var(--bs-primary-bg-subtle), #fff 5%);
  --bs-table-striped-color: var(--bs-body-color);
  --bs-table-active-bg: color-mix(in srgb, var(--bs-primary-bg-subtle), #fff 10%);
  --bs-table-active-color: var(--bs-body-color);
  --bs-table-hover-bg: color-mix(in srgb, var(--bs-primary-bg-subtle), #fff 7.5%);
  --bs-table-hover-color: var(--bs-body-color);
}
[data-bs-theme=dark] .table-secondary {
  --bs-table-color: var(--bs-body-color);
  --bs-table-bg: var(--bs-secondary-bg-subtle);
  --bs-table-border-color: var(--bs-secondary-border-subtle);
  --bs-table-striped-bg: color-mix(in srgb, var(--bs-secondary-bg-subtle), #fff 5%);
  --bs-table-striped-color: var(--bs-body-color);
  --bs-table-active-bg: color-mix(in srgb, var(--bs-secondary-bg-subtle), #fff 10%);
  --bs-table-active-color: var(--bs-body-color);
  --bs-table-hover-bg: color-mix(in srgb, var(--bs-secondary-bg-subtle), #fff 7.5%);
  --bs-table-hover-color: var(--bs-body-color);
}
[data-bs-theme=dark] .table-success {
  --bs-table-color: var(--bs-body-color);
  --bs-table-bg: var(--bs-success-bg-subtle);
  --bs-table-border-color: var(--bs-success-border-subtle);
  --bs-table-striped-bg: color-mix(in srgb, var(--bs-success-bg-subtle), #fff 5%);
  --bs-table-striped-color: var(--bs-body-color);
  --bs-table-active-bg: color-mix(in srgb, var(--bs-success-bg-subtle), #fff 10%);
  --bs-table-active-color: var(--bs-body-color);
  --bs-table-hover-bg: color-mix(in srgb, var(--bs-success-bg-subtle), #fff 7.5%);
  --bs-table-hover-color: var(--bs-body-color);
}
[data-bs-theme=dark] .table-info {
  --bs-table-color: var(--bs-body-color);
  --bs-table-bg: var(--bs-info-bg-subtle);
  --bs-table-border-color: var(--bs-info-border-subtle);
  --bs-table-striped-bg: color-mix(in srgb, var(--bs-info-bg-subtle), #fff 5%);
  --bs-table-striped-color: var(--bs-body-color);
  --bs-table-active-bg: color-mix(in srgb, var(--bs-info-bg-subtle), #fff 10%);
  --bs-table-active-color: var(--bs-body-color);
  --bs-table-hover-bg: color-mix(in srgb, var(--bs-info-bg-subtle), #fff 7.5%);
  --bs-table-hover-color: var(--bs-body-color);
}
[data-bs-theme=dark] .table-warning {
  --bs-table-color: var(--bs-body-color);
  --bs-table-bg: var(--bs-warning-bg-subtle);
  --bs-table-border-color: var(--bs-warning-border-subtle);
  --bs-table-striped-bg: color-mix(in srgb, var(--bs-warning-bg-subtle), #fff 5%);
  --bs-table-striped-color: var(--bs-body-color);
  --bs-table-active-bg: color-mix(in srgb, var(--bs-warning-bg-subtle), #fff 10%);
  --bs-table-active-color: var(--bs-body-color);
  --bs-table-hover-bg: color-mix(in srgb, var(--bs-warning-bg-subtle), #fff 7.5%);
  --bs-table-hover-color: var(--bs-body-color);
}
[data-bs-theme=dark] .table-danger {
  --bs-table-color: var(--bs-body-color);
  --bs-table-bg: var(--bs-danger-bg-subtle);
  --bs-table-border-color: var(--bs-danger-border-subtle);
  --bs-table-striped-bg: color-mix(in srgb, var(--bs-danger-bg-subtle), #fff 5%);
  --bs-table-striped-color: var(--bs-body-color);
  --bs-table-active-bg: color-mix(in srgb, var(--bs-danger-bg-subtle), #fff 10%);
  --bs-table-active-color: var(--bs-body-color);
  --bs-table-hover-bg: color-mix(in srgb, var(--bs-danger-bg-subtle), #fff 7.5%);
  --bs-table-hover-color: var(--bs-body-color);
}

/* Coloured text inside a row of the same colour (a red "Not sent" in a red Emergency row)
   uses the deeper shade, so it stays readable in both modes. */
.table-danger .text-danger { color: var(--bs-danger-text-emphasis) !important; }
.table-warning .text-warning { color: var(--bs-warning-text-emphasis) !important; }
.table-success .text-success { color: var(--bs-success-text-emphasis) !important; }

/* Bootstrap's text-warning is plain yellow, unreadable on white; use its readable shade
   (dark amber in light mode, pale yellow in dark mode). */
.text-warning { color: var(--bs-warning-text-emphasis) !important; }

/* Bootstrap keeps green and red text at their light-mode shades in dark mode (3.4:1 on a
   dark card); use its lighter dark-mode shades. */
[data-bs-theme=dark] .text-success { color: var(--bs-success-text-emphasis) !important; }
[data-bs-theme=dark] .text-danger { color: var(--bs-danger-text-emphasis) !important; }

[data-bs-theme=dark] .table-light {
  --bs-table-bg: var(--bs-tertiary-bg);
  --bs-table-color: var(--bs-body-color);
  --bs-table-border-color: var(--bs-border-color);
}

/* Nav bar: dark mode toggle and the account menu. */
.theme-toggle { color: var(--bs-secondary-color); padding: 0.25rem 0.4rem; }
.theme-toggle:hover, .theme-toggle:focus { color: var(--bs-body-color); }
[data-bs-theme=light] .theme-icon-light,
[data-bs-theme=dark] .theme-icon-dark { display: none; }

.profile-button { color: var(--bs-body-color); border: 0; padding: 0.2rem 0.4rem; }
.profile-button:hover, .profile-button[aria-expanded=true] { background: var(--bs-tertiary-bg); }
.profile-image {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bp-avatar-bg);
  color: var(--bp-avatar-fg);
  flex: none;
}
.profile-name { font-size: 0.9rem; }
.profile-caret { color: var(--bs-secondary-color); }
.nav-right .dropdown-menu form { margin: 0; }

/* Account mode band (imp-plan 6.2): blue for paper, red for live. */
.mode-band {
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.35rem 0;
  color: #fff;
}

.mode-paper { background: #1f6feb; }
.mode-live { background: #c62828; }

.mode-big {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.mode-big.mode-paper-text { color: var(--bp-paper); }
.mode-big.mode-live-text { color: var(--bp-down); }

.card { margin-bottom: 1rem; }

.table-sm td, .table-sm th { white-space: nowrap; }

.num { text-align: right; font-variant-numeric: tabular-nums; }

.pnl-up { color: var(--bp-up); }
.pnl-down { color: var(--bp-down); }

.recovery-codes {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 1.1rem;
  columns: 2;
}

.shared-key {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 1.1rem;
}

.qr { width: 220px; height: 220px; image-rendering: pixelated; }

.narrow { max-width: 420px; }

/* Collapsed dashboard panels (Skipped today). */
details.card > summary { cursor: pointer; list-style: revert; }
