* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    color: #333;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* ============================================
   ХЕДЕР (исправлена контрастность)
   ============================================ */
.header {
    background: linear-gradient(135deg, #1a3a5c, #0f2a44);
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.header h1 {
    color: white !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    font-weight: 600;
    letter-spacing: 0.5px;
    margin: 0;
    font-size: 1.8rem;
}
.user-info {
    background: rgba(255,255,255,0.15);
    padding: 8px 15px;
    border-radius: 40px;
    backdrop-filter: blur(4px);
    font-weight: 500;
    color: white;
}
.user-info a {
    color: white;
    text-decoration: none;
}
.logout, .back-link {
    color: white;
    text-decoration: none;
    margin-left: 15px;
    padding: 5px 12px;
    background: rgba(255,255,255,0.2);
    border-radius: 30px;
    transition: all 0.2s;
    font-weight: 500;
}
.logout:hover, .back-link:hover {
    background: rgba(255,255,255,0.35);
    transform: translateY(-1px);
}

/* ============================================
   НАВИГАЦИЯ
   ============================================ */
.nav {
    background: white;
    padding: 12px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.nav a {
    color: #1a3a5c;
    text-decoration: none;
    padding: 8px 18px;
    border-radius: 40px;
    font-weight: 600;
    transition: all 0.2s;
    background: #f8fafc;
}
.nav a:hover {
    background: #e0e7ff;
    transform: translateY(-1px);
}
.nav a.active {
    background: #1a3a5c;
    color: white;
}

/* ============================================
   ДАШБОРД
   ============================================ */
.dashboard {
    background: white;
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.dashboard h3 {
    margin-bottom: 15px;
    color: #1a3a5c;
}
.dashboard-summary {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.stats {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.stat-card {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 15px 20px;
    border-radius: 16px;
    text-align: center;
    min-width: 120px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.stat-card-large {
    background: #1a3a5c;
    color: white;
    padding: 20px;
    border-radius: 16px;
    text-align: center;
    flex: 1;
    min-width: 180px;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.stat-card-large.regulatory {
    background: linear-gradient(135deg, #ff9800, #f44336);
}
.stat-card-small {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    padding: 12px 20px;
    border-radius: 16px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    flex: 1;
}
.stat-number {
    font-size: 28px;
    font-weight: bold;
}
.stat-label {
    font-size: 12px;
    margin-top: 5px;
    opacity: 0.9;
}
.damage-summary {
    display: flex;
    gap: 15px;
    margin: 15px 0;
    flex-wrap: wrap;
}

/* ============================================
   ФИЛЬТРЫ
   ============================================ */
.filters {
    background: white;
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.filter-form {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.filter-group label {
    font-size: 12px;
    font-weight: bold;
    color: #2c3e50;
}
.filter-group select {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    min-width: 150px;
    background: white;
}
.btn-filter {
    background: #1a3a5c;
    color: white;
    border: none;
    padding: 8px 24px;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}
.btn-filter:hover {
    background: #0f2a44;
    transform: translateY(-1px);
}
.btn-reset {
    background: #6c757d;
    color: white;
    padding: 8px 24px;
    text-decoration: none;
    border-radius: 30px;
    font-weight: 600;
    transition: all 0.2s;
}
.btn-reset:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

/* ============================================
   ТАБЛИЦА ИНЦИДЕНТОВ
   ============================================ */
.table-container {
    background: white;
    border-radius: 16px;
    overflow-x: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.incident-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.incident-table th,
.incident-table td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid #eef2f6;
}
.incident-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #1e293b;
    position: sticky;
    top: 0;
}
.incident-table tbody tr:hover {
    background: #f8fafc;
}
.counter {
    width: 40px;
    text-align: center;
    color: #64748b;
}
.incident-number {
    font-weight: bold;
    color: #1a3a5c;
}
.damage-cell {
    text-align: right;
    font-family: monospace;
    font-weight: bold;
}

/* ============================================
   КОЛОНКА ДЕЙСТВИЯ
   ============================================ */
.actions-cell {
    white-space: nowrap;
    text-align: center;
}
.btn-view, .btn-delete {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    text-decoration: none;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}
.btn-view {
    background: #e0e7ff;
    color: #1a3a5c;
}
.btn-view:hover {
    background: #1a3a5c;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.btn-delete {
    background: #fee2e2;
    color: #dc3545;
    margin-left: 8px;
}
.btn-delete:hover {
    background: #dc3545;
    color: white;
    transform: translateY(-2px);
}

/* ============================================
   БЕЙДЖИ И СТАТУСЫ
   ============================================ */
.operational-category {
    display: inline-block;
    padding: 4px 12px;
    background: #2196F3;
    color: white;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
}
.regulatory-category {
    display: inline-block;
    padding: 4px 12px;
    background: #ff9800;
    color: white;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
}
.violation-badge {
    display: inline-block;
    padding: 4px 10px;
    background: #6c757d;
    color: white;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
}
.custom-type-badge {
    display: inline-block;
    padding: 4px 10px;
    background: #9C27B0;
    color: white;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
}
.custom-type-note {
    font-size: 10px;
    color: #9C27B0;
    margin-left: 5px;
    font-style: italic;
}
.cause-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
}
.cause-systems { background: #2196F3; color: white; }
.cause-process { background: #4CAF50; color: white; }
.cause-personnel { background: #FF9800; color: white; }
.cause-external { background: #f44336; color: white; }
.cause-default { background: #607D8B; color: white; }
.risk-rating {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
    color: white;
}
.risk-rating-1 { background: #28a745; }
.risk-rating-2 { background: #8bc34a; color: #333; }
.risk-rating-3 { background: #ffc107; color: #333; }
.risk-rating-4 { background: #fd7e14; }
.risk-rating-5 { background: #dc3545; }
.risk-badge {
    display: inline-block;
    padding: 4px 10px;
    background: #17a2b8;
    color: white;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
    max-width: 200px;
    white-space: normal;
    word-wrap: break-word;
    cursor: help;
}
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
}
.status-draft { background: #e0e0e0; color: #666; }
.status-registered { background: #2196F3; color: white; }
.status-investigation { background: #FF9800; color: white; }
.status-measures_assigned { background: #9C27B0; color: white; }
.status-resolved { background: #4CAF50; color: white; }
.status-closed { background: #607D8B; color: white; }
.status-archived { background: #999; color: white; }
.no-data { color: #94a3b8; font-style: italic; }

/* ============================================
   ФОРМЫ
   ============================================ */
.incident-form {
    background: white;
    border-radius: 20px;
    padding: 30px;
}
.form-section {
    background: #ffffff;
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 28px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid #eef2f6;
}
.form-section h3 {
    font-size: 20px;
    font-weight: 600;
    color: #1a3a5c;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e7ff;
    padding-bottom: 10px;
}
.form-group {
    margin-bottom: 24px;
}
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: #1e293b;
    margin-bottom: 8px;
}
.form-group label .required { color: #dc3545; margin-left: 4px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    background: #fafbfc;
    transition: all 0.2s;
    font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: #1a3a5c;
    background: white;
    box-shadow: 0 0 0 3px rgba(26,58,92,0.1);
}
.form-group textarea { resize: vertical; min-height: 100px; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.help-text { display: block; font-size: 11px; color: #64748b; margin-top: 4px; }
.regulatory-box {
    background: #fff8e7;
    border-left: 4px solid #ffc107;
    padding: 20px;
    border-radius: 16px;
    margin-top: 20px;
}
.custom-type-block {
    margin-top: 12px;
    padding: 16px;
    background: #f0f8ff;
    border-left: 3px solid #2196F3;
    border-radius: 12px;
}
.prescription-details {
    margin-top: 12px;
    padding: 16px;
    background: #f8fafc;
    border-left: 3px solid #17a2b8;
    border-radius: 12px;
}
.damage-box {
    background: #f0f8ff;
    padding: 20px;
    border-radius: 16px;
    margin-top: 20px;
}
.btn-submit {
    background: linear-gradient(135deg, #1a3a5c, #0f2a44);
    color: white;
    padding: 16px 28px;
    border: none;
    border-radius: 40px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s;
}
.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(26,58,92,0.3);
}

/* ============================================
   КАРТОЧКА ПРОСМОТРА
   ============================================ */
.info-card {
    background: white;
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid #eef2f6;
}
.info-card h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1a3a5c;
    margin-bottom: 16px;
    border-bottom: 2px solid #e0e7ff;
    padding-bottom: 10px;
}
.detail-row {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 12px;
    font-size: 14px;
}
.detail-label {
    width: 200px;
    font-weight: 600;
    color: #334155;
    flex-shrink: 0;
}
.detail-value {
    flex: 1;
    color: #1e293b;
    word-break: break-word;
}
.comments-list {
    max-height: 500px;
    overflow-y: auto;
    margin-top: 15px;
}
.comment-item {
    display: flex;
    gap: 12px;
    border-bottom: 1px solid #eef2f6;
    padding: 14px 0;
    transition: background 0.2s;
}
.comment-item:hover { background: #f8fafc; }
.comment-avatar { flex-shrink: 0; }
.comment-avatar div {
    width: 40px;
    height: 40px;
    background: #1a3a5c;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}
.comment-header {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 5px;
}
.comment-author { font-weight: bold; color: #1a3a5c; }
.comment-date { font-size: 12px; color: #64748b; }
.comment-text { color: #1e293b; line-height: 1.45; }
.comment-text code { background: #f1f5f9; padding: 2px 6px; border-radius: 8px; font-family: monospace; }
.success-message, .error-message {
    padding: 12px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    border-left: 4px solid;
}
.success-message { background: #d4edda; color: #155724; border-left-color: #28a745; }
.error-message { background: #f8d7da; color: #721c24; border-left-color: #dc3545; }

/* ============================================
   ОТЧЁТЫ И СТАТИСТИКА
   ============================================ */
.filter-panel, .chart-container, .export-advanced-section {
    background: white;
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid #eef2f6;
}
.collapsible-header {
    background: white;
    padding: 16px 20px;
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #eef2f6;
    transition: all 0.2s;
}
.collapsible-header:hover { background: #f8fafc; }
.collapsible-content {
    display: none;
    padding: 20px;
    border-top: none;
}
.collapsible-content.active { display: block; }
.report-table {
    width: 100%;
    border-collapse: collapse;
}
.report-table th, .report-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eef2f6;
}
.report-table th { background: #f8fafc; font-weight: 600; }
.tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.tab-btn {
    padding: 8px 20px;
    background: #f1f5f9;
    border: none;
    border-radius: 40px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}
.tab-btn.active {
    background: #1a3a5c;
    color: white;
}
.tab-content { display: none; }
.tab-content.active { display: block; }
.btn-export-page {
    display: inline-block;
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    padding: 10px 24px;
    border-radius: 40px;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.2s;
}
.btn-export-page:hover { transform: translateY(-2px); }

/* ============================================
   АДАПТИВНОСТЬ
   ============================================ */
@media (max-width: 768px) {
    .container { padding: 12px; }
    .stats { flex-direction: column; }
    .filter-form { flex-direction: column; align-items: stretch; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 16px; }
    .detail-label { width: 100%; margin-bottom: 4px; }
    .detail-row { flex-direction: column; }
    .btn-text { display: none; }
    .btn-view, .btn-delete { width: 34px; justify-content: center; padding: 0; }
    .double-chart { grid-template-columns: 1fr; }
}