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

:root {
    --primary-color: #000000;
    --secondary-color: #1a1a1a;
    --accent-color: #2d2d2d;
    --highlight-color: #f5f5f5;
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(0, 0, 0, 0.08);
    --text-primary: #000000;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #e5e5e5;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.08);
    --sidebar-width: 70px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    height: 100vh;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    overflow: hidden;
}

.wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    color: var(--primary-color);
    font-weight: 700;
    letter-spacing: 0;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--highlight-color);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.5rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    transition: var(--transition);
    position: relative;
}

.nav-item span {
    display: none;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--highlight-color);
}

.nav-item.active {
    color: var(--primary-color);
    background: var(--highlight-color);
    font-weight: 600;
}

.nav-item svg,
.nav-item i[data-feather] {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.stat-icon svg,
.stat-icon i[data-feather] {
    color: var(--bg-primary);
}

.sidebar-toggle svg,
.sidebar-toggle i[data-feather],
.mobile-menu-btn svg,
.mobile-menu-btn i[data-feather] {
    color: var(--text-primary);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100vh;
}

.mobile-header {
    display: none;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: var(--transition);
}

.mobile-menu-btn:hover {
    background: var(--highlight-color);
}

.mobile-header h1 {
    font-size: 1.25rem;
}

.content-wrapper {
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Page Header */
.page-header {
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    letter-spacing: -0.02em;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.stat-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--accent-color);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    color: var(--bg-primary);
}

.stat-content h3 {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.02em;
}

/* Content Card */
.content-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    transition: var(--transition);
    box-shadow: var(--shadow);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* Table */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.table-header-left {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.table-header-right {
    display: flex;
    align-items: center;
}

.table-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}


.sort-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.sort-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.pagination-info {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.sortable:hover {
    background: var(--highlight-color);
}

.sortable::after {
    content: '↕';
    position: absolute;
    right: 0.5rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.table-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
}

.btn-link {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    font-weight: 500;
}

.btn-link:hover {
    color: var(--primary-color);
}

.table-wrapper {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.data-table {
    width: 100%;
    min-width: 1580px;
    border-collapse: collapse;
    font-size: 0.8125rem;
    table-layout: fixed;
}

.data-table thead th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 10;
}

/* Фиксированные ширины столбцов */
.data-table thead th:nth-child(1) { 
    width: 140px; 
    position: sticky;
    left: 0;
    z-index: 20;
    background: var(--bg-primary);
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
}

.data-table thead th:nth-child(2) { 
    width: 180px; 
    position: sticky;
    left: 140px;
    z-index: 20;
    background: var(--bg-primary);
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
}


/* Ховер эффекты для заголовков закрепленных столбцов */
.data-table tbody tr:hover td:nth-child(1),
.data-table tbody tr:hover td:nth-child(2) {
    background: var(--highlight-color) !important;
    z-index: 6;
}

.data-table tbody td:nth-child(1) {
    position: sticky;
    left: 0;
    background: var(--bg-primary);
    z-index: 5;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
}

.data-table tbody td:nth-child(2) {
    position: sticky;
    left: 140px;
    background: var(--bg-primary);
    z-index: 5;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
    width: 180px;
}


/* Ширины столбцов для главной страницы */
.data-table thead th:nth-child(3) { width: 160px; } /* ФИО (настоящее) */
.data-table thead th:nth-child(4) { width: 120px; } /* Дата рождения */
.data-table thead th:nth-child(5) { width: 130px; } /* Телефон */
.data-table thead th:nth-child(6) { width: 90px; }  /* Согласие ПДН */
.data-table thead th:nth-child(7) { width: 90px; }  /* Выгружен в 1С */
.data-table thead th:nth-child(8) { width: 180px; } /* Бонусный баланс */
.data-table thead th:nth-child(9) { width: 180px; } /* История покупок */
.data-table thead th:nth-child(10) { width: 180px; } /* Последнее обновление */
.data-table thead th:nth-child(11) { width: 180px; } /* Дата регистрации */

.data-table tbody td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr {
    /* transition: var(--transition); - убрано для мгновенного ховера */
}

.data-table tbody tr:hover {
    background: var(--highlight-color);
}

.data-table code {
    background: var(--highlight-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8125rem;
    font-family: 'Monaco', 'Courier New', monospace;
    color: var(--text-secondary);
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.text-danger {
    color: #dc3545;
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
}

.status-yes {
    background: #000000;
    color: #ffffff;
}

.status-no {
    background: #e5e5e5;
    color: #999999;
}

/* Data states */
.no-data {
    color: #cccccc;
    font-style: italic;
    font-size: 0.8125rem;
}

.contact-value {
    color: var(--text-primary);
}

/* Compact Info */
.compact-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-primary {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.8125rem;
}

.info-secondary {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.info-warning {
    font-size: 0.75rem;
    color: #f59e0b;
    font-weight: 500;
}

.info-success {
    font-size: 0.75rem;
    color: #10b981;
    font-weight: 500;
}

.info-danger {
    font-size: 0.75rem;
    color: #ef4444;
    font-weight: 500;
}

.loading-spinner {
    padding: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.spinner {
    width: 40px;
    height: 40px;
    position: relative;
}

.spinner::before,
.spinner::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    inset: 0;
}

.spinner::before {
    border-top-color: var(--primary-color);
    animation: spin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.spinner::after {
    border-top-color: var(--accent-color);
    animation: spin 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    animation-delay: 0.2s;
}

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

.spinner-text {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Table Row Animation */
.data-table tbody tr {
    animation: fadeInUp 0.5s ease-out backwards;
}

.data-table tbody tr:nth-child(1) {
    animation-delay: 0.05s;
}

.data-table tbody tr:nth-child(2) {
    animation-delay: 0.1s;
}

.data-table tbody tr:nth-child(3) {
    animation-delay: 0.15s;
}

.data-table tbody tr:nth-child(4) {
    animation-delay: 0.2s;
}

.data-table tbody tr:nth-child(5) {
    animation-delay: 0.25s;
}

.data-table tbody tr:nth-child(6) {
    animation-delay: 0.3s;
}

.data-table tbody tr:nth-child(7) {
    animation-delay: 0.35s;
}

.data-table tbody tr:nth-child(8) {
    animation-delay: 0.4s;
}

.data-table tbody tr:nth-child(9) {
    animation-delay: 0.45s;
}

.data-table tbody tr:nth-child(10) {
    animation-delay: 0.5s;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    /* Общие улучшения для мобильных */
    body {
        overflow-x: hidden;
        overflow-y: auto !important;
        height: auto !important;
    }
    
    .wrapper {
        overflow-x: hidden;
        overflow-y: visible !important;
        height: auto !important;
        min-height: 100vh;
    }
    
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
        z-index: 1000;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .mobile-header {
        display: flex;
        padding: 0.75rem 1rem;
    }
    
    .mobile-header h2 {
        font-size: 1.25rem;
    }

    .content-wrapper {
        padding: 0.5rem;
        overflow-x: hidden;
        overflow-y: visible;
        height: auto;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .page-header {
        padding: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .data-table {
        font-size: 0.75rem;
    }
    
    .data-table thead th,
    .data-table tbody td {
        padding: 0.75rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Скрываем некоторые колонки на мобильных */
    .data-table thead th:nth-child(2),
    .data-table tbody td:nth-child(2),
    .data-table thead th:nth-child(4),
    .data-table tbody td:nth-child(4),
    .data-table thead th:nth-child(5),
    .data-table tbody td:nth-child(5),
    .data-table thead th:nth-child(6),
    .data-table tbody td:nth-child(6),
    .data-table thead th:nth-child(8),
    .data-table tbody td:nth-child(8),
    .data-table thead th:nth-child(9),
    .data-table tbody td:nth-child(9),
    .data-table thead th:nth-child(10),
    .data-table tbody td:nth-child(10) {
        display: none;
    }
    
    .compact-info {
        gap: 0.125rem;
    }
    
    .info-primary {
        font-size: 0.75rem;
    }
    
    .info-secondary {
        font-size: 0.6875rem;
    }
}


/* Кнопки действий */
.btn-detail {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-detail:hover {
    background: var(--highlight-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}


/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--bg-primary);
    margin: 5% auto;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--highlight-color);
    color: var(--primary-color);
}

.modal-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.stat-card {
    animation: scaleIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

.stat-card:nth-child(1) {
    animation-delay: 0.05s;
}

.stat-card:nth-child(2) {
    animation-delay: 0.1s;
}

.stat-card:nth-child(3) {
    animation-delay: 0.15s;
}

.content-card {
    animation: fadeIn 0.5s ease-out 0.2s backwards;
}

/* Number counter animation */
.stat-value {
    display: inline-block;
    transition: transform 0.3s ease;
}

.stat-card:hover .stat-value {
    transform: scale(1.05);
}

/* Notifications */
.notification-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
}

.notification {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transform: translateX(450px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

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

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

.notification-warning .notification-icon {
    background: #f59e0b;
    color: white;
}

.notification-default .notification-icon {
    background: var(--accent-color);
    color: white;
}

.notification-content {
    flex: 1;
}

.notification-title {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.notification-message {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.notification-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: var(--transition);
    flex-shrink: 0;
}

.notification-close:hover {
    background: var(--highlight-color);
    color: var(--primary-color);
}

@media (max-width: 768px) {
    .notification-container {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
    
    .notification {
        transform: translateY(-100px);
    }
    
    .notification.show {
        transform: translateY(0);
    }
}

