/*
 * Общие стили системы авторизации и кнопки личного кабинета.
 * Они подключаются после локального CSS каждого независимого раздела.
 */
:root {
    --auth-blue: #0b5cab;
    --auth-dark-blue: #073b75;
    --auth-red: #e31e2f;
    --auth-background: #eef4fa;
    --auth-border: #d7e2ed;
    --auth-text: #18324a;
    --auth-muted: #66788a;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Трехчастная шапка: логотип, название и личный кабинет справа. */
.site-header__inner--auth {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 24px;
}

.site-header__text {
    min-width: 0;
    text-align: center;
}

.site-header__inner--auth .site-title,
.site-header__inner--auth .site-subtitle {
    text-align: center;
}

.site-header__actions {
    min-width: 0;
}

/* Кнопка личного кабинета и кнопка выхода. */
.site-user {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--auth-border);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 6px 18px rgba(7, 59, 117, 0.08);
    overflow: hidden;
}

.site-user__account {
    min-height: 52px;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    color: var(--auth-dark-blue);
    text-decoration: none;
}

.site-user__icon {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #ffffff;
    background: var(--auth-blue);
}

.site-user__icon svg,
.site-user__logout svg {
    width: 19px;
    height: 19px;
    display: block;
    fill: currentColor;
}

.site-user__details {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.site-user__name {
    max-width: 190px;
    overflow: hidden;
    color: var(--auth-dark-blue);
    font-size: 14px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-user__role {
    max-width: 190px;
    overflow: hidden;
    margin-top: 2px;
    color: var(--auth-muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-user__logout-form {
    display: flex;
    margin: 0;
    border-left: 1px solid var(--auth-border);
}

.site-user__logout {
    width: 46px;
    min-width: 46px;
    min-height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: 0;
    color: var(--auth-muted);
    background: transparent;
    cursor: pointer;
}

.site-user__account:focus-visible,
.site-user__logout:focus-visible {
    position: relative;
    z-index: 2;
    outline: 3px solid rgba(11, 92, 171, 0.32);
    outline-offset: -3px;
}

@media (hover: hover) and (pointer: fine) {
    .site-user__account:hover {
        background: #f2f7fc;
    }

    .site-user__logout:hover {
        color: #ffffff;
        background: var(--auth-red);
    }
}

/* В технологическом журнале личный кабинет размещается в верхней навигации. */
.journal-navigation .site-header__actions {
    margin-left: auto;
}

.journal-navigation .site-user__account,
.journal-navigation .site-user__logout {
    min-height: 44px;
}

/* Страницы входа, установки и личного кабинета. */
body.auth-page {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    font-family: "Open Sans", Arial, sans-serif;
    color: var(--auth-text);
    background:
        radial-gradient(circle at top right, rgba(11, 92, 171, 0.18), transparent 32rem),
        var(--auth-background);
}

body.auth-page--top {
    align-items: flex-start;
    padding-top: 48px;
}

.auth-card {
    width: min(100%, 470px);
    padding: 32px;
    border: 1px solid var(--auth-border);
    border-radius: 22px;
    background: #ffffff;
    box-shadow: 0 18px 50px rgba(7, 59, 117, 0.14);
}

.auth-card--wide {
    width: min(100%, 760px);
}

.auth-logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.auth-logo-wrap img {
    width: 175px;
    max-width: 55vw;
    height: auto;
}

.auth-heading {
    margin-bottom: 24px;
    text-align: center;
}

.auth-heading h1 {
    margin: 0 0 9px;
    color: var(--auth-dark-blue);
    font-size: clamp(26px, 5vw, 36px);
    line-height: 1.2;
}

.auth-heading p {
    margin: 0;
    color: var(--auth-muted);
    line-height: 1.55;
}

.auth-badge {
    display: inline-block;
    margin-bottom: 13px;
    padding: 6px 11px;
    border-radius: 999px;
    color: #7b5400;
    background: #fff3cd;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.auth-form {
    display: grid;
    gap: 18px;
}

.auth-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.auth-field {
    min-width: 0;
    display: grid;
    gap: 7px;
}

.auth-field > span {
    color: var(--auth-dark-blue);
    font-size: 14px;
    font-weight: 800;
}

.auth-field small {
    color: var(--auth-muted);
    font-size: 12px;
    line-height: 1.45;
}

.auth-field input,
.auth-field select {
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    border: 1px solid #bac9d8;
    border-radius: 10px;
    color: var(--auth-text);
    background: #ffffff;
    font: inherit;
}

.auth-field input:focus,
.auth-field select:focus {
    border-color: var(--auth-blue);
    outline: 3px solid rgba(11, 92, 171, 0.14);
}

.auth-button {
    min-height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 20px;
    border: 0;
    border-radius: 11px;
    color: #ffffff;
    background: var(--auth-blue);
    font: inherit;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.auth-button--link {
    width: 100%;
    margin-top: 12px;
}

@media (hover: hover) and (pointer: fine) {
    .auth-button:hover {
        background: var(--auth-dark-blue);
    }
}

.auth-alert {
    margin-bottom: 20px;
    padding: 13px 15px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.5;
}

.auth-alert--error {
    border: 1px solid #f1b8bd;
    color: #8c1520;
    background: #fff0f1;
}

.auth-alert--success {
    border: 1px solid #a9d8b4;
    color: #17652a;
    background: #edf9f0;
}

.auth-card-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.auth-card-toolbar form {
    margin: 0;
}

.auth-back-link,
.auth-text-button {
    color: var(--auth-blue);
    font: inherit;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
}

.auth-text-button {
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.profile-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 24px;
}

.profile-summary > div {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--auth-border);
    border-radius: 11px;
    background: #f7fafc;
}

.profile-summary span,
.profile-summary strong {
    display: block;
    overflow-wrap: anywhere;
}

.profile-summary span {
    margin-bottom: 4px;
    color: var(--auth-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.profile-summary strong {
    color: var(--auth-dark-blue);
    font-size: 14px;
}

/* Минимальная панель администратора. */
.admin-layout {
    display: grid;
    grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.4fr);
    gap: 24px;
    align-items: start;
}

.admin-panel {
    min-width: 0;
    padding: 26px;
    border: 1px solid var(--auth-border);
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 10px 28px rgba(7, 59, 117, 0.08);
}

.admin-panel h2 {
    margin: 0 0 6px;
    color: var(--auth-dark-blue);
    font-size: 24px;
}

.admin-panel__description {
    margin: 0 0 22px;
    color: var(--auth-muted);
    line-height: 1.55;
}

.admin-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.admin-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--auth-border);
    text-align: left;
    vertical-align: middle;
    font-size: 13px;
}

.admin-table th {
    color: var(--auth-dark-blue);
    background: #f5f8fb;
    font-size: 12px;
    text-transform: uppercase;
}

.role-pill,
.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.role-pill {
    color: var(--auth-dark-blue);
    background: #e7f1fb;
}

.status-pill--active {
    color: #17652a;
    background: #e8f7ec;
}

.status-pill--disabled {
    color: #7d2930;
    background: #fdecee;
}

@media (max-width: 1024px) {
    .site-header__inner--auth {
        gap: 16px;
    }

    .site-user__details {
        display: none;
    }

    .site-user__account {
        padding: 7px 9px;
    }

    .admin-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .site-header__inner--auth {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "logo actions"
            "text text";
        gap: 8px 12px;
        text-align: center;
    }

    .site-header__inner--auth .site-logo {
        grid-area: logo;
        justify-self: start;
    }

    .site-header__inner--auth .site-header__text {
        grid-area: text;
    }

    .site-header__inner--auth .site-header__actions {
        grid-area: actions;
        justify-self: end;
    }

    .site-user__account,
    .site-user__logout {
        min-height: 46px;
    }

    .site-user__icon {
        width: 31px;
        height: 31px;
        flex-basis: 31px;
    }

    .journal-navigation .site-header__actions {
        width: 100%;
        display: flex;
        justify-content: center;
        margin-left: 0;
    }

    body.auth-page,
    body.auth-page--top {
        align-items: flex-start;
        padding: 14px;
    }

    .auth-card {
        margin-top: 10px;
        padding: 24px 18px;
        border-radius: 17px;
    }

    .auth-form-grid,
    .profile-summary {
        grid-template-columns: 1fr;
    }

    .auth-card-toolbar {
        align-items: flex-start;
    }

    .admin-panel {
        padding: 20px 16px;
    }
}


/* Расширенный личный кабинет: отдельные карточки личных данных и пароля. */
.auth-card--account {
    width: min(100%, 1040px);
}

.account-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
}

.account-settings-panel {
    min-width: 0;
    padding: 22px;
    border: 1px solid var(--auth-border);
    border-radius: 15px;
    background: #f9fbfd;
}

.account-settings-panel__heading {
    margin-bottom: 19px;
}

.account-settings-panel__heading h2 {
    margin: 0 0 6px;
    color: var(--auth-dark-blue);
    font-size: 21px;
}

.account-settings-panel__heading p {
    margin: 0;
    color: var(--auth-muted);
    font-size: 13px;
    line-height: 1.5;
}

/* Состояния пользователей и действия в административной таблице. */
.admin-table--users {
    min-width: 960px;
}

.admin-table__row--dismissed td {
    color: #788795;
    background: #fafbfc;
}

.admin-user-name {
    display: block;
    color: var(--auth-dark-blue);
    overflow-wrap: anywhere;
}

.admin-table__row--dismissed .admin-user-name {
    color: #657482;
}

.primary-admin-pill {
    display: inline-flex;
    align-items: center;
    margin-top: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    color: #6b4a00;
    background: #fff1bd;
    font-size: 10px;
    font-weight: 800;
    white-space: nowrap;
}

.admin-action-form {
    margin: 0;
}

.admin-dismiss-button {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 11px;
    border: 1px solid #d66b74;
    border-radius: 8px;
    color: #9b1f2b;
    background: #fff5f6;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.admin-action-note {
    display: inline-block;
    color: var(--auth-muted);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
}

@media (hover: hover) and (pointer: fine) {
    .admin-dismiss-button:hover {
        color: #ffffff;
        background: #b52b38;
        border-color: #b52b38;
    }
}

@media (max-width: 820px) {
    .account-settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .account-settings-panel {
        padding: 18px 14px;
        border-radius: 13px;
    }

    .account-settings-panel__heading h2 {
        font-size: 19px;
    }
}


/* ==========================================================================
 * Общий режим «Только чтение» для любой роли.
 * ========================================================================== */
.site-user__readonly {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    padding: 4px 7px;
    border-radius: 999px;
    color: #6a3b00;
    background: #fff0c9;
    font-size: 9px;
    font-weight: 800;
    white-space: nowrap;
}

.danone-readonly .readonly-form {
    opacity: 0.78;
}

.danone-readonly .readonly-form input:disabled,
.danone-readonly .readonly-form select:disabled,
.danone-readonly .readonly-form textarea:disabled {
    color: #5d6e7e;
    background: #f2f5f8;
    cursor: not-allowed;
}

.danone-readonly .readonly-control {
    display: none !important;
}

.readonly-mode-notice {
    margin: 0 0 10px;
    padding: 7px 10px;
    border: 1px solid #e7c77f;
    border-radius: 9px;
    color: #6a4300;
    background: #fff8df;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.45;
}


.admin-section-card__icon img {
    width: 22px;
    height: 22px;
    display: block;
    object-fit: contain;
}
