/* ============================================================
   FHA Report (ОФО / АФО) — Стили
   ============================================================ */

/* -------- Overlay -------- */
.fha-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    opacity: 0;
    transition: opacity .3s ease;
}
.fha-overlay-visible { opacity: 1; }

.fha-overlay-content {
    width: 96%;
    max-width: 1400px;
    margin: 30px auto;
    animation: fhaSlideIn .35s ease;
}

@keyframes fhaSlideIn {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* -------- Report container -------- */
.fha-report {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.18);
    overflow: hidden;
    font-family: 'Segoe UI', 'Inter', system-ui, sans-serif;
    color: #1e293b;
    font-size: 13px;
    line-height: 1.5;
}

/* -------- Header -------- */
.fha-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 28px 36px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: #fff;
}
.fha-header-afo {
    background: linear-gradient(135deg, #1a3347 0%, #0d9488 100%);
}
.fha-header-icon {
    width: 56px;
    height: 56px;
    background: rgba(255,255,255,.15);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}
.fha-header-text h1 {
    margin: 0 0 2px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.3px;
}
.fha-header-text h2 {
    margin: 0;
    font-size: 13px;
    font-weight: 400;
    opacity: .85;
}

/* -------- Info bar -------- */
.fha-info-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 28px;
    padding: 16px 36px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}
.fha-info-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #64748b;
}
.fha-info-item i {
    font-size: 14px;
    color: #94a3b8;
    width: 16px;
    text-align: center;
}
.fha-info-item strong { color: #1e293b; }

/* -------- Stats row -------- */
.fha-stats-row {
    display: flex;
    gap: 10px;
    padding: 18px 36px;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
}
.fha-stat-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 10px;
    background: #f1f5f9;
    min-width: 140px;
}
.fha-stat-badge {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}
.fha-stat-label {
    font-size: 11px;
    color: #64748b;
    line-height: 1.2;
}
.fha-stat-count {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin-left: auto;
}

/* -------- Summary bar (АФО) -------- */
.fha-summary-bar {
    display: flex;
    gap: 12px;
    padding: 16px 36px;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
}
.fha-summary-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
}
.fha-summary-pass  { background: #ecfdf5; color: #047857; }
.fha-summary-fail  { background: #fef2f2; color: #b91c1c; }
.fha-summary-na    { background: #f8fafc; color: #64748b; }

/* -------- Tables -------- */
.fha-table-wrap {
    padding: 0 24px 24px;
    overflow-x: auto;
}
.fha-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
    margin-top: 18px;
}
.fha-table thead th {
    background: #1e293b;
    color: #fff;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .3px;
    padding: 10px 10px;
    position: sticky;
    top: 0;
    z-index: 2;
    white-space: nowrap;
    text-align: center;
    border-right: 1px solid #334155;
}
.fha-table thead th:first-child { border-radius: 8px 0 0 0; }
.fha-table thead th:last-child  { border-radius: 0 8px 0 0; border-right: none; }

.fha-table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #f1f5f9;
    vertical-align: middle;
}
.fha-table tbody tr:hover td {
    background: #f0f9ff;
}
.fha-table tbody tr:last-child td:first-child { border-radius: 0 0 0 8px; }
.fha-table tbody tr:last-child td:last-child  { border-radius: 0 0 8px 0; }

.fha-td-center { text-align: center; }
.fha-td-func   { font-weight: 600; background: #f8fafc; }
.fha-td-mono   { font-family: 'JetBrains Mono', 'Consolas', monospace; font-size: 11px; }

.fha-table-mini {
    font-size: 11px;
    margin-top: 14px;
}
.fha-table-mini thead th {
    font-size: 10px;
    padding: 6px 8px;
}
.fha-table-mini tbody td {
    padding: 5px 8px;
}

/* -------- Badges -------- */
.fha-hazard-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: .5px;
}
.fha-fdal-badge {
    display: inline-block;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 12px;
    color: #fff;
    text-align: center;
    line-height: 26px;
}

/* -------- Compliance -------- */
.fha-compliance-pass {
    color: #047857;
    font-weight: 600;
    background: #ecfdf5;
    padding: 2px 8px;
    border-radius: 4px;
}
.fha-compliance-fail {
    color: #b91c1c;
    font-weight: 600;
    background: #fef2f2;
    padding: 2px 8px;
    border-radius: 4px;
}
.fha-compliance-nodata {
    color: #92400e;
    background: #fffbeb;
    padding: 2px 8px;
    border-radius: 4px;
}
.fha-compliance-na {
    color: #64748b;
}

/* -------- FTA link -------- */
.fha-fta-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff !important;
    border-radius: 6px;
    font-weight: 600;
    font-size: 11px;
    text-decoration: none !important;
    transition: transform .15s, box-shadow .15s;
    white-space: nowrap;
}
.fha-fta-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99,102,241,.4);
}
.fha-no-fta {
    color: #cbd5e1;
}

/* -------- FTA Appendix -------- */
.fha-appendix {
    padding: 0 24px 24px;
}
.fha-appendix-header {
    padding: 24px 12px 12px;
    border-top: 2px solid #e2e8f0;
    margin-top: 8px;
}
.fha-appendix-header h2 {
    margin: 0;
    font-size: 18px;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 10px;
}
.fha-appendix-header h2 i { color: #6366f1; }

.fha-fta-section {
    margin: 20px 0;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    scroll-margin-top: 20px;
}
.fha-fta-section-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    background: linear-gradient(135deg, #f8fafc, #eef2ff);
    border-bottom: 1px solid #e2e8f0;
}
.fha-fta-section-num {
    width: 54px;
    height: 36px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}
.fha-fta-section-title h3 {
    margin: 0;
    font-size: 14px;
    color: #1e293b;
}
.fha-fta-meta {
    display: flex;
    gap: 14px;
    margin-top: 3px;
    font-size: 11px;
    color: #64748b;
}
.fha-fta-meta i {
    margin-right: 3px;
    font-size: 10px;
}
.fha-back-link {
    margin-left: auto;
    font-size: 12px;
    color: #6366f1 !important;
    text-decoration: none !important;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}
.fha-back-link:hover { text-decoration: underline !important; }

.fha-fta-diagram {
    padding: 20px;
}
.fha-fta-causes-table {
    padding: 0 20px 20px;
}

.fha-no-data {
    text-align: center;
    color: #94a3b8;
    padding: 24px;
    font-style: italic;
}

/* -------- FTA Visual tree -------- */
.fta-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
}
.fta-level {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}
.fta-level-causes {
    gap: 16px;
}

.fta-event {
    text-align: center;
    max-width: 220px;
    min-width: 140px;
}
.fta-event-top {
    background: linear-gradient(135deg, #1e293b, #334155);
    color: #fff;
    border-radius: 12px;
    padding: 14px 20px;
    box-shadow: 0 4px 16px rgba(30,41,59,.3);
}
.fta-event-top .fta-event-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .8px;
    opacity: .7;
    margin-bottom: 4px;
}
.fta-event-top .fta-event-name {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.3;
}
.fta-event-top .fta-event-prob {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    margin-top: 6px;
    opacity: .85;
}

.fta-event-basic {
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 16px;
    position: relative;
    transition: border-color .2s, box-shadow .2s;
}
.fta-event-basic:hover {
    border-color: #6366f1;
    box-shadow: 0 4px 12px rgba(99,102,241,.15);
}
.fta-event-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2.5px solid #6366f1;
    margin: 0 auto 8px;
    background: #eef2ff;
}
.fta-event-basic .fta-event-name {
    font-weight: 600;
    font-size: 12px;
    color: #1e293b;
    line-height: 1.3;
    margin-bottom: 2px;
}
.fta-event-basic .fta-event-code {
    font-size: 10px;
    color: #94a3b8;
    font-family: monospace;
}
.fta-event-basic .fta-event-node {
    font-size: 10px;
    color: #64748b;
    margin-top: 4px;
}
.fta-event-basic .fta-event-prob {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #475569;
    margin-top: 3px;
}
.fta-event-basic .fta-event-hazard {
    font-weight: 700;
    font-size: 11px;
    margin-top: 4px;
}

/* Gate */
.fta-gate {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    position: relative;
}
.fta-gate-or  { background: linear-gradient(135deg, #6366f1, #818cf8); }
.fta-gate-and { background: linear-gradient(135deg, #0d9488, #14b8a6); }
.fta-gate-label {
    position: absolute;
    bottom: -16px;
    font-size: 9px;
    letter-spacing: .5px;
    color: #64748b;
    font-weight: 600;
}

/* Connectors */
.fta-connector-v {
    width: 2px;
    height: 24px;
    background: #cbd5e1;
    margin: 0 auto;
}
.fta-connector-h {
    width: 60%;
    max-width: 500px;
    height: 2px;
    background: #cbd5e1;
    margin: 0 auto;
}

/* -------- Footer -------- */
.fha-footer {
    padding: 16px 36px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}
.fha-footer p {
    margin: 0;
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.5;
}

/* -------- Export bar -------- */
.fha-export-bar {
    display: flex;
    gap: 10px;
    padding: 16px 36px;
    justify-content: flex-end;
    border-top: 1px solid #e2e8f0;
}

.fha-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .12s, box-shadow .12s;
}
.fha-btn:hover {
    transform: translateY(-1px);
}
.fha-btn-pdf {
    background: linear-gradient(135deg, #dc3545, #e74c3c);
    color: #fff;
}
.fha-btn-pdf:hover { box-shadow: 0 4px 14px rgba(220,53,69,.35); }

.fha-btn-word {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
}
.fha-btn-word:hover { box-shadow: 0 4px 14px rgba(37,99,235,.35); }

.fha-btn-close {
    background: #e2e8f0;
    color: #475569;
}
.fha-btn-close:hover { background: #cbd5e1; }

/* -------- Report buttons in workspace tab -------- */
.fha-report-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 18px 22px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s, transform .15s;
    text-align: left;
    min-width: 260px;
    flex: 1;
    max-width: 380px;
}
.fha-report-card:hover {
    border-color: #6366f1;
    box-shadow: 0 6px 24px rgba(99,102,241,.12);
    transform: translateY(-2px);
}
.fha-report-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    flex-shrink: 0;
}
.fha-report-card-icon-ofo { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.fha-report-card-icon-afo { background: linear-gradient(135deg, #0d9488, #14b8a6); }
.fha-report-card-text h4 {
    margin: 0 0 3px;
    font-size: 14px;
    color: #1e293b;
    font-weight: 600;
}
.fha-report-card-text p {
    margin: 0;
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.4;
}

/* -------- Responsive -------- */
@media (max-width: 900px) {
    .fha-overlay-content { width: 99%; margin: 10px auto; }
    .fha-header { padding: 18px 20px; }
    .fha-info-bar { padding: 12px 20px; }
    .fha-table-wrap { padding: 0 10px 14px; }
    .fha-stats-row { padding: 12px 20px; }
    .fha-export-bar { padding: 12px 20px; }
    .fha-fta-section-header { flex-wrap: wrap; }
}

/* -------- Print -------- */
@media print {
    .fha-overlay { position: static; background: none; backdrop-filter: none; }
    .fha-overlay-content { width: 100%; margin: 0; }
    .fha-report { box-shadow: none; border-radius: 0; }
    .fha-export-bar { display: none !important; }
    .fha-btn { display: none !important; }
    .fha-back-link { display: none !important; }
}
