* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Навигация */
.navbar {
    background: white;
    border-radius: 15px;
    padding: 15px 25px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
    cursor: pointer;
}

.nav-links {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.nav-link {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    padding: 8px 15px;
    border-radius: 20px;
    transition: all 0.3s;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 1rem;
}

.nav-link:hover {
    background: #f0f0f0;
    color: #667eea;
}

.btn-login, .btn-register, .btn-logout {
    padding: 8px 20px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
    font-size: 1rem;
}

.btn-login {
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-login:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.btn-register {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-register:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-logout {
    background: #dc3545;
    color: white;
}

.btn-logout:hover {
    background: #c82333;
    transform: translateY(-2px);
}

/* Dropdown для админ-меню */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.dropdown-toggle::after {
    content: '▼';
    font-size: 10px;
    transition: transform 0.3s;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 5px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    z-index: 1000;
    overflow: hidden;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    display: block;
    padding: 12px 16px;
    text-decoration: none;
    color: #333;
    transition: background 0.2s;
    cursor: pointer;
    font-size: 0.95rem;
    width: 100%;
    text-align: left;
    border: none;
    background: none;
}

.dropdown-item:hover {
    background: #f5f5f5;
    color: #667eea;
}

/* Герой секция */
.hero {
    background: white;
    border-radius: 20px;
    padding: 60px 50px;
    text-align: center;
    margin-bottom: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 15px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1.2rem;
    color: #6c757d;
    margin-bottom: 40px;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 50px;
    flex-wrap: wrap;
}

.stat {
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    color: #6c757d;
}

/* Секции */
.section-title {
    text-align: center;
    margin: 40px 0 30px;
    font-size: 2rem;
    color: white;
}

/* Сетки */
.features-grid, .cars-grid, .blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.feature-card, .car-card, .blog-card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    transition: transform 0.3s;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.feature-card:hover, .car-card:hover, .blog-card:hover {
    transform: translateY(-5px);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.car-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.car-header h3 {
    margin: 0;
}

.year {
    color: #6c757d;
}

.car-details p {
    margin: 8px 0;
    font-size: 14px;
}

.car-actions, .to-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

/* Статистика */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    color: #6c757d;
    margin-top: 5px;
}

/* Действия */
.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.action-card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    text-align: center;
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s;
    cursor: pointer;
}

.action-card:hover {
    transform: translateY(-5px);
}

.action-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

/* Таблицы */
.table-container {
    background: white;
    border-radius: 15px;
    overflow-x: auto;
    padding: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    font-weight: 600;
}

/* Кнопки */
.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
}

.btn-small {
    padding: 6px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background: #28a745;
    color: white;
    font-size: 0.9rem;
}

.btn-small.danger {
    background: #dc3545;
}

.btn-small.skip {
    background: #6c757d;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    margin: 0 5px;
}

/* Модальные окна */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: 15px;
    padding: 30px;
    width: 90%;
    max-width: 500px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal .close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
}

/* Формы */
.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .half {
    flex: 1;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Поиск с выпадающим списком */
.search-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.dropdown-list .dropdown-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.dropdown-list .dropdown-item:hover {
    background: #f5f5f5;
}

.model-years {
    font-size: 12px;
    color: #6c757d;
    margin-left: 8px;
}

/* Уведомления */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 10px;
    color: white;
    font-weight: 500;
    z-index: 2000;
    animation: slideInRight 0.3s ease;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification.success {
    background: #28a745;
}

.notification.error {
    background: #dc3545;
}

.notification.info {
    background: #17a2b8;
}

/* Статусы ТО */
.to-card {
    border-left: 5px solid #6c757d;
}

.to-card.overdue {
    border-left-color: #dc3545;
    background: #fff5f5;
}

.to-card.upcoming {
    border-left-color: #ffc107;
}

.to-card.completed {
    border-left-color: #28a745;
    opacity: 0.7;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    background: #e9ecef;
}

.to-card.overdue .status-badge {
    background: #dc3545;
    color: white;
}

.to-card.upcoming .status-badge {
    background: #ffc107;
    color: #856404;
}

/* Предупреждение */
.alert {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    color: #856404;
}

.no-data {
    text-align: center;
    padding: 50px;
    background: white;
    border-radius: 15px;
    color: #6c757d;
}

.filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.cta {
    text-align: center;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 50px;
    border-radius: 20px;
    margin-top: 40px;
}

.cta h2 {
    margin-bottom: 20px;
}

.text-muted {
    color: #6c757d;
}

@media (max-width: 768px) {
    .hero h1 {
        font-size: 2rem;
    }
    .hero {
        padding: 40px 20px;
    }
    .stats {
        gap: 30px;
    }
    .features-grid, .cars-grid {
        grid-template-columns: 1fr;
    }
    .form-row {
        flex-direction: column;
        gap: 20px;
    }
}
.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.form-row .half {
    flex: 1;
}

.form-group select {
    cursor: pointer;
    background-color: white;
}

select#car-category {
    font-weight: normal;
}

select#car-category option[value=""] {
    color: #999;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: #666;
    transition: all 0.3s;
}

.tab-btn.active {
    color: #667eea;
    border-bottom: 2px solid #667eea;
}

.tab-btn:hover {
    color: #667eea;
}

.template-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 15px;
}

.template-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
}

.template-item:hover {
    background: #f5f5f5;
}

.template-item.selected {
    background: #e8eaf6;
    border-left: 3px solid #667eea;
}

.template-item strong {
    display: block;
    margin-bottom: 5px;
}

.template-interval {
    font-size: 0.85rem;
    color: #666;
}

.calendar-widget {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-top: 30px;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card.danger .stat-value { color: #dc3545; }
.stat-card.warning .stat-value { color: #ffc107; }
.stat-card.info .stat-value { color: #17a2b8; }
.stat-card.success .stat-value { color: #28a745; }

.to-reminders {
    margin-bottom: 30px;
}

.reminder-section {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 10px;
}

.reminder-section.overdue {
    background: #fff5f5;
    border-left: 4px solid #dc3545;
}

.reminder-section.upcoming {
    background: #fff9e6;
    border-left: 4px solid #ffc107;
}

.reminder-section ul {
    list-style: none;
    padding: 0;
}

.reminder-section li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
    gap: 10px;
}

.calendar-months {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.month-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
}

.month-card h4 {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.events-list {
    max-height: 300px;
    overflow-y: auto;
}

.event-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.event-item.planned.overdue { background: #fff0f0; }
.event-item.planned .event-title { color: #ffc107; }
.event-item.maintenance .event-title { color: #28a745; }
.event-item.fuel .event-title { color: #17a2b8; }

.event-date {
    width: 30px;
    font-weight: bold;
    color: #667eea;
}

.event-title {
    flex: 1;
}

.event-car {
    color: #6c757d;
    font-size: 0.8rem;
}

.maintenance-table .description-cell {
    max-width: 250px;
    word-wrap: break-word;
    cursor: help;
}

.description-box {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    margin-top: 5px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.chart-controls {
    margin: 20px 0;
    display: flex;
    align-items: center;
    gap: 15px;
}

.chart-controls select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.chart-container {
    margin-top: 20px;
    min-height: 400px;
}

.stats-widget {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-top: 30px;
}

.stat-card.primary .stat-value {
    color: #667eea;
}

.stat-card.success .stat-value {
    color: #28a745;
}

/* Дополнительная мобильная адаптация для виджетов */
@media (max-width: 768px) {
    /* Статистика - 2 столбца */
    .stats-summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    /* Статистика на очень маленьких экранах - 1 столбец */
    @media (max-width: 480px) {
        .stats-summary {
            grid-template-columns: 1fr;
        }
    }

    /* Карточки статистики */
    .stat-card {
        padding: 10px !important;
        margin: 0 !important;
    }

    .stat-value {
        font-size: 1rem !important;
    }

    .stat-label {
        font-size: 0.65rem !important;
    }

    /* Блок просроченных ТО */
    .to-reminders {
        overflow-x: auto;
    }

    .reminder-section {
        padding: 10px;
        margin-bottom: 10px;
    }

    .reminder-section li {
        flex-wrap: wrap;
        gap: 8px;
    }

    .reminder-section .btn-small {
        padding: 4px 8px;
        font-size: 0.7rem;
    }

    /* Календарь */
    .calendar-months {
        grid-template-columns: 1fr;
    }

    .month-card {
        padding: 10px;
    }

    /* График */
    .chart-container {
        min-height: 200px;
        overflow-x: auto;
    }

    .chart-container canvas {
        min-width: 400px;
    }

    /* Контейнер */
    .container {
        padding: 8px;
    }

    /* Заголовки */
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.2rem;
    }

    h3 {
        font-size: 1rem;
    }

    /* Таблицы */
    .table-container {
        overflow-x: auto;
    }

    table {
        font-size: 0.8rem;
    }

    th, td {
        padding: 6px 8px;
    }

    /* Кнопки действий */
    .to-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
    }

    .to-actions .btn-small {
        flex: 1;
        min-width: 80px;
        text-align: center;
    }

    /* Сетка действий */
    .actions-grid {
        gap: 8px;
    }

    .action-card {
        padding: 10px;
    }

    .action-icon {
        font-size: 1.5rem;
    }

    .action-card h3 {
        font-size: 0.8rem;
    }

    .action-card p {
        font-size: 0.65rem;
    }
}

/* Для экранов до 380px */
@media (max-width: 380px) {
    .stats-summary {
        grid-template-columns: 1fr;
    }

    .stat-value {
        font-size: 0.9rem !important;
    }

    .to-actions {
        flex-direction: column;
    }

    .to-actions .btn-small {
        width: 100%;
    }

    .nav-links {
        gap: 5px;
    }

    .nav-link, .btn-login, .btn-register, .btn-logout {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
}

/* Горизонтальная прокрутка для таблиц на мобильных */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Улучшение для карточек ТО на мобильных */
.to-card {
    margin-bottom: 10px;
}

.to-header {
    flex-wrap: wrap;
}

.to-details p {
    font-size: 0.85rem;
    margin: 5px 0;
}

/* Тёмная тема - расширенная */
body.dark-theme {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.dark-theme .navbar,
body.dark-theme .card,
body.dark-theme .stat-card,
body.dark-theme .action-card,
body.dark-theme .car-card,
body.dark-theme .modal,
body.dark-theme .to-card,
body.dark-theme .calendar-widget,
body.dark-theme .stats-widget,
body.dark-theme .month-card,
body.dark-theme .template-list,
body.dark-theme .dropdown-list,
body.dark-theme .dropdown-menu,
body.dark-theme .table-container,
body.dark-theme .hero,
body.dark-theme .feature-card,
body.dark-theme .blog-card,
body.dark-theme .no-data,
body.dark-theme .reminder-section {
    background: #1e1e2e;
    color: #e0e0e0;
}

body.dark-theme .navbar .logo,
body.dark-theme h1,
body.dark-theme h2,
body.dark-theme h3,
body.dark-theme .stat-value,
body.dark-theme .action-card h3,
body.dark-theme .car-header h3 {
    color: #e0e0e0;
}

body.dark-theme .nav-link,
body.dark-theme .dropdown-item,
body.dark-theme .stat-label,
body.dark-theme .car-details p,
body.dark-theme .to-details p,
body.dark-theme .event-car,
body.dark-theme .event-date {
    color: #b0b0b0;
}

body.dark-theme .nav-link:hover,
body.dark-theme .dropdown-item:hover {
    background: #2a2a3e;
    color: #667eea;
}

body.dark-theme .btn-secondary,
body.dark-theme .btn-small:not(.danger):not(.success):not(.warning) {
    background: #2a2a3e;
    color: #e0e0e0;
}

body.dark-theme input,
body.dark-theme select,
body.dark-theme textarea,
body.dark-theme .search-input,
body.dark-theme .dropdown-list {
    background: #2a2a3e;
    border-color: #3a3a4e;
    color: #e0e0e0;
}

body.dark-theme input::placeholder,
body.dark-theme textarea::placeholder {
    color: #888;
}

body.dark-theme .alert {
    background: #2a2a3e;
    border-color: #3a3a4e;
    color: #e0e0e0;
}

body.dark-theme .alert-danger {
    background: #3a1a1a;
    border-color: #dc3545;
    color: #ffaaaa;
}

body.dark-theme .alert-warning {
    background: #3a3a1a;
    border-color: #ffc107;
    color: #ffffaa;
}

body.dark-theme .no-data {
    background: #1e1e2e;
    color: #888;
}

body.dark-theme table th {
    background: #2a2a3e;
    color: #e0e0e0;
}

body.dark-theme table td {
    border-bottom-color: #3a3a4e;
}

body.dark-theme .to-card.overdue {
    background: #3a1a1a;
}

body.dark-theme .to-card.upcoming {
    background: #3a3a1a;
}

body.dark-theme .status-badge {
    background: #2a2a3e;
    color: #e0e0e0;
}

body.dark-theme .template-item {
    border-bottom-color: #3a3a4e;
}

body.dark-theme .template-item:hover {
    background: #2a2a3e;
}

body.dark-theme .template-item.selected {
    background: #2a2a4e;
}

body.dark-theme .stat-card.danger .stat-value { color: #ff6b6b; }
body.dark-theme .stat-card.warning .stat-value { color: #ffd93d; }
body.dark-theme .stat-card.info .stat-value { color: #6bcbff; }
body.dark-theme .stat-card.success .stat-value { color: #6bcb77; }
body.dark-theme .stat-card.primary .stat-value { color: #667eea; }

body.dark-theme .theme-switch {
    background: #1e1e2e;
    color: #ffd93d;
    border: 1px solid #3a3a4e;
}

body.dark-theme .chart-container canvas {
    filter: brightness(0.8);
}

.theme-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 8px 12px;
    border-radius: 20px;
    transition: all 0.3s;
    background: #f0f0f0;
}

.theme-btn:hover {
    transform: scale(1.1);
    background: #e0e0e0;
}

body.dark-theme .theme-btn {
    background: #2a2a3e;
    color: #ffd93d;
}

body.dark-theme .theme-btn:hover {
    background: #3a3a4e;
}