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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f7fa;
    color: #2c3e50;
    line-height: 1.6;
}

/* Страница входа */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: #2c3e50;
    font-size: 1.8rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #34495e;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #667eea;
    color: white;
}

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

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.alert {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

/* Основной layout */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* Боковая панель */
.sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #e1e8ed;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
    height: 100vh;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e1e8ed;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0;
    scrollbar-width: thin;
}

.nav-group {
    margin-bottom: 0.5rem;
}

.nav-group-header {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    color: #2c3e50;
    transition: background 0.2s;
}

.nav-group-header:hover {
    background: #f8f9fa;
}

.nav-group-header .arrow {
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.nav-group.expanded .nav-group-header .arrow {
    transform: rotate(180deg);
}

.nav-group-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.nav-group.expanded .nav-group-content {
    max-height: 500px;
}

.nav-link {
    display: block;
    padding: 0.75rem 1.5rem 0.75rem 2.5rem;
    color: #5a6c7d;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: #f8f9fa;
    color: #667eea;
    border-left-color: #667eea;
}

.nav-link.active {
    background: #f0f4ff;
    color: #667eea;
    border-left-color: #667eea;
    font-weight: 500;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid #e1e8ed;
}

.sidebar-footer .btn {
    width: 100%;
    text-align: center;
}

/* Основной контент */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-x: auto;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
}

.content-header h1 {
    font-size: 1.75rem;
    color: #2c3e50;
    font-weight: 600;
    flex: 1;
}

.content-header .btn {
    white-space: nowrap;
    min-width: auto;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Поиск */
.search-container {
    margin-bottom: 1.5rem;
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.search-wrapper {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.search-column-select {
    padding: 0.5rem;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    font-size: 0.875rem;
    background: white;
    cursor: pointer;
    min-width: 150px;
}

.search-column-select:focus {
    outline: none;
    border-color: #667eea;
}

.search-input {
    flex: 1;
    padding: 0.5rem 1rem;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
}

.search-input::placeholder {
    color: #95a5a6;
}

/* Секция управления файлами */
.files-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e1e8ed;
}

.files-section > label {
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: block;
}

.files-list {
    margin-bottom: 1rem;
}

.files-list-items {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    padding: 0.5rem;
}

.files-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-bottom: 1px solid #f0f0f0;
}

.files-list-item:last-child {
    border-bottom: none;
}

.files-list-item span {
    flex: 1;
    font-size: 0.875rem;
}

.text-muted {
    color: #95a5a6;
    font-size: 0.875rem;
    font-style: italic;
}

.error {
    color: #e74c3c;
    font-size: 0.875rem;
}

/* Контейнер добавления файла */
.add-file-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 6px;
}

.add-file-select {
    flex: 1;
    min-width: 200px;
}

/* Изображения в таблице */
.image-cell {
    padding: 0.5rem !important;
    text-align: center;
}

.image-wrapper {
    position: relative;
    display: inline-block;
}

.table-image {
    max-width: 100px;
    max-height: 100px;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s;
}

.table-image:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.file-url-text {
    font-size: 0.875rem;
    color: #6c757d;
    word-break: break-all;
}

/* Увеличенное изображение при наведении */
.image-preview {
    position: absolute;
    z-index: 10000;
    pointer-events: none;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    padding: 8px;
    width: 600px;
    max-height: 600px;
    border: 2px solid #667eea;
    animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.image-preview-img {
    width: 100%;
    max-height: 584px;
    object-fit: contain;
    display: block;
    border-radius: 4px;
}

.table-wrapper-container {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Dashboard */
.dashboard-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.dashboard-loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    color: #5a6c7d;
}

.dashboard-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    align-items: flex-end;
    margin-bottom: 1rem;
}

.dashboard-filter {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 140px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4rem;
}

.dashboard-cards-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.dashboard-main {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.dashboard-section {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.dashboard-section-spaced {
    margin-top: 1.5rem;
}

.dashboard-section-title {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.75rem;
}

.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.dashboard-table th,
.dashboard-table td {
    padding: 0.5rem;
    border: 1px solid #e1e8ed;
    text-align: center;
}

.dashboard-table thead th {
    background: #f8f9fa;
    font-weight: 600;
}

.dashboard-side {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.dashboard-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    padding: 1rem;
}

.dashboard-card-title {
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #2c3e50;
}

.dashboard-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    color: #5a6c7d;
    font-size: 0.875rem;
}

.dashboard-card-line {
    line-height: 1.4;
}

@media (max-width: 1200px) {
    .dashboard-cards-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .dashboard-cards-row {
        grid-template-columns: 1fr;
    }
}

.table-container {
    background: white;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 250px);
}

.empty-state {
    padding: 4rem 2rem;
    text-align: center;
    color: #95a5a6;
}

.table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 350px);
    flex: 1;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: #f8f9fa;
}

.data-table {
    font-size: 0.875rem;
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    padding: 0.75rem 0.5rem;
    text-align: center;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #e1e8ed;
    white-space: nowrap;
    font-size: 0.875rem;
}

.data-table td {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid #e1e8ed;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
    text-align: center;
}

.data-table tbody tr {
    transition: background 0.2s;
}

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

.data-table thead {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 10;
}

.actions {
    white-space: nowrap;
}

/* Пагинация */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e1e8ed;
    background: #f8f9fa;
    flex-wrap: wrap;
    gap: 1rem;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.pagination-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #5a6c7d;
    font-size: 0.875rem;
}

.rows-select {
    padding: 0.5rem;
    border: 1px solid #e1e8ed;
    border-radius: 4px;
    font-size: 0.875rem;
    background: white;
    cursor: pointer;
}

.rows-select:focus {
    outline: none;
    border-color: #667eea;
}

.pagination-buttons {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.pagination-buttons button:disabled,
.pagination-buttons button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.pagination-buttons button:disabled:hover,
.pagination-buttons button.disabled:hover {
    background: #95a5a6;
    transform: none;
    box-shadow: none;
}

#current-page-info {
    color: #5a6c7d;
    font-size: 0.875rem;
    min-width: 120px;
    text-align: center;
}

.btn-icon {
    background: none;
    border: 1px solid #ddd;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.35rem 0.5rem;
    margin: 0 0.2rem;
    border-radius: 4px;
    transition: all 0.2s;
    color: #555;
    font-weight: bold;
    min-width: 30px;
    text-align: center;
    line-height: 1;
}

.btn-icon:hover {
    transform: scale(1.1);
}

.btn-edit {
    background: #e3f2fd;
    color: #1976d2;
    border-color: #1976d2;
}

.btn-edit:hover {
    background: #1976d2;
    color: white;
    border-color: #1976d2;
}

.btn-delete {
    background: #ffebee;
    color: #d32f2f;
    border-color: #d32f2f;
}

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

.btn-duplicate {
    background: #f3e5f5;
    color: #7b1fa2;
    border-color: #7b1fa2;
}

.btn-duplicate:hover {
    background: #7b1fa2;
    color: white;
    border-color: #7b1fa2;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

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

.modal-header h2 {
    font-size: 1.5rem;
    color: #2c3e50;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #95a5a6;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.modal-close:hover {
    background: #f0f0f0;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-body .form-group {
    margin-bottom: 1.25rem;
}

.modal-body .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #34495e;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e1e8ed;
}

/* Индикатор загрузки */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #95a5a6;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Скроллбар */
.sidebar-nav::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
    background: #f8f9fa;
}

.sidebar-nav::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

