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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: #1a1a1a;
    background-color: #ffffff;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Navbar */
.navbar {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 1.2rem 0;
    margin-bottom: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand a {
    color: white;
    text-decoration: none;
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.nav-menu {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.nav-menu a:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 6px;
}

.nav-user {
    color: #ecf0f1;
    font-size: 0.9rem;
}

/* Messages */
.messages {
    margin-bottom: 1rem;
}

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

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(30, 60, 114, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2a5298 0%, #3d6bb3 100%);
    box-shadow: 0 4px 12px rgba(30, 60, 114, 0.4);
    transform: translateY(-1px);
}

.btn-success {
    background-color: #28a745;
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.btn-success:hover {
    background-color: #218838;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
    transform: translateY(-1px);
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-warning {
    background-color: #ffc107;
    color: #1a1a1a;
    border: none;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

.btn-warning:hover {
    background-color: #e0a800;
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.4);
    transform: translateY(-1px);
}

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

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

.btn-info {
    background-color: #17a2b8;
    color: white;
}

.btn-info:hover {
    background-color: #138496;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.btn-large {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
}

/* Forms */
.form {
    background: white;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    max-width: 600px;
    margin: 0 auto;
    border: 1px solid #e8e8e8;
}

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

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

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.875rem;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.form-group input[type="text"]:focus,
.form-group input[type="email"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="number"]:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2a5298;
    box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group input[type="checkbox"],
.form-group input[type="radio"] {
    width: auto;
    margin-right: 0.5rem;
}

/* Login */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

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

.login-box h1 {
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Tables */
.table {
    width: 100%;
    background: white;
    border-collapse: collapse;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid #e8e8e8;
}

.table thead {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

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

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.dashboard-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid #e8e8e8;
    transition: transform 0.3s, box-shadow 0.3s;
}

.dashboard-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 30px rgba(0,0,0,0.12);
}

.dashboard-card h2 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

/* Test List */
.test-list {
    list-style: none;
}

.test-item {
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.test-item h3 {
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.test-meta {
    display: flex;
    gap: 1rem;
    margin: 0.5rem 0;
    font-size: 0.9rem;
    color: #666;
}

/* Test Taking */
.test-header {
    margin-bottom: 2rem;
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.test-header h1 {
    margin-bottom: 1rem;
}

.test-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.question-counter {
    background-color: #3498db;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-weight: bold;
    font-size: 1.1rem;
}

.timer {
    background-color: #e74c3c;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-weight: bold;
    font-size: 1.1rem;
}

.question-block {
    background: white;
    padding: 2rem;
    margin-bottom: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid #e8e8e8;
    transition: box-shadow 0.3s;
}

.question-block:hover {
    box-shadow: 0 6px 30px rgba(0,0,0,0.12);
}

.question-text {
    font-size: 1.1rem;
    margin: 1rem 0;
    line-height: 1.8;
}

.answers-list {
    margin-top: 1rem;
}

.answer-option {
    display: block;
    padding: 1rem 1.25rem;
    margin: 0.75rem 0;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    background-color: #fafafa;
}

.answer-option:hover {
    border-color: #2a5298;
    background-color: #f0f4ff;
    transform: translateX(5px);
}

.answer-option input[type="radio"]:checked + span,
.answer-option input[type="checkbox"]:checked + span {
    font-weight: bold;
    color: #3498db;
}

.answer-option input[type="radio"]:checked ~ .answer-option,
.answer-option input[type="checkbox"]:checked ~ .answer-option {
    border-color: #3498db;
}

.test-submit {
    text-align: center;
    margin: 2rem 0;
}

/* Test Result */
.result-summary {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.score-box {
    text-align: center;
    padding: 2rem;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 1rem 0;
}

.score {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.percentage {
    font-size: 2rem;
    color: #3498db;
}

.questions-review {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.question-review {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #ddd;
}

.question-review:last-child {
    border-bottom: none;
}

.answer-review {
    padding: 1rem;
    border-radius: 4px;
    margin-top: 1rem;
}

.answer-review.correct {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
}

.answer-review.incorrect {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

.badge-success {
    background-color: #27ae60;
    color: white;
}

.badge-danger {
    background-color: #e74c3c;
    color: white;
}

/* Info boxes */
.info-box {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.info-box ul {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
}

.warning-box {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1.5rem 0;
}

.test-info {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
}

.test-info p {
    margin: 0.5rem 0;
}

.test-edit-container {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
}

.stats-list {
    list-style: none;
}

.stats-list li {
    padding: 0.5rem 0;
    font-size: 1.1rem;
}

/* Footer */
footer {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

/* User assignment */
.users-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    background-color: #fafafa;
    margin: 1rem 0;
}

.user-checkbox {
    display: block;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background-color: #ffffff;
    cursor: pointer;
    transition: all 0.3s;
}

.user-checkbox:hover {
    background-color: #f0f4ff;
    border-color: #2a5298;
}

.user-checkbox input[type="checkbox"] {
    margin-right: 0.75rem;
}

.current-image {
    margin: 1rem 0;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.current-image img {
    display: block;
    margin: 10px 0;
    border-radius: 6px;
}

.answer-item {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.answer-item input[type="text"] {
    flex: 1;
}

/* Test taking - step by step */
.test-container {
    max-width: 1400px;
    margin: 0 auto;
}

.test-content-wrapper {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    margin-top: 1rem;
}

.test-main-content {
    min-width: 0; /* Для правильной работы grid */
}

.test-sidebar {
    position: sticky;
    top: 20px;
    height: fit-content;
}

.statistics-panel {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid #e8e8e8;
}

.statistics-panel h4 {
    margin-bottom: 1rem;
    color: #2c3e50;
    text-align: center;
}

.questions-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 5px;
}

.question-square {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.question-square.answered {
    background-color: #27ae60;
    color: white;
}

.question-square.unanswered {
    background-color: #95a5a6;
    color: white;
}

.question-square.current {
    border-color: #2a5298;
    box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.3);
    transform: scale(1.1);
}

.question-square.marked {
    background-color: #e74c3c !important;
    color: white;
    border: 2px solid #c0392b;
}

.question-square.marked.answered {
    background: linear-gradient(135deg, #27ae60 0%, #27ae60 50%, #e74c3c 50%, #e74c3c 100%);
    position: relative;
    border: 2px solid #c0392b;
}

.question-square.marked.answered::before {
    content: '✓';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.7rem;
    color: white;
    text-shadow: 0 0 2px rgba(0,0,0,0.5);
}

.question-square:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.legend {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e8e8e8;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.legend-square {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: inline-block;
}

.legend-square.answered {
    background-color: #27ae60;
}

.legend-square.unanswered {
    background-color: #95a5a6;
}

.legend-square.current {
    background-color: #2a5298;
    border: 2px solid #2a5298;
}

.legend-square.marked {
    background-color: #e74c3c;
    border: 2px solid #c0392b;
}

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

.mark-question-flag {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-left: 1rem;
    user-select: none;
}

.mark-question-flag input[type="checkbox"] {
    display: none;
}

.flag-icon {
    font-size: 24px;
    transition: all 0.3s;
    display: inline-block;
    filter: grayscale(100%) opacity(0.5);
    line-height: 1;
}

.mark-question-flag input[type="checkbox"]:checked ~ .flag-icon,
.flag-icon.marked {
    filter: grayscale(0%) opacity(1);
    transform: scale(1.2);
}

.mark-question-flag:hover .flag-icon {
    transform: scale(1.15);
    filter: grayscale(50%) opacity(0.8);
}

.mark-question-flag input[type="checkbox"]:checked ~ .flag-icon:hover,
.flag-icon.marked:hover {
    transform: scale(1.3);
    filter: grayscale(0%) opacity(1);
}

.question-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid #e8e8e8;
}

.btn-block {
    width: 100%;
    display: block;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.pagination .btn {
    margin: 0;
}

/* Responsive */
@media (max-width: 1024px) {
    .test-content-wrapper {
        grid-template-columns: 1fr;
    }
    
    .test-sidebar {
        position: relative;
        top: 0;
    }
    
    .questions-grid {
        grid-template-columns: repeat(8, 1fr);
    }
}

@media (max-width: 768px) {
    .test-edit-container {
        grid-template-columns: 1fr;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .nav-menu {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .test-header-info {
        flex-direction: column;
        align-items: stretch;
    }
    
    .question-counter,
    .timer {
        width: 100%;
        text-align: center;
    }
    
    .test-content-wrapper {
        grid-template-columns: 1fr;
    }
    
    .questions-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .question-square {
        width: 35px;
        height: 35px;
        font-size: 0.8rem;
    }
}
