:root {
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.5);
    --secondary: #ec4899;
    --accent: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;

    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text: var(--text-main);

    --safe-area-inset-bottom: env(safe-area-inset-bottom);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    background-color: var(--bg-dark);
    transition: background-color 0.3s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

.screen {
    display: none;
    height: 100vh;
    padding-bottom: 80px;
    overflow-y: auto;
}

.screen.active {
    display: block;
}

#blocked-screen.active {
    display: flex !important;
}

.content-padding,
.list-container {
    padding: 0 20px;
    margin-top: 10px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card,
.welcome-card,
.item-card,
.admin-item-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

h1,
h2,
h3,
h4 {
    font-weight: 700;
    letter-spacing: -0.025em;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

h3 {
    font-size: 1.25rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--glass-border);
    gap: 8px;
    width: 100%;
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    color: white;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 14px 0 var(--primary-glow);
}

.btn.primary:active {
    transform: scale(0.97);
    box-shadow: 0 2px 8px 0 var(--primary-glow);
}

.btn.secondary {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

.btn.disabled,
.category-card.disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(1);
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
    padding-left: 4px;
}

input[type="text"],
input[type="tel"],
input[type="number"],
textarea,
select {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 14px 16px;
    color: var(--text-main);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: flex-end;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-card);
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 32px 32px 0 0;
    padding: 24px;
    padding-bottom: calc(30px + var(--safe-area-inset-bottom));
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--glass-border);
    border-bottom: none;
}

.back-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-right: 15px;
    backdrop-filter: blur(10px);
}

.back-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.1);
}

.back-btn img {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

.main-header {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--glass-border);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.close-modal-btn {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    height: calc(70px + var(--safe-area-inset-bottom));
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: var(--safe-area-inset-bottom);
    z-index: 500;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item img {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    opacity: 0.6;
}

.nav-item.active img {
    opacity: 1;
    filter: drop-shadow(0 0 5px var(--primary-glow));
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--glass);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

.center-all {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.pending {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-badge.confirmed {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.cancelled {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.category-card.no-slots {
    opacity: 0.5;
    filter: grayscale(1);
}

#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    width: 90%;
    max-width: 400px;
    pointer-events: none;
}

.toast {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 12px 20px;
    border-radius: 16px;
    margin-bottom: 10px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition: all 0.3s;
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

.toast-icon {
    font-size: 1.2rem;
}

.toast-msg {
    font-size: 0.9rem;
    font-weight: 500;
    flex: 1;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.toast.out {
    opacity: 0;
    transform: translateY(-20px) scale(0.9);
}

.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.confirm-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 24px;
    width: 100%;
    max-width: 320px;
    text-align: center;
    animation: zoomIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.confirm-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: white;
}

.confirm-text {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.4;
}

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

.confirm-actions button {
    flex: 1;
}

/* Custom Alert Modal (Single Button) */
.alert-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 21000;
    padding: 20px;
}

.alert-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 24px;
    width: 100%;
    max-width: 300px;
    text-align: center;
    animation: zoomIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.alert-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
}

.alert-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: white;
}

.alert-text {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.4;
}

.status-badge.completed {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.dash-period-btn.active {
    background: var(--secondary) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3) !important;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 8px 5px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

/* Agreement & Policy Files styling */
.agreement-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 10px 14px;
    gap: 12px;
    transition: all 0.2s ease;
}

.agreement-file-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

.agreement-file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.agreement-file-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.agreement-file-name {
    font-size: 0.85rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agreement-file-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.agreement-file-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.agreement-file-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.agreement-file-btn.delete {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

.agreement-file-btn.delete:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}

/* --- THEME CUSTOMIZATION --- */
#app-custom-bg {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw; height: 100vh;
    z-index: -1;
    pointer-events: none;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 0.3s ease;
}

#app {
    position: relative;
    z-index: 1;
}

body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

.card, .welcome-card, .item-card, .admin-item-card, .btn, input, textarea, select {
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Сетка пикеров цветов */
.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.color-picker-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.color-picker-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-picker-wrapper input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    background: none;
    padding: 0;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch {
    border: 2px solid var(--glass-border);
    border-radius: 50%;
}

.color-hex-text {
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    width: 80px;
    text-align: center;
}

/* Ползунки прозрачности */
.range-slider-group {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 20px;
}

.range-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.range-slider-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.range-slider-value {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 700;
}

.range-slider-input {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    height: 6px;
    border-radius: 3px;
    outline: none;
}

.range-slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 10px var(--primary-glow);
    transition: transform 0.1s;
}

.range-slider-input::-webkit-slider-thumb:active {
    transform: scale(1.3);
}

/* Зона загрузки фонового фото */
.bg-upload-area {
    background: rgba(255, 255, 255, 0.02);
    border: 2px dashed var(--glass-border);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.bg-upload-area:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.02);
}

.bg-upload-icon {
    font-size: 2rem;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.bg-upload-text {
    font-size: 0.9rem;
    color: var(--text-main);
    font-weight: 600;
    margin-bottom: 4px;
}

.bg-upload-subtext {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.bg-preview-container {
    margin-top: 16px;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    border: 1px solid var(--glass-border);
    display: none;
}

.bg-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bg-delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(239, 68, 68, 0.85);
    border: none;
    color: white;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.bg-delete-btn:hover {
    background: rgb(239, 68, 68);
}

/* Вкладки (tabs-nav) с поддержкой динамического контура */
.tabs-nav {
    border: 1px solid var(--glass-border) !important;
}

/* --- THUMBNAIL & LIGHTBOX STYLES --- */
.thumb-image {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.thumb-image:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

/* Lightbox Modal */
.lightbox-modal {
    display: none;
    position: fixed;
    z-index: 25000; /* Выше обычных модалок */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(15, 23, 42, 0.85); /* Солидный темный цвет с прозрачностью */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.lightbox-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 80%;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
    animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 25px;
    color: var(--text-muted);
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

.lightbox-close:hover,
.lightbox-close:focus {
    color: var(--text-main);
    text-decoration: none;
    cursor: pointer;
}

/* Drag-and-Drop Area admin UI tweaks */
.drag-drop-zone.dragover {
    border-color: var(--primary) !important;
    background: rgba(99, 102, 241, 0.05) !important;
}