/* ------------------------------------------------------------------ tokens */
:root {
  --page: #f9f9f7;           /* page background */
  --surface: #fcfcfb;        /* cards and charts */
  --ink-1: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #898781;          /* axes and muted labels */
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --outline: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;       /* blue: income / paid / spent */
  --series-2: #eb6834;       /* orange: expenses / due */
  --positive: #2a78d6;       /* diverging: in credit */
  --negative: #e34948;       /* diverging: in debt */
  --success-text: #006300;
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-critical: #d03b3b;
  --accent-soft: #cde2fb;    /* meter track (blue ramp, step 100) */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* owner app */
  --brand: #1f5fb8;
  --tint: #e7f0fc;           /* icon tiles, active navigation */
  --ok-bg: #e7f5ea;
  --debt-bg: #fdeceb;
  --negative-text: #b42318;  /* red text on light backgrounds (AA contrast) */
  --shadow: 0 1px 2px rgba(11, 11, 11, .04), 0 6px 20px rgba(11, 11, 11, .05);
}
:root[data-bs-theme="dark"] {
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink-1: #f0efec;
  --ink-2: #c3c2b7;
  --ink-3: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --outline: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --positive: #3987e5;
  --negative: #e66767;
  --success-text: #0ca30c;
  --accent-soft: #184f95;
  --bs-body-bg: #0d0d0d;
  --bs-tertiary-bg: #141413;
  --brand: #6aa6f2;
  --tint: #172a42;
  --ok-bg: #11291a;
  --debt-bg: #361b1a;
  --negative-text: #ff8f87;
  --shadow: none;
}

body { font-family: var(--font-sans); background: var(--page); }
.card { background: var(--surface); border-color: var(--outline); }
.navbar.bg-body-tertiary { background: var(--surface) !important; }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-sm td, .table-sm th { vertical-align: middle; }
.table { --bs-table-bg: transparent; }
.negative { color: var(--negative); }
.positive { color: var(--success-text); }
.status-unvalidated, .badge-unvalidated { background: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis); }
.explanation { font-size: .82rem; color: var(--bs-secondary-color); }
.card-kpi .value { font-size: 1.5rem; font-weight: 600; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }
@media (max-width: 576px) { h1 { font-size: 1.5rem; } }

/* ------------------------------------------------------------- dashboard */
.dashboard-filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.hero { font-size: clamp(2.5rem, 6vw, 3.5rem); font-weight: 600; line-height: 1.05; color: var(--ink-1); letter-spacing: -0.02em; }
.hero-label, .tile-label { color: var(--ink-2); font-size: .875rem; }
.tile-value { font-size: 1.75rem; font-weight: 600; color: var(--ink-1); line-height: 1.2; }
.tile-note { color: var(--ink-2); font-size: .8125rem; }
.panel { background: var(--surface); border: 1px solid var(--outline); border-radius: 12px; padding: 1.25rem; height: 100%; }
.panel h2 { font-size: 1rem; font-weight: 600; margin: 0 0 .25rem; color: var(--ink-1); }
.panel .subtitle { color: var(--ink-2); font-size: .8125rem; margin-bottom: .75rem; }
.meter { height: 8px; border-radius: 4px; background: var(--accent-soft); overflow: hidden; margin: .5rem 0 .25rem; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--series-1); }
.meter.warning > span { background: var(--status-warning); }
.meter.critical > span { background: var(--status-critical); }
.alert-item { display: flex; gap: .75rem; align-items: flex-start; padding: .625rem 0; border-top: 1px solid var(--grid); color: var(--ink-1); text-decoration: none; }
.alert-item:first-child { border-top: 0; }
.alert-item:hover .alert-text { text-decoration: underline; }
.alert-item .bi { font-size: 1.1rem; line-height: 1.3; }
.alert-count { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-table summary { color: var(--ink-2); font-size: .8125rem; cursor: pointer; margin-top: .5rem; }

/* ---------------------------------------------------------------- charts */
.chart { position: relative; width: 100%; min-width: 0; min-height: 40px; overflow-x: clip; }
.panel, .row > [class*="col"] { min-width: 0; }
.chart svg { display: block; overflow: visible; font-family: var(--font-sans); }
.g-axis { font-size: 11px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.g-axis-cat { font-size: 12px; fill: var(--ink-2); }
.g-label { font-size: 12px; fill: var(--ink-1); font-weight: 600; }
.g-grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.g-base { stroke: var(--baseline); stroke-width: 1; shape-rendering: crispEdges; }
.g-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.g-stroke-1 { stroke: var(--series-1); }
.g-stroke-2 { stroke: var(--series-2); }
.g-series-1 { fill: var(--series-1); }
.g-series-2 { fill: var(--series-2); }
.g-area { opacity: .10; }
.g-dot { stroke: var(--surface); stroke-width: 2; }
.g-positive { fill: var(--positive); }
.g-negative { fill: var(--negative); }
.g-target { stroke: var(--ink-1); stroke-width: 2; stroke-linecap: round; }
.g-crosshair { stroke: var(--ink-3); stroke-width: 1; }
.g-hit { fill: transparent; cursor: default; outline: none; }
.g-hit:focus-visible { stroke: var(--ink-2); stroke-width: 1; }
.g-group { transition: opacity .12s; }
.chart:has(.g-active) .g-group:not(.g-active) { opacity: .45; }
.g-empty { color: var(--ink-2); font-size: .875rem; margin: 1rem 0; }
.g-tooltip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface); color: var(--ink-1);
  border: 1px solid var(--outline); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.12); padding: .5rem .625rem;
  font-size: .8125rem; min-width: 9rem; white-space: nowrap; }
.g-tooltip-title { color: var(--ink-2); margin-bottom: .25rem; }
.g-tooltip-row { display: flex; align-items: center; gap: .4rem; }
.g-tooltip-row strong { font-variant-numeric: tabular-nums; }
.g-tooltip-name { color: var(--ink-2); }
.g-legend { display: flex; flex-wrap: wrap; gap: .25rem 1rem; list-style: none; padding: 0; margin: .5rem 0 0; font-size: .8125rem; color: var(--ink-2); }
.g-legend li { display: flex; align-items: center; gap: .375rem; }
.g-key { display: inline-block; flex: none; }
.g-tooltip .g-key { width: 12px; height: 2px; border-radius: 1px; }
.g-tooltip .g-stroke-1 { background: var(--series-1); }
.g-tooltip .g-stroke-2 { background: var(--series-2); }
.g-legend .g-key { width: 10px; height: 10px; border-radius: 2px; }
.g-swatch-1 { background: var(--series-1); }
.g-swatch-2 { background: var(--series-2); }
.g-swatch-positive { background: var(--positive); }
.g-swatch-negative { background: var(--negative); }
.g-legend .g-key-target { width: 2px; height: 14px; border-radius: 1px; background: var(--ink-1); }

@media print { .g-tooltip, .dashboard-filters { display: none !important; } }

/* ============================================================ owner app (mobile first) */
body.owner-ui { -webkit-tap-highlight-color: transparent; }
.owner-main { max-width: 960px; padding-top: .5rem; padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
@media (min-width: 992px) { .owner-main { padding-bottom: 3rem; } }
.owner-main > .alert { margin-top: .75rem; border-radius: 12px; }

/* top bar */
.app-bar { position: sticky; top: 0; z-index: 1030; padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--outline); }
.app-bar-inner { display: flex; align-items: center; gap: 1rem; min-height: 60px; max-width: 960px; }
.app-brand { display: flex; align-items: center; gap: .625rem; color: var(--ink-1); text-decoration: none; min-width: 0; }
.app-brand img { border-radius: 9px; flex: none; }
.app-brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.app-brand-text strong { font-size: 1rem; }
.app-brand-text small { color: var(--ink-2); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55vw; }
.app-links { gap: .25rem; margin-left: 1rem; align-items: center; flex-wrap: nowrap; }
.app-links a { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; line-height: 1.2;
  padding: .45rem .85rem; border-radius: 999px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.app-links a:hover { color: var(--ink-1); background: var(--tint); }
.app-links a.active { color: var(--brand); background: var(--tint); }
.avatar { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--brand); color: #fff;
  font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.avatar:focus-visible { outline: 3px solid var(--tint); outline-offset: 2px; }

/* bottom tabs (phone / tablet) */
.tab-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--outline);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); }
.tab-bar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px;
  color: var(--ink-3); text-decoration: none; font-size: .6875rem; font-weight: 500; }
.tab-bar a .bi { font-size: 1.35rem; line-height: 1; }
.tab-bar a.active { color: var(--brand); }

/* page structure */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin: .75rem 0 1rem; }
.page-head > .btn, .page-head > .badge { flex: none; white-space: nowrap; }
.page-head h1 { font-size: 1.625rem; font-weight: 700; letter-spacing: -0.02em; margin: 0; overflow-wrap: anywhere; }
.eyebrow { color: var(--ink-2); font-size: .8125rem; margin-bottom: .1rem; }
.back-link { display: inline-flex; align-items: center; gap: .25rem; min-height: 44px; margin-top: .25rem; color: var(--ink-2);
  text-decoration: none; font-size: .9375rem; }
.back-link:hover { color: var(--brand); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 1.5rem 0 .5rem; }
.section-head h2 { font-size: 1rem; font-weight: 700; margin: 0; }
.section-head a { font-size: .875rem; text-decoration: none; }
.owner-ui .panel { border-radius: 16px; box-shadow: var(--shadow); }

/* unit status */
.unit-card { background: var(--surface); border: 1px solid var(--outline); border-radius: 20px; padding: 1.1rem;
  box-shadow: var(--shadow); margin-bottom: 1rem; }
.unit-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.unit-head h2 { font-size: 1.125rem; font-weight: 700; margin: 0; }
.unit-sub { color: var(--ink-2); font-size: .8125rem; }
.status-hero { border-radius: 16px; padding: 1rem 1.1rem; margin-top: .9rem; }
.unit-card > .status-hero:first-child { margin-top: 0; }
.status-hero.is-ok { background: var(--ok-bg); }
.status-hero.is-debt { background: var(--debt-bg); }
.status-label { font-size: .875rem; font-weight: 600; display: flex; align-items: center; gap: .375rem; }
.is-ok .status-label { color: var(--success-text); }
.is-debt .status-label { color: var(--negative-text); }
.status-amount { font-size: clamp(1.9rem, 8vw, 2.4rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15;
  color: var(--ink-1); font-variant-numeric: tabular-nums; }
.status-note { color: var(--ink-2); font-size: .875rem; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: .75rem; }
.fact { border: 1px solid var(--outline); border-radius: 14px; padding: .75rem .9rem; min-width: 0; }
.fact-label { color: var(--ink-2); font-size: .78rem; }
.fact-value { font-size: 1.15rem; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--ink-1); }
.fact-note { color: var(--ink-3); font-size: .75rem; }
.note-validation { font-size: .8125rem; background: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis);
  border-radius: 10px; padding: .5rem .75rem; margin: .75rem 0 0; }

/* quick actions */
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin: 1rem 0 .5rem; }
.quick-actions a { display: flex; flex-direction: column; align-items: center; gap: .375rem; padding: .9rem .5rem;
  background: var(--surface); border: 1px solid var(--outline); border-radius: 16px; color: var(--ink-1);
  text-decoration: none; font-size: .8125rem; font-weight: 500; text-align: center; box-shadow: var(--shadow); }
.quick-actions a .bi { font-size: 1.4rem; color: var(--brand); }
.quick-actions a:hover { border-color: var(--brand); }

/* lists */
.list-card { background: var(--surface); border: 1px solid var(--outline); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.list-row { display: flex; align-items: center; gap: .8rem; padding: .75rem 1rem; min-height: 64px; color: inherit;
  text-decoration: none; border-top: 1px solid var(--grid); }
.list-row:first-child { border-top: 0; }
a.list-row:hover { background: color-mix(in srgb, var(--tint) 50%, transparent); color: inherit; }
a.list-row:active { background: var(--tint); }
.list-icon { width: 40px; height: 40px; flex: none; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: var(--tint); color: var(--brand); font-size: 1.15rem; }
.list-icon.is-credit { background: var(--ok-bg); color: var(--success-text); }
.list-row.is-future .list-icon { background: transparent; border: 1px dashed var(--baseline); color: var(--ink-3); }
.list-row.is-future .list-title, .list-row.is-future .amount { color: var(--ink-2); }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 600; font-size: .9375rem; overflow-wrap: anywhere; }
.list-sub { color: var(--ink-2); font-size: .8125rem; overflow-wrap: anywhere; }
.list-end { flex: none; text-align: right; }
.amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* notices */
.notice-card { background: var(--surface); border: 1px solid var(--outline); border-radius: 16px; padding: 1rem 1.1rem;
  margin-bottom: .75rem; box-shadow: var(--shadow); scroll-margin-top: 80px; }
.notice-card:target { border-color: var(--brand); box-shadow: 0 0 0 3px var(--tint); }
.notice-card h2 { font-size: 1.0625rem; font-weight: 700; margin: .25rem 0 .5rem; }
.notice-date { color: var(--ink-2); font-size: .8125rem; }

/* tickets */
.ticket-outstanding { background: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis); }
.ticket-in_analysis { background: var(--bs-info-bg-subtle); color: var(--bs-info-text-emphasis); }
.ticket-in_progress { background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); }
.ticket-resolved { background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
.ticket-closed { background: var(--bs-secondary-bg-subtle); color: var(--bs-secondary-text-emphasis); }
.thread { display: flex; flex-direction: column; gap: .625rem; }
.bubble { max-width: 88%; align-self: flex-start; background: var(--surface); border: 1px solid var(--outline);
  border-radius: 16px 16px 16px 4px; padding: .65rem .85rem; }
.bubble.is-mine { align-self: flex-end; background: var(--tint); border-color: transparent; border-radius: 16px 16px 4px 16px; }
.bubble-meta { color: var(--ink-2); font-size: .75rem; margin-bottom: .15rem; }
.bubble-file { display: inline-flex; align-items: center; gap: .25rem; margin: .4rem .75rem 0 0; font-size: .875rem; }

/* empty states and install prompt */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--ink-2); }
.empty-state > .bi { display: block; font-size: 2.5rem; color: var(--ink-3); margin-bottom: .5rem; }
.empty-state h1, .empty-state h2 { color: var(--ink-1); }
.install-card { display: flex; align-items: center; gap: .8rem; background: var(--surface); border: 1px solid var(--outline);
  border-radius: 16px; padding: .75rem .9rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.install-card[hidden] { display: none; }
.install-card img { border-radius: 10px; flex: none; }
.install-text { flex: 1; min-width: 0; font-size: .8125rem; color: var(--ink-2); }
.install-text strong { display: block; color: var(--ink-1); font-size: .9375rem; }

/* touch-friendly controls */
.owner-ui .form-control:not(textarea):not([type="file"]), .owner-ui .form-select { min-height: 46px; }
.owner-ui .btn:not(.btn-sm):not(.btn-close) { min-height: 44px; }

/* sign-in */
.auth-wrap { max-width: 420px; margin: 0 auto; min-height: calc(100svh - 2rem); display: flex; flex-direction: column;
  justify-content: center; padding: 1.5rem 0; }
.auth-card { background: var(--surface); border: 1px solid var(--outline); border-radius: 20px; padding: 1.75rem 1.5rem;
  box-shadow: var(--shadow); }
.auth-brand { text-align: center; margin-bottom: 1.25rem; }
.auth-brand img { border-radius: 16px; margin-bottom: .75rem; }
.auth-brand h1 { font-size: 1.375rem; font-weight: 700; margin: 0; }
.auth-brand p { color: var(--ink-2); font-size: .9rem; margin: .25rem 0 0; }
.auth-foot { text-align: center; color: var(--ink-2); font-size: .8125rem; margin: 1rem 0 .25rem; }

@media print { .app-bar, .tab-bar, .install-card { display: none !important; } .owner-main { padding: 0; } }

/* Unit standing traffic light (management units list). Text keeps the ink
   colour; the dot carries the state, and the label says it in words. */
.standing { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; font-weight: 600;
  font-size: .8125rem; padding: .2rem .6rem .2rem .45rem; border-radius: 999px; }
.standing-dot { width: .75rem; height: .75rem; border-radius: 50%; flex: none; }
.standing-ok { background: #e3f4e8; color: #17663a; }
.standing-ok .standing-dot { background: #1f9d55; }
.standing-pending { background: #fdf3d6; color: #7a5600; }
.standing-pending .standing-dot { background: #e0a100; }
.standing-late { background: #fce4e2; color: #a3221a; }
.standing-late .standing-dot { background: #d93025; }
[data-bs-theme="dark"] .standing-ok { background: #12301e; color: #7fd9a1; }
[data-bs-theme="dark"] .standing-pending { background: #3a2e0a; color: #f2cc5c; }
[data-bs-theme="dark"] .standing-late { background: #3d1614; color: #ff9b92; }
.standing-legend .standing { white-space: normal; font-weight: 500; }
tr.row-link { cursor: pointer; }

/* Forms split into titled groups (person, identification form). */
.form-group-card { border: 1px solid var(--bs-border-color); border-radius: 12px; padding: .9rem 1rem 1rem; margin-bottom: 1rem; }
.form-group-card > legend { float: none; width: auto; font-size: .95rem; font-weight: 600; padding: 0 .35rem; margin: 0 0 .25rem -.35rem; }

/* Same look for every data table: row highlight on hover (like .table-hover). */
.table > tbody > tr:hover > * { --bs-table-bg-state: var(--bs-table-hover-bg); color: var(--bs-table-hover-color); }
.table > tbody > tr.table-danger:hover > *, .table > tbody > tr.table-warning:hover > * { --bs-table-bg-state: initial; }

/* Unit statement (extrato): status colours always come with an icon and a label. */
.stmt-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .75rem; margin: .75rem 0 1rem; }
.stmt-kpi { border: 1px solid var(--bs-border-color); border-radius: 12px; padding: .65rem .85rem; }
.stmt-kpi-label { font-size: .8rem; color: var(--bs-secondary-color); }
.stmt-kpi-value { font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; }
.stmt-kpi.is-debt { background: #fce4e2; border-color: #f4b8b2; }
.stmt-kpi.is-debt .stmt-kpi-label { color: #a3221a; }
.stmt-kpi.is-ok { background: #e3f4e8; border-color: #b4dfc2; }
.stmt-kpi.is-ok .stmt-kpi-label { color: #17663a; }
.stmt-reasons { border-radius: 12px; background: var(--bs-tertiary-bg); padding: .85rem 1rem; }
.reason { display: flex; gap: .55rem; align-items: flex-start; padding: .2rem 0; }
.reason .bi { flex: none; margin-top: .15rem; }
.reason-ok .bi { color: #1f9d55; } .reason-unpaid .bi { color: #d93025; } .reason-partial .bi { color: #c78f00; }
.reason-change .bi { color: #0b6bcb; } .reason-info .bi { color: var(--bs-secondary-color); }
.stmt-legend { display: flex; flex-wrap: wrap; gap: .9rem; margin-bottom: .5rem; }
.stmt-legend > span { display: inline-flex; align-items: center; gap: .35rem; }
.cell-dot { width: .8rem; height: .8rem; border-radius: 3px; display: inline-block; }
.stmt-year { display: flex; gap: .6rem; align-items: stretch; margin-bottom: .4rem; }
.stmt-year-label { width: 2.6rem; flex: none; font-weight: 600; font-size: .85rem; padding-top: .55rem; }
.stmt-months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; flex: 1; }
@media (max-width: 575.98px) { .stmt-months { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.stmt-cell { border-radius: 8px; min-height: 3.4rem; padding: .25rem .2rem; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: .72rem; line-height: 1.15; text-align: center; border: 1px solid transparent; }
.stmt-cell-m { font-weight: 600; text-transform: capitalize; }
.stmt-cell-v { font-size: .68rem; font-weight: 600; }
.st-paid { background: #e3f4e8; color: #17663a; } .cell-dot.st-paid { background: #1f9d55; }
.st-partial { background: #fdf3d6; color: #7a5600; } .cell-dot.st-partial { background: #e0a100; }
.st-unpaid { background: #fce4e2; color: #a3221a; } .cell-dot.st-unpaid { background: #d93025; }
.st-future { background: transparent; color: var(--bs-secondary-color); border: 1px dashed var(--bs-border-color); }
.cell-dot.st-future { background: transparent; border: 1px dashed var(--bs-secondary-color); }
.st-none { background: transparent; color: var(--bs-secondary-color); opacity: .6; }
.st-badge { display: inline-flex; gap: .3rem; align-items: center; padding: .1rem .5rem; border-radius: 999px; font-weight: 600; white-space: nowrap; font-size: .78rem; }
[data-bs-theme="dark"] .stmt-kpi.is-debt { background: #3d1614; border-color: #6b2622; }
[data-bs-theme="dark"] .stmt-kpi.is-debt .stmt-kpi-label { color: #ff9b92; }
[data-bs-theme="dark"] .stmt-kpi.is-ok { background: #12301e; border-color: #1f5133; }
[data-bs-theme="dark"] .stmt-kpi.is-ok .stmt-kpi-label { color: #7fd9a1; }
[data-bs-theme="dark"] .st-paid { background: #12301e; color: #7fd9a1; }
[data-bs-theme="dark"] .st-partial { background: #3a2e0a; color: #f2cc5c; }
[data-bs-theme="dark"] .st-unpaid { background: #3d1614; color: #ff9b92; }
@media print { .stmt-cell, .st-badge, .stmt-kpi { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* Management menu icons: top level always labelled; in submenus only the main action has an icon,
   the others keep the same indent so the text stays aligned. */
.nav-ico { margin-right: .35rem; }
@media (min-width: 992px) and (max-width: 1299.98px) { .nav-ico { display: none; } }
.menu-ico { display: inline-block; width: 1.1rem; margin-right: .5rem; text-align: center; color: var(--bs-secondary-color); }
.dropdown-item:hover .menu-ico, .dropdown-item:focus .menu-ico { color: inherit; }

/* Dashboard: balance of each account */
.account-list > li + li { border-top: 1px solid var(--bs-border-color); }
.account-row { display: flex; align-items: center; gap: .65rem; padding: .55rem .25rem; color: inherit; text-decoration: none; border-radius: 8px; }
.account-row:hover { background: var(--bs-tertiary-bg); color: inherit; }
.account-icon { width: 2rem; height: 2rem; flex: none; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); }
.account-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.account-name { font-weight: 600; font-size: .9rem; }
.account-sub { font-size: .75rem; color: var(--bs-secondary-color); }
.account-balance { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.account-fund { font-size: .75rem; margin: 0 0 .5rem 2.9rem; }
.account-fund.is-ok { color: #17663a; } .account-fund.is-short { color: #a3221a; }
[data-bs-theme="dark"] .account-fund.is-ok { color: #7fd9a1; } [data-bs-theme="dark"] .account-fund.is-short { color: #ff9b92; }

/* Report: income and expenses per class and month */
.catmonth { white-space: nowrap; }
.catmonth th, .catmonth td { padding: .3rem .5rem; }
.catmonth-first { position: sticky; left: 0; z-index: 1; background: var(--bs-body-bg); min-width: 13rem; max-width: 19rem;
  overflow: hidden; text-overflow: ellipsis; box-shadow: 1px 0 0 var(--bs-border-color); }
.catmonth thead th { position: sticky; top: 0; background: var(--bs-body-bg); z-index: 2; }
.catmonth thead th.catmonth-first { z-index: 3; }
.catmonth-code { font-weight: 600; font-variant-numeric: tabular-nums; }
.catmonth-desc { color: var(--bs-secondary-color); }
.catmonth-head th { background: var(--bs-tertiary-bg) !important; font-weight: 700; padding-top: .55rem; }
.catmonth-sub th, .catmonth-sub td { font-weight: 700; border-top: 1px solid var(--bs-border-color); }
.catmonth-result th, .catmonth-result td { font-weight: 700; border-top: 2px solid var(--bs-emphasis-color); }
.catmonth td.cm-zero { color: var(--bs-tertiary-color); }
/* one hue per group, light → strong (text stays in ink) */
.cm-income .cm-l1 { background: #e8f5ec; } .cm-income .cm-l2 { background: #d0ecd9; }
.cm-income .cm-l3 { background: #b4dfc2; } .cm-income .cm-l4 { background: #94d0a8; }
.cm-expense .cm-l1 { background: #e9f0fb; } .cm-expense .cm-l2 { background: #d2e1f7; }
.cm-expense .cm-l3 { background: #b6cff2; } .cm-expense .cm-l4 { background: #97baea; }
[data-bs-theme="dark"] .cm-income .cm-l1 { background: #14291b; } [data-bs-theme="dark"] .cm-income .cm-l2 { background: #1a3824; }
[data-bs-theme="dark"] .cm-income .cm-l3 { background: #21482e; } [data-bs-theme="dark"] .cm-income .cm-l4 { background: #295a39; }
[data-bs-theme="dark"] .cm-expense .cm-l1 { background: #152338; } [data-bs-theme="dark"] .cm-expense .cm-l2 { background: #1b2e4a; }
[data-bs-theme="dark"] .cm-expense .cm-l3 { background: #223a5e; } [data-bs-theme="dark"] .cm-expense .cm-l4 { background: #2a4774; }
.catmonth tbody tr:hover > * { --bs-table-bg-state: transparent; }
.catmonth tbody tr:hover > th, .catmonth tbody tr:hover > td.cm-l0 { background-image: linear-gradient(var(--bs-table-hover-bg), var(--bs-table-hover-bg)); }

/* Budget execution: % bar with the elapsed share of the fiscal year as a tick */
.exec-col { min-width: 9.5rem; }
.exec-bar-wrap { display: flex; align-items: center; gap: .4rem; }
.exec-bar { position: relative; flex: 1 1 auto; height: .55rem; min-width: 4.5rem; border-radius: .3rem;
  background: var(--bs-secondary-bg); overflow: visible; }
.exec-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: .3rem; background: #3b78d8; }
.cm-income .exec-fill { background: #1f9d55; }
.exec-over .exec-fill { background: #d93025; }
.exec-mark { position: absolute; top: -.2rem; bottom: -.2rem; width: 2px; margin-left: -1px;
  background: var(--bs-emphasis-color); opacity: .55; }
.exec-pct { min-width: 3.2rem; text-align: right; font-variant-numeric: tabular-nums; }
.exec-over + .exec-pct { color: #d93025; font-weight: 600; }
.exec-card .exec-bar { height: .7rem; }
.catmonth th.cm-future, .catmonth td.cm-future { color: var(--bs-tertiary-color); background: repeating-linear-gradient(135deg, transparent 0 6px, var(--bs-tertiary-bg) 6px 8px); }

/* Balances report */
.balances td.cm-zero { color: var(--bs-tertiary-color); }
.balances-holders { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.standing-filter { text-decoration: none; border: 2px solid transparent; }
a.standing-filter:hover { filter: brightness(.96); }
a.standing-filter.active { border-color: currentColor; }
.standing-count { font-variant-numeric: tabular-nums; opacity: .8; }

/* Bank reconciliation */
.recon-tabs { display: flex; flex-wrap: wrap; gap: .5rem; }
.recon-tab { display: flex; align-items: center; gap: .6rem; padding: .45rem .7rem; border: 1px solid var(--bs-border-color);
  border-radius: 10px; color: inherit; text-decoration: none; min-width: 12rem; background: var(--bs-body-bg); }
.recon-tab:hover { background: var(--bs-tertiary-bg); color: inherit; }
.recon-tab.active { border-color: var(--bs-primary); box-shadow: 0 0 0 1px var(--bs-primary); }
.recon-tab-main { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.2; }
.recon-tab-name { font-weight: 600; font-size: .85rem; }
.recon-tab-balance { font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--bs-secondary-color); }
.recon-flag { font-size: 1.05rem; }
.recon-flag-ok { color: #1f9d55; } .recon-flag-bad { color: #d93025; } .recon-flag-na { color: var(--bs-tertiary-color); }
.recon-status-ok { background: #e3f4e8; color: #17663a; border-color: #b9e2c6; }
.recon-status-bad { background: #fce4e2; color: #a3221a; border-color: #f3bdb8; }
.recon-status-na { background: var(--bs-tertiary-bg); }
[data-bs-theme="dark"] .recon-status-ok { background: #12301e; color: #7fd9a1; border-color: #1f4d31; }
[data-bs-theme="dark"] .recon-status-bad { background: #3d1614; color: #ff9b92; border-color: #6a2622; }
.recon-status a { color: inherit; font-weight: 600; }
.recon-month th { background: var(--bs-tertiary-bg) !important; font-weight: 700; text-transform: capitalize; }
.recon-month th.num { font-weight: 600; color: var(--bs-secondary-color); }
.recon-in { color: #17663a; }
[data-bs-theme="dark"] .recon-in { color: #7fd9a1; }
.recon-table tr.recon-new > td:first-child { box-shadow: inset 3px 0 0 #d93025; }
.recon-table tr.recon-carried > td:first-child { box-shadow: inset 3px 0 0 #f3bdb8; }

/* Unit identification card (pages about one unit) */
.unit-card { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; margin: .75rem 0 .5rem;
  padding: .6rem .8rem; border: 1px solid var(--bs-border-color); border-radius: 10px; background: var(--bs-tertiary-bg); }
.unit-card-code { flex: none; min-width: 3.2rem; height: 3.2rem; padding: 0 .5rem; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; font-size: 1.35rem; font-weight: 700; text-decoration: none;
  background: var(--bs-primary); color: #fff; }
.unit-card-code:hover { color: #fff; filter: brightness(1.1); }
.unit-card-main { flex: 1 1 18rem; min-width: 0; display: flex; flex-direction: column; gap: .3rem; }
.unit-card-line { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1rem; font-size: .875rem; }
.unit-card-people a { font-weight: 600; }
.unit-card-links { display: flex; gap: .4rem; flex-wrap: wrap; }

/* Collapsible periods inside tables */
.period-table tbody.period-head th { background: var(--bs-tertiary-bg); padding: 0; }
.period-btn { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: .4rem; width: 100%;
  padding: .4rem .5rem; cursor: pointer; font-weight: 600; }
.period-btn:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: -2px; }
.period-btn .bi { transition: transform .15s; }
.period-btn[aria-expanded="true"] .bi { transform: rotate(90deg); }
.period-meta { font-weight: 400; color: var(--bs-secondary-color); font-size: .85em; }

/* Bank entries list */
.entries-in { color: #17663a; }
[data-bs-theme="dark"] .entries-in { color: #7fd9a1; }
.entries-tag { display: inline-flex; align-items: center; gap: .2rem; margin-left: .35rem; padding: 0 .35rem;
  border-radius: 6px; font-size: .75rem; background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); white-space: nowrap; }
.entries-cat { display: inline-block; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* Allocations overview */
.unit-chip { flex: none; min-width: 2.6rem; height: 2.6rem; padding: 0 .4rem; border-radius: 9px; display: flex; align-items: center;
  justify-content: center; font-weight: 700; text-decoration: none; background: var(--bs-primary); color: #fff; }
.unit-chip:hover { color: #fff; filter: brightness(1.1); }
.alloc-table td { border-bottom-color: var(--bs-border-color-translucent); }
.alloc-payer { max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alloc-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .5rem; }
.alloc-tile { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border: 1px solid var(--bs-border-color);
  border-radius: 10px; color: inherit; text-decoration: none; background: var(--bs-body-bg); }
.alloc-tile:hover { background: var(--bs-tertiary-bg); color: inherit; }
.alloc-tile-code { flex: none; width: 2.4rem; height: 2.4rem; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; background: var(--bs-tertiary-bg); }
.alloc-tile-main { display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; min-width: 0; }
.alloc-tile-name { font-weight: 600; font-size: .85rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alloc-tile .standing { font-size: .75rem; padding: .05rem .45rem; }

/* Visibility picker */
.vis-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .5rem; margin: 0; }
.vis-choice { display: flex; align-items: flex-start; gap: .55rem; padding: .55rem .7rem; border: 1px solid var(--bs-border-color);
  border-radius: 10px; cursor: pointer; background: var(--bs-body-bg); }
.vis-choice:hover { background: var(--bs-tertiary-bg); }
.vis-choice.active { border-color: var(--bs-primary); box-shadow: 0 0 0 1px var(--bs-primary); }
.vis-choice .form-check-input { margin-top: .2rem; flex: none; }
.vis-choice > .bi { font-size: 1.1rem; color: var(--bs-secondary-color); margin-top: .05rem; }
.vis-choice.active > .bi { color: var(--bs-primary); }
.vis-choice-label { display: block; font-weight: 600; font-size: .875rem; line-height: 1.25; }
.vis-choice-help { display: block; font-size: .78rem; color: var(--bs-secondary-color); }
.vis-panel { padding: .7rem; border-radius: 10px; background: var(--bs-tertiary-bg); }
.vis-search { width: 14rem; max-width: 100%; }
.vis-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .4rem; max-height: 22rem; overflow: auto; }
.vis-item { display: flex; align-items: center; gap: .5rem; padding: .35rem .5rem; border-radius: 8px; background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color); cursor: pointer; }
.vis-item:has(input:checked) { border-color: var(--bs-primary); background: var(--bs-primary-bg-subtle); }
.vis-item[hidden] { display: none; }
.vis-item .form-check-input { margin: 0; flex: none; }
.vis-item-code { font-weight: 700; min-width: 1.8rem; }
.vis-item-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.vis-item-name { font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vis-item-sub { font-size: .75rem; color: var(--bs-secondary-color); }

/* Email log */
.mail-status { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-weight: 600; font-size: .78rem; white-space: nowrap; }
.mail-sent { background: #e3f4e8; color: #17663a; }
.mail-saved { background: #fdf3d6; color: #7a5600; }
.mail-failed { background: #fce4e2; color: #a3221a; }
.mail-prepared { background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); }
[data-bs-theme="dark"] .mail-sent { background: #12301e; color: #7fd9a1; }
[data-bs-theme="dark"] .mail-saved { background: #3a2e0a; color: #f2cc5c; }
[data-bs-theme="dark"] .mail-failed { background: #3d1614; color: #ff9b92; }
a.mail-filter { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .65rem; border-radius: 999px; font-size: .85rem;
  font-weight: 600; text-decoration: none; border: 2px solid transparent; }
a.mail-filter.active { border-color: currentColor; }
.mail-count { opacity: .8; font-variant-numeric: tabular-nums; }
.mail-body { white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: .9rem; background: var(--bs-tertiary-bg);
  padding: .75rem; border-radius: 8px; margin-bottom: .5rem; }

/* Portal receipts: open + explicit download */
.receipt-row { gap: .5rem; }
.receipt-open { display: flex; align-items: center; gap: .75rem; flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.receipt-download { flex: none; }
.unit-place { font-size: .78rem; font-weight: 600; color: var(--bs-secondary-color); text-transform: uppercase; letter-spacing: .02em; }
.page-jump { width: 4.2rem; text-align: center; }

/* Unread counter (portal notices) */
.count-badge { display: inline-flex; align-items: center; justify-content: center; flex: none; min-width: 1.1rem; height: 1.1rem;
  padding: 0 .3rem; border-radius: 999px; background: #d93025; color: #fff; font-size: .68rem; font-weight: 700; line-height: 1;
  vertical-align: middle; }
.tab-with-badge { position: relative; }
.tab-badge { position: absolute; top: .2rem; left: calc(50% + .35rem); }
.notice-new { border-left: 4px solid #d93025; }
.app-manage { white-space: nowrap; flex: none; }

/* Configuration page */
.config-tabs .nav-link { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.config-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
.config-form { max-width: 980px; }
.config-checks .mb-3 { margin-bottom: .6rem !important; }
.config-checks .form-text { margin-top: 0; margin-left: 1.6rem; }

/* Payments list */
.unit-chip-sm { display: inline-flex; min-width: 2rem; height: 1.6rem; font-size: .78rem; border-radius: 6px; padding: 0 .3rem; vertical-align: middle; }
.payments-holder { display: inline-block; max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.payments-ref { max-width: 18rem; overflow-wrap: anywhere; }
.pay-state { display: inline-block; padding: .05rem .45rem; border-radius: 999px; font-weight: 600; font-size: .75rem; }
.pay-ok { background: #e3f4e8; color: #17663a; }
.pay-todo { background: #fdf3d6; color: #7a5600; }
[data-bs-theme="dark"] .pay-ok { background: #12301e; color: #7fd9a1; }
[data-bs-theme="dark"] .pay-todo { background: #3a2e0a; color: #f2cc5c; }
.pay-adv { background: #e2ecfb; color: #1f4f9a; }
[data-bs-theme="dark"] .pay-adv { background: #16263f; color: #9cc0f5; }
.monthly-day input { width: 5rem; }
