:root {
    --brand-bg: #0d1020;
    --brand-bg-soft: #171523;
    --brand-surface: rgba(23, 21, 35, 0.78);
    --brand-surface-light: rgba(255, 255, 255, 0.92);
    --brand-border: rgba(142, 147, 254, 0.22);
    --brand-text: #f3f8ff;
    --brand-text-muted: #a9b8d8;
    --brand-accent: #02cad4;
    --brand-accent-2: #2386e9;
    --brand-accent-3: #8e93fe;
    --brand-accent-soft: #e1fdff;
}

body {
    font-family: Verdana, Geneva, sans-serif;
    color: #1f2a44;
    background:
        radial-gradient(circle at top right, rgba(2, 202, 212, 0.18), transparent 26%),
        radial-gradient(circle at top left, rgba(142, 147, 254, 0.2), transparent 28%),
        linear-gradient(180deg, var(--brand-bg) 0, #12182a 18rem, #eef4fb 18rem, #f4f7fb 100%);
    min-height: 100vh;
}

html {
    scroll-behavior: smooth;
}

h1, h2, h3, h4, h5, h6,
.navbar,
.navbar-brand,
.nav-link,
.btn,
.form-control,
.form-select,
table,
.badge,
.breadcrumb,
.list-group-item {
    font-family: Verdana, Geneva, sans-serif;
}

a {
    color: var(--brand-accent-2);
}

a:hover {
    color: #1264b6;
}

.navbar.bg-dark {
    background: linear-gradient(135deg, rgba(13, 16, 32, 0.95), rgba(23, 21, 35, 0.92)) !important;
    border-bottom: 1px solid rgba(154, 247, 255, 0.14);
    box-shadow: 0 12px 30px rgba(5, 10, 24, 0.28);
}

.navbar-brand,
.nav-link {
    color: rgba(243, 248, 255, 0.92) !important;
}

.navbar-brand {
    position: relative;
}

.navbar-brand-mark {
    display: flex;
    align-items: center;
}

.sp-logo-link {
    display: inline-flex;
    align-items: center;
}

.sp-logo {
    display: block;
    height: 28px;
    width: auto;
}

.nav-link:hover,
.nav-link:focus {
    color: var(--brand-accent) !important;
}

.nav-link.active {
    color: #ffffff !important;
    position: relative;
}

.nav-link.active::after {
    content: "";
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.2rem;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--brand-accent), var(--brand-accent-3));
}

.navbar-brand.active {
    color: #ffffff !important;
}

.navbar-brand.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -0.15rem;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--brand-accent), var(--brand-accent-3));
}

main.container {
    position: relative;
    z-index: 1;
}

h1, h2, h3, h4, h5, h6 {
    color: #11203b;
}

.h5,
.h6 {
    font-weight: 700;
}

.page-title {
    color: #f3f8ff;
    text-shadow: 0 2px 10px rgba(5, 10, 24, 0.28);
}

.text-muted,
.small.text-muted,
.form-text {
    color: #6d7d9a !important;
}

.card,
.list-group-item,
.table,
.alert,
.border.rounded,
.list-group {
    border-color: rgba(155, 171, 199, 0.24) !important;
}

.card,
.alert,
.empty-state,
.list-group-item,
.border.rounded,
.table-responsive {
    box-shadow: 0 12px 30px rgba(13, 26, 52, 0.07);
}

.card,
.alert,
.empty-state,
.list-group-item {
    border-radius: 1rem;
}

.card {
    background: var(--brand-surface-light);
    backdrop-filter: blur(10px);
}

.card.border-0.bg-light,
.card.card-body.bg-light,
.list-group-item {
    background: rgba(255, 255, 255, 0.88);
}

.table {
    overflow: hidden;
    background: rgba(255, 255, 255, 0.88);
    border-radius: 1rem;
}

.table-light,
.table-light > th,
.table-light > td {
    --bs-table-bg: rgba(225, 253, 255, 0.75);
    color: #163055;
}

.btn-primary {
    --bs-btn-bg: linear-gradient(135deg, var(--brand-accent), var(--brand-accent-2));
    --bs-btn-border-color: transparent;
    --bs-btn-hover-bg: linear-gradient(135deg, #02b7c0, #1f74ca);
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-bg: linear-gradient(135deg, #029fa7, #1a63ac);
    --bs-btn-active-border-color: transparent;
    color: #08111f !important;
    font-weight: 700;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    color: #08111f !important;
}

.btn-outline-primary {
    --bs-btn-color: var(--brand-accent-2);
    --bs-btn-border-color: rgba(35, 134, 233, 0.4);
    --bs-btn-hover-bg: rgba(35, 134, 233, 0.1);
    --bs-btn-hover-color: #0d2f58;
    --bs-btn-hover-border-color: rgba(35, 134, 233, 0.7);
}

.btn-outline-secondary {
    --bs-btn-color: #4f5f80;
    --bs-btn-border-color: rgba(79, 95, 128, 0.35);
    --bs-btn-hover-bg: rgba(79, 95, 128, 0.08);
    --bs-btn-hover-color: #22314f;
    --bs-btn-hover-border-color: rgba(79, 95, 128, 0.55);
}

.btn-home {
    background: rgba(255, 255, 255, 0.96);
    color: #18243c;
    border: 1px solid rgba(255, 255, 255, 0.92);
    font-weight: 700;
}

.btn-home:hover,
.btn-home:focus {
    background: #ffffff;
    color: #0d1830;
    border-color: #ffffff;
}

.btn-copy-icon {
    padding: 0.1rem 0.35rem;
    border: 1px solid rgba(79, 95, 128, 0.18);
    background: rgba(255, 255, 255, 0.85);
    color: #4f5f80;
    border-radius: 0.5rem;
    line-height: 1;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.btn-copy-icon:hover,
.btn-copy-icon:focus {
    background: rgba(35, 134, 233, 0.08);
    color: #114d88;
    border-color: rgba(35, 134, 233, 0.28);
}

.copy-inline-wrap {
    display: inline-flex;
    align-items: flex-start;
    gap: 0.4rem;
    max-width: 100%;
    width: auto;
}

.copy-inline-wrap > :first-child {
    min-width: 0;
}

.copy-inline-text {
    display: inline;
}

.btn-copy-inline {
    display: inline-flex;
    vertical-align: baseline;
    margin-left: 0.35rem;
}

.badge.text-bg-secondary {
    background: rgba(142, 147, 254, 0.16) !important;
    color: #343c97 !important;
}

.badge.text-bg-info {
    background: rgba(2, 202, 212, 0.16) !important;
    color: #006d73 !important;
}

.badge.text-bg-warning {
    background: rgba(35, 134, 233, 0.14) !important;
    color: #114d88 !important;
}

.badge.text-bg-dark {
    background: linear-gradient(135deg, #24385d, #171523) !important;
}

.form-control,
.form-select {
    border-radius: 0.8rem;
    border-color: rgba(124, 143, 174, 0.3);
    box-shadow: none;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(2, 202, 212, 0.55);
    box-shadow: 0 0 0 0.2rem rgba(2, 202, 212, 0.12);
}

mark {
    background: rgba(2, 202, 212, 0.18);
    color: inherit;
    padding: 0 3px;
    border-radius: 0.25rem;
}

.card-title a {
    color: inherit;
}

.card-title a:hover {
    color: var(--brand-accent-2);
}

.breadcrumb {
    background: transparent;
    padding-left: 0;
}

.breadcrumb-item,
.breadcrumb-item a {
    color: #6d7d9a;
}

.breadcrumb-item.active {
    color: #22314f;
}

.empty-state {
    padding: 2rem;
    border: 1px dashed rgba(79, 95, 128, 0.28);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(225, 253, 255, 0.56));
}

.display-6 {
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.theory-flow .border.rounded {
    position: relative;
    overflow: hidden;
}

.theory-flow .border.rounded::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(180deg, var(--brand-accent), var(--brand-accent-3));
}

.theory-nav-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(225, 253, 255, 0.78));
}

.theory-sidebar {
    position: sticky;
    top: 1.25rem;
    z-index: 10;
    align-self: flex-start;
    height: max-content;
}

.theory-sidebar-nav .nav-link {
    color: #22314f !important;
    padding: 0.55rem 0.75rem;
    border-radius: 0.75rem;
    margin-bottom: 0.25rem;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.theory-sidebar-nav .nav-link:hover,
.theory-sidebar-nav .nav-link:focus {
    background: rgba(35, 134, 233, 0.08);
    color: #114d88 !important;
    transform: translateX(2px);
}

.theory-flow-card {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(154, 247, 255, 0.12)),
        rgba(255, 255, 255, 0.92);
    min-height: 100%;
}

.theory-flow .col-md-3 {
    position: relative;
}

@media (min-width: 768px) {
    .theory-flow .col-md-3:not(:last-child)::after {
        content: "\2192";
        position: absolute;
        right: -0.75rem;
        top: 50%;
        transform: translateY(-50%);
        color: var(--brand-accent-2);
        font-size: 1.5rem;
        font-weight: 700;
        text-shadow: 0 2px 10px rgba(35, 134, 233, 0.18);
        z-index: 2;
    }
}

@media (max-width: 991.98px) {
    .theory-sidebar {
        position: static;
    }

    .navbar-brand-mark {
        margin-top: 0.75rem;
    }
}

.table-fixed-snapshots {
    table-layout: fixed;
    width: 100%;
}

.table-fixed-snapshots th,
.table-fixed-snapshots td {
    width: 14.285%;
    text-align: left;
    vertical-align: top;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.table-fixed-snapshots th {
    line-height: 1.25;
}

.table-fixed-snapshots td {
    line-height: 1.35;
}

.btn-sort-header {
    padding: 0.1rem 0;
    border: 0;
    color: #163055;
    text-decoration: none;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.2rem;
    width: auto;
    white-space: normal;
    text-align: left;
    line-height: 1.2;
}

.btn-sort-header:hover,
.btn-sort-header:focus {
    color: #114d88;
    text-decoration: none;
}

.btn-sort-header.active {
    color: #114d88;
}

.btn-sort-header.active span:first-child {
    background: rgba(35, 134, 233, 0.1);
    border-radius: 0.45rem;
    padding: 0.15rem 0.35rem;
}

.sort-indicator {
    flex: 0 0 auto;
    text-align: left;
    color: #2386e9;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1;
}

.project-code {
    color: #f3f8ff !important;
    font-weight: 400;
}

.risk-class-badge-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.risk-class-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.risk-class-dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 999px;
    background: #171523;
    display: inline-block;
}

.project-detail-code {
    color: #f3f8ff !important;
}

.risk-detail-code {
    color: #f3f8ff !important;
}

.risk-detail-hero .badge.text-bg-secondary,
.risk-detail-hero .badge.text-bg-info,
.risk-detail-hero .badge.text-bg-warning {
    background: rgba(255, 255, 255, 0.92) !important;
}

.risk-detail-hero {
    min-height: 11.5rem;
}

.risk-detail-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: start;
}

.risk-detail-header-main {
    min-width: 0;
}

.risk-detail-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
    white-space: nowrap;
}

.risk-detail-header-actions-stack {
    flex-direction: column;
    align-items: flex-end;
}

.risk-detail-summary {
    margin-top: 1.5rem;
}

.project-detail-hero {
    min-height: 11rem;
}

.project-detail-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: start;
}

.project-detail-header-main {
    min-width: 0;
}

.project-detail-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
    white-space: nowrap;
}

@media (max-width: 767.98px) {
    .risk-detail-header {
        grid-template-columns: 1fr;
    }

    .risk-detail-header-actions {
        justify-content: flex-start;
        white-space: normal;
        flex-wrap: wrap;
    }

    .risk-detail-header-actions-stack {
        align-items: flex-start;
    }

    .project-detail-header {
        grid-template-columns: 1fr;
    }

.project-detail-header-actions {
        justify-content: flex-start;
        white-space: normal;
        flex-wrap: wrap;
    }
}

.risk-stats-hero {
    min-height: 9rem;
}

.risk-stats-filter {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(225, 253, 255, 0.72)),
        rgba(255, 255, 255, 0.94);
}

.risk-chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.risk-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    border: 1px solid rgba(35, 134, 233, 0.18);
    background: rgba(255, 255, 255, 0.9);
    color: #22314f;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.risk-chip:hover {
    transform: translateY(-1px);
    border-color: rgba(35, 134, 233, 0.34);
}

.risk-chip.active {
    background: linear-gradient(135deg, rgba(2, 202, 212, 0.16), rgba(35, 134, 233, 0.14));
    border-color: rgba(35, 134, 233, 0.38);
    color: #10284b;
}

.risk-chip input {
    margin: 0;
}

.stats-kpi-card {
    background:
        linear-gradient(155deg, rgba(255, 255, 255, 0.98), rgba(225, 253, 255, 0.68)),
        rgba(255, 255, 255, 0.92);
}

.widget-sort-select {
    min-width: 12rem;
}

.stats-bars {
    display: grid;
    gap: 1rem;
}

.stats-bar-item {
    display: block;
    padding: 0.9rem 1rem;
    border: 1px solid rgba(155, 171, 199, 0.22);
    border-radius: 0.9rem;
    background: rgba(255, 255, 255, 0.74);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.stats-bar-item:hover,
.stats-bar-item:focus {
    transform: translateY(-1px);
    border-color: rgba(35, 134, 233, 0.32);
    box-shadow: 0 14px 28px rgba(13, 26, 52, 0.1);
}

.table tbody tr.position-relative {
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.table tbody tr.position-relative:hover,
.table tbody tr.position-relative:focus-within {
    background: linear-gradient(90deg, rgba(2, 202, 212, 0.08), rgba(35, 134, 233, 0.06));
    box-shadow: inset 3px 0 0 rgba(35, 134, 233, 0.75);
}

.table tbody tr.position-relative:hover td,
.table tbody tr.position-relative:focus-within td {
    background: transparent;
}

.stretched-link-anchor {
    position: relative;
    z-index: 2;
}

.stats-progress {
    height: 0.7rem;
    background: rgba(17, 32, 59, 0.08);
    border-radius: 999px;
}

.stats-progress .progress-bar {
    background: linear-gradient(90deg, var(--brand-accent), var(--brand-accent-2));
    border-radius: 999px;
}

.stats-progress .stats-progress-stage {
    background: linear-gradient(90deg, #8e93fe, #2386e9);
}

@media (max-width: 767.98px) {
    .widget-sort-select {
        min-width: 100%;
    }

    .risk-chip-group {
        gap: 0.45rem;
    }

    .risk-chip {
        width: 100%;
        justify-content: flex-start;
    }
}

footer.container {
    color: var(--brand-text-muted) !important;
    border-top-color: rgba(169, 184, 216, 0.18) !important;
}

/* ---- Страница отчёта: рендер исходного markdown ---- */
.report-md {
    font-size: 0.95rem;
    line-height: 1.55;
    color: #1F2A44;
}

.report-md h1,
.report-md h2,
.report-md h3,
.report-md h4 {
    margin-top: 1.5em;
    margin-bottom: 0.6em;
    font-weight: 600;
}
.report-md h1 { font-size: 1.45rem; }
.report-md h2 { font-size: 1.25rem; }
.report-md h3 { font-size: 1.1rem; }
.report-md h4 { font-size: 1rem; }

.report-md p {
    margin-bottom: 0.8em;
}

.report-md img {
    max-width: 100%;
    height: auto;
    display: inline-block;
    margin: 0.5em 0;
    /* Плейсхолдер для битых картинок — alt-текст отрендерится
       поверх пунктирной рамки как пометка «тут была картинка». */
    min-width: 64px;
    min-height: 36px;
    background: #f6f8fb;
    border: 1px dashed #cbd5e0;
    padding: 0.35rem 0.55rem;
    color: #7b8698;
    font-size: 0.8rem;
    line-height: 1.3;
    border-radius: 4px;
    vertical-align: middle;
}

.report-md a {
    color: #2c67b1;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.report-md a:hover {
    color: #143f7b;
}

.report-md table {
    width: 100%;
    margin: 1em 0;
    border-collapse: collapse;
    display: block;
    overflow-x: auto;
    font-size: 0.9rem;
}

.report-md table th,
.report-md table td {
    border: 1px solid #dce3ec;
    padding: 0.5rem 0.75rem;
    vertical-align: top;
    text-align: left;
}

.report-md table thead th {
    background: #f1f5f9;
    font-weight: 600;
}

.report-md table tbody tr:nth-child(odd) {
    background: #fafbfc;
}

.report-md code {
    font-size: 0.85em;
    color: #643b8a;
    background: #f4f0fa;
    padding: 0.1em 0.3em;
    border-radius: 3px;
}

.report-md pre {
    background: #f7f8fa;
    padding: 0.8rem 1rem;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.85rem;
}

.report-md blockquote {
    border-left: 3px solid #b7c9d9;
    padding-left: 1rem;
    color: #5a6578;
    margin: 1em 0;
}

.report-md hr {
    margin: 2em 0;
    border-top: 1px dashed #d0d7de;
}
