/*
 * NVOCC interface layer. Loaded after the Rubick theme (app.css) on every page.
 * It restyles the theme's own classes, so pages keep their normal Rubick / Bootstrap markup.
 *
 * Usability rules this file holds to (many users read slowly):
 *   - text and controls are large; every clickable thing looks clickable
 *   - one meaning, one colour: navy = main action, green = approve, red = delete / remove, grey = go back
 *   - nothing moves or fades in on page load
 */

:root {
    /* Brand: taken from the Yaran Shipping Line logo */
    --ui-navy: #14305c;
    --ui-navy-dark: #0e2343;
    --ui-navy-soft: #e7ecf4;
    --ui-red: #b3202c;
    --ui-red-soft: #fbeaeb;
    --ui-green: #1b7a4b;
    --ui-green-dark: #14613b;
    --ui-green-soft: #e4f3ea;
    --ui-amber: #9a5b00;
    --ui-amber-soft: #fdf1da;
    --ui-marker: #f2a71b;

    /* Neutrals: slightly warm so pages read like paper */
    --ui-page: #f4f3ef;
    --ui-surface: #ffffff;
    --ui-surface-2: #f8f7f3;
    --ui-line: #dcd9d0;
    --ui-line-strong: #a8a79f;
    --ui-ink: #1a2530;
    --ui-muted: #55606a;

    --ui-radius: 6px;
    --ui-control: 32px;
    --ui-control-sm: 28px;
    --ui-topbar: 50px;
    --ui-nav: 232px;
    --ui-gutter: 16px;

    /* Rubick / Bootstrap tokens, so theme utility classes follow the same colours */
    --bs-primary: #14305c;
    --bs-primary-rgb: 20, 48, 92;
    --bs-theme-1-rgb: 20, 48, 92;
    --bs-theme-10-rgb: 20, 48, 92;
    --bs-theme-2-rgb: 244, 243, 239;
    --bs-theme-5-rgb: 220, 217, 208;
    --bs-theme-9-rgb: 27, 122, 75;
    --bs-theme-6-rgb: 179, 32, 44;
    --bs-success: #1b7a4b;
    --bs-success-rgb: 27, 122, 75;
    --bs-danger: #b3202c;
    --bs-danger-rgb: 179, 32, 44;
    --bs-body-font-family: "IBM Plex Sans", Roboto, "Segoe UI", Arial, sans-serif;
    --bs-font-roboto: "IBM Plex Sans", Roboto, "Segoe UI", Arial, sans-serif;
    --bs-body-font-size: 0.9375rem;
    --bs-body-color: #1a2530;
}

/* ---------- Page frame ---------- */

html {
    background: var(--ui-page);
}

html body,
html body.main {
    padding: 0 !important;
    color: var(--ui-ink);
    font-family: var(--bs-body-font-family);
    font-size: .8125rem;
    line-height: 1.4;
    background: var(--ui-page);
}

/* No entrance animations: content must be there as soon as the page opens. */
.intro-x,
.-intro-x,
.intro-y,
.-intro-y,
*>.intro-x:first-child,
*>.-intro-x:first-child,
*>.intro-y:first-child,
.side-nav ul li a,
.side-nav ul li.side-nav__devider {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
}

.zoom-in,
.zoom-in:hover {
    transform: none !important;
    box-shadow: none;
}

.ui-frame {
    display: flex;
    min-height: 100vh;
}

.content {
    flex: 1 1 0%;
    min-width: 0;
    min-height: 100vh;
    padding: 0 var(--ui-gutter) 56px;
    background: var(--ui-page);
    border-radius: 0;
}

.content:before {
    display: none;
}

a {
    text-underline-offset: 2px;
}

:focus-visible {
    outline: 3px solid var(--ui-marker);
    outline-offset: 1px;
}

h1, h2, h3, h4, h5 {
    color: var(--ui-ink);
    font-weight: 600;
    letter-spacing: 0;
}

.text-gray-600 {
    color: var(--ui-muted) !important;
}

.fs-sm,
.fs-xs,
.form-help {
    font-size: .78125rem !important;
}

/* ---------- Side menu ---------- */

/* The logo stays put; only the list below it scrolls. */
.side-nav,
.side-nav.side-nav--simple {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    flex: none;
    width: var(--ui-nav);
    height: 100vh;
    padding: 0;
    overflow: hidden;
    background: var(--ui-navy-dark);
}

.ui-nav-brand {
    display: flex;
    flex: none;
    align-items: center;
    height: var(--ui-topbar);
    padding: 0 14px;
    background: var(--ui-surface);
    border-bottom: 1px solid var(--ui-line);
}

.ui-nav-brand img {
    display: block;
    max-width: 100%;
    max-height: 38px;
    width: auto;
}

.side-nav #menuList {
    flex: 1 1 auto;
    min-height: 0;
    padding: 8px 8px 16px;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-color: #47618a transparent;
    scrollbar-width: thin;
}

.side-nav .side-menu {
    display: flex;
    align-items: center;
    height: auto;
    min-height: 34px;
    margin: 0 0 1px;
    padding: 4px 8px;
    color: #e6ecf5;
    font-size: .8125rem;
    line-height: 1.3;
    border-radius: var(--ui-radius);
    text-decoration: none;
}

.side-nav .side-menu .side-menu__icon {
    flex: none;
    color: inherit;
    z-index: auto;
}

.side-nav .side-menu .side-menu__icon:before,
.side-nav .side-menu--active:before,
.side-nav .side-menu--active:after,
.side-nav .side-menu--active .side-menu__icon:before,
.side-nav .side-menu--active .side-menu__icon:after {
    display: none !important;
    content: none !important;
}

.side-nav .side-menu .side-menu__icon svg {
    width: 17px;
    height: 17px;
}

.side-nav .side-menu .side-menu__title {
    display: flex;
    align-items: center;
    width: 100%;
    margin-left: 9px;
    color: inherit;
    font-weight: 400;
    z-index: auto;
}

.side-nav .side-menu .side-menu__title .side-menu__sub-icon {
    display: inline-flex;
    margin-left: auto;
    margin-right: 0;
    padding-left: 8px;
    opacity: .8;
}

/* Every state is reset first: the theme gives each level its own colours. */
.side-nav>ul>li>.side-menu.side-menu--active,
.side-nav>ul ul li a.side-menu.side-menu--active,
.side-nav>ul ul li a:not(.side-menu--active) {
    color: #e6ecf5;
    background: transparent;
    box-shadow: none;
}

.side-nav>ul>li>.side-menu.side-menu--active .side-menu__icon,
.side-nav>ul>li>.side-menu.side-menu--active .side-menu__title,
.side-nav>ul ul li a.side-menu--active .side-menu__title {
    color: inherit;
}

.side-nav>ul ul li a.side-menu:hover,
.side-nav>ul>li>.side-menu:hover {
    color: #fff;
    background: rgba(255, 255, 255, .1);
}

/* Level 1: the task areas read as headings. */
.side-nav #menuList>li {
    margin-bottom: 4px;
    border-radius: 8px;
}

.side-nav #menuList>li>.side-menu--group {
    color: #fff;
    font-weight: 500;
}

/* An open area sits on its own lighter panel, so it is clear what belongs to it. */
.side-nav #menuList>li:has(>.side-menu--open) {
    padding-bottom: 6px;
    background: rgba(255, 255, 255, .06);
}

.side-nav #menuList>li>.side-menu--open .side-menu__title {
    font-weight: 600;
}

/* Level 2 (Setup, Transaction...) */
.side-nav>ul ul,
.side-nav>ul ul ul {
    margin: 0;
    padding: 0 6px;
    background: transparent;
    border: 0;
    border-radius: 0;
}

.side-nav>ul>li>ul>li>.side-menu--group {
    min-height: 30px;
    padding: 3px 6px;
    color: #c3d0e3;
    font-size: .78125rem;
    font-weight: 500;
}

.side-nav>ul>li>ul>li>.side-menu--group.side-menu--open {
    color: #fff;
    font-weight: 600;
}

.side-nav>ul>li>ul>li>.side-menu--group .side-menu__icon svg {
    width: 15px;
    height: 15px;
}

/* Level 3: the pages themselves, stepped in under their group. */
.side-nav>ul ul ul {
    margin: 0 0 4px 13px;
    padding: 0 0 0 6px;
    border-left: 2px solid #3a5074;
}

.side-nav ul ul .side-menu:not(.side-menu--group) {
    min-height: 28px;
    padding: 3px 6px;
    font-size: .78125rem;
}

.side-nav ul ul .side-menu:not(.side-menu--group) .side-menu__icon svg {
    width: 14px;
    height: 14px;
}

.side-nav ul ul .side-menu .side-menu__title {
    margin-left: 10px;
}

/* The page you are on: one strong colour, used nowhere else in the menu. */
.side-nav>ul>li>.side-menu.side-menu--active:not(.side-menu--group),
.side-nav>ul ul li a.side-menu.side-menu--active:not(.side-menu--group),
.side-nav>ul>li>.side-menu.side-menu--active:not(.side-menu--group):hover,
.side-nav>ul ul li a.side-menu.side-menu--active:not(.side-menu--group):hover {
    color: var(--ui-navy-dark);
    background: var(--ui-marker);
}

.side-nav>ul>li>.side-menu.side-menu--active:not(.side-menu--group) .side-menu__title,
.side-nav>ul ul li a.side-menu.side-menu--active:not(.side-menu--group) .side-menu__title {
    color: var(--ui-navy-dark);
    font-weight: 600;
}

.side-nav>ul>li>.side-menu.side-menu--active:not(.side-menu--group) .side-menu__icon,
.side-nav>ul ul li a.side-menu.side-menu--active:not(.side-menu--group) .side-menu__icon {
    color: var(--ui-navy-dark);
}

/* Compact menu (user's choice, wide screens only): icons alone; opening a group expands it again. */
.side-nav.side-nav--simple {
    width: 60px;
}

.side-nav.side-nav--simple .ui-nav-brand {
    justify-content: center;
    padding: 0 8px;
}

.side-nav.side-nav--simple #menuList {
    padding-left: 10px;
    padding-right: 10px;
}

.side-nav.side-nav--simple .side-menu {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.side-nav.side-nav--simple .side-menu .side-menu__title,
.side-nav.side-nav--simple ul ul {
    display: none !important;
}

/* Pointing at the compact menu: the full menu with everything open, over the page so nothing else moves.
 * It is laid out at full width straight away and uncovered with clip-path: the page is not recalculated
 * on each frame and the labels do not re-wrap, so the slide stays smooth on long forms. */
.side-nav.side-nav--simple {
    clip-path: inset(0 calc(100% - 60px) 0 0);
}

.side-nav.is-peek {
    z-index: 70;
    margin-right: calc(60px - var(--ui-nav));
    box-shadow: 4px 0 18px rgba(14, 35, 67, .35);
    clip-path: inset(0 -24px 0 0);
    transition: clip-path .24s cubic-bezier(.4, 0, .2, 1);
}

.side-nav.is-peek.is-closing {
    clip-path: inset(0 calc(100% - 60px) 0 0);
}

/* The rows change place once when the groups open or close; a short fade hides that step. */
.side-nav.is-peek:not(.is-closing) #menuList,
.side-nav.is-peek:not(.is-closing) .ui-nav-brand,
.side-nav.is-settling #menuList,
.side-nav.is-settling .ui-nav-brand {
    animation: ui-nav-fade .22s ease-out;
}

@keyframes ui-nav-fade {
    from {
        opacity: .25;
    }

    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .side-nav.is-peek {
        transition: none;
    }

    .side-nav.is-peek #menuList,
    .side-nav.is-peek .ui-nav-brand,
    .side-nav.is-settling #menuList,
    .side-nav.is-settling .ui-nav-brand {
        animation: none;
    }
}

/* The first-level icons stay exactly where they were in the compact menu. */
.side-nav.is-peek #menuList>li>.side-menu {
    padding-left: 13.5px;
}

.side-nav.is-peek ul ul {
    display: block !important;
}

.side-nav.is-peek .side-menu__sub-icon {
    display: none !important;
}

.side-nav.is-peek #menuList>li:has(>ul) {
    padding-bottom: 6px;
    background: rgba(255, 255, 255, .06);
}

.ui-nav-backdrop {
    display: none;
}

/* ---------- Top bar ---------- */

.top-bar {
    position: sticky;
    top: 0;
    z-index: 60; /* above the theme's .intro-y panels (up to 51), so the search results open over them */
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--ui-topbar);
    margin: 0 calc(var(--ui-gutter) * -1);
    padding: 0 var(--ui-gutter);
    background: var(--ui-surface);
    border-bottom: 1px solid var(--ui-line);
}

.ui-icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: none;
    height: var(--ui-control);
    padding: 0 8px;
    color: var(--ui-ink);
    font-weight: 500;
    background: var(--ui-surface);
    border: 1px solid var(--ui-line-strong);
    border-radius: var(--ui-radius);
    cursor: pointer;
}

.ui-icon-btn:hover {
    background: var(--ui-surface-2);
    border-color: var(--ui-navy);
}

.top-bar .breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    min-width: 0;
    margin: 0 auto 0 0;
    color: var(--ui-muted);
    font-size: .8125rem;
    white-space: nowrap;
    overflow: hidden;
}

.top-bar .breadcrumb a {
    color: var(--ui-muted);
    text-transform: none !important;
}

.top-bar .breadcrumb a:hover {
    color: var(--ui-navy);
    text-decoration: underline;
}

.top-bar .breadcrumb .breadcrumb--active {
    color: var(--ui-ink);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-bar .breadcrumb .breadcrumb__icon {
    flex: none;
    width: 16px;
    height: 16px;
    margin: 0 6px;
    color: var(--ui-line-strong);
}

.ui-search {
    position: relative;
    flex: 0 1 340px;
    min-width: 170px;
}

.ui-search input {
    width: 100%;
    height: var(--ui-control);
    padding: 0 8px 0 30px;
    color: var(--ui-ink);
    font-size: .8125rem;
    background: var(--ui-surface-2);
    border: 1px solid var(--ui-line-strong);
    border-radius: var(--ui-radius);
}

.ui-search input::placeholder {
    color: var(--ui-muted);
}

.ui-search input:focus {
    background: var(--ui-surface);
    border-color: var(--ui-navy);
    outline: none;
    box-shadow: 0 0 0 3px rgba(20, 48, 92, .18);
}

.ui-search__icon {
    position: absolute;
    top: 50%;
    left: 9px;
    width: 15px;
    height: 15px;
    margin-top: -7.5px;
    color: var(--ui-muted);
    pointer-events: none;
}

.ui-search__results {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 60;
    width: min(440px, 88vw);
    max-height: 62vh;
    padding: 6px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--ui-surface);
    border: 1px solid var(--ui-line-strong);
    border-radius: var(--ui-radius);
    box-shadow: 0 10px 24px rgba(14, 35, 67, .18);
}

.ui-search__item {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 3px 8px;
    color: var(--ui-ink);
    border-radius: 4px;
    text-decoration: none;
}

.ui-search__item.is-current {
    background: var(--ui-navy-soft);
}

.ui-search__item svg {
    flex: none;
    width: 18px;
    height: 18px;
    color: var(--ui-navy);
}

.ui-search__section {
    margin-left: auto;
    padding-left: 10px;
    color: var(--ui-muted);
    font-size: .75rem;
    text-align: right;
    white-space: nowrap;
}

.ui-search__empty {
    padding: 12px 10px;
    color: var(--ui-muted);
}

.ui-user {
    position: relative;
    flex: none;
}

.ui-user__initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    color: #fff;
    font-size: .75rem;
    font-weight: 600;
    background: var(--ui-navy);
    border-radius: 50%;
}

.ui-user__name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-bar .dropdown-menu {
    min-width: 230px;
    padding: 6px;
    background: var(--ui-surface);
    border: 1px solid var(--ui-line-strong);
    border-radius: var(--ui-radius);
    box-shadow: 0 10px 24px rgba(14, 35, 67, .18);
}

.ui-user__who {
    padding: 8px 10px;
    border-bottom: 1px solid var(--ui-line);
    margin-bottom: 4px;
}

/* ---------- Page headings ---------- */

.ui-page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    margin-top: 10px;
}

.ui-page-title {
    margin: 0 auto 0 0;
    color: var(--ui-ink);
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.25;
}

.ui-page-count {
    color: var(--ui-muted);
}

/* ---------- Panels ---------- */

.box {
    background: var(--ui-surface);
    border: 1px solid var(--ui-line);
    border-radius: 8px;
    box-shadow: none;
}

.card {
    border-color: var(--ui-line);
    border-radius: 8px;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--ui-control);
    padding: 4px 12px;
    font-size: .8125rem;
    font-weight: 500;
    line-height: 1.2;
    border-width: 1px;
    border-radius: var(--ui-radius);
    box-shadow: none !important;
    cursor: pointer;
    transition: background-color .1s, border-color .1s, color .1s;
}

.btn-sm {
    min-height: var(--ui-control-sm);
    padding: 2px 8px;
    font-size: .75rem;
}

.btn-lg {
    min-height: 38px;
    padding: 6px 16px;
    font-size: 1rem;
}

.btn svg {
    flex: none;
    margin: 0 !important;
}

/* Older pages squeeze buttons with spacing utilities; keep them a usable size. */
.btn.p-1,
.btn.p-2 {
    padding: 2px 8px !important;
}

.btn-elevated-primary {
    color: #fff;
    background: var(--ui-navy);
    border-color: var(--ui-navy);
}

.btn-elevated-danger {
    color: var(--ui-ink);
    background: var(--ui-surface);
    border-color: var(--ui-line-strong);
}

.btn:disabled,
.btn.disabled {
    opacity: .5;
    cursor: not-allowed;
}

.btn-primary {
    color: #fff;
    background: var(--ui-navy);
    border-color: var(--ui-navy);
}

.btn-primary:hover,
.btn-primary:focus {
    color: #fff;
    background: var(--ui-navy-dark);
    border-color: var(--ui-navy-dark);
}

.btn-success {
    color: #fff;
    background: var(--ui-green);
    border-color: var(--ui-green);
}

.btn-success:hover,
.btn-success:focus {
    color: #fff;
    background: var(--ui-green-dark);
    border-color: var(--ui-green-dark);
}

.btn-danger {
    color: #fff;
    background: var(--ui-red);
    border-color: var(--ui-red);
}

.btn-danger:hover,
.btn-danger:focus {
    color: #fff;
    background: #8f1822;
    border-color: #8f1822;
}

.btn-warning {
    color: #3f2a00;
    background: var(--ui-marker);
    border-color: var(--ui-marker);
}

.btn-warning:hover {
    color: #3f2a00;
    background: #db9413;
    border-color: #db9413;
}

.btn-secondary,
.btn-outline-secondary {
    color: var(--ui-ink);
    background: var(--ui-surface);
    border-color: var(--ui-line-strong);
}

.btn-secondary:hover,
.btn-outline-secondary:hover,
.btn-secondary:focus,
.btn-outline-secondary:focus {
    color: var(--ui-ink);
    background: #eeece6;
    border-color: #7f7f78;
}

.btn-outline-primary {
    color: var(--ui-navy);
    background: var(--ui-surface);
    border-color: var(--ui-navy);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    color: var(--ui-navy);
    background: var(--ui-navy-soft);
    border-color: var(--ui-navy);
}

.btn-outline-danger {
    color: var(--ui-red);
    background: var(--ui-surface);
    border-color: var(--ui-red);
}

.btn-outline-danger:hover,
.btn-outline-danger:focus {
    color: #fff;
    background: var(--ui-red);
    border-color: var(--ui-red);
}

.btn-outline-success {
    color: var(--ui-green);
    background: var(--ui-surface);
    border-color: var(--ui-green);
}

.btn-outline-success:hover,
.btn-outline-success:focus {
    color: #fff;
    background: var(--ui-green);
    border-color: var(--ui-green);
}

.btn-outline-warning {
    color: var(--ui-amber);
    background: var(--ui-surface);
    border-color: var(--ui-amber);
}

.btn-outline-warning:hover,
.btn-outline-warning:focus {
    color: var(--ui-amber);
    background: var(--ui-amber-soft);
    border-color: var(--ui-amber);
}

.btn-close {
    box-shadow: none !important;
}

/* ---------- Form fields ---------- */

.form-label {
    display: block;
    margin-bottom: 2px;
    color: var(--ui-ink);
    font-size: .8125rem;
    font-weight: 500;
}

.form-control,
.form-select {
    min-height: var(--ui-control);
    padding: 4px 8px;
    color: var(--ui-ink);
    font-size: .8125rem;
    line-height: 1.35;
    background-color: var(--ui-surface);
    border: 1px solid var(--ui-line-strong);
    border-radius: var(--ui-radius);
    box-shadow: none;
}

.form-select {
    padding-right: 32px;
}

textarea.form-control {
    min-height: 50px;
}

/* Fields inside grids are the same size as every other field. */
.form-control-sm,
.form-select-sm {
    min-height: var(--ui-control);
    padding: 4px 8px;
    font-size: .8125rem;
    border-radius: var(--ui-radius);
}

.form-select-sm {
    padding-right: 32px;
}

.form-control::placeholder {
    color: #6d7880;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--ui-navy);
    outline: none;
    box-shadow: 0 0 0 3px rgba(20, 48, 92, .18);
}

.form-control:disabled,
.form-control[readonly],
.form-select:disabled {
    color: #3e4a54;
    background-color: #eeede7;
    border-color: var(--ui-line);
    opacity: 1;
}

.form-control.is-invalid,
.form-select.is-invalid {
    background-image: none;
    border-color: var(--ui-red);
    border-width: 2px;
}

.form-help {
    margin-top: 4px;
    color: var(--ui-muted);
}

.form-check-input {
    width: 16px;
    height: 16px;
    margin-top: 1px;
    border: 1px solid var(--ui-line-strong);
    cursor: pointer;
}

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

.form-check {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 22px;
    padding-left: 0;
}

.form-check .form-check-input {
    float: none;
    flex: none;
    margin: 0;
}

.form-check-label {
    margin: 0;
    cursor: pointer;
}

.input-group>.form-control,
.input-group>.form-select,
.input-group>.btn {
    min-height: var(--ui-control);
}

.input-group-text {
    background: var(--ui-surface-2);
    border-color: var(--ui-line-strong);
}

/* Search-as-you-type dropdowns line up with the other fields and show their arrow. */
.select2.select2-container {
    display: block;
    height: auto;
    padding: 0;
    background: transparent;
    border: 0;
}

.select2-container--default .select2-selection--single {
    position: relative;
    display: flex;
    align-items: center;
    height: var(--ui-control);
    background: var(--ui-surface);
    border: 1px solid var(--ui-line-strong);
    border-radius: var(--ui-radius);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    flex: 1;
    padding-left: 8px;
    padding-right: 44px;
    color: var(--ui-ink);
    font-size: .8125rem;
    line-height: 1.3;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #6d7880;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    display: block;
    top: 0;
    right: 6px;
    height: 100%;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    display: none;
}

.select2-container--default .select2-selection--single .select2-selection__arrow:after {
    content: "";
    position: absolute;
    top: 50%;
    right: 6px;
    width: 8px;
    height: 8px;
    margin-top: -6px;
    border-right: 2px solid var(--ui-muted);
    border-bottom: 2px solid var(--ui-muted);
    transform: rotate(45deg);
}

.select2-container--default .select2-selection--single .select2-selection__clear {
    margin-right: 22px;
    color: var(--ui-muted);
    font-size: 1.15rem;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--ui-navy);
    box-shadow: 0 0 0 3px rgba(20, 48, 92, .18);
}

.select2-container--default.select2-container--disabled .select2-selection--single {
    background: #eeede7;
    border-color: var(--ui-line);
}

.select2-dropdown {
    border-color: var(--ui-navy);
    border-radius: var(--ui-radius);
    z-index: 1060;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    height: 30px;
    padding: 3px 8px;
    font-size: .8125rem;
    border: 1px solid var(--ui-line-strong);
    border-radius: 4px;
}

.select2-results__option {
    padding: 5px 8px;
    font-size: .8125rem;
}

.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    color: #fff;
    background: var(--ui-navy);
}

/* ---------- Tables ---------- */

.table {
    --bs-table-bg: transparent;
    margin-bottom: 0;
    color: var(--ui-ink);
    font-variant-numeric: tabular-nums;
    border-color: var(--ui-line);
}

.ui-table-box {
    margin-top: 10px;
    overflow-x: auto;
    background: var(--ui-surface);
    border: 1px solid var(--ui-line);
    border-radius: 8px;
}

.ui-table-box>.table,
.ui-table-box>* .table {
    margin: 0 !important;
}

.table th,
.table thead th {
    padding: 6px 8px;
    color: var(--ui-ink);
    font-size: .78125rem;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    vertical-align: middle;
    background: #eeede6;
    border-color: var(--ui-line);
    border-bottom: 1px solid var(--ui-line-strong);
}

.table th.text-end {
    text-align: right;
}

.table th.text-center {
    text-align: center;
}

.table td {
    padding: 5px 8px;
    vertical-align: middle;
    border-color: var(--ui-line);
}

.table-sm th,
.table-sm thead th,
.table-sm td {
    padding: 3px 5px;
}

/* Rows are separated by lines only, which is easier to follow across a wide table. */
.table-bordered>:not(caption)>*>* {
    border-width: 0 0 1px;
}

.table-bordered>:not(caption)>* {
    border-width: 0;
}

.table>tbody>tr:last-child>td {
    border-bottom-width: 0;
}

.table-hover>tbody>tr:hover>* {
    --bs-table-accent-bg: transparent;
    background: #f1f4f9;
}

.table-striped>tbody>tr:nth-of-type(odd)>* {
    --bs-table-accent-bg: transparent;
    background: var(--ui-surface-2);
}

.table-report {
    border-collapse: collapse;
    border-spacing: 0;
}

.table-report td {
    background: var(--ui-surface);
    box-shadow: none;
}

.table-report td:first-child,
.table-report td:last-child {
    border-radius: 0;
}

.table a:not(.btn) {
    color: var(--ui-navy);
    font-weight: 500;
    text-decoration: underline;
}

.ui-row-actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
}

.ui-row-actions form {
    margin: 0;
}

/* ---------- Tabs ---------- */

.nav-tabs {
    gap: 2px;
    border-bottom: 0;
    box-shadow: inset 0 -2px 0 var(--ui-line-strong);
}

.nav-tabs .nav-item {
    margin-bottom: 0;
}

.nav-tabs .nav-link,
.nav-tabs .nav-link:hover,
.nav-tabs .nav-link:focus,
.nav-tabs .nav-link.active {
    border-style: solid;
    border-color: transparent;
    border-width: 0 0 3px;
    outline: 0;
    box-shadow: none;
}

.nav-tabs .nav-link {
    min-height: 32px;
    margin-bottom: 0;
    padding: 4px 12px;
    color: var(--ui-muted);
    font-size: .8125rem;
    font-weight: 500;
    background: transparent;
    border: 0;
    border-bottom: 3px solid transparent;
    border-radius: 0;
}

.nav-tabs .nav-link:hover {
    color: var(--ui-navy);
    background: var(--ui-surface-2);
    border-bottom-color: var(--ui-line-strong);
}

.nav-tabs .nav-link.active {
    color: var(--ui-navy);
    font-weight: 600;
    background: transparent;
    border-bottom-color: var(--ui-navy);
}

.tab-content.border {
    border-color: var(--ui-line) !important;
}

/* ---------- Messages ---------- */

.alert {
    padding: 6px 10px;
    color: var(--ui-ink);
    font-size: .8125rem;
    border: 1px solid var(--ui-line);
    border-left-width: 4px;
    border-radius: var(--ui-radius);
}

.alert-danger {
    background: var(--ui-red-soft);
    border-color: #e3b5b8;
    border-left-color: var(--ui-red);
}

.alert-warning,
.alert-warning-soft {
    color: var(--ui-ink);
    background: var(--ui-amber-soft);
    border-color: #ecd6a6;
    border-left-color: var(--ui-amber);
}

.alert-success,
.alert-success-soft,
.alert-outline-success {
    color: var(--ui-ink);
    background: var(--ui-green-soft);
    border-color: #b6dcc5;
    border-left-color: var(--ui-green);
}

.alert-info,
.alert-secondary-soft {
    color: var(--ui-ink);
    background: var(--ui-navy-soft);
    border-color: #c8d3e4;
    border-left-color: var(--ui-navy);
}

.ui-flash {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 8px;
}

.ui-flash svg {
    flex: none;
    width: 18px;
    height: 18px;
}

.ui-flash__close {
    flex: none;
    margin-left: auto;
    padding: 2px 10px;
    color: var(--ui-ink);
    font-weight: 500;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
}

.ui-flash__close:hover {
    border-color: var(--ui-line-strong);
}

.badge {
    display: inline-block;
    padding: 4px 9px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.25;
    border-radius: 4px;
}

.badge.bg-success {
    color: #0f5a35 !important;
    background: var(--ui-green-soft) !important;
    border: 1px solid #a9d6bc;
}

.badge.bg-danger {
    color: #8f1822 !important;
    background: var(--ui-red-soft) !important;
    border: 1px solid #e3b5b8;
}

.badge.bg-warning {
    color: #6d4100 !important;
    background: var(--ui-amber-soft) !important;
    border: 1px solid #e8cd91;
}

.badge.bg-secondary {
    color: #38434d !important;
    background: #e8e7e0 !important;
    border: 1px solid #cdccc3;
}

.badge.bg-primary,
.badge.bg-info {
    color: var(--ui-navy) !important;
    background: var(--ui-navy-soft) !important;
    border: 1px solid #c8d3e4;
}

abbr.ui-abbr {
    cursor: help;
    text-decoration: underline dotted var(--ui-line-strong);
    text-underline-offset: 3px;
}

/* ---------- Dialogs and notices ---------- */

.modal-content {
    border: 0;
    border-radius: 8px;
}

.modal-header {
    border-bottom: 1px solid var(--ui-line);
}

.modal-footer {
    border-top: 1px solid var(--ui-line);
}

.swal2-popup {
    font-family: var(--bs-body-font-family);
    border-radius: 8px;
}

.swal2-popup .swal2-title {
    color: var(--ui-ink);
    font-size: 1.3rem;
    font-weight: 600;
}

.swal2-popup .swal2-html-container {
    color: var(--ui-ink);
    font-size: 1rem;
}

.swal2-popup .swal2-styled {
    min-width: 120px;
    min-height: 46px;
    padding: 8px 20px;
    font-size: 1rem;
    font-weight: 500;
    border-radius: var(--ui-radius);
    box-shadow: none !important;
}

.swal2-popup.swal2-toast .swal2-title {
    font-size: 1rem;
    font-weight: 500;
}

/* ---------- Pagination ---------- */

.pagination {
    flex-wrap: wrap;
    gap: 4px;
    margin: 0;
}

.pagination .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    min-height: var(--ui-control-sm);
    color: var(--ui-navy);
    background: var(--ui-surface);
    border: 1px solid var(--ui-line-strong);
    border-radius: 4px;
    box-shadow: none;
}

.pagination .page-item.active .page-link {
    color: #fff;
    font-weight: 600;
    background: var(--ui-navy);
    border-color: var(--ui-navy);
}

.pagination .page-item.disabled .page-link {
    color: #8c9198;
    background: #eeede7;
    border-color: var(--ui-line);
}

/* ---------- Forms: the action bar stays on screen while scrolling ---------- */

.ui-form-bar {
    position: sticky;
    top: var(--ui-topbar);
    z-index: 30;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    padding: 6px 12px;
    background: var(--ui-surface);
    border-bottom: 1px solid var(--ui-line);
    border-radius: 8px 8px 0 0;
}

.ui-form-bar__title {
    margin: 0 auto 0 0;
    font-size: 1rem;
    font-weight: 600;
}

.ui-form-bar__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* ---------- Older pages that build their own form header ---------- */

.content .box>.d-flex.border-bottom:first-child,
.content form>.box>.d-flex.border-bottom:first-child {
    position: sticky;
    top: var(--ui-topbar);
    z-index: 30;
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 12px !important;
    background: var(--ui-surface);
    border-bottom: 1px solid var(--ui-line) !important;
    border-radius: 8px 8px 0 0;
}

.modal .box>.d-flex.border-bottom:first-child {
    position: static;
}

.content .box h2.fs-base {
    font-size: 1rem !important;
    font-weight: 600 !important;
    white-space: normal;
}

.content .box label:not(.form-check-label) {
    font-weight: 500;
}

/* Older pages space their buttons with a margin as well; the gap above is enough. */
.content .box>.d-flex.border-bottom:first-child .btn.me-2 {
    margin-right: 0 !important;
}

/* Plain labels look the same as .form-label, and the field sits equally close under them. */
.content label:not(.form-check-label):not(.btn) {
    font-size: .8125rem;
}

.content .box .ui-perm-table label {
    font-size: .875rem;
}

.content label.fs-sm,
.content label.fs-xs {
    font-size: .8125rem !important;
}

.content label:not([class]):not(:has(input, select)),
.content label[class^="lbl_"] {
    display: block;
    margin-bottom: 2px;
}

.content label:not([class])+.mt-2,
.content label[class^="lbl_"]+.mt-2 {
    margin-top: 0 !important;
}

/* Tom Select dropdowns are the same size as every other field. */
.content .ts-control .ts-input {
    min-height: var(--ui-control);
    padding: 4px 30px 4px 8px;
    font-size: .8125rem;
    line-height: 1.35;
    border: 1px solid #8a93a0;
    border-radius: var(--ui-radius);
    box-shadow: none;
}

.content .ts-control.focus .ts-input {
    border-color: var(--ui-navy);
    box-shadow: 0 0 0 3px rgba(20, 48, 92, .18);
}

.content .ts-control.disabled .ts-input {
    background-color: #d9dee6;
    border-color: #d9dee6;
}

.content .ts-dropdown {
    font-size: .8125rem;
}

/* A dropdown written as .form-control still shows its arrow, so it does not look like a text box. */
select.form-control:not([multiple]):not(:disabled) {
    padding-right: 32px;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%231a2530' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px 10px;
    cursor: pointer;
}

.content .box>form>.row,
.content>.row {
    margin-left: 0;
    margin-right: 0;
}

.btn-label-secondary {
    color: var(--ui-ink);
    background: var(--ui-surface);
    border-color: var(--ui-line-strong);
}

.btn-xs {
    min-height: var(--ui-control-sm);
    padding: 2px 8px;
    font-size: .75rem;
}

/* ---------- Dashboard ---------- */

.ui-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 6px;
    font-size: .9375rem;
    font-weight: 600;
}

.ui-section-title a {
    margin-left: auto;
    color: var(--ui-navy);
    font-size: .8125rem;
    font-weight: 500;
    text-decoration: underline;
}

.ui-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
    gap: 8px;
}

.ui-tile {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 5px 8px;
    color: var(--ui-ink);
    font-weight: 500;
    line-height: 1.25;
    background: var(--ui-surface);
    border: 1px solid var(--ui-line-strong);
    border-radius: 8px;
    text-decoration: none;
}

.ui-tile:hover {
    color: var(--ui-navy);
    background: var(--ui-navy-soft);
    border-color: var(--ui-navy);
}

.ui-tile__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 30px;
    height: 30px;
    color: #fff;
    background: var(--ui-navy);
    border-radius: 6px;
}

.ui-tile__icon svg {
    width: 16px;
    height: 16px;
}

.ui-tile--plain .ui-tile__icon {
    color: var(--ui-navy);
    background: var(--ui-navy-soft);
}

.ui-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ui-stat {
    display: flex;
    flex: 1 1 165px;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    color: var(--ui-ink);
    background: var(--ui-surface);
    border: 1px solid var(--ui-line);
    border-radius: 8px;
    text-decoration: none;
}

.ui-stat__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 30px;
    height: 30px;
    color: var(--ui-navy);
    background: var(--ui-navy-soft);
    border-radius: 6px;
}

.ui-stat__icon svg {
    width: 16px;
    height: 16px;
}

.ui-stat:hover {
    background: var(--ui-navy-soft);
    border-color: var(--ui-navy);
}

.ui-stat__value {
    display: block;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.ui-stat__label {
    display: block;
    margin-top: 2px;
    color: var(--ui-muted);
}

.ui-panels {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 0 10px;
}

.ui-panel--4 {
    grid-column: span 4;
}

.ui-panel--8 {
    grid-column: span 8;
}

.ui-panel__body {
    padding: 10px;
}

.ui-kv {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 3px 0;
    border-bottom: 1px solid #ebe9e2;
}

.ui-kv:last-child {
    border-bottom: 0;
}

.ui-kv>span:last-child {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---------- Compact spacing: as many fields as possible on one screen ---------- */

.gy-3,
.gy-4,
.g-3,
.g-4 {
    --bs-gutter-y: .4rem;
}

.content .row {
    --bs-gutter-x: .75rem;
}

.content .box .p-5 {
    padding: .5rem .75rem !important;
}

.content .tab-content.p-4,
.content .tab-content .p-4,
.content .box .p-4 {
    padding: .5rem .625rem !important;
}

.content .box .mb-5,
.content .box .mb-4 {
    margin-bottom: .4rem !important;
}

.content .box .mb-3 {
    margin-bottom: .3rem !important;
}

.content .box .mt-5,
.content .box .mt-4,
.content .box .mt-3 {
    margin-top: .4rem !important;
}

.content .box .form-check.mb-2 {
    margin-bottom: 5px !important;
}

/* Long pages split into tabs: the bar of tabs stays with the Save bar. */
.content .tab-content.border {
    border-top: 0 !important;
}

/* ---------- Sign-in pages keep comfortable sizes ---------- */

.ui-login__form .form-label {
    font-size: .9375rem;
}

/* ---------- Forms that are easy to read at a glance ----------
 * Navy header with a bright Save, tabs that look like buttons, white fields on a tinted panel,
 * yellow for fields that must still be filled, flat grey for fields that cannot be changed.
 */

.ui-form-bar,
.content .box>.d-flex.border-bottom:first-child,
.content form>.box>.d-flex.border-bottom:first-child {
    background: var(--ui-navy);
    border-bottom: 0 !important;
}

.ui-form-bar__title,
.content .box>.d-flex.border-bottom:first-child>h2 {
    color: #fff;
}

.ui-form-bar .btn-primary,
.content .box>.d-flex.border-bottom:first-child .btn-primary {
    color: var(--ui-navy-dark);
    font-weight: 600;
    background: var(--ui-marker);
    border-color: var(--ui-marker);
}

.ui-form-bar .btn-primary:hover,
.ui-form-bar .btn-primary:focus,
.content .box>.d-flex.border-bottom:first-child .btn-primary:hover {
    color: var(--ui-navy-dark);
    background: #ffbb33;
    border-color: #ffbb33;
}

.modal .box>.d-flex.border-bottom:first-child {
    background: var(--ui-surface);
    border-bottom: 1px solid var(--ui-line) !important;
}

.modal .box>.d-flex.border-bottom:first-child>h2 {
    color: var(--ui-ink);
}

.ui-legend {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 12px;
    color: #dbe3ef;
    font-size: .75rem;
    font-weight: 400;
    white-space: nowrap;
}

.ui-legend:before {
    content: "";
    width: 18px;
    height: 12px;
    background: #fff3bf;
    border: 1px solid #c99700;
    border-radius: 2px;
}

/* The working area is tinted so that white fields stand out from it. */
.ui-form-bar+.p-5,
.content .box>.d-flex.border-bottom:first-child+* {
    background: #e9edf4;
    border-radius: 0 0 8px 8px;
}

.content .section-card {
    background: #e9edf4;
    border-color: #c8d3e4;
}

.content .section-card .section-header {
    background: #d8e0ec;
    border-bottom-color: #c8d3e4;
}

.content .section-card .section-header h5 {
    color: var(--ui-navy);
    font-size: .8125rem;
}

.content .section-card .section-body {
    padding: .4rem .625rem;
}

.content .section-card {
    margin-bottom: .5rem;
}

.form-label,
.content .box label:not(.form-check-label) {
    color: var(--ui-ink);
    font-weight: 600;
}

.form-control,
.form-select,
.select2-container--default .select2-selection--single {
    background-color: #fff;
    border-color: #8a93a0;
}

.form-control:disabled,
.form-control[readonly],
.form-select:disabled,
.select2-container--default.select2-container--disabled .select2-selection--single {
    color: #2c3640;
    background-color: #d9dee6;
    border-color: #d9dee6;
}

.form-select:disabled {
    background-image: none;
}

.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__arrow {
    display: none;
}

/* Must be filled and still empty. Turns white by itself once it has a value. */
.form-control:required:not(:disabled):invalid,
.form-select:required:not(:disabled):invalid,
select:required:invalid+.select2-container--default .select2-selection--single {
    background-color: #fff3bf;
    border-color: #c99700;
}

.form-control.is-invalid,
.form-select.is-invalid {
    background-color: #fff;
    border-color: var(--ui-red);
}

.form-check-label {
    color: var(--ui-ink);
    font-size: .8125rem;
    font-weight: 500;
}

.form-check-input:disabled~.form-check-label {
    opacity: .75;
}

.form-check-input {
    background-color: #fff;
    border-color: #8a93a0;
}

/* Tabs look like buttons: the open one is solid and joined to its panel. */
.nav-tabs {
    gap: 3px;
    box-shadow: inset 0 -2px 0 var(--ui-navy);
}

.nav-tabs .nav-link,
.nav-tabs .nav-link:focus {
    color: var(--ui-ink);
    font-weight: 500;
    background: #d3dae5;
    border-width: 0;
    border-radius: 6px 6px 0 0;
}

.nav-tabs .nav-link:hover {
    color: var(--ui-navy);
    background: #bfc9d9;
    border-width: 0;
}

.nav-tabs .nav-link.active,
.nav-tabs .nav-link.active:hover,
.nav-tabs .nav-link.active:focus {
    color: #fff;
    font-weight: 600;
    background: var(--ui-navy);
    border-width: 0;
}

.content .tab-content.border {
    background: #f4f6fa;
    border: 1px solid #c8d3e4 !important;
    border-top: 0 !important;
}

/* Grids: white rows, a clear heading, and numbers that are not cut off. */
.tab-content .table,
.ui-form-bar+.p-5 .table,
.section-body .table {
    background: #fff;
}

.tab-content .table th,
.ui-form-bar+.p-5 .table th {
    color: #fff;
    background: #33507e;
    border-color: #33507e;
}

.table .form-control,
.table .form-select {
    min-width: 72px;
}

.table input[type="number"] {
    min-width: 84px;
}

.table .select2-container {
    min-width: 130px;
}

.ui-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    margin-left: 4px;
    color: #fff;
    font-size: .625rem;
    font-weight: 600;
    font-style: normal;
    line-height: 1;
    vertical-align: text-top;
    background: #33507e;
    border-radius: 50%;
    cursor: help;
}

.ui-section-tabs {
    margin-bottom: .4rem;
}

/* Inside a tab the group needs no frame or heading of its own: the tab is its heading. */
.ui-section-tabs .section-card {
    margin: 0;
    background: transparent;
    border: 0;
}

.ui-section-tabs .section-card .section-header,
.ui-section-tabs .field-box>.group-title {
    display: none;
}

.ui-section-tabs .section-card .section-body,
.ui-section-tabs .field-box {
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

/* Note boxes start short and can be pulled larger with the corner handle. */
.content form textarea.form-control {
    resize: vertical;
}

.content form textarea.form-control[rows="2"],
.content form textarea.form-control[rows="3"],
.content form textarea.form-control[rows="4"] {
    height: 50px;
}

.content form textarea.form-control:not([rows="1"]):not([rows="2"]):not([rows="3"]):not([rows="4"]) {
    height: 88px;
}

/* Everything fits the screen: no empty band under the page. */
.content {
    padding-bottom: 8px;
}

.content .box .p-3 {
    padding: .375rem .5rem !important;
}

.ui-help-fold {
    display: inline-flex;
    align-items: center;
    margin: 0;
    color: var(--ui-navy);
    font-weight: 500;
    cursor: help;
}

.ui-scroll-area {
    max-height: calc(100vh - 285px);
    overflow: auto;
    background: #fff;
    border: 1px solid #c8d3e4;
    border-radius: 6px;
}

.ui-scroll-area .table th {
    color: var(--ui-ink);
    background: #eeede6;
}

/* Choice buttons (e.g. print on Original / Letterhead / Blank Page): the chosen one is solid. */
.btn-check:checked+.btn-outline-primary {
    color: #fff;
    background: var(--ui-navy);
    border-color: var(--ui-navy);
}

.btn.flex-column {
    flex-direction: column;
    gap: 0;
    height: auto;
    line-height: 1.25;
}

/* ---------- Form header: dark text on a light bar, easier to read than white on navy ---------- */

.ui-form-bar,
.content .box>.d-flex.border-bottom:first-child,
.content form>.box>.d-flex.border-bottom:first-child {
    background: #fff;
    border-bottom: 2px solid var(--ui-navy) !important;
}

.ui-form-bar__title,
.content .box>.d-flex.border-bottom:first-child>h2 {
    color: var(--ui-navy-dark);
    font-size: 1.125rem !important;
    font-weight: 700 !important;
}

.ui-legend {
    color: #3e4a54;
    font-weight: 500;
}

/* Table headings: dark text on light blue everywhere, also inside forms. */
.table th,
.table thead th,
.tab-content .table th,
.ui-form-bar+.p-5 .table th,
.ui-scroll-area .table th {
    color: var(--ui-navy-dark);
    background: #dfe5ef;
    border-color: #c8d3e4;
    border-bottom-color: #9fb0c8;
}

/* ---------- Profile menu (the theme moves it out of the top bar, so it has its own class) ---------- */

.dropdown-menu.ui-user-menu {
    z-index: 1050;
    width: 220px;
    padding: 4px;
    background: #fff;
    border: 1px solid var(--ui-line-strong);
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(14, 35, 67, .2);
}

.ui-user-menu .ui-user__who {
    padding: 6px 8px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--ui-line);
}

.ui-user-menu form {
    margin: 0;
}

.ui-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 32px;
    padding: 4px 8px;
    color: var(--ui-ink);
    font-size: .8125rem;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    background: transparent;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
}

.ui-menu-item:hover {
    color: var(--ui-navy);
    background: var(--ui-navy-soft);
}

.ui-menu-item--danger:hover {
    color: var(--ui-red);
    background: var(--ui-red-soft);
}

/* ---------- Search dropdowns: text, clear and arrow on one centred line ---------- */

.select2-container--default .select2-selection--single .select2-selection__rendered {
    display: block;
    width: 100%;
    padding-right: 44px;
    overflow: hidden;
    line-height: calc(var(--ui-control) - 2px);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.select2-container--default .select2-selection--single .select2-selection__clear {
    position: absolute;
    top: 50%;
    right: 24px;
    float: none;
    margin: 0;
    padding: 0 3px;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1;
    transform: translateY(-50%);
}

.select2-container--default .select2-selection--single .select2-selection__clear:hover {
    color: var(--ui-red);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    top: 0;
    right: 4px;
    width: 18px;
    height: 100%;
}

.select2-container--default .select2-selection--single .select2-selection__arrow:after {
    top: 50%;
    right: 5px;
    margin-top: -5px;
}

/* ---------- Filter card ---------- */

.ui-filter {
    margin-top: 8px;
    padding: 8px 12px 10px;
    background: #e9edf4;
    border: 1px solid #c8d3e4;
    border-top: 3px solid var(--ui-navy);
    border-radius: 6px;
}

.ui-filter__title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    color: var(--ui-navy-dark);
    font-size: .8125rem;
    font-weight: 600;
}

.ui-filter__title svg {
    width: 15px;
    height: 15px;
}

.ui-filter .form-label {
    font-weight: 600;
}

.ui-filter__buttons .btn {
    min-width: 92px;
}

.ui-filter-toggle svg:last-child {
    transition: transform .12s;
}

.ui-filter-toggle[aria-expanded="true"] svg:last-child {
    transform: rotate(180deg);
}

.ui-filter-toggle[aria-expanded="true"] {
    color: var(--ui-navy);
    background: var(--ui-navy-soft);
    border-color: var(--ui-navy);
}

/* ---------- Lists: a row opens its record ---------- */

.ui-row-actions .btn {
    white-space: nowrap;
}


.ui-row-link {
    cursor: pointer;
}

/* ---------- Printing a list page: heading and rows only ---------- */

.ui-print-head {
    display: none;
}

@media print {
    @page {
        size: A4 portrait;
        margin: 10mm;
    }

    html,
    html body,
    .content {
        background: #fff !important;
    }

    .ui-frame {
        display: block;
    }

    .content {
        padding: 0;
    }

    .side-nav,
    .ui-nav-backdrop,
    .top-bar,
    .ui-page-head .btn,
    .ui-page-head .ui-page-count,
    #index-filters,
    .ui-list-foot,
    .ui-col-actions,
    td:has(>.ui-row-actions) {
        display: none !important;
    }

    .ui-print-head {
        display: block;
        margin-bottom: 6px;
        font-size: 11px;
    }

    .ui-table-box {
        overflow: visible;
        border: 0;
    }

    .table th,
    .table td {
        padding: 3px 5px;
        font-size: 10px;
        white-space: normal !important;
        border: 1px solid #777 !important;
    }

    .table th {
        color: #000 !important;
        background: #eee !important;
    }

    .badge {
        color: #000 !important;
        background: none !important;
        border: 0 !important;
    }

    tr {
        break-inside: avoid;
    }
}

/* ---------- Sign-in pages ---------- */

body.login {
    padding: 0 !important;
    background: var(--ui-page);
}

body.login:before {
    display: none !important;
}

.ui-login {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    min-height: 100vh;
}

.ui-login__side {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 22px;
    padding: 48px;
    color: #fff;
    background: var(--ui-navy-dark);
}

.ui-login__side h1 {
    margin: 0;
    color: #fff;
    font-size: 2rem;
    line-height: 1.25;
}

.ui-login__side p {
    margin: 0;
    color: #d3dceb;
    font-size: 1.0625rem;
}

.ui-login__stack {
    display: block;
    width: 100%;
    max-width: 440px;
    margin-bottom: auto;
}

.ui-login__main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
}

.ui-login__form {
    width: 100%;
    max-width: 420px;
}

.ui-login__form h2 {
    margin: 22px 0 4px;
    font-size: 1.75rem;
}

.ui-login__form .form-control {
    min-height: 50px;
    font-size: 1rem;
}

.ui-login__form .btn {
    width: 100%;
    min-height: 52px;
    font-size: 1.0625rem;
}

.ui-login__logo {
    display: block;
    max-width: 200px;
    max-height: 90px;
}

/* ---------- Password fields: an eye button shows what was typed (password-eye.js adds it) ---------- */

.ui-password {
    position: relative;
    display: block;
    width: 100%;
}

.ui-password input {
    padding-right: 42px;
    background-image: none;
}

.ui-password input::-ms-reveal,
.ui-password input::-ms-clear {
    display: none; /* Edge's own eye would make two */
}

.ui-password__eye {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    padding: 0;
    color: var(--ui-muted);
    background: none;
    border: 0;
    cursor: pointer;
}

.ui-password__eye:hover,
.ui-password__eye:focus-visible {
    color: var(--ui-navy);
}

.ui-password__eye svg {
    width: 18px;
    height: 18px;
}

.ui-password.is-invalid ~ .invalid-feedback {
    display: block;
}

/* ---------- Role permissions: screens down the side, actions across the top ---------- */

.ui-perm__tools {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 16px;
    margin-bottom: 12px;
}

.ui-perm__name {
    flex: 0 1 260px;
}

.ui-perm__find {
    flex: 0 1 280px;
}

.ui-perm__only {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: var(--ui-control);
    margin: 0;
    padding: 0;
}

.ui-perm__only .form-check-input {
    float: none;
    margin: 0;
}

.ui-perm__only .form-check-label {
    margin: 0;
}

.ui-perm__totals {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.ui-perm__count {
    margin-right: 6px;
    color: var(--ui-muted);
    white-space: nowrap;
}

.ui-perm__count strong {
    color: var(--ui-navy);
    font-size: 1.125rem;
}

.ui-perm__body {
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    gap: 12px;
    height: calc(100vh - 240px);
    min-height: 340px;
}

.ui-perm__nav,
.ui-perm__grid {
    overflow: auto;
    background: var(--ui-surface);
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius);
}

.ui-perm__nav {
    padding: 4px 6px 8px;
}

.ui-perm__area {
    padding: 10px 8px 4px;
    color: var(--ui-muted);
    font-size: .8125rem;
    font-weight: 600;
}

.ui-perm__tab {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 7px 8px;
    color: var(--ui-ink);
    font-weight: 500;
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: 4px;
}

.ui-perm__tab small {
    color: var(--ui-muted);
    font-size: .75rem;
    white-space: nowrap;
}

.ui-perm__tab:hover {
    background: var(--ui-navy-soft);
}

.ui-perm__tab.is-active {
    color: #fff;
    background: var(--ui-navy);
}

.ui-perm__tab.is-active small {
    color: #fff;
}

.ui-perm-table {
    width: 100%;
    min-width: 780px;
    border-collapse: separate;
    border-spacing: 0;
}

.ui-perm-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 8px 10px;
    color: var(--ui-ink);
    font-size: .9375rem;
    font-weight: 600;
    white-space: nowrap;
    background: #e3e9f3;
    border-bottom: 2px solid var(--ui-navy);
}

.ui-perm-table tbody th,
.ui-perm-table tbody td {
    border-bottom: 1px solid var(--ui-line);
}

.ui-perm-table__section {
    display: none;
}

.is-filtering .ui-perm-table__section {
    display: table-row;
}

.ui-perm-table__section th {
    padding: 6px 10px;
    color: var(--ui-navy);
    font-weight: 600;
    background: var(--ui-surface-2);
}

.ui-perm-table__head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    cursor: pointer;
}

.ui-perm-table .form-check-input {
    flex: none;
    float: none;
    margin: 0;
    cursor: pointer;
}

.ui-perm-table__action {
    width: 76px;
}

.ui-perm-table__screen {
    min-width: 240px;
    font-weight: 500;
}

.ui-perm-table tbody .ui-perm-table__screen {
    padding: 7px 10px;
}

.ui-perm-table__cell {
    padding: 0;
}

/* The whole cell can be clicked; a ticked one is tinted so a row reads at a glance. */
.ui-perm-table__tick {
    display: flex;
    align-items: center;
    height: 100%;
    min-height: 36px;
    margin: 0;
    padding: 0 10px;
    cursor: pointer;
}

.ui-perm-table__cell:has(.js-perm:checked) {
    background: var(--ui-navy-soft);
}

.ui-perm-table__other {
    padding: 4px 10px;
    white-space: nowrap;
}

.ui-perm-table__chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 2px 12px 2px 0;
    cursor: pointer;
}

.ui-perm-table tbody tr.js-row:hover th,
.ui-perm-table tbody tr.js-row:hover td:not(:has(.js-perm:checked)) {
    background: var(--ui-surface-2);
}

/* ---------- Narrow screens ---------- */

@media (max-width: 900px) {
    .ui-perm__body {
        grid-template-columns: minmax(0, 1fr);
        height: auto;
    }

    .ui-perm__nav {
        max-height: 180px;
    }

    .ui-perm__grid {
        max-height: 70vh;
    }

    .ui-perm__totals {
        margin-left: 0;
    }
}

@media (max-width: 1100px) {
    .ui-panel--4,
    .ui-panel--8 {
        grid-column: span 12;
    }

    .ui-user__name,
    .ui-search__section {
        display: none;
    }
}

@media (max-width: 860px) {
    :root {
        --ui-gutter: 14px;
    }

    .ui-login {
        grid-template-columns: minmax(0, 1fr);
    }

    .ui-login__side {
        display: none;
    }

    .side-nav,
    .side-nav.side-nav--simple {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 70;
        display: flex;
        width: 290px;
        max-width: 86vw;
        transform: translateX(-102%);
        transition: transform .16s ease-out;
    }

    .side-nav .side-menu .side-menu__title {
        display: flex !important;
    }

    .ui-nav-open .side-nav {
        transform: none;
    }

    .ui-nav-open .ui-nav-backdrop {
        position: fixed;
        inset: 0;
        z-index: 65;
        display: block;
        background: rgba(14, 35, 67, .5);
    }

    .top-bar .breadcrumb {
        display: none;
    }

    .ui-search {
        flex: 1 1 auto;
        min-width: 0;
    }

    .ui-page-title {
        flex-basis: 100%;
        font-size: 1.3rem;
    }

    .ui-form-bar {
        position: static;
        padding: 12px 14px;
    }

    .ui-form-bar__title {
        flex-basis: 100%;
    }

    .ui-form-bar__actions {
        justify-content: flex-start;
    }
}

/* ---------- Printing a normal page: only the content ---------- */

@media print {
    .side-nav,
    .top-bar,
    .ui-form-bar__actions,
    .ui-flash {
        display: none !important;
    }

    .content {
        padding: 0;
        background: #fff;
    }
}
