*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --text: #0f172a;
    --text-subtle: #334155;
    --muted: #64748b;
    --border: #e2e8f0;
    --border-strong: #94a3b8;
    --paper: #ffffff;
    --paper-2: #f1f5f9;
    --paper-muted: #f8fafc;
    --accent: #1e40af;
    --accent-hover: #1d4ed8;
    --accent-soft: rgba(30, 64, 175, 0.09);
    --accent-ring: rgba(30, 64, 175, 0.28);
    --focus: var(--accent);
    --err: #b91c1c;
    --err-bg: #fef2f2;
    --err-border: #fecaca;
    --err-soft: rgba(185, 28, 28, 0.12);
    --ok: #15803d;
    --ok-bg: #f0fdf4;
    --ok-border: #bbf7d0;
    --ok-soft: rgba(21, 128, 61, 0.12);
    --warn: #b45309;
    --warn-bg: #fffbeb;
    --warn-border: #fde68a;
    --warn-soft: rgba(180, 83, 9, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --shadow-sheet: 0 25px 50px -12px rgba(15, 23, 42, 0.15), 0 0 0 1px rgba(15, 23, 42, 0.04);
    --shadow-popup: 0 25px 50px -12px rgba(15, 23, 42, 0.28);
    --font-serif: "Source Serif 4", Georgia, "Times New Roman", Times, serif;
    --font-ui: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (prefers-reduced-motion: reduce) {
    .sheet--enter {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .reg-popup,
    .reg-popup__backdrop,
    .reg-popup__panel {
        animation: none !important;
    }

    .reg-popup--leaving {
        animation: none !important;
        opacity: 0;
    }
}

.page-registration {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-serif);
    font-size: 1.0625rem;
    line-height: 1.65;
    color: var(--text);
    background: linear-gradient(155deg, #e8edf5 0%, #dce6f2 42%, #cfd8e8 100%);
    -webkit-font-smoothing: antialiased;
}

body.reg-popup-active {
    overflow: hidden;
}

.sheet {
    max-width: 52rem;
    margin: 1.75rem auto 3.5rem;
    padding: 2.25rem 2.5rem 2.75rem;
    background: var(--paper);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sheet);
}

.sheet--enter {
    animation: sheetEnter 0.75s var(--ease-out-expo) both;
}

@keyframes sheetEnter {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sheet__head {
    text-align: center;
    margin: -0.25rem -0.5rem 2rem;
    padding: 1.5rem 1.25rem 1.35rem;
    background: linear-gradient(180deg, var(--accent-soft) 0%, transparent 100%);
    border-radius: var(--radius-sm);
    border-bottom: 2px solid var(--accent);
}

.sheet__to {
    margin: 0 0 0.35rem;
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
}

.sheet__to strong {
    font-weight: 700;
}

.sheet__title {
    margin: 0;
    font-size: clamp(1.35rem, 3.5vw, 1.7rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text);
}

.appeal-form {
    text-align: justify;
}

.block {
    display: grid;
    grid-template-columns: 2.5rem 1fr;
    gap: 0.65rem 1.15rem;
    margin-bottom: 1.75rem;
    padding: 1.25rem 1.15rem 1.35rem;
    background: var(--paper-muted);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.85) inset;
}

.block__label {
    margin: 0;
    padding-top: 0.15rem;
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1.2;
}

.block__body {
    min-width: 0;
}

.row--top {
    margin: 0 0 1rem;
    line-height: 2.05;
}

.para {
    margin: 0 0 1.05rem;
    text-indent: 0;
}

.para:last-child {
    margin-bottom: 0;
}

.para strong {
    color: var(--accent);
    font-weight: 700;
}

.para--docs {
    margin-bottom: 0.65rem;
    font-weight: 600;
    font-family: var(--font-ui);
    font-size: 0.98rem;
    color: var(--text);
}

.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;
}

.field {
    display: inline-block;
    vertical-align: baseline;
    font-family: var(--font-ui);
    font-size: 0.95rem;
    line-height: 1.4;
    color: var(--text);
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.55rem;
    margin: 0 0.12rem;
    max-width: 100%;
    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        background-color 0.18s ease;
}

.field:hover {
    border-color: var(--border-strong);
}

.field:focus {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.field:focus-visible {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.field::placeholder {
    color: var(--muted);
    font-style: italic;
}

select.field {
    cursor: pointer;
    appearance: auto;
    padding: 0.42rem 0.55rem;
    min-width: 7.5rem;
    font-family: var(--font-ui);
    font-size: 0.95rem;
}

select.field.field--select-relation {
    min-width: 11.75rem;
    max-width: 100%;
}

select.field.field--err {
    color: var(--text);
}

.field--err {
    border-color: var(--err);
    background: var(--err-bg);
}

.field--err:focus,
.field--err:focus-visible {
    box-shadow: 0 0 0 3px var(--err-soft);
}

.field--xs {
    width: 3.35rem;
    text-align: center;
}

.field--sm {
    width: 6rem;
}

.field--md {
    width: 9.25rem;
}

.field--lg {
    width: 14rem;
}

.field--date {
    width: 10.75rem;
    font-family: var(--font-ui);
    font-size: 0.95rem;
}

.field--wide {
    width: min(100%, 23rem);
}

.dotted-fields {
    list-style: none;
    margin: 0 0 1.35rem;
    padding: 1rem 1.1rem;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-size: 0.95rem;
    box-shadow: var(--shadow);
}

.dotted-fields li {
    display: flex;
    align-items: flex-end;
    gap: 0.65rem;
    margin-bottom: 0.75rem;
}

.dotted-fields li:last-child {
    margin-bottom: 0;
}

.dotted-fields label {
    flex: 0 0 auto;
    min-width: 7.75rem;
    color: var(--text);
    font-weight: 500;
}

.dotted {
    flex: 1;
    min-width: 0;
    font-family: var(--font-ui);
    font-size: inherit;
    border: none;
    border-bottom: 2px dotted var(--border-strong);
    border-radius: 0;
    padding: 0.3rem 0;
    background: transparent;
    color: var(--text);
    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease;
}

.dotted:hover {
    border-bottom-color: var(--accent);
}

.dotted:focus {
    outline: none;
    border-bottom-style: solid;
    border-bottom-color: var(--accent);
    box-shadow: 0 1px 0 0 var(--accent);
}

.dotted:focus-visible {
    outline: none;
    border-bottom-style: solid;
    border-bottom-color: var(--accent);
}

.address {
    margin: 1.5rem 0 0;
    padding: 1rem 1.15rem;
    background: linear-gradient(135deg, var(--paper-muted) 0%, #eef2f7 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--accent);
    font-size: 0.9rem;
    font-family: var(--font-ui);
    line-height: 1.55;
    text-align: left;
    color: var(--text-subtle);
    letter-spacing: 0.015em;
}

.address strong {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    justify-content: center;
    align-items: center;
    margin-top: 2.25rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

.btn {
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 600;
    padding: 0.72rem 1.65rem;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(30, 64, 175, 0.28);
    transition:
        background 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.12s ease;
}

.btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 20px rgba(29, 78, 216, 0.32);
}

.btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.22);
}

.btn:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 2px #fff,
        0 0 0 5px var(--accent-ring);
}

a.btn {
    text-decoration: none;
    display: inline-block;
}

.btn--ghost {
    color: var(--accent);
    background: var(--paper);
    border: 2px solid var(--accent);
    box-shadow: none;
}

.btn--ghost:hover {
    background: var(--accent-soft);
    box-shadow: none;
}

.btn--ghost:focus-visible {
    box-shadow:
        0 0 0 2px #fff,
        0 0 0 5px var(--accent-ring);
}

/* —— Popup overlay —— */
.reg-popup {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    animation: regPopupRootIn 0.4s var(--ease-out-expo) both;
}

.reg-popup--leaving {
    animation: regPopupRootOut 0.3s ease forwards;
    pointer-events: none;
}

@keyframes regPopupRootIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes regPopupRootOut {
    to {
        opacity: 0;
    }
}

.reg-popup__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    cursor: pointer;
    animation: regPopupBackdropIn 0.45s ease both;
}

.reg-popup--leaving .reg-popup__backdrop {
    animation: regPopupFadeOut 0.28s ease forwards;
}

@keyframes regPopupBackdropIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes regPopupFadeOut {
    to {
        opacity: 0;
    }
}

.reg-popup__panel {
    position: relative;
    z-index: 1;
    width: min(100%, 26rem);
    padding: 1.85rem 1.75rem 1.65rem;
    background: var(--paper);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-popup);
    text-align: center;
    font-family: var(--font-ui);
    animation: regPopupPanelIn 0.55s var(--ease-spring) 0.06s both;
}

.reg-popup--leaving .reg-popup__panel {
    animation: regPopupPanelOut 0.32s var(--ease-out-expo) forwards;
}

@keyframes regPopupPanelIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(24px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes regPopupPanelOut {
    to {
        opacity: 0;
        transform: scale(0.94) translateY(12px);
    }
}

.reg-popup__glyph {
    width: 3.35rem;
    height: 3.35rem;
    margin: 0 auto 1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1;
    font-family: var(--font-ui);
}

.reg-popup__glyph--ok {
    background: var(--ok-bg);
    color: var(--ok);
    border: 1px solid var(--ok-border);
}

.reg-popup__glyph--ok::before {
    content: "✓";
}

.reg-popup__glyph--warn {
    background: var(--warn-bg);
    color: var(--warn);
    border: 1px solid var(--warn-border);
}

.reg-popup__glyph--warn::before {
    content: "!";
    font-weight: 800;
}

.reg-popup__glyph--err {
    background: var(--err-bg);
    color: var(--err);
    border: 1px solid var(--err-border);
}

.reg-popup__glyph--err::before {
    content: "✕";
    font-size: 1.2rem;
}

.reg-popup__title {
    margin: 0 0 0.65rem;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    line-height: 1.25;
}

.reg-popup__body {
    margin-bottom: 1.35rem;
    text-align: left;
    color: var(--text-subtle);
    font-size: 0.95rem;
    line-height: 1.55;
}

.reg-popup__p {
    margin: 0;
}

.reg-popup__link {
    color: var(--accent-hover);
    font-weight: 600;
    text-underline-offset: 2px;
    word-break: break-word;
}

.reg-popup__btn {
    width: 100%;
    max-width: 14rem;
    margin: 0 auto;
    display: block;
}

@media (max-width: 640px) {
    .sheet {
        margin: 0;
        padding: 1.35rem 1.1rem 2rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
    }

    .sheet__head {
        margin-left: 0;
        margin-right: 0;
    }

    .block {
        grid-template-columns: 2rem 1fr;
        padding: 1rem 0.9rem;
    }

    .field--lg,
    .field--md,
    .field--wide,
    select.field {
        width: 100%;
        margin: 0.28rem 0;
        display: block;
    }

    .row--top {
        line-height: 1.65;
    }

    .appeal-form {
        text-align: left;
    }

    .reg-popup__panel {
        padding: 1.5rem 1.25rem 1.35rem;
    }
}

@media print {
    .page-registration {
        background: #fff;
    }

    .sheet {
        box-shadow: none;
        border: none;
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .sheet--enter {
        animation: none;
    }

    .actions {
        display: none;
    }

    .block {
        break-inside: avoid;
        box-shadow: none;
    }

    .reg-popup {
        display: none !important;
    }
}
