/* =============================================================================
   Moje Obligacje - client portal stylesheet (Phase 3A)

   Sections:
     1. Design tokens
     2. Reset / base
     3. Utilities (sr-only, skip-link, muted, focus)
     4. Public pages (base.html.twig): topbar, wrap, auth card, forms
     5. Flash messages (shared)
     6. App shell: sidebar, topbar, drawer  (app.html.twig)
     7. Page primitives: page-header, panel, data-list
     8. Components: kpi, position-card, badge, empty-state,
        upcoming list, coupon timeline, schedule list, account list
     9. Responsive breakpoints
   ========================================================================== */

/* --- 1. Design tokens ----------------------------------------------------- */
:root {
    --navy-900: #0f1b2d;   /* sidebar background */
    --navy-800: #17263c;   /* sidebar hover */
    --navy-700: #1c3350;   /* sidebar active */

    --ink:        #1a2230;  /* primary text */
    --ink-soft:   #5b6472;  /* secondary text */
    --ink-faint:  #8a929e;  /* tertiary text */

    --page-bg:        #f4f5f7;
    --surface:        #ffffff;
    --surface-sunken: #f5f7fa;   /* subtle inset row/panel, not a nested card */
    --border:         #e4e7ec;
    --border-soft:    #eef0f3;

    --accent:      #1f5fbf;
    --accent-dark: #1d3a6b;

    --tone-positive-bg:   #e7f4ec;
    --tone-positive-ink:  #1c6b3a;
    --tone-positive-line: #b6e0c4;

    --tone-attention-bg:  #fdf2e2;
    --tone-attention-ink: #8a5a12;
    --tone-attention-line:#f0d9ac;

    --tone-neutral-bg:    #e8eef7;
    --tone-neutral-ink:   #1d3a6b;
    --tone-neutral-line:  #c3d4ea;

    --tone-muted-bg:      #eef0f3;
    --tone-muted-ink:     #59606b;
    --tone-muted-line:    #d9dde3;

    --tone-teal-bg:       #e2f2ef;
    --tone-teal-ink:      #0f6b60;
    --tone-teal-line:     #a9dcd5;

    --tone-danger-bg:     #fbe9e7;
    --tone-danger-ink:    #a1261f;
    --tone-danger-line:   #f0c4bf;

    /* Chart tones (Statystyki bar chart + donut - both charts share these
       exact two values, nothing else). Defined once, centrally, as plain
       colors - every chart element consumes them only via var(--chart-paid)
       / var(--chart-forecast), never repeats the hex itself. */
    --chart-paid:     #63C695; /* fresh light green - already-due / paid */
    --chart-forecast: #9BC8F5; /* clean light blue - future / forecast */

    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow:    0 1px 3px rgba(16, 24, 40, .10), 0 1px 2px rgba(16, 24, 40, .06);

    --sidebar-w: 264px;

    /* Decorative login background (layout/auth.html.twig only) - CSS-only,
       no images. Consumed solely by .auth-body / .auth-main pseudo-elements. */
    --auth-bg-base:   #f8fbff;
    --auth-bg-blue-a: rgba(181, 215, 244, .42);
    --auth-bg-blue-b: rgba(201, 226, 247, .32);
    --auth-bg-blue-c: rgba(221, 237, 250, .42);
    --auth-bg-cream:  rgba(244, 231, 200, .34);
    --auth-bg-gold:   rgba(184, 145, 67, .62);
}

/* --- 2. Reset / base ---------------------------------------------------- */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    margin: 0;
    color: var(--ink);
    background: #fafafa;
}

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }

a { color: var(--accent); }

img { max-width: 100%; height: auto; }

.icon { width: 20px; height: 20px; flex: 0 0 auto; }
.icon--sm { width: 16px; height: 16px; }

/* --- 3. Utilities ----------------------------------------------------- */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: 8px; top: -60px;
    z-index: 100;
    padding: .5rem .9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: top .15s ease;
}
.skip-link:focus { top: 8px; }

.muted { color: var(--ink-soft); }
.muted-inline { color: var(--ink-faint); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
}

/* --- 4. Public pages (base.html.twig) ------------------------------------ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 46rem;
    margin: 0 auto;
    padding: .9rem 1.25rem;
    border-bottom: 1px solid #e3e3e3;
}
.brand { font-weight: 600; text-decoration: none; color: var(--ink); }
.topnav { display: flex; align-items: center; gap: 1rem; font-size: .95rem; }
.topnav a { color: var(--accent); text-decoration: none; }
.inline-form { display: inline; margin: 0; }
.linklike {
    background: none; border: 0; padding: 0; margin: 0;
    color: #a33; cursor: pointer; font: inherit; text-decoration: underline;
}

.wrap { max-width: 46rem; margin: 2rem auto; padding: 0 1.25rem; }
.wrap h1 { font-size: 1.6rem; margin-bottom: .5rem; }

.foot {
    max-width: 46rem;
    margin: 2rem auto;
    padding: 1rem 1.25rem 0;
    border-top: 1px solid #e3e3e3;
    color: #666;
}

.lead { font-size: 1.1rem; color: #444; }
.hint { margin-top: 1.5rem; }
.facts li { padding: .25rem 0; border-bottom: 1px solid #ececec; }

.card {
    max-width: 24rem;
    margin: 1rem auto;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid #e3e3e3;
    border-radius: var(--radius-sm);
}
.card h1 { font-size: 1.4rem; margin-bottom: .75rem; }

form.stack { display: flex; flex-direction: column; gap: .35rem; }
form.stack label { margin-top: .6rem; font-weight: 600; font-size: .9rem; }
form.stack input {
    padding: .55rem .6rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font: inherit;
}
form.stack button {
    margin-top: 1rem;
    padding: .6rem;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 6px;
    font: inherit;
    cursor: pointer;
}
form.stack button:hover { background: var(--accent-dark); }

/* --- 4b. Login page (layout/auth.html.twig) -------------------------------
   Layered full-screen auth background inspired by the approved wide mockup.
   CSS-only, no images / SVG / JS. */
.auth-body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    background:
        radial-gradient(
            ellipse 54% 58% at 90% 8%,
            rgba(248, 232, 200, .34) 0%,
            rgba(251, 241, 221, .17) 42%,
            rgba(255, 255, 255, 0) 74%
        ),
        linear-gradient(
            140deg,
            #eef7ff 0%,
            #f8fbff 28%,
            #ffffff 52%,
            #fffdf8 100%
        );
}

/* Broad upper-left ribbon */
.auth-body::before {
    content: "";
    position: fixed;
    z-index: 0;
    pointer-events: none;

    width: 150vw;
    height: 56vh;
    left: -48vw;
    top: -28vh;

    border-radius: 50%;

    background:
        linear-gradient(
            13deg,
            rgba(119, 187, 239, .42) 0%,
            rgba(157, 207, 244, .37) 24%,
            rgba(190, 222, 248, .31) 48%,
            rgba(215, 236, 251, .21) 70%,
            rgba(246, 251, 255, 0) 100%
        );

    transform: rotate(10deg);
}

/* Main deep lower wave */
.auth-body::after {
    content: "";
    position: fixed;
    z-index: 0;
    pointer-events: none;

    width: 190vw;
    height: 62vh;
    left: -45vw;
    bottom: -37vh;

    border-radius: 50%;

    background:
        linear-gradient(
            9deg,
            rgba(62, 145, 220, .72) 0%,
            rgba(92, 168, 229, .64) 20%,
            rgba(132, 193, 238, .54) 42%,
            rgba(174, 215, 246, .42) 64%,
            rgba(212, 235, 251, .26) 82%,
            rgba(248, 252, 255, 0) 100%
        );

    transform: rotate(-6deg);
}

.auth-main {
    position: relative;
    z-index: 1;
    isolation: isolate;
    min-height: 100vh;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
}

/* Brand block (MO monogram + name) - rendered at the top INSIDE .auth-card. */
.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .25rem;
    margin: 0 0 1.75rem;
}

.auth-brand__mark {
    width: 92px;
    height: auto;
}

.auth-brand__name {
    font-size: 1.45rem;
    line-height: 1.15;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -.02em;
}

/* Per-screen heading under the brand (forgot / reset). Login has none. */
.auth-card__heading {
    margin: -.35rem 0 1.1rem;
    font-size: 1.15rem;
    line-height: 1.25;
    font-weight: 600;
    text-align: center;
    color: var(--ink);
}

/* Short explanatory line above a form (forgot-password). */
.auth-card__intro {
    margin: 0 0 1.25rem;
    font-size: .9rem;
    line-height: 1.45;
    color: var(--ink-soft);
}

/* Secondary wave crossing middle/lower part */
.auth-main::before {
    content: "";
    position: fixed;
    z-index: -2;
    pointer-events: none;

    width: 180vw;
    height: 42vh;
    left: -38vw;
    bottom: -3vh;

    border-radius: 50%;

    background:
        linear-gradient(
            8deg,
            rgba(139, 195, 239, .18) 0%,
            rgba(111, 181, 235, .34) 20%,
            rgba(151, 205, 243, .42) 40%,
            rgba(190, 223, 248, .38) 61%,
            rgba(220, 239, 252, .25) 79%,
            rgba(255, 255, 255, 0) 100%
        );

    transform: rotate(5deg);
}

/* Gold arcs + additional translucent wave layers */
.auth-main::after {
    content: "";
    position: fixed;
    z-index: -1;
    pointer-events: none;
    inset: 0;

    background:
        radial-gradient(
            ellipse 86vw 50vh at 101% 30%,
            transparent 99.15%,
            rgba(199, 156, 65, .64) 99.33%,
            rgba(199, 156, 65, .64) 99.48%,
            transparent 99.68%
        ),
        radial-gradient(
            ellipse 82vw 44vh at 97% 80%,
            transparent 99.15%,
            rgba(199, 156, 65, .50) 99.33%,
            rgba(199, 156, 65, .50) 99.48%,
            transparent 99.68%
        ),
        radial-gradient(
            ellipse 110vw 34vh at 29% 85%,
            rgba(107, 177, 232, .18) 0%,
            rgba(147, 201, 241, .20) 35%,
            rgba(198, 228, 249, .12) 65%,
            rgba(255, 255, 255, 0) 100%
        ),
        radial-gradient(
            ellipse 96vw 28vh at 75% 73%,
            rgba(121, 187, 236, .17) 0%,
            rgba(177, 216, 246, .16) 45%,
            rgba(255, 255, 255, 0) 100%
        );
}

/* Login card */
.auth-card {
    position: relative;
    z-index: 5;
    width: 100%;
    max-width: 33rem;
    padding: 2.25rem 2.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-card__notices {
    margin-bottom: 1.25rem;
}

.auth-card__notices .flash:last-child {
    margin-bottom: 0;
}

.auth-notice {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    font-size: .9rem;
}

.auth-notice .icon {
    flex: 0 0 auto;
    margin-top: .05rem;
}

.auth-notice span {
    min-width: 0;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.auth-field > label {
    font-weight: 600;
    font-size: .9rem;
    color: var(--ink);
}

.auth-field__error {
    color: var(--tone-danger-ink);
    font-size: .85rem;
}

.auth-input {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: 0 .8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.auth-input:focus-within {
    border-color: var(--accent);
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.auth-input .icon {
    color: var(--ink-faint);
}

.auth-input input {
    flex: 1 1 auto;
    min-width: 0;
    padding: .7rem 0;
    border: 0;
    background: none;
    font: inherit;
    color: var(--ink);
}

.auth-input input:focus,
.auth-input input:focus-visible {
    outline: none;
}

.auth-card__submit {
    width: 100%;
    margin-top: .35rem;
    padding-block: .7rem;
}

.auth-card__reset {
    margin: 1.25rem 0 0;
    text-align: center;
    font-size: .9rem;
}

/* Wide desktop */
@media (min-width: 1400px) {
    .auth-body::before {
        width: 142vw;
        height: 54vh;
        left: -43vw;
        top: -25vh;
    }

    .auth-body::after {
        width: 182vw;
        height: 60vh;
        left: -41vw;
        bottom: -35vh;
    }

    .auth-main::before {
        width: 172vw;
        height: 40vh;
        left: -34vw;
        bottom: -1vh;
    }
}

/* Very wide desktop */
@media (min-width: 1800px) {
    .auth-body::before {
        top: -23vh;
        height: 52vh;
    }

    .auth-body::after {
        bottom: -33vh;
        height: 58vh;
    }

    .auth-main::before {
        bottom: 1vh;
        height: 38vh;
    }
}

/* Mobile */
@media (max-width: 560px) {
    .auth-main {
        padding: 1.5rem 1rem;
        align-items: flex-start;
    }

    .auth-card {
        padding: 1.75rem 1.25rem;
    }

    .auth-brand {
        margin-bottom: 1.4rem;
    }

    .auth-brand__mark {
        width: 76px;
    }

    .auth-brand__name {
        font-size: 1.3rem;
    }

    .auth-body::before {
        width: 230vw;
        height: 48vh;
        left: -95vw;
        top: -18vh;
        opacity: .65;
    }

    .auth-body::after {
        width: 255vw;
        height: 50vh;
        left: -105vw;
        bottom: -27vh;
        opacity: .72;
    }

    .auth-main::before {
        width: 235vw;
        height: 36vh;
        left: -90vw;
        bottom: 3vh;
        opacity: .60;
    }

    .auth-main::after {
        opacity: .48;
    }
}

/* --- 5. Flash messages ------------------------------------------------- */
.flashes { margin: 0 0 1rem; }
.flash {
    padding: .6rem .85rem;
    border-radius: var(--radius-sm);
    margin-bottom: .5rem;
    border: 1px solid transparent;
}
.flash-success { background: var(--tone-positive-bg);  border-color: var(--tone-positive-line);  color: var(--tone-positive-ink); }
.flash-info    { background: var(--tone-neutral-bg);   border-color: var(--tone-neutral-line);   color: var(--tone-neutral-ink); }
.flash-warning { background: var(--tone-attention-bg); border-color: var(--tone-attention-line); color: var(--tone-attention-ink); }
.flash-error   { background: #fdecec; border-color: #f5b5b5; color: #a22; }

/* --- 6. App shell --------------------------------------------------------- */
.app-body { background: var(--page-bg); }

.app { position: relative; min-height: 100vh; }

/* Mobile topbar (hidden on desktop) */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1rem;
    background: var(--navy-900);
    color: #fff;
}
.app-topbar__brand {
    color: #fff;
    font-weight: 600;
    text-decoration: none;
}

.nav-burger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    padding: 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: var(--radius-sm);
    color: #fff;
    cursor: pointer;
}
.nav-burger__box {
    position: relative;
    width: 18px; height: 2px;
    background: currentColor;
    display: block;
}
.nav-burger__box::before,
.nav-burger__box::after {
    content: "";
    position: absolute;
    left: 0;
    width: 18px; height: 2px;
    background: currentColor;
}
.nav-burger__box::before { top: -6px; }
.nav-burger__box::after  { top: 6px; }

.nav-scrim {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 39;
    border: 0;
    padding: 0;
    background: rgba(15, 27, 45, .45);
    cursor: pointer;
}
.app.nav-open .nav-scrim { display: block; }

/* Sidebar */
.app-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 40;
    width: 82vw;
    max-width: 320px;
    background: var(--navy-900);
    transform: translateX(-100%);
    transition: transform .2s ease;
    overflow-y: auto;
}
.app.nav-open .app-sidebar { transform: translateX(0); }

.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: 1.1rem .85rem;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .4rem .5rem 1rem;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.05rem;
}
.sidebar__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    background: var(--navy-700);
    border-radius: var(--radius-sm);
    font-size: .8rem;
    letter-spacing: .04em;
}

.sidebar__nav { margin-top: .25rem; }
.sidebar__list { display: flex; flex-direction: column; gap: 2px; }

.sidebar__link {
    display: flex;
    align-items: center;
    gap: .7rem;
    width: 100%;
    padding: .62rem .6rem;
    border-radius: var(--radius-sm);
    color: #c2cbd8;
    text-decoration: none;
    font-size: .95rem;
    line-height: 1.2;
}
.sidebar__link:hover { background: var(--navy-800); color: #fff; }
.sidebar__link.is-active {
    background: var(--navy-700);
    color: #fff;
    font-weight: 600;
}
/* Unresolved-count pill on a nav item (admin "Zdarzenia systemowe"). */
.sidebar__badge {
    margin-left: auto;
    min-width: 1.3rem;
    padding: 0 .35rem;
    border-radius: 999px;
    background: var(--tone-danger-ink);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    line-height: 1.3rem;
    text-align: center;
}
.sidebar__link--button {
    background: transparent;
    border: 0;
    font: inherit;
    cursor: pointer;
    text-align: left;
}

.sidebar__logout {
    margin-top: auto;
    padding-top: .75rem;
    border-top: 1px solid rgba(255, 255, 255, .12);
}

/* Main column - a vertical stack; the gap is the only section spacing. */
.app-main {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.15rem 1rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    font-size: .9375rem;   /* 15px body copy inside the client app */
}

/* --- 7. Page primitives ------------------------------------------------- */
.page-header { margin: 0; }
.page-header__back {
    display: inline-block;
    margin-bottom: .4rem;
    font-size: .875rem;
    text-decoration: none;
    color: var(--accent);
}
.page-header__back:hover { text-decoration: underline; }
.page-header h1 { font-size: 1.6rem; line-height: 1.2; letter-spacing: -.01em; }
.page-header__sub { margin-top: .3rem; color: var(--ink-soft); }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem 1.25rem;
}
.panel h2 { font-size: 1.2rem; }
.panel__note { margin-top: .85rem; color: var(--ink-soft); font-size: .8125rem; }

/* Section header - used inside panels and above bare sections alike */
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.section-head h2 { font-size: 1.2rem; }
.section-head__link {
    font-size: .875rem;
    text-decoration: none;
    white-space: nowrap;
}
.section-head__link:hover { text-decoration: underline; }
.section-head__total { color: var(--ink-soft); font-size: .875rem; }
.section-head__total strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.data-list > div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: .55rem 0;
    border-bottom: 1px solid var(--border-soft);
}
.data-list > div:last-child { border-bottom: 0; }
.data-list dt { color: var(--ink-soft); }
.data-list dd { margin: 0; font-weight: 600; text-align: right; }
.data-list .dd-sub {
    display: block;
    font-weight: 400;
    font-size: .8125rem;
    color: var(--ink-soft);
}

/* --- 8. Components ---------------------------------------------------- */

/* KPI cards - exactly one row of four on desktop */
.kpi-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.kpi {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: .35rem;
    min-height: 112px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--tone-neutral-line);
    border-radius: var(--radius);
    padding: .9rem 1.15rem;
}
.kpi__label { color: var(--ink-soft); font-size: .8125rem; }
.kpi__value { font-size: 1.625rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.kpi__hint {
    color: var(--ink-faint);
    font-size: .8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi--positive  { border-left-color: var(--tone-positive-ink); }
.kpi--attention { border-left-color: var(--tone-attention-ink); }
.kpi--neutral   { border-left-color: var(--accent); }
.kpi--muted     { border-left-color: var(--tone-muted-line); }

/* Stage 4 client-dashboard KPI: tinted card + soft shadow + rounded icon chip.
   Only applied when the card is given an icon (admin KPIs keep the plain style). */
.kpi--iconed {
    flex-direction: row;
    align-items: flex-start;
    justify-content: flex-start;
    gap: .85rem;
    border-left-width: 1px;
    box-shadow: var(--shadow);
}
.kpi--iconed .kpi__body { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.kpi--iconed .kpi__value { font-size: 1.75rem; letter-spacing: -.025em; }
.kpi__icon {
    flex: 0 0 auto;
    width: 2.3rem;
    height: 2.3rem;
    display: grid;
    place-items: center;
    border-radius: 10px;
}
.kpi__icon .icon { width: 18px; height: 18px; }

.kpi--blue  { background: linear-gradient(155deg, #f1f6fd, var(--surface) 62%); border-color: #d8e5f6; }
.kpi--blue  .kpi__icon { background: var(--tone-neutral-bg);  color: var(--accent); }
.kpi--green { background: linear-gradient(155deg, #eef7f1, var(--surface) 62%); border-color: #cae7d4; }
.kpi--green .kpi__icon { background: var(--tone-positive-bg); color: var(--tone-positive-ink); }
.kpi--teal  { background: linear-gradient(155deg, #ebf6f4, var(--surface) 62%); border-color: #bfe2dc; }
.kpi--teal  .kpi__icon { background: var(--tone-teal-bg);     color: var(--tone-teal-ink); }
.kpi--amber { background: linear-gradient(155deg, #fdf4e7, var(--surface) 62%); border-color: #f0dcb4; }
.kpi--amber .kpi__icon { background: var(--tone-attention-bg); color: var(--tone-attention-ink); }

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .18rem .55rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge--positive  { background: var(--tone-positive-bg);  color: var(--tone-positive-ink);  border-color: var(--tone-positive-line); }
.badge--attention { background: var(--tone-attention-bg); color: var(--tone-attention-ink); border-color: var(--tone-attention-line); }
.badge--neutral   { background: var(--tone-neutral-bg);   color: var(--tone-neutral-ink);   border-color: var(--tone-neutral-line); }
.badge--muted     { background: var(--tone-muted-bg);     color: var(--tone-muted-ink);     border-color: var(--tone-muted-line); }
.badge--danger    { background: var(--tone-danger-bg);    color: var(--tone-danger-ink);    border-color: var(--tone-danger-line); }

/* Empty state */
.empty-state {
    padding: 1.75rem 1rem;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: #fbfcfd;
}
.empty-state__message { font-weight: 600; }
.empty-state__hint { margin-top: .35rem; color: var(--ink-soft); font-size: .9rem; }

/* Dashboard: main column + fixed-width side rail */
.dashboard-grid { display: grid; gap: 1.25rem; }
.dashboard-grid__side .panel { height: 100%; }

/* Admin client detail: investments area + a proportional right rail (no fixed px).
   Sections are FLAT - each investment / account is its own card, but the list
   areas have no outer panel/border/background. */
.client-detail-grid { display: grid; gap: 1.5rem; }
.client-detail-grid__main,
.client-detail-grid__side { min-width: 0; }
.client-detail-grid__side { display: flex; flex-direction: column; gap: 1.75rem; }

/* Positions page toolbar (summary + server-side status filter) */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem 1.25rem;
    padding: .75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.toolbar__summary { display: flex; flex-wrap: wrap; gap: .35rem 1rem; font-size: .9rem; }
.toolbar__stat strong { font-size: 1rem; }
.toolbar__stat--muted { color: var(--ink-soft); }
.toolbar__filters { display: flex; flex-wrap: wrap; gap: .25rem; }
.toolbar__filter {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .7rem;
    border-radius: 999px;
    font-size: .85rem;
    text-decoration: none;
    color: var(--ink-soft);
    border: 1px solid transparent;
}
.toolbar__filter:hover { background: var(--surface-sunken); }
.toolbar__filter.is-current {
    background: var(--tone-neutral-bg);
    border-color: var(--tone-neutral-line);
    color: var(--tone-neutral-ink);
    font-weight: 600;
}
.toolbar__count { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.toolbar__filter.is-current .toolbar__count { color: inherit; }

/* Position card - compact, spacing not divider lines */
.position-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.position-card {
    display: flex;
    flex-direction: column;
    gap: .7rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem 1.1rem;
}
.position-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
}
.position-card__series { font-weight: 700; font-size: 1.0625rem; line-height: 1.2; }
.position-card__issuer { margin-top: .1rem; color: var(--ink-soft); font-size: .875rem; }
.position-card__capital { font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; }

.position-card__meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .25rem 1rem;
}
.position-card__meta > div { display: flex; flex-direction: column; }
.position-card__meta dt { color: var(--ink-soft); font-size: .8rem; }
.position-card__meta dd { margin: 0; font-weight: 600; font-size: .9rem; }

.position-card__coupon {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    padding: .5rem .7rem;
    background: var(--surface-sunken);
    border-radius: var(--radius-sm);
}
.position-card__coupon-label { color: var(--ink-soft); font-size: .775rem; }
.position-card__coupon-value { font-weight: 600; font-size: .9rem; }

.position-card__link {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    align-self: flex-start;
    margin-top: auto;
    font-weight: 600;
    font-size: .875rem;
    text-decoration: none;
}
.position-card__link:hover { text-decoration: underline; }

/* Upcoming payments list - shared by the client dashboard, the admin client
   detail rail, and (with --card) the admin dashboard rail. */
.upcoming-list { display: flex; flex-direction: column; }
/* One compact bordered card holding all rows (admin dashboard). Same
   border/radius/padding tokens as .account-card, so the two rails match. */
.upcoming-list--card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: .25rem 1rem;
}
/* narrow admin client-detail rail: keep each payout row tidy on two lines */
.client-detail-grid__side .upcoming-list--card .upcoming-item__series,
.client-detail-grid__side .upcoming-list--card .upcoming-item__issuer {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.upcoming-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: .85rem;
    min-height: 58px;
    padding: .6rem 0;
    border-bottom: 1px solid var(--border-soft);
}
.upcoming-item:last-child { border-bottom: 0; }
.upcoming-item__date { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: .875rem; }
.upcoming-item__body { display: flex; flex-direction: column; min-width: 0; }
.upcoming-item__client {
    font-weight: 600;
    text-decoration: none;
    color: inherit;
}
.upcoming-item__client:hover { text-decoration: underline; }
.upcoming-item__series { font-weight: 600; }
.upcoming-item__issuer { color: var(--ink-soft); font-size: .8125rem; }
.upcoming-item__amount { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* admin dashboard: keep each row on two tidy lines even with a long name */
.upcoming-list--card .upcoming-item__client,
.upcoming-list--card .upcoming-item__issuer {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Dashboard "Twoje inwestycje": chip filter + compact sort, then full-width rows */
.investments-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .6rem 1rem;
    margin-bottom: 1rem;
}
.chip-filter { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .32rem .75rem;
    border-radius: 999px;
    font-size: .85rem;
    text-decoration: none;
    color: var(--ink-soft);
    background: var(--surface);
    border: 1px solid var(--border);
}
.chip:hover { filter: brightness(.985); }
.chip__count { font-variant-numeric: tabular-nums; opacity: .7; }
.chip.is-current { font-weight: 700; }
.chip.is-current .chip__count { opacity: 1; }

/* Semantic filter chips: Aktywne = green, Zakończone (redeemed) = grey, Wszystkie = blue.
   Unselected = light tint of the same hue; selected = filled + stronger border. */
.chip--active   { color: var(--tone-positive-ink); background: #f3faf5; border-color: #d8ecdf; }
.chip--active.is-current   { background: var(--tone-positive-bg);  border-color: var(--tone-positive-ink); }
.chip--redeemed { color: var(--tone-muted-ink);    background: #f6f7f8; border-color: var(--tone-muted-line); }
.chip--redeemed.is-current { background: var(--tone-muted-bg);     border-color: var(--tone-muted-ink); }
.chip--all      { color: var(--accent);            background: #f3f7fd; border-color: #d8e5f6; }
.chip--all.is-current      { background: var(--tone-neutral-bg);   border-color: var(--accent); }

/* Admin > Inwestycje chips (AdminPositionFilter): active/all reuse the two
   rules above verbatim (same keys); early_redeemed/matured are their own
   "ended" lifecycle group, same muted tone as .chip--redeemed. */
.chip--early_redeemed { color: var(--tone-muted-ink); background: #f6f7f8; border-color: var(--tone-muted-line); }
.chip--early_redeemed.is-current { background: var(--tone-muted-bg); border-color: var(--tone-muted-ink); }
.chip--matured  { color: var(--tone-muted-ink);    background: #f6f7f8; border-color: var(--tone-muted-line); }
.chip--matured.is-current  { background: var(--tone-muted-bg);     border-color: var(--tone-muted-ink); }

/* Payout schedule chips: Do wypłaty = amber, Wypłacono = green, Wszystkie = blue */
.chip--payout-due  { color: var(--tone-attention-ink); background: #fdf6ec; border-color: var(--tone-attention-line); }
.chip--payout-due.is-current  { background: var(--tone-attention-bg); border-color: var(--tone-attention-ink); }
.chip--payout-paid { color: var(--tone-positive-ink);  background: #f3faf5; border-color: #d8ecdf; }
.chip--payout-paid.is-current { background: var(--tone-positive-bg);  border-color: var(--tone-positive-ink); }
.chip--payout-all  { color: var(--accent);             background: #f3f7fd; border-color: #d8e5f6; }
.chip--payout-all.is-current  { background: var(--tone-neutral-bg);   border-color: var(--accent); }

/* Tone-driven filter chips (token-only, no raw colours): inactive chips keep
   the subtle neutral base above; ONLY .is-current is filled with its tone.
   Reusable anywhere a status/filter chip needs a semantic colour. */
.chip--tone-neutral.is-current   { background: var(--tone-neutral-bg);   color: var(--tone-neutral-ink);   border-color: var(--tone-neutral-ink); }
.chip--tone-attention.is-current { background: var(--tone-attention-bg); color: var(--tone-attention-ink); border-color: var(--tone-attention-ink); }
.chip--tone-positive.is-current  { background: var(--tone-positive-bg);  color: var(--tone-positive-ink);  border-color: var(--tone-positive-ink); }
.chip--tone-danger.is-current    { background: var(--tone-danger-bg);    color: var(--tone-danger-ink);    border-color: var(--tone-danger-ink); }
.chip--tone-muted.is-current     { background: var(--tone-muted-bg);     color: var(--tone-muted-ink);     border-color: var(--tone-muted-ink); }

.sort-control { display: flex; align-items: center; gap: .4rem; }
.sort-control__label { color: var(--ink-soft); font-size: .8125rem; }
.sort-control__select {
    font: inherit;
    font-size: .85rem;
    padding: .3rem 1.6rem .3rem .55rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    max-width: 15rem;
}
.sort-control__apply {
    font: inherit;
    font-size: .82rem;
    padding: .32rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
    color: var(--ink);
    cursor: pointer;
}
.sort-control__apply:hover { background: var(--tone-neutral-bg); border-color: var(--tone-neutral-line); }

.investment-list { display: flex; flex-direction: column; gap: .55rem; }

.investment-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: box-shadow .15s ease, border-color .15s ease;
}
.investment-row:hover { box-shadow: var(--shadow-sm); border-color: #d9dee6; }
.investment-row[open] { box-shadow: var(--shadow); border-color: #cdd5df; }

/* Collapsed row = the <summary>: ONE compact horizontal line.
   [ id (flexible) ][ ring ][ facts (compact) ]......[ aside: badge / details ].
   The whitespace lives between the facts group and the right aside
   (margin-left:auto), so the ring drops into the gap right after the id
   block without pushing the facts to the far right. gap ~20px, no
   space-between, no flex:1 on ring/aside. flex-wrap is a fallback only. */
.investment-row__summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 1rem;
    padding: .8rem 1.05rem;
    cursor: pointer;
    list-style: none;
    border-radius: var(--radius);
}
.investment-row__summary::-webkit-details-marker { display: none; }
.investment-row__summary:hover { background: var(--surface-sunken); }
.investment-row__summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* Wrapper for id + ring. Takes over the "fill line 1" role: it grows to
   summary.width - facts - aside - gaps, a width independent of --ring-gap,
   so tuning --ring-gap moves only the ring, never the facts/aside columns. */
.investment-row__lead {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: var(--ring-gap, 1rem);
}
/* flex: 0 1 (not 1 1) - keeps the 11rem basis and shrink-under-pressure, but
   must not grow, or it would eat --ring-gap and pin the ring to the id block. */
.investment-row__id { flex: 0 1 11rem; min-width: 0; display: flex; flex-direction: column; }
.investment-row__series { font-weight: 700; font-size: 1rem; line-height: 1.25; }
.investment-row__issuer { color: var(--ink-soft); font-size: .85rem; }

/* Maturity progress ring - pure CSS conic-gradient, no JS/SVG. --p = 0..100.
   Compact fixed block (~44px), sits in the empty space after the id block. */
.ring {
    --p: 0;
    position: relative;
    flex: 0 0 auto;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: conic-gradient(
        var(--accent) calc(var(--p) * 1%),
        var(--border) calc(var(--p) * 1%)
    );
}
.ring::before {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--surface);
}
.investment-row__summary:hover .ring::before { background: var(--surface-sunken); }
.investment-row[open] .ring::before { background: var(--surface); }
.ring__pct {
    position: relative;
    font-size: .68rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

/* Compact horizontal facts group - content width, small gap (not far right). */
.investment-row__facts { flex: 0 1 auto; display: flex; flex-wrap: wrap; gap: .3rem 1rem; }
.investment-row__fact { display: flex; flex-direction: column; gap: .05rem; }
.investment-row__fact-k { color: var(--ink-soft); font-size: .68rem; text-transform: uppercase; letter-spacing: .01em; }
.investment-row__fact-v { font-weight: 600; font-size: .9rem; font-variant-numeric: tabular-nums; }

/* Right column holds only the lifecycle badge; align-self:flex-start pins it
   to the top of the summary row so it never moves when the toggle below grows. */
.investment-row__aside {
    margin-left: auto;
    flex: 0 0 8rem;
    display: flex;
    justify-content: flex-end;
    align-self: flex-start;
}

/* Details toggle: its own full-width line under the summary row. margin-top is
   the single vertical-spacing control; the card just grows downward. */
.investment-row__toggle {
    display: flex;
    flex-basis: 100%;
    margin-top: .55rem;
    align-items: center;
    justify-content: flex-end;
    gap: .35rem;
    color: var(--accent);
    font-size: .82rem;
    font-weight: 600;
}
.investment-row__toggle::after {
    content: "";
    width: .46rem;
    height: .46rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-1px);
    transition: transform .15s ease;
}
.investment-row[open] .investment-row__toggle::after { transform: rotate(-135deg) translateY(-1px); }
.investment-row__toggle-hide { display: none; }
.investment-row[open] .investment-row__toggle-show { display: none; }
.investment-row[open] .investment-row__toggle-hide { display: inline; }

/* Lifecycle badge (client dashboard). Admin keeps the shared .badge component. */
.lifecycle-badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .6rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: .76rem;
    font-weight: 600;
    white-space: nowrap;
}
.lifecycle-badge--active {
    background: var(--tone-positive-bg);
    color: var(--tone-positive-ink);
    border-color: var(--tone-positive-ink);
    box-shadow: 0 0 0 3px rgba(28, 107, 58, .12);
}
.lifecycle-badge--matured {
    background: var(--tone-muted-bg);
    color: var(--tone-muted-ink);
    border-color: var(--tone-muted-line);
}
.lifecycle-badge--early_redeemed {
    background: #f7f0e3;
    color: #7a6636;
    border-color: #dfcfa8;
}
.lifecycle-badge--archived {
    background: var(--tone-muted-bg);
    color: var(--tone-muted-ink);
    border-color: var(--tone-muted-line);
}

/* Expanded panel */
.investment-row__detail {
    border-top: 1px solid var(--border-soft);
    padding: 1rem 1.05rem 1.15rem;
    display: grid;
    gap: 1.25rem;
}
.investment-detail__facts {
    display: grid;
    grid-template-columns: 1fr;
    gap: .1rem;
}
.investment-detail__facts > div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: .5rem 0;
    border-bottom: 1px solid var(--border-soft);
}
.investment-detail__facts > div:last-child { border-bottom: 0; }
.investment-detail__facts dt { color: var(--ink-soft); font-size: .85rem; }
.investment-detail__facts dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.investment-detail__facts .dd-sub { display: block; font-weight: 400; font-size: .8125rem; color: var(--ink-soft); }
/* Leading time icon on the "Wcześniejszy wykup" value - the date keeps its
   existing weight / size / colour, the icon just sits on the text line. */
.investment-detail__facts dd .icon { vertical-align: -.14em; margin-right: .3rem; color: var(--ink-soft); }

.investment-detail__timeline-title {
    font-size: .95rem;
    font-weight: 700;
    margin-bottom: .75rem;
}

/* Admin client-detail: one investment = the shared expandable row + a compact
   admin action bar, wrapped as a single flat card (no card-in-card - the inner
   .investment-row drops its own border/background). */
.admin-investment {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: box-shadow .15s ease, border-color .15s ease;
}
.admin-investment:hover { box-shadow: var(--shadow-sm); border-color: #d9dee6; }
.admin-investment .investment-row {
    border: 0;
    background: none;
    border-radius: 0;
    box-shadow: none;
}
.admin-investment .investment-row:hover,
.admin-investment .investment-row[open] { box-shadow: none; border-color: transparent; }

.admin-investment__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    padding: .5rem .8rem;
    border-bottom: 1px solid var(--border-soft);
}
.admin-investment__actions form { margin: 0; }
.admin-investment__actions .disclosure--bare { margin-top: 0; }
.admin-investment__actions .disclosure--bare[open] { flex-basis: 100%; }
.admin-investment__actions .disclosure--bare .form--inline { margin-top: .6rem; max-width: 22rem; }

/* Vertical coupon/redemption timeline - one markup, works desktop + mobile */
.timeline { position: relative; margin: 0; padding: 0 0 0 1.35rem; }
.timeline::before {
    content: "";
    position: absolute;
    left: 5px;
    top: .35rem;
    bottom: .35rem;
    width: 2px;
    background: var(--border);
}
.timeline__point { position: relative; padding: .5rem 0; }
.timeline__point + .timeline__point { border-top: 1px solid var(--border-soft); }
.timeline__dot {
    position: absolute;
    left: calc(-1.35rem + 1px);
    top: .95rem;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--surface);
    border: 2px solid var(--ink-faint);
}
.timeline__point.is-past .timeline__dot { background: var(--ink-faint); }
.timeline__point--positive .timeline__dot { border-color: var(--tone-positive-ink); }
.timeline__point--positive.is-past .timeline__dot { background: var(--tone-positive-ink); }
.timeline__point--attention .timeline__dot { border-color: var(--tone-attention-ink); }
.timeline__dot--final {
    width: 13px;
    height: 13px;
    left: calc(-1.35rem - 1px);
    border-color: var(--accent);
    background: var(--accent);
}
.timeline__body { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem 1rem; }
.timeline__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; }
.timeline__date { font-weight: 600; font-variant-numeric: tabular-nums; }
.timeline__label { color: var(--ink-soft); font-size: .85rem; }
.timeline__amounts { margin-left: auto; text-align: right; }
.timeline__net { font-weight: 700; font-variant-numeric: tabular-nums; }
.timeline__sub { display: block; color: var(--ink-soft); font-size: .78rem; }
.timeline__point--final .timeline__label { color: var(--accent); font-weight: 600; }

/* Coupon schedule - table on desktop, stacked cards under 760px */
.table-scroll { overflow-x: auto; }
.coupon-table { width: 100%; max-width: 760px; border-collapse: collapse; }
.coupon-table thead th {
    text-align: left;
    padding: .45rem .75rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--ink-soft);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.coupon-table th.is-num { text-align: right; }
.coupon-table td {
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
.coupon-table tbody tr:last-child td { border-bottom: 0; }
.coupon-table tbody tr:hover { background: var(--surface-sunken); }
.coupon-table .is-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.coupon-table__period { width: 3.25rem; font-weight: 700; }
.coupon-table__net { font-weight: 700; }
.coupon-table__paid { display: block; margin-top: .1rem; font-size: .775rem; color: var(--ink-faint); }

@media (max-width: 759px) {
    .table-scroll { overflow-x: visible; }
    .coupon-table thead {
        position: absolute;
        width: 1px; height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
    .coupon-table,
    .coupon-table tbody,
    .coupon-table tr,
    .coupon-table td { display: block; width: auto; }
    .coupon-table tr {
        border: 1px solid var(--border);
        border-left: 3px solid var(--tone-muted-line);
        border-radius: var(--radius-sm);
        padding: .55rem .8rem;
        margin-bottom: .6rem;
    }
    .coupon-table__row--positive  { border-left-color: var(--tone-positive-ink); }
    .coupon-table__row--attention { border-left-color: var(--tone-attention-ink); }
    .coupon-table__row--neutral   { border-left-color: var(--accent); }
    .coupon-table td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 1rem;
        padding: .22rem 0;
        border: 0;
        text-align: right;
    }
    .coupon-table td::before {
        content: attr(data-label);
        color: var(--ink-soft);
        font-size: .8125rem;
        font-weight: 500;
        text-align: left;
    }
    .coupon-table__period { width: auto; }
    .coupon-table__paid { display: inline; margin: 0; }
}

/* Schedule list */
.schedule-list { display: flex; flex-direction: column; }
.schedule-list__year {
    margin: 1rem 0 .35rem;
    color: var(--ink-faint);
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .06em;
}
.schedule-list__year:first-child { margin-top: 0; }
.schedule-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: .75rem;
    padding: .7rem 0;
    border-bottom: 1px solid var(--border-soft);
}
.schedule-row:last-child { border-bottom: 0; }
.schedule-row__date { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: .9rem; }
.schedule-row__body { display: flex; flex-direction: column; min-width: 0; }
.schedule-row__series { font-weight: 600; }
.schedule-row__issuer { color: var(--ink-soft); font-size: .85rem; }
.schedule-row__amount { font-weight: 700; white-space: nowrap; }

/* Account list */
.account-list {
    display: grid;
    gap: .85rem;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.account-card {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.05rem;
}
.account-card--inactive { opacity: .75; }
/* Settings context ("Moje dane"): one account per row so the inline edit
   form has full width. */
.account-list--stack { grid-template-columns: 1fr; }
.account-list--stack .account-card__actions { width: 100%; }
.account-list--stack .account-card__actions .disclosure[open] { flex: 1 1 100%; }
.account-list--stack .account-card__actions .form--inline { max-width: 30rem; }
.account-card__iban { font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: .02em; }
.account-card__meta { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.account-card__label { color: var(--ink-soft); font-size: .9rem; }

/* Admin client-detail: ONE compact card for all payout accounts (no oversized
   per-account cards). Row 1 = IBAN + status badge on one line; row 2 = actions. */
.acct-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: .4rem .7rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.acct-card__note { color: var(--ink-soft); font-size: .875rem; margin: .4rem 0; }
.acct { padding: .65rem 0; border-top: 1px solid var(--border-soft); min-width: 0; }
.acct:first-child { border-top: 0; }
.acct--off { opacity: .7; }
.acct__top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .35rem;
}
.acct__iban {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    letter-spacing: 0;
    font-size: .72rem;
    white-space: nowrap;
}
.acct__top .badge { flex: 0 0 auto; font-size: .66rem; padding: .05rem .3rem; }
.acct__label { color: var(--ink-soft); font-size: .8rem; margin: .25rem 0 0; }
.acct__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: .35rem;
    margin-top: .5rem;
}
.acct__actions form { margin: 0; }
.acct__actions .disclosure--bare { margin-top: 0; }
.acct__actions .disclosure--bare[open] { flex: 1 1 100%; }
.acct__actions .disclosure--bare[open] .form--inline { margin-top: .55rem; max-width: 100%; }

/* Client "Statystyki": two simple CSS-only charts (no library) - a 12-column
   bar chart for the current year's monthly interest, and a compact donut for
   "paid vs remaining". Bar heights / donut share and stacking ratios are
   integers or Money amounts set server-side as the --h / --p custom property
   or an inline flex-grow - same pattern as the maturity-progress .ring
   (conic-gradient, --p). Colors always come from the --chart-* tokens above -
   nothing here repeats a raw hex/rgb value. */
/* Single column by default (mobile/narrow tablet); becomes a 3fr/1fr row -
   monthly chart left, donut right - at the same >=1120px breakpoint already
   used by .dashboard-grid/.admin-grid below. */
.stats-charts { display: grid; gap: 1rem; margin-top: 1.25rem; }

/* The legend lives in the card's own .section-head row (title left, legend
   right) instead of a separate row under the chart. */
.stats-charts__main .section-head .bar-chart__legend { align-self: center; }

/* Y-axis: 5 monetary labels (view.monthlyChartAxis, highest first, 0 zł
   last) in their own column, the exact same 150px height as .bar-chart so
   the flex `justify-content: space-between` distribution lines their edges
   up with the chart's 0/25/50/75/100% grid lines. Width is auto (sized to
   its own content, whatever the longest label needs) so labels never clip
   and never eat into the plotting area. Small/muted text, matching the
   grid lines' subtlety - existing --ink-faint token, not a new gray. */
.bar-chart-plot { display: flex; gap: .5rem; }
.bar-chart__axis {
    flex: 0 0 auto;
    height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    text-align: right;
    font-size: .68rem;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.bar-chart {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: flex-end;
    gap: .5rem;
    height: 150px; /* ~145-160px plotting area */
    padding: 0 .25rem;
    /* Subtle horizontal reference lines only (no vertical grid) - a plain
       repeating background, using the existing neutral border token rather
       than a new chart-specific gray. Sits behind the bars automatically:
       it is the container's own background, bars paint over it as children. */
    background-image: repeating-linear-gradient(
        to top,
        var(--border-soft) 0,
        var(--border-soft) 1px,
        transparent 1px,
        transparent 25%
    );
}
.bar-chart__col {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: .4rem;
}
/* A month with nothing due/scheduled renders no .bar-chart__bar at all - no
   sliver, no artificial minimum height - only its label stays, per-column,
   so the other columns' bars are unaffected. No amount label is ever
   rendered above a bar (mockup shows bars + axis labels only). */
.bar-chart__bar {
    width: 100%;
    max-width: 30px; /* ~28-34px on desktop */
    height: var(--h, 0%);
    border-radius: 3px 3px 0 0;
    display: flex;
    flex-direction: column-reverse; /* first child (paid) anchors the bottom */
    overflow: hidden;
}
.bar-chart__seg--paid     { background: var(--chart-paid); }
.bar-chart__seg--forecast { background: var(--chart-forecast); }
.bar-chart__label { font-size: .72rem; color: var(--ink-soft); }

.bar-chart__legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; font-size: .8rem; color: var(--ink-soft); }
.bar-chart__legend-item { display: flex; align-items: center; gap: .4rem; }
.bar-chart__swatch { width: .6rem; height: .6rem; border-radius: 2px; flex: 0 0 auto; }
.bar-chart__swatch--paid     { background: var(--chart-paid); }
.bar-chart__swatch--forecast { background: var(--chart-forecast); }

/* Wypłacone / pozostało: compact 2-part donut, conic-gradient with a punched
   center - identical technique to .ring, just larger and two-tone. Stacked
   (ring, then a tight two-row amount summary, both centered/full-width) so
   it stays compact in the narrow 1fr side column and never grows the card. */
.split-donut { display: flex; flex-direction: column; align-items: center; gap: .65rem; }
.split-donut__ring {
    --p: 0;
    position: relative;
    flex: 0 0 auto;
    width: 6rem;
    height: 6rem;
    border-radius: 50%;
    background: conic-gradient(
        var(--chart-paid) calc(var(--p) * 1%),
        var(--chart-forecast) calc(var(--p) * 1%)
    );
}
.split-donut__ring::before {
    content: "";
    position: absolute;
    inset: 20%;
    border-radius: 50%;
    background: var(--surface);
}
/* Two compact rows, label left / amount right - stretches to the card's
   full content width instead of shrink-wrapping under the ring. */
.split-donut__summary { align-self: stretch; display: flex; flex-direction: column; gap: .35rem; }
.split-donut__row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.split-donut__row-label { display: flex; align-items: center; gap: .4rem; color: var(--ink-soft); font-size: .8125rem; }
.split-donut__row-amount { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; font-size: .875rem; }
.split-donut__dot { width: .5rem; height: .5rem; border-radius: 50%; flex: 0 0 auto; }
.split-donut__dot--paid     { background: var(--chart-paid); }
.split-donut__dot--forecast { background: var(--chart-forecast); }

@media (max-width: 640px) {
    .bar-chart { gap: .25rem; }
}

/* --- 8b. Admin --------------------------------------------------------- */

/* Two-column admin layout: content + fixed side rail */
.admin-grid { display: grid; gap: 1.25rem; }

/* Admin payout schedule: filter + global total row, then flat per-month groups
   (heading -> one table-card -> month total). No card-in-card.
   .schedule-month__total (below) is also reused, unmodified, by the client
   "Harmonogram wypłat" page (templates/portfolio/schedule.html.twig) - same
   per-month section shape, no cross-client filter/global total there. */
.schedule-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem 1rem;
}
.schedule-toolbar__total { color: var(--ink-soft); font-size: .9rem; }
.schedule-toolbar__total strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.schedule-month__total {
    margin-top: .6rem;
    text-align: right;
    color: var(--ink-soft);
    font-size: .875rem;
}
.schedule-month__total strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.detail-strip { margin-top: -.75rem; display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; }
.detail-strip__actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.detail-strip__actions form { margin: 0; }
/* account status badge sits at the far right of the same row */
.detail-strip__status { margin-left: auto; }

/* investment filter chips, right-aligned in the "Inwestycje klienta" heading row */
.section-head__filters { align-self: center; }

.page-actions { display: flex; justify-content: flex-end; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .5rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { background: var(--surface-sunken); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn--ghost { background: transparent; }
.btn--sm { padding: .35rem .7rem; font-size: .8125rem; }
.btn--xs { padding: .25rem .5rem; font-size: .75rem; font-weight: 600; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 1.25rem; }
.form--inline { margin-top: .85rem; gap: .85rem; }
.form__group {
    border: 0;
    border-top: 1px solid var(--border-soft);
    padding: 1rem 0 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: .85rem;
}
.form__group:first-of-type { border-top: 0; padding-top: 0; }
.form__group legend { font-weight: 700; font-size: .95rem; padding: 0; margin-bottom: .25rem; }
.form__row { display: grid; gap: .85rem; }
.form__note { color: var(--ink-soft); font-size: .8125rem; margin: 0; }
.form__actions { display: flex; flex-wrap: wrap; gap: .6rem; padding-top: .5rem; }

.form-field { display: flex; flex-direction: column; gap: .3rem; }
.form-field > label { font-weight: 600; font-size: .85rem; color: var(--ink); }
.form-field__req { color: var(--tone-attention-ink); }
.form-field input,
.form-field select {
    padding: .5rem .65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: .9375rem;
    width: 100%;
}
.form-field input:focus,
.form-field select:focus { border-color: var(--accent); }
.form-field.has-error input,
.form-field.has-error select { border-color: var(--tone-attention-ink); }
.form-field__hint { color: var(--ink-faint); font-size: .8rem; margin: 0; }
.form-field__error { color: var(--tone-attention-ink); font-size: .8125rem; font-weight: 500; margin: 0; }
.form-field__static { font-weight: 600; margin: 0; padding: .35rem 0; }

/* Inline disclosure (add / edit forms tucked behind a summary) */
.disclosure { margin-top: .85rem; }
.disclosure > summary {
    display: inline-flex;
    list-style: none;
    width: auto;
}
.disclosure > summary::-webkit-details-marker { display: none; }

/* Per-item admin action rows */
.account-card__actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-start; }
.account-card__actions form { margin: 0; }

@media (min-width: 640px) {
    .form__row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form__row .form-field:only-child { grid-column: 1 / -1; }
}


/* Search / select toolbar (extends .toolbar from section 8) */
.toolbar__search { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.toolbar__search input[type="search"],
.toolbar__search select {
    padding: .42rem .6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font: inherit;
    font-size: .875rem;
    color: var(--ink);
    min-width: 11rem;
}
.toolbar__search button {
    padding: .42rem 1rem;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
}
.toolbar__search button:hover { background: var(--accent-dark); }

.filterbar { display: flex; flex-wrap: wrap; gap: .3rem; }

/* Admin > Klienci: filter chips + search + "Szukaj" + "Nowy klient" all on
   ONE horizontal row; stacks only on narrow screens. */
.client-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem 1rem;
    margin-bottom: .75rem;
}
.client-controls__filters { flex: 0 1 auto; }
.client-controls__search { margin: 0; margin-left: auto; }  /* push search + new to the right */
.client-controls__new { margin: 0; flex: 0 0 auto; }
.client-controls__summary {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem 1rem;
    font-size: .9rem;
    margin: 0 0 1rem;
}
@media (max-width: 720px) {
    .client-controls__search { margin-left: 0; width: 100%; }
    .client-controls__search input[type="search"] { flex: 1 1 auto; min-width: 0; }
    .client-controls__new { width: 100%; text-align: center; }
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: .875rem;
}
.pagination__link { text-decoration: none; font-weight: 600; }
.pagination__link:hover { text-decoration: underline; }
.pagination__link.is-disabled { color: var(--ink-faint); font-weight: 400; }
.pagination__status { color: var(--ink-soft); }

/* Responsive table: table on desktop, stacked cards under 760px. Full card
   width, no max-width - avoid .coupon-table (760px cap) for a full-width page
   table like the admin and client payout schedules.
   One markup; column labels come from a per-page cols array (also used for the
   mobile data-label). Status tone via optional .rtable__row--<tone>. */
.table-card { overflow-x: auto; }
.rtable { width: 100%; border-collapse: collapse; }
.rtable thead th {
    text-align: left;
    padding: .55rem .75rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--ink-soft);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.rtable th.is-num { text-align: right; }
.rtable td {
    padding: .65rem .75rem;
    font-size: .9rem;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
.rtable tbody tr:last-child td { border-bottom: 0; }
.rtable tbody tr:hover { background: var(--surface-sunken); }
.rtable td.is-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.rtable__primary { font-weight: 600; }
.rtable__primary a { text-decoration: none; }
.rtable__primary a:hover { text-decoration: underline; }
.rtable__action { text-align: right; white-space: nowrap; }
.rtable__action a { font-weight: 600; text-decoration: none; font-size: .875rem; }
.rtable__action a:hover { text-decoration: underline; }

/* Monthly total as a <tfoot> row (not a paragraph under the table), so its
   amount cell sits in the SAME column as the body rows' amount - "Suma"
   naturally lines up under e.g. "Odsetki". Used by the client payout
   schedule (templates/portfolio/schedule.html.twig); admin's own schedule
   keeps its separate .schedule-month__total paragraph, untouched. */
.rtable__total-row td { border-top: 1px solid var(--border); border-bottom: 0; font-weight: 700; }

@media (min-width: 760px) {
    .table-card {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: .35rem .75rem;
    }
}
@media (max-width: 759px) {
    .rtable thead {
        position: absolute;
        width: 1px; height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
    .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: auto; }
    .rtable tr {
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        padding: .6rem .85rem;
        margin-bottom: .65rem;
        background: var(--surface);
    }
    .rtable__row--positive  { border-left: 3px solid var(--tone-positive-ink); }
    .rtable__row--attention { border-left: 3px solid var(--tone-attention-ink); }
    .rtable__row--neutral   { border-left: 3px solid var(--accent); }
    .rtable__row--muted     { border-left: 3px solid var(--tone-muted-line); }
    .rtable td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 1rem;
        padding: .22rem 0;
        border: 0;
        text-align: right;
    }
    .rtable td:empty { display: none; }
    .rtable td::before {
        content: attr(data-label);
        color: var(--ink-soft);
        font-size: .8125rem;
        font-weight: 500;
        text-align: left;
    }
    .rtable td[data-label=""]::before { content: none; }
    .rtable__action { text-align: left; }
    /* the label cell (colspan on desktop) is redundant once stacked - the
       amount cell's own data-label="Suma" already carries it, on one line */
    .rtable__total-label { display: none; }
}

/* Dashboard "Struktura portfela" - one horizontal card per issuer, visually
   related to the investment rows (surface + border + radius, no outer panel). */
.issuer-cards { display: flex; flex-direction: column; gap: .55rem; }
.issuer-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .8rem 1.05rem;
}
.issuer-card__body { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.issuer-card__name { font-weight: 700; font-size: 1rem; line-height: 1.25; }
.issuer-card__meta { display: flex; flex-wrap: wrap; gap: .1rem 1rem; color: var(--ink-soft); font-size: .85rem; }
.issuer-card__capital { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Slightly larger ring for the issuer structure cards (same conic-gradient
   language as .ring; ::before inset picks up the card's surface colour). */
.ring--card { width: 3.1rem; height: 3.1rem; }
.ring--card .ring__pct { font-size: .72rem; }

/* Accounting reports (Zestawienia księgowe): compact generation form + filters */
.report-form__row { display: grid; gap: .5rem 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .report-form__row { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.report-form__row .form-field { margin: 0; }

.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem 1rem; margin-bottom: 1rem; }
.filter-bar__field { display: flex; flex-direction: column; gap: .25rem; font-size: .8125rem; color: var(--ink-soft); }
/* Every filter control shares one shape: same height, radius, padding, type. */
.filter-bar__field select,
.filter-bar__field input {
    height: 2.25rem;
    padding: .35rem .55rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: .875rem;
}
.filter-bar__field select:focus,
.filter-bar__field input:focus { border-color: var(--accent); }
.filter-bar__actions { display: flex; gap: .5rem; align-self: flex-end; }
.filter-bar__actions .btn { height: 2.25rem; }

.rtable__inline-form { display: inline; margin: 0; }
.rtable__action .rtable__inline-form + a,
.rtable__action a + .rtable__inline-form,
.rtable__action .rtable__inline-form + .rtable__inline-form { margin-left: .5rem; }

/* Admin > Inwestycje: inline row editing. Kapitał/Oprocentowanie/Data
   nabycia each carry a view span + a hidden input; "Edytuj" (a real link -
   the no-JS fallback is the full edit page) toggles the row to
   .is-editing, swapping which one shows and swapping Edytuj for
   Zapisz/Anuluj. Each row's actual <form> lives OUTSIDE the table (a <form>
   cannot legally wrap cells split across one <tr>) - inputs/buttons point
   at it via the HTML `form="..."` attribute. */
.rtable__edit-input {
    display: none;
    width: 100%;
    max-width: 7rem;
    font: inherit;
    padding: .2rem .35rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
tr.is-editing .rtable__view { display: none; }
tr.is-editing .rtable__edit-input { display: inline-block; }
.rtable__edit-save,
.rtable__edit-cancel { display: none; }
tr.is-editing .rtable__edit-toggle { display: none; }
tr.is-editing .rtable__edit-save,
tr.is-editing .rtable__edit-cancel { display: inline-block; }

/* Admin > Zdarzenia systemowe: status chips + filter form share one compact
   card; tight internal spacing so the controls, counters and table sit close. */
.system-events__filters {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    padding: .85rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.system-events__filters .filter-bar { margin-bottom: 0; }
.system-events__summary {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem 1rem;
    /* sit close to the filter card and the table below (the page column adds
       its own 1.25rem gap on each side) */
    margin: -.5rem 0;
    font-size: .9rem;
}

/* Admin > Zdarzenia systemowe: the per-row "Szczegóły" disclosure. The
   context JSON is already sanitised (App\Infrastructure\SystemEvent) and
   is rendered as autoescaped text - never raw HTML. */
.system-event__details { margin-top: .4rem; }
.system-event__entity { margin: .35rem 0 0; font-size: .8125rem; color: var(--ink-soft); }
.system-event__context {
    margin: .35rem 0 0;
    max-width: 100%;
    overflow-x: auto;
    padding: .5rem .6rem;
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
    font-size: .78rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

/* --- 9. Responsive --------------------------------------------------- */

/* Two position-card columns once there is room (dashboard + list) */
@media (min-width: 640px) {
    .position-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Detail top: two equal-height cards */
@media (min-width: 760px) {
    .detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: stretch; }
    .detail-grid .panel { height: 100%; }
}

@media (min-width: 900px) {
    .app {
        display: grid;
        grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
        align-items: start;
    }
    .app-topbar { display: none; }
    .nav-scrim { display: none !important; }

    .app-sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        width: auto;
        max-width: none;
        transform: none;
        transition: none;
    }

    .app-main { padding: 2rem 2rem 3.5rem; gap: 1.875rem; }

    .page-header h1 { font-size: 1.875rem; }

    .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Three list columns on wide desktop */
@media (min-width: 1200px) {
    .position-grid--list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Dashboard / admin side rails become fixed columns on wide desktop */
@media (min-width: 1120px) {
    .dashboard-grid {
        grid-template-columns: minmax(0, 1fr) 360px;
        gap: 1.5rem;
        align-items: start;
    }
    .admin-grid {
        grid-template-columns: minmax(0, 1fr) 380px;
        gap: 1.5rem;
        align-items: start;
    }
    .client-detail-grid {
        grid-template-columns: minmax(0, 3fr) minmax(240px, 1fr);
        gap: 1.5rem;
        align-items: start;
    }
    /* Statystyki: monthly chart 75% / donut 25%, side by side. align-items:
       start keeps the compact donut card from being stretched to the taller
       chart card's height. */
    .stats-charts {
        grid-template-columns: minmax(0, 3fr) minmax(200px, 1fr);
        gap: 1.5rem;
        align-items: start;
    }
}

/* Investment row on narrow screens: id + ring on the first line, facts wrap to
   full width below, badge/toggle drop to their own right-aligned block. */
/* Mobile: id + ring share the first line, facts wrap full-width below,
   badge + details action stay an obvious right-aligned block. */
@media (max-width: 560px) {
    .investment-row__summary { gap: .5rem .9rem; padding: .8rem .85rem; }
    .investment-row__lead { flex-basis: 100%; gap: .75rem; }
    .investment-row__id { flex: 1 1 auto; }
    .ring { width: 2.55rem; height: 2.55rem; }
    .investment-row__facts { order: 3; flex-basis: 100%; gap: .5rem 1.25rem; }
    .investment-row__toggle { order: 4; }
    .investment-row__aside { min-width: 0; }
    .kpi--iconed .kpi__value { font-size: 1.55rem; }
}

@media (prefers-reduced-motion: reduce) {
    .app-sidebar, .skip-link,
    .investment-row, .investment-row__toggle::after { transition: none; }
}
