:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --light: #f8fafc;
    --dark: #1e293b;
    --gray: #64748b;
    --border: #e2e8f0;
    --sidebar-bg: #ffffff;
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 60px;
    --header-height: 60px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f1f5f9;
    color: var(--dark);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    width: calc(100% - var(--sidebar-width));
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    transition: margin-left 0.3s ease, width 0.3s ease;
    margin-left: var(--sidebar-width);
}

/* Header */
.header {
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    margin-left: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Menu buttons */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--dark);
}

.desktop-menu-btn {
    display: block;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--dark);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.desktop-menu-btn:hover {
    background-color: rgba(37, 99, 235, 0.1);
}

/* Sidebar menu */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: var(--sidebar-bg);
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 999;
    transform: translateX(0);
    transition: all 0.3s ease-in-out;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid var(--border);
}

.sidebar.hidden {
    transform: translateX(-100%);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-nav {
    padding: 1rem 0;
    transition: padding 0.3s ease;
}

.sidebar.collapsed .sidebar-nav {
    padding: 0.5rem 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    text-decoration: none;
    color: var(--gray);
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    font-weight: 500;
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-nav a {
    padding: 1rem;
    justify-content: center;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
    border-left: 3px solid var(--primary);
}

.sidebar.collapsed .sidebar-nav a:hover,
.sidebar.collapsed .sidebar-nav a.active {
    border-left: none;
    border-right: 3px solid var(--primary);
}

.menu-icon {
    margin-right: 0.75rem;
    font-size: 1.1rem;
    min-width: 24px;
    text-align: center;
}

.sidebar.collapsed .menu-icon {
    margin-right: 0;
    font-size: 1.2rem;
}

.menu-text {
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .menu-text {
    opacity: 0;
    width: 0;
    height: 0;
    overflow: hidden;
    position: absolute;
}

/* Cards */
.card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark);
    margin: 0;
}

/* Objects */
.object-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.object-card {
    border: 2px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    background: white;
    cursor: pointer;
    min-height: 280px;
    display: flex;
    flex-direction: column;
}

.object-card.maintained {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.05);
}

.object-card.not_maintained {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
}

.object-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dark);
}

.object-address {
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.object-description {
    color: var(--gray);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    line-height: 1.4;
    flex-grow: 1;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.object-type {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.type-monthly {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.type-quarterly {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.maintenance-status {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.status-maintained {
    background: var(--success);
}

.status-not_maintained {
    background: var(--danger);
}

.maintenance-btn {
    width: 100%;
    margin-top: auto;
}

/* Requests */
.request-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.request-card {
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.request-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dark);
}

.request-description {
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.request-object {
    font-size: 0.85rem;
    color: var(--gray);
    margin-bottom: 0.5rem;
}

.request-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.request-date {
    font-size: 0.8rem;
    color: var(--gray);
    margin-bottom: 1rem;
}

.request-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.table th {
    background: var(--primary);
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 500;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover {
    background: rgba(37, 99, 235, 0.05);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.stat-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--gray);
    font-size: 0.9rem;
}

.stat-total { border-top: 4px solid var(--primary); }
.stat-maintained { border-top: 4px solid var(--success); }
.stat-not-maintained { border-top: 4px solid var(--danger); }

/* Status indicators */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-in-progress { background: rgba(59, 130, 246, 0.1); color: var(--info); }
.status-urgent { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.status-pending { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.status-completed { background: rgba(16, 185, 129, 0.1); color: var(--success); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    text-align: center;
    font-size: 0.9rem;
    border: none;
    outline: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid var(--warning);
    color: var(--warning);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 0.75rem;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray);
}

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* Map */
.map-container {
    width: 100%;
    height: 500px;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    overflow: hidden;
}

.map-legend {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.legend-color.red { background-color: #ff0000; }
.legend-color.green { background-color: #00ff00; }

/* Search and filters */
.search-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
}

.filter-select {
    min-width: 150px;
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive design - МОБИЛЬНАЯ ВЕРСИЯ ИСПРАВЛЕНА */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }
    
    .desktop-menu-btn {
        display: none !important;
    }
    
    /* ФИКС: Убрано margin-left и исправлена ширина */
    .container {
        margin-left: 0 !important;
        padding: 1rem;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }
    
    .sidebar:not(.hidden) {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        width: var(--sidebar-width) !important;
    }
    
    .sidebar-nav a {
        justify-content: flex-start !important;
        padding: 1rem 1.5rem !important;
    }
    
    .menu-icon {
        margin-right: 0.75rem !important;
    }
    
    .menu-text {
        opacity: 1 !important;
        width: auto !important;
        height: auto !important;
        position: static !important;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .object-grid,
    .request-grid {
        grid-template-columns: 1fr;
    }
    
    .card-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .search-filters {
        flex-direction: column;
    }
    
    .search-input,
    .filter-select {
        width: 100%;
    }
    
    .modal-content {
        width: 95%;
        padding: 1.5rem;
        margin: 1rem;
        max-height: 80vh;
    }
    
    .map-container {
        height: 400px;
    }
    
    .user-info span {
        display: none;
    }
    
    .user-info span:first-child {
        display: inline;
    }
    
    .object-card {
        min-height: 250px;
        margin: 0 0.5rem;
    }
    
    /* ФИКС: Выравнивание заголовков в мобильной версии */
    h1, h2, h3 {
        text-align: center;
        margin: 0.5rem 0;
    }
    
    /* ФИКС: Карточки не прилипают к краям */
    .card {
        margin: 0.5rem;
        padding: 1rem;
    }
    
    /* ФИКС: Кнопки в мобильной версии */
    .btn {
        width: 100%;
        margin: 0.25rem 0;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.5rem;
    }
    
    .card {
        padding: 1rem;
        margin: 0.5rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
    
    .map-container {
        height: 300px;
    }
    
    .object-name {
        font-size: 1rem;
    }
    
    .object-address {
        font-size: 0.85rem;
    }
    
    .object-description {
        font-size: 0.8rem;
        -webkit-line-clamp: 2;
    }
    
    .header {
        padding: 0 0.5rem;
    }
    
    .logo {
        font-size: 1.25rem;
        margin-left: 0;
    }
    
    .object-card {
        min-height: 220px;
        padding: 1rem;
        margin: 0.5rem;
    }
    
    /* ФИКС: Улучшенное отображение на очень маленьких экранах */
    body {
        font-size: 14px;
    }
    
    .card-title {
        font-size: 1.1rem;
    }
}

/* Бейджи */
.badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Адаптивные виды */
.mobile-view {
    display: none;
}

.desktop-view {
    display: block;
}

@media (max-width: 768px) {
    .mobile-view {
        display: grid;
    }
    
    .desktop-view {
        display: none;
    }
    
    .request-grid.mobile-view {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .request-card {
        padding: 1rem;
        margin: 0.5rem;
    }
    
    .request-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 0.5rem;
    }
    
    .request-title {
        font-size: 1rem;
        margin-bottom: 0;
        flex: 1;
        margin-right: 0.5rem;
    }
    
    .request-status {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
    
    .request-details {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }
    
    .request-actions {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .status-form {
        width: 100%;
    }
    
    .status-form select {
        width: 100%;
    }
}

/* Стили для карточек заявок */
.request-details {
    margin-bottom: 1rem;
}

.request-details > div {
    margin-bottom: 0.25rem;
}

.request-creator {
    font-size: 0.8rem;
    color: var(--gray);
}

/* Стили для карточек объектов в админке */
.object-info {
    font-size: 0.8rem;
    color: var(--gray);
    margin-bottom: 0.5rem;
}

.object-info > div {
    margin-bottom: 0.25rem;
}

.object-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.object-actions .btn {
    width: 100%;
}

/* Форма поиска в админке */
.search-filters {
    display: grid;
    grid-template-columns: 1fr auto auto auto auto;
    gap: 0.5rem;
    align-items: end;
}

@media (max-width: 768px) {
    .search-filters {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

/* Подтверждения действий */
.confirmation-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.confirmation-actions .btn {
    flex: 1;
}

/* Стили для отчетов */
.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.report-card {
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.report-object-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dark);
}

.report-object-address {
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.report-object-type {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.report-last-maintenance {
    font-size: 0.8rem;
    color: var(--gray);
    margin-bottom: 1rem;
}

/* Стили для карточек отчетов на мобильных */
@media (max-width: 768px) {
    .report-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0.5rem;
    }
    
    .report-card {
        padding: 1rem;
        margin: 0.5rem;
    }
}

/* Улучшенные стили для меню на ПК */
@media (min-width: 769px) {
    .sidebar {
        transition: width 0.3s ease, transform 0.3s ease;
    }
    
    .container {
        transition: margin-left 0.3s ease, width 0.3s ease;
    }
    
    /* Фиксированная ширина контейнера при свернутом меню */
    .sidebar.collapsed ~ .container {
        margin-left: 60px;
        width: calc(100% - 60px);
    }
    
    /* Фиксированная ширина контейнера при развернутом меню */
    .sidebar:not(.collapsed) ~ .container {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }
}

/* Улучшенные стили для предотвращения скачков */
.sidebar, .container {
    transition: all 0.3s ease;
}

/* Убираем скачки при изменении размера окна */
body {
    overflow-x: hidden;
}

/* ФИКС: Центрирование контента на мобильных */
@media (max-width: 768px) {
    .container > * {
        margin-left: auto;
        margin-right: auto;
        max-width: 100%;
    }
    
    /* Центрирование текста в мобильной версии */
    .card-header,
    .form-group,
    .search-filters {
        text-align: center;
    }
    
    /* Выравнивание кнопок по центру */
    .btn {
        margin: 0.25rem auto;
    }
}

/* ФИКС: Убираем горизонтальный скролл на мобильных */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        width: 100%;
    }
    
    .container {
        overflow-x: hidden;
    }
}

/* ФИКС: Правильное отображение карточек на мобильных */
@media (max-width: 768px) {
    .object-grid,
    .request-grid,
    .report-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0.5rem;
    }
    
    .object-card,
    .request-card,
    .report-card {
        margin: 0;
        width: 100%;
    }
}