/* TMS — dark fintech theme, shared by every page.
   Class names (.muted .err .ok .neg .num .scroll .hint .badge .logo .card
   .toolbar .fx-form .cell) are used by the page scripts — keep them stable. */

:root {
  color-scheme: dark;
  --bg: #0b0e14;
  --bg-elev: #10141c;
  --surface: #151a24;
  --surface-2: #1c2230;
  --border: #252c3a;
  --border-strong: #343d50;
  --text: #e8ebf1;
  --text-dim: #9aa4b6;
  --text-faint: #6b7588;
  --accent: #4f8cff;
  --accent-hover: #6ba0ff;
  --accent-ink: #06122b;
  --pos: #1fd18b;
  --neg: #ff5d73;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 40px rgba(0, 0, 0, .45);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 88% -8%, rgba(79, 140, 255, .13), transparent 65%),
    radial-gradient(700px 380px at -6% 0%, rgba(31, 209, 139, .07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(79, 140, 255, .35); }
* { scrollbar-color: var(--border-strong) transparent; scrollbar-width: thin; }
[hidden] { display: none !important; }

/* ---------- typography ---------- */
h1 { font-size: 1.65rem; font-weight: 700; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 1.1rem; font-weight: 650; letter-spacing: -.01em; margin: 0 0 .75rem; }
h3 { font-size: .8rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); margin: 1.5rem 0 .5rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .88em; color: var(--text); }
.muted { color: var(--text-dim); }
.hint { color: var(--text-faint); font-size: .85rem; font-weight: 400; }
.err { color: var(--neg); font-size: .85rem; min-height: 1em; margin: .25rem 0; }
.ok { color: var(--pos); }
.neg { color: var(--neg); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1.5rem;
  padding: .7rem 1.5rem;
  background: rgba(11, 14, 20, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex; align-items: center; gap: .6rem;
  color: var(--text); font-weight: 750; letter-spacing: .02em; font-size: 1.05rem;
}
.brand:hover { color: var(--text); }
/* logo polybanking.app (static/brand/logo.svg — wektor z przezroczystym tłem, ostry na każdym ekranie) */
.brand img { display: block; height: 40px; width: auto; }
.nav { display: flex; gap: .25rem; }
.nav a {
  color: var(--text-dim); padding: .4rem .8rem; border-radius: var(--radius-sm);
  font-weight: 550; font-size: .92rem;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.user { margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.user .muted { font-size: .85rem; margin-right: .25rem; }
.currency-select { padding: .42rem 1.6rem .42rem .6rem; font-size: .88rem; font-weight: 600; }

/* ---------- page layout ---------- */
.page { max-width: 1320px; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
main > section {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 1.25rem 1.25rem 1.5rem; margin-top: 1.25rem;
}
#global { min-height: 1.2em; margin: 0 0 .5rem; font-size: .9rem; }

/* ---------- buttons ---------- */
button, .btn {
  font: inherit; font-size: .9rem; font-weight: 550; line-height: 1.2;
  display: inline-block; cursor: pointer;
  padding: .5rem .95rem; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
button:hover, .btn:hover { background: #252d3f; border-color: #46536e; color: var(--text); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary, button[type="submit"], .btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
button.primary:hover, button[type="submit"]:hover, .btn.primary:hover {
  background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink);
  box-shadow: 0 6px 20px rgba(79, 140, 255, .35);
}
.btn { text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- inputs ---------- */
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: .5rem .7rem;
}
input::placeholder { color: var(--text-faint); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 140, 255, .22); }
input[type="checkbox"] { accent-color: var(--accent); width: 1rem; height: 1rem; padding: 0; }
input.cell, select.cell { max-width: 240px; padding: .35rem .55rem; }
select { padding-right: 1.6rem; }

form.card {
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin: .9rem 0; max-width: 640px;
}
form.card p { margin: .7rem 0; }
form.card label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-dim); margin-bottom: .3rem; }
form.card input:not([type="checkbox"]), form.card select { width: 100%; }
.toolbar { display: flex; align-items: center; gap: .5rem; margin: .5rem 0 .75rem; }

.fx-form, .filters { display: flex; align-items: end; flex-wrap: wrap; gap: .75rem; margin: .75rem 0; }
.fx-form label, .filters label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-dim); margin-bottom: .3rem; }
.filters label.check { display: flex; align-items: center; gap: .4rem; font-weight: 400; color: var(--text); margin: 0 .25rem .55rem; }

/* ---------- tables ---------- */
.scroll {
  overflow-x: auto; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--radius);
}
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  text-align: left; white-space: nowrap;
  font-size: .72rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-faint); background: var(--surface);
  padding: .7rem .9rem; border-bottom: 1px solid var(--border);
}
td { padding: .65rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: rgba(79, 140, 255, .05); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { font-weight: 550; white-space: nowrap; }

.badge {
  display: inline-block; padding: .1rem .6rem; border-radius: 999px;
  background: rgba(154, 164, 182, .14); color: var(--text-dim);
  font-size: .75rem; font-weight: 650;
}

/* Row height is explicit — otherwise the row grows to the image's size instead
   of the image scaling to the row (circular percentage height). Logo = 90% of it. */
#accounts-body td { height: 56px; white-space: nowrap; }
td code { white-space: nowrap; }
.logo {
  height: 90%; width: auto; max-width: 130px; object-fit: contain; vertical-align: middle;
  background: #fff; border-radius: 8px; padding: 3px; margin-right: .4rem;
}

/* ---------- chart ---------- */
#fx-chart {
  margin: .25rem 0 1rem; padding: .75rem;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
}
#fx-chart svg { display: block; max-width: 100%; height: auto; }
#fx-chart .fx-empty { color: var(--text-dim); font-size: .88rem; padding: 1.25rem 0; text-align: center; margin: 0; }

/* ---------- dialog ---------- */
dialog {
  width: min(940px, 94vw); max-height: 88vh; padding: 0;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(3, 6, 12, .68); backdrop-filter: blur(3px); }
dialog .head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}
dialog .body { padding: 0 1.25rem 1.25rem; overflow: auto; max-height: calc(88vh - 3.6rem); }

/* ---------- admin panel: clients ---------- */
.chip {
  display: inline-flex; align-items: center; gap: .35rem; margin: .1rem .3rem .1rem 0;
  padding: .15rem .25rem .15rem .6rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border-strong); font-size: .82rem;
}
.chip-x { padding: 0 .4rem; font-size: .75rem; line-height: 1.4; border-radius: 999px; background: transparent; border-color: transparent; }
.chip-x:hover { color: var(--neg); background: rgba(255, 93, 115, .12); border-color: transparent; }
.inline { display: flex; align-items: center; gap: .4rem; }
td .inline button { padding: .35rem .7rem; font-size: .82rem; white-space: nowrap; }
.count-link {
  padding: .1rem .55rem; font-weight: 650; color: var(--accent);
  background: transparent; border-color: transparent; text-decoration: underline dotted;
}
.count-link:hover { background: rgba(79, 140, 255, .12); border-color: transparent; color: var(--accent-hover); }
.popover {
  position: absolute; z-index: 30; min-width: 220px; max-width: min(360px, calc(100vw - 32px));
  padding: .75rem .9rem; background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow); font-size: .88rem;
}
.popover ul { margin: .45rem 0 0; padding-left: 1.1rem; max-height: 260px; overflow: auto; }
.popover li { margin: .2rem 0; }
button.danger { color: var(--neg); }
button.danger:hover { background: rgba(255, 93, 115, .12); border-color: var(--neg); color: var(--neg); }
.card.secret {
  background: rgba(31, 209, 139, .08); border: 1px solid rgba(31, 209, 139, .35); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin: .9rem 0; max-width: 640px;
}
.card.secret p { margin: .5rem 0; }
.secret-value { display: inline-block; font-size: 1.05rem; padding: .35rem .6rem; background: var(--bg-elev); border-radius: var(--radius-sm); user-select: all; }

/* ---------- consent status badges ---------- */
.badge.st-linked { background: rgba(31, 209, 139, .15); color: var(--pos); }
.badge.st-awaiting, .badge.st-draft { background: rgba(79, 140, 255, .16); color: var(--accent-hover); }
.badge.st-expired, .badge.st-rejected, .badge.st-error { background: rgba(255, 93, 115, .15); color: var(--neg); }

/* ---------- structure: users (companies as checkboxes) ---------- */
.checks-field { border: none; padding: 0; margin: .7rem 0; }
.checks-field legend { font-size: .82rem; font-weight: 600; color: var(--text-dim); margin-bottom: .3rem; padding: 0; }
.checks {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .35rem .9rem;
  max-height: 220px; overflow: auto; padding: .5rem .7rem;
  background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
form.card .checks label.check, .checks label.check {
  display: flex; align-items: center; gap: .45rem; margin: 0;
  font-size: .9rem; font-weight: 400; color: var(--text); cursor: pointer;
}
.checks:has(.check-group) { display: block; }
.check-group { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .35rem .9rem; }
.check-group + .check-group { margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--border); }
.check-group-title {
  grid-column: 1 / -1; font-size: .72rem; font-weight: 650; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-faint);
}
.access-editor { max-width: 760px; margin: .25rem 0; }
.access-editor p { margin: .6rem 0; }
tbody tr.editor:hover td { background: transparent; }

/* ---------- structure: consents and accounts ---------- */
.fx-note { font-weight: 400; white-space: nowrap; }
td.bank-cell { height: 56px; white-space: nowrap; }
/* Long lists: the table scrolls inside its card and the header row stays visible. */
.scroll.sticky-table { max-height: max(360px, calc(100vh - 220px)); overflow: auto; }
.sticky-table thead th { position: sticky; top: 0; z-index: 2; box-shadow: inset 0 -1px 0 var(--border); }
/* Denser rows (Structure → Bank accounts). */
.compact-table th { padding: .5rem .6rem; }
.compact-table td, .compact-table #accounts-body td { height: 36px; padding: .2rem .6rem; line-height: 1.3; }
.compact-table input.cell, .compact-table select.cell { padding: .2rem .45rem; font-size: .85rem; }
.compact-table td button { padding: .25rem .6rem; font-size: .82rem; }
.compact-table .logo { width: 22px; height: 22px; }
.compact-table .hint { font-size: .72rem; }
.compact-table .badge { padding: 0 .5rem; font-size: .7rem; }
.compact-table td > div:has(> .badge) { display: inline; margin-left: .35rem; }
.compact-table .err:empty { display: none; }
.compact-table td.clip { max-width: 112px; overflow: hidden; text-overflow: ellipsis; }
.compact-table td.w-grouping input.cell { width: 84px; }
/* Kolumna Grouping: nagłówek nie szerszy niż pole w wierszu. */
.compact-table th.w-grouping { width: 84px; max-width: 84px; }
.compact-table td.w-category select.cell { width: 92px; }
.compact-table td.w-company select.cell { width: 92px; }
.compact-table td.w-limit select.cell { width: 122px; }
/* Column filters in the header row. */
.col-filter {
  display: block; width: 100%; min-width: 3.2rem; margin-top: .25rem; padding: .15rem .35rem;
  font-size: .72rem; font-weight: 400; letter-spacing: 0; text-transform: none;
}
select.col-filter { padding-right: 1.1rem; }
.filter-bar { display: flex; align-items: center; gap: .6rem; min-height: 1.6rem; margin: .2rem 0 .4rem; }
.filter-bar button { padding: .15rem .55rem; font-size: .76rem; }

/* ---------- compact pages (Structure): smaller type, tighter tables ---------- */
.compact-page table { font-size: .8rem; }
.compact-page th { font-size: .66rem; padding: .45rem .55rem; }
.compact-page td { padding: .4rem .55rem; }
.compact-page .compact-table td, .compact-page .compact-table #accounts-body td { padding: .15rem .35rem; height: 32px; }
.compact-page .compact-table th { padding: .4rem .35rem; vertical-align: bottom; white-space: normal; line-height: 1.15; }
.compact-page .compact-table td code { font-size: .72rem; }
.compact-page .compact-table .logo { width: 18px; height: 18px; }
.compact-page td code { font-size: .76rem; }
/* Bank accounts: jedna czcionka i jeden rozmiar we wszystkich kolumnach wierszy. */
.compact-page .compact-table tbody td, .compact-page .compact-table tbody td input.cell,
.compact-page .compact-table tbody td select.cell, .compact-page .compact-table tbody td button {
  font-family: inherit; font-size: .76rem;
}
.compact-table .iban { font-variant-numeric: tabular-nums; white-space: nowrap; }
.compact-page td button, .compact-page td .btn { padding: .22rem .55rem; font-size: .76rem; }
.compact-page td .badge { font-size: .68rem; padding: .05rem .5rem; }
.compact-page input.cell, .compact-page select.cell { font-size: .78rem; padding: .18rem .4rem; }
.compact-page select.cell { padding-right: 1.3rem; }
.compact-page .acc-list { font-size: .76rem; }
.compact-page .rule-conditions { display: flex; flex-wrap: wrap; gap: .1rem .7rem; }
.compact-page .rule-cond { font-size: .76rem; }
.compact-page h2 { font-size: 1.05rem; }
.compact-page .hint { font-size: .78rem; }
#renew-dialog { width: min(760px, 94vw); }
#renew-dialog .body { padding-top: 1rem; }
.renew-tip {
  padding: .6rem .8rem; border-radius: var(--radius-sm);
  background: rgba(79, 140, 255, .1); border: 1px solid rgba(79, 140, 255, .3); color: var(--text);
}
.acc-list { display: grid; gap: .15rem; font-size: .85rem; white-space: nowrap; }
tbody tr.row-attention td { background: rgba(79, 140, 255, .06); }
select.needs-choice { border-color: var(--accent); }

/* ---------- bank selection (AIS consent) ---------- */
.filters .grow { flex: 1 1 260px; }
.filters .grow input { width: 100%; }
.bank-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem;
  margin-top: .25rem;
}
.bank-tile {
  display: flex; align-items: center; gap: .7rem; text-align: left;
  padding: .7rem .8rem; min-height: 64px; background: var(--bg-elev);
}
.bank-tile:hover { border-color: var(--accent); background: var(--surface-2); }
.bank-logo {
  flex: none; width: 40px; height: 40px; object-fit: contain;
  background: #fff; border-radius: 8px; padding: 3px;
}
.bank-initial {
  display: grid; place-items: center; font-weight: 700; color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), #8a63ff);
}
.bank-name { font-size: .88rem; line-height: 1.25; overflow-wrap: anywhere; }
.bank-picked { display: flex; align-items: center; gap: .9rem; margin: 1.1rem 0 .5rem; font-size: 1.05rem; }
.bank-picked .bank-logo { width: 52px; height: 52px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: 1rem 0; font-size: .9rem; }
.facts dt { color: var(--text-dim); font-weight: 600; }
.facts dd { margin: 0; }

/* ---------- auth pages (index, login) ---------- */
body.auth { display: grid; place-items: center; padding: 1.5rem; }
.auth-card {
  width: min(410px, 100%);
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 2rem; box-shadow: var(--shadow);
}
.auth-card .brand { margin-bottom: 1.5rem; }
.auth-card h1 { font-size: 1.45rem; margin-bottom: 1.25rem; }
.auth-card form { display: grid; gap: 1rem; }
.auth-card p { margin: 0; }
.auth-card label { display: flex; flex-direction: column; gap: .35rem; font-size: .82rem; font-weight: 600; color: var(--text-dim); }
.auth-card input { width: 100%; padding: .65rem .8rem; }
.auth-card button[type="submit"] { width: 100%; padding: .7rem 1rem; margin-top: .25rem; }
.auth-card .back { display: inline-block; margin-top: 1.25rem; font-size: .88rem; }
.auth-card .btn { width: 100%; text-align: center; padding: .7rem 1rem; }
.auth-card .tagline { margin: -.5rem 0 1.5rem; color: var(--text-dim); }

@media (max-width: 720px) {
  .topbar { padding: .6rem 1rem; }
  .user { margin-left: 0; width: 100%; }
  .page { padding: 1.25rem 1rem 3rem; }
  main > section { padding: 1rem; }
}

/* ---------- accounts: IBAN link, tooltips, account details ---------- */
button.iban-link {
  padding: 0; border: 0; background: none; box-shadow: none; cursor: pointer;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .95rem; font-weight: 500;
  color: var(--accent); white-space: nowrap; text-decoration: underline; text-decoration-color: rgba(79, 140, 255, .35);
  text-underline-offset: 3px;
}
button.iban-link:hover, button.iban-link:focus-visible { color: var(--accent-hover); text-decoration-color: currentColor; background: none; }
.has-tip { cursor: help; border-bottom: 1px dotted var(--text-faint); }
.tip {
  position: fixed; z-index: 1000; pointer-events: none; max-width: 280px;
  padding: .45rem .6rem; border-radius: var(--radius-sm); font-size: .8rem; line-height: 1.45;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
}
.tip strong { display: block; margin-bottom: .1rem; }
#account-dialog { width: min(860px, 94vw); }
#account-dialog .body { padding-top: 1rem; }
.detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem 1.25rem; margin: 0 0 1rem;
}
.detail-grid div { min-width: 0; }
.detail-grid dt { font-size: .72rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); }
.detail-grid dd { margin: .2rem 0 0; font-size: .98rem; overflow-wrap: anywhere; }
.detail-grid dd.big { font-size: 1.15rem; font-weight: 650; }
#balance-chart {
  position: relative; margin: .25rem 0 0; padding: .75rem;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
}
#balance-chart svg { display: block; max-width: 100%; height: auto; }
#balance-chart .chart-empty { color: var(--text-dim); font-size: .88rem; padding: 1.25rem 0; text-align: center; margin: 0; }
#balance-chart circle.pt { cursor: pointer; }

/* ---------- dashboard ---------- */
.dash-asof { margin: 0 0 .55rem auto; font-size: .85rem; }
.dash-warnings {
  margin: 0 0 1rem; padding: .6rem .8rem; border-radius: var(--radius-sm); font-size: .85rem;
  background: rgba(255, 181, 71, .08); border: 1px solid rgba(255, 181, 71, .3); color: #ffcf85;
}
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .9rem; margin: 0 0 1rem; }
.kpi {
  display: flex; flex-direction: column; gap: .3rem; padding: 1rem 1.1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.kpi-label { font-size: .75rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); }
.kpi-value { font-size: 1.6rem; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.kpi-value.pos { color: var(--pos); }
.kpi-value.neg { color: var(--neg); }
.kpi-sub { font-size: .8rem; color: var(--text-dim); }
.util { font-weight: 650; }
.util.u-green { color: var(--pos); }
.util.u-amber { color: #ffb547; }
.util.u-red { color: var(--neg); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: .9rem; }
@media (max-width: 520px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-card { margin: 0; padding: 1rem 1.2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.dash-card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .6rem; margin-bottom: .8rem; }
.dash-card-head h2 { margin: 0; font-size: 1rem; }
.pill-group { display: inline-flex; gap: .3rem; flex-wrap: wrap; }
.pill {
  padding: .3rem .7rem; font-size: .8rem; font-weight: 600; border-radius: 999px;
  background: transparent; border: 1px solid var(--border-strong); color: var(--text-dim); box-shadow: none;
}
.pill:hover { color: var(--text); background: var(--surface-2); }
.pill.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.donut-wrap { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; }
.donut svg { display: block; }
.donut .arc { cursor: pointer; transition: stroke-width .12s; }
.donut .arc:hover { stroke-width: 32; }
.legend { flex: 1 1 200px; display: grid; gap: .35rem; min-width: 0; }
.legend-row {
  display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 3.4rem; align-items: center; gap: .55rem;
  padding: .3rem .4rem; border-radius: 6px; font-size: .88rem; cursor: default;
}
.legend-row:hover { background: var(--surface-2); }
.swatch { width: 12px; height: 12px; border-radius: 3px; }
.legend-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.legend-pct { text-align: right; font-variant-numeric: tabular-nums; }
.facilities { display: grid; gap: .9rem; }
.facility-head { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; font-size: .88rem; margin-bottom: .35rem; }
.facility-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }
.bar-fill.u-green { background: var(--pos); }
.bar-fill.u-amber { background: #ffb547; }
.bar-fill.u-red { background: var(--neg); }
.dash-wide { margin: .9rem 0; }
.dash-grid + .dash-wide { margin-top: .9rem; }
.dash-controls { display: flex; gap: .6rem; flex-wrap: wrap; }
.trend-chart svg { display: block; max-width: 100%; height: auto; }
.trend-chart .hit { cursor: crosshair; }
.trend-chart .hit:hover { fill: rgba(255, 255, 255, .04); }
.trend-chart .chart-empty { color: var(--text-dim); font-size: .88rem; padding: 1.25rem 0; text-align: center; margin: 0; }
.trend-legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin: .6rem 0 0; font-size: .84rem; color: var(--text-dim); }
.trend-legend .swatch { display: inline-block; vertical-align: -1px; }
.exposure { display: grid; gap: .55rem; }
.exposure-row { display: grid; grid-template-columns: minmax(0, 150px) 1fr 1fr; align-items: center; gap: 0; font-size: .86rem; }
.exposure-bank { display: flex; align-items: center; gap: .45rem; min-width: 0; padding-right: .6rem; }
.exposure-bank .logo { width: 22px; height: 22px; }
.exposure-side { display: flex; align-items: center; gap: .35rem; height: 22px; }
.exposure-side.left { justify-content: flex-end; border-right: 1px solid var(--border-strong); padding-right: 0; }
.exposure-side.right { justify-content: flex-start; }
.exposure-bar { height: 16px; min-width: 0; }
.exposure-bar.debt { background: var(--neg); border-radius: 4px 0 0 4px; }
.exposure-bar.deposits { background: var(--pos); border-radius: 0 4px 4px 0; }
.exposure-amt { font-size: .78rem; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.attention { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.attention-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: .6rem;
  padding: .5rem .6rem; border-radius: var(--radius-sm); background: var(--bg-elev); border: 1px solid var(--border); font-size: .86rem;
}
.attention-item .sev { font-size: .7rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: .12rem .45rem; border-radius: 999px; }
.sev-high .sev { color: #ffd0d6; background: rgba(255, 93, 115, .18); }
.sev-medium .sev { color: #ffe0b0; background: rgba(255, 181, 71, .16); }
.sev-info .sev { color: #cfe0ff; background: rgba(79, 140, 255, .16); }
.attention-msg { overflow-wrap: anywhere; }
.attention-link { white-space: nowrap; font-size: .82rem; }
.attention-ok { color: var(--pos); font-size: .88rem; padding: .4rem 0; }

/* ---------- structure: shared credit limits ---------- */
.limit-form-title { margin: 0 0 .4rem; font-weight: 650; }
.limit-companies { display: grid; gap: .35rem; max-width: 560px; }
.limit-companies .check-group { display: grid; gap: .35rem; margin-bottom: .4rem; }
.limit-company { display: grid; grid-template-columns: minmax(0, 1fr) 170px; align-items: center; gap: .75rem; }
.limit-company label.check { margin: 0; }
.limit-company input.sub-limit { width: 100%; }
.limit-company input.sub-limit:disabled { opacity: .45; }
.limit-parts { display: grid; gap: .15rem; font-size: .88rem; }
.limit-parts .badge { justify-self: start; margin-top: .2rem; }
td.nowrap { white-space: nowrap; }
.limit-parts .nowrap { white-space: nowrap; }

/* ---------- transaction categories ---------- */
td.cat-cell { white-space: nowrap; }
select.cat-select { max-width: 170px; padding-top: .25rem; padding-bottom: .25rem; font-size: .82rem; }
.badge.cat-src { font-size: .68rem; cursor: help; }
.badge.cat-rule { color: #cfe0ff; background: rgba(79, 140, 255, .16); }
.badge.cat-manual { color: #ffe0b0; background: rgba(255, 181, 71, .16); }
.rule-conditions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .2rem 1rem; }
.rule-cond { font-size: .84rem; }
.preview-box { margin: .6rem 0; padding: .6rem .8rem; border-radius: var(--radius-sm); background: var(--bg-elev); border: 1px solid var(--border); font-size: .85rem; }
.rule-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 1rem; }
.rule-grid p { margin: .35rem 0; }
.rule-grid input, .rule-grid select { width: 100%; }
.dash-grid + .dash-grid { margin-top: .9rem; }
.dash-card[data-trend] .dash-controls .pill { padding: .25rem .6rem; }
/* Needs attention: three items visible, the rest scrolls (height set by fitAttention()). */
.attention.scrolls { overflow-y: auto; padding-right: .35rem; scrollbar-width: thin; }
.tip .tip-total { font-weight: 700; margin-top: .2rem; padding-top: .2rem; border-top: 1px solid var(--border-strong); }
.badge.src-badge { font-size: .66rem; padding: 0 .45rem; vertical-align: middle; cursor: help; }
/* ---------- Accounts page table ---------- */
.accounts-table .has-tip { border-bottom: none; }  /* tooltip zostaje, bez podkreślenia */
.accounts-table td.iban { white-space: nowrap; font-variant-numeric: tabular-nums; }
.accounts-table .row-actions button { padding: .15rem .5rem; font-size: .72rem; }
.accounts-table th.total-head { vertical-align: bottom; text-align: right; white-space: nowrap; }
.accounts-table .total-label { display: block; font-size: .62rem; color: var(--text-faint); }
.accounts-table #accounts-total { display: block; font-size: .8rem; font-weight: 650; color: var(--text); letter-spacing: 0;
  text-transform: none; font-variant-numeric: tabular-nums; cursor: help; }
.accounts-table #accounts-total.neg { color: var(--neg); }
.compact-page .accounts-table td, .compact-page .accounts-table #accounts-body td { height: 34px; }
/* Strona Accounts: mniejszy odstęp nagłówek → tabela, niższe wiersze. */
.accounts-page .page-head { margin-bottom: .35rem; }
.accounts-page #global:empty { display: none; }
.accounts-page .accounts-table #accounts-body td { height: 29px; padding-top: .1rem; padding-bottom: .1rem; }
.accounts-page .accounts-table #accounts-body .logo { width: 16px; height: 16px; }
/* Okna History i Chart: niższe filtry z mniejszą czcionką, przyciski okresu. */
.dialog-filters { gap: .55rem; margin: .45rem 0; }
.dialog-filters label { font-size: .7rem; margin-bottom: .2rem; }
.dialog-filters input[type="date"] { padding: .25rem .45rem; font-size: .8rem; }
.dialog-filters select { padding: .25rem 1.5rem .25rem .45rem; font-size: .8rem; }
.dialog-filters button[type="submit"] { padding: .3rem .75rem; font-size: .8rem; }
.dialog-filters label.check { font-size: .8rem; margin-bottom: .35rem; }
.dialog-filters .period-pills { align-self: flex-end; margin-bottom: .15rem; }
.dialog-filters .pill { padding: .22rem .6rem; font-size: .76rem; }
#history-dialog { width: min(1400px, 97vw); }
.history-table table { font-size: .76rem; }
.history-table td.desc { min-width: 260px; white-space: normal; overflow-wrap: anywhere; }
#account-dialog .detail-grid dt { font-size: .64rem; }
#account-dialog .detail-grid dd { font-size: .86rem; }
#account-dialog .detail-grid dd.big { font-size: 1rem; }
#account-dialog h3 { margin-top: 1rem; }
/* Nagłówki z filtrami: etykieta u góry, pola filtrów w jednej linii pod nią, jednakowa wysokość pól. */
.col-filter { box-sizing: border-box; height: 1.6rem; line-height: 1.2; }
.compact-page .accounts-table thead th { vertical-align: top; white-space: nowrap; }
.accounts-table .th-label { display: block; line-height: 1.2; min-height: 1.2em; }
.accounts-table th.num .th-label { text-align: right; }
.compact-page .accounts-table thead th.total-head { text-align: center; vertical-align: top; }
.accounts-table th.total-head .total-label, .accounts-table th.total-head #accounts-total { text-align: center; }
.accounts-table th.total-head #accounts-total { margin-top: .25rem; line-height: 1.6rem; }
/* Okno History: licznik i suma nad tabelą (suma z prawej, jak w tabeli Accounts). */
.history-bar { justify-content: flex-start; }
.history-total { margin-left: auto; text-align: center; }
.history-total .total-label { display: block; font-size: .62rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; }
#history-total { font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; cursor: help; }
#history-total.neg { color: var(--neg); }
.history-table { max-height: max(300px, calc(100vh - 330px)); }
/* Ostrzeżenie (pomarańczowe) — np. brak kursu pod wykresem trendu. */
.warn { color: #ffb547; }
/* Accounts: nieuprawniony debet (ujemne saldo bez limitu kredytowego). */
.overdraft-flag {
  display: inline-flex; align-items: center; justify-content: center; width: 1rem; height: 1rem; margin-right: .35rem;
  border-radius: 50%; background: rgba(255, 181, 71, .18); color: #ffb547; font-size: .7rem; font-weight: 800;
  vertical-align: 1px; cursor: help;
}
/* Structure → Credit limits: węższe kolumny, suma pod tabelą. */
.compact-page .limits-table th, .compact-page .limits-table td { padding-left: .45rem; padding-right: .45rem; }
.limits-table .fx-note { white-space: nowrap; }
.limits-table tfoot td { border-top: 1px solid var(--border); padding-top: .5rem; padding-bottom: .5rem; color: var(--text-dim); }
.limits-table tfoot strong { color: var(--text); }
/* Dashboard: 5 kafelków w jednym rzędzie na typowym ekranie. */
.kpi-grid.kpi-grid-5 { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: .75rem; }
.kpi-grid-5 .kpi-value { font-size: 1.35rem; }
/* Kwota wyglądająca jak link (np. „on cession accounts …”). */
.link-button {
  background: none; border: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer;
  text-decoration: underline; text-decoration-color: rgba(79, 140, 255, .4); text-underline-offset: 2px;
}
.link-button:hover, .link-button:focus-visible { color: var(--accent-hover); background: none; text-decoration-color: currentColor; }
#cession-dialog { width: min(1420px, 97vw); }
#cession-dialog .body { padding-top: .75rem; }
.cession-table { max-height: calc(88vh - 12rem); }
/* Okno cession: mniejsza czcionka i ciaśniejsze komórki — wszystkie kolumny bez przewijania w bok. */
.cession-table table { font-size: .78rem; }
.cession-table th, .cession-table td { padding: .4rem .5rem; }
.cession-table th { font-size: .66rem; }
.cession-table .col-filter { font-size: .72rem; padding: .1rem .3rem; max-width: 8.5rem; }
.cession-table td.bank-cell { white-space: nowrap; }
.cession-table .logo { height: 18px; width: auto; max-width: 60px; padding: 2px; border-radius: 4px; margin-right: .35rem; }
.cession-table td .hint { font-size: .68rem; margin: .1rem 0 0; }

/* Dashboard: niższe filtry, mniejszy odstęp do ostrzeżeń. */
.dash-filters { gap: .6rem; margin: .25rem 0 .45rem; }
.dash-filters label { font-size: .72rem; margin-bottom: .2rem; }
.dash-filters select { padding: .28rem 1.5rem .28rem .55rem; font-size: .82rem; }
.dash-filters .dash-asof { margin-bottom: .3rem; }
#dash-filters + #global:empty { display: none; }
#dash-filters ~ .dash-warnings { margin-bottom: .9rem; padding: .45rem .75rem; }

/* Netting per spółka: dymek z kwotami per bank. */
.tip-bank { display: flex; align-items: center; gap: .4rem; }
.tip-bank img { height: 14px; width: auto; max-width: 40px; background: #fff; border-radius: 3px; padding: 1px; }
.tip-bank-dot { width: 14px; height: 14px; border-radius: 3px; background: var(--surface-2); flex: none; }

/* Kursy walut (dwie osie) i Needs attention obok — ta sama wysokość karty. */
.fx-pick { display: inline-flex; align-items: center; gap: .35rem; }
.fx-pick select { padding: .25rem 1.5rem .25rem .5rem; font-size: .8rem; }
#fx-card .dash-controls .pill { padding: .25rem .6rem; }
.attention-card { display: flex; flex-direction: column; }
.attention-box { position: relative; flex: 1 1 auto; min-height: 260px; }
.attention-box > .attention { position: absolute; inset: 0; overflow-y: auto; align-content: start; padding-right: .35rem; }

/* ---------- Transactions (cash flow) ---------- */
.cf-filters { align-items: flex-end; flex-wrap: wrap; }
.dash-wide { margin: 0 0 .9rem; }
.cf-table { max-height: 380px; overflow: auto; }
.cf-gap { margin-top: .6rem; }
.cf-table td.pos { color: var(--pos); }
.cf-net-cell { position: relative; white-space: nowrap; min-width: 110px; }
.cf-net-cell .cf-bar { position: absolute; right: .45rem; top: 25%; height: 50%; opacity: .22; border-radius: 3px; }
.cf-net-cell span:last-child { position: relative; }
.cf-bar.in { background: var(--pos); }
.cf-bar.out { background: var(--neg); }
.cf-categories { display: grid; gap: .45rem; margin: .3rem 0 .6rem; }
.cf-cat { display: grid; grid-template-columns: 9.5rem 1fr 4.5rem; align-items: center; gap: .6rem; font-size: .82rem; cursor: help; }
.cf-cat-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); }
.cf-cat-bars { display: grid; gap: 2px; }
.cf-cat-bars .cf-bar { height: .45rem; border-radius: 3px; min-width: 2px; }
.cf-cat-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.cf-total { font-weight: 650; }
.net-swatch { background: #e8ebf1; border-radius: 50%; }
.kpi-value.pos, .cf-cat-value.pos { color: var(--pos); }
.cf-filters .check { display: flex; gap: .4rem; align-items: center; font-size: .85rem; color: var(--text-dim); padding-bottom: .45rem; }
@media (min-width: 900px) { .cf-categories { grid-template-columns: 1fr 1fr; column-gap: 2.5rem; } }
.cf-table.cf-matrix { max-height: none; }
.cf-matrix tfoot td { border-top: 1px solid var(--border-strong); font-weight: 600; }

/* ---------- Admin: jump links + Roadmap ---------- */
.jump-links { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .85rem; margin-top: .3rem; }
.jump-links a { color: var(--text-dim); }
.jump-links a:hover { color: var(--text); }
.rm-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; }
.rm-toolbar select, .rm-toolbar input[type="search"] { width: auto; min-width: 11rem; }
.rm-form { max-width: 820px; }
.rm-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 1rem; }
.rm-form textarea { width: 100%; resize: vertical; font: inherit; }
.rm-table td { vertical-align: top; }
.rm-title { max-width: 640px; }
.rm-desc {
  color: var(--text-dim); font-size: .8rem; margin-top: .15rem; cursor: pointer; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.rm-desc.open { display: block; }
.rm-status { width: auto; padding: .2rem .4rem; font-size: .8rem; }
.rm-actions { white-space: nowrap; }
.rm-actions button { padding: .2rem .55rem; font-size: .78rem; margin-right: .25rem; }
.rm-origin { font-size: .72rem; }
.rm-active td { background: rgba(79, 140, 255, .06); }
.badge.rm-p1 { background: rgba(255, 93, 115, .15); color: var(--neg); }
.badge.rm-p2 { background: rgba(255, 181, 71, .15); color: #ffcf7a; }
.badge.rm-p3 { background: rgba(154, 164, 182, .14); color: var(--text-dim); }
.badge.rm-fix { background: rgba(255, 181, 71, .15); color: #ffcf7a; }

/* Transactions: przyklejone filtry, panel kategorii wewnętrznych, okna operacji i wymiany walut */
.cf-sticky {
  position: sticky; top: var(--topbar-h, 64px); z-index: 15;
  margin: 0 -1rem .6rem; padding: .5rem 1rem .4rem;
  background: rgba(11, 14, 20, .94); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.cf-sticky .filters { margin-bottom: 0; }
.cf-internal { position: relative; padding-bottom: .45rem; }
.cf-internal .check { padding-bottom: 0; cursor: pointer; }
.cf-caret { font-size: .7rem; color: var(--text-dim); }
.cf-internal-panel {
  display: none; position: absolute; right: 0; top: 100%; z-index: 30; width: min(440px, 90vw);
  padding: .7rem .85rem; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 12px; box-shadow: var(--shadow);
}
.cf-internal:hover .cf-internal-panel, .cf-internal:focus-within .cf-internal-panel { display: block; }
.cf-internal-head, .cf-internal-foot { margin: 0 0 .5rem; font-size: .78rem; color: var(--text-dim); }
.cf-internal-foot { margin: .5rem 0 0; }
.cf-internal-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: .55rem; align-items: start;
  padding: .3rem 0; font-size: .84rem; border-top: 1px solid var(--border); cursor: pointer;
}
.cf-internal-item input { margin-top: .15rem; }
.cf-internal-name { color: var(--text); }
.cf-internal-rules { display: block; color: var(--text-dim); font-size: .74rem; }
.cf-internal-amount { white-space: nowrap; color: var(--text-dim); font-size: .78rem; font-variant-numeric: tabular-nums; }

/* Lista rozwijana wielokrotnego wyboru (Transactions: Company, Category) */
.ms { position: relative; }
.ms-button {
  display: inline-flex; align-items: center; justify-content: space-between; gap: .5rem;
  min-width: 11rem; max-width: 16rem; text-align: left; font-weight: 400; font-size: 1rem; line-height: normal;
  padding: .5rem .7rem; background: var(--bg-elev);
}
.ms-button:hover { background: var(--bg-elev); }
.ms-button:active { transform: none; }
.ms-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-panel {
  position: absolute; left: 0; top: calc(100% + 4px); z-index: 30; width: max(100%, 260px); max-height: 360px; overflow: auto;
  padding: .5rem .7rem; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow);
}
.ms-actions { display: flex; justify-content: space-between; gap: .8rem; padding-bottom: .35rem; font-size: .78rem; }
.ms-item { display: flex; align-items: center; gap: .5rem; padding: .25rem 0; font-size: .84rem; cursor: pointer; border-top: 1px solid var(--border); }
.filters .ms-item { font-weight: 400; color: var(--text); margin: 0; }

/* Sekcje Transactions: link w nagłówku przewija pod przyklejonym paskiem filtrów */
.cf-section { scroll-margin-top: calc(var(--cf-sticky-h, 140px) + .6rem); }
.cf-subhead { margin-top: 1.4rem; }
.cf-subhead h3 { margin: 0; font-size: 1rem; }

/* Macierz intercompany */
.ic-legend { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1rem; font-size: .82rem; margin: .1rem 0 .5rem; }
.ic-legend-item { display: inline-flex; align-items: center; gap: .35rem; }
.ic-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; vertical-align: middle; }
.ic-currency { margin-bottom: .6rem; }
.ic-currency .pill .ic-dot { margin-right: .1rem; }
.ic-matrix td.ic-self { background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255, 255, 255, .035) 6px 12px); }
.ic-matrix th.ic-corner { color: var(--text-dim); font-weight: 500; }
.ic-amount { display: inline-flex; align-items: center; gap: .45rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ic-dots { display: inline-flex; gap: 3px; }
.fx-leg-cell { cursor: help; text-decoration: underline dotted rgba(255, 255, 255, .25); text-underline-offset: 3px; }
.fx-leg-line { white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge.cf-src { font-size: .64rem; padding: 0 .4rem; margin-left: .35rem; vertical-align: middle; }
.cf-int-mark { font-size: .7rem; color: var(--text-dim); }
.cf-cat .cf-cat-label { text-align: left; color: var(--text); text-decoration: none; cursor: pointer; }
.cf-cat .cf-cat-label:hover { color: var(--accent-hover); text-decoration: underline; }
.cf-cat { cursor: default; }
.cf-cat-bars { cursor: help; }
.dialog-filters { margin: .9rem 0 .4rem; flex-wrap: wrap; align-items: flex-end; }
#tx-dialog, #fx-dialog { width: min(1280px, 97vw); }
.tx-table, .fx-table { max-height: calc(88vh - 15rem); }
.tx-title-cell { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); }
.nowrap { white-space: nowrap; }
.fx-diff-summary { display: flex; flex-wrap: wrap; gap: .4rem 1.6rem; margin: .4rem 0 .7rem; font-size: .88rem; color: var(--text-dim); }
.fx-accounts { font-size: .78rem; white-space: nowrap; }

/* Transactions (2026-10-08): mniejsze odstępy i czcionki, filtry jednej wysokości, okna bez przewijania w bok. */
.cf-page .page-head { margin-bottom: .3rem; }
.cf-page .cf-sticky { padding-top: .35rem; padding-bottom: .3rem; }
.cf-filters { gap: .55rem; }
.cf-filters label, .cf-page .dialog-filters label { font-size: .7rem; margin-bottom: .2rem; }
.cf-filters input[type="date"], .cf-filters .ms-button,
.cf-page .dialog-filters input[type="date"], .cf-page .dialog-filters select, .cf-page .dialog-filters .ms-button {
  box-sizing: border-box; height: 1.85rem; padding-top: 0; padding-bottom: 0; font-size: .8rem; line-height: 1.2;
}
.cf-filters .ms-button, .cf-page .dialog-filters .ms-button { min-width: 9.5rem; padding-left: .55rem; padding-right: .55rem; }
.cf-filters .pill { padding: .22rem .6rem; font-size: .76rem; }
.cf-filters .check { font-size: .8rem; padding-bottom: .4rem; }
.cf-page .dialog-filters { margin: .5rem 0 .35rem; gap: .55rem; }
.cf-cat .link-button.cf-cat-label { color: var(--accent); text-decoration: underline; text-decoration-color: rgba(79, 140, 255, .4); }
.cf-cat .link-button.cf-cat-label:hover { color: var(--accent-hover); text-decoration-color: currentColor; }
#tx-dialog, #fx-dialog { width: min(1440px, 97vw); }
.tx-table table, .fx-table table { font-size: .76rem; }
.tx-table th, .fx-table th { font-size: .62rem; padding: .4rem .45rem; white-space: normal; vertical-align: bottom; line-height: 1.15; }
.tx-table td, .fx-table td { padding: .3rem .45rem; }
.tx-table .tx-title-cell { max-width: 300px; }
.fx-table .fx-company { font-size: .72rem; }
.fx-table .fx-accounts { font-size: .72rem; }
.fx-diff-summary { font-size: .8rem; margin: .3rem 0 .5rem; }
#sec-fx table, #sec-intercompany table { font-size: .78rem; }
#sec-fx th, #sec-intercompany th { font-size: .62rem; padding: .4rem .55rem; }
#sec-fx td, #sec-intercompany td { padding: .35rem .55rem; }
.cf-subhead h3 { font-size: .85rem; }
#sec-intercompany .dash-card-head h2 { font-size: .9rem; }
#ic-total { font-size: .8rem; }
.cf-table td .link-button { padding: 0; font-size: inherit; line-height: inherit; vertical-align: baseline; }
.fx-leg-link { color: inherit; text-decoration: underline dotted; text-decoration-color: currentColor; text-underline-offset: 3px; }
.fx-leg-link:hover { color: inherit; filter: brightness(1.2); }
#sec-monthly { margin-top: .9rem; }
#sec-monthly .dash-card-head h2 { font-size: .9rem; }
.cf-monthly-chart .hit.clickable { cursor: pointer; }

/* ---------- Admin: kreator migracji zgód PSD2 ---------- */
#mig-dialog { width: min(1180px, 96vw); }
#mig-dialog .body { padding-top: .8rem; }
.mig-steps { display: flex; gap: .4rem; list-style: none; padding: 0; margin: 0 0 1rem; counter-reset: step; flex-wrap: wrap; }
.mig-steps li { counter-increment: step; padding: .3rem .8rem; border-radius: 999px; border: 1px solid var(--border); color: var(--text-dim); font-size: .82rem; }
.mig-steps li::before { content: counter(step) ". "; }
.mig-steps li.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.mig-steps li.done { color: var(--pos); border-color: rgba(31, 209, 139, .4); }
.mig-drop {
  display: flex; flex-direction: column; gap: .3rem; align-items: center; text-align: center; cursor: pointer;
  padding: 1.6rem 1rem; margin: .6rem 0; border: 2px dashed var(--border-strong); border-radius: 12px; color: var(--text);
}
.mig-drop:hover, .mig-drop:focus-visible, .mig-drop.over { border-color: var(--accent); background: rgba(79, 140, 255, .06); }
.mig-issues { margin: .3rem 0 .6rem; padding-left: 1.2rem; font-size: .82rem; max-height: 220px; overflow: auto; }
.mig-issues li.error { color: var(--neg); }
.mig-issues li.warning { color: #ffcf7a; }
.mig-nav { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .8rem; }
.mig-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; margin: .5rem 0 .8rem; }
.mig-tile { display: flex; flex-direction: column; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.mig-tile strong { font-size: 1.25rem; }
.mig-tile span { font-size: .75rem; color: var(--text-dim); }
.mig-tile.ok strong { color: var(--pos); }
.mig-tile.warn strong { color: #ffcf7a; }
.mig-tile.err strong { color: var(--neg); }
.mig-table { max-height: 320px; overflow: auto; margin-bottom: .6rem; }
.mig-table td { vertical-align: top; }
.mig-note { font-size: .76rem; color: var(--text-dim); }
#mig-dialog h3 { font-size: .95rem; margin: .9rem 0 .3rem; }
.badge.mig-new { background: rgba(31, 209, 139, .15); color: var(--pos); }
.badge.mig-attach { background: rgba(79, 140, 255, .16); color: var(--accent-hover); }
.badge.mig-conflict, .badge.mig-skipped { background: rgba(255, 93, 115, .15); color: var(--neg); }
.badge.mig-already-imported { background: rgba(154, 164, 182, .14); color: var(--text-dim); }
#bal-dialog { width: min(1180px, 96vw); }
#bal-dialog .body { padding-top: .8rem; }

/* ---------- Okno „Citi bank statements” (static/bank-feed.js) ---------- */
.bank-feed-dialog { width: min(980px, 96vw); }
.bank-feed-dialog .body { padding-top: .8rem; }
.bf-checklist { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; align-items: baseline; padding: .7rem .9rem; margin-bottom: .6rem;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.bf-checklist ol { display: flex; flex-wrap: wrap; gap: .3rem 1rem; list-style: none; margin: 0; padding: 0; font-size: .82rem; color: var(--text-dim); }
.bf-checklist li.done { color: var(--pos); }
.bf-section { border-top: 1px solid var(--border); padding: .7rem 0 .4rem; }
.bf-section h3 { font-size: .95rem; margin: 0 0 .4rem; }
.bf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .4rem .9rem; }
.bf-field { display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; color: var(--text-dim); }
.bf-dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: .3rem 0 .5rem; font-size: .86rem; }
.bf-dl dt { color: var(--text-dim); }
.bf-dl dd { margin: 0; }
.bf-mono { font-family: ui-monospace, Consolas, monospace; font-size: .74rem; word-break: break-all; }
.bf-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.bf-steps { margin: .3rem 0; padding-left: 1.2rem; font-size: .85rem; }
.bf-steps li.ok { color: var(--pos); }
.bf-steps li.err { color: var(--neg); }
.bf-uploads { margin: .3rem 0; padding-left: 1.1rem; font-size: .82rem; max-height: 260px; overflow: auto; }
.bf-msg { min-height: 1em; margin: .3rem 0 0; font-size: .85rem; }
.badge.bf-warn { background: rgba(255, 181, 71, .15); color: #ffcf7a; margin-left: .4rem; }

/* Historia sald odtworzona z transakcji — statusy */
.badge.hist-verified, .badge.hist-corrected { background: rgba(31, 209, 139, .15); color: var(--pos); }
.badge.hist-unverified { background: rgba(154, 164, 182, .14); color: var(--text-dim); }
.badge.hist-mismatch { background: rgba(255, 93, 115, .15); color: var(--neg); }
.badge.hist-skipped { background: rgba(255, 181, 71, .15); color: #ffcf7a; }

/* Logowanie: drugi krok (kod z e-maila) */
#code-input { letter-spacing: .35em; font-size: 1.2rem; font-variant-numeric: tabular-nums; text-align: center; }
.code-actions { display: flex; justify-content: space-between; gap: 1rem; font-size: .85rem; }
.code-actions .link-button:disabled { color: var(--text-faint); text-decoration: none; cursor: default; }

/* Structure → Scheduled balance entries: start, time and end in one row */
.schedule-when { display: flex; flex-wrap: wrap; gap: 0 1.25rem; }
.schedule-when p { margin-top: 0; }

/* Language switch on the login and home pages (EN / PL) */
.auth-card { position: relative; }
.lang-switch { position: absolute; top: .75rem; right: .75rem; display: flex; gap: .25rem; }
.lang-switch button { padding: .15rem .45rem; font-size: .75rem; min-height: 0; background: transparent; }
.lang-switch button.active { border-color: var(--accent, #4f8cff); color: var(--accent, #4f8cff); }

/* Structure: re-classification running in the background */
.reclass-status { margin: .25rem 0 .75rem; padding: .45rem .75rem; border-radius: 8px; font-size: .85rem;
  background: rgba(79, 140, 255, .12); color: var(--text, #e8ebf1); }
.reclass-status.ok { background: rgba(46, 160, 67, .14); }
.reclass-status.err { background: rgba(229, 72, 77, .14); }

/* Admin: bank call usage (last 24 h) */
#usage-dialog { width: min(1280px, 97vw); }
#usage-dialog .small { font-size: .78rem; }

/* Accounts: transactions incomplete (balance moved differently than the transactions explain) */
.gap-flag { display: inline-block; margin-right: .35rem; color: #f0a020; font-weight: 700; cursor: help; }

/* Structure: VAT account balances — entered balances with the calculation drift */
.vat-anchor { padding: .1rem 0; }
.vat-anchor .small-btn { padding: .05rem .45rem; font-size: .75rem; }

/* Structure: logo w tabelach sald VAT i harmonogramu (bez wysokości wiersza rosło do rozmiaru obrazka). */
#vat-body .logo, #schedules-body .logo { height: 28px; width: auto; max-width: 100px; }
/* Structure → Users: rola w jednej linii, spółki po przecinku (zawijane). */
#team-body .team-role { max-width: 34rem; line-height: 1.45; }
#team-body .team-role + .team-role { margin-top: .2rem; }
#team-body .team-role-name { font-weight: 600; }
/* Transactions: „By category” w połowie szerokości (obok opłat bankowych) — jedna kolumna, pełne nazwy. */
@media (min-width: 900px) { .dash-grid .cf-categories { grid-template-columns: 1fr; } }
.dash-grid .cf-cat { grid-template-columns: 12rem 1fr 4.5rem; }
/* Opłaty bankowe per spółka: części słupka klikalne, kolor spółki także w dymku. */
.cf-monthly-chart rect.clickable { cursor: pointer; }
.cf-monthly-chart rect.clickable:hover { opacity: .85; }
.tip .swatch { display: inline-block; vertical-align: -1px; }

/* Structure → Budget exchange rates: tabela na rok (karty obok siebie). */
.budget-years { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: .8rem; margin-top: .6rem; }
.budget-year { padding: .7rem .9rem; }
.budget-year-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; }
.budget-year table { width: 100%; }
.budget-rate-input { width: 8.5rem; text-align: right; }
.budget-year-input { width: 6rem; }
.budget-add label { align-self: center; }
.budget-client + .budget-client { margin-top: 1.2rem; }

/* FX netting: kropki spółek przy kwotach kupna/sprzedaży walut i legenda nad tabelą. */
.fx-company-dots { margin-right: .4rem; }
.fx-company-legend { margin-bottom: .35rem; }
/* FX netting: tabela par — długie nagłówki zawijane, żeby 9 kolumn mieściło się bez przewijania. */
.fx-pairs-table th { white-space: normal; vertical-align: bottom; line-height: 1.25; }
.fx-pairs-table th.num { max-width: 9.5rem; }

/* Linki do sekcji: płynne przewijanie; w Strukturze nagłówek sekcji nie chowa się pod paskiem. */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
main > section[id] { scroll-margin-top: calc(var(--topbar-h, 64px) + .8rem); }
/* FX netting: podsekcje w karcie z odstępem od tabeli powyżej i nagłówkiem jak tytuł sekcji. */
.cf-subhead h2 { margin: 0; }
.fx-company-legend { margin: .2rem 0 .45rem; }

/* Pulpit: legenda pierścieni (Deposits by / Credits by) i netting spółek wypełniają wysokość karty (wyznacza ją karta obok
   w rzędzie, jak w Needs attention), a lista dłuższa niż miejsce przewija się — bez sumowania w „Other”. */
.dash-card[data-donut], .netting-card { display: flex; flex-direction: column; }
.dash-card[data-donut] .donut-wrap { flex: 1 1 auto; align-items: flex-start; }
.scroll-fill { position: relative; flex: 1 1 auto; min-width: 0; }
.scroll-fill > * { position: absolute; inset: 0; overflow-y: auto; align-content: start; padding-right: .4rem; }
.legend-box { flex: 1 1 200px; align-self: stretch; min-height: 200px; }
.netting-card .scroll-fill { min-height: 220px; }
/* Delikatny pasek przewijania (wąski, w kolorze obramowania). W Chromium ::-webkit-scrollbar działa tylko przy
   scrollbar-width/color = auto — stąd nadpisanie globalnego „thin”; Firefox (bez ::-webkit-scrollbar) — thin. */
.soft-scroll { scrollbar-width: auto; scrollbar-color: auto; }
.soft-scroll::-webkit-scrollbar { width: 5px; height: 5px; }
.soft-scroll::-webkit-scrollbar-track { background: transparent; }
.soft-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
.soft-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
@supports not selector(::-webkit-scrollbar) {
  .soft-scroll { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
}
