/* Без внешних шрифтов: @import Google Fonts блокировал первую отрисовку на секунды (сеть, DNS). */
:root {
    --primary: #ffffff;
    --accent: #d0d0d0; /* Polished Steel */
    --bg-dark: #050505;
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    /* Переходы экранов/модалок */
    --ease-out-soft: cubic-bezier(0.22, 1, 0.36, 1);
    --ui-page: 0.48s;
    --ui-modal-overlay: 0.34s;
    --ui-modal-panel: 0.38s;
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html,
body {
    height: 100%;
}

/* Small utilities to replace inline styles */
.u-m0 { margin: 0 !important; }
.u-mt-05 { margin-top: 0.5rem !important; }
.u-mt-075 { margin-top: 0.75rem !important; }
.u-mt-1 { margin-top: 1rem !important; }
.u-mt-15 { margin-top: 1.5rem !important; }
.u-mb-075 { margin-bottom: 0.75rem !important; }
.u-mb-1 { margin-bottom: 1rem !important; }
.u-w-100 { width: 100% !important; }
.u-w-auto { width: auto !important; }
.u-maxw-800 { max-width: 800px !important; }
.u-maxw-720 { max-width: 720px !important; }
.u-resize-vertical { resize: vertical !important; }
.u-minh-100 { min-height: 100px !important; }
.u-flex0 { flex: 0 0 auto !important; }
.u-hidden { display: none !important; }
.u-pad-compact { padding: 0.5rem 0.9rem !important; }
.u-nowrap { white-space: nowrap !important; }
.u-strong { font-weight: 700 !important; }
.u-opacity-07 { opacity: 0.7 !important; }
.u-opacity-06 { opacity: 0.6 !important; }
.u-opacity-05 { opacity: 0.5 !important; }

.tg-deeplink-iframe {
    position: fixed;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    border: 0;
}

.title-compact {
    margin: 0 !important;
    font-size: 1.1rem !important;
}

.subtitle-compact {
    margin-bottom: 1rem !important;
}

.cabinet-card-edges {
    margin-top: 20px !important;
    margin-bottom: 20px !important;
}

.modal-header.modal-header--tight {
    padding-top: 0 !important;
}

.h2-compact {
    font-size: 1.1rem !important;
}

.family-passes-section {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.admin-news-body {
    width: 100% !important;
    resize: vertical !important;
    min-height: 100px !important;
    box-sizing: border-box;
}

.pass-duration-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.pass-duration-btn {
    width: auto !important;
    margin-top: 0 !important;
    padding: 6px 10px !important;
}

.duration-feedback {
    font-size: 0.75rem;
    opacity: 0.6;
    margin-top: 8px;
}

.empty-state {
    padding: 20px;
    opacity: 0.3;
    text-align: center;
}

.loading-state {
    opacity: 0.6;
    padding: 20px;
    text-align: center;
}

.loading-state.loading-state--compact {
    padding: 12px;
    text-align: left;
}

.grid-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    opacity: 0.3;
}

.muted-state {
    opacity: 0.3;
}

.danger-text {
    color: #ff6b81 !important;
}

/* Manage items: modifiers used in JS templates */
.manage-item.manage-item--stack {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

.manage-item-info.manage-item-info--full {
    width: 100%;
}

.manage-item-subtitle.manage-item-subtitle--spaced {
    margin-top: 6px;
}

.manage-actions-row {
    display: flex;
    gap: 10px;
}

.manage-actions-row.manage-actions-row--center {
    align-items: center;
}

.row-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.minw-0 {
    min-width: 0;
}

.btn-fav.btn-fav--inline {
    padding: 4px 8px;
    margin-left: 8px;
}

/* Reusable small text blocks from JS templates */
.meta-line {
    font-size: 0.75rem;
    opacity: 0.5;
    margin-top: 4px;
}

.meta-line.meta-line--compact {
    font-size: 0.7rem;
    opacity: 0.45;
    white-space: nowrap;
}

.meta-line.meta-line--tiny {
    font-size: 0.72rem;
    opacity: 0.5;
}

.meta-line.meta-line--softer {
    opacity: 0.55;
}

.meta-line.meta-line--note {
    font-size: 0.7rem;
    opacity: 0.5;
    margin-top: 6px;
}

.muted-state.muted-state--padded {
    padding: 12px;
}

.defect-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.admin-card.admin-card--row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.admin-card.admin-card--row-compact {
    margin-bottom: 5px;
}

.btn-accent-plain {
    background: var(--accent);
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    color: black;
}

.btn-soft {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 5px 10px;
    border-radius: 8px;
    cursor: pointer;
    color: white;
}

.btn-danger-soft {
    background: rgba(255, 71, 87, 0.12);
    border: 1px solid rgba(255, 71, 87, 0.25);
    padding: 5px 10px;
    border-radius: 8px;
    cursor: pointer;
    color: #ff4757;
}

.btn-danger-mini {
    background: #e84118;
    color: white;
    border: none;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-dark);
    color: var(--primary);
    overflow: hidden;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: stretch;
}

/* Page transitions and layout */
.page {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-bottom: calc(34px + env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Только opacity: transform на предке ломает позицию каретки в input на iOS Safari */
    z-index: 0;
    transition: opacity var(--ui-page) ease-in-out;
    opacity: 0;
    pointer-events: none;
}

.page.active {
    z-index: 1;
    opacity: 1;
    pointer-events: all;
}

/* До app-booted переходы выключены — иначе boot-скрипт + init дают двойную анимацию и мигание */
html:not(.app-booted) .page {
    transition: none !important;
}

@keyframes pageBlockSoft {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

html.app-booted .page.active > .glass-card {
    animation: pageBlockSoft 0.52s ease-in-out both;
}

body.news-lightbox-open,
body.overlay-open {
    overflow: hidden;
}

/* Background: Liquid Metal & Facets */
.background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background: #000;
    overflow: hidden;
}

/* Base Macro Crystal Facets */
.background-container::before {
    content: '';
    position: absolute;
    inset: -50%;
    background:
        /* Primary bright edge — knife-sharp (0.3% band instead of 2%) */
        linear-gradient(115deg, 
            rgba(0, 0, 0, 0.0) 20%, 
            rgba(255, 255, 255, 0.04) 40%, 
            rgba(255, 255, 255, 0.55) 49.6%, 
            rgba(255, 255, 255, 1.0) 50%, 
            rgba(0, 0, 0, 0.98) 50.3%, 
            rgba(12, 8, 22, 0.9) 65%,
            transparent 100%),
        /* Lower intersecting facet */
        linear-gradient(35deg, 
            transparent 28%, 
            rgba(0, 0, 0, 0.9) 28.3%, 
            rgba(18, 18, 35, 0.6) 60%, 
            rgba(5, 5, 12, 0.95) 100%),
        /* Top dark wedge */
        linear-gradient(-22deg, 
            rgba(15, 12, 28, 0.95) 0%, 
            rgba(4, 4, 8, 0.5) 49.7%, 
            rgba(0, 0, 0, 0.98) 50%),
        /* Subtle ambient glows */
        radial-gradient(ellipse at 72% 22%, rgba(80, 70, 140, 0.35) 0%, transparent 55%),
        radial-gradient(ellipse at 28% 78%, rgba(50, 60, 100, 0.25) 0%, transparent 55%);
    background-color: #04040a;
    animation: liquidMove 60s ease-in-out infinite alternate;
}

/* Clustered Crystal Dust / Particles masked to bright edge */
.background-container::after {
    content: '';
    position: absolute;
    inset: -50%;
    background-image: 
        radial-gradient(circle, rgba(255,255,255,0.9) 0.5px, transparent 1px),
        radial-gradient(circle, rgba(200,200,255,0.7) 1px, transparent 2px),
        radial-gradient(circle, rgba(255,255,255,0.4) 1.5px, transparent 3px);
    background-size: 
        70px 70px, 
        110px 110px, 
        180px 180px;
    background-position: 
        0 0, 
        40px 50px, 
        90px 100px;
    mix-blend-mode: color-dodge;
    opacity: 0.8;
    -webkit-mask-image: linear-gradient(115deg, transparent 47%, rgba(0,0,0,0.6) 49%, #000 49.8%, #000 50.5%, rgba(0,0,0,0.6) 51.5%, transparent 56%);
    mask-image:         linear-gradient(115deg, transparent 47%, rgba(0,0,0,0.6) 49%, #000 49.8%, #000 50.5%, rgba(0,0,0,0.6) 51.5%, transparent 56%);
    animation: liquidMove 60s ease-in-out infinite alternate, facetDrift 80s linear infinite, dustShimmer 7s ease-in-out infinite alternate;
}

@keyframes liquidMove {
    0%   { transform: translate(0, 0) rotate(0deg) scale(1.0); }
    25%  { transform: translate(1.5%, 2%) rotate(1.2deg) scale(1.04); }
    50%  { transform: translate(-1%, 1.5%) rotate(-0.8deg) scale(1.06); }
    75%  { transform: translate(0.8%, -1.5%) rotate(0.5deg) scale(1.03); }
    100% { transform: translate(0, 0) rotate(0deg) scale(1.0); }
}

@keyframes facetDrift {
    from { background-position: 0 0, 40px 50px, 90px 100px; }
    to { background-position: -260px 180px, -220px 230px, -170px 280px; }
}

@keyframes dustShimmer {
    0% { opacity: 0.35; }
    100% { opacity: 0.9; }
}

@media (prefers-reduced-motion: reduce) {
    .page {
        transition: none !important;
    }

    .background-container::before,
    .background-container::after {
        animation: none !important;
    }

    .modal-overlay {
        transition: opacity 0.12s ease, visibility 0.12s ease;
    }

    .modal-content {
        transition: none !important;
    }

    html.app-booted .page.active > .glass-card {
        animation: none !important;
    }
}

.cabinet-header {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.settings-menu {
    position: relative;
    display: flex;
    justify-content: flex-end;
}

.btn-settings {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.2rem;
    color: white;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.btn-settings:hover {
    background: rgba(255,255,255,0.1);
    transform: rotate(45deg);
}

.settings-dropdown {
    position: absolute;
    top: 60px;
    right: 0;
    background: rgba(8, 8, 14, 0.75);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 4px;
    width: 200px;
    display: none;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.7), inset 0 0 0 1px rgba(255,255,255,0.1);
    z-index: 1001;
}

.settings-dropdown.active {
    display: flex;
    animation: fadeInDown 0.3s ease;
}

.settings-dropdown button {
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: white;
    padding: 12px 20px;
    text-align: left;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.settings-dropdown button:last-child {
    border-bottom: none;
}

.settings-dropdown-item {
    opacity: 0.85;
    font-size: 0.85rem !important;
}

.settings-dropdown button:hover {
    background: rgba(255,255,255,0.05);
}

/* Glass Card: Heavy Refractive Glass */
.glass-card {
    background: rgba(10, 10, 10, 0.45);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 4px; /* Precision edges */
    padding: 3rem;
    width: 100%;
    max-width: 440px;
    margin: 1.5rem auto;
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 50px 100px -20px rgba(0, 0, 0, 0.9),
        inset 0 0 0 1px rgba(255, 255, 255, 0.2); /* Internal bevel */
    transition: transform 0.3s ease;
}

.glass-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        transparent 0%,
        rgba(255, 255, 255, 0.05) 45%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 55%,
        transparent 100%
    );
    transform: translateX(-100%);
    animation: glassGlint 8s infinite;
    pointer-events: none;
}

@keyframes glassGlint {
    0% { transform: translateX(-100%) skewX(-15deg); }
    30%, 100% { transform: translateX(200%) skewX(-15deg); }
}

h1 {
    font-size: 2.22rem;
    font-weight: 300;
    margin-bottom: 0.5rem;
    color: #fff;
    text-shadow: 0 0 25px rgba(255, 255, 255, 0.2);
    letter-spacing: 3px;
    text-transform: uppercase;
}

p.subtitle {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7); /* Increased contrast */
    margin-bottom: 2.2rem;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Input Fields & Labels */
.input-group {
    margin-bottom: 1.8rem;
    position: relative;
}

label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.6); /* Increased contrast */
    margin-bottom: 0.6rem;
    margin-left: 4px;
}

input, textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 1.1rem;
    color: #fff;
    /* ≥16px: иначе iOS Safari зумит при фокусе — «улетает» каретка и вёрстка */
    font-size: max(16px, 0.95rem);
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: start;
    direction: ltr;
}

input:focus, textarea:focus {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.05);
}

input::placeholder {
    color: rgba(255, 255, 255, 0.15);
}



.login-phone-row {
    display: flex;
    align-items: center;
    gap: 8px;
    direction: ltr;
    justify-content: flex-start;
}

.login-phone-prefix {
    flex: 0 0 auto;
    font-weight: 600;
    opacity: 0.85;
    user-select: none;
}

.login-phone-row input {
    flex: 1 1 auto;
    min-width: 0;
}

/*
 * iOS WebKit: backdrop-filter, анимированный ::before у «стекла» и transform на предках
 * (в т.ч. .modal-content) дают смещение каретки в input — см. также .page без transform.
 */
@supports (-webkit-touch-callout: none) {
    .glass-card {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(14, 14, 18, 0.94);
    }

    .glass-card::before {
        animation: none !important;
        opacity: 0;
        visibility: hidden;
    }

    input,
    textarea {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: rgba(255, 255, 255, 0.09);
        -webkit-appearance: none;
        appearance: none;
    }

    .modal-overlay,
    .role-auth-modal.modal-overlay {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    .modal-content,
    .role-auth-modal .modal-content {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: rgba(14, 14, 20, 0.96) !important;
        transform: none !important;
        transition: opacity var(--ui-modal-panel) var(--ease-out-soft) !important;
    }

    .modal-overlay.active .modal-content,
    .role-auth-modal.modal-overlay.active .modal-content {
        transform: none !important;
    }

    .settings-dropdown {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: rgba(18, 18, 26, 0.96) !important;
    }

    .btn-settings {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    .dropdown-list {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: rgba(28, 28, 32, 0.98) !important;
    }

    .btn-primary,
    .btn-secondary {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    .alert {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: rgba(50, 16, 20, 0.92) !important;
    }

    .news-card {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: rgba(18, 18, 22, 0.92) !important;
    }

    .prompt-modal-input {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: rgba(255, 255, 255, 0.09) !important;
        font-size: max(16px, 1rem) !important;
    }
}

.input-hint {
    font-size: 0.75rem;
    opacity: 0.55;
    margin: 0.35rem 0 0;
}

/* Госномер: подпись и «Иностранный номер» в одной строке; избранное — в поле ввода */
.input-group-car-number {
    position: relative;
    padding-top: 0;
}

.car-number-field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.car-number-field-header label {
    margin: 0;
    padding: 0;
    flex: 1 1 auto;
    min-width: 0;
}

.car-number-input-wrap {
    position: relative;
}

.input-group-car-number .masked {
    width: 100%;
    box-sizing: border-box;
    padding-right: 5.5rem;
}

.input-group-car-number .btn-favorite-toggle {
    top: 50%;
    bottom: auto;
    right: 10px;
    transform: translateY(-50%);
}

.btn-favorite-toggle {
    position: absolute;
    right: 14px;
    top: 36px;
    width: 34px;
    height: 34px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(0,0,0,0.25);
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-foreign-toggle {
    position: relative;
    flex: 0 0 auto;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.85);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0.55rem 0.7rem;
    font-size: 0.75rem;
    white-space: nowrap;
}

.btn-foreign-toggle:hover {
    background: rgba(255,255,255,0.08);
    transform: translateY(-1px);
    color: white;
}

.btn-foreign-toggle.active {
    background: rgba(80,227,194,0.10);
    border-color: rgba(80,227,194,0.35);
    color: var(--accent);
}

.btn-favorite-toggle.active {
    color: var(--accent);
    border-color: rgba(80,227,194,0.35);
    background: rgba(80,227,194,0.08);
}

.btn-favorite-toggle:hover {
    transform: translateY(-1px);
    color: white;
}

.favorites-block {
    margin: 0 0 1.25rem;
    padding: 0.9rem 1rem;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 4px;
    background: rgba(255,255,255,0.02);
}

.favorites-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.55;
    margin-bottom: 0.6rem;
}

.favorites-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 140px;
    overflow-y: auto;
    padding-right: 4px;
}

.favorites-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(0,0,0,0.18);
}

.favorites-item .fav-main {
    font-size: 0.9rem;
    font-weight: 600;
}

.favorites-item .fav-sub {
    font-size: 0.7rem;
    opacity: 0.55;
    margin-top: 2px;
}

.favorites-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-fav {
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.03);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}

.btn-fav.primary {
    border-color: rgba(80,227,194,0.25);
    background: rgba(80,227,194,0.10);
    color: var(--accent);
}

/* Кнопки и элементы-кнопки: без системной рамки фокуса при клике/tap */
button,
[type="button"],
[type="submit"],
[type="reset"],
[role="button"],
summary,
.login-channel-tile,
.close-modal,
.btn-fav,
.btn-stealth,
.btn-delete,
.btn-cancel-pass,
.btn-settings,
.settings-dropdown button,
.pass-duration-btn {
    -webkit-tap-highlight-color: transparent;
}

button:focus,
button:focus-visible,
[type="button"]:focus,
[type="button"]:focus-visible,
[type="submit"]:focus,
[type="submit"]:focus-visible,
[type="reset"]:focus,
[role="button"]:focus,
[role="button"]:focus-visible,
summary:focus,
summary:focus-visible,
.login-channel-tile:focus,
.login-channel-tile:focus-visible,
.close-modal:focus,
.close-modal:focus-visible,
.btn-fav:focus,
.btn-fav:focus-visible,
.btn-stealth:focus,
.btn-stealth:focus-visible,
.btn-delete:focus,
.btn-delete:focus-visible,
.btn-cancel-pass:focus,
.btn-cancel-pass:focus-visible,
.btn-settings:focus,
.btn-settings:focus-visible,
.settings-dropdown button:focus,
.settings-dropdown button:focus-visible,
.pass-duration-btn:focus,
.pass-duration-btn:focus-visible {
    outline: none;
}

a.btn-primary:focus,
a.btn-primary:focus-visible,
a.btn-secondary:focus,
a.btn-secondary:focus-visible,
.security-link-btn:focus,
.security-link-btn:focus-visible {
    outline: none;
}

button::-moz-focus-inner {
    border: 0;
}

.input-invalid {
    border-color: rgba(255, 71, 87, 0.45) !important;
    box-shadow: 0 0 0 2px rgba(255, 71, 87, 0.10) !important;
}

/* Button: Refractive Glass Block */
.btn-primary {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 1.1rem;
    border-radius: 4px; /* Precision block */
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    font-weight: 500;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    margin-top: 1.5rem;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.5),
        inset 0 0 0 1px rgba(255, 255, 255, 0.2); /* Knife edge */
}

.btn-primary:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.12);
    border-color: #ffffff;
    box-shadow: 0 15px 40px rgba(255, 255, 255, 0.08);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0.9rem 1rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.02);
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-top: 0.8rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.4);
}

/* Mobile tactile feedback instead of blue tap flash */
@media (hover: none) and (pointer: coarse) {
    button,
    [type="button"],
    [type="submit"],
    [type="reset"],
    .btn-primary,
    .btn-secondary,
    .btn-fav,
    .btn-mini-accent,
    .security-link-btn,
    .news-react-btn {
        transition: transform 0.12s ease, filter 0.12s ease;
        transform: translateZ(0);
    }

    button:active,
    [type="button"]:active,
    [type="submit"]:active,
    [type="reset"]:active,
    .btn-primary:active,
    .btn-secondary:active,
    .btn-fav:active,
    .btn-mini-accent:active,
    .security-link-btn:active,
    .news-react-btn:active {
        transform: scale(0.98);
        filter: brightness(0.97);
    }
}
/* Modal Overlay */
/* Охрана/админ: поверх остальных модалок */
.role-auth-modal {
    z-index: 2100;
}

/* Вход охраны/админа: меньше blur — меньше лагов на слабых телефонах */
.role-auth-modal.modal-overlay {
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.role-auth-modal .modal-content {
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    padding-top: calc(16px + env(safe-area-inset-top));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity var(--ui-modal-overlay) var(--ease-out-soft),
        visibility var(--ui-modal-overlay) var(--ease-out-soft);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-content {
    /* Якорь для absolute .close-modal (иначе контекст — fixed overlay, крестик в углу экрана) */
    position: relative;
    background: rgba(8, 8, 14, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(40px) saturate(160%);
    -webkit-backdrop-filter: blur(40px) saturate(160%);
    border-radius: 4px; /* Sharp like the cards */
    padding: 2.5rem;
    width: min(92vw, 400px);
    margin: auto 0;
    max-width: 400px;
    max-height: min(88dvh, 720px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    box-shadow: 
        0 40px 80px rgba(0, 0, 0, 0.8),
        inset 0 0 0 1px rgba(255, 255, 255, 0.12);
    transform: scale(0.94) translateY(8px);
    opacity: 0;
    transition:
        transform var(--ui-modal-panel) var(--ease-out-soft),
        opacity calc(var(--ui-modal-panel) * 0.9) var(--ease-out-soft);
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

#plots-modal .modal-content {
    max-width: 880px;
    max-height: min(86vh, 820px);
    padding: 2rem 2.5rem 1.6rem;
    display: flex;
    flex-direction: column;
}

#plots-list-container {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.prompt-modal-content {
    max-width: 560px;
    padding: 1.25rem 1.25rem 1.1rem;
    border-radius: 4px;
}

.prompt-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.9rem;
}

.prompt-modal-title {
    font-size: 1rem;
    font-weight: 600;
}

.prompt-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.10);
    background: rgba(0,0,0,0.18);
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

.prompt-modal-close:hover {
    background: rgba(255,255,255,0.06);
    color: white;
}

.prompt-modal-label {
    display: block;
    font-size: 0.8rem;
    letter-spacing: 0.6px;
    opacity: 0.75;
    margin-bottom: 0.5rem;
    margin-left: 0.25rem;
    text-transform: none;
}

.prompt-modal-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 0.9rem 1rem;
    color: white;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.25s, background 0.25s;
}

.prompt-modal-input:focus {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.5);
}

.prompt-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 1rem;
}

.prompt-btn {
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.12);
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.9rem;
}

.prompt-btn.ok {
    background: rgba(255,255,255,0.92);
    color: black;
    border-color: rgba(255,255,255,0.25);
}

.prompt-btn.cancel {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.85);
}

.prompt-btn.cancel:hover {
    background: rgba(255,255,255,0.10);
}

.modal-header {
    margin-bottom: 1.5rem;
}

.close-modal {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.3s ease;
}

.close-modal:hover {
    color: white;
}
/* Security Dashboard Styles */
.security-header {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 12px;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 2rem;
    width: 100%;
    min-width: 0;
}

.security-header-title {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
}

.security-date-filter {
    flex: 1 1 148px;
    min-width: min(100%, 148px);
    max-width: 100%;
}

.security-quick-dates {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    flex: 1 1 200px;
    justify-content: flex-end;
    min-width: 0;
}

.security-quick-btn {
    width: auto !important;
    margin-top: 0 !important;
    padding: 10px 12px !important;
    font-size: 0.85rem !important;
    flex: 0 1 auto;
    min-width: 0;
    white-space: nowrap;
}

@media (max-width: 560px) {
    .security-header {
        flex-direction: column;
        align-items: stretch;
    }

    .security-header-title {
        flex: none;
    }

    .security-date-filter {
        flex: none;
        width: 100%;
        max-width: none;
        box-sizing: border-box;
    }

    .security-quick-dates {
        flex: none;
        width: 100%;
        justify-content: stretch;
    }

    .security-quick-dates .security-quick-btn {
        flex: 1 1 0;
        text-align: center;
    }
}

.date-filter {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    padding: 0.5rem 1rem;
    color: white;
    outline: none;
    cursor: pointer;
}

.pass-list {
    width: 100%;
    max-height: min(56vh, 540px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-right: 0.5rem;
}

.pass-list::-webkit-scrollbar {
    width: 4px;
}

.pass-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

/* Mobile optimization for security passes */
#pass-list-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    padding: 10px;
}

/* Охрана: один скролл у экрана .page — без вложенного overflow, иначе до конца списка жест не «переходит» к логам и кнопкам */
#security-page #pass-list-container.pass-list {
    max-height: none !important;
    overflow: visible;
    overscroll-behavior: auto;
    touch-action: auto;
}

.pass-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    padding: 0.65rem 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    transition: all 0.3s ease;
    min-height: auto;
    justify-content: space-between;
    gap: 0.35rem;
    touch-action: pan-y;
}

/* «Не выехал» — зафиксировано после полуночи */
.pass-item.pass-ne-vyehal {
    border-color: rgba(255, 120, 90, 0.45);
    background: rgba(60, 20, 10, 0.25);
}

@media (max-width: 520px) {
    .pass-list {
        gap: 0.6rem;
        padding-right: 0;
    }
    .pass-item {
        padding: 0.55rem 0.65rem;
    }
    .pass-plot {
        font-size: 1rem;
        margin-bottom: 2px;
    }
    .pass-car-brand {
        font-size: 0.78rem;
    }
    .pass-car-plate {
        font-size: 1.05rem;
        letter-spacing: 0.1em;
    }
    .pass-controls {
        flex-wrap: wrap;
        gap: 6px;
        padding-top: 6px;
    }
    .status-badge {
        font-size: 0.82rem;
        padding: 6px 12px;
    }
    .status-buttons button {
        width: 50px;
        height: 50px;
        min-width: 50px;
        min-height: 50px;
        font-size: 1.2rem;
    }
}

.pass-plot {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}

.pass-car {
    font-size: 0.75rem;
    line-height: 1.2;
    margin-bottom: 8px;
    opacity: 0.9;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
}

.pass-car-brand {
    font-size: 0.82rem;
    font-weight: 500;
    opacity: 0.92;
    line-height: 1.25;
}

.pass-car-plate {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
    font-size: 1.18rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.98);
    line-height: 1.2;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.pass-expire {
    font-size: 0.7rem;
    line-height: 1.15;
    opacity: 0.65;
    margin-top: 6px;
}

.pass-controls {
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 8px;
}

.status-badge {
    font-size: 0.92rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.35);
    background: rgba(0,0,0,0.4);
}

.status-buttons {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.status-buttons button {
    width: 46px;
    height: 46px;
    min-width: 46px;
    min-height: 46px;
    font-size: 1.1rem;
    margin-top: 0 !important;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Add Plot Button (Stealth) */
.btn-stealth {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.1);
    font-size: 0.7rem;
    cursor: pointer;
    margin-top: 15px;
    transition: color 0.3s;
}

.btn-stealth:hover {
    color: var(--accent);
}

/* Admin Styles */
.admin-section {
    margin-top: 2rem;
    width: 100%;
}

/* Touch-friendly overrides for logs controls (prevents offscreen/tap issues) */
#btn-security-logs-toggle,
#btn-admin-logs-toggle,
#btn-admin-defects-toggle,
#btn-admin-error-reports-toggle {
    touch-action: manipulation;
    width: auto !important;
    margin-top: 0 !important;
    min-height: 44px;
}

#admin-logs-date,
#admin-defects-date,
#admin-error-reports-date {
    width: auto !important;
}

.admin-filter-search {
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
}

.admin-filters-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
}

.admin-filter-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    align-items: center;
    min-width: 0;
}

.admin-filter-row .btn-secondary {
    flex: 0 0 auto;
    margin-top: 0 !important;
}

.admin-filter-row input[type='date'] {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
}

.btn-compact {
    width: auto !important;
    margin-top: 0 !important;
    padding: 8px 14px !important;
    font-size: 0.8rem !important;
    min-height: 40px;
}

.admin-collapsible-panel[hidden] {
    display: none !important;
}

.admin-stats-hint {
    font-size: 0.78rem;
    line-height: 1.35;
    margin-bottom: 0.75rem;
}

.admin-passes-stats-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.admin-month-label {
    font-size: 0.75rem;
    opacity: 0.75;
}

.admin-month-input {
    width: auto;
    max-width: 11rem;
    padding: 6px 10px;
    font-size: 0.85rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.35);
    color: inherit;
}

.pass-stats-chart {
    margin-top: 4px;
}

.pass-stats-row {
    display: grid;
    grid-template-columns: minmax(100px, 1fr) minmax(80px, 4fr) 2.5rem;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.82rem;
}

.pass-stats-label {
    opacity: 0.88;
    line-height: 1.2;
}

.pass-stats-bar-wrap {
    height: 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.pass-stats-meter {
    width: 100%;
    height: 10px;
    border: none;
    background: transparent;
    display: block;
    appearance: none;
    -webkit-appearance: none;
}

.pass-stats-meter::-webkit-progress-bar {
    background: transparent;
}

.pass-stats-meter::-webkit-progress-value,
.pass-stats-meter::-moz-progress-bar {
    border-radius: 6px;
    transition: width 0.35s ease;
}

.pass-stats-meter.bar-orders::-webkit-progress-value,
.pass-stats-meter.bar-orders::-moz-progress-bar {
    background: linear-gradient(90deg, #6c5ce7, #a29bfe);
}
.pass-stats-meter.bar-in::-webkit-progress-value,
.pass-stats-meter.bar-in::-moz-progress-bar {
    background: linear-gradient(90deg, #00b894, #55efc4);
}
.pass-stats-meter.bar-out::-webkit-progress-value,
.pass-stats-meter.bar-out::-moz-progress-bar {
    background: linear-gradient(90deg, #0984e3, #74b9ff);
}
.pass-stats-meter.bar-cancel::-webkit-progress-value,
.pass-stats-meter.bar-cancel::-moz-progress-bar {
    background: linear-gradient(90deg, #fdcb6e, #ffeaa7);
}
.pass-stats-meter.bar-del::-webkit-progress-value,
.pass-stats-meter.bar-del::-moz-progress-bar {
    background: linear-gradient(90deg, #e17055, #fab1a0);
}

.pass-stats-bar {
    height: 100%;
    border-radius: 6px;
    min-width: 4px;
    transition: width 0.35s ease;
}

.pass-stats-bar.bar-orders {
    background: linear-gradient(90deg, #6c5ce7, #a29bfe);
}
.pass-stats-bar.bar-in {
    background: linear-gradient(90deg, #00b894, #55efc4);
}
.pass-stats-bar.bar-out {
    background: linear-gradient(90deg, #0984e3, #74b9ff);
}
.pass-stats-bar.bar-cancel {
    background: linear-gradient(90deg, #fdcb6e, #ffeaa7);
    color: #111;
}
.pass-stats-bar.bar-del {
    background: linear-gradient(90deg, #e17055, #fab1a0);
}

.pass-stats-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    opacity: 0.95;
}

.pass-stats-err {
    color: #ff7675;
    padding: 10px;
    font-size: 0.85rem;
}

.admin-excel-panel {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
    max-width: 100%;
}

.admin-excel-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    font-size: 0.8rem;
}

.admin-excel-hint {
    width: 100%;
    opacity: 0.65;
    font-size: 0.72rem;
    margin-bottom: 2px;
}

.admin-excel-label {
    opacity: 0.75;
    font-size: 0.75rem;
}

.admin-excel-date {
    width: auto;
    max-width: 10.5rem;
    padding: 5px 8px;
    font-size: 0.8rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(0, 0, 0, 0.35);
    color: inherit;
}

.admin-excel-dash {
    opacity: 0.45;
    user-select: none;
}

/* Админ/охрана: одна сетка для поиска + дата/кнопка; экспорт на всю ширину ниже */
@media (min-width: 640px) {
    .admin-filters-stack {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 10px;
    }

    .admin-filters-stack > .admin-filter-search,
    .admin-filters-stack > input[type='text']:first-child {
        grid-column: 1;
        grid-row: 1;
        min-width: 0;
    }

    .admin-filters-stack > .admin-filter-row {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
    }

    .admin-filters-stack > .btn-secondary.btn-compact {
        grid-column: 1 / -1;
        width: auto !important;
        justify-self: start;
    }

    .admin-filters-stack > .admin-excel-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 639px) {
    .admin-filters-stack {
        gap: 12px;
    }

    .admin-filters-stack > .admin-filter-search,
    .admin-filters-stack > input[type='text']:first-child {
        width: 100% !important;
        box-sizing: border-box;
    }

    .admin-filter-row {
        width: 100%;
        flex-wrap: nowrap;
    }

    .admin-filter-row input[type='date'] {
        flex: 1 1 auto;
        width: auto !important;
        min-width: 0;
    }

    /* Экспорт и вторичные кнопки — на всю ширину, удобнее для пальца */
    .admin-filters-stack > .btn-secondary.btn-compact {
        width: 100% !important;
        justify-self: stretch;
        box-sizing: border-box;
    }

    .admin-excel-row {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-excel-row .admin-excel-date,
    .admin-excel-row .btn-secondary {
        width: 100% !important;
        max-width: none;
    }

    .admin-excel-hint {
        width: 100%;
    }
}

#security-logs-search {
    touch-action: manipulation;
}

.admin-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 10px;
    font-size: 0.85rem;
    overflow-wrap: anywhere;
}

.admin-family {
    margin-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.06);
    padding-top: 10px;
}

.admin-family summary {
    cursor: pointer;
    opacity: 0.75;
    user-select: none;
}

.admin-family summary:hover {
    opacity: 1;
}

.admin-family-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-family-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 4px;
    background: rgba(0,0,0,0.12);
}

.admin-log-item {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.admin-log-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-log-top .admin-time {
    float: none;
    flex-shrink: 0;
}

.admin-log-detail {
    margin-top: 8px;
    width: 100%;
    min-width: 0;
}

.admin-log-plain {
    display: inline-block;
    opacity: 0.92;
    word-break: break-word;
    font-size: 0.88rem;
    line-height: 1.45;
}

.admin-error-report-message {
    margin-top: 8px;
    font-size: 0.88rem;
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
}

.log-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    align-items: center;
}

.log-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.8rem;
    max-width: 100%;
}

.log-pill-k {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.55;
    color: rgba(255, 255, 255, 0.88);
}

.log-pill-only .log-pill-k {
    display: none;
}

.log-pill-v {
    color: rgba(255, 255, 255, 0.95);
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Компактные лог-пилюли на телефоне: меньше отступы + сетка 2 колонки */
@media (max-width: 560px) {
    .admin-log-detail {
        margin-top: 6px;
    }

    .log-pills {
        gap: 4px 6px;
    }

    .log-pill {
        padding: 4px 8px;
        gap: 4px;
        font-size: 0.72rem;
        border-radius: 10px;
    }

    .log-pill-k {
        font-size: 0.6rem;
        letter-spacing: 0.02em;
    }

    .log-pill-v {
        font-size: 0.75rem;
        line-height: 1.25;
    }
}

@media (max-width: 480px) {
    .log-pills {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px 8px;
        align-items: stretch;
    }

    .log-pill {
        width: 100%;
        max-width: none;
        min-width: 0;
        box-sizing: border-box;
        padding: 5px 8px;
        flex-wrap: wrap;
        align-items: flex-start;
        align-content: center;
    }

    .log-pill-k {
        flex: 0 0 auto;
        max-width: 42%;
    }

    .log-pill-v {
        flex: 1 1 55%;
        min-width: 0;
    }
}

/* Очень узкий экран — одна колонка, но всё ещё компактно */
@media (max-width: 340px) {
    .log-pills {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .log-pill {
        flex-wrap: wrap;
    }
}

.admin-logs-more {
    margin-top: 8px;
}

.admin-logs-more summary {
    cursor: pointer;
    opacity: 0.75;
    user-select: none;
    padding: 6px 0;
}

.admin-logs-more summary:hover {
    opacity: 1;
}

.admin-tag {
    font-weight: bold;
    color: var(--accent);
    margin-right: 10px;
}

.admin-time {
    font-size: 0.7rem;
    opacity: 0.5;
    float: right;
}

@media (min-width: 768px) {
    #pass-list-container {
        grid-template-columns: 1fr;
    }
    .pass-item {
        flex-direction: row;
        align-items: center;
        min-height: auto;
    }
    .pass-controls {
        width: auto;
        min-width: 0;
        border-top: none;
        padding-top: 0;
        align-self: center;
    }
}

/* Masked Input Styling */
input.masked {
    letter-spacing: 2px;
    text-transform: uppercase;
    font-family: monospace;
}

/* Resident Pass Management */
.stat-item.clickable {
    cursor: pointer;
    transition: all 0.3s ease;
}

.stat-item.clickable:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
}

.manage-pass-list {
    margin-top: 1.5rem;
    max-height: min(52vh, 480px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    text-align: left;
    /* Тёмный скролл (Windows/Chrome): без белого системного ползунка */
    color-scheme: dark;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.28) rgba(0, 0, 0, 0.25);
}

.manage-pass-list::-webkit-scrollbar {
    width: 8px;
}

.manage-pass-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.manage-pass-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
    border-radius: 4px;
}

.manage-pass-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

.manage-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    margin-bottom: 0.8rem;
    padding: 1rem;
    border-radius: 4px;
}

.manage-item-info {
    flex-grow: 1;
}

.manage-item-title {
    font-size: 1rem;
    font-weight: 600;
    display: block;
}

.manage-item-subtitle {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
}

.btn-delete {
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid rgba(255, 71, 87, 0.2);
    color: #ff4757;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.btn-delete:hover {
    background: #ff4757;
    color: white;
}

/* Кнопка отмены в «Мои пропуски» — максимальный контраст */
.btn-cancel-pass {
    flex: 0 0 auto;
    margin-top: 0 !important;
    width: 42px !important;
    height: 42px !important;
    min-width: 42px;
    border-radius: 50% !important;
    border: 2px solid rgba(255, 71, 87, 0.95) !important;
    background: rgba(40, 0, 0, 0.85) !important;
    color: #ff6b81 !important;
    font-size: 1.35rem !important;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}

.btn-cancel-pass:hover:not(:disabled) {
    background: rgba(255, 71, 87, 0.95) !important;
    color: #1a0505 !important;
}

.btn-cancel-pass:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}


.pass-duration-btn.pass-duration-btn--active {
    border-color: var(--accent);
    background: rgba(80, 227, 194, 0.18);
    color: rgba(255, 255, 255, 0.92);
    box-shadow: 0 0 0 1px rgba(80, 227, 194, 0.35);
}

/* Loader */
.loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0,0,0,0.1);
    border-top: 2px solid black;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}

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

/* Cabinet Extra Styles */
.cabinet-content {
    text-align: center;
}

.user-badge {
    width: auto;
    height: auto;
    background: transparent;
    border-radius: 0;
    margin: 0 auto 0.45rem;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0;
    box-shadow: none;
}

.user-badge-icon {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 50%;
    transform: none;
    display: block;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.35));
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 2rem;
}

.stat-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 4px;
    border: 1px solid var(--glass-border);
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 600;
    display: block;
}

.stat-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
}

/* Notifications */
.alert {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 71, 87, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 71, 87, 0.2);
    color: #ff4757;
    padding: 1rem 2rem;
    border-radius: 4px;
    transform: translateX(200%);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
}

.alert.show {
    transform: translateX(0);
}

/* Searchable Dropdown */
.searchable-dropdown {
    position: relative;
    width: 100%;
}

.dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 200px;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    margin-top: 5px;
    padding: 0;
    list-style: none;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.dropdown-list.active {
    display: block;
    animation: fadeInDown 0.3s ease;
}

.dropdown-list li {
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-size: 0.9rem;
}

.dropdown-list li:last-child {
    border-bottom: none;
}

.dropdown-list li:hover {
    background: rgba(255,255,255,0.05);
    color: var(--accent);
    padding-left: 1.5rem;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: scaleY(0.96);
    }
    to {
        opacity: 1;
        transform: scaleY(1);
    }
}

.dropdown-list::-webkit-scrollbar {
    width: 4px;
}

.dropdown-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.login-footer {
    margin-top: 2rem;
    text-align: center;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 1.5rem;
}

.security-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--glass-border);
    color: var(--accent);
    padding: 10px 20px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.security-link-btn:hover {
    background: rgba(255,255,255,0.08);
    transform: translateY(-2px);
}

.login-code-status {
    font-size: 0.85rem;
    color: var(--accent);
    margin: -0.5rem 0 0.75rem;
    min-height: 1.2em;
}

.login-telegram-hint {
    font-size: 0.85rem;
    line-height: 1.4;
    color: rgba(255, 200, 120, 0.95);
    margin: 0.5rem 0 1rem;
}

.login-telegram-hint a {
    color: var(--accent);
}

.btn-linkish {
    margin-top: 0.75rem;
    background: transparent;
    border: none;
    box-shadow: none;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.85rem;
}

.btn-linkish:hover {
    color: rgba(255, 255, 255, 0.85);
}

.login-verify-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 0.75rem;
    justify-content: flex-start;
}

.login-verify-actions .btn-primary,
.login-verify-actions .btn-secondary {
    margin-top: 0;
    flex: 0 1 auto;
    min-width: min(120px, 100%);
}

.login-verify-actions .btn-linkish {
    margin-top: 0;
}

@media (min-width: 420px) {
    .login-verify-actions {
        gap: 10px;
        justify-content: center;
    }
}

@media (min-width: 900px) {
    .login-verify-actions {
        gap: 6px;
        justify-content: center;
    }
}

.login-channel-modal-content {
    max-width: 400px;
    width: min(400px, calc(100vw - 2rem));
    position: relative;
    box-sizing: border-box;
    overflow-x: hidden;
}

.login-channel-tiles {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 1.25rem;
}

@media (min-width: 420px) {
    .login-channel-tiles {
        grid-template-columns: 1fr 1fr;
    }
}

.login-channel-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 4px;
    padding: 14px 16px;
    border-radius: 4px; /* Precision edges */
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.35);
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    font: inherit;
    transition: all 0.25s ease;
}

.login-channel-tile:hover {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.05);
}

.login-channel-tile.active {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.05);
}

.login-channel-tile-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.login-channel-tile-hint {
    font-size: 0.75rem;
    line-height: 1.35;
    opacity: 0.65;
}

.login-channel-modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    align-items: stretch;
}

.login-channel-modal-actions .btn-secondary,
.login-channel-modal-actions .btn-primary {
    margin: 0;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

@media (max-width: 340px) {
    .login-channel-modal-actions {
        grid-template-columns: 1fr;
    }
}

/* Кнопка «Получить код» для входа охрана/админ — внутри модалки */
#role-auth-step-phone > .btn-primary {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-top: 1rem;
}

.resident-contact-panel {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    text-align: left;
}

.resident-contact-line {
    font-size: 0.85rem;
    opacity: 0.75;
    margin: 0.35rem 0 0;
}

.resident-error-panel {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    text-align: left;
    opacity: 0.8;
}

.resident-error-panel--footer {
    margin-top: 1rem;
    padding-top: 0.9rem;
    border-top-color: rgba(255, 255, 255, 0.08);
}

.resident-error-toggle {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.resident-error-toggle:hover {
    color: rgba(255, 255, 255, 0.75);
}

.resident-error-body {
    margin-top: 0.5rem;
}

.resident-error-hint {
    font-size: 0.75rem;
    opacity: 0.55;
    margin-top: 0.35rem;
}

.resident-error-email {
    opacity: 0.7;
}

.resident-error-textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    padding: 0.9rem 1rem;
    color: white;
    font-size: 0.95rem;
    outline: none;
    resize: vertical;
    min-height: 92px;
}

.resident-error-textarea:focus {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.05);
}

/* Кабинет: главное действие выше ленты новостей */
.cabinet-btn-order-pass {
    width: 100%;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}

.cabinet-news-title {
    margin-top: 0.75rem !important;
}

.cabinet-news-hint {
    margin-top: 0.35rem;
}

/* Лента новостей поселка */
.news-section {
    text-align: left;
    margin-top: 0.25rem;
}

.news-feed {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 10px;
}

.news-empty {
    opacity: 0.45;
    font-size: 0.9rem;
    padding: 12px 0;
}

.news-card {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px; /* Precision edges */
    padding: 1.5rem;
    background: rgba(10, 10, 10, 0.5);
    backdrop-filter: blur(10px);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.news-card-meta {
    font-size: 0.7rem;
    opacity: 0.4;
    margin-bottom: 1rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.news-card-body {
    font-size: 0.9rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
    white-space: pre-wrap;
    word-break: break-word;
}

.news-card-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.news-img-link {
    display: block;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.news-img-link img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

/* Лента жителя: одна колонка, фото по центру, без жёсткой обрезки */
.news-feed--resident .news-card-images {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    width: 100%;
}

.news-feed--resident .news-img-link {
    width: 100%;
    max-width: min(100%, 420px);
    margin: 0 auto;
    display: block;
    border: none;
    padding: 0;
    background: transparent;
    font: inherit;
    text-align: center;
    cursor: zoom-in;
    border-radius: 4px;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.news-feed--resident .news-img-link img {
    width: 100%;
    height: auto;
    max-height: min(70vh, 320px);
    min-height: 0;
    object-fit: contain;
    object-position: center;
    background: rgba(0, 0, 0, 0.18);
}

.news-img-link.news-img-missing {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-height: 72px;
    pointer-events: none;
    cursor: default;
    border-style: dashed;
}

.news-img-link.news-img-missing img {
    display: none !important;
}

.news-img-link.news-img-missing::after {
    content: 'Фото недоступно';
    font-size: 0.78rem;
    opacity: 0.45;
    padding: 12px;
    text-align: center;
}

.news-feed-archive {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 4px;
}

.news-feed-archive[hidden] {
    display: none !important;
}

.btn-news-archive {
    width: 100%;
    margin-top: 6px;
}

.news-card-react {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.news-react-btn {
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.85);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: manipulation;
    transition:
        transform 0.18s cubic-bezier(0.33, 1, 0.68, 1),
        border-color 0.2s,
        background 0.2s,
        box-shadow 0.35s ease;
    will-change: transform;
}

.news-react-btn:hover {
    border-color: rgba(80, 227, 194, 0.35);
}

.news-react-btn:active {
    transform: scale(0.88);
}

.news-react-btn.active {
    border-color: var(--accent);
    background: rgba(80, 227, 194, 0.12);
}

@keyframes news-react-pop {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(80, 227, 194, 0.45);
    }
    45% {
        transform: scale(1.2);
        box-shadow: 0 0 0 6px rgba(80, 227, 194, 0.12);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(80, 227, 194, 0);
    }
}

.news-react-btn.news-react-btn--anim {
    animation: news-react-pop 0.48s cubic-bezier(0.34, 1.45, 0.64, 1) both;
}

@media (prefers-reduced-motion: reduce) {
    .news-react-btn:active {
        transform: none;
    }
    .news-react-btn.news-react-btn--anim {
        animation: none;
    }
}

.admin-news-list .admin-news-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    align-items: center;
}

.admin-news-imgs {
    position: relative;
}

.news-img-wrap {
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.news-img-wrap img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
}

.news-img-del {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.55);
    color: white;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.news-img-del:hover {
    background: rgba(255, 71, 87, 0.85);
}

/* Нативные поля даты/месяца: тёмная тема везде, где поддерживается */
input[type='date'],
input[type='month'],
input[type='datetime-local'] {
    color-scheme: dark;
    accent-color: var(--accent);
    background: rgba(0, 0, 0, 0.35);
    color: var(--primary);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 0.88rem;
    min-height: 40px;
}

input[type='date']::-webkit-calendar-picker-indicator,
input[type='month']::-webkit-calendar-picker-indicator,
input[type='datetime-local']::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.85;
    filter: invert(1);
}

/* Лайтбокс фото новости (ЛК) */
.news-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    box-sizing: border-box;
}

.news-lightbox[hidden] {
    display: none !important;
}

.news-lightbox-backdrop {
    position: absolute;
    inset: 0;
    border: none;
    margin: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.92);
    cursor: zoom-out;
}

.news-lightbox-dialog {
    position: relative;
    z-index: 1;
    max-width: min(96vw, 960px);
    max-height: 90vh;
}

.news-lightbox-img-el {
    display: block;
    max-width: 100%;
    max-height: 86vh;
    width: auto;
    height: auto;
    object-fit: contain;
    margin: 0 auto;
    border-radius: 14px;
    box-shadow: 0 16px 56px rgba(0, 0, 0, 0.55);
}

.news-lightbox-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.news-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.15);
}


/* Shared adaptive rows (instead of inline styles) */
.action-row {
    display: flex;
    gap: 10px;
    margin-top: 2rem;
    align-items: center;
    flex-wrap: wrap;
    min-width: 0;
}

.action-row:last-child {
    margin-bottom: 0;
}

/* Security/Admin pages: same clean bottom behavior as resident cabinet */
#security-page .glass-card,
#admin-page .glass-card {
    width: min(100%, 800px);
    box-sizing: border-box;
    margin-top: 0.35rem;
    margin-bottom: calc(2rem + env(safe-area-inset-bottom));
    padding-bottom: calc(1.9rem + env(safe-area-inset-bottom));
}

/* Охрана: не задавать overflow:visible — иначе ::before (glassGlint) не режется и блик «ездит» по всему экрану. Скролл страницы не ломается: высота карточки по контенту. */

#admin-page .action-row:last-child,
#security-page .action-row:last-child {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
}

@media (min-width: 641px) {
    /* Админ: две кнопки одной высоты и ширины (~50/50) */
    #admin-page .action-row:last-child {
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 12px;
    }

    #admin-page .action-row:last-child #btn-admin-to-resident,
    #admin-page .action-row:last-child #btn-admin-logout {
        flex: 1 1 0;
        min-width: 0;
        width: auto !important;
        margin-top: 0 !important;
        align-self: stretch;
        min-height: 3.25rem;
        box-sizing: border-box;
        padding-top: 1rem;
        padding-bottom: 1rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    min-width: 0;
}

.header-row--compact {
    margin-bottom: 10px;
}

.btn-mini-accent {
    background: var(--accent);
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    color: #000;
    width: auto;
}

@media (max-width: 640px) {
    .page {
        padding: 12px;
        padding-top: calc(12px + env(safe-area-inset-top));
        padding-bottom: calc(34px + env(safe-area-inset-bottom));
    }

    .glass-card {
        padding: 1.25rem;
        margin: 0.75rem auto;
    }

    #security-page .glass-card,
    #admin-page .glass-card {
        margin: 0.6rem auto calc(2rem + env(safe-area-inset-bottom));
        padding-bottom: calc(1.8rem + env(safe-area-inset-bottom));
    }

    h1 {
        font-size: 1.55rem;
        letter-spacing: 1.5px;
    }

    .subtitle {
        letter-spacing: 1px;
    }

    .action-row {
        margin-top: 1.25rem;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .action-row .btn-primary,
    .action-row .btn-secondary {
        width: 100% !important;
    }

    .header-row h1 {
        width: 100%;
        min-width: 0;
    }

    .header-row .btn-primary,
    .header-row .btn-secondary {
        width: 100% !important;
    }

    .btn-mini-accent {
        width: 100%;
        min-height: 40px;
    }

    .modal-content {
        padding: 1.25rem;
        width: min(94vw, 420px);
    }

    /* Только модалка "Новый пропуск": один скролл у overlay без рывков */
    #pass-modal .modal-content {
        max-height: none;
        overflow-y: visible;
    }

    .modal-overlay {
        align-items: flex-start;
        justify-content: center;
        padding: 10px;
        padding-top: calc(10px + env(safe-area-inset-top));
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    #plots-modal .modal-content {
        padding: 1rem;
        max-height: min(90dvh, 90vh);
    }

    #plots-list-container {
        max-height: none;
        overflow-y: auto;
    }

    .pass-list {
        max-height: none;
    }

    #manage-modal .manage-pass-list,
    #manage-modal #family-passes-container {
        max-height: min(52dvh, 420px);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
}
