:root {
    --app-accent: #0d6efd;
    --app-bg: #f3f6fa;
    --app-panel: #ffffff;
    --app-text: #172033;
    --app-muted: #657085;
    --app-border: #dce3ec;
    --app-sidebar: #0a1728;
    --app-sidebar-hover: #142a45;
    --app-sidebar-text: #d7e1ee;
    --app-row-ok: rgba(25, 135, 84, 0.075);
    --app-row-diff: rgba(220, 53, 69, 0.075);
    --app-row-neutral: rgba(108, 117, 125, 0.07);
    --sidebar-width: 212px;
    --sidebar-collapsed-width: 56px;
    --topbar-height: 46px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--app-bg);
    color: var(--app-text);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 12px;
}

body,
.form-control,
.form-select,
.btn,
.table,
.dropdown-menu,
.pagination {
    font-size: 12px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: inherit;
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    display: flex;
    width: var(--sidebar-width);
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 8px;
    color: var(--app-sidebar-text);
    background: var(--app-sidebar);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    transition: width 160ms ease, transform 160ms ease;
}

.brand {
    display: flex;
    height: 40px;
    align-items: center;
    gap: 9px;
    padding: 4px 6px;
    margin-bottom: 7px;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
}

.brand:hover {
    color: #fff;
}

.brand-mark {
    display: inline-grid;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    place-items: center;
    border-radius: 8px;
    color: #fff;
    background: var(--app-accent);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.brand-text {
    overflow: hidden;
    font-size: 13px;
    font-weight: 650;
    text-overflow: ellipsis;
}

.sidebar-nav {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
}

.sidebar .nav-link {
    display: flex;
    min-height: 34px;
    align-items: center;
    gap: 9px;
    padding: 7px 8px;
    overflow: hidden;
    border-radius: 6px;
    color: var(--app-sidebar-text);
    line-height: 1.15;
    text-decoration: none;
    white-space: nowrap;
}

.sidebar a.nav-link:hover {
    color: #fff;
    background: var(--app-sidebar-hover);
}

.sidebar .nav-link.active {
    color: #fff;
    background: var(--app-accent);
    cursor: default;
}

.app-icon {
    display: inline-block;
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    fill: currentColor;
    vertical-align: -2px;
}

.nav-icon {
    width: 17px;
    height: 17px;
    flex-basis: 17px;
}

.nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-section {
    margin: 12px 8px 3px;
    color: #8393a8;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.sidebar-footer {
    padding: 8px;
    color: #8091a7;
    font-size: 9px;
}

.app-main {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    transition: margin-left 160ms ease;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    height: var(--topbar-height);
    align-items: center;
    gap: 9px;
    padding: 0 12px;
    background: var(--app-panel);
    border-bottom: 1px solid var(--app-border);
}

.topbar h1 {
    flex: 1;
    margin: 0;
    overflow: hidden;
    font-size: 14px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 7px;
}

.user-name {
    color: var(--app-muted);
    white-space: nowrap;
}

.icon-button,
.copy-btn {
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--app-border);
    color: var(--app-muted);
    background: transparent;
    cursor: pointer;
}

.icon-button {
    width: 29px;
    height: 29px;
    padding: 0;
    border-radius: 6px;
}

.icon-button:hover,
.copy-btn:hover {
    color: var(--app-text);
    background: rgba(13, 110, 253, 0.08);
}

.content {
    padding: 12px;
}

.panel,
.metric-card {
    background: var(--app-panel);
    border: 1px solid var(--app-border);
    border-radius: 8px;
}

.panel {
    padding: 12px;
}

.metric-card {
    height: 100%;
    padding: 12px;
}

.metric-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--app-muted);
}

.metric-icon {
    display: inline-grid;
    width: 29px;
    height: 29px;
    place-items: center;
    border-radius: 7px;
    color: var(--app-accent);
    background: rgba(13, 110, 253, 0.1);
}

.metric-label {
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.metric-value {
    margin-top: 8px;
    font-size: 22px;
    font-weight: 720;
    line-height: 1;
}

.chart-panel {
    min-height: 290px;
}

.chart-title {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 650;
}

.donut-chart {
    display: grid;
    grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
    align-items: center;
    gap: 18px;
}

.donut-svg {
    width: 100%;
    max-width: 210px;
    height: auto;
}

.chart-legend {
    display: grid;
    gap: 7px;
}

.legend-row {
    display: grid;
    grid-template-columns: 9px minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--legend-color);
}

.bar-chart {
    display: grid;
    height: 220px;
    grid-template-columns: repeat(var(--bar-count), minmax(28px, 1fr));
    align-items: end;
    gap: 8px;
    padding-top: 14px;
}

.bar-item {
    display: grid;
    height: 100%;
    grid-template-rows: minmax(0, 1fr) auto;
    align-items: end;
    gap: 6px;
    text-align: center;
}

.bar-track {
    position: relative;
    height: 100%;
    border-radius: 5px 5px 2px 2px;
    background: rgba(13, 110, 253, 0.08);
}

.bar-fill {
    position: absolute;
    inset: auto 0 0;
    min-height: 2px;
    border-radius: 5px 5px 2px 2px;
    background: var(--app-accent);
}

.bar-label {
    color: var(--app-muted);
    font-size: 9px;
}

.table {
    --bs-table-color: var(--app-text);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--app-border);
    margin-bottom: 0;
}

.table > :not(caption) > * > * {
    padding: 0.25rem 0.35rem;
    vertical-align: middle;
}

.table thead th {
    white-space: nowrap;
}

.table a {
    color: inherit;
}

.report-table tbody tr.status-ok > td {
    background: var(--app-row-ok) !important;
}

.report-table tbody tr.status-diff > td {
    background: var(--app-row-diff) !important;
}

.report-table tbody tr.status-neutral > td {
    background: var(--app-row-neutral) !important;
}

.report-table tbody tr.selected-row > td {
    outline: 1px solid rgba(13, 110, 253, 0.45);
    outline-offset: -1px;
}

.release-name {
    min-width: 210px;
    max-width: 380px;
    white-space: normal;
    overflow-wrap: anywhere;
}

.compare-grid {
    display: grid;
    min-width: 200px;
    grid-template-columns: 45px minmax(0, 1fr) 23px;
    align-items: start;
    gap: 2px 5px;
}

.compare-grid b {
    font-weight: 650;
    white-space: nowrap;
}

.compare-value {
    min-width: 0;
    overflow-wrap: anywhere;
}

.copy-btn {
    width: 21px;
    height: 20px;
    padding: 0;
    border-radius: 4px;
}

.copy-btn .app-icon {
    width: 12px;
    height: 12px;
}

.size-difference {
    margin-top: 3px;
    color: #dc3545;
    font-size: 9px;
    font-weight: 650;
    white-space: nowrap;
}

.match-badges {
    display: inline-flex;
    gap: 3px;
}

.match-badge {
    min-width: 19px;
    cursor: help;
}

.status-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.selection-column {
    width: 31px;
}

html.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

html.sidebar-collapsed .app-main {
    margin-left: var(--sidebar-collapsed-width);
}

html.sidebar-collapsed .brand-text,
html.sidebar-collapsed .nav-label,
html.sidebar-collapsed .nav-section,
html.sidebar-collapsed .sidebar-footer {
    display: none;
}

html.sidebar-collapsed .brand {
    justify-content: center;
    padding-inline: 0;
}

html.sidebar-collapsed .sidebar .nav-link {
    justify-content: center;
    padding-inline: 0;
}

html[data-theme="dark"] {
    --app-bg: #12171f;
    --app-panel: #1a222d;
    --app-text: #e7edf5;
    --app-muted: #aab5c3;
    --app-border: #334050;
    --app-row-ok: rgba(34, 197, 94, 0.12);
    --app-row-diff: rgba(239, 68, 68, 0.12);
    --app-row-neutral: rgba(148, 163, 184, 0.1);
    color-scheme: dark;
}

html[data-theme="dark"] body,
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
    color: var(--app-text);
    background-color: var(--app-bg);
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
    border-color: var(--app-border);
}

html[data-theme="dark"] .table,
html[data-theme="dark"] .table td,
html[data-theme="dark"] .table th,
html[data-theme="dark"] .table a,
html[data-theme="dark"] .compare-value,
html[data-theme="dark"] .release-name,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .metric-card {
    color: var(--app-text) !important;
}

html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-accent-bg: rgba(255, 255, 255, 0.025);
    color: var(--app-text);
}

html[data-theme="dark"] .btn-outline-dark {
    color: #e6edf7;
    border-color: #7e8a99;
}

html[data-theme="dark"] .btn-outline-dark:hover,
html[data-theme="dark"] .btn-outline-dark:focus,
html[data-theme="dark"] .btn-dark {
    color: #fff;
    background: #526070;
    border-color: #748295;
}

html[data-theme="dark"] .btn-outline-secondary {
    color: #d5deea;
    border-color: #637184;
}

html[data-theme="dark"] .text-muted {
    color: var(--app-muted) !important;
}

@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    html.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .app-main,
    html.sidebar-collapsed .app-main {
        margin-left: 0;
    }

    .content {
        padding: 8px;
    }

    .user-name,
    .button-label {
        display: none;
    }

    .donut-chart {
        grid-template-columns: 1fr;
        justify-items: center;
    }
}

/* Compact login */
.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 20px;
    background: var(--app-bg);
}

.login-card {
    width: min(100%, 360px);
    padding: 20px;
    background: var(--app-panel);
    border: 1px solid var(--app-border);
    border-radius: 10px;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

.login-brand-mark {
    display: inline-grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    place-items: center;
    border-radius: 8px;
    color: #fff;
    background: var(--app-accent);
    font-size: 11px;
    font-weight: 700;
}

.login-title {
    font-size: 14px;
    font-weight: 700;
}

.login-subtitle,
.login-version {
    color: var(--app-muted);
    font-size: 10px;
}

.login-version {
    margin-top: 14px;
    text-align: center;
}

/* Role and permission administration */
.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 6px;
}

.permission-option {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 8px;
    border: 1px solid var(--app-border);
    border-radius: 6px;
    background: rgba(127, 127, 127, 0.035);
    cursor: pointer;
}

.permission-option:hover {
    border-color: var(--app-accent);
}

.permission-option .form-check-input {
    margin-top: 2px;
    flex: 0 0 auto;
}

.permission-option span {
    display: grid;
    min-width: 0;
}

.permission-option strong {
    font-size: 11px;
    line-height: 1.25;
}

.permission-option small {
    color: var(--app-muted);
    font-size: 9px;
    overflow-wrap: anywhere;
}

/* Report pagination: distinct light and dark theme colors. */
.report-pagination .pagination {
    margin: 0;
}

.report-pagination .page-link {
    color: var(--app-text);
    background: var(--app-panel);
    border-color: var(--app-border);
}

.report-pagination .page-link:hover,
.report-pagination .page-link:focus {
    color: var(--app-accent);
    background: rgba(13, 110, 253, 0.09);
    border-color: rgba(13, 110, 253, 0.35);
}

.report-pagination .page-item.active .page-link {
    color: #fff;
    background: var(--app-accent);
    border-color: var(--app-accent);
}

.report-pagination .page-item.disabled .page-link {
    color: var(--app-muted);
    background: var(--app-panel);
    border-color: var(--app-border);
    opacity: 0.58;
}

[data-bs-theme="dark"] .report-pagination .page-link {
    color: #e8edf4;
    background: #172131;
    border-color: #3c4b5f;
}

[data-bs-theme="dark"] .report-pagination .page-link:hover,
[data-bs-theme="dark"] .report-pagination .page-link:focus {
    color: #fff;
    background: #26364b;
    border-color: #6683aa;
}

[data-bs-theme="dark"] .report-pagination .page-item.active .page-link {
    color: #fff;
    background: #0d6efd;
    border-color: #4b91ff;
}

[data-bs-theme="dark"] .report-pagination .page-item.disabled .page-link {
    color: #8794a6;
    background: #111a27;
    border-color: #344257;
}
.duplicate-value {
    cursor: help;
    text-decoration: underline dotted;
    text-underline-offset: 0.2em;
}

.duplicate-tooltip .tooltip-inner {
    width: max-content;
    max-width: min(72rem, calc(100vw - 2rem));
    padding: 0.65rem 0.8rem;
    text-align: left;
    white-space: pre-line;
    overflow-wrap: anywhere;
    word-break: break-word;
}
