:root {
    color-scheme: light;
    --energy-navy: #0b2342;
    --energy-navy-light: #163b64;
    --energy-green: #1fc96f;
    --energy-green-dark: #087443;
    --energy-green-soft: #e4f8ec;
    --energy-canvas: #f3f6fa;
    --energy-surface: #ffffff;
    --energy-surface-soft: #eef2f6;
    --energy-border: #dce3ec;
    --energy-border-strong: #becbda;
    --energy-text: #172941;
    --energy-text-muted: #5e6e83;
    --energy-text-subtle: #8190a3;
    --energy-shadow-xs: 0 0.25rem 1rem rgb(9 34 63 / 5%);
    --energy-shadow-sm: 0 0.75rem 2.5rem rgb(9 34 63 / 9%);
    font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-synthesis: none;
}

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

html {
    min-width: 20rem;
    min-height: 100%;
    background: var(--energy-canvas);
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    background: var(--energy-canvas);
    color: var(--energy-text);
    font-family: inherit;
    line-height: 1.45;
    text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    cursor: pointer;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.55rem;
    padding: 0.5rem 0.8rem;
    border: 1px solid transparent;
    border-radius: 0.65rem;
    font-size: 0.78rem;
    font-weight: 750;
    text-decoration: none;
}

.button--primary {
    background: var(--energy-navy);
    color: #fff;
}

.button--primary:hover:not(:disabled) {
    background: var(--energy-navy-light);
}

.button--quiet {
    border-color: var(--energy-border);
    background: #fff;
    color: var(--energy-text);
}

.button--quiet:hover:not(:disabled) {
    border-color: var(--energy-border-strong);
    background: var(--energy-surface-soft);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.icon-button {
    display: grid;
    place-items: center;
    width: 2.3rem;
    height: 2.3rem;
    border: 0;
    border-radius: 0.6rem;
    background: transparent;
    color: var(--energy-text-muted);
    font-size: 1.35rem;
    line-height: 1;
}

.icon-button:hover {
    background: var(--energy-surface-soft);
    color: var(--energy-navy);
}

.loading-ring {
    width: 1.25rem;
    height: 1.25rem;
    border: 0.18rem solid var(--energy-border);
    border-top-color: var(--energy-green);
    border-radius: 50%;
    animation: shell-spin 800ms linear infinite;
}

a {
    color: var(--energy-green-dark);
}

:focus-visible {
    outline: 0.2rem solid #236fd1;
    outline-offset: 0.18rem;
}

h1:focus {
    outline: none;
}

.skip-link {
    position: fixed;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 200;
    padding: 0.7rem 1rem;
    border-radius: 0.65rem;
    background: #fff;
    color: var(--energy-navy);
    font-weight: 750;
    transform: translateY(-140%);
}

.skip-link:focus {
    transform: translateY(0);
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.valid.modified:not([type="checkbox"]) {
    outline: 1px solid var(--energy-green);
}

.invalid {
    outline: 1px solid #c83f35;
}

.validation-message {
    color: #a9362f;
    font-size: 0.75rem;
}

/*
 * Operational forms use Blazor input components as well as native controls.
 * These rules intentionally live outside CSS isolation so both render paths
 * share the same visual language throughout the authenticated workspace.
 */
.workspace-content :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]), select, textarea) {
    width: 100%;
    min-width: 0;
    min-height: 2.75rem;
    padding: 0.62rem 0.75rem;
    border: 1px solid var(--energy-border-strong);
    border-radius: 0.68rem;
    background: #fff;
    color: var(--energy-text);
    line-height: 1.25;
    transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.workspace-content :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]), select) {
    height: 2.75rem;
}

.workspace-content textarea {
    min-height: 6rem;
    resize: vertical;
}

.workspace-content :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea):hover:not(:disabled) {
    border-color: #91a6bd;
}

.workspace-content :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea):focus {
    border-color: var(--energy-green-dark);
    box-shadow: 0 0 0 0.2rem rgb(31 201 111 / 14%);
    outline: none;
}

.workspace-content :where(input, select, textarea):disabled,
.workspace-content :where(input, textarea)[readonly] {
    background: var(--energy-surface-soft);
    color: var(--energy-text-muted);
    cursor: not-allowed;
    opacity: 1;
}

.workspace-content :where(input[type="checkbox"], input[type="radio"]) {
    width: 1.05rem;
    height: 1.05rem;
    flex: 0 0 auto;
    margin: 0;
    accent-color: var(--energy-green-dark);
}

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

.form-field {
    display: grid;
    align-content: start;
    gap: 0.35rem;
    min-width: 0;
}

.form-field--wide {
    grid-column: 1 / -1;
}

.form-field > label,
.management-form-grid > label,
.inline-field {
    color: var(--energy-text-muted);
    font-size: 0.76rem;
    font-weight: 750;
}

.form-field > small {
    color: var(--energy-text-subtle);
    font-size: 0.72rem;
    line-height: 1.4;
}

.new-customer__form {
    display: grid;
    gap: 0.9rem;
}

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

    .form-field--wide {
        grid-column: auto;
    }
}

#blazor-error-ui {
    position: fixed;
    inset: auto 1rem 1rem 1rem;
    z-index: 1000;
    display: none;
    max-width: 44rem;
    margin-inline: auto;
    padding: 0.8rem 3rem 0.8rem 1rem;
    border: 1px solid #e5ada8;
    border-radius: 0.8rem;
    background: #fff1ef;
    box-shadow: var(--energy-shadow-sm);
    color: #8d302a;
}

#blazor-error-ui .reload {
    margin-left: 0.5rem;
    color: inherit;
    font-weight: 750;
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 0.55rem;
    right: 0.75rem;
    cursor: pointer;
    font-size: 1.2rem;
}

.blazor-error-boundary {
    padding: 1rem;
    border-radius: 0.8rem;
    background: #a9362f;
    color: #fff;
}

.blazor-error-boundary::after {
    content: "Не удалось отобразить раздел.";
}

.loading-screen {
    position: fixed;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 1rem;
    background:
        radial-gradient(circle at center, rgb(31 201 111 / 12%), transparent 24rem),
        #081a31;
    color: #fff;
}

.loading-screen__mark {
    display: grid;
    place-items: center;
    width: 4.25rem;
    height: 4.25rem;
    border-radius: 1.25rem;
    background: rgb(31 201 111 / 12%);
    color: #2be786;
}

.loading-screen__mark svg {
    width: 2.5rem;
    fill: currentColor;
}

.loading-screen strong {
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.loading-screen span:last-child {
    color: #a9b9cd;
    font-size: 0.8rem;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

.auth-layout {
    display: grid;
    min-height: 100dvh;
    grid-template-columns: minmax(18rem, 38%) minmax(0, 1fr);
    background: var(--energy-canvas);
}

.auth-layout__brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-height: 100%;
    padding: clamp(2rem, 7vw, 7rem);
    background:
        radial-gradient(circle at 12% 12%, rgb(53 223 137 / 28%), transparent 22rem),
        radial-gradient(circle at 85% 82%, rgb(63 126 212 / 22%), transparent 18rem),
        linear-gradient(145deg, #102b4c 0%, #08192f 100%);
    color: #fff;
}

.auth-layout__brand-mark {
    display: grid;
    place-items: center;
    width: 4rem;
    height: 4rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgb(255 255 255 / 18%);
    border-radius: 1.2rem;
    background: rgb(31 201 111 / 14%);
    color: #43e28d;
}

.auth-layout__brand-mark svg {
    width: 2.2rem;
    fill: currentColor;
}

.auth-layout__brand strong {
    display: block;
    font-size: clamp(2rem, 4vw, 3rem);
    letter-spacing: -0.06em;
}

.auth-layout__brand > div:nth-child(2) span {
    color: #b7c7d9;
    font-size: 0.9rem;
}

.auth-layout__brand > p {
    max-width: 24rem;
    margin: 2.2rem 0 1.25rem;
    color: #d5e0ec;
    font-size: 1.05rem;
}

.auth-layout__feature {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-top: 0.6rem;
    color: #b9c9dc;
    font-size: 0.85rem;
}

.auth-layout__feature span {
    display: grid;
    place-items: center;
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 50%;
    background: rgb(37 220 126 / 17%);
    color: #5be8a1;
    font-size: 0.7rem;
    font-weight: 850;
}

.auth-layout__main {
    display: grid;
    place-items: center;
    min-width: 0;
    padding: clamp(1.25rem, 5vw, 5rem);
}

.auth-card,
.auth-message-card {
    width: min(100%, 28rem);
    padding: clamp(1.5rem, 4vw, 2.5rem);
    border: 1px solid rgb(211 221 233 / 88%);
    border-radius: 1.45rem;
    background: var(--energy-surface);
    box-shadow: 0 1.25rem 4rem rgb(9 34 63 / 10%);
}

.auth-card__heading h1,
.auth-message-card h1 {
    margin: 0.2rem 0 0.6rem;
    color: var(--energy-navy);
    font-size: clamp(1.65rem, 4vw, 2.25rem);
    line-height: 1.12;
    letter-spacing: -0.04em;
}

.auth-card__heading > p:last-child,
.auth-message-card p:last-child {
    margin: 0;
    color: var(--energy-text-muted);
}

.auth-kicker {
    margin: 0;
    color: var(--energy-green-dark);
    font-size: 0.72rem;
    font-weight: 850;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.auth-form {
    display: grid;
    gap: 1rem;
    margin-top: 1.8rem;
}

.auth-field {
    display: grid;
    gap: 0.42rem;
}

.auth-field label,
.setup-secret > label {
    color: var(--energy-text);
    font-size: 0.84rem;
    font-weight: 750;
}

.auth-field input,
.setup-secret input {
    width: 100%;
    min-height: 3.15rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--energy-border-strong);
    border-radius: 0.78rem;
    background: #fff;
    color: var(--energy-text);
}

.auth-field input:hover,
.auth-field input:focus,
.setup-secret input:focus {
    border-color: var(--energy-green-dark);
}

.auth-code-input {
    letter-spacing: 0.15em;
    text-align: center;
    font-size: 1.25rem;
    font-variant-numeric: tabular-nums;
}

.auth-primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    min-height: 3.2rem;
    padding: 0.75rem 1.1rem;
    border: 1px solid var(--energy-green-dark);
    border-radius: 0.8rem;
    background: var(--energy-green-dark);
    color: #fff;
    font-weight: 780;
    transition: background-color 140ms ease, transform 140ms ease;
}

.auth-primary-button:hover:not(:disabled) {
    background: #065a35;
    transform: translateY(-1px);
}

.auth-primary-button:disabled,
.auth-text-button:disabled {
    cursor: wait;
    opacity: 0.62;
}

.auth-alert {
    margin-top: 1.25rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid #e9b3ad;
    border-radius: 0.75rem;
    background: #fff3f1;
    color: #8f332d;
    font-size: 0.875rem;
}

.auth-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    color: var(--energy-text-muted);
    font-size: 0.84rem;
}

.auth-checkbox input {
    width: 1.05rem;
    height: 1.05rem;
    margin: 0.1rem 0 0;
    accent-color: var(--energy-green-dark);
}

.auth-card__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.8rem;
    margin-top: 1.45rem;
    font-size: 0.84rem;
}

.auth-text-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--energy-green-dark);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 0.18rem;
}

.auth-card__footnote {
    margin: 1.75rem 0 0;
    color: var(--energy-text-subtle);
    font-size: 0.76rem;
    line-height: 1.5;
}

.auth-route-loading {
    display: grid;
    place-items: center;
    min-height: 9rem;
    color: var(--energy-text-muted);
}

.security-page {
    width: min(100%, 54rem);
    margin: 0 auto;
}

.security-page__heading {
    margin-bottom: 1.5rem;
}

.security-page__heading h1 {
    margin: 0.25rem 0 0.45rem;
    color: var(--energy-navy);
    font-size: clamp(1.7rem, 4vw, 2.35rem);
    letter-spacing: -0.04em;
}

.security-page__heading > p:last-child,
.security-card > p {
    margin: 0;
    color: var(--energy-text-muted);
}

.security-warning {
    display: flex;
    gap: 0.9rem;
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid #e6c36d;
    border-radius: 1rem;
    background: #fff9e9;
}

.security-warning > div:first-child {
    display: grid;
    place-items: center;
    width: 1.55rem;
    height: 1.55rem;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #d28a11;
    color: #fff;
    font-weight: 850;
}

.security-warning h2,
.security-card h2 {
    margin: 0;
    color: var(--energy-navy);
    font-size: 1.1rem;
}

.security-warning p {
    margin: 0.3rem 0 0;
    color: #695122;
    font-size: 0.88rem;
}

.security-card {
    margin-top: 1rem;
    padding: clamp(1.1rem, 3vw, 1.75rem);
    border: 1px solid var(--energy-border);
    border-radius: 1.15rem;
    background: var(--energy-surface);
    box-shadow: var(--energy-shadow-xs);
}

.security-card__heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.security-status {
    flex: 0 0 auto;
    padding: 0.3rem 0.55rem;
    border-radius: 99rem;
    background: var(--energy-surface-soft);
    color: var(--energy-text-muted);
    font-size: 0.72rem;
    font-weight: 750;
}

.security-status--enabled {
    background: var(--energy-green-soft);
    color: var(--energy-green-dark);
}

.security-card > .auth-primary-button {
    margin-top: 1.1rem;
}

.authenticator-setup {
    display: grid;
    gap: 1.15rem;
    margin-top: 1.25rem;
}

.setup-steps {
    display: grid;
    gap: 0.5rem;
    margin: 0;
    padding-left: 1.3rem;
    color: var(--energy-text-muted);
    font-size: 0.88rem;
}

.auth-qr-code {
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 0.55rem;
    padding: 1rem;
    border: 1px solid var(--energy-border);
    border-radius: 0.95rem;
    background: #fafcff;
    color: var(--energy-text-muted);
    text-align: center;
}

.auth-qr-code img {
    display: block;
    width: min(100%, 14.5rem);
    height: auto;
    padding: 0.45rem;
    border-radius: 0.55rem;
    background: #fff;
}

.auth-qr-code strong {
    color: var(--energy-navy);
    font-size: 0.9rem;
}

.auth-qr-code small {
    max-width: 20rem;
    font-size: 0.75rem;
}

.setup-secret {
    display: grid;
    gap: 0.4rem;
}

.setup-secret > div {
    display: flex;
    gap: 0.5rem;
}

.setup-secret output {
    display: block;
    min-width: 0;
    flex: 1 1 auto;
    overflow-wrap: anywhere;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--energy-border);
    border-radius: 0.78rem;
    background: var(--energy-surface-soft);
    color: var(--energy-navy);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.83rem;
    font-weight: 700;
}

.setup-secret > small {
    color: var(--energy-text-subtle);
    font-size: 0.74rem;
}

.auth-copy-button {
    flex: 0 0 auto;
    min-height: 2.75rem;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--energy-border-strong);
    border-radius: 0.7rem;
    background: #fff;
    color: var(--energy-green-dark);
    font-size: 0.78rem;
    font-weight: 750;
}

.setup-confirm {
    width: min(100%, 24rem);
}

.recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    margin: 1.15rem 0;
    padding: 0;
    list-style: none;
}

.recovery-codes li {
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--energy-border);
    border-radius: 0.65rem;
    background: var(--energy-surface-soft);
    color: var(--energy-navy);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    font-weight: 700;
    text-align: center;
}

@media (max-width: 760px) {
    .auth-layout {
        grid-template-columns: 1fr;
    }

    .auth-layout__brand {
        min-height: auto;
        padding: 1.5rem clamp(1.25rem, 6vw, 2.5rem);
    }

    .auth-layout__brand-mark,
    .auth-layout__brand > p,
    .auth-layout__feature {
        display: none;
    }

    .auth-layout__brand strong {
        font-size: 1.65rem;
    }

    .auth-layout__main {
        align-items: start;
        padding: 1.25rem;
    }

    .auth-card,
    .auth-message-card {
        width: 100%;
        box-shadow: none;
    }
}

@media (max-width: 420px) {
    .setup-secret > div {
        flex-wrap: wrap;
    }

    .auth-copy-button {
        width: 100%;
    }

    .recovery-codes {
        grid-template-columns: 1fr;
    }
}
