:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5f6b7a;
  --border: #d9dee5;
  --primary: #2563eb;
  --primary-text: #ffffff;
  --danger: #c2372f;
  --pos: #178f5f;
  --warn-bg: #fff4d6;
  --warn-border: #e8c46a;
  --info-bg: #e8f1ff;
  --info-border: #9cc2ff;
  --error-bg: #fde8e7;
  --error-border: #f0a8a4;
  --radius: 6px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0d;
    --surface: #151517;
    --text: #f2f3f5;
    --muted: #9a9fa6;
    --border: #27282c;
    --primary: #2b6cf6;
    --danger: #d9362d;
    --pos: #3fd27a;
    --warn-bg: #3a2f10;
    --warn-border: #8a6d1f;
    --info-bg: #10233d;
    --info-border: #2a4f8a;
    --error-bg: #3c1715;
    --error-border: #8a2f2a;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 {
  font-size: 22px;
  margin: 0 0 12px;
}
h2 {
  font-size: 16px;
  margin: 0 0 10px;
}
p {
  margin: 0 0 10px;
}
code {
  font-family: ui-monospace, Consolas, "Cascadia Mono", monospace;
  font-size: 12.5px;
}
a {
  color: var(--primary);
}

.muted {
  color: var(--muted);
}
.hint {
  color: var(--muted);
  font-size: 12.5px;
}
.hidden {
  display: none !important;
}

/* Boot screen */
.splash {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  transition: opacity 0.4s ease;
}
.splash.done {
  opacity: 0;
  pointer-events: none;
}
.splash img {
  border-radius: 16px;
}
.splash-name {
  font-size: 22px;
  font-weight: 700;
}
.splash .spinner {
  width: 22px;
  height: 22px;
  border-width: 3px;
}
.splash-msg {
  color: var(--muted);
  font-size: 13px;
  max-width: 420px;
  text-align: center;
  padding: 0 16px;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand {
  font-weight: 700;
  font-size: 16px;
}
nav {
  display: flex;
  gap: 4px;
}
nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
}
nav a:hover {
  color: var(--text);
}
nav a.active {
  color: var(--text);
  background: var(--bg);
}
/* On a phone the links scroll sideways inside the top bar instead of widening the page. */
.topbar nav {
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
#topbar-right {
  margin-left: auto;
  position: relative;
}
.user-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 4px;
  border-radius: 50%;
  cursor: pointer;
  line-height: 0;
}
.user-btn:hover,
.user-btn[aria-expanded="true"] {
  color: var(--text);
  background: var(--bg);
}
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px 0;
  z-index: 6;
}
.menu-who {
  padding: 10px 16px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.menu-who .sub {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
}
.menu a {
  display: block;
  padding: 8px 16px;
  color: var(--muted);
  text-decoration: none;
}
.menu a:hover {
  color: var(--text);
  background: var(--bg);
}
.menu-quit {
  display: block;
  width: calc(100% - 32px);
  margin: 10px 16px 6px;
}
.menu-version {
  padding: 6px 16px 2px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

/* Layout */
main {
  max-width: 1520px;
  margin: 0 auto;
  padding: 20px;
}
.page.narrow {
  max-width: 720px;
}
.page.signin {
  max-width: 440px;
  margin-top: 8vh;
}
.page.signin input.short {
  width: 10em;
  font-size: 1.4rem;
  letter-spacing: 0.2em;
}
.qr {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}
.qr img {
  background: #fff;
  padding: 8px;
  border-radius: 8px;
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.page-head h1 {
  margin: 0;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.empty {
  text-align: center;
  padding: 36px 20px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
@media (max-width: 640px) {
  .grid2 {
    grid-template-columns: 1fr;
  }
}

/* Banners */
.banner {
  max-width: 1520px;
  margin: 12px auto 0;
  padding: 10px 14px;
  border: 1px solid;
  border-radius: var(--radius);
  display: flex;
  gap: 12px;
  align-items: center;
}
.banner.info {
  background: var(--info-bg);
  border-color: var(--info-border);
}
.banner.warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
}
.banner.error {
  background: var(--error-bg);
  border-color: var(--error-border);
}
.banner .grow {
  flex: 1;
}
.banner ul {
  margin: 0;
  padding-left: 18px;
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: none;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table th,
.table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.table th {
  font-weight: 600;
  color: var(--muted);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.table tbody tr:hover {
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}
.table tfoot td {
  border-bottom: 0;
  font-weight: 600;
  color: var(--muted);
}
.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.table .ticker {
  font-weight: 600;
}
.row-actions {
  text-align: right;
  white-space: nowrap;
}
.row-actions .btn {
  margin-left: 6px;
}
/* A wide table scrolls inside this box instead of pushing the whole page sideways. */
.table-scroll {
  overflow-x: auto;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
.btn:hover:not(:disabled) {
  border-color: var(--muted);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}
.btn.danger {
  color: var(--danger);
}
.btn.danger:hover:not(:disabled) {
  border-color: var(--danger);
}
.btn.small {
  padding: 4px 9px;
  font-size: 12.5px;
}

/* Forms */
label {
  display: block;
  margin-bottom: 12px;
  font-weight: 500;
}
label.inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}
input,
select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
label.inline select,
label.check input {
  width: auto;
  margin: 0;
}
input:focus,
select:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent);
  border-color: var(--primary);
}
.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}
.inline-form input {
  margin: 0;
  flex: 1;
}
.list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}
.list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 16px;
  z-index: 10;
}
.dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  width: min(520px, 100%);
  padding: 20px;
  max-height: 80vh;
  overflow: auto;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 20;
  max-width: min(600px, 90vw);
}
.toast.error {
  background: var(--danger);
  color: #fff;
}

/* Badges, key-value tables */
.sub {
  font-weight: 400;
  color: var(--muted);
  font-size: 11.5px;
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--bg);
  border: 1px solid var(--border);
}
.badge.received,
.badge.updated {
  color: #1a7f37;
  border-color: #1a7f37;
}
.badge.pending,
.badge.fresh {
  color: var(--primary);
  border-color: var(--primary);
}
.badge.failed {
  color: var(--danger);
  border-color: var(--danger);
}
.badge.skipped {
  color: var(--muted);
}
.kv {
  border-collapse: collapse;
  margin: 0 0 12px;
}
.kv td {
  padding: 4px 12px 4px 0;
  vertical-align: top;
}
.kv td:first-child {
  color: var(--muted);
  white-space: nowrap;
}
.kv.steps td:first-child {
  text-transform: capitalize;
  width: 90px;
}
.actions.left {
  justify-content: flex-start;
  margin-top: 8px;
}
.banner .spinner {
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}
.page-head .hint {
  margin: 2px 0 0;
}

/* Dashboard: stat cards, holdings table */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .label {
  color: var(--muted);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.stat .value {
  font-size: 26px;
  font-weight: 700;
  margin: 4px 0 2px;
  font-variant-numeric: tabular-nums;
}
.stat .sub,
td .sub {
  color: var(--muted);
  font-size: 12px;
}
/* A home card that opens a page: looks like the other cards, not like a link. */
a.stat.link {
  color: inherit;
  text-decoration: none;
}
a.stat.link:hover {
  border-color: var(--primary);
}
/* A placeholder for a module that does not exist yet. */
.stat.soon {
  border-style: dashed;
  background: transparent;
  color: var(--muted);
}
.stat.soon .label::after {
  content: " · planned";
  text-transform: none;
  letter-spacing: 0;
}
.grid2.gap {
  gap: 20px;
  margin-top: 20px;
}
.grid2.gap > div {
  min-width: 0;
}
.table.compact th,
.table.compact td {
  padding: 5px 10px;
}
.table tr.future td {
  color: var(--muted);
}
.flag {
  display: inline-block;
  font-size: 11.5px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  margin: 1px 0;
}
.badge.announced {
  color: #8957e5;
  border-color: #8957e5;
}
.badge.estimated {
  color: var(--muted);
  border-color: var(--muted);
}
.badge.raised {
  color: #1a7f37;
  border-color: #1a7f37;
}
.badge.cut {
  color: var(--danger);
  border-color: var(--danger);
}
.badge.unchanged {
  color: var(--muted);
}
td.raised {
  color: #1a7f37;
}
td.cut {
  color: var(--danger);
}
.bar-cell {
  width: 40%;
}
.bar {
  height: 10px;
  border-radius: 5px;
  background: var(--primary);
  min-width: 2px;
}
.notes {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}
h2 {
  margin-top: 8px;
}
.table.compact td:first-child,
.table.compact th:first-child {
  white-space: nowrap;
}
/* Phones (DESIGN.md 9.5): a wide table scrolls inside its card instead of the page, and the
   columns marked phone-hide (categories, ex-dates and the like) go. Replaced by the Spaces shell. */
@media (max-width: 640px) {
  .table.compact {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }
  .table.compact .phone-hide {
    display: none;
  }
}
@media (max-width: 900px) {
  .grid2.gap {
    grid-template-columns: 1fr;
  }
}

/* Charts and calendar */
.chart-box {
  position: relative;
  height: 240px;
  margin: 4px 0 8px;
}
.chart-box.tall {
  height: 300px;
}
.charts .card {
  margin-bottom: 0;
}
.table-twin summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12.5px;
  margin: 6px 0;
}
.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  vertical-align: middle;
}
.month-nav {
  display: inline-flex;
  gap: 4px;
}
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 8px;
}
.cal-head h2 {
  margin: 0;
}
.legend {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  transition: opacity 0.2s;
}
.calendar.loading {
  opacity: 0.5;
}
.weekday {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 4px 6px;
}
.day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 92px;
  padding: 4px 6px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.day.empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
}
.day:not(.empty):hover {
  border-color: var(--muted);
}
.day.today {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.daynum {
  font-size: 12px;
  color: var(--muted);
}
.day.today .daynum {
  color: var(--primary);
  font-weight: 700;
}
.pill {
  display: inline-block;
  font-size: 11px;
  line-height: 1.3;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.pill.ex {
  border-color: #2a78d6;
  color: #2a78d6;
}
.pill.pay {
  background: #1baf7a;
  color: #fff;
}
.pill.earnings {
  background: #eb6834;
  color: #fff;
}
.pill.estimated {
  border-style: dashed;
  opacity: 0.85;
}
.pill.pay.estimated {
  background: transparent;
  color: #1baf7a;
  border-color: #1baf7a;
}
.pill.more {
  color: var(--muted);
}
@media (prefers-color-scheme: dark) {
  .pill.ex {
    border-color: #3987e5;
    color: #3987e5;
  }
  .pill.pay {
    background: #199e70;
  }
  .pill.earnings {
    background: #d95926;
  }
  .pill.pay.estimated {
    color: #199e70;
    border-color: #199e70;
  }
}
@media (max-width: 640px) {
  .day {
    min-height: 56px;
  }
  .pill {
    font-size: 10px;
    padding: 0 4px;
  }
}

/* Cards with a headline number (Overview, Portfolio) */
.card.center {
  text-align: center;
}
.big {
  font-size: 34px;
  font-weight: 700;
  margin: 6px 0 4px;
  font-variant-numeric: tabular-nums;
}
.kv.wide {
  width: 100%;
  margin-top: 10px;
}
.kv.wide td {
  padding: 5px 0;
}
.kv.wide td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--text);
}
.kv.wide td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.pos {
  color: var(--pos);
}
.neg {
  color: var(--danger);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.card-head h2 {
  margin: 0;
}
select.small {
  width: auto;
  margin: 0;
  padding: 4px 8px;
  font-size: 12.5px;
}
.yearbtns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.grid2.gap.top {
  margin-top: 0;
}
.grid2.gap + .card,
.card + .grid2.gap {
  margin-top: 20px;
}
.grid2.gap > .card {
  margin-bottom: 0;
}
.stat.center {
  text-align: center;
}
.stat .value.small {
  font-size: 20px;
}
.center-actions {
  justify-content: center;
}
.next-payout {
  padding: 6px 0 12px;
}
.goal-empty {
  padding: 24px 12px;
}
.hint.center {
  text-align: center;
}
.notes {
  margin-top: 8px;
}

/* Composition: doughnut beside the full list */
.comp {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: start;
}
.comp-chart {
  height: 260px;
  margin: 0;
}
.comp-body {
  min-width: 0;
}
.comp-list td {
  border-bottom: 0;
  padding: 4px 8px;
}
.comp-list td:first-child {
  width: 22px;
}
.comp-list td:nth-child(2) {
  width: 64px;
}
@media (max-width: 760px) {
  .comp {
    grid-template-columns: 1fr;
  }
}

/* Portfolio tabs and sortable table */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 0 0 16px;
}
.tabs a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a.active {
  color: var(--text);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th.sortable:hover {
  color: var(--text);
}
th.sorted {
  color: var(--text);
}
.sort-arrow {
  font-size: 9px;
  margin-left: 4px;
  opacity: 0.6;
}
.table.holdings {
  font-size: 13px;
}
.table.holdings th,
.table.holdings td {
  padding: 5px 7px;
}
.table.holdings td .sub {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.holdings-view [data-action] {
  cursor: pointer;
}
.holdings-view [data-action]:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent);
  outline-offset: -2px;
}

/* Holdings on a phone: a card per holding instead of the table, plus the sort and
   "show on the right" buttons that open sheets */
.holding-list,
.holdings-head .toolbar {
  display: none;
}
@media (max-width: 640px) {
  .holdings-view .table-scroll {
    display: none;
  }
  .holding-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .holdings-head .toolbar {
    display: flex;
  }
}
.btn.round {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
}
.holding-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.ticker-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: hsl(var(--hue) 45% 38%);
  color: #fff;
  font-weight: 700;
}
.hc-main {
  flex: 1;
  min-width: 0;
}
.hc-ticker {
  font-size: 16px;
  font-weight: 700;
}
.hc-name {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hc-position,
.hc-detail {
  font-variant-numeric: tabular-nums;
}
.hc-right {
  text-align: right;
  white-space: nowrap;
}
.hc-figure {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.hc-figure .fig-unit {
  margin-right: 2px;
  font-size: 15px;
  font-weight: 600;
}
.hc-figure .fig-dec {
  font-size: 17px;
}
.hc-detail {
  color: var(--muted);
  font-size: 13px;
}
.hc-right.pos .hc-detail,
.hc-right.neg .hc-detail {
  color: inherit;
}

/* Sheets: a list of choices and a two-way segmented control, each a hidden radio */
.choices {
  display: grid;
  margin-bottom: 8px;
}
.choice {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
  cursor: pointer;
}
.choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}
.choice:has(input:checked) {
  font-weight: 600;
}
.choices .choice:has(input:checked)::after {
  content: "✓";
  color: var(--primary);
  font-weight: 700;
}
.choice:has(input:focus-visible) {
  outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent);
  outline-offset: -2px;
}
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.segmented .choice {
  justify-content: center;
  padding: 8px;
  border: 0;
  border-radius: 7px;
}
.segmented .choice:has(input:checked) {
  background: var(--primary);
  color: var(--primary-text);
}
.btn.wide {
  width: 100%;
}

/* Overlays with many rows */
.dialog.wide {
  width: min(900px, 100%);
}
.overlay-scroll {
  max-height: 60vh;
  overflow: auto;
  margin: 0 -4px;
  padding: 0 4px;
}
.payout-group {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.payout-head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
}
.grow-right {
  margin-left: auto;
}
.payout-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0 6px 12px;
}
.change-block {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.change-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.change-dates {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 10px;
  text-align: center;
}
.pairs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  text-align: center;
}
.pair .sub {
  min-height: 14px;
}
@media (max-width: 640px) {
  .pairs,
  .change-dates {
    grid-template-columns: 1fr 1fr;
  }
}

/* Calendar: eight columns (seven days plus the week total), event rows inside days */
.calendar {
  grid-template-columns: repeat(7, minmax(0, 1fr)) 84px;
}
.day.other {
  background: transparent;
  cursor: default;
  opacity: 0.45;
}
.dayhead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px;
}
.daytotal {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.evrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  line-height: 1.3;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg);
  min-width: 0;
}
.evrow .ticker {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.evrow.pay {
  background: color-mix(in srgb, #1baf7a 18%, var(--surface));
}
.evrow.pay .amt {
  color: #1a7f37;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.evrow.estimated {
  border: 1px dashed var(--border);
  background: transparent;
}
.evrow .tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.evrow .tag.ex {
  color: #2a78d6;
}
.evrow .tag.earnings {
  color: #eb6834;
}
.evrow.more {
  color: var(--muted);
  background: transparent;
  padding-left: 0;
}
.evrow.demo {
  display: inline-flex;
  width: 110px;
}
.weekcol {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: 4px 6px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.pending-amt {
  color: var(--primary);
}
.month-total {
  font-variant-numeric: tabular-nums;
}
.cal-head .toolbar h2 {
  margin: 0 0 0 6px;
}
.legend {
  align-items: center;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}
@media (prefers-color-scheme: dark) {
  .evrow.pay .amt {
    color: #3fb950;
  }
  .evrow .tag.ex {
    color: #3987e5;
  }
  .evrow .tag.earnings {
    color: #d95926;
  }
}
@media (max-width: 640px) {
  .calendar {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
  .weekcol,
  .weekday:last-child {
    display: none;
  }
  .evrow .amt,
  .evrow .tag {
    display: none;
  }
}

/* Portfolio tabs in the page head, and the My Portfolios dialog */
.pf-tabs {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}
.pf-tab {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}
.pf-tab:hover {
  color: var(--text);
}
.pf-tab.active {
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
}
.btn.icon {
  padding: 6px 9px;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  font-size: 18px;
}
.btn.danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.pf-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.pf-dialog-head h2 {
  margin: 0;
}
.pf-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.pf-section > h3 {
  margin: 0 0 12px;
  font-size: 14px;
}
.pf-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.pf-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.pf-card.selected {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.pf-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
}
.pf-figures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.pf-figures .muted {
  font-size: 12.5px;
}
.pf-card-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
}
.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  vertical-align: middle;
}
.comp-list .num strong {
  font-variant-numeric: tabular-nums;
}

/* Goals */
.goal-ring {
  position: relative;
  height: 180px;
  width: 180px;
  margin: 4px auto 8px;
}
.goal-figures {
  font-size: 26px;
}
.goal-list {
  text-align: left;
  margin-top: 16px;
  border-top: 1px solid var(--border);
}
.goal-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.goal-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.bar-track {
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
}
.bar-fill.done {
  background: var(--pos);
}
.actions.between {
  justify-content: space-between;
}

/* Budget month tables: inline actuals */
.table input.cell {
  width: 110px;
  margin: 0;
  padding: 4px 8px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.table th.cell-col {
  width: 130px;
}
.table input.paid-box {
  width: auto;
  margin: 0;
}
.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 20px;
}
.grid3 > .card {
  margin-bottom: 0;
}
textarea {
  display: block;
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
@media (max-width: 900px) {
  .grid3 {
    grid-template-columns: 1fr;
  }
}

.btn.icon-btn {
  padding: 1px 6px;
  font-size: 13px;
  line-height: 1.4;
  margin-left: 6px;
  vertical-align: middle;
}

/* Number inputs without spinner arrows, everywhere */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* An input with a fixed symbol inside it ($ before, % after) */
.input-group {
  display: flex;
  align-items: center;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}
.input-group:focus-within {
  outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent);
  border-color: var(--primary);
}
.input-group input {
  border: 0;
  background: transparent;
  margin: 0;
  min-width: 0;
}
.input-group input:focus {
  outline: none;
}
.input-group .adorn {
  color: var(--muted);
  padding: 0 10px;
}
.or-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: end;
}
.or-row .or {
  color: var(--muted);
  padding-bottom: 20px;
}
h3.sub-head {
  font-size: 14px;
  margin: 4px 0 10px;
}

/* Settings: a left nav, one section at a time, the App card under the nav */
.settings {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  column-gap: 28px;
  align-items: start;
}
.settings > h1 {
  grid-column: 1 / -1;
}
.settings-side {
  position: sticky;
  top: 72px;
}
.settings-nav {
  flex-direction: column;
  gap: 2px;
}
.settings-nav a {
  padding: 7px 12px;
}
.settings-nav a.active {
  background: var(--surface);
  font-weight: 600;
}
.settings-nav .nav-group {
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 14px 12px 4px;
}
.settings-nav .nav-sep {
  border-top: 1px solid var(--border);
  margin: 8px 12px;
}
.settings-app {
  margin: 16px 0 0;
}
.settings-app .btn {
  width: 100%;
  margin-top: 10px;
}
.settings-body {
  min-width: 0;
  max-width: 760px;
}
.settings-body.wide {
  max-width: 1080px;
}
.settings-body > h2 {
  font-size: 18px;
  margin: 4px 0 14px;
}
.settings-body input.short {
  max-width: 160px;
}
.block-head {
  font-size: 16px;
  margin: 0 0 10px;
}
.menu-sep {
  border-top: 1px solid var(--border);
  margin: 6px 0;
}
@media (max-width: 760px) {
  .settings {
    grid-template-columns: minmax(0, 1fr);
  }
  .settings-side {
    display: contents;
  }
  .settings-nav {
    flex-direction: row;
    flex-wrap: wrap;
    margin-bottom: 12px;
  }
  .settings-nav .nav-group,
  .settings-nav .nav-sep {
    display: none;
  }
  .settings-app {
    order: 1;
  }
}

/* Billing (a placeholder: nothing is sold) and the question lists of Billing and Help */
.badge.ok {
  color: var(--pos);
  border-color: var(--pos);
}
.billing-note {
  border-top: 1px solid var(--border);
  margin: 4px 0 0;
  padding-top: 12px;
  color: var(--muted);
}
.pricing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 28px 0 14px;
}
.pricing-head .block-head {
  margin: 0;
}
.seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  padding: 5px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.seg button:hover {
  color: var(--text);
}
.seg button.active {
  background: var(--primary);
  color: var(--primary-text);
}
.tiers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.tier {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.tier.highlight {
  border: 2px solid var(--pos);
  padding: 17px;
}
.tier-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
}
.tier-head h3 {
  margin: 0;
  font-size: 16px;
}
.save-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  color: var(--pos);
  background: color-mix(in srgb, var(--pos) 16%, transparent);
  white-space: nowrap;
}
.tier-note {
  font-size: 12.5px;
  color: var(--muted);
  margin: 2px 0 14px;
}
.tier-note.soon {
  color: #9a6700;
}
.tier-price {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}
.tier-price .amount {
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.tier-price s,
.tier-price .per,
.tier-billed {
  color: var(--muted);
}
.tier-price s {
  font-size: 16px;
}
.tier-billed {
  font-size: 12.5px;
  margin-top: 2px;
}
.tier-desc {
  flex: 1;
  margin: 14px 0 16px;
}
.tier .btn {
  width: 100%;
}
.tier-features {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.tier-features-head {
  font-weight: 600;
  margin-bottom: 8px;
}
.tier-features ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tier-features li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.tier-features svg {
  flex: none;
}
.feat-yes {
  color: var(--pos);
}
.feat-no {
  color: var(--danger);
}
.pricing-note {
  margin: 14px 0 0;
}
hr.divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}
.faq {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px 16px;
  margin-bottom: 16px;
}
.faq-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.faq-item:last-child {
  border-bottom: 0;
}
.faq-item h3 {
  font-size: 14.5px;
  margin: 0 0 6px;
}
.faq-item p {
  margin: 0;
  line-height: 1.55;
}
@media (prefers-color-scheme: dark) {
  .tier-note.soon {
    color: #d29922;
  }
}
@media (max-width: 900px) {
  .tiers {
    grid-template-columns: minmax(0, 1fr);
  }
}
