/*
 * MVP20.10 — stabilizacja layoutu.
 * Ładowany jako ostatni arkusz, aby nadpisać historyczne konflikty stylów.
 */

:root {
    --layout-content-max: 1440px;
}

/* ===== Cache-safe, stabilny shell administratora ===== */
html,
body.app-page {
    min-width: 1180px;
    overflow-x: auto;
}

body.app-page {
    margin: 0;
}

.app-shell {
    min-width: 1180px;
    min-height: 100vh;
    display: grid !important;
    grid-template-columns: var(--layout-sidebar-width, 264px) minmax(0, 1fr) !important;
    align-items: start;
}

.app-shell > .sidebar {
    width: var(--layout-sidebar-width, 264px) !important;
    min-width: var(--layout-sidebar-width, 264px) !important;
    height: 100vh;
    display: flex !important;
    visibility: visible !important;
    position: sticky !important;
    inset: 0 auto auto 0;
    align-self: start;
    overflow: hidden;
}

.app-shell > .workspace {
    width: 100%;
    min-width: 0;
    max-width: none;
    box-sizing: border-box;
}

.workspace > *:not(.app-topbar) {
    width: min(100%, var(--layout-content-max, 1440px));
    margin-right: auto;
    margin-left: auto;
    box-sizing: border-box;
}

.app-topbar__inner {
    width: min(100%, var(--layout-content-max, 1440px));
}

/* Nagłówki nie rozciągają się ponad obszar treści. */
.workspace-header {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* ===== Podsumowania i toolbary ===== */
.module-summary {
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.module-summary__item {
    min-width: 0;
    box-sizing: border-box;
}

.client-toolbar,
.project-toolbar {
    width: 100%;
    box-sizing: border-box;
}

.search-form,
.project-filter-form {
    min-width: 0;
}

.search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: end;
}

.project-filter-form {
    display: grid;
    grid-template-columns: minmax(320px, 1.7fr) minmax(220px, .8fr) auto auto;
    align-items: end;
}

.search-form .field,
.project-filter-form .field {
    min-width: 0;
}

/* ===== Karty list: stały rytm zamiast przypadkowego rozciągania ===== */
.client-card-grid,
.project-card-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 420px));
    justify-content: start;
    align-items: stretch;
    gap: 18px;
}

.client-card,
.project-card {
    width: 100%;
    min-width: 0;
    max-width: 420px;
    box-sizing: border-box;
}

.client-card {
    display: flex;
    flex-direction: column;
}

.project-card {
    display: grid;
    grid-template-rows: auto 1fr;
}

.client-card__body,
.project-card__content,
.project-card__heading > div {
    min-width: 0;
}

.client-card__body h2,
.project-card__heading h2,
.client-card__body p,
.project-card__description,
.project-card__meta dd {
    overflow-wrap: anywhere;
}

/* ===== Login: pole hasła jest jednym zwartym komponentem ===== */
.auth-form--refined {
    display: grid;
    gap: 19px;
}

.auth-form--refined .field--auth {
    display: grid;
    grid-template-rows: auto 54px auto;
    gap: 8px;
    min-width: 0;
}

.auth-form--refined .input-control {
    width: 100%;
    height: 54px;
    min-height: 54px;
    display: block;
    position: relative;
}

.auth-form--refined .input-control input[type="text"],
.auth-form--refined .input-control input[type="password"] {
    width: 100%;
    height: 54px;
    min-height: 54px;
    margin: 0;
    box-sizing: border-box;
}

.auth-form--refined .input-control__icon {
    top: 50% !important;
    bottom: auto !important;
    left: 15px !important;
    margin: 0 !important;
    transform: translateY(-50%) !important;
}

.auth-form--refined .password-toggle {
    position: absolute !important;
    z-index: 4;
    top: 50% !important;
    right: 9px !important;
    bottom: auto !important;
    left: auto !important;
    width: 36px !important;
    height: 36px !important;
    display: grid !important;
    place-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: translateY(-50%) !important;
}

.auth-form--refined .password-toggle svg {
    width: 18px !important;
    height: 18px !important;
}

/* Pokazujemy zawsze dokładnie jedną ikonę oka. */
.auth-form--refined .password-toggle .password-toggle__show {
    display: block !important;
}

.auth-form--refined .password-toggle .password-toggle__hide {
    display: none !important;
}

.auth-form--refined .password-toggle[aria-pressed="true"] .password-toggle__show {
    display: none !important;
}

.auth-form--refined .password-toggle[aria-pressed="true"] .password-toggle__hide {
    display: block !important;
}

.auth-form--refined .caps-lock-hint {
    min-height: 0;
    margin: 0;
}

.auth-form--refined .caps-lock-hint:not(.is-visible) {
    display: none !important;
}

.auth-form--refined .caps-lock-hint.is-visible {
    display: inline-flex !important;
    min-height: 18px;
}

.auth-form--refined .auth-submit {
    width: 100%;
    margin-top: 0;
}

/* Desktop-only: przy mniejszej szerokości zachowujemy czytelny układ z przewijaniem. */
@media (max-width: 1320px) {
    :root {
        --layout-sidebar-width: 244px;
        --layout-gutter: 28px;
    }

    .module-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .project-filter-form {
        grid-template-columns: minmax(280px, 1fr) minmax(200px, .7fr) auto;
    }

    .project-filter-form .button--quiet {
        grid-column: 1 / -1;
        justify-self: start;
    }
}


/* MVP20.16 — uporządkowany nagłówek szczegółów klienta */
.workspace > .client-detail-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 32px;
    min-height: 148px;
    margin-bottom: 24px;
    padding: 26px 30px;
    overflow: hidden;
}

.workspace > .client-detail-header .client-detail-header__identity {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    align-items: center;
    gap: 26px;
    min-width: 0;
}

.workspace > .client-detail-header .client-detail-header__avatar {
    width: 88px;
    height: 88px;
    flex: 0 0 88px;
    border-radius: 20px;
    font-size: 34px;
    line-height: 1;
}

.workspace > .client-detail-header .client-detail-header__copy {
    display: grid;
    align-content: center;
    gap: 8px;
    min-width: 0;
}

.workspace > .client-detail-header .client-detail-header__copy .eyebrow,
.workspace > .client-detail-header .client-detail-header__copy h1,
.workspace > .client-detail-header .client-detail-header__copy .mono-value {
    margin: 0;
}

.workspace > .client-detail-header .client-detail-header__copy h1 {
    overflow: hidden;
    font-size: clamp(32px, 3vw, 46px);
    line-height: 1.08;
    letter-spacing: -0.045em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workspace > .client-detail-header .client-detail-header__copy .mono-value {
    font-size: 14px;
    line-height: 1.45;
}

.workspace > .client-detail-header > .status-pill {
    align-self: center;
    min-height: 34px;
    padding-inline: 14px;
    font-size: 12px;
}

@media (max-width: 900px) {
    .workspace > .client-detail-header {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 24px;
    }

    .workspace > .client-detail-header > .status-pill {
        justify-self: start;
    }
}

/* MVP20.24 — panel administratora pozostaje nieruchomy podczas przewijania strony. */
.app-shell > .sidebar {
    position: fixed !important;
    inset: 0 auto 0 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100vh;
    min-height: 100dvh;
    max-height: 100dvh;
    align-self: auto !important;
    overflow: hidden;
}

/* Po wyjęciu sidebara z przepływu utrzymujemy workspace w drugiej kolumnie siatki. */
.app-shell > .workspace {
    grid-column: 2 / 3;
    grid-row: 1;
}
