/* p2pDashboard, hosted -- the local app's stylesheet (app/web/static/app.css), then the hosted
   additions at the end. One stylesheet, no external fonts or assets. */

/* Dark is the default, whatever the operating system prefers. */
:root {
  --bg: #0f141b;
  --surface: #161d27;
  --surface-2: #1d2633;
  --border: #2a3442;
  --text: #e6eaf0;
  --muted: #93a0b1;
  --accent: #5b93f0;
  --accent-text: #0b1220;
  --pos: #4cc17f;
  --neg: #f07167;
  --danger: #f04438;
  --radius: 10px;
  --shadow: none;
  /* Chart tokens. Categorical order is fixed (never cycled) and was validated
     against the card surface in both schemes. */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --chart-context: #898781;
  --chart-grid: #2a3442;
  --chart-axis: #3a4555;
  --chart-ink: #93a0b1;
  --marker: #ffffff;
  --marker-ink: #0b0b0b;
  /* Regulatory tiers: one neutral ramp, strongest regulation brightest, so the
     ring stays apart from the platforms' colours. Unknown is hatched. */
  --tier-1: #e3e7ec;
  --tier-2: #aeb6c1;
  --tier-3: #7d8796;
  --tier-4: #56606e;
  color-scheme: dark;
}

/* Light scheme, kept validated for an explicit opt-in (<html data-theme="light">).
   Slots 3-5 are below 3:1 on white, so every chart ships a legend and a table view. */
:root[data-theme="light"] {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --text: #1c2330;
  --muted: #5f6b7a;
  --accent: #2f6fdb;
  --accent-text: #ffffff;
  --pos: #1a7f45;
  --neg: #c0392b;
  --danger: #b42318;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --chart-context: #898781;
  --chart-grid: #e1e0d9;
  --chart-axis: #c3c2b7;
  --chart-ink: #898781;
  --tier-1: #343c47;
  --tier-2: #66707c;
  --tier-3: #98a0ab;
  --tier-4: #c4c9d0;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.underlined { text-decoration: underline; text-underline-offset: 2px; }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
code { background: var(--surface-2); padding: 0 .3em; border-radius: 4px; font-size: .9em; }

/* Layout: menu bar across the top, content centred below it. */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1800px; margin: 0 auto;
  display: flex; align-items: center; gap: 1.5rem;
  padding: .6rem 2rem;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); flex: none; }
.brand:hover { text-decoration: none; }
.brand span { color: var(--accent); }

/* min-width: 0 lets the menu shrink and scroll on its own instead of
   widening the whole page. */
.topnav {
  display: flex; gap: .25rem; min-width: 0;
  overflow-x: auto; scrollbar-width: none;
}
.topnav::-webkit-scrollbar { display: none; }
.topnav a { padding: .45rem .85rem; border-radius: 8px; color: var(--text); white-space: nowrap; }
.topnav a:hover { background: var(--surface-2); text-decoration: none; }
.topnav a.current { background: var(--surface-2); font-weight: 600; }

.topbar-end { margin-left: auto; display: flex; align-items: center; gap: .75rem; flex: none; }
.local-badge {
  font-size: .75rem; color: var(--muted); white-space: nowrap;
  padding: .15rem .55rem; border: 1px solid var(--border); border-radius: 999px;
}

.theme-toggle { display: flex; gap: .2rem; padding: .2rem; background: var(--surface-2); border-radius: 9px; }
.theme-toggle[hidden] { display: none; }
.theme-toggle button {
  display: inline-grid; place-items: center;
  border: 0; border-radius: 7px; padding: .35rem .45rem; cursor: pointer;
  background: transparent; color: var(--muted);
}
.theme-toggle svg { display: block; }
.theme-toggle button:hover { color: var(--text); }
.theme-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.theme-toggle button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* The language switch beside the colour scheme: the same plate, one button. */
.language-toggle { display: flex; padding: .2rem; background: var(--surface-2); border-radius: 9px; margin: 0; }
.language-toggle button, a.language-toggle {
  display: inline-flex; align-items: center; gap: .3rem;
  border: 0; border-radius: 7px; padding: .3rem .45rem; cursor: pointer;
  background: transparent; color: var(--muted); font: inherit; font-size: .75rem; font-weight: 600;
  letter-spacing: .03em; text-decoration: none;
}
a.language-toggle { padding: .5rem .65rem; }
.language-toggle svg { display: block; }
.language-toggle button:hover, a.language-toggle:hover { color: var(--text); }
.language-toggle button:focus-visible, a.language-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

main { max-width: 1800px; margin: 0 auto; padding: 1.75rem 2rem 3rem; min-width: 0; }

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.page-head p { margin: .25rem 0 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin: 0 0 .25rem !important; }
.section-title { margin-top: 1.75rem; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem;
}
.card.callout { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; flex-wrap: wrap; margin-top: 1.5rem; }
.card.callout p { margin: 0; }
.empty { text-align: center; padding: 3rem 1rem; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

/* Text helpers */
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.badge { font-size: .75rem; font-weight: 500; vertical-align: middle; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); }

/* Buttons */
.button {
  display: inline-block; border: 0; cursor: pointer;
  padding: .55rem 1rem; border-radius: 8px;
  background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 600;
}
.button:hover { filter: brightness(1.08); text-decoration: none; }
.button.danger { background: var(--danger); color: #fff; }
.button.danger:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.button.danger-outline { background: transparent; color: var(--neg); border: 1px solid var(--neg); font-weight: 500; }
.button.secondary { background: var(--surface-2); color: var(--text); font-weight: 500; }

.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.notice { border-left: 3px solid var(--accent); font-size: .9rem; color: var(--muted); }
.notice p { margin: 0 0 .4rem; }
.notice p:last-child { margin-bottom: 0; }
.scope { display: flex; align-items: flex-end; gap: .5rem; }
.head-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
/* Long references (project names, free text) are cut with an ellipsis; the
   full text is in the cell's tooltip. */
td.reference { max-width: 22rem; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.export-hint { margin: -.25rem 0 1rem; padding: .55rem .8rem; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 8px 8px 0; font-size: .9rem; }

table.unrecognised td { vertical-align: top; white-space: normal; }
table.unrecognised td:first-child { white-space: nowrap; }
table.unrecognised .num, table.unrecognised th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cells { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .1rem .75rem; margin: 0; font-size: .82rem; }
.cells dt { color: var(--muted); }
.cells dd { margin: 0; overflow-wrap: anywhere; }
/* Platform page: tabs and the "more actions" menu side by side. */
/* Tab bar and menu button share one height; the button is square and ends
   flush with the content's right edge. */
.head-actions { --bar: 2.625rem; display: flex; align-items: center; gap: .5rem; }
.head-actions .tabs { height: var(--bar); align-items: center; }
.actions-menu { position: relative; flex: none; }
.actions-menu > summary { list-style: none; }
.actions-menu > summary::-webkit-details-marker { display: none; }
.icon-button {
  display: flex; align-items: center; justify-content: center;
  width: var(--bar, 2.25rem); height: var(--bar, 2.25rem);
  border-radius: 9px; background: var(--surface-2); color: var(--text); cursor: pointer;
  font-size: 1.25rem; line-height: 1; user-select: none;
}
.icon-button:hover, .actions-menu[open] > .icon-button { background: var(--border); }
.icon-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.menu {
  position: absolute; right: 0; top: calc(100% + .35rem); z-index: 20; min-width: 15rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: .35rem; box-shadow: 0 8px 24px rgb(0 0 0 / 25%);
}
.menu-caption { margin: .25rem .5rem .2rem; font-size: .75rem; color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: .35rem .25rem; }
.menu button {
  display: flex; width: 100%; align-items: center; gap: .75rem; padding: .45rem .6rem;
  border: 0; border-radius: 6px; background: transparent; color: var(--text);
  font: inherit; font-size: .9rem; text-align: left; cursor: pointer;
}
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); outline: none; }
.menu button[aria-disabled="true"] { color: var(--muted); cursor: default; }
.menu button[aria-disabled="true"]:hover { background: transparent; }
.menu .count { margin-left: auto; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.menu .danger-item { color: var(--neg); }

/* Confirmation dialogs (<dialog>), opened by data-dialog buttons. */
dialog.confirm {
  width: min(28rem, calc(100vw - 2rem)); padding: 1.25rem 1.4rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
dialog.confirm::backdrop { background: rgb(0 0 0 / 50%); }
dialog.confirm h2 { margin: 0 0 .5rem; font-size: 1.1rem; }
dialog.confirm p { margin: 0; color: var(--muted); line-height: 1.55; font-size: .9rem; }
dialog.confirm label { margin-top: 1rem; }
dialog.confirm label input { margin-top: .2rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }
.flash { margin: -.75rem 0 1.25rem; padding: .55rem .8rem; border-left: 3px solid var(--pos); background: var(--surface-2); border-radius: 0 8px 8px 0; font-size: .9rem; }

/* The transactions page: filter row and pager. */
.filters { margin: -.25rem 0 1rem; }
.filters form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; }
.filters .grow { flex: 1 1 14rem; }
.filters .link-button { align-self: center; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: .75rem; flex-wrap: wrap; }
.pager .pages { display: flex; align-items: center; gap: .75rem; }

/* A centred check box column inside a table of numbers. */

/* Sortable columns: the header is a button; its arrow shows the order. */
th button.sort {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: .25rem;
  font: inherit; color: inherit;
}
th button.sort:hover, th button.sort:focus-visible { color: var(--text); }
th button.sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
th[aria-sort] .sort-arrow::after { content: "↕"; opacity: .5; }
th[aria-sort="descending"] .sort-arrow::after { content: "↓"; opacity: 1; }
th[aria-sort="ascending"] .sort-arrow::after { content: "↑"; opacity: 1; }
tfoot tr.total td { border-top: 2px solid var(--border); border-bottom: 0; }
tfoot tr.total.sub td { border-top: 0; padding-top: .15rem; }

table.numbers tr.show-more-row td { text-align: left; border-bottom: 0; padding: .5rem 0; }
tbody tr.show-more-row:hover { background: none; }
.show-more {
  display: inline-flex; align-items: center; gap: .4rem;
  border: 1px solid var(--border); border-radius: 8px; padding: .35rem .8rem; cursor: pointer;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: .85rem;
}
.show-more:hover { border-color: var(--accent); }
.show-more:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Down-pointing chevron drawn with borders, so no icon file is needed. */
.show-more .chevron {
  width: .45rem; height: .45rem; margin-top: -.2rem;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg);
}
.show-more.up .chevron { transform: rotate(-135deg); margin-top: .25rem; }
.show-more + .show-more { margin-left: .5rem; }
/* display: inline-flex above would otherwise beat the hidden attribute. */
.show-more[hidden] { display: none; }
.link-button { border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.kpi-label { color: var(--muted); font-size: .8rem; }
.kpi-value { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: .15rem; }
.kpi-hint { color: var(--muted); font-size: .78rem; margin-top: .2rem; }
.kpi-form { margin-top: .5rem; }
.kpi-form label { font-size: .78rem; margin-bottom: .4rem; }
.kpi-input { display: flex; gap: .4rem; }
.kpi-input input { min-width: 0; flex: 1; width: 6rem; padding: .3rem .5rem; font-size: .85rem; }
.kpi-input .button { padding: .3rem .7rem; font-size: .85rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: .45rem .5rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: .8rem; text-align: left; }
/* Long headings ("Withholding Tax", "Monthly Avg Income") wrap onto two lines
   instead of widening their column; the figures below stay on one line. */
table.numbers th { white-space: normal; vertical-align: bottom; }
/* The statement has the most columns; a slightly smaller face keeps it unscrolled. */
table.statement { font-size: .88rem; }
table.statement tr.month td { background: var(--surface-2); color: var(--muted); font-size: .85em; }
table.statement tr.month td:first-child { padding-left: 1.4rem; }
table.numbers td, table.numbers th { text-align: right; font-variant-numeric: tabular-nums; }
table.numbers td:first-child, table.numbers th:first-child, table.numbers td.text, table.numbers th.text { text-align: left; }
tbody tr:hover { background: var(--surface-2); }

/* Platform cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.card-grid.dimmed { opacity: .7; }
.account-card {
  display: block; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow);
}
.account-card:hover { border-color: var(--accent); text-decoration: none; }
.account-card .last-record { font-size: .72rem; }
.account-card-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.figures { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; margin: 0 0 .6rem; font-variant-numeric: tabular-nums; }
.figures dt { color: var(--muted); font-size: .85rem; }
.figures dd { margin: 0; text-align: right; }

.monogram {
  display: inline-grid; place-items: center; flex: none;
  width: 2.2rem; height: 2.2rem; border-radius: 8px;
  background: var(--surface-2); color: var(--accent); font-weight: 700; text-transform: uppercase;
}
.monogram.tile-mark { width: 3rem; height: 3rem; font-size: 1.1rem; }
.monogram.head-mark { width: 2.8rem; height: 2.8rem; font-size: 1rem; }
.monogram.row-mark { width: 1.6rem; height: 1.6rem; font-size: .65rem; border-radius: 5px; }

/* Platform logos are mostly dark wordmarks, so they sit on a light plate in
   both colour schemes. The light grey-blue is the plate the logos were drawn
   for; pure white would hide the few with white lettering. */
.logo-plate {
  display: inline-flex; flex: none; box-sizing: border-box;
  background: #e2e8f0; border: 1px solid var(--border); border-radius: 8px;
  padding: .3rem .5rem; width: 5.5rem; height: 2.2rem;
}
/* Logos drawn in white (app.catalogue.DARK_PLATES) and pale ones (BRIGHT_PLATES). */
.logo-plate.plate-dark { background: #1e293b; }
.logo-plate.plate-bright { background: #f8fafc; }
/* Logos the user wants on plain white (app.catalogue.WHITE_PLATES). */
.logo-plate.plate-white { background: #fff; }
/* Fill the padded box and let object-fit keep the aspect ratio; max-height
   alone does not constrain an image inside a flex or grid item. */
.logo-plate img { display: block; width: 100%; height: 100%; object-fit: contain; }
.logo-plate.tile-mark { width: 100%; height: 3rem; padding: .4rem .6rem; }
.logo-plate.head-mark { width: 7rem; height: 2.8rem; }
.logo-plate.row-mark { width: 3.6rem; height: 1.6rem; padding: .15rem .3rem; border-radius: 5px; }

.title-with-mark { display: flex; align-items: center; gap: 1rem; }
.name-with-mark { display: inline-flex; align-items: center; gap: .6rem; }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: .3rem; margin: .7rem 0 0; padding: 0; }
.chips li { font-size: .75rem; padding: .1rem .55rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 1rem; max-width: 560px; }
.stack .actions { display: flex; align-items: center; gap: 1rem; }
.checklist { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; margin: 0; display: grid; gap: .5rem; }
.checklist legend { font-size: .85rem; color: var(--muted); padding: 0 .3rem; }

/* Platform picker */
.filter {
  width: 100%; max-width: 420px; margin-bottom: 1rem;
  padding: .55rem .8rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  padding: 1rem .5rem; cursor: pointer;
  background: var(--surface); color: var(--text); font: inherit;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.tile:hover, .tile:focus-visible { border-color: var(--accent); outline: none; }
.tile-name { font-size: .85rem; text-align: center; }

/* Tabs */
.tabs { display: flex; gap: .25rem; background: var(--surface-2); padding: .25rem; border-radius: 9px; }
.tabs a { padding: .35rem .9rem; border-radius: 7px; color: var(--muted); }
.tabs a.current { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem 1rem; align-items: end; }
.form-grid .wide { grid-column: span 2; }
.form-grid .actions { grid-column: 1 / -1; }
.form-grid .row { grid-column: 1 / -1; }
.form-grid .row select { display: block; max-width: 24rem; }
.field-hint { display: block; margin-top: .3rem; color: var(--muted); font-size: .78rem; font-weight: 400; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); }
input, textarea, select {
  padding: .5rem .65rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit;
}
select.compact { padding: .3rem .5rem; font-size: .85rem; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.upload { display: flex; flex-direction: column; gap: 1rem; }
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.5rem;
  align-items: center; text-align: center; color: var(--muted); cursor: pointer;
}
.dropzone:hover { border-color: var(--accent); }
.modes { border: 0; padding: 0; margin: 0; display: grid; gap: .5rem; }
.modes legend { font-size: .85rem; color: var(--muted); margin-bottom: .4rem; }
.modes label { flex-direction: row; align-items: flex-start; gap: .6rem; color: var(--text); font-size: .9rem; }
.modes input { margin-top: .3rem; }

.help { margin-top: 1rem; color: var(--muted); font-size: .9rem; }
.help summary { cursor: pointer; color: var(--text); }

.result-list { list-style: none; padding: 0; margin: 0 0 .75rem; display: grid; gap: .4rem; }
.result { padding: .55rem .8rem; border-radius: 8px; background: var(--surface-2); }
.result.error { border-left: 3px solid var(--danger); }
.result.ok { border-left: 3px solid var(--pos); }

.danger-zone { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.danger-zone p { margin: 0; color: var(--muted); font-size: .9rem; }

/* Charts */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 1.25rem; }
.chart-grid > .card { margin-top: 0; margin-bottom: 0; }
/* Two cards side by side keep their heading, description and chart on common
   rows, so that the rings begin at the same height whatever the text wraps to. */
.chart-grid.aligned > .card { display: grid; grid-template-rows: subgrid; grid-row: span 3; row-gap: 0; }
.chart-grid + .card, .chart-grid + .chart-grid { margin-top: 1.25rem; }
.card-sub { margin: -.5rem 0 .75rem; color: var(--muted); font-size: .85rem; }

.chart { position: relative; margin: 0; outline: none; }
.chart:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis { stroke: var(--chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--chart-ink); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart .wash { opacity: .10; }
.chart .crosshair { stroke: var(--chart-axis); stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }
.chart .hit { cursor: crosshair; }
.chart .col { transition: opacity .12s; }
.chart .marker { fill: var(--marker); stroke: var(--marker-ink); stroke-width: 1.5; pointer-events: none; }

/* Zoom bar under an income chart: the whole run of months, the window shown. */
.zoom { margin-top: .6rem; user-select: none; touch-action: none; }
.zoom-strip { position: relative; height: 34px; }
.zoom-strip svg { display: block; width: 100%; height: 100%; overflow: hidden; }
.zoom-strip svg rect { fill: var(--series-1); opacity: .55; }
.zoom-shade { position: absolute; top: 0; bottom: 0; background: rgb(128 128 128 / 22%); pointer-events: none; }
.zoom-shade.l { left: 0; }
.zoom-shade.r { right: 0; }
.zoom-win { position: absolute; top: 0; bottom: 0; box-sizing: border-box; border: 1.5px solid var(--accent); border-radius: 4px; cursor: grab; outline: none; }
.zoom-win:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.zoom-grip { position: absolute; top: 0; bottom: 0; width: 12px; cursor: ew-resize; display: flex; align-items: center; justify-content: center; }
.zoom-grip.l { left: -7px; }
.zoom-grip.r { right: -7px; }
.zoom-grip::before { content: ""; width: 3px; height: 14px; border-radius: 2px; background: #fff; box-shadow: 0 0 0 1px var(--accent); }
.zoom-years { position: relative; height: 1rem; margin-top: .15rem; font-size: 11px; color: var(--chart-ink); }
.zoom-years span { position: absolute; top: 0; }
.chart.hovering .col:not(.active) { opacity: .45; }

.chart-tooltip {
  position: absolute; z-index: 2; pointer-events: none; min-width: 9rem;
  padding: .5rem .65rem; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgb(0 0 0 / 18%); font-size: .82rem;
}
.tt-label { color: var(--muted); margin-bottom: .3rem; }
.tt-row { display: grid; grid-template-columns: .9rem auto 1fr; align-items: center; gap: .45rem; }
.tt-key { width: .9rem; height: 2px; border-radius: 1px; }
.tt-value { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.tt-name { color: var(--muted); }
.tt-total { border-top: 1px solid var(--border); margin-top: .3rem; padding-top: .3rem; }
/* A sum in the tooltip: sign, name, amount; the last line is the result. */
.tt-calc { display: grid; grid-template-columns: .9rem 1fr auto; align-items: baseline; column-gap: .45rem; row-gap: .1rem; }
.tt-calc .tt-sign { color: var(--muted); }
.tt-calc .tt-name { color: var(--text); }
.tt-calc.tt-total .tt-name, .tt-calc.tt-total .tt-value { font-weight: 650; }
.tt-calc .tt-rule { border-top: 1px solid var(--border); margin-top: .2rem; padding-top: .2rem; }
.tt-calc .tt-rule.tt-name, .tt-calc .tt-rule.tt-value { font-weight: 650; }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem 1rem; margin: .6rem 0 0; padding: 0; font-size: .82rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: .4rem; }
.key { display: inline-block; background: var(--key); }
.key.line { width: 14px; height: 2px; border-radius: 1px; }
.key.rect { width: 10px; height: 10px; border-radius: 2px; }
/* The net income marker: a white dot with a black rim, the same in both schemes. */
.key.marker { width: 8px; height: 8px; margin: 1px; border-radius: 50%; background: var(--marker); box-shadow: 0 0 0 1.5px var(--marker-ink); }
.legend.top { margin: -.4rem 0 .75rem; }

.chart-table { margin-top: .6rem; font-size: .85rem; }
.chart-table summary { cursor: pointer; color: var(--muted); }
.chart-table .table-wrap { max-height: 320px; overflow-y: auto; margin-top: .5rem; }

/* Donuts: the ring at its drawn size beside a legend table with the figures. */
.chart.donut { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 1rem 1.75rem; }
/* As large as the card allows next to the legend: 300px nominal, 240-330px. */
.chart.donut svg { width: clamp(240px, 46%, 330px); flex: none; }
.chart .seg { stroke: var(--surface); stroke-width: 2; stroke-linejoin: round; transition: opacity .12s; }
.chart.hovering .seg:not(.active) { opacity: .45; }
.donut-total { fill: var(--text); font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.donut-caption { fill: var(--muted); font-size: 13px; }
.donut-side { flex: 1 1 15rem; min-width: 0; }
.donut-legend { font-size: .85rem; }
.donut-legend td.text { display: flex; align-items: center; gap: .5rem; white-space: normal; }
.donut-legend tr.group td { font-weight: 600; }
.donut-legend tr.member td.text { padding-left: 1.5rem; color: var(--muted); }
.donut-legend tr.active { background: var(--surface-2); }
.donut-note { margin: .6rem 0 0; }
.key.swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.key.hatch { background: repeating-linear-gradient(45deg, var(--chart-context) 0 2px, var(--surface-2) 2px 4px); }

/* Medium widths: thinner page and card margins leave more room for tables. */
@media (max-width: 1280px) {
  main { padding: 1.5rem 1.25rem 2.5rem; }
  .topbar-inner { padding-left: 1.25rem; padding-right: 1.25rem; }
  .card { padding: 1rem; }
}

/* Narrow screens: the menu moves to its own row and scrolls sideways. */
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; gap: .5rem 1rem; padding: .5rem 1rem; }
  .topnav { order: 3; flex-basis: 100%; margin: 0 -.25rem; }
  .local-badge { display: none; }
  main { padding: 1.25rem 1rem 2rem; }
  .form-grid .wide { grid-column: 1 / -1; }
  .chart-grid { grid-template-columns: 1fr; }
}

/* Income by platform: a grid of platforms and months, shaded by the amount. */
.head-tools { display: flex; align-items: center; gap: 1rem; }
.head-tools label.check { font-size: .8rem; }
.income-grid { font-size: .82rem; }
.income-grid th, .income-grid td { padding: .4rem .45rem; }
/* The platform names and their column title are as large as in the Platforms table (the page's own
   15px and the common .8rem of a table head), not as small as the figures of the grid. */
.income-grid th.text { font-size: .8rem; }
.income-grid tbody td.text { font-size: 15px; }
.income-grid td.empty { color: var(--muted); }
.income-grid .running { font-style: italic; color: var(--muted); }
.income-grid.heat td.cell.pos { background: color-mix(in srgb, var(--pos) calc(var(--heat) * 38%), transparent); }
.income-grid.heat td.cell.neg { background: color-mix(in srgb, var(--neg) calc(var(--heat) * 38%), transparent); }

/* Sections that fold up under their heading (base.html keeps the state). */
.collapse { display: inline-flex; align-items: center; gap: .55rem; margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.collapse::before { content: ""; flex: none; width: .42em; height: .42em; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-.12em); transition: transform .15s; }
.collapse[aria-expanded="false"]::before { transform: rotate(-45deg); }
.card.folded > :not(h2):not(.card-head) { display: none; }
.card.folded .head-tools { display: none; }
.card.folded > h2, .card.folded > .card-head { margin-bottom: 0; }

/* The platform icon that fetches a statement, and the panel that follows the run. */
.fetch-start { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 1.4rem; height: 1.4rem; padding: 0; border: 0; border-radius: 50%; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); cursor: pointer; }
.fetch-start.manual { background: color-mix(in srgb, var(--series-4) 25%, transparent); color: var(--series-4); }
.fetch-start:hover, .fetch-start:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.fetch-spacer { flex: none; width: 1.4rem; }
/* The frame round a platform's logo: how long ago the last import was. */
.mark-frame { display: inline-flex; border-radius: 5px; }
.frame-ok { box-shadow: 0 0 0 2px var(--pos); }
.frame-warn { box-shadow: 0 0 0 2px var(--series-4); }
.frame-late { box-shadow: 0 0 0 2px var(--neg); }
.fetch-panel { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 50; width: min(24rem, calc(100vw - 2.5rem)); padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.fetch-panel [hidden] { display: none; }
.fetch-title { font-weight: 650; }
.fetch-text { margin: .4rem 0 .8rem; color: var(--muted); font-size: .88rem; }
.fetch-buttons { display: flex; flex-wrap: wrap; gap: .5rem; }

/* Tax declaration: the check list, a card per platform, the draft text. */
.check-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.check-list li { padding: .5rem .8rem; border-radius: 8px; background: var(--surface-2); font-size: .92rem; }
.check-list li.warning { border-left: 3px solid var(--series-4); }
.check-list li.note { border-left: 3px solid var(--border); color: var(--muted); }
.check-list .badge { margin-right: .4rem; }
details.tax-card > summary { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; cursor: pointer; list-style: none; }
details.tax-card > summary::-webkit-details-marker { display: none; }
details.tax-card > summary::before { content: "▸"; color: var(--muted); }
details.tax-card[open] > summary::before { content: "▾"; }
.tax-card-result { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.tax-card-body { margin-top: .8rem; }
.tax-card-body h3 { margin: 1rem 0 .4rem; font-size: 1rem; }
tr.strong-row td { font-weight: 600; }
textarea.explanation { width: 100%; font: inherit; font-size: .9rem; line-height: 1.45; resize: vertical; }

/* ---- Hosted additions: sign-in, account and administration. -------------------------------
   Written with :where() (no specificity), so that every rule of the pages above wins. */
:where(.stack) { display: grid; gap: .8rem; margin: 1rem 0; }
:where(.stack) label { display: grid; gap: .3rem; font-size: .95rem; }
:where(form.inline, form.row) { display: inline-flex; gap: .6rem; margin: 0; align-items: center; flex-wrap: wrap; }
:where(main, dialog) :where(input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select, textarea) {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: .5rem .6rem;
}
:where(main, dialog) :where(button) {
  font: inherit; font-weight: 600; color: var(--accent-text); background: var(--accent);
  border: 0; border-radius: 6px; padding: .55rem 1rem; cursor: pointer; justify-self: start;
}
button.link { border: 0; background: none; padding: 0; color: var(--muted); font: inherit; font-weight: 400; cursor: pointer; }
button.link:hover { color: var(--text); }
:where(button.small) { padding: .35rem .7rem; font-size: .9rem; }
:where(button.quiet) { background: var(--surface-2); color: var(--text); }
:where(button.danger) { background: var(--danger); color: #fff; }
:where(.narrow) { max-width: 30rem; margin-inline: auto; }
:where(.card + .card) { margin-top: 1rem; }
:where(.error) { color: var(--neg); background: color-mix(in srgb, var(--neg) 14%, transparent); border-radius: 6px; padding: .5rem .7rem; }
:where(.note) { color: var(--pos); background: color-mix(in srgb, var(--pos) 14%, transparent); border-radius: 6px; padding: .5rem .7rem; }
:where(.qr) { background: #fff; display: inline-block; padding: .5rem; border-radius: 6px; margin: .5rem 0; }
:where(.qr) svg { display: block; }
:where(.secret) { letter-spacing: .05em; word-break: break-all; }
:where(.codes) { columns: 2; list-style: none; padding: 0; font-size: 1.05rem; }
:where(.person) { border-top: 1px solid var(--border); padding: .8rem 0; }
:where(.person) h3 { margin: 0; font-size: 1.05rem; }
:where(.copy) { width: 100%; }
:where(.topbar-end) form { display: inline; margin: 0; }

:where(pre.description) { white-space: pre-wrap; background: var(--surface-2); padding: .8rem; border-radius: 6px; font-size: .85rem; max-height: 28rem; overflow: auto; }

/* The account menu in the top bar: a round button with the person, its panel below on the right. */
.account-menu { position: relative; }
.account-menu > summary {
  list-style: none; cursor: pointer; display: grid; place-items: center;
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  border: 1.5px solid var(--border); color: var(--text); background: var(--surface);
}
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu > summary:hover, .account-menu[open] > summary { border-color: var(--muted); }
.account-menu > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.account-menu-panel {
  position: absolute; right: 0; top: calc(100% + .5rem); z-index: 50;
  min-width: 15rem; max-width: calc(100vw - 2rem); width: max-content;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 22%); overflow: hidden;
}
.account-menu-head { display: grid; gap: .15rem; padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
.account-menu-head strong { overflow-wrap: anywhere; }
.account-menu-panel > a {
  display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem;
  color: var(--text); text-decoration: none;
}
.account-menu-panel > a svg { color: var(--muted); flex: none; }
.account-menu-panel > a:hover { background: var(--surface-2); }
.account-menu-foot { display: block; margin: 0; border-top: 1px solid var(--border); }
.account-menu-foot button {
  display: block; width: 100%; text-align: left; padding: .8rem 1rem;
  border: 0; background: none; color: var(--text); font: inherit; cursor: pointer;
}
.account-menu-foot button:hover { background: var(--surface-2); }
.account-menu-item { display: block; margin: 0; }
.account-menu-item button {
  white-space: nowrap;
  display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left; padding: .7rem 1rem;
  border: 0; background: none; color: var(--text); font: inherit; cursor: pointer;
}
.account-menu-item button svg { color: var(--muted); flex: none; }
.account-menu-item button:hover { background: var(--surface-2); }
.account-notice { margin: 0 0 1rem; }

/* The dialogs of the account menu: modal with script, otherwise shown in place of the page. */
dialog.account-dialog {
  position: fixed; inset: 0; margin: auto; height: fit-content; max-height: calc(100vh - 2rem); overflow: auto;
  width: min(28rem, calc(100vw - 2rem)); padding: 1.2rem 1.4rem 1.4rem; z-index: 60;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 16px 48px rgb(0 0 0 / 35%);
}
dialog.account-dialog::backdrop { background: rgb(0 0 0 / 55%); }
.account-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; }
.account-dialog-head h2 { margin: 0; font-size: 1.15rem; }
.account-dialog-close {
  display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%;
  color: var(--muted); font-size: 1.4rem; line-height: 1; text-decoration: none;
}
.account-dialog-close:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

/* The portfolio menu of the overview: a pill after the title, its panel of links below it. */
.scope-title { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.scope-title h1 { margin: 0; }
.scope-menu { position: relative; }
.scope-pill {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: .5rem;
  font-size: .95rem; font-weight: 600; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: .3rem .8rem;
}
.scope-pill::-webkit-details-marker { display: none; }
.scope-pill svg { color: var(--muted); }
.scope-pill:hover, .scope-menu[open] > .scope-pill { border-color: var(--muted); }
.scope-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.scope-panel {
  position: absolute; left: 0; top: calc(100% + .5rem); z-index: 50; width: 21rem; max-width: calc(100vw - 2rem);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 28%); overflow: hidden;
}
.scope-panel hr { border: 0; border-top: 1px solid var(--border); margin: 0; }
.scope-option {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .6rem 1rem .6rem 2.2rem; color: var(--text); font-size: .95rem; text-decoration: none;
}
.scope-option span { flex: 1; overflow-wrap: anywhere; }
.scope-option small { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.scope-option:hover { background: var(--surface-2); text-decoration: none; }
.scope-option.on { background: var(--surface-2); font-weight: 600; padding-left: 1rem; }
.scope-option.on::before { content: "✓"; color: var(--accent); margin-right: .6rem; }
.scope-manage { display: block; padding: .6rem 1rem .6rem 2.2rem; font-size: .9rem; }

/* The footer with the privacy link, and the privacy page's table. */
.site-footer { max-width: 1800px; margin: 0 auto; padding: 0 2rem 2rem; text-align: center; font-size: .85rem; }
.site-footer a { color: var(--muted); }
.prose h2 { margin-top: 1.6rem; font-size: 1.1rem; }
table.privacy td { white-space: normal; vertical-align: top; }
.account-menu-panel > a.danger-item { color: var(--neg); }
.account-menu-panel > a.danger-item svg { color: var(--neg); }
