:root {
    --app-bg: #f2f5fa;
    --app-surface: #ffffff;
    --app-surface-soft: #f8faff;
    --app-sidebar: 286px;
    --app-sidebar-bg: #11182a;
    --app-sidebar-soft: #1a2339;
    --app-ink: #182033;
    --app-muted: #6c768c;
    --app-border: #e4e9f2;
    --app-primary: #5367f8;
    --app-primary-dark: #4053dc;
    --app-accent: #37c6d0;
    --app-danger: #e4526f;
    --app-success: #21a179;
    --app-warning: #e5a52f;
    --app-shadow: 0 12px 34px rgba(31, 42, 71, .075);
    --app-shadow-hover: 0 18px 42px rgba(31, 42, 71, .12);
    --bs-primary: #5367f8;
    --bs-primary-rgb: 83, 103, 248;
    --bs-link-color: #465be8;
    --bs-link-hover-color: #3044c7;
    --bs-body-font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
    --bs-body-color: #182033;
    --bs-border-color: #e4e9f2;
}

html,
body {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    overflow-x: hidden;
    overflow-x: clip;
}

body {
    overflow-x: hidden;
    background:
        radial-gradient(circle at 85% -10%, rgba(83, 103, 248, .12), transparent 29rem),
        radial-gradient(circle at 18% 105%, rgba(55, 198, 208, .09), transparent 34rem),
        var(--app-bg);
    color: var(--app-ink);
    font-size: .94rem;
    -webkit-font-smoothing: antialiased;
}

a {
    text-underline-offset: .17em;
}

/* Головний каркас і фірмова навігація. */
.app-shell {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
}

.app-sidebar {
    --bs-offcanvas-width: var(--app-sidebar);
    background:
        radial-gradient(circle at 20% 0, rgba(83, 103, 248, .28), transparent 18rem),
        linear-gradient(180deg, #131b2f 0%, var(--app-sidebar-bg) 100%);
    border: 0;
    color: #eaf0ff;
}

.app-sidebar::after {
    position: absolute;
    inset: auto 1rem 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .12), transparent);
    content: "";
}

.brand {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: 1.65rem 1.35rem 1.4rem;
    color: #fff;
    font-size: 1.02rem;
    font-weight: 760;
    letter-spacing: -.015em;
    line-height: 1.1;
    text-decoration: none;
}

.brand:hover {
    color: #fff;
}

.brand small {
    display: block;
    margin-top: .32rem;
    color: #92a0be;
    font-size: .68rem;
    font-weight: 550;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.brand-mark {
    display: inline-grid;
    width: 2.65rem;
    height: 2.65rem;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .23);
    border-radius: .9rem;
    background: linear-gradient(145deg, #7181ff, #5263ee 58%, #31bac7);
    box-shadow: 0 .6rem 1.5rem rgba(62, 80, 218, .38), inset 0 1px 0 rgba(255, 255, 255, .25);
    color: #fff;
    font-size: 1.25rem;
    font-weight: 800;
}

.sidebar-nav {
    min-height: 0;
    flex: 1 1 auto;
    flex-wrap: nowrap;
    gap: .28rem;
    overflow-x: hidden;
    overflow-y: auto;
    padding: .45rem .95rem 1rem;
    scrollbar-color: rgba(143, 155, 181, .4) transparent;
    scrollbar-width: thin;
}

.sidebar-nav .nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: .8rem;
    min-height: 46px;
    padding: .68rem .82rem;
    border: 1px solid transparent;
    border-radius: .85rem;
    color: #aeb9d0;
    font-size: .88rem;
    font-weight: 620;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}

.sidebar-nav .nav-link i {
    display: grid;
    width: 1.75rem;
    height: 1.75rem;
    place-items: center;
    border-radius: .55rem;
    background: rgba(255, 255, 255, .045);
    font-size: 1rem;
    transition: background-color .18s ease, color .18s ease;
}

.sidebar-nav .nav-link:hover {
    border-color: rgba(255, 255, 255, .06);
    background: rgba(255, 255, 255, .05);
    color: #fff;
    transform: translateX(2px);
}

.sidebar-nav .nav-link.active {
    border-color: rgba(124, 142, 255, .26);
    background: linear-gradient(90deg, rgba(83, 103, 248, .29), rgba(83, 103, 248, .12));
    box-shadow: inset 3px 0 0 #7888ff;
    color: #fff;
}

.sidebar-nav .nav-link.active i {
    background: #6678fa;
    box-shadow: 0 .35rem .85rem rgba(83, 103, 248, .35);
    color: #fff;
}

.sidebar-user {
    flex: 0 0 auto;
    margin: 0 .85rem .85rem;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, .075);
    border-radius: 1rem;
    background: rgba(255, 255, 255, .045);
    backdrop-filter: blur(8px);
}

.sidebar-user strong {
    color: #fff;
    font-size: .86rem;
}

.sidebar-user .text-secondary {
    color: #8f9bb5 !important;
    font-size: .72rem;
}

.sidebar-user .btn-outline-secondary {
    border-color: rgba(255, 255, 255, .13);
    background: rgba(255, 255, 255, .035);
    color: #c7d0e4;
}

.sidebar-user .btn-outline-secondary:hover {
    border-color: rgba(255, 255, 255, .24);
    background: rgba(255, 255, 255, .1);
    color: #fff;
}

.sidebar-user .logout-button {
    display: inline-flex;
    width: 100%;
    height: 2.35rem;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.sidebar-quick-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .5rem;
}

.sidebar-quick-actions > * {
    width: 100%;
    min-width: 0;
}

.sidebar-quick-actions .icon-button {
    width: 100%;
    height: 2.35rem;
    padding-inline: .5rem;
}

.sidebar-preference-button {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.sidebar-preference-button .sidebar-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-preference-menu {
    min-width: 15rem;
    max-height: min(24rem, 65vh);
    overflow-y: auto;
}

.sidebar-preference-menu form {
    display: contents;
}

.user-avatar {
    display: inline-grid;
    width: 2.55rem;
    height: 2.55rem;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .13);
    border-radius: .8rem;
    background: linear-gradient(145deg, rgba(115, 132, 255, .35), rgba(54, 196, 207, .22));
    color: #fff;
    font-weight: 800;
}

.min-width-0 {
    min-width: 0;
}

.app-main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 1.25rem;
}

.mobile-header {
    display: flex;
    min-height: 4.4rem;
    align-items: center;
    justify-content: space-between;
    padding: .65rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    background: rgba(17, 24, 42, .97);
    box-shadow: 0 .45rem 1.4rem rgba(22, 31, 54, .18);
    backdrop-filter: blur(14px);
}

.mobile-header .brand-mark {
    width: 2.35rem;
    height: 2.35rem;
    border-radius: .75rem;
}

.mobile-menu-button {
    border: 1px solid rgba(255, 255, 255, .3);
    background: linear-gradient(145deg, #6678fa, #4053dc);
    box-shadow: 0 .45rem 1rem rgba(37, 53, 139, .35);
    color: #fff;
}

.mobile-menu-button:hover,
.mobile-menu-button:focus-visible {
    border-color: rgba(255, 255, 255, .55);
    background: linear-gradient(145deg, #7585ff, #4b5ee6);
    color: #fff;
}

.brand-mobile {
    padding: 0;
}

.app-sidebar .offcanvas-header {
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    color: #fff;
}

.app-sidebar .btn-close {
    filter: invert(1) grayscale(1);
}

/* Виразний заголовок кожної робочої сторінки. */
.page-header {
    position: relative;
    display: flex;
    min-height: 168px;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.35rem;
    padding: 1.8rem 2rem;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 1.35rem;
    background:
        radial-gradient(circle at 82% 25%, rgba(55, 198, 208, .25), transparent 15rem),
        radial-gradient(circle at 62% 140%, rgba(105, 123, 255, .42), transparent 22rem),
        linear-gradient(125deg, #19233b 0%, #222f50 55%, #273d61 100%);
    box-shadow: 0 18px 40px rgba(26, 37, 65, .16);
    color: #fff;
}

.page-header::after {
    position: absolute;
    top: -5.5rem;
    right: 7%;
    width: 12rem;
    height: 12rem;
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 50%;
    box-shadow: 0 0 0 2.4rem rgba(255, 255, 255, .022), 0 0 0 4.8rem rgba(255, 255, 255, .016);
    content: "";
    pointer-events: none;
}

.page-header > * {
    position: relative;
    z-index: 1;
}

.page-header h1 {
    margin: .28rem 0 .45rem;
    font-size: clamp(1.75rem, 3vw, 2.45rem);
    font-weight: 780;
    letter-spacing: -.045em;
    line-height: 1.08;
}

.page-header p {
    max-width: 720px;
    margin: 0;
    color: #b8c4db;
    font-size: .96rem;
    line-height: 1.55;
}

.eyebrow {
    color: #77e1e6;
    font-size: .69rem;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.page-header .badge {
    padding: .65rem .85rem;
    border: 1px solid rgba(255, 255, 255, .15);
    box-shadow: 0 .4rem 1rem rgba(0, 0, 0, .12);
}

.page-header .btn-primary {
    border-color: rgba(255, 255, 255, .16);
    background: #fff;
    box-shadow: 0 .65rem 1.5rem rgba(4, 12, 28, .2);
    color: #233153;
}

.page-header .btn-primary:hover {
    border-color: #fff;
    background: #eef1ff;
    color: #17213a;
    transform: translateY(-1px);
}

.page-header .btn-outline-primary,
.page-header .btn-outline-secondary,
.page-header .btn-outline-danger {
    border-color: rgba(255, 255, 255, .19);
    background: rgba(255, 255, 255, .07);
    color: #eef3ff;
    backdrop-filter: blur(8px);
}

.page-header .btn-outline-primary:hover,
.page-header .btn-outline-secondary:hover,
.page-header .btn-outline-danger:hover {
    border-color: rgba(255, 255, 255, .34);
    background: rgba(255, 255, 255, .14);
    color: #fff;
}

/* Картки, статистика та загальна глибина інтерфейсу. */
.section-card,
.stat-card {
    border: 1px solid rgba(224, 230, 241, .92);
    border-radius: 1.15rem;
    background: rgba(255, 255, 255, .97);
    box-shadow: var(--app-shadow);
}

.section-card {
    overflow: visible;
}

.section-card .card-header,
.section-card .card-footer {
    border-color: var(--app-border);
    padding: 1.05rem 1.3rem;
}

.section-card .card-header:first-child {
    border-radius: 1.15rem 1.15rem 0 0;
}

.section-card .card-body {
    padding: 1.3rem;
}

.section-card h2,
.section-card h3 {
    letter-spacing: -.02em;
}

.stat-card {
    position: relative;
    overflow: hidden;
    transition: transform .2s ease, box-shadow .2s ease;
}

.stat-card::after {
    position: absolute;
    right: -2rem;
    bottom: -2.8rem;
    width: 7rem;
    height: 7rem;
    border-radius: 50%;
    background: rgba(83, 103, 248, .045);
    content: "";
}

.stat-card:hover {
    box-shadow: var(--app-shadow-hover);
    transform: translateY(-2px);
}

.stat-card-link {
    color: inherit;
    text-decoration: none;
}

.stat-card-link:focus-visible {
    outline: 3px solid rgba(83, 103, 248, .3);
    outline-offset: 3px;
}

.stat-card .card-body {
    position: relative;
    z-index: 1;
    display: flex;
    min-height: 154px;
    flex-direction: column;
    justify-content: flex-start;
    padding: 1.2rem;
}

.stat-card strong {
    display: block;
    margin: auto 0 .18rem;
    color: #17203a;
    font-size: 2.05rem;
    font-weight: 790;
    letter-spacing: -.045em;
    line-height: 1.05;
}

.stat-card .card-body > span:first-of-type {
    display: block;
    min-height: 2.65rem;
    overflow-wrap: anywhere;
}

.stat-card .card-body:has(.stat-icon) > span:first-of-type {
    padding-right: 3.25rem;
}

.stat-icon {
    position: absolute;
    top: 1.1rem;
    right: 1.1rem;
    display: grid;
    width: 2.65rem;
    height: 2.65rem;
    place-items: center;
    border-radius: .85rem;
    box-shadow: 0 .45rem 1rem rgba(44, 58, 104, .13);
    font-size: 1.08rem;
}

/* Власний вигляд кнопок замість стандартного Bootstrap. */
.btn {
    min-height: 42px;
    padding: .55rem .9rem;
    border-radius: .72rem;
    font-size: .86rem;
    font-weight: 680;
    transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease, border-color .16s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    border-color: transparent;
    background: linear-gradient(135deg, #6678ff, var(--app-primary) 58%, #4559e5);
    box-shadow: 0 .48rem 1.15rem rgba(83, 103, 248, .24);
}

.btn-primary:hover,
.btn-primary:focus-visible {
    border-color: transparent;
    background: linear-gradient(135deg, #5f71fa, var(--app-primary-dark));
    box-shadow: 0 .65rem 1.4rem rgba(83, 103, 248, .31);
    transform: translateY(-1px);
}

.btn-outline-primary {
    border-color: #cbd3ff;
    background: #f7f8ff;
    color: #4357df;
}

.btn-outline-primary:hover {
    border-color: #5367f8;
    background: #5367f8;
    color: #fff;
}

.btn-outline-secondary {
    border-color: #dbe1eb;
    background: #fff;
    color: #657086;
}

.btn-outline-secondary:hover {
    border-color: #bac3d3;
    background: #f3f5f9;
    color: #30394b;
}

.btn-outline-success {
    border-color: #afe2d2;
    background: #f4fcf9;
    color: #168463;
}

.btn-outline-success:hover {
    border-color: var(--app-success);
    background: var(--app-success);
    color: #fff;
}

.btn-outline-danger {
    border-color: #f2c8d1;
    background: #fff8f9;
    color: #c73e5a;
}

.btn-outline-danger:hover {
    border-color: var(--app-danger);
    background: var(--app-danger);
    color: #fff;
}

.btn-sm {
    min-height: 34px;
    padding: .35rem .65rem;
    border-radius: .6rem;
    font-size: .78rem;
}

/* Поля, фільтри та модальні форми. */
.form-control,
.form-select {
    min-height: 44px;
    border-color: #dfe5ef;
    border-radius: .72rem;
    background-color: #fbfcfe;
    color: #222b3e;
    font-size: .88rem;
    box-shadow: inset 0 1px 2px rgba(26, 34, 56, .018);
}

.form-control:hover,
.form-select:hover {
    border-color: #c9d1df;
    background-color: #fff;
}

.form-control:focus,
.form-select:focus {
    border-color: #8795fa;
    background-color: #fff;
    box-shadow: 0 0 0 .23rem rgba(83, 103, 248, .12);
}

.form-control::placeholder {
    color: #9ba5b8;
}

.form-label,
legend {
    margin-bottom: .42rem;
    color: #3a4458;
    font-size: .79rem;
    font-weight: 720;
}

.form-text {
    color: #7d879a;
    font-size: .75rem;
    line-height: 1.45;
}

.form-check-input {
    border-color: #cbd3e0;
}

.form-check-input:checked {
    border-color: var(--app-primary);
    background-color: var(--app-primary);
}

.form-check-input:focus {
    border-color: #8795fa;
    box-shadow: 0 0 0 .2rem rgba(83, 103, 248, .12);
}

.modal-backdrop.show {
    opacity: .56;
    backdrop-filter: blur(4px);
}

.modal-content {
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: 1.25rem;
    box-shadow: 0 2rem 5rem rgba(17, 24, 42, .27);
}

.modal-header {
    padding: 1.2rem 1.35rem;
    border-color: var(--app-border);
    background: linear-gradient(180deg, #fbfcff, #f7f9fd);
}

.modal-title {
    color: #1c263b;
    font-weight: 760;
    letter-spacing: -.025em;
}

.modal-body {
    padding: 1.35rem;
}

.modal-footer {
    padding: 1rem 1.35rem;
    border-color: var(--app-border);
    background: #fbfcfe;
}

/* Таблиці для великих робочих наборів. */
.table-responsive {
    overflow-x: auto;
    border-radius: 0 0 1.15rem 1.15rem;
    scrollbar-color: #c9d1e0 transparent;
    scrollbar-width: thin;
}

.table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: #f8faff;
    color: #263045;
}

.table > :not(caption) > * > * {
    padding: .86rem 1rem;
    border-color: #edf0f5;
    vertical-align: middle;
}

.table thead th {
    border-top: 0;
    border-bottom: 1px solid #e4e9f1;
    background: #f7f9fc;
    color: #737e92;
    font-size: .66rem;
    font-weight: 790;
    letter-spacing: .075em;
    text-transform: uppercase;
    white-space: nowrap;
}

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

.table tbody tr:hover {
    background: #f8faff;
}

.table tbody tr:hover > td:first-child {
    box-shadow: inset 3px 0 0 rgba(83, 103, 248, .55);
}

/* Неактивний рядок залишається приглушеним без opacity, яка створює окремий шар над dropdown сусіднього рядка. */
.table tbody tr.table-row-disabled > td {
    background: #f7f8fa;
    color: #8a93a5;
}

.table tbody tr.table-row-disabled > td strong,
.table tbody tr.table-row-disabled > td a:not(.btn) {
    color: #727c8f;
}

.table tbody tr.table-row-disabled:hover > td,
.table-hover > tbody > tr.table-row-disabled:hover > td:has(> .action-buttons) {
    background: #f2f4f7;
}

.table tbody td strong {
    color: #1d273c;
    font-weight: 710;
}

.table a:not(.btn) {
    color: #4259de;
    font-weight: 620;
    text-decoration: none;
}

.table a:not(.btn):hover {
    color: #293dbb;
    text-decoration: underline;
}

.table .product-link,
.table tbody tr.table-row-disabled > td .product-link {
    color: #4259de;
    font-weight: 650;
}

.table .product-link strong {
    color: inherit;
}

.table .product-link:hover,
.table tbody tr.table-row-disabled > td .product-link:hover {
    color: #293dbb;
}

.table-sort-link {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    color: inherit !important;
    font: inherit;
    letter-spacing: inherit;
    text-decoration: none !important;
}

.table-sort-link.active {
    color: #4259de !important;
}

.table-sort-link i {
    font-size: .72rem;
}

.empty-state {
    padding: 3.3rem 1rem !important;
    color: var(--app-muted) !important;
    font-size: .9rem;
    text-align: center;
}

.badge {
    padding: .38rem .55rem;
    border-radius: .48rem;
    font-size: .68rem;
    font-weight: 750;
    letter-spacing: .01em;
}

.badge.text-bg-success {
    background: #e2f7ef !important;
    color: #137557 !important;
}

.badge.text-bg-primary {
    background: #e8e4ff !important;
    color: #5944b7 !important;
}

.badge.text-bg-danger {
    background: #fde8ed !important;
    color: #be3653 !important;
}

.badge.text-bg-warning {
    background: #fff2d9 !important;
    color: #9a6411 !important;
}

.badge.text-bg-secondary {
    background: #edf0f5 !important;
    color: #657085 !important;
}

.badge.text-bg-light {
    border: 1px solid #e2e7ef;
    background: #f8f9fc !important;
    color: #596478 !important;
}

.badge.text-bg-info {
    background: #e1f8fa !important;
    color: #147983 !important;
}

.page-header .badge.text-bg-success {
    border-color: rgba(99, 226, 181, .32);
    background: rgba(33, 161, 121, .22) !important;
    color: #c4f8e5 !important;
}

.page-header .badge.text-bg-secondary {
    border-color: rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .1) !important;
    color: #edf1f8 !important;
}

.action-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: .38rem;
}

.action-buttons form {
    display: contents;
}

.action-dropdown .dropdown-menu {
    z-index: 1085;
    min-width: 13rem;
    padding: .4rem;
    border-color: var(--app-border);
    border-radius: .8rem;
    box-shadow: 0 1rem 2.5rem rgba(31, 42, 71, .18);
}

.action-dropdown .dropdown-item {
    width: 100%;
    min-height: 2.35rem;
    padding: .5rem .65rem;
    border: 0;
    border-radius: .55rem;
    background: transparent;
    color: var(--app-ink);
    font-size: .82rem;
    text-align: left;
    text-decoration: none;
}

.action-dropdown .dropdown-item:hover,
.action-dropdown .dropdown-item:focus-visible {
    background: #eef1ff;
    color: var(--app-primary-dark);
}

.action-dropdown .dropdown-item i {
    width: 1.1rem;
    flex: 0 0 1.1rem;
    text-align: center;
}

.action-dropdown .dropdown-action-form {
    display: block;
    width: 100%;
    margin: 0;
}

.action-menu-toggle::after {
    display: none;
}

.icon-button {
    display: inline-grid;
    width: 2.28rem;
    height: 2.28rem;
    min-height: 0;
    flex: 0 0 auto;
    padding: 0;
    place-items: center;
    border-radius: .62rem;
}

.icon-button i {
    font-size: .9rem;
}

.selector-list {
    display: flex;
    max-width: 360px;
    flex-wrap: wrap;
    gap: .28rem;
}

.selector-list code {
    max-width: 100%;
    padding: .2rem .4rem;
    overflow: hidden;
    border: 1px solid #e0e6ef;
    border-radius: .38rem;
    background: #f4f6fa;
    color: #4e596c;
    font-size: .69rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Панель фільтрів і пошук у великих довідниках. */
.page-header + .section-card {
    border-color: #dde3ee;
}

.filter-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto auto;
    gap: .7rem;
}

.filter-grid-wide {
    grid-template-columns: minmax(220px, 1.25fr) minmax(150px, .75fr) minmax(160px, .75fr) auto auto auto;
}

.filter-grid-listings {
    grid-template-columns: minmax(0, 1.45fr) minmax(0, .85fr) minmax(0, .72fr) minmax(0, .62fr) auto auto auto;
    align-items: center;
}

.filter-grid-listings > *,
.history-filter-grid > * {
    min-width: 0;
}

.filter-switch {
    display: inline-flex;
    min-height: 2.65rem;
    align-items: center;
    gap: .35rem;
    margin: 0;
    padding: .35rem .75rem .35rem 3rem;
    overflow: hidden;
    box-sizing: border-box;
    white-space: nowrap;
}

.filter-switch .form-check-input {
    flex: 0 0 auto;
}

.searchable-select {
    position: relative;
    min-width: 0;
}

.searchable-select.enhanced > select {
    display: none;
}

.searchable-options {
    position: absolute;
    z-index: 1080;
    top: calc(100% + .4rem);
    right: 0;
    left: 0;
    max-height: 290px;
    padding: .42rem;
    overflow-y: auto;
    border: 1px solid #dfe5ef;
    border-radius: .82rem;
    background: #fff;
    box-shadow: 0 1.2rem 2.8rem rgba(24, 32, 51, .17);
}

.searchable-option {
    display: block;
    width: 100%;
    padding: .65rem .72rem;
    border: 0;
    border-radius: .58rem;
    background: transparent;
    color: var(--app-ink);
    font-size: .84rem;
    text-align: left;
}

.searchable-option:hover,
.searchable-option:focus {
    outline: 0;
    background: #edf0ff;
    color: #3449ce;
}

.searchable-empty {
    padding: .85rem;
    color: var(--app-muted);
    text-align: center;
}

/* Службові блоки, сповіщення та код. */
.alert {
    border-width: 1px;
    border-radius: .9rem;
    box-shadow: 0 .45rem 1.2rem rgba(31, 42, 71, .045);
}

.alert-info {
    border-color: #bfe9ed;
    background: #eefbfc;
    color: #236d74;
}

.alert-warning {
    border-color: #f0d9a7;
    background: #fff8e9;
    color: #76571f;
}

.alert-danger {
    border-color: #f2c9d2;
    background: #fff3f5;
    color: #9f3049;
}

.alert-success {
    border-color: #bce6d8;
    background: #effaf6;
    color: #166e54;
}

.run-details > div {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 1rem;
    padding: .72rem 0;
    border-bottom: 1px solid var(--app-border);
}

.run-details dt {
    color: var(--app-muted);
    font-weight: 560;
}

.run-details dd {
    margin: 0;
    color: #2a3448;
    font-weight: 630;
}

.code-block {
    padding: 1rem 1.1rem;
    border: 1px solid rgba(255, 255, 255, .07);
    border-radius: .8rem;
    background: linear-gradient(145deg, #172036, #11182a);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
    color: #dfe7fa;
}

.pagination {
    gap: .3rem;
}

.pagination .page-link {
    display: grid;
    min-width: 2rem;
    height: 2rem;
    padding: 0 .45rem;
    place-items: center;
    border: 1px solid #dfe5ee;
    border-radius: .55rem !important;
    color: #667187;
    font-size: .75rem;
    font-weight: 700;
}

.pagination .page-item.active .page-link {
    border-color: var(--app-primary);
    background: var(--app-primary);
    box-shadow: 0 .35rem .8rem rgba(83, 103, 248, .22);
    color: #fff;
}

.tooltip {
    --bs-tooltip-bg: #11182a;
    --bs-tooltip-color: #f8fafc;
    --bs-tooltip-opacity: 1;
}

.tooltip-inner {
    padding: .42rem .62rem;
    border-radius: .45rem;
    background: #11182a;
    color: #f8fafc !important;
    font-size: .72rem;
    font-weight: 620;
}

[data-bs-theme="dark"] .tooltip {
    --bs-tooltip-bg: #f1f5fb;
    --bs-tooltip-color: #111827;
}

[data-bs-theme="dark"] .tooltip-inner {
    background: #f1f5fb;
    color: #111827 !important;
}

/* Окремий вигляд входу та встановлювача. */
.auth-shell {
    position: relative;
    display: grid;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1rem;
    place-items: center;
}

.auth-flashes {
    position: absolute;
    top: 1rem;
    left: 50%;
    z-index: 5;
    width: min(calc(100% - 2rem), 470px);
    transform: translateX(-50%);
}

.auth-shell::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(circle at 15% 20%, rgba(83, 103, 248, .2), transparent 24rem),
        radial-gradient(circle at 85% 80%, rgba(55, 198, 208, .15), transparent 27rem),
        linear-gradient(145deg, #eef2fa, #f8faff);
    content: "";
}

.auth-card {
    width: min(100%, 470px);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .8) !important;
    border-radius: 1.35rem;
    box-shadow: 0 2rem 5rem rgba(34, 45, 75, .16) !important;
}

.auth-brand {
    display: grid;
    width: 3.2rem;
    height: 3.2rem;
    border-radius: 1rem;
}

.auth-product {
    display: grid;
    gap: .18rem;
    justify-items: center;
}

.auth-product-name {
    color: #5264ec;
    font-size: 1.08rem;
    font-weight: 800;
    letter-spacing: .025em;
}

.auth-product-tagline {
    color: var(--bs-secondary-color);
    font-size: .86rem;
    line-height: 1.45;
}

.totp-qr-code {
    display: grid;
    width: min(100%, 15rem);
    aspect-ratio: 1;
    place-items: center;
    overflow: hidden;
    padding: .7rem;
    border: 1px solid var(--app-border);
    border-radius: 1.1rem;
    background: #fff;
    box-shadow: 0 .65rem 1.8rem rgba(28, 40, 73, .1);
}

.totp-qr-code svg {
    display: block;
    width: 100%;
    height: 100%;
}

.backup-file-input {
    min-height: 3.25rem;
    padding: .45rem;
    border-style: dashed;
    border-width: 1.5px;
    border-color: color-mix(in srgb, var(--bs-primary) 38%, var(--app-border));
    border-radius: .9rem;
    background: color-mix(in srgb, var(--bs-primary) 4%, var(--app-surface));
    line-height: 2.25rem;
    cursor: pointer;
}

.backup-file-input::file-selector-button {
    min-height: 2.35rem;
    margin: -.05rem .8rem -.05rem -.05rem;
    padding: .5rem .9rem;
    border: 0;
    border-radius: .65rem;
    background: color-mix(in srgb, var(--bs-primary) 14%, var(--app-surface));
    color: var(--bs-primary);
    font-weight: 700;
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease;
}

.backup-file-input:hover::file-selector-button {
    background: var(--bs-primary);
    color: #fff;
}

.backup-file-input:focus {
    border-style: solid;
}

@media (min-width: 992px) {
    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: var(--app-sidebar);
        transform: none !important;
        visibility: visible !important;
    }

    .app-sidebar .offcanvas-body {
        height: 100vh;
        min-height: 0;
        overflow: hidden;
    }

    .app-main {
        width: calc(100% - var(--app-sidebar));
        margin-left: var(--app-sidebar);
        padding: 2rem clamp(1.5rem, 3vw, 3.2rem) 3rem;
    }
}

@media (max-width: 991.98px) {
    .app-sidebar {
        --bs-offcanvas-width: 100vw;
        width: 100vw !important;
        max-width: none;
        height: 100dvh;
    }

    .app-sidebar .offcanvas-body {
        height: calc(100dvh - 65px);
    }

    .app-main {
        width: 100%;
        overflow-x: clip;
    }

    .filter-grid,
    .filter-grid-wide {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .page-header {
        min-height: 154px;
        padding: 1.55rem 1.6rem;
    }
}

@media (max-width: 575.98px) {
    body {
        font-size: .91rem;
    }

    .app-main {
        padding: 1rem .75rem 1.5rem;
    }

    .page-header {
        min-height: auto;
        flex-direction: column;
        align-items: stretch;
        padding: 1.4rem;
        border-radius: 1.1rem;
    }

    .page-header h1 {
        font-size: 1.72rem;
    }

    .page-header p {
        font-size: .88rem;
    }

    .page-header > .btn,
    .page-header > form,
    .page-header > form .btn {
        width: 100%;
    }

    .filter-grid,
    .filter-grid-wide {
        grid-template-columns: 1fr;
    }

    .section-card,
    .stat-card {
        border-radius: .95rem;
    }

    .section-card .card-body,
    .section-card .card-header,
    .section-card .card-footer {
        padding: 1rem;
    }

    .table > :not(caption) > * > * {
        padding: .72rem .78rem;
    }

    .modal-dialog {
        margin: .6rem;
    }
}

.api-permission-editor {
    padding: 1rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 1rem;
    background: rgba(37, 99, 235, .035);
}

.api-scope-option {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    height: 100%;
    padding: .75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: .8rem;
    background: var(--bs-body-bg);
    cursor: pointer;
}

.api-scope-option:hover {
    border-color: rgba(37, 99, 235, .45);
    background: rgba(37, 99, 235, .035);
}

.api-scope-option .form-check-input {
    flex: 0 0 auto;
    margin-top: .18rem;
}

.api-scope-option span,
.api-scope-option small {
    display: block;
    min-width: 0;
}

.api-scope-option small {
    margin-top: .15rem;
    color: var(--bs-secondary-color);
    font-family: var(--bs-font-monospace);
    overflow-wrap: anywhere;
}

.api-token-reveal {
    border: 0;
    box-shadow: var(--app-card-shadow);
}

.api-integration-records-card .table-responsive {
    min-height: 17rem;
}

.api-docs-layout {
    align-items: flex-start;
}

.api-docs-nav {
    top: 1rem;
}

.api-docs-nav a {
    display: block;
    padding: .42rem 0;
    color: var(--bs-secondary-color);
    text-decoration: none;
}

.api-docs-nav a:hover {
    color: var(--bs-primary);
}

.api-docs-definition {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
    margin: 1.25rem 0 0;
}

.api-docs-definition > div {
    min-width: 0;
    padding: .85rem 1rem;
    border-radius: .85rem;
    background: var(--bs-tertiary-bg);
}

.api-docs-definition dt {
    margin-bottom: .25rem;
    color: var(--bs-secondary-color);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.api-docs-definition dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.api-code-examples .accordion-item {
    overflow: hidden;
}

.api-code-examples .code-block {
    max-height: 28rem;
    overflow: auto;
}

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

.api-endpoint-table th:nth-child(1) {
    width: 10%;
}

.api-endpoint-table th:nth-child(2) {
    width: 29%;
}

.api-endpoint-table th:nth-child(3) {
    width: 31%;
}

.api-endpoint-table th:nth-child(4) {
    width: 23%;
}

.api-endpoint-table th:nth-child(5) {
    width: 7%;
}

.api-endpoint-table > tbody > tr:not(.api-endpoint-example-row) > td:nth-child(2) code,
.api-endpoint-table > tbody > tr:not(.api-endpoint-example-row) > td:nth-child(4) code {
    white-space: normal;
    overflow-wrap: anywhere;
}

.api-endpoint-example {
    min-width: 0;
    border-top: 1px solid #e5e9f2;
    border-bottom: 1px solid #e5e9f2;
    background: #f7f9fd;
}

.api-endpoint-example .code-block {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    max-height: 32rem;
    overflow: auto;
}

.api-endpoint-example .code-block code {
    white-space: pre;
}

.api-endpoint-example-row:hover > * {
    box-shadow: none !important;
}

.mw-320 {
    max-width: 320px;
}

@media (max-width: 767.98px) {
    .api-docs-definition {
        grid-template-columns: minmax(0, 1fr);
    }

    .api-integration-records-card .table-responsive {
        min-height: 14rem;
    }
}

/* Компактне бокове меню для ПК і планшетів з клавіатурно доступним перемикачем. */
.sidebar-brand-row {
    align-items: center;
    justify-content: space-between;
    min-height: 5.75rem;
    padding-right: .8rem;
}

.sidebar-brand-row .brand {
    min-width: 0;
    flex: 1;
}

.sidebar-collapse-button {
    width: 2.35rem;
    height: 2.35rem;
    flex: 0 0 2.35rem;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .06);
    color: #dce4f5;
}

.sidebar-collapse-button:hover,
.sidebar-collapse-button:focus-visible {
    border-color: rgba(255, 255, 255, .22);
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

@media (min-width: 992px) {
    .app-sidebar,
    .app-main {
        transition: width .22s ease, margin-left .22s ease, padding .22s ease;
    }

    body.sidebar-collapsed .app-sidebar {
        width: 86px;
    }

    body.sidebar-collapsed .app-main {
        width: calc(100% - 86px);
        margin-left: 86px;
    }

    body.sidebar-collapsed .sidebar-label {
        display: none !important;
    }

    body.sidebar-collapsed .sidebar-brand-row {
        flex-direction: column;
        gap: .55rem;
        min-height: 8rem;
        padding: .9rem 0;
    }

    body.sidebar-collapsed .sidebar-brand-row .brand {
        flex: 0 0 auto;
        padding: 0;
    }

    body.sidebar-collapsed .sidebar-nav {
        align-items: center;
        padding-inline: .65rem;
    }

    body.sidebar-collapsed .sidebar-nav .nav-link {
        width: 3.2rem;
        justify-content: center;
        padding: .55rem;
    }

    body.sidebar-collapsed .sidebar-nav .nav-link i {
        width: 2rem;
        height: 2rem;
        flex: 0 0 2rem;
    }

    body.sidebar-collapsed .sidebar-user {
        margin-inline: .55rem;
        padding: .7rem;
    }

    body.sidebar-collapsed .sidebar-user > .d-flex {
        justify-content: center;
        margin-bottom: .65rem !important;
    }

    body.sidebar-collapsed .sidebar-user form .btn {
        justify-content: center;
        padding-inline: .5rem;
    }

    body.sidebar-collapsed .sidebar-quick-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .35rem;
    }
}

/* Редактори контактів, відповідальності та явних правил доступу. */
.subsection,
.access-editor {
    padding: 1.1rem;
    border: 1px solid var(--app-border);
    border-radius: 1rem;
    background: var(--app-surface-soft);
}

.access-rule-list,
.contact-list {
    display: grid;
    gap: .65rem;
}

.access-rule-row {
    display: grid;
    grid-template-columns: minmax(15rem, 1fr) minmax(10rem, .45fr) auto;
    gap: .65rem;
    align-items: center;
}

.contact-row {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .85rem;
    border: 1px solid #e4e9f2;
    border-radius: .85rem;
    background: #fff;
}

.contact-row-number {
    display: grid;
    width: 1.8rem;
    height: 1.8rem;
    place-items: center;
    flex: 0 0 1.8rem;
    border-radius: .55rem;
    background: #eef1ff;
    color: #5367f8;
    font-size: .75rem;
    font-weight: 800;
}

/* Таблиці не розтягують сторінку: дії закріплені й залишаються в межах картки. */
.section-card,
.section-card .card-body,
.section-card .table-responsive {
    min-width: 0;
    max-width: 100%;
}

.section-card .table-responsive {
    overflow-x: auto;
    overscroll-behavior-inline: contain;
}

.table .action-buttons {
    width: max-content;
    max-width: none;
    flex-wrap: nowrap;
    gap: .38rem;
    margin-left: auto;
}

.table th:last-child.text-end,
.table td:has(> .action-buttons) {
    position: sticky;
    right: 0;
    z-index: 2;
    min-width: 4.5rem;
    background: #fff;
    box-shadow: -.75rem 0 1rem -.95rem rgba(31, 41, 70, .55);
}

.table thead th:last-child.text-end {
    z-index: 3;
    background: #f7f9fc;
}

.table-hover > tbody > tr:hover > td:has(> .action-buttons) {
    background: #f8faff;
}

.table td.action-dropdown-open {
    z-index: 25 !important;
}

.history-filter-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, .85fr) minmax(0, .72fr) minmax(0, .72fr) minmax(0, .72fr) minmax(0, .58fr) auto;
    gap: .75rem;
    align-items: center;
}

.filter-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: .55rem;
    justify-self: end;
}

/* Графік динаміки ціни з адаптивною легендою та підказкою. */
.price-chart-wrap {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.price-chart-wrap canvas {
    display: block;
    width: 100%;
    max-width: 100%;
    cursor: crosshair;
}

.chart-period-panel {
    display: grid;
    gap: 1rem;
}

.chart-period-buttons {
    display: flex;
    flex-wrap: wrap;
    width: fit-content;
    max-width: 100%;
}

.chart-period-buttons .btn {
    white-space: nowrap;
}

.chart-custom-period {
    max-width: 720px;
}

.chart-tooltip {
    position: absolute;
    z-index: 4;
    display: grid;
    min-width: 190px;
    gap: .2rem;
    padding: .7rem .8rem;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: .8rem;
    background: rgba(17, 24, 42, .94);
    box-shadow: 0 1rem 2rem rgba(17, 24, 42, .2);
    color: #f5f7ff;
    font-size: .76rem;
    pointer-events: none;
}

.chart-tooltip strong {
    margin-bottom: .2rem;
    font-size: .78rem;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--app-muted);
    font-size: .8rem;
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
}

.product-chart-legend {
    max-width: min(100%, 760px);
    max-height: 7rem;
    justify-content: flex-end;
    overflow-y: auto;
    padding: .15rem;
}

.chart-series-controls {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem .75rem;
    margin-bottom: 1rem;
}

.chart-series-toggle {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    min-width: 0;
    padding: .4rem .65rem;
    border: 1px solid var(--bs-border-color);
    border-radius: .7rem;
    background: #fff;
    color: var(--app-muted);
    font-size: .8rem;
    font-weight: 620;
}

.chart-series-toggle > i {
    width: .7rem;
    height: .7rem;
    flex: 0 0 .7rem;
    border-radius: 50%;
}

.chart-series-toggle a {
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-series-toggle a:hover {
    color: var(--app-primary-dark);
}

.chart-series-toggle:has(input:not(:checked)) {
    opacity: .52;
}

.product-chart-legend a {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    color: var(--app-muted);
    font-weight: 620;
    text-decoration: none;
}

.product-chart-legend a:hover {
    color: var(--app-primary-dark);
}

.chart-legend i {
    width: 1.7rem;
    height: .18rem;
    border-radius: 1rem;
}

.legend-client { background: #5367f8; }
.legend-rrp { background: #e09b36; }

.product-chart-tooltip {
    width: min(340px, calc(100% - 1rem));
    max-height: 310px;
    overflow-y: auto;
}

.product-chart-tooltip-row {
    display: grid;
    grid-template-columns: .65rem minmax(0, 1fr);
    align-items: center;
    gap: .5rem;
}

.product-chart-tooltip-row .legend-dot {
    width: .65rem;
    height: .65rem;
    border-radius: 50%;
}

@media (max-width: 991.98px) {
    .history-filter-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .history-filter-grid .filter-actions {
        justify-self: stretch;
    }
}

.page-help-button {
    position: static !important;
    width: 2.55rem;
    height: 2.55rem;
    flex: 0 0 2.55rem;
    border-color: rgba(255, 255, 255, .2);
    background: rgba(255, 255, 255, .08);
    color: #fff;
    backdrop-filter: blur(8px);
}

.page-header-actions {
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 auto;
    flex-wrap: nowrap !important;
    gap: .65rem;
}

.page-header-actions > * {
    flex: 0 0 auto;
}

.metric-link-button {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .2rem .48rem;
    border: 1px solid #dfe4ee;
    border-radius: .5rem;
    background: #f7f9fc;
    color: #4053dc;
    font: inherit;
    font-weight: 750;
    line-height: 1.25;
}

.metric-link-button:not(:disabled):hover,
.metric-link-button:not(:disabled):focus-visible {
    border-color: #b9c2ff;
    background: #eef1ff;
}

.metric-link-button:disabled {
    color: var(--app-muted);
    cursor: default;
    opacity: .75;
}

.metric-link-button.metric-link-danger {
    border-color: #f3c4ce;
    background: #fff2f5;
    color: #be3653;
}

.metric-link-button.metric-link-danger:hover,
.metric-link-button.metric-link-danger:focus-visible {
    border-color: #e993a6;
    background: #fde8ed;
    color: #a72b45;
}

.page-filter-button.filter-active {
    border-color: #77e1e6;
    background: rgba(119, 225, 230, .18);
    color: #fff;
    box-shadow: 0 0 0 .18rem rgba(119, 225, 230, .12);
}

.modal-filter-form {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    align-items: center;
}

.modal-filter-form > *,
.modal-filter-form .searchable-select {
    min-width: 0;
}

.modal-filter-form > input[type="hidden"] {
    display: none;
}

.modal-filter-form > .modal-filter-actions,
.modal-filter-form > .ms-lg-auto {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: flex-end;
    grid-column: 1 / -1;
    flex-wrap: wrap;
    gap: .65rem;
    margin-left: 0 !important;
}

.modal-filter-form .filter-switch {
    position: static;
    width: 100%;
}

.page-filter-modal .modal-body {
    min-height: min(430px, 65vh);
    overflow: visible;
    padding: 1.4rem;
}

.modal-filter-form > .searchable-select:first-of-type {
    grid-column: 1 / -1;
}

.modal-filter-form .form-control,
.modal-filter-form .form-select,
.modal-filter-form .filter-switch {
    min-height: 3.1rem;
}

.modal-filter-form .form-control,
.modal-filter-form .form-select {
    padding-top: .7rem;
    padding-bottom: .7rem;
}

.modal-filter-form .searchable-options {
    max-height: min(340px, 48vh);
}

.page-header > :first-child {
    min-width: 0;
}

.check-status-button {
    cursor: pointer;
    white-space: nowrap;
    transition: transform .15s ease, box-shadow .15s ease;
}

.check-status-button:hover,
.check-status-button:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 .35rem .8rem rgba(31, 41, 70, .16);
}

.check-details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
}

.check-details-grid > div {
    min-width: 0;
    padding: .8rem .9rem;
    border: 1px solid var(--app-border);
    border-radius: .8rem;
    background: var(--app-surface-soft);
}

.check-details-grid dt {
    margin-bottom: .2rem;
    color: var(--app-muted);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.check-details-grid dd {
    margin: 0;
    overflow-wrap: anywhere;
    font-weight: 650;
}

.detail-modal-content {
    max-height: 45vh;
    margin: 0;
    padding: 1rem;
    overflow: auto;
    border: 1px solid var(--app-border);
    border-radius: .8rem;
    background: #f7f9fc;
    color: #27324a;
    font-family: var(--bs-font-monospace);
    font-size: .78rem;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.page-help-button:hover,
.page-help-button:focus-visible {
    border-color: rgba(255, 255, 255, .38);
    background: rgba(255, 255, 255, .16);
    color: #fff;
}

.page-help-steps {
    display: grid;
    gap: .8rem;
    padding: 0;
    list-style: none;
    counter-reset: page-help;
}

.page-help-steps li {
    display: grid;
    grid-template-columns: 2rem 1fr;
    gap: .75rem;
    align-items: start;
    counter-increment: page-help;
}

.page-help-steps li::before {
    display: grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    border-radius: .65rem;
    background: #eef1ff;
    color: #5367f8;
    content: counter(page-help);
    font-size: .78rem;
    font-weight: 800;
}

.department-member-search {
    width: min(100%, 17rem);
}

.department-members-list {
    display: grid;
    max-height: 19rem;
    overflow-y: auto;
    border: 1px solid var(--app-border);
    border-radius: .85rem;
    background: var(--app-surface-soft);
}

.department-member-option {
    display: flex;
    min-width: 0;
    gap: .75rem;
    align-items: flex-start;
    padding: .8rem .9rem;
    cursor: pointer;
}

.department-member-option + .department-member-option {
    border-top: 1px solid var(--app-border);
}

.department-member-option:hover {
    background: #fff;
}

.department-member-option[hidden] {
    display: none;
}

.provider-link-card {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border: 1px solid var(--app-border);
    border-radius: 1rem;
    background: var(--app-surface-soft);
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.provider-link-card:hover,
.provider-link-card.is-active {
    border-color: rgba(83, 103, 248, .45);
    box-shadow: 0 .75rem 1.8rem rgba(38, 50, 100, .09);
    transform: translateY(-1px);
}

.provider-link-card.is-active {
    background: linear-gradient(145deg, rgba(83, 103, 248, .08), rgba(39, 183, 194, .06));
}

.provider-settings-panel {
    padding: 1rem;
    border: 1px solid var(--app-border);
    border-radius: 1rem;
    background: var(--app-surface-soft);
}

.provider-settings-panel[hidden] {
    display: none;
}

@media (max-width: 767.98px) {
    .access-rule-row {
        grid-template-columns: 1fr;
    }

    .access-rule-row .icon-button {
        justify-self: end;
    }

    .contact-row {
        flex-wrap: wrap;
    }

    .history-filter-grid {
        grid-template-columns: 1fr;
    }

    .filter-actions,
    .history-filter-grid .filter-actions {
        width: 100%;
        justify-self: stretch;
    }

    .filter-actions > * {
        flex: 1;
    }

    .product-chart-legend {
        width: 100%;
        max-height: 8.5rem;
        justify-content: flex-start;
    }
}

@media (max-width: 575.98px) {
    .page-header-actions {
        width: 100%;
        max-width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: .15rem;
    }

    .modal-filter-form {
        grid-template-columns: 1fr;
    }

    .page-filter-modal .modal-body {
        min-height: min(360px, 62vh);
        overflow-y: auto;
        padding: 1rem;
    }

    .modal-filter-form > .searchable-select:first-of-type {
        grid-column: 1;
    }

    .modal-filter-form > .modal-filter-actions,
    .modal-filter-form > .ms-lg-auto {
        grid-column: 1;
        justify-content: stretch;
    }

    .modal-filter-actions > * {
        flex: 1;
    }

    .check-details-grid {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}

/* Темна тема використовує ті самі компоненти й акцентні кольори без окремого шаблону сторінок. */
[data-bs-theme="dark"] {
    --app-bg: #0e1422;
    --app-surface: #171f30;
    --app-surface-soft: #1d2638;
    --app-ink: #e7ecf7;
    --app-muted: #9aa6bb;
    --app-border: #2b364b;
    --app-shadow: 0 12px 34px rgba(0, 0, 0, .22);
    --app-shadow-hover: 0 18px 42px rgba(0, 0, 0, .3);
    --bs-body-color: #e7ecf7;
    --bs-body-bg: #0e1422;
    --bs-border-color: #2b364b;
    --bs-link-color: #8d9bff;
    --bs-link-hover-color: #b1bbff;
}

[data-bs-theme="dark"] body {
    background:
        radial-gradient(circle at 85% -10%, rgba(83, 103, 248, .16), transparent 29rem),
        radial-gradient(circle at 18% 105%, rgba(55, 198, 208, .1), transparent 34rem),
        var(--app-bg);
    color: var(--app-ink);
}

[data-bs-theme="dark"] .section-card,
[data-bs-theme="dark"] .stat-card {
    border-color: rgba(53, 66, 91, .9);
    background: rgba(23, 31, 48, .97);
}

[data-bs-theme="dark"] .stat-card strong,
[data-bs-theme="dark"] .table tbody td strong,
[data-bs-theme="dark"] .modal-title,
[data-bs-theme="dark"] .form-label,
[data-bs-theme="dark"] legend {
    color: #edf2ff;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    border-color: #354158;
    background-color: #151d2c;
    color: #e7ecf7;
    color-scheme: dark;
}

[data-bs-theme="dark"] .form-control:hover,
[data-bs-theme="dark"] .form-select:hover,
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    border-color: #6474d7;
    background-color: #192235;
    color: #fff;
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: #78869e;
}

[data-bs-theme="dark"] .form-text,
[data-bs-theme="dark"] .text-secondary {
    color: #9ba7ba !important;
}

[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] .dropdown-menu {
    border-color: #344057;
    background: #171f30;
    color: #e7ecf7;
}

[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
    border-color: var(--app-border);
    background: linear-gradient(180deg, #1b2436, #171f30);
}

[data-bs-theme="dark"] .dropdown-item {
    color: #dce3f2;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background: #263149;
    color: #fff;
}

[data-bs-theme="dark"] .dropdown-item.active {
    background: #5367f8;
    color: #fff;
}

[data-bs-theme="dark"] .subsection,
[data-bs-theme="dark"] .access-editor,
[data-bs-theme="dark"] .contact-row {
    border-color: #303c52;
    background: #1b2436;
}

[data-bs-theme="dark"] .contact-row-number {
    background: #283252;
    color: #aeb8ff;
}

[data-bs-theme="dark"] .table {
    --bs-table-color: #dce3f0;
    --bs-table-bg: transparent;
    --bs-table-hover-color: #eef2fb;
    --bs-table-hover-bg: #1d273a;
    color: #dce3f0;
}

[data-bs-theme="dark"] .table > :not(caption) > * > * {
    border-color: #283348;
}

[data-bs-theme="dark"] .table thead th {
    border-color: #344057;
    background: #1b2435;
    color: #9aa7bc;
}

[data-bs-theme="dark"] .table tbody tr:hover {
    background: #1d273a;
}

[data-bs-theme="dark"] .table th:last-child.text-end,
[data-bs-theme="dark"] .table td:has(> .action-buttons) {
    background: #171f30;
}

[data-bs-theme="dark"] .table thead th:last-child.text-end {
    background: #1b2435;
}

[data-bs-theme="dark"] .table-hover > tbody > tr:hover > td:has(> .action-buttons) {
    background: #1d273a;
}

[data-bs-theme="dark"] .table tbody tr.table-row-disabled > td,
[data-bs-theme="dark"] .table tbody tr.table-row-disabled:hover > td,
[data-bs-theme="dark"] .table-hover > tbody > tr.table-row-disabled:hover > td:has(> .action-buttons) {
    background: #151c29;
    color: #77849a;
}

[data-bs-theme="dark"] .table tbody tr.table-row-disabled > td strong,
[data-bs-theme="dark"] .table tbody tr.table-row-disabled > td a:not(.btn) {
    color: #8996ac;
}

[data-bs-theme="dark"] .table a:not(.btn),
[data-bs-theme="dark"] .product-link {
    color: #91a0ff;
}

[data-bs-theme="dark"] dd,
[data-bs-theme="dark"] .run-details dd,
[data-bs-theme="dark"] .check-details-grid dd {
    color: #dce3f0;
}

[data-bs-theme="dark"] .text-bg-light {
    background: #2a354b !important;
    color: #e1e7f3 !important;
}

[data-bs-theme="dark"] .btn-outline-primary {
    border-color: #5968b8;
    background: #202a48;
    color: #a9b3ff;
}

[data-bs-theme="dark"] .btn-outline-secondary {
    border-color: #3c485e;
    background: #1a2333;
    color: #b7c0d2;
}

[data-bs-theme="dark"] .btn-outline-secondary:hover {
    border-color: #66748c;
    background: #2a3548;
    color: #fff;
}

[data-bs-theme="dark"] .btn-outline-success {
    border-color: #286c5b;
    background: #15342d;
    color: #75d8bd;
}

[data-bs-theme="dark"] .btn-outline-danger {
    border-color: #74394a;
    background: #351c26;
    color: #f09aae;
}

[data-bs-theme="dark"] .auth-shell::before {
    background:
        radial-gradient(circle at 15% 20%, rgba(83, 103, 248, .18), transparent 24rem),
        radial-gradient(circle at 85% 80%, rgba(55, 198, 208, .11), transparent 27rem),
        linear-gradient(145deg, #0e1422, #151d2c);
}

[data-bs-theme="dark"] .auth-product-name {
    color: #a7b4ff;
}
