:root {
    --bg: #f5f7fc;
    --surface: #ffffff;
    --border: #e2e7f0;
    --text: #14181f;
    --muted: #6e7685;
    --accent: #527dff;
}

/* =========================
   BASE
========================= */
html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
}

.app-bg {
    background: var(--bg);
    color: var(--text);
}

.content-wrap {
    padding: 18px;
}

.page {
    padding-bottom: 24px;
}

.page-head {
    margin-bottom: 16px;
}

    .page-head h2 {
        margin: 0 0 4px 0;
        font-weight: 700;
    }

.page-subtitle,
.muted {
    color: var(--muted);
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.section-help {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 14px;
    line-height: 1.5;
}

/* =========================
   NAVBAR / HEADER
========================= */
.topnav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .65rem 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 800;
}

    .brand img {
        width: 26px;
        height: 26px;
    }

.user-pill {
    text-align: right;
    line-height: 1.05;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.user-name {
    font-weight: 700;
    font-size: .9rem;
}

.user-role {
    color: var(--muted);
    font-size: .8rem;
}

/* =========================
   CARDS / PANELS
========================= */
.card-soft {
    border: 1px solid #e9ecef;
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 2px 10px rgba(0,0,0,.03);
}

    .card-soft .card-body {
        padding: 20px;
    }

.page-intro {
    border: 1px solid #e9ecef;
    border-radius: 14px;
    background: #f8f9fa;
    padding: 16px 18px;
}

.page-intro-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 6px;
}

.page-intro-text {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
    line-height: 1.55;
}

.insight-box {
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 14px;
    background: #fff;
}

/* =========================
   KPI
========================= */
.kpi-title {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
}

/* =========================
   FILTERS
========================= */
.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

    .filters .form-control,
    .filters .form-select {
        border-radius: 12px;
        border: 1px solid var(--border);
        background: var(--surface);
    }

/* =========================
   BUTTONS
========================= */
.btn-gradient {
    border: none !important;
    border-radius: 12px;
    color: #fff !important;
    background: linear-gradient(90deg, #527dff, #7a5cff);
    box-shadow: 0 6px 18px rgba(82,125,255,.22);
}

    .btn-gradient:hover {
        filter: brightness(0.98);
    }

.buttonFormat {
    margin-top: 10px;
}

/* =========================
   TABLES
========================= */
.table-modern {
    border-collapse: separate;
    border-spacing: 0;
}

    .table-modern thead th {
        background: var(--surface);
        border-bottom: 1px solid #e9ecef;
        color: var(--muted);
        font-weight: 700;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: .02em;
    }

    .table-modern tbody td {
        border-top: 1px solid var(--border);
        vertical-align: middle;
    }

    .table-modern tbody tr:hover {
        background: #f1f6ff;
    }

/* =========================
   BADGES
========================= */
.badge-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #eef2ff;
    color: #334155;
    border: 1px solid #dbe4ff;
}

.badge-score-high {
    background: #e8fff3;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.badge-score-medium {
    background: #fff7e6;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-score-low {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.badge-risk {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid transparent;
}

    .badge-risk.low {
        background: #ecfdf5;
        color: #166534;
        border-color: #bbf7d0;
    }

    .badge-risk.medium {
        background: #fffbeb;
        color: #92400e;
        border-color: #fde68a;
    }

    .badge-risk.high {
        background: #fff7ed;
        color: #9a3412;
        border-color: #fdba74;
    }

    .badge-risk.critical {
        background: #fef2f2;
        color: #991b1b;
        border-color: #fca5a5;
    }

.badge-soft {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: #f8fafc;
    color: #475569 !important;
    border: 1px solid #e2e8f0;
}

/* =========================
   RISK HEAT
========================= */
.risk-heat-min {
    background: #f8f9fa;
    color: #6c757d;
    font-weight: 600;
}

.risk-heat-low {
    background: #d1ecf1;
    color: #0c5460;
    font-weight: 700;
}

.risk-heat-medium {
    background: #fff3cd;
    color: #856404;
    font-weight: 700;
}

.risk-heat-high {
    background: #f8d7da;
    color: #721c24;
    font-weight: 700;
}

.risk-heat-critical {
    background: #dc3545;
    color: #fff;
    font-weight: 700;
}

/* =========================
   CHARTS / CODE
========================= */
.chart-box {
    position: relative;
    min-height: 320px;
    height: 240px;
}

.codebox {
    background: #0b1220;
    color: #e6edf3;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 14px;
    padding: 12px;
    max-height: 420px;
    overflow: auto;
    font-size: 12px;
    white-space: pre-wrap;
}

/* =========================
   AUTH
========================= */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at 10% 10%, #e8efff, #f5f7fc);
}

.auth-card {
    width: 100%;
    max-width: 460px;
    background: #fff;
    border: 1px solid #e2e7f0;
    border-radius: 18px;
    padding: 28px;
    position: relative;
    box-shadow: 0 12px 40px rgba(16,24,40,.10);
}

.auth-card-lg {
    max-width: 460px;
}

.auth-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid #e2e7f0;
    background: #fff;
    color: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
    font-size: 16px;
}

    .auth-close:hover {
        background: #f8fafc;
    }

.auth-card .brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 18px;
    text-align: center;
}

.brand-logo {
    width:120px !important;
    height:80px !important;
    max-width: 220px;
    height: auto;
    display: inline-block;
}

.brand-subtitle {
    margin-top: 2px;
    color: #6e7685;
    font-size: 14px;
}

.auth-card .form-label {
    font-weight: 600;
    color: #14181f;
    margin-bottom: 6px;
}

.auth-card .form-control {
    border-radius: 12px;
    border: 1px solid #e2e7f0;
    min-height: 48px;
}

    .auth-card .form-control:focus {
        border-color: #527dff;
        box-shadow: 0 0 0 0.2rem rgba(82,125,255,.12);
    }

.auth-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

    .auth-check .form-check-input {
        margin-top: 0;
    }

    .auth-check .form-check-label {
        color: #475569;
        font-size: 14px;
    }

.auth-links {
    margin-top: 14px;
    text-align: center;
}

    .auth-links a {
        color: #527dff;
        text-decoration: none;
        font-weight: 500;
    }

        .auth-links a:hover {
            text-decoration: underline;
        }

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 576px) {
    .content-wrap {
        padding: 14px;
    }

    .auth-wrap {
        padding: 16px;
    }

    .auth-card {
        padding: 22px 18px;
        border-radius: 16px;
    }

    .brand-logo {
        max-width: 180px;
    }

    .user-pill {
        display: none;
    }
}

/*=========================
    OVERVIEW
========================= */
.billing-info-box {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    padding: 14px;
    height: 100%;
}

.billing-info-label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.billing-info-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

.billing-kpi-value {
    font-size: 26px;
    line-height: 1.15;
    word-break: break-word;
}

.billing-kpi-separator {
    font-size: 16px;
    font-weight: 600;
    color: var(--muted);
}

.billing-kpi-help {
    font-size: 12px;
}

.billing-progress {
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: #eef2f7;
}

.billing-meta-box {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8fafc;
    padding: 14px;
    height: 100%;
}

.billing-meta-label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.billing-meta-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    word-break: break-word;
}

/*=========================
    WINDOWS
========================= */
.download-kpi-value {
    font-size: 24px;
    line-height: 1.2;
    word-break: break-word;
}

.download-action-box {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 12px;
}

.download-list {
    line-height: 1.9;
    padding-left: 1.2rem;
}

.download-badge-required {
    background: #fef2f2;
    color: #991b1b !important;
    border-color: #fecaca;
}

.download-badge-optional {
    background: #ecfdf5;
    color: #166534 !important;
    border-color: #bbf7d0;
}

/*=========================
    ONBOARDING
========================= */

.onboarding-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.onboarding-step {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.step-number {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: #527dff;
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

/*=========================
    DASHBOARD
========================= */

.dashboard-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

    .dashboard-filters .form-select {
        min-width: 180px;
        border-radius: 12px;
        border: 1px solid var(--border);
        background: var(--surface);
    }

.dashboard-hero {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff, #f8fbff);
    box-shadow: 0 2px 10px rgba(0,0,0,.03);
}

.dashboard-hero-score {
    font-size: 34px;
    font-weight: 800;
    line-height: 1.1;
}

.dashboard-hero-side {
    min-width: 180px;
}

.dashboard-helper {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.55;
}

.dashboard-chart {
    height: 300px;
}

.repo-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    word-break: break-word;
}

    .repo-link:hover {
        text-decoration: underline;
    }

.table-wrap-tight td,
.table-wrap-tight th {
    white-space: nowrap;
}

.table-break td:first-child,
.table-break th:first-child {
    min-width: 220px;
}

.table-break td:first-child,
.table-break td:nth-child(2) {
    word-break: break-word;
    white-space: normal;
}


@media (max-width: 992px) {
    .dashboard-hero-side {
        min-width: auto;
        text-align: left !important;
    }

    .dashboard-filters .form-select {
        min-width: 150px;
    }
}

@media (max-width: 576px) {
    .dashboard-filters {
        width: 100%;
    }

        .dashboard-filters .form-select {
            width: 100%;
            min-width: 100%;
        }

    .dashboard-hero-score {
        font-size: 28px;
    }
}

/*=========================
    HISTORY
========================= */

.history-filters .form-control,
.history-filters .form-select {
    border-radius: 12px;
}

.history-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

/*=========================
    Risks
========================= */

.risks-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

    .risks-filters .form-select {
        min-width: 180px;
        border-radius: 12px;
        border: 1px solid var(--border);
        background: var(--surface);
    }

.risk-chart-sm {
    max-width: 320px;
    margin: 0 auto;
}

.risk-chart-lg {
    height: 340px;
}

.risk-chart-md {
    height: 320px;
}

.risk-helper {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.55;
}

.risk-heatmap th,
.risk-heatmap td {
    white-space: nowrap;
}

    .risk-heatmap td:first-child,
    .risk-heatmap th:first-child {
        position: sticky;
        left: 0;
        background: #fff;
        z-index: 1;
    }

@media (max-width: 992px) {
    .risks-filters .form-select {
        min-width: 150px;
    }
}

@media (max-width: 576px) {
    .risks-filters {
        width: 100%;
    }

        .risks-filters .form-select {
            width: 100%;
            min-width: 100%;
        }

    .risk-chart-lg,
    .risk-chart-md {
        height: 280px;
    }
}