:root {
    color-scheme: light;
    --ink: #151515;
    --muted: #666666;
    --line: #dedede;
    --soft: #f5f5f5;
    --accent: #b4232f;
    --accent-dark: #891a23;
    --success: #147a48;
    --danger: #a51d2d;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    background: #eeeeee;
    color: var(--ink);
}

button,
input,
select {
    font: inherit;
}

.web-shell {
    width: min(1040px, calc(100% - 32px));
    min-height: 620px;
    margin: 40px auto;
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 28px;
    overflow: hidden;
}

.brand-panel {
    padding: 64px 52px;
    background: #191919;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.brand-mark {
    width: 84px;
    height: 54px;
    display: flex;
    align-items: stretch;
    gap: 6px;
    margin-bottom: 34px;
}

.brand-mark span {
    display: block;
    background: #ffffff;
}

.brand-mark span:nth-child(1),
.brand-mark span:nth-child(5) {
    width: 7px;
}

.brand-mark span:nth-child(2) {
    width: 13px;
}

.brand-mark span:nth-child(3) {
    width: 5px;
}

.brand-mark span:nth-child(4) {
    width: 18px;
}

.brand-kicker,
.eyebrow {
    margin: 0 0 12px;
    font-size: 12px;
    letter-spacing: 0.16em;
    font-weight: 700;
}

.brand-kicker {
    color: #d7a0a5;
}

.brand-panel h1 {
    margin: 0;
    font-size: clamp(38px, 5vw, 58px);
    line-height: 1;
    font-weight: 700;
}

.brand-copy {
    max-width: 360px;
    margin: 28px 0 0;
    color: #c9c9c9;
    line-height: 1.65;
}

.auth-panel {
    padding: 64px 58px;
    display: flex;
    align-items: center;
}

.auth-panel > div {
    width: 100%;
}

.auth-panel h2 {
    margin: 0 0 14px;
    font-size: clamp(28px, 4vw, 38px);
    line-height: 1.15;
}

.eyebrow {
    color: var(--accent);
}

.section-copy,
.state-card p,
.state-card small {
    color: var(--muted);
    line-height: 1.55;
}

form {
    display: grid;
    gap: 12px;
    margin-top: 28px;
}

label {
    margin-top: 4px;
    font-size: 14px;
    font-weight: 650;
}

input {
    width: 100%;
    min-height: 52px;
    padding: 0 16px;
    border: 1px solid #c9c9c9;
    border-radius: 14px;
    background: #ffffff;
    color: var(--ink);
    outline: none;
}

input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(180, 35, 47, 0.12);
}

button {
    min-height: 52px;
    margin-top: 10px;
    padding: 0 20px;
    border: 0;
    border-radius: 14px;
    background: var(--accent);
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

button:hover {
    background: var(--accent-dark);
}

button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.secondary-button {
    width: 100%;
    background: var(--soft);
    color: var(--ink);
    border: 1px solid var(--line);
}

.secondary-button:hover {
    background: #e9e9e9;
}

.security-note {
    margin: 22px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.error-box,
.info-box {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 13px;
    line-height: 1.45;
}

.error-box {
    background: #fff0f1;
    border: 1px solid #f0c4c8;
    color: var(--danger);
}

.info-box {
    background: var(--soft);
    border: 1px solid var(--line);
    color: var(--muted);
}

.state-card {
    text-align: left;
}

.status-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 24px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--soft);
    font-size: 28px;
}

.status-icon.success {
    background: #e9f7f0;
    color: var(--success);
}

.loader {
    width: 42px;
    height: 42px;
    margin-bottom: 24px;
    display: block;
    border: 4px solid #dddddd;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.role-line {
    font-weight: 650;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 760px) {
    .web-shell {
        width: min(100% - 20px, 560px);
        min-height: 0;
        margin: 10px auto;
        grid-template-columns: 1fr;
        border-radius: 22px;
    }

    .brand-panel {
        padding: 34px 28px;
    }

    .brand-mark {
        width: 58px;
        height: 38px;
        margin-bottom: 20px;
        gap: 4px;
    }

    .brand-panel h1 {
        font-size: 38px;
    }

    .brand-copy {
        margin-top: 18px;
    }

    .auth-panel {
        padding: 38px 28px 44px;
    }
}

/* =========================================================
   VISUAL FIX 1 — ЛОГОТИП MAX-КОНЦЕПЦИИ И ПОКАЗ ПАРОЛЯ
   ========================================================= */

:root {
    --accent: #e3212d;
    --accent-dark: #b51620;
    --accent-soft: #fff0f1;
}

.brand-panel {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 17%, rgba(227, 33, 45, 0.28), transparent 28%),
        linear-gradient(145deg, #191919 0%, #171717 62%, #310d12 100%);
}

.brand-panel::after {
    content: "";
    position: absolute;
    z-index: -1;
    right: -90px;
    bottom: -120px;
    width: 330px;
    height: 330px;
    border: 1px solid rgba(227, 33, 45, 0.33);
    border-radius: 50%;
    box-shadow:
        0 0 0 42px rgba(227, 33, 45, 0.055),
        0 0 0 84px rgba(227, 33, 45, 0.035);
}

.brand-mark {
    width: 86px;
    height: 86px;
    align-items: stretch;
    justify-content: center;
    gap: 5px;
    padding: 22px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow:
        0 0 0 8px rgba(227, 33, 45, 0.14),
        0 18px 38px rgba(0, 0, 0, 0.22);
}

.brand-mark span,
.brand-mark span:nth-child(1),
.brand-mark span:nth-child(2),
.brand-mark span:nth-child(3),
.brand-mark span:nth-child(4),
.brand-mark span:nth-child(5) {
    width: auto;
    flex: 1;
    background: #ffffff;
}

.brand-mark span:nth-child(2),
.brand-mark span:nth-child(4) {
    flex: 0.45;
}

.brand-kicker {
    color: #ffb4ba;
}

.auth-panel {
    border-top: 4px solid var(--accent);
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 58px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    width: 42px;
    min-height: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 0;
    transform: translateY(-50%);
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: #6d7076;
    box-shadow: none;
}

.password-toggle:hover,
.password-toggle:focus-visible {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.password-toggle svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (max-width: 760px) {
    .brand-mark {
        width: 62px;
        height: 62px;
        padding: 16px;
        gap: 4px;
    }

    .auth-panel {
        border-top-width: 3px;
    }
}

/* WEB AUTH RECOVERY V1 */
.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 4px;
}

.label-row label {
    margin: 0;
}

.text-button,
.back-button {
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--accent);
    font-size: 13px;
    font-weight: 750;
}

.text-button:hover,
.back-button:hover {
    background: transparent;
    color: var(--accent-dark);
    text-decoration: underline;
}

.back-button {
    margin-bottom: 28px;
    color: var(--muted);
}

.auth-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 22px;
    color: var(--muted);
    font-size: 13px;
}

.code-input {
    text-align: center;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.35em;
    font-variant-numeric: tabular-nums;
}

.password-field .password-toggle {
    width: auto;
    min-width: 82px;
    padding: 0 14px;
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 760px) {
    .label-row {
        align-items: baseline;
    }

    .auth-links {
        flex-wrap: wrap;
    }
}

/* WEB REGISTRATION V1 */
button,
input,
select,
textarea {
    font: inherit;
}

textarea {
    width: 100%;
    min-height: 94px;
    padding: 14px 16px;
    resize: vertical;
    border: 1px solid #c9c9c9;
    border-radius: 14px;
    background: #ffffff;
    color: var(--ink);
    outline: none;
}

textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(227, 33, 45, 0.12);
}

.registration-form input,
.registration-form select,
.registration-form textarea {
    min-width: 0;
    max-width: 100%;
}

.registration-form select {
    width: 100%;
    min-height: 52px;
    padding: 0 46px 0 16px;
    border: 1px solid #c9c9c9;
    border-radius: 14px;
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath d='m6 8 4 4 4-4' fill='none' stroke='%234f5258' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    color: var(--ink);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.registration-form select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(227, 33, 45, 0.12);
}

.registration-form select:invalid {
    color: #8a8a8a;
}

.registration-form select option {
    color: var(--ink);
}

#reg-birth-date {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    min-height: 52px;
    text-align: left;
}

#reg-birth-date::-webkit-date-and-time-value {
    min-height: 1.2em;
    text-align: left;
}

#reg-birth-date::-webkit-datetime-edit {
    display: block;
    padding: 0;
}

.registration-form {
    gap: 14px;
}

.registration-consents {
    display: grid;
    gap: 10px;
    margin: 2px 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.registration-consents legend {
    padding: 0 4px;
    font-size: 14px;
    font-weight: 700;
}

.registration-consents label {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    color: var(--ink);
    font-size: 13px;
    line-height: 1.45;
}

.registration-consents input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); }
.registration-consents a { color: #9b1721; font-weight: 700; }

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

.form-grid label,
.registration-form > label {
    min-width: 0;
    display: grid;
    gap: 8px;
}

.optional {
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.type-picker {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 4px;
    padding: 0;
    border: 0;
}

.type-picker legend {
    grid-column: 1 / -1;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 700;
}

.type-picker label {
    position: relative;
    min-width: 0;
    margin: 0;
    cursor: pointer;
}

.type-picker input {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    opacity: 0;
    pointer-events: none;
}

.type-picker span {
    min-height: 96px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #ffffff;
    transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.type-picker strong {
    font-size: 14px;
}

.type-picker small {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
    font-weight: 500;
}

.type-picker input:checked + span {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 2px rgba(227, 33, 45, 0.08);
}

.type-picker input:focus-visible + span {
    outline: 3px solid rgba(227, 33, 45, 0.18);
    outline-offset: 2px;
}

.client-picker {
    display: grid;
    gap: 8px;
    padding: 16px;
    border: 1px solid #ead1d4;
    border-radius: 16px;
    background: #fff8f8;
}

.client-results {
    max-height: 260px;
    overflow-y: auto;
    display: grid;
    gap: 6px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #ffffff;
}

.client-result {
    width: 100%;
    min-height: 0;
    display: grid;
    gap: 4px;
    margin: 0;
    padding: 12px 13px;
    text-align: left;
    border: 1px solid transparent;
    border-radius: 11px;
    background: #ffffff;
    color: var(--ink);
}

.client-result:hover,
.client-result:focus-visible {
    border-color: #efb8bd;
    background: var(--accent-soft);
}

.client-result strong,
.client-selected strong {
    font-size: 13px;
    line-height: 1.35;
}

.client-result span,
.client-selected span {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
}

.client-result-empty {
    padding: 14px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.client-result-empty.error {
    color: var(--danger);
}

.client-selected {
    position: relative;
    display: grid;
    gap: 4px;
    padding: 14px 92px 14px 14px;
    border: 1px solid #a9d7bf;
    border-radius: 14px;
    background: #f0faf5;
}

.client-clear {
    position: absolute;
    top: 50%;
    right: 10px;
    width: auto;
    min-height: 34px;
    margin: 0;
    padding: 0 10px;
    transform: translateY(-50%);
    border: 1px solid #bad9c8;
    border-radius: 9px;
    background: #ffffff;
    color: var(--success);
    font-size: 11px;
}

.client-clear:hover {
    background: #e6f5ed;
}

@media (min-width: 761px) {
    .web-shell:has(#registration-form-state:not([hidden])) {
        width: min(1240px, calc(100% - 32px));
        grid-template-columns: minmax(300px, 0.72fr) minmax(600px, 1.28fr);
    }

    .web-shell:has(#registration-form-state:not([hidden])) .auth-panel {
        align-items: flex-start;
        padding-top: 46px;
        padding-bottom: 46px;
    }
}

@media (max-width: 920px) {
    .type-picker {
        grid-template-columns: 1fr;
    }

    .type-picker span {
        min-height: 72px;
    }
}

@media (max-width: 560px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .client-selected {
        padding-right: 14px;
    }

    .client-clear {
        position: static;
        width: max-content;
        margin-top: 6px;
        transform: none;
    }
}


/* PROFILE REGISTRATION VISUAL FIX V1.1 — deterministic iPhone layout */
.registration-form .profile-fields {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: end;
}
.registration-form .profile-fields > label {
    min-width: 0;
    overflow: hidden;
}
#reg-birth-date,
#reg-gender {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 52px;
    min-height: 52px;
    margin: 0;
    font-size: 16px;
    line-height: normal;
}
#reg-birth-date {
    padding: 0 14px;
    -webkit-min-logical-width: 0;
    overflow: hidden;
}
#reg-birth-date::-webkit-datetime-edit,
#reg-birth-date::-webkit-date-and-time-value {
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
    text-align: left;
}
#reg-birth-date::-webkit-calendar-picker-indicator {
    margin: 0 0 0 auto;
}
#reg-gender {
    padding-top: 0;
    padding-bottom: 0;
}
#reg-client-block[hidden],
#reg-client-results[hidden],
#reg-client-selected[hidden] {
    display: none !important;
}
.registration-active #reg-client-block {
    width: 100%;
    min-width: 0;
}
.registration-active .client-picker > input[type="search"] {
    display: block;
    width: 100%;
    min-width: 0;
    height: 52px;
    margin: 0;
}
@media (max-width: 760px) {
    .registration-active .auth-panel {
        padding-left: 20px;
        padding-right: 20px;
    }
    .registration-form .profile-fields {
        grid-template-columns: 1fr !important;
        gap: 14px;
    }
    .registration-form .profile-fields > label {
        width: 100%;
        overflow: visible;
    }
    #reg-birth-date,
    #reg-gender {
        width: 100% !important;
        max-width: 100% !important;
    }
}


/* PROFILE REGISTRATION DATE MICROFIX V1.2 — iPhone width and vertical alignment */
.registration-form .registration-date-field {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.registration-date-control {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 52px;
    min-height: 52px;
    overflow: hidden;
    border: 1px solid #c9c9c9;
    border-radius: 14px;
    background: #ffffff;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.registration-date-control:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(227, 33, 45, 0.12);
}

.registration-date-control #reg-birth-date {
    box-sizing: border-box !important;
    display: block;
    inline-size: 100% !important;
    width: 100% !important;
    min-inline-size: 0 !important;
    min-width: 0 !important;
    max-inline-size: 100% !important;
    max-width: 100% !important;
    height: 50px !important;
    min-height: 50px !important;
    margin: 0 !important;
    padding: 0 14px !important;
    overflow: hidden;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent;
    box-shadow: none !important;
    color: var(--ink);
    font-size: 16px;
    line-height: normal;
}

.registration-date-control #reg-birth-date:focus {
    border: 0 !important;
    outline: 0;
    box-shadow: none !important;
}

.registration-date-control #reg-birth-date::-webkit-datetime-edit,
.registration-date-control #reg-birth-date::-webkit-date-and-time-value,
.registration-date-control #reg-birth-date::-webkit-datetime-edit-fields-wrapper {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    width: 100%;
    height: 50px;
    min-height: 50px;
    margin: 0;
    padding: 0;
    line-height: normal;
    text-align: left;
}

.registration-date-control #reg-birth-date::-webkit-calendar-picker-indicator {
    align-self: center;
    flex: 0 0 auto;
    margin: 0;
    padding: 8px 0 8px 8px;
}

@supports (-webkit-touch-callout: none) {
    .registration-date-control #reg-birth-date {
        inline-size: -webkit-fill-available !important;
        width: -webkit-fill-available !important;
    }
}
