* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Предотвращение мерцания при переходах */
html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Основные стили body */
html {
    height: 100%;
    height: 100dvh; /* Dynamic viewport height для мобильных устройств */
    overflow: hidden;
    position: fixed;
    width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #000;
    background-attachment: fixed;
    background-size: cover;
    padding: 0;
    margin: 0;
    will-change: auto;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Фон для html тоже */
html::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    z-index: -1;
}

/* Для страницы логина разрешаем прокрутку */
body:has(.login-page) {
    overflow-y: auto;
    position: relative;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Плавные переходы без мерцания */
.dashboard-container,
.card,
.admin-nav,
.dashboard-header {
    will-change: auto;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Центрирование только для страницы логина */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
    overflow-y: auto;
    position: relative;
}

body:has(.login-page) {
    overflow-y: auto;
    position: relative;
}

/* Страница чека — прокрутка */
html:has(.check-page) {
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    height: auto;
    min-height: 100dvh;
}

body:has(.check-page) {
    overflow-y: auto;
    position: relative;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

/* Flash messages */
.flash-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 400px;
}

.flash-message {
    padding: 15px 20px;
    margin-bottom: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease-out;
}

.flash-success {
    background-color: #10b981;
    color: white;
}

.flash-error {
    background-color: #ef4444;
    color: white;
}

.flash-info {
    background-color: #3b82f6;
    color: white;
}

.flash-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    margin-left: 15px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.flash-close:hover {
    opacity: 1;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Login page - стили определены выше */

.login-box {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    color: #1f2937;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-header p {
    color: #6b7280;
    font-size: 14px;
}

.login-form {
    margin-bottom: 20px;
}

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

.form-group label {
    display: block;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
    background-color: #f9fafb;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 10px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

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

.login-footer {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
    color: #6b7280;
    font-size: 12px;
}

/* Переключатель режимов входа */
.login-mode-switch {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background-color: #f3f4f6;
    padding: 4px;
    border-radius: 8px;
}

.mode-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: #6b7280;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.mode-btn.active {
    background: white;
    color: #667eea;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mode-btn:hover {
    color: #374151;
}

/* PIN группа */
.pin-group {
    margin-bottom: 20px;
}

.pin-display {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.pin-dots {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #d1d5db;
    background-color: white;
    transition: all 0.2s;
}

.pin-dot.filled {
    background-color: #667eea;
    border-color: #667eea;
}

/* Цифровая клавиатура */
.pin-keyboard {
    margin-top: 20px;
    margin-bottom: 20px;
    touch-action: manipulation;
    -webkit-touch-callout: none;
}

.keyboard-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    justify-content: center;
}

.key-btn {
    width: 70px;
    height: 70px;
    border: 2px solid #e5e7eb;
    background: white;
    border-radius: 12px;
    font-size: 24px;
    font-weight: 600;
    color: #1f2937;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.key-btn:hover {
    background-color: #f9fafb;
    border-color: #667eea;
    transform: scale(1.05);
}

.key-btn:active {
    background-color: #667eea;
    color: white;
    transform: scale(0.95);
}

/* Предотвращение double-tap zoom на iPad */
.key-btn,
.pin-keyboard,
.pin-display,
.login-box {
    touch-action: manipulation;
    -webkit-touch-callout: none;
}

.key-btn-clear,
.key-btn-backspace {
    font-size: 14px;
    background-color: #f3f4f6;
    color: #6b7280;
}

.key-btn-clear:hover,
.key-btn-backspace:hover {
    background-color: #e5e7eb;
    border-color: #9ca3af;
}

.key-btn-backspace {
    font-size: 20px;
}

/* Адаптивность для мобильных */
@media (max-width: 480px) {
    .key-btn {
        width: 60px;
        height: 60px;
        font-size: 20px;
    }
    
    .pin-dots {
        gap: 12px;
    }
    
    .pin-dot {
        width: 14px;
        height: 14px;
    }
}

.login-footer p {
    margin: 4px 0;
}

.login-footer strong {
    color: #374151;
}

/* Dashboard */
.dashboard-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 20px 20px 20px;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: transparent;
}

.dashboard-header {
    background: white;
    border-radius: 12px;
    padding: 15px 30px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.dashboard-header h1 {
    color: #1f2937;
    font-size: 32px;
}

.btn-logout {
    padding: 10px 20px;
    background-color: #ef4444;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.btn-logout:hover {
    background-color: #dc2626;
}

.dashboard-content {
    display: grid;
    gap: 20px;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Справочники и остальные страницы (кроме главной пользователя) — прокрутка всей страницы */
html:has(.dashboard-container):not(:has(.dashboard-layout-user)) {
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    height: auto;
    min-height: 100dvh;
}

body:has(.dashboard-container):not(:has(.dashboard-layout-user)) {
    overflow-y: auto;
    position: relative;
    height: auto;
    min-height: 100dvh;
}

.dashboard-container:not(:has(.dashboard-layout-user)) {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
}

.dashboard-container:not(:has(.dashboard-layout-user)) .dashboard-content {
    overflow: visible;
    min-height: 0;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Для страниц с контентом, который может прокручиваться */
.card.scrollable {
    overflow-y: auto;
    max-height: 100%;
}

.card h2 {
    color: #1f2937;
    margin-bottom: 15px;
    font-size: 24px;
}

.card p {
    color: #6b7280;
    line-height: 1.6;
    margin-bottom: 10px;
}

/* Navigation */
.admin-nav {
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    display: flex;
    flex-shrink: 0;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
}

.nav-left {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-name {
    color: #374151;
    font-weight: 600;
    font-size: 14px;
    padding: 8px 12px;
    background-color: #f3f4f6;
    border-radius: 8px;
    white-space: nowrap;
}

.nav-item {
    padding: 12px 20px;
    text-decoration: none;
    color: #6b7280;
    border-radius: 8px;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-item:hover {
    background-color: #f3f4f6;
    color: #374151;
}

.nav-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.nav-icon {
    font-size: 18px;
}

/* Card Header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.card-header h2 {
    margin: 0;
}

/* Buttons */
.btn-primary {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: inline-block;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    padding: 12px 24px;
    background-color: #6b7280;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: background-color 0.2s;
    display: inline-block;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

.btn-edit {
    padding: 8px 16px;
    background-color: #3b82f6;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
    display: inline-block;
    margin-right: 8px;
}

.btn-edit:hover {
    background-color: #2563eb;
}

.btn-delete {
    padding: 8px 16px;
    background-color: #ef4444;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

/* Tables */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.data-table thead {
    background-color: #f9fafb;
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
    color: #1f2937;
}

.data-table tbody tr:hover {
    background-color: #f9fafb;
}

.data-table .actions {
    white-space: nowrap;
}

.check-link-cell {
    white-space: nowrap;
}

.check-link-cell .btn-check-link,
.check-link-cell .btn-copy-url {
    display: inline-block;
    margin-right: 8px;
    margin-bottom: 4px;
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

.check-link-cell .btn-check-link {
    background: #667eea;
    color: white;
}

.check-link-cell .btn-check-link:hover {
    background: #5568d3;
}

.check-link-cell .btn-copy-url {
    background: #e5e7eb;
    color: #374151;
}

.check-link-cell .btn-copy-url:hover {
    background: #d1d5db;
}

/* Forms */
.form-container {
    max-width: 600px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    color: #374151;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
    background-color: #f9fafb;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #6b7280;
}

.card-no-hint {
    display: block;
    margin-top: 4px;
    font-size: 13px;
}
.card-no-hint.card-no-taken { color: #dc2626; }
.card-no-hint.card-no-free { color: #16a34a; }

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 30px;
    flex-wrap: wrap;
}

/* Badges */
.discount-price {
    color: #10b981;
    font-weight: 600;
}

.no-discount {
    color: #9ca3af;
}

.discount-badge {
    display: inline-block;
    padding: 4px 10px;
    background-color: #d1fae5;
    color: #065f46;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.level-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.level-обычный {
    background-color: #e5e7eb;
    color: #374151;
}

.level-постоянный {
    background-color: #dbeafe;
    color: #1e40af;
}

.level-vip {
    background-color: #fef3c7;
    color: #92400e;
}

.level-премиум {
    background-color: #fce7f3;
    color: #9f1239;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-free {
    background-color: #d1fae5;
    color: #065f46;
}

.status-occupied {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-reserved {
    background-color: #fef3c7;
    color: #92400e;
}

/* PIN badge */
.pin-badge {
    display: inline-block;
    padding: 4px 10px;
    background-color: #d1fae5;
    color: #065f46;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.pin-badge-none {
    background-color: #e5e7eb;
    color: #6b7280;
}

/* Role badges */
.role-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.role-admin {
    background-color: #fee2e2;
    color: #991b1b;
}

.role-user {
    background-color: #dbeafe;
    color: #1e40af;
}

.text-muted {
    color: #9ca3af;
    font-size: 14px;
    font-style: italic;
}

/* Form row for side-by-side inputs */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    color: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    font-size: 48px;
    opacity: 0.9;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
}

/* Empty message */
.empty-message {
    text-align: center;
    padding: 60px 20px;
    color: #9ca3af;
    font-size: 16px;
}

/* Responsive */
@media (max-width: 768px) {
    .admin-nav {
        flex-direction: column;
        align-items: stretch;
    }
    
    .nav-left {
        width: 100%;
        flex-direction: column;
    }
    
    .nav-right {
        width: 100%;
        justify-content: space-between;
        margin-top: 10px;
        flex-wrap: wrap;
    }
    
    .user-name {
        font-size: 13px;
    }
    
    .nav-item {
        width: 100%;
        justify-content: center;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .data-table {
        font-size: 14px;
    }
    
    .data-table th,
    .data-table td {
        padding: 10px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 30px 20px;
    }
    
    .dashboard-header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .dashboard-header h1 {
        font-size: 24px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn-primary,
    .form-actions .btn-secondary {
        width: 100%;
        text-align: center;
    }
}
