/* ============================================================ tokens === */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ef;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --hover: rgba(11, 11, 11, 0.04);

  --series-1: #2a78d6;      /* value / price */
  --series-2: #eb6834;      /* buys */
  --series-3: #1baf7a;      /* sells */
  --reference: #898781;     /* cost basis, average cost */
  --cat-1: #2a78d6; --cat-2: #eb6834; --cat-3: #1baf7a; --cat-4: #eda100;   /* categorical (pie) */
  --cat-5: #e87ba4; --cat-6: #008300; --cat-7: #4a3aa7; --cat-8: #e34948; --cat-other: #b5b4ad;

  --good: #0ca30c;          /* gain – marks */
  --bad: #d03b3b;           /* loss – marks */
  --good-text: #006300;
  --bad-text: #c23030;
  --faded: 62%;             /* how much of a colour is left in a quiet note */
  --warning: #fab219;
  --warning-bg: #fff6e0;
  --warning-ink: #6b4a00;

  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --focus: #2a78d6;

  --radius: 10px;
  --radius-sm: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232322;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --hover: rgba(255, 255, 255, 0.05);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --good-text: #0ca30c;
    --bad-text: #e66767;
    --faded: 82%;
    --warning-bg: #2e2510;
    --warning-ink: #fab219;
    --accent: #3987e5;
    --focus: #3987e5;
    --cat-1: #3987e5; --cat-2: #d95926; --cat-3: #199e70; --cat-4: #c98500;
    --cat-5: #d55181; --cat-6: #008300; --cat-7: #9085e9; --cat-8: #e66767; --cat-other: #6a6964;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232322;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --hover: rgba(255, 255, 255, 0.05);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --good-text: #0ca30c;
  --bad-text: #e66767;
  --faded: 82%;
  --warning-bg: #2e2510;
  --warning-ink: #fab219;
  --accent: #3987e5;
  --focus: #3987e5;
  --cat-1: #3987e5; --cat-2: #d95926; --cat-3: #199e70; --cat-4: #c98500;
  --cat-5: #d55181; --cat-6: #008300; --cat-7: #9085e9; --cat-8: #e66767; --cat-other: #6a6964;
}

/* ============================================================ base === */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
[x-cloak], [hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
.muted { color: var(--muted); }
.secondary { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--good-text); }
.neg { color: var(--bad-text); }
.badge.est { background: none; border: 1px dashed var(--border); color: var(--ink-2); padding: 0 5px; }
label.check { display: flex; gap: 6px; align-items: center; margin-top: 6px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
label.check input { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
/* a field only a password manager reads (the login name above a new password): the control rule
   below gives inputs a width of 100% and padding – this keeps it a point */
input[type].sr-only { width: 1px; min-height: 0; padding: 0; border: 0; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; overflow-wrap: anywhere; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ============================================================ top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 10px 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; text-decoration: none; font-size: 15px; }
.brand svg { color: var(--accent); }
.nav { display: flex; flex-wrap: wrap; gap: 2px; }
.nav a {
  text-decoration: none; color: var(--ink-2); white-space: nowrap;
  padding: 6px 10px; border-radius: var(--radius-sm);
}
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); font-weight: 550; }
.topbar .controls { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.status {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink-2); font-size: 12.5px;
  background: none; border: 0; cursor: pointer; padding: 4px 6px; border-radius: var(--radius-sm);
  font-family: inherit;
}
.status:hover { background: var(--hover); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status .dot.fresh { background: var(--good); }
.status .dot.error { background: var(--bad); }
.status .dot.busy { animation: pulse 1s ease-in-out infinite; background: var(--accent); }
@keyframes pulse { 50% { opacity: .3; } }

/* the signed-in user: name, Account, Sign out */
.user-menu { position: relative; }
.user-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); cursor: pointer;
}
.user-btn:hover { background: var(--hover); }
.user-btn .user-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.menu {
  position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; min-width: 220px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12); padding: 4px;
}
.menu .who { display: grid; gap: 2px; justify-items: start; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.menu .who .secondary { font-size: 12.5px; }
.menu a, .menu button {
  display: block; width: 100%; padding: 7px 10px; border: 0; border-radius: 4px; background: none;
  text-align: left; text-decoration: none; cursor: pointer;
}
.menu a:hover, .menu button:hover, .menu a[aria-current="page"] { background: var(--hover); }

/* ============================================================ controls */
select, input, textarea, button { font: inherit; color: inherit; }
select, input[type="text"], input[type="number"], input[type="date"], input[type="search"],
input[type="email"], input[type="password"], textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 9px; min-height: 34px; width: 100%;
}
select { width: auto; padding-right: 26px; }
input:hover, select:hover, textarea:hover { border-color: var(--baseline); }
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
input::placeholder { text-transform: none; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; min-height: 34px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 550; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad-text); }
.btn.ghost { border-color: transparent; background: none; }
.btn.small { padding: 3px 9px; min-height: 28px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); }

.segmented { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border-radius: var(--radius-sm); padding: 2px; }
.segmented button {
  border: 0; background: none; padding: 4px 10px; border-radius: 4px; cursor: pointer;
  color: var(--ink-2); font-size: 13px;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 550; box-shadow: 0 0 0 1px var(--border); }

/* ============================================================ layout */
.container { max-width: 1320px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; }
.stack { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
@media (max-width: 960px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
/* two cards side by side, equally tall: bars start at the top, a pie sits in the middle */
.grid-2.equal { align-items: stretch; }
.card.fill { display: flex; flex-direction: column; }
.card.fill > .card-body { flex: 1; display: flex; flex-direction: column; }
.card.fill > .card-body > .pie-wrap { margin-block: auto; }
@media (min-width: 961px) { .grid-2.equal .card-body { min-height: var(--row-body); } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head p { margin: 2px 0 0; font-size: 13px; }
.card.flush { padding: 0; }
.card.flush .card-head { padding: 16px 20px 0; }

/* ============================================================ KPI */
.kpis { display: grid; grid-template-columns: 1.5fr repeat(5, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.kpis.cols-5 { grid-template-columns: 1.5fr repeat(4, minmax(0, 1fr)); }
.kpi { background: var(--surface); padding: 18px 20px; min-width: 0; }
.kpi .label { color: var(--ink-2); font-size: 13px; }
.kpi .value { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; white-space: nowrap; }
.kpi .delta { font-size: 13px; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.kpi.hero .value { font-size: 40px; line-height: 1.05; }
@media (max-width: 1200px) { .kpis, .kpis.cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kpi.hero { grid-column: 1 / -1; } }
@media (max-width: 760px) { .kpis, .kpis.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .kpis { grid-template-columns: minmax(0, 1fr); } .kpi.hero .value { font-size: 36px; } }

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--warning-bg); color: var(--warning-ink);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px;
}
.notice.error { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); color: var(--bad-text); }
.notice.info { background: var(--surface-2); color: var(--ink-2); }
.notice.success { background: color-mix(in srgb, var(--good) 12%, var(--surface)); color: var(--good-text); }
.notice-close {
  flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; margin: -3px -6px -3px 0;
  border: 0; border-radius: 4px; background: none; color: inherit; opacity: .7; cursor: pointer;
}
.notice-close:hover { opacity: 1; background: var(--hover); }

/* ============================================================ charts */
.chart { width: 100%; }
.chart.h-history { height: 320px; }
.chart.h-price { height: 360px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .line { width: 14px; height: 2px; border-radius: 1px; }
.legend .dot { width: 9px; height: 9px; border-radius: 50%; }
.legend .diamond { width: 8px; height: 8px; transform: rotate(45deg); }
.chart-tip { font: 12.5px/1.5 var(--font); }
.chart-tip .t { color: var(--ink-2); margin-bottom: 2px; white-space: normal; max-width: 320px; }
.chart-tip .row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.chart-tip .row span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.chart-tip .sw { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chart-tip b { font-variant-numeric: tabular-nums; font-weight: 600; }
.empty { padding: 40px 12px; text-align: center; color: var(--muted); }

/* the pages of a long table */
.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap;
  padding: 12px 20px; border-top: 1px solid var(--border);
}
.pager-buttons { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pager-page { min-width: 96px; text-align: center; font-variant-numeric: tabular-nums; }
@media (max-width: 480px) { .pager-word { display: none; } .pager-page { min-width: 84px; } }

/* ============================================================ tables */
.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--grid); vertical-align: middle; }
th { font-size: 12px; font-weight: 550; color: var(--ink-2); white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th .arrow { font-size: 10px; margin-left: 2px; }
td.r, th.r { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: var(--hover); }
tfoot td { border-top: 1px solid var(--baseline); border-bottom: 0; font-weight: 600; }
td .sym, td.sym { font-weight: 600; white-space: nowrap; }  /* BTC-USD, not BTC- / USD */
td.note { min-width: 16rem; }  /* an exchange's note ("Binance XRP/ETH buy: …") in two lines, not six */
td .name { color: var(--ink-2); font-size: 12.5px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.closed td { color: var(--muted); }
td.nowrap { white-space: nowrap; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; padding: 1px 7px; border-radius: 99px;
  background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.badge.warn { background: var(--warning-bg); color: var(--warning-ink); }
.badge.good { background: color-mix(in srgb, var(--good) 14%, var(--surface)); color: var(--good-text); }
.badge.bad { background: color-mix(in srgb, var(--bad) 14%, var(--surface)); color: var(--bad-text); }

.weight { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.weight .track { display: block; flex: none; width: 56px; height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.weight .fill { display: block; height: 100%; background: var(--series-1); border-radius: 2px; }

/* ============================================================ forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 14px; }
.field { display: grid; gap: 4px; align-content: start; }
.field label { font-size: 12.5px; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field.wide { grid-column: span 2; }
@media (max-width: 560px) { .field.wide { grid-column: auto; } }
.form-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.form-actions.sign-out-everywhere { align-items: center; gap: 12px; }
.form-actions.sign-out-everywhere label.check { margin-top: 0; }

.combo { position: relative; }
.combo-list {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; min-width: min(360px, calc(100vw - 64px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12); max-height: 300px; overflow-y: auto; padding: 4px;
}
.combo-list button {
  display: grid; grid-template-columns: auto 1fr; gap: 0 10px; width: 100%; text-align: left;
  border: 0; background: none; padding: 7px 9px; border-radius: 4px; cursor: pointer;
}
.combo-list button:hover, .combo-list button.active { background: var(--hover); }
.combo-list .s { font-weight: 600; }
.combo-list .n { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-list .x { grid-column: 2; font-size: 12px; color: var(--muted); }
/* a fund's share class is at the end of its long name: the name wraps under the ISIN */
.combo-list button.fund { grid-template-columns: 1fr; }
.combo-list button.fund .n { white-space: normal; }
.combo-list button.fund .x { grid-column: 1; }
.combo-note { margin: 0; padding: 7px 9px; font-size: 12px; color: var(--muted); }
.combo-list .combo-note:has(~ button) { border-bottom: 1px solid var(--border); margin-bottom: 4px; }

.howto { font-size: 13.5px; margin: 0 0 12px; max-width: 900px; }
.howto p { margin: 0 0 6px; }
.howto ol { margin: 0 0 6px; padding-left: 20px; }
.howto li { margin-bottom: 3px; }
/* an exchange's two keys and the button, one under another. (A class, not a style attribute:
   showing an element with x-show removes the display of its style attribute.) */
.api-key { display: grid; gap: 12px; }
.api-key .form-actions { margin-top: 2px; }
.load-outcome .note { margin-top: 6px; font-size: 13px; }
/* a secret shown as dots without being a password field */
input.secret[type="text"] { -webkit-text-security: disc; }
.dropzone {
  display: block;
  border: 1.5px dashed var(--baseline); border-radius: var(--radius); padding: 28px; text-align: center;
  color: var(--ink-2); cursor: pointer; transition: background .15s;
}
.dropzone:hover, .dropzone.over { background: var(--hover); border-color: var(--accent); }
.dropzone input { display: none; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }

/* the Import page: the tab of a source that cannot be imported from yet shows what to ask for */
.wish-panel { margin: 0 0 4px; }
/* the automatic import of an exchange: its state and what to do with it */
.keep-sync { margin: 0 0 12px; }
.connection { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; display: grid; gap: 8px; }
.connection-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.other-form { display: grid; gap: 12px; max-width: 520px; }
.other-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; font-size: 13.5px; }
.other-list li { display: flex; gap: 2px 10px; flex-wrap: wrap; align-items: baseline; }

/* ============================================================ position detail */
.detail-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-end; }
.detail-head .price { text-align: right; }
.detail-head .price .value { font-size: 36px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.meta-line { display: flex; gap: 6px 14px; flex-wrap: wrap; color: var(--ink-2); font-size: 13px; margin-top: 6px; }
.back { display: inline-flex; gap: 4px; align-items: center; color: var(--ink-2); text-decoration: none; font-size: 13px; margin-bottom: 8px; }
.back:hover { color: var(--ink); }

.ai-card { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.ai-card .txt { max-width: 720px; }
.ai-card p { margin: 4px 0 0; color: var(--ink-2); font-size: 13px; }

.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 50; max-width: 420px;
  background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 13.5px;
}
.toast.error { background: var(--bad); color: #fff; }

@media (max-width: 720px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .container { padding: 16px; }
  .topbar .controls { margin-left: 0; width: 100%; }
  .user-menu { margin-left: auto; }  /* its menu opens to the left, within the screen */
  .user-btn .user-name { max-width: 110px; }
}

/* ============================================================ markets */
.mkt { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.mkt.open { background: var(--good); }
.mkt.pre, .mkt.post { background: var(--warning); }
.mkt.closed { border: 1.5px solid var(--muted); }
.mkt.nav { border: 1.5px dashed var(--muted); }  /* a fund: priced once a day */
.holds { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px 28px; }
.holds h3 { font-size: 13.5px; margin: 0; }
.holds p { font-size: 12px; margin: 0 0 6px; }
.holds-row { display: grid; grid-template-columns: minmax(0, 1fr) 70px 52px; gap: 8px; align-items: center; font-size: 13px; padding: 2px 0; }
.holds-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.holds-row .track { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.holds-row .track i { display: block; height: 100%; background: var(--series-1); border-radius: 2px; }
.holds-row .num { text-align: right; }
.markets { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.markets .chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px;
  border: 1px solid var(--border); border-radius: 99px; background: var(--surface);
  font-size: 12.5px; color: var(--ink-2);
}
.markets .chip b { color: var(--ink); font-weight: 600; }

/* ============================================================ pie */
.pie-wrap { display: grid; grid-template-columns: minmax(200px, 260px) minmax(0, 1fr); gap: 16px; align-items: center; }
.pie-wrap .chart { height: 260px; }
.pie-legend { display: grid; gap: 2px; font-size: 13px; }
.pie-legend .row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 3px 4px; border-radius: 4px; }
.pie-legend .row:hover { background: var(--hover); }
.pie-legend .sw { width: 10px; height: 10px; border-radius: 3px; }
.pie-legend .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pie-legend .val { color: var(--ink-2); }
.pie-legend .pct { font-weight: 600; min-width: 48px; text-align: right; }
@media (max-width: 560px) { .pie-wrap { grid-template-columns: minmax(0, 1fr); } }

td .sub { display: block; font-size: 12px; }
/* a US stock's price before the open or after the close: a quiet note under its price –
   smaller, paler and set apart from it */
.ext { color: var(--muted); font-size: 11px; font-weight: 400; }
.ext > span + span { margin-left: 4px; }
.ext .pos { color: color-mix(in srgb, var(--good-text) var(--faded), var(--surface)); }
.ext .neg { color: color-mix(in srgb, var(--bad-text) var(--faded), var(--surface)); }
td .sub.ext { margin-top: 6px; font-size: 11px; }
.detail-head .ext { padding: 5px 0 3px; font-size: 12px; }
.chart.h-daily { height: 220px; }

/* ============================================================ AI reports */
.badge.info { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); }
.meter { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--series-1) 18%, var(--surface)); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--series-1); border-radius: 3px; transition: width .4s; }
.meter.indeterminate > span { width: 30% !important; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button {
  border: 0; background: none; padding: 8px 14px; cursor: pointer; color: var(--ink-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 14px; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 550; }
.rating { font-size: 26px; font-weight: 650; letter-spacing: -0.01em; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 20px; }
.facts .label { color: var(--ink-2); font-size: 12.5px; }
/* a long email address breaks anywhere rather than widen the page on a phone */
.facts > div { min-width: 0; }
.facts .value { font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
/* the facts of the cards of the operator are a list of terms and values (<dl>): no browser margins */
dl.facts { margin: 0; }
.facts dd.value { margin: 2px 0 0; }
.facts > .wide { grid-column: span 2; }  /* a long word (the type of a webhook event) must not break in the middle */
/* on a phone the facts of the operator are two to a row (one column of sixteen is a screen and a half of numbers) */
@media (max-width: 560px) { dl.facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; } }
@keyframes spin { to { transform: rotate(360deg); } }
.feed { display: grid; gap: 4px; font-size: 13px; }
.feed .row { display: grid; grid-template-columns: 64px 1fr; gap: 8px; color: var(--ink-2); }
.feed .row .num { color: var(--muted); }
.log td { font-size: 12.5px; vertical-align: top; }
.log td.msg { word-break: break-word; }
.log td.msg .text { white-space: pre-wrap; }
.log pre { margin: 6px 0 0; padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 12px; max-height: 320px; overflow: auto; white-space: pre-wrap; }
.log tr.error td { background: color-mix(in srgb, var(--bad) 7%, transparent); }
.log tr.warning td { background: color-mix(in srgb, var(--warning) 9%, transparent); }
details.section { border-top: 1px solid var(--grid); }
details.section > summary { cursor: pointer; padding: 10px 0; font-weight: 600; list-style: none; display: flex; gap: 8px; align-items: center; }
details.section > summary::before { content: "▸"; color: var(--muted); font-size: 12px; }
details.section[open] > summary::before { content: "▾"; }
.team-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 2px; }
.chip-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; }
.chip-btn:hover { background: var(--hover); }
.checks { display: grid; gap: 6px; font-size: 13px; }
.checks .row { display: grid; grid-template-columns: 20px 150px 1fr; gap: 8px; align-items: start; }
.checks .ok { color: var(--good-text); }
.checks .fail { color: var(--bad-text); }

/* rendered markdown of a report (LLM output, sanitized) */
.md { line-height: 1.6; font-size: 14px; overflow-wrap: anywhere; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.2em 0 .5em; line-height: 1.3; }
.md h1 { font-size: 20px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15px; } .md h4 { font-size: 14px; }
.md p, .md ul, .md ol { margin: .6em 0; }
.md ul, .md ol { padding-left: 1.4em; }
.md table { width: auto; max-width: 100%; display: block; overflow-x: auto; margin: .8em 0; font-size: 13px; }
.md th, .md td { border: 1px solid var(--grid); padding: 5px 9px; }
.md th { background: var(--surface-2); color: var(--ink); }
.md pre { background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm); overflow-x: auto; }
.md blockquote { margin: .8em 0; padding: 2px 12px; border-left: 3px solid var(--baseline); color: var(--ink-2); }
.md hr { border: 0; border-top: 1px solid var(--grid); margin: 1.2em 0; }

/* ============================================================ AI report: the team at work
   The board and the steps of the welcome page (landing.css), in the app's colours */
.board, .desk {
  --m-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13l4.5 4.5L19 7'/%3E%3C/svg%3E");
  --m-dash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
  --m-cross: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E");
}
.board { container-type: inline-size; display: grid; gap: 6px; margin-top: 14px; }
.lane { --team: var(--baseline); display: grid; gap: 6px; padding: 5px 0 5px 11px; border-left: 3px solid var(--team); }
.lane[data-team="analysts"] { --team: var(--cat-1); }
.lane[data-team="research"] { --team: var(--cat-7); }
.lane[data-team="trading"] { --team: var(--cat-4); }
.lane[data-team="risk"] { --team: var(--cat-5); }
.lane[data-team="portfolio"] { --team: var(--ink); }
.lane-t { color: var(--muted); font-size: 11.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
@container (min-width: 600px) { .lane { grid-template-columns: 150px minmax(0, 1fr); align-items: center; } }
.pill {
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%; min-height: 28px; padding: 3px 11px 3px 9px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 13px; font-weight: 550;
  transition: background-color .3s, border-color .3s;
}
.pill .meta { color: var(--muted); font-size: 12px; font-weight: 450; }
.pill .meta:empty { display: none; }
.pill[data-state="working"] { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 11%, var(--surface)); }
.pill[data-state="waiting"] .nm, .pill[data-state="skipped"] .nm { color: var(--muted); }
/* the mark of a state: a ring (waiting), a spinner, a check, a cross, a dash */
.st { position: relative; display: inline-block; flex: none; width: 12px; height: 12px; border: 1.5px solid var(--muted); border-radius: 50%; }
[data-state="working"] > .st, [data-state="working"] > header > .st { border: 2px solid var(--accent); border-top-color: transparent; animation: spin .8s linear infinite; }
[data-state="done"] > .st, [data-state="done"] > header > .st,
[data-state="stopped"] > .st, [data-state="stopped"] > header > .st,
[data-state="skipped"] > .st, [data-state="skipped"] > header > .st {
  width: 13px; height: 13px; border: 0; border-radius: 0; -webkit-mask: var(--mark) center / 100% no-repeat; mask: var(--mark) center / 100% no-repeat;
}
[data-state="done"] > .st, [data-state="done"] > header > .st { --mark: var(--m-check); background: var(--good-text); animation: desk-pop .45s cubic-bezier(.34, 1.4, .5, 1); }
[data-state="stopped"] > .st, [data-state="stopped"] > header > .st { --mark: var(--m-cross); background: var(--bad-text); }
[data-state="skipped"] > .st, [data-state="skipped"] > header > .st { --mark: var(--m-dash); background: var(--muted); }

.live-report .meter, .desk .meter { margin-top: 0; }

.desk .card-head { align-items: flex-start; }
.desk .steps { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; padding: 0; list-style: none; }
.desk .steps button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 14px; border: 1px solid var(--border);
  border-radius: 999px; background: none; color: var(--ink-2); font-size: 13px; font-weight: 550; cursor: pointer;
  transition: background-color .2s, color .2s;
}
.desk .steps button:hover { background: var(--hover); color: var(--ink); }
.desk .steps button[aria-current="step"] { border-color: var(--ink); background: var(--ink); color: var(--surface); }
.desk .steps button[data-state="done"]::after { content: ""; width: 12px; height: 12px; background: var(--good-text); -webkit-mask: var(--m-check) center / 100% no-repeat; mask: var(--m-check) center / 100% no-repeat; }
.desk .steps button[data-state="done"][aria-current="step"]::after { background: var(--surface); }
.desk .steps button[data-state="working"]::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1s ease-in-out infinite; }

.desk .panel { display: grid; gap: 12px; align-content: start; animation: desk-rise .35s cubic-bezier(.2, .7, .2, 1); }
.acards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.duel, .trio { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.trio { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { .acards, .duel, .trio { grid-template-columns: minmax(0, 1fr); } }
.acard {
  display: grid; gap: 8px; align-content: start; min-width: 0; padding: 14px 16px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface-2); transition: border-color .3s, background-color .3s;
}
.acard header { display: flex; align-items: center; gap: 8px; }
.acard h3 { flex: 1; min-width: 0; font-size: 14px; font-weight: 650; }
.acard .meta { color: var(--muted); font-size: 12px; }
.acard[data-state="working"] { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.acard[data-state="waiting"] h3, .acard[data-state="skipped"] h3 { color: var(--muted); }
.desk .tx { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.desk .tx .w { animation: desk-word .35s ease-out backwards; }
.desk .hint, .desk .fine, .desk .role { margin: 0; color: var(--muted); font-size: 12.5px; }
.desk .round { justify-self: start; margin: 0; padding: 2px 12px; border: 1px solid var(--border); border-radius: 999px; color: var(--ink-2); font-size: 12.5px; font-weight: 600; }
.bub.bull { border-color: color-mix(in srgb, var(--accent) 35%, transparent); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); animation: desk-from-left .45s cubic-bezier(.2, .7, .2, 1); }
.bub.bear { border-color: color-mix(in srgb, var(--cat-7) 40%, transparent); background: color-mix(in srgb, var(--cat-7) 10%, var(--surface)); animation: desk-from-right .45s cubic-bezier(.2, .7, .2, 1); }
.queue-chip {
  justify-self: start; display: inline-flex; align-items: center; gap: 7px; margin: 0; padding: 2px 11px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); font-size: 12.5px; font-weight: 600;
}
.skel { display: grid; gap: 7px; }
.skel i { display: block; height: 9px; border-radius: 5px; background: linear-gradient(90deg, var(--hover) 25%, color-mix(in srgb, var(--accent) 22%, transparent) 50%, var(--hover) 75%) 0 0 / 300% 100%; animation: desk-shimmer 1.6s linear infinite; }
.skel i:nth-child(2) { width: 88%; }
.skel i:nth-child(3) { width: 62%; }
.desk-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 0; }
.desk-facts > div { min-width: 0; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.desk-facts dt { color: var(--muted); font-size: 12px; }
.desk-facts dd { margin: 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.decide .desk-facts > div { background: var(--surface); }

/* the sentiment: six words, a marker that slides to the one the analyst chose */
.mood { position: relative; padding-top: 16px; }
.mood-scale { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 3px; margin: 0; padding: 0; list-style: none; }
.mood-scale li { padding-top: 10px; border-top: 5px solid color-mix(in srgb, var(--series-1) 18%, transparent); border-radius: 3px; color: var(--muted); font-size: 12px; line-height: 1.25; text-align: center; }
.mood-scale li.res { color: var(--ink); font-weight: 650; text-decoration: underline; text-underline-offset: 3px; }
.mood-mark { position: absolute; top: 12px; left: calc(100% / 12 * (2 * var(--pos, 2) + 1)); width: 13px; height: 13px; margin-left: -6.5px; border-radius: 3px; background: var(--accent); transform: rotate(45deg); box-shadow: 0 0 0 3px var(--surface-2); animation: desk-mood 1s cubic-bezier(.34, 1.4, .5, 1) backwards .15s; }
.mood-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin: 10px 0 0; }
.mood-line b { font-size: 18px; }

/* the verdict: the five ratings, a marker on the one of the report – never green or red */
.verdict { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.scale { position: relative; flex: 1 1 340px; min-width: 0; height: 54px; }
.scale::before { content: ""; position: absolute; top: 16px; left: 10%; right: 10%; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 22%, transparent); }
.scale ol { margin: 0; padding: 0; list-style: none; }
.scale li { position: absolute; top: 34px; left: calc(10% + 20% * var(--i)); transform: translateX(-50%); color: var(--muted); font-size: 12px; white-space: nowrap; }
.scale li:nth-of-type(1) { --i: 0; } .scale li:nth-of-type(2) { --i: 1; } .scale li:nth-of-type(3) { --i: 2; }
.scale li:nth-of-type(4) { --i: 3; } .scale li:nth-of-type(5) { --i: 4; }
.scale li.res { color: var(--ink); font-weight: 650; text-decoration: underline; text-underline-offset: 3px; }
.scale .mark { position: absolute; top: 10px; left: calc(10% + 20% * var(--pos, 2)); width: 18px; height: 18px; margin-left: -9px; border: 3px solid var(--surface); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1.5px var(--accent); animation: desk-rating 1.1s cubic-bezier(.34, 1.4, .5, 1) backwards .15s; }
.rate { display: inline-flex; padding: 5px 22px; border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 999px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); font-size: 22px; font-weight: 650; animation: desk-pop .5s cubic-bezier(.34, 1.4, .5, 1) backwards .8s; }
@media (max-width: 560px) { .scale li:nth-of-type(even) { visibility: hidden; } .mood-scale li { font-size: 10.5px; } }

.desk-board { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--grid); }
.desk .feed { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--grid); }

/* the ticker of a new report, with what the search suggests */
.ticker-combo { width: 280px; max-width: 100%; }
.ticker-combo .combo-list { min-width: 340px; max-width: calc(100vw - 48px); }
.ticker-combo input::placeholder { text-transform: none; }
.picked { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@keyframes desk-rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes desk-word { from { opacity: 0; filter: blur(3px); } }
@keyframes desk-pop { from { opacity: 0; transform: scale(.5); } }
@keyframes desk-from-left { from { opacity: 0; transform: translateX(-18px); } }
@keyframes desk-from-right { from { opacity: 0; transform: translateX(18px); } }
@keyframes desk-shimmer { to { background-position: -300% 0; } }
@keyframes desk-mood { from { left: calc(100% / 12 * 5); } }
@keyframes desk-rating { from { left: 50%; } }
@media (prefers-reduced-motion: reduce) {
  .desk *, .board *, .live-report * { animation: none !important; transition: none !important; }
  [data-state="working"] > .st, [data-state="working"] > header > .st { border-top-color: var(--accent); }
}
@media (forced-colors: active) {
  .pill, .acard, .rate, .queue-chip { border: 1px solid CanvasText; }
  [data-state="done"] > .st, [data-state="done"] > header > .st, [data-state="stopped"] > .st, [data-state="stopped"] > header > .st { forced-color-adjust: none; background: CanvasText; }
}

/* ============================================================ sharing a portfolio === */
/* the page that makes a link: the choices beside the preview */
.share-setup { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .share-setup { grid-template-columns: minmax(0, 1fr); } }
.share-setup form { display: grid; gap: 14px; }
.share-setup form > .btn { justify-self: start; }
.share-setup form > .hint { margin: -6px 0 0; font-size: 12.5px; color: var(--muted); }
.share-setup label.check { align-items: flex-start; gap: 9px; margin-top: 0; font-size: 13.5px; line-height: 1.45; color: var(--ink); }
.share-setup label.check input { flex: none; margin-top: 3px; }
.share-setup .field .label { font-size: 12.5px; color: var(--ink-2); }
.share-setup .field > .segmented { justify-self: start; }
.share-sub { display: grid; gap: 10px; margin: -4px 0 0 24px; justify-items: start; }
.share-warning { display: flex; gap: 8px; margin: 0; background: var(--warning-bg); color: var(--warning-ink); }
.share-preview { display: grid; gap: 10px; min-width: 0; }
.share-preview-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.share-frame { border: 1px dashed var(--baseline); border-radius: var(--radius); padding: 16px; min-height: 120px; min-width: 0; transition: opacity .15s; }
.share-frame.loading { opacity: .55; }
.share-link { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.share-link input { flex: 1; min-width: 220px; }
/* what a link shows: the public page and the preview */
.share-main { max-width: 900px; }
.share-view { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.share-head h1 { margin: 0; overflow-wrap: anywhere; }
.share-head p { margin: 4px 0 0; }
.share-view .fine { margin: 0; color: var(--muted); font-size: 12.5px; }
.share-view .share-note { margin-top: 10px; }
.share-alloc { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 20px 32px; }
.share-ring { position: relative; width: 184px; height: 184px; }
.share-donut { display: block; width: 100%; height: 100%; }
.share-donut circle { fill: none; stroke-width: 5.5; }
.share-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0; line-height: 1.2; pointer-events: none; }
.share-center b { font-size: 28px; }
.share-center span { font-size: 12px; color: var(--muted); }
.share-legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 9px 28px; min-width: 0; }
.share-legend li { display: flex; align-items: baseline; min-width: 0; font-size: 13.5px; }
.share-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: auto; padding-right: 6px; }
.share-types { list-style: none; margin: 18px 0 16px; padding: 14px 0 0; border-top: 1px solid var(--grid); display: grid; gap: 9px; }
.share-types li { display: flex; align-items: center; gap: 14px; }
.share-type { width: 56px; flex: none; }
.share-track { flex: 1; min-width: 30px; height: 8px; border-radius: 4px; background: var(--grid); overflow: hidden; }
.share-track i { display: block; height: 100%; border-radius: 4px; background: var(--series-1); }
.share-types b { min-width: 52px; text-align: right; }
.share-money { min-width: 96px; text-align: right; }
.share-types .share-sum { justify-content: space-between; border-top: 1px solid var(--grid); padding-top: 9px; }
@media (max-width: 560px) {
  .share-alloc { grid-template-columns: minmax(0, 1fr); }
  .share-ring { justify-self: center; }
  .share-legend { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px 12px; }
  .share-legend .share-dot { margin-right: 6px; }
}
.share-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; background: var(--cat-other); }
.share-donut .share-c0 { stroke: var(--cat-other); }
.share-donut .share-c1 { stroke: var(--cat-1); }
.share-donut .share-c2 { stroke: var(--cat-2); }
.share-donut .share-c3 { stroke: var(--cat-3); }
.share-donut .share-c4 { stroke: var(--cat-4); }
.share-donut .share-c5 { stroke: var(--cat-5); }
.share-donut .share-c6 { stroke: var(--cat-6); }
.share-donut .share-c7 { stroke: var(--cat-7); }
.share-donut .share-c8 { stroke: var(--cat-8); }
.share-dot.share-c1 { background: var(--cat-1); }
.share-dot.share-c2 { background: var(--cat-2); }
.share-dot.share-c3 { background: var(--cat-3); }
.share-dot.share-c4 { background: var(--cat-4); }
.share-dot.share-c5 { background: var(--cat-5); }
.share-dot.share-c6 { background: var(--cat-6); }
.share-dot.share-c7 { background: var(--cat-7); }
.share-dot.share-c8 { background: var(--cat-8); }
.share-holding { overflow-wrap: anywhere; }
.share-name { font-size: 13px; }
.share-big { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0 0 12px; }
.share-big b { font-size: 32px; letter-spacing: -0.02em; }
.share-chart { margin: 0 0 14px; }
.share-chart svg { display: block; width: 100%; height: 160px; }
.share-bars svg { height: 96px; }
.share-zero { stroke: var(--baseline); stroke-width: 1; vector-effect: non-scaling-stroke; }
.share-line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.share-line.up { stroke: var(--good); }
.share-line.down { stroke: var(--bad); }
.share-area { stroke: none; opacity: .12; }
.share-area.up, .share-bars rect.up { fill: var(--good); }
.share-area.down, .share-bars rect.down { fill: var(--bad); }
.share-axis { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 4px; font-size: 12px; color: var(--muted); }
.share-periods { max-height: 360px; overflow-y: auto; }

/* ======================================================== signing in === */
/* the pages of signing in, registering and the links of mails (templates/_signin.html) */
.signin { max-width: 400px; margin: clamp(24px, 8vh, 12vh) auto 40px; padding: 0 16px; }
/* Contrast (WCAG AA: 4.5:1 for text this small). These pages and the legal pages carry the
   instructions of signing in, so they use darker values than the tokens: the muted grey is 3.5:1 on
   the card, the link blue 4.3:1, white on the primary blue 4.4:1 (3.6:1 in the dark theme). The
   other pages of the app keep the palette. A browser without color-mix keeps the tokens. */
.signin, .legal-page { --muted: var(--ink-2); --link: var(--accent); --accent-solid: var(--accent); }
@supports (color: color-mix(in srgb, red, blue)) {
  .signin, .legal-page {
    --link: color-mix(in srgb, var(--accent) 78%, var(--ink));  /* toward the text colour: darker on light, lighter on dark */
    --accent-solid: color-mix(in srgb, var(--accent) 80%, #000);
  }
}
.signin .btn.primary { background: var(--accent-solid); border-color: var(--accent-solid); }
.signin > .brand { justify-content: center; margin-bottom: 18px; font-size: 18px; }
.signin .card { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 24px; }
.signin .card p { margin: 0; }
.signin .card h2 { font-size: 14px; }
.signin .providers { display: grid; gap: 10px; }
.signin form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.signin form .btn, .signin .providers .btn { width: 100%; white-space: normal; text-align: center; }
.signin h1 + p { margin-top: 4px; }
.btn.provider { gap: 10px; min-height: 40px; font-weight: 550; }
/* a phone zooms into a field whose text is smaller than 16 px: the fields of these pages are not */
.signin input { font-size: 16px; }
.signin input[readonly] { background: var(--surface-2); color: var(--ink-2); text-overflow: ellipsis; }
.signin input[aria-invalid="true"] { border-color: var(--bad); }
.signin .hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.signin .address, .signin .card strong { overflow-wrap: anywhere; }  /* a long name or address wraps, it never widens the page */
.signin .links { display: flex; flex-wrap: wrap; gap: 0 18px; font-size: 13.5px; }
.signin .card a:not(.btn), .signin-foot a { color: var(--link); }
.signin .links a { display: inline-block; padding: 8px 0; }  /* a target a thumb finds */
.signin .terms-note { font-size: 12.5px; }
.signin .or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; }
.signin .or::before, .signin .or::after { content: ""; flex: 1; border-top: 1px solid var(--grid); }
/* the checkbox of the terms: the text beside it wraps under itself, never under the box */
.signin label.check { align-items: flex-start; font-size: 13px; line-height: 1.45; }
.signin label.check input { margin-top: 3px; flex: none; }
.pw-row { display: flex; gap: 8px; }
.pw-row input { flex: 1; min-width: 0; }
.signin .pw-row .btn { width: auto; flex: none; }
.pw-toggle[aria-pressed="true"] { background: var(--surface-2); border-color: var(--baseline); }
/* Cloudflare's widget is 300 px wide at the least: on a narrower card its box scrolls – the page
   does not, and the lines under it wrap */
.captcha { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.captcha-box { overflow-x: auto; }
.signin-foot { margin-top: 16px; text-align: center; color: var(--muted); font-size: 13px; }
.signin-foot a { display: inline-block; padding: 8px 4px; text-decoration: none; }
.signin-foot a:hover { text-decoration: underline; }
@media (max-width: 400px) {
  .signin { padding: 0 8px; }
  .signin .card { padding: 16px; }
}
@media (pointer: coarse) {
  .signin .btn, .signin input:not([type="checkbox"]) { min-height: 44px; }
  .signin input[type="checkbox"] { width: 20px; height: 20px; }
}

/* ============================================================ account */
.logo { flex: none; }
.provider { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.new-token { display: grid; gap: 8px; margin: 0 20px 16px; }
.new-token p { margin: 0; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.copy-row code { flex: 1; padding: 6px 9px; }
.token-form { display: flex; gap: 12px 14px; flex-wrap: wrap; align-items: end; padding: 0 20px 16px; }
.token-form .field:first-child { flex: 1; min-width: 200px; max-width: 360px; }
td code { white-space: nowrap; overflow-wrap: normal; }  /* a token's start in one piece */
.as-list .address { overflow-wrap: anywhere; }  /* a long address wraps, the table stays */
/* on a phone the account's tables are lists: a block per row – its cells one below the other,
   named by their data-label – with its button (Remove, Revoke) on the right of the first */
@media (max-width: 560px) {
  table.as-list, table.as-list tbody { display: block; }
  table.as-list thead { display: none; }
  table.as-list tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: start;
    padding: 10px 20px; border-bottom: 1px solid var(--grid);
  }
  table.as-list tbody tr:last-child { border-bottom: 0; }
  table.as-list td { grid-column: 1; padding: 0; border: 0; text-align: left; }
  table.as-list td.sym { white-space: normal; overflow-wrap: anywhere; }
  table.as-list td.r { grid-column: 2; grid-row: 1; }
  table.as-list td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); }
}

/* ============================================ account: the own account, danger zone === */
/* minmax(0, 1fr): a long address in a label wraps, it never widens the card */
.inline-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; max-width: 420px; margin-bottom: 12px; }
.card > .stack-sm, .card .stack-sm { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.card .stack-sm p { margin: 0; }
.card.flush .inline-form { margin: 0 20px 12px; }
.inline-form .btn { white-space: normal; text-align: center; }  /* "Delete my account and all data" on a phone */
.address { overflow-wrap: anywhere; }
.notice.line { margin: 12px 0 0; }
.card.flush > .notice.line { margin: 0 20px 12px; }
.field .hint { margin: 0; }
.inline-form .hint, .stack-sm .hint { color: var(--ink-2); }  /* the password rule, where the link was mailed */
.inline-form > .hint { font-size: 12px; margin: 0; }  /* a note under the fields, as the ones in a field */
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 550; }
.btn.danger-solid:hover { filter: brightness(1.08); }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.danger-zone h2 { color: var(--bad-text); }
.danger-zone h2:focus, .card h2:focus { outline: none; }
.card .pw-row { display: flex; gap: 8px; }
.card .pw-row input { flex: 1; min-width: 0; }
.card .pw-toggle[aria-pressed="true"] { background: var(--surface-2); border-color: var(--baseline); }
@media (pointer: coarse) {
  .inline-form .btn, .inline-form input:not([type="checkbox"]) { min-height: 44px; }
}

/* the line under every page of the app: Terms · Privacy · who runs it */
.app-foot { max-width: 1320px; margin: 0 auto; padding: 0 24px 28px; color: var(--muted); font-size: 12.5px; text-align: center; }
.app-foot a { display: inline-block; padding: 6px 2px; text-decoration: none; }
.app-foot a:hover { text-decoration: underline; }
@media (max-width: 720px) { .app-foot { padding: 0 16px 24px; } }
@media (max-width: 560px) { .inline-form input { font-size: 16px; } }

/* ============================================================ credits and the AI notices === */
/* Tokens only: the dark values come with the theme. No colour of alarm anywhere - a balance of
   0 is a number, not a warning. */

/* the balance in the header: a link to the credits of the Account page (a link, not a button, and
   not live - the script updates the number, a screen reader is told what happened elsewhere) */
.credit-chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 99px; background: var(--surface); color: var(--ink);
  font-size: 13px; text-decoration: none; white-space: nowrap;
}
.credit-chip:hover { background: var(--hover); }
.credit-chip svg { flex: none; color: var(--ink-2); }
.credit-chip-n { font-variant-numeric: tabular-nums; font-weight: 550; }
/* on a phone: the icon and the number; the words stay in the accessible name */
@media (max-width: 560px) {
  .credit-chip-unit { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
@media (pointer: coarse) { .credit-chip { min-height: 44px; } }

/* the New report card: the balance line, the notices that are said once, the sentence for a program */
.card-head .credit-balance-line { color: var(--ink); font-weight: 550; }
.credit-notices { display: grid; gap: 8px; margin: 0 0 14px; }
.credit-notice-text { flex: 1; min-width: 0; }
.ai-note { margin: 8px 0 0; font-size: 12.5px; }

/* the top of a report: an AI wrote it (the banner), and the lines under it */
.ai-banner-text { flex: 1; min-width: 0; }
.ai-banner-text p { margin: 0 0 4px; }
.ai-banner-text p:last-child { margin-bottom: 0; }
.ai-footer p { margin: 0 0 4px; }

/* Account > Credits: the card is not flush, so its tables sit on the card's own text edge; the
   chip links to #credits, and the sticky header must not cover the top of the card it lands on */
.credits-card, #credits { scroll-margin-top: 72px; }
.credits-card h3 { font-size: 14px; }
.credits-card .facts .value.credit-balance { font-size: 24px; letter-spacing: -0.02em; }
.credits-card th:first-child, .credits-card td:first-child { padding-left: 0; }
.credits-card th:last-child, .credits-card td:last-child { padding-right: 0; }
.credits-card td.sym { white-space: normal; }
@media (min-width: 561px) { .credits-card th.delta, .credits-card td.delta { text-align: right; } }
@media (max-width: 560px) {
  .credits-card table.as-list tr { padding-left: 0; padding-right: 0; }
}
/* a finger: the buttons of the credit cards are 44 px (the dismiss cross grows into the notice's
   padding, so the notice stays as high as it was) */
@media (pointer: coarse) {
  .credits-card .btn { min-height: 44px; }
  .credits-card .notice-close, .credit-notices .notice-close { width: 44px; height: 44px; margin: -13px -14px -13px 0; }
}

/* Where credits can be bought. The banner of the return from Stripe stands at the top of the card; a
   notice that carries a link or buttons keeps its text in one block (a .notice is a row of boxes) and
   the depths a refusal offers are buttons beside the sentence. Tokens only; a selected pack is told
   by the ring and by the radio that is checked, never by colour alone. */
.credits-banner { margin: 12px 0; }
.notice-body { flex: 1; min-width: 0; }
.notice-body a { color: inherit; font-weight: 550; text-decoration: underline; }
.refusal-actions { display: inline-flex; flex-wrap: wrap; gap: 8px; margin-left: 8px; vertical-align: middle; }
.credits-pending { margin: 0; }

/* Buy credits: the packs side by side (one column on a phone), the same weight, none chosen */
.checkout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; max-width: 640px; margin-bottom: 14px; }
.checkout h3:focus { outline: none; }
/* the sentence that stands in place of the form for a buyer who cannot buy just now: the room the form leaves */
.credits-card #credits-buy-note { margin-bottom: 14px; }
.pack-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 0; padding: 0; border: 0; min-width: 0; }
.pack-card {
  position: relative; display: grid; gap: 2px; padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink-2);
}
.pack-card:hover { border-color: var(--baseline); }
.pack-card.selected { box-shadow: 0 0 0 2px var(--accent); }
.pack-card:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.pack-price { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); }
.pack-credits { font-weight: 550; color: var(--ink); }
.pack-per { font-size: 12.5px; color: var(--muted); }
.order-summary { display: grid; gap: 6px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink-2); font-size: 13px; }
.order-summary p { margin: 0; }
.order-total { color: var(--ink); font-weight: 550; }
.before-title { color: var(--ink); font-weight: 600; }
.checkout .checks { display: grid; gap: 10px; }
.checkout label.check { align-items: flex-start; margin-top: 0; font-size: 13px; line-height: 1.45; }
.checkout label.check input { flex: none; margin-top: 2px; }
.checkout label.check a { color: var(--ink); }
.checkout .btn { white-space: normal; text-align: center; }
.checkout .btn[aria-busy="true"] { cursor: progress; }
@media (max-width: 560px) {
  .pack-grid { grid-template-columns: minmax(0, 1fr); }
  .checkout .btn { width: 100%; }
}
/* a finger: the packs and the boxes are targets of 44 px, the boxes themselves 20 px (as the sign-in's) */
@media (pointer: coarse) {
  .pack-card { min-height: 44px; }
  .checkout label.check { min-height: 44px; }
  .checkout input[type="checkbox"] { width: 20px; height: 20px; }
  .refusal-actions .btn { min-height: 44px; }
}

/* Your purchases (the script draws it from the data, like the banner): the table of the Credits card, the
   receipt and the withdrawal buttons, and the panel of a withdrawal under its row. Tokens only. A button
   that is busy is aria-disabled, not disabled: it keeps the keyboard the user is on. */
.credits-purchases h4 { margin: 0; font-size: 14px; }
.credits-purchases h4:focus, .purchase-note:focus { outline: none; }
.credits-purchases .purchase-state, .credits-purchases .purchase-note { margin: 4px 0 0; font-size: 12.5px; }
.credits-purchases .purchase-alert { color: var(--bad-text); }
.credits-purchases td.actions { white-space: normal; }
.credits-purchases td.actions .btn { margin-left: 8px; }
.credits-purchases td.span { padding-top: 0; }
.withdraw { max-width: 520px; margin: 4px 0 8px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.withdraw p { margin: 0; }
.withdraw .form-actions { margin-top: 2px; }
.btn[aria-disabled="true"] { opacity: .5; cursor: progress; filter: none; }
@media (max-width: 560px) {
  .credits-purchases table.as-list td.actions { grid-column: 1 / -1; grid-row: auto; display: flex; flex-wrap: wrap; gap: 8px; }
  .credits-purchases table.as-list td.actions .btn { margin-left: 0; }
  .credits-purchases table.as-list td.span { grid-column: 1 / -1; }
  .credits-purchases table.as-list tr.purchase-panel { padding-top: 0; }
  .withdraw { max-width: none; }
}

/* ============================================== legal pages: terms, privacy === */
/* standalone like .signin (no app shell), with a text column that reads well; every class
   here starts with legal- (templates/_legal.html) */
.legal-page { max-width: 760px; margin: 6vh auto 40px; padding: 0 16px; }
.legal-page > .brand { justify-content: center; margin-bottom: 18px; font-size: 18px; }
.legal-card { padding: 28px 32px; font-size: 15px; line-height: 1.6; }
.legal-head { margin-bottom: 14px; }
.legal-version { margin: 4px 0 0; }
.legal-card p, .legal-card ul, .legal-card ol { margin: 0 0 12px; }
.legal-lead { color: var(--ink-2); }
.legal-card a { color: var(--link); }
.legal-card h2 { margin: 26px 0 8px; font-size: 17px; scroll-margin-top: 16px; }
.legal-toc ol { columns: 2 260px; margin: 0 0 6px; padding-left: 1.5em; }
.legal-toc li { break-inside: avoid; margin-bottom: 2px; }
.legal-list { padding-left: 1.3em; }
.legal-list li { margin-bottom: 8px; }
.legal-draft { margin: 0 0 18px; }
.legal-todo, .legal-flag { background: var(--warning-bg); color: var(--warning-ink); border-radius: 4px; padding: 0 4px; }
.legal-todo { font-weight: 600; }
.legal-flag { font-size: 12.5px; }
.legal-hint { color: var(--muted); font-size: 12.5px; }
.legal-foot { margin-top: 16px; text-align: center; color: var(--muted); font-size: 13px; }
.legal-foot a { display: inline-block; padding: 8px 4px; text-decoration: none; }
.legal-foot a:hover { text-decoration: underline; }
.legal-foot a[aria-current="page"] { color: var(--ink); }
.legal-table { margin: 8px 0 14px; font-size: 13.5px; line-height: 1.5; }
.legal-table th, .legal-table td { padding: 10px 14px 10px 0; vertical-align: top; }
.legal-table tbody th { width: 36%; font-size: inherit; font-weight: 400; color: inherit; white-space: normal; }
.legal-table tbody tr:last-child > * { border-bottom: 0; }
@media (max-width: 640px) {
  .legal-page { margin-top: 3vh; }
  .legal-card { padding: 20px 16px; }
  /* a row of the tables is a block, its cells one below the other, named by their data-label */
  .legal-table, .legal-table tbody, .legal-table tr, .legal-table tbody th, .legal-table td { display: block; width: auto; }
  .legal-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .legal-table tr { padding: 12px 0; border-bottom: 1px solid var(--grid); }
  .legal-table tbody th, .legal-table td { padding: 2px 0; border: 0; }
  .legal-table tbody tr:last-child { border-bottom: 0; }
  .legal-table tbody th { margin-bottom: 4px; }
  .legal-table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); }
}
