/**
 * custom.css — small shared helpers (KPI tiles, avatars, detail lists).
 * Loaded after style.css by the main layout. Put project-specific CSS here.
 */

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

.kpi-card .stat-icon,
.card .stat-icon.bg-primary-subtle,
.card .stat-icon.bg-success-subtle,
.card .stat-icon.bg-warning-subtle,
.card .stat-icon.bg-danger-subtle,
.card .stat-icon.bg-info-subtle,
.card .stat-icon.bg-secondary-subtle {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    font-size: 18px;
}

.kpi-card:hover {
    border-color: var(--primary);
}

.avatar-sm,
.avatar-lg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    flex-shrink: 0;
}

.avatar-sm {
    width: 36px;
    height: 36px;
    font-size: 12.5px;
}

.avatar-lg {
    width: 72px;
    height: 72px;
    font-size: 23.5px;
}

.detail-list dt {
    font-weight: 500;
    color: #7d84a0;
    margin-bottom: 6px;
}

.detail-list dd {
    margin-bottom: 6px;
    color: #3d4257;
    word-break: break-word;
}


/* Tile colours for .icon-tile-box / .circle-tile-icon / .indicator-icon */

.tile-blue {
    background: #4361ee;
}

.tile-green {
    background: #2ecc71;
}

.tile-orange {
    background: #ffab00;
}

.tile-sky {
    background: #17a2e8;
}

.tile-red {
    background: #f04248;
}

.tile-purple {
    background: #7b3fe4;
}


/* --- DataTable listings ------------------------------------------------- */

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-btn {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px;
}

.action-icon a {
    font-size: 17px;
    color: #7d84a0;
}

.action-icon a:hover {
    color: var(--primary);
}

.action-icon a.deleteItem:hover {
    color: var(--danger);
}

.dt-card .card-body {
    padding: 16px 20px;
}

.dt-card table.dataTable {
    width: 100% !important;
    margin: 0 !important;
}

.dt-card table.dataTable thead th {
    font-size: 12px;
    text-transform: uppercase;
    color: #7d84a0;
    white-space: nowrap;
}

.dt-card table.dataTable td {
    vertical-align: middle;
    font-size: 13px;
}

.dt-card div.dt-container .dt-search input {
    min-width: 220px;
}


/* Wide tables scroll left-right on every listing (no columns hidden). */

.dt-card div.dt-container .dt-layout-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-left: 0;
    margin-right: 0;
}

.dt-card div.dt-container .dt-layout-table>.dt-layout-cell {
    padding: 0;
}

.dt-card table.dataTable th,
.dt-card table.dataTable td {
    white-space: nowrap;
}


/* --- Website settings: media previews ---------------------------------- */

.media-preview {
    height: 110px;
    border: 1px dashed #d6dae6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.media-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.media-preview-light {
    background: #fff;
}

.media-preview-dark {
    background: var(--navy);
}

.media-preview.is-icon img {
    width: 48px;
    height: 48px;
}


/* Uploaded logo in the topbar / login card (smaller on tablet / phone, see Responsive below) */

.topbar-brand img.site-logo {
    height: 66px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
}

.auth-card .brand-logo img.site-logo {
    height: 42px;
    width: auto;
    max-width: 220px;
    object-fit: contain;
}


/* --- Footer at the bottom of the screen ----------------------------------
   Short pages: the footer sits at the bottom of the viewport.
   Long pages: it follows the content as usual. */

.main-content {
    display: flex;
    flex-direction: column;
}

.main-content>.page-content {
    flex: 1 0 auto;
}

footer.app-footer {
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid var(--card-border);
    padding: 14px 24px;
}


/* --- Lock screen ---------------------------------------------------------- */

.lock-avatar {
    position: relative;
    width: 88px;
    height: 88px;
}

.lock-avatar img,
.lock-avatar>span {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-light);
}

.lock-avatar>span {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-red);
    color: #fff;
    font-size: 32px;
    font-weight: 700;
}

.lock-avatar .lock-badge {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--navy);
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #fff;
}


/* --- Forgot password (OTP) ------------------------------------------------ */

.fp-steps {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0 0 26px;
    counter-reset: step;
}

.fp-steps li {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 600;
    color: #a0a6bb;
    position: relative;
}

.fp-steps li::before {
    content: "";
    position: absolute;
    top: 14px;
    left: -50%;
    width: 100%;
    height: 2px;
    background: #e3e6f0;
    z-index: 0;
}

.fp-steps li:first-child::before {
    display: none;
}

.fp-steps li span {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 2px solid #e3e6f0;
    position: relative;
    z-index: 1;
}

.fp-steps li.active {
    color: var(--primary);
}

.fp-steps li.active span {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.fp-steps li.done {
    color: var(--success);
}

.fp-steps li.done span {
    border-color: var(--success);
    background: var(--success);
    color: #fff;
}

.fp-steps li.done::before,
.fp-steps li.active::before {
    background: var(--primary);
}

.otp-boxes {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.otp-boxes .otp-box {
    width: 52px;
    height: 56px;
    padding: 0;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    border-radius: 10px !important;
    border: 1.5px solid #dfe3ee;
    caret-color: var(--primary);
}

.otp-boxes .otp-box:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(67, 97, 238, 0.15);
}

.otp-boxes .otp-box.filled {
    border-color: var(--primary);
    background: var(--primary-light);
}

.otp-boxes .otp-box.is-invalid {
    border-color: var(--danger);
    background: #fff5f5;
    animation: otp-shake 0.3s;
}

@keyframes otp-shake {
    0%,
    100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-4px);
    }
    75% {
        transform: translateX(4px);
    }
}


/* OTP boxes shrink to fit any width (6 boxes on a 320px phone). */

.otp-boxes .otp-box {
    flex: 1 1 0;
    min-width: 0;
    max-width: 52px;
}

@media (max-width: 400px) {
    .otp-boxes {
        gap: 6px;
    }
    .otp-boxes .otp-box {
        height: 48px;
        font-size: 1.25rem;
    }
}


/* --- Auth screens (login, lock, forgot password): responsive -------------
   The two halves are flex items of .auth-wrapper (not a Bootstrap .row), so
   col-lg-6 gives them no width below 992px: the form side must fill the
   screen itself there. */

.auth-form-side {
    flex: 1 1 0;
    min-width: 0;
}

.auth-card .brand-logo img.site-logo {
    max-width: min(220px, 100%);
}

@media (max-width: 1199.98px) {
    .auth-visual {
        padding: 48px;
    }
}

@media (max-width: 991.98px) {
    .auth-form-side {
        width: 100%;
        min-height: 100vh;
        padding: 32px 24px;
        background: var(--body-bg);
    }
    /* Tablet / phone: the form sits on a card, centred. */
    .auth-card {
        max-width: 440px;
        background: #fff;
        border: 1px solid var(--card-border);
        border-radius: var(--radius);
        box-shadow: var(--shadow-md);
        padding: 32px 28px;
    }
    .auth-card .brand-logo {
        justify-content: center;
        margin-bottom: 24px;
    }
    .auth-card h3,
    .auth-card .subtitle {
        text-align: center;
    }
}

@media (max-width: 575.98px) {
    .auth-form-side {
        padding: 16px 12px;
        align-items: flex-start;
        padding-top: 8vh;
    }
    .auth-card {
        padding: 24px 18px;
    }
    .auth-card h3 {
        font-size: 1.35rem;
    }
    .auth-card .subtitle {
        margin-bottom: 20px;
    }
    .auth-card .brand-logo img.site-logo {
        height: 36px;
    }
    .fp-steps {
        margin-bottom: 20px;
    }
    .fp-steps li {
        font-size: 10.5px;
        text-align: center;
    }
    .lock-avatar,
    .lock-avatar img,
    .lock-avatar>span {
        width: 72px;
        height: 72px;
    }
    .lock-avatar>span {
        font-size: 26px;
    }
}

html[data-theme="dark"] .auth-form-side,
html[data-theme="dark"] .auth-card {
    background-color: #1c2736;
    color: #d1d5db;
}

@media (max-width: 991.98px) {
    html[data-theme="dark"] .auth-form-side {
        background-color: #111827;
    }
}

.pw-rules li {
    color: #9198ab;
    margin-bottom: 2px;
}

.pw-rules li.ok {
    color: var(--success);
}


/* --- Toasts: top-right (theme default was bottom-right) -------------------
   Just below the top bar; newest toast on top. */

.toast-container {
    top: calc(var(--topbar-height) + 12px);
    right: 20px;
    bottom: auto;
}

@media (max-width: 575.98px) {
    .toast-container {
        top: 12px;
        right: 12px;
        left: 12px;
        bottom: auto;
    }
    /* Slide down from the top on phones (theme slid up from the bottom). */
    .toast-item,
    .toast-item.toast-out {
        transform: translateY(-120%);
    }
    .toast-item.toast-in {
        transform: translateY(0);
    }
}


/* Count badge on a sidebar link (e.g. open Issues). Hidden in the mini sidebar with the labels. */

.sidebar-nav .nav-link .nav-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 7px;
    line-height: 1;
}


/* --- Topbar user menu (avatar header + icon rows) ------------------------ */

.user-menu {
    min-width: 250px;
    padding: 6px;
    margin-top: 8px !important;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(20, 25, 50, 0.14);
}

.user-menu-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px 12px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--card-border);
}

.user-menu-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-red);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
}

.user-menu-name {
    font-weight: 700;
    font-size: 13px;
    color: #1f2437;
}

.user-menu-email {
    font-size: 11.5px;
    color: #8a90a2;
}

.user-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 500;
    color: #3d4257;
}

.user-menu-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 13.5px;
    transition: background .15s ease, color .15s ease;
}

.user-menu .dropdown-item:hover,
.user-menu .dropdown-item:focus {
    background: var(--body-bg);
    color: var(--primary);
}

.user-menu .dropdown-item:hover .user-menu-icon {
    background: var(--primary);
    color: #fff;
}

.user-menu .dropdown-divider {
    margin: 6px 4px;
    border-color: var(--card-border);
}

.user-menu .user-menu-logout {
    color: var(--danger);
}

.user-menu .user-menu-logout .user-menu-icon {
    background: rgba(240, 66, 72, 0.1);
    color: var(--danger);
}

.user-menu .user-menu-logout:hover,
.user-menu .user-menu-logout:focus {
    background: rgba(240, 66, 72, 0.08);
    color: var(--danger);
}

.user-menu .user-menu-logout:hover .user-menu-icon {
    background: var(--danger);
    color: #fff;
}

html[data-theme="dark"] .user-menu-name {
    color: #e5e7eb;
}

html[data-theme="dark"] .user-menu-email {
    color: #9ca3af;
}

html[data-theme="dark"] .user-menu .dropdown-item {
    color: #d1d5db;
}

html[data-theme="dark"] .user-menu .dropdown-item:hover {
    background: #293548;
    color: #fff;
}

html[data-theme="dark"] .user-menu .user-menu-logout {
    color: #f87171;
}


/* --- Topbar notifications dropdown --------------------------------------- */

.notif-menu {
    width: min(380px, calc(100vw - 24px));
    margin-top: 8px !important;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(20, 25, 50, 0.14);
    overflow: hidden;
}

.notif-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--card-border);
}

.notif-head-title {
    font-weight: 700;
    font-size: 14px;
    color: #1f2437;
}

.notif-head-sub {
    font-size: 11.5px;
    color: #8a90a2;
}

.notif-mark-read {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}

.notif-mark-read:hover {
    text-decoration: underline;
}

.notif-list {
    max-height: min(420px, calc(100vh - 200px));
    overflow-y: auto;
}

.notif-item {
    display: flex;
    gap: 10px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--card-border);
    color: inherit;
    position: relative;
    transition: background .15s ease;
}

.notif-item:last-child {
    border-bottom: 0;
}

.notif-item:hover {
    background: var(--body-bg);
}

.notif-item.is-new {
    background: rgba(67, 97, 238, 0.05);
}

.notif-item.is-new::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--primary);
}

.notif-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.notif-icon.tone-primary {
    background: rgba(67, 97, 238, 0.12);
    color: var(--primary);
}

.notif-icon.tone-success {
    background: rgba(46, 204, 113, 0.14);
    color: #1f9d55;
}

.notif-icon.tone-warning {
    background: rgba(255, 171, 0, 0.16);
    color: #c98600;
}

.notif-icon.tone-info {
    background: rgba(23, 162, 232, 0.14);
    color: var(--info);
}

.notif-icon.tone-purple {
    background: rgba(123, 63, 228, 0.12);
    color: #7b3fe4;
}

.notif-icon.tone-secondary {
    background: var(--body-bg);
    color: #7d84a0;
}

.notif-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.notif-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.notif-title {
    font-weight: 600;
    font-size: 12.5px;
    color: #1f2437;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notif-time {
    font-size: 10.5px;
    color: #9198ab;
    white-space: nowrap;
    flex-shrink: 0;
}

.notif-msg {
    font-size: 11.5px;
    color: #6b7185;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notif-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    font-size: 10.5px;
    color: #8a90a2;
}

.notif-meta .badge {
    font-size: 9.5px;
    font-weight: 600;
}

.notif-purpose {
    padding: 0 6px;
    border-radius: 4px;
    background: var(--body-bg);
}

.notif-state {
    padding: 32px 16px;
    text-align: center;
    color: #9198ab;
    font-size: 12px;
}

.notif-state .bi {
    font-size: 26px;
    display: block;
    margin-bottom: 6px;
}

.notif-foot {
    display: block;
    padding: 10px 14px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    border-top: 1px solid var(--card-border);
}

.notif-foot:hover {
    background: var(--body-bg);
}

html[data-theme="dark"] .notif-head-title,
html[data-theme="dark"] .notif-title {
    color: #e5e7eb;
}

html[data-theme="dark"] .notif-msg {
    color: #9ca3af;
}

html[data-theme="dark"] .notif-item:hover,
html[data-theme="dark"] .notif-foot:hover {
    background: #293548;
}

html[data-theme="dark"] .notif-purpose {
    background: #293548;
}


/* --- Responsive: large desktop / laptop / tablet / phone -----------------
   ≥ 1200 full padding · 992–1199 laptop · < 992 tablet (off-canvas sidebar)
   · < 768 small tablet · < 576 phone. */

.main-content {
    min-width: 0;
    overflow-x: clip;
}


/* nothing pushes the page sideways */

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

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

.breadcrumb-nav {
    overflow-wrap: anywhere;
}

.modal-footer {
    flex-wrap: wrap;
    gap: 6px;
}

.modal-footer>* {
    margin: 0;
}

@media (max-width: 1199.98px) {
    .page-content {
        padding: 11px 20px;
    }
}


/* Tablet: drawer sidebar, hamburger first in the top bar. */

@media (max-width: 991.98px) {
    .topbar {
        padding: 0 12px;
        gap: 8px;
    }
    .topbar-left {
        gap: 10px;
    }
    .sidebar-toggle-btn {
        order: -1;
    }
    .topbar-brand img.site-logo {
        height: 48px;
        max-width: 160px;
    }
    .page-toolbar {
        padding: 0 12px;
    }
    .page-content {
        padding: 10px 16px;
    }
    footer.app-footer {
        padding: 12px 16px;
        text-align: center;
    }
    .card-header {
        padding: 14px 16px;
    }
    .card-body {
        padding: 16px;
    }
}


/* Small tablet / large phone. */

@media (max-width: 767.98px) {
    .page-header h1 {
        font-size: 17px;
    }
    .page-header {
        gap: 8px;
    }
    .filter-bar {
        padding: 12px;
        margin-bottom: 12px;
    }
    .dt-card .card-body {
        padding: 12px;
    }
    /* Many tabs (member details, settings, profile): one swipeable row. */
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .nav-tabs::-webkit-scrollbar {
        display: none;
    }
    .nav-tabs .nav-link {
        white-space: nowrap;
    }
    /* DataTables: length / search / info / paging stacked, full width. */
    .dt-card div.dt-container>.row:not(.dt-layout-table) {
        row-gap: 8px;
    }
    .dt-card div.dt-container .dt-search,
    .dt-card div.dt-container .dt-length {
        text-align: left;
    }
    .dt-card div.dt-container .dt-search input {
        min-width: 0;
        width: 100%;
        margin-left: 0;
    }
    .dt-card div.dt-container .dt-search label {
        display: none;
    }
    .dt-card div.dt-container .dt-info {
        text-align: center;
        padding-top: 4px;
    }
    .dt-card div.dt-container .dt-paging .pagination {
        flex-wrap: wrap;
        justify-content: center;
        row-gap: 4px;
    }
    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        max-width: calc(100vw - 1rem);
    }
}


/* Phone. */

@media (max-width: 575.98px) {
    .topbar-brand img.site-logo {
        height: 38px;
        max-width: 120px;
    }
    .topbar-brand span {
        font-size: 14px;
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .topbar-user {
        margin-left: 0;
        padding: 4px;
    }
    /* Toolbar: icons only, except the main action ("Add …", "Edit"). */
    .page-toolbar {
        padding: 0 8px;
        height: 42px;
    }
    .page-toolbar .tb-btn {
        padding: 6px 8px;
    }
    .page-toolbar .tb-btn:not(.primary)>span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
        /* hidden, still read by screen readers */
    }
    .page-toolbar .tb-sep {
        margin: 0 2px;
    }
    .page-content {
        padding: 10px 12px;
    }
    .card-header {
        padding: 12px 14px;
    }
    .card-body {
        padding: 14px;
    }
    .dt-card .card-body {
        padding: 10px;
    }
    .dt-card table.dataTable td {
        font-size: 12px;
    }
    .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    .stat-value {
        font-size: 18px;
    }
    /* Filter bar: Filter / Reset buttons share the row. */
    .filter-bar .d-flex.gap-2>.btn {
        flex: 1 1 0;
    }
    .modal-dialog {
        margin: 0.5rem;
    }
    .modal-body {
        padding: 14px;
    }
    .modal-header,
    .modal-footer {
        padding: 10px 14px;
    }
}


/* --- Persisted dark theme ------------------------------------------------ */

html[data-theme="dark"] {
    color-scheme: dark;
    --sidebar-bg: #161f2e;
    --sidebar-border: #293548;
    --sidebar-icon: #cbd5e1;
    --sidebar-label: #94a3b8;
    --sidebar-active-bg: #22314a;
    --body-bg: #111827;
    --card-border: #293548;
    --primary-light: #22314a;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] body {
    color: #d1d5db;
}

html[data-theme="dark"] .theme-toggle-btn {
    color: #fbbf24;
}

html[data-theme="dark"] .theme-toggle-btn:hover {
    color: #fde68a;
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .offcanvas,
html[data-theme="dark"] .list-group-item,
html[data-theme="dark"] .popover,
html[data-theme="dark"] .toast,
html[data-theme="dark"] .page-toolbar,
html[data-theme="dark"] .filter-bar,
html[data-theme="dark"] .toast-item {
    background-color: #1c2736;
    color: #d1d5db;
}

html[data-theme="dark"] .card-header,
html[data-theme="dark"] .page-header h1,
html[data-theme="dark"] .stat-value,
html[data-theme="dark"] .detail-list dd,
html[data-theme="dark"] .dropdown-item,
html[data-theme="dark"] .modal-title {
    color: #e5e7eb;
}

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

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .input-group-text,
html[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection,
html[data-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown,
html[data-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field {
    background-color: #111827;
    border-color: #374151;
    color: #e5e7eb;
}

html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection__placeholder {
    color: #9ca3af;
}

html[data-theme="dark"] .form-select option,
html[data-theme="dark"] .table,
html[data-theme="dark"] .table thead th,
html[data-theme="dark"] .table tbody td {
    color: #d1d5db;
}

html[data-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: #d1d5db;
    --bs-table-border-color: #293548;
    --bs-table-striped-bg: rgba(255, 255, 255, 0.035);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .table thead th {
    background-color: #202c3d;
}

html[data-theme="dark"] .page-toolbar .tb-btn,
html[data-theme="dark"] .mini-action-text,
html[data-theme="dark"] .breakdown-list li,
html[data-theme="dark"] .breakdown-list .count,
html[data-theme="dark"] .circle-tile .circle-tile-value,
html[data-theme="dark"] .indicator-list li {
    color: #d1d5db;
}

html[data-theme="dark"] .btn-icon,
html[data-theme="dark"] .compact-table-footer .pager-btns button {
    background-color: #1c2736;
    color: #cbd5e1;
}

html[data-theme="dark"] .file-preview,
html[data-theme="dark"] .list-thumb {
    background-color: #111827;
}

html[data-theme="dark"] .file-preview img {
    background-color: #1c2736;
}

html[data-theme="dark"] .submenu.sidebar-flyout {
    background-color: #1c2736;
    border-color: #293548;
}

html[data-theme="dark"] .sidebar-flyout .sidebar-flyout-title {
    border-color: #293548;
}

html[data-theme="dark"] .sidebar-flyout .nav-link {
    color: #cbd5e1;
}

html[data-theme="dark"] .pagination .page-link {
    background-color: #1c2736;
    border-color: #293548;
    color: #d1d5db;
}

html[data-theme="dark"] .page-item.disabled .page-link {
    background-color: #161f2e;
    color: #6b7280;
}

html[data-theme="dark"] .form-check-input {
    background-color: #111827;
    border-color: #4b5563;
}

html[data-theme="dark"] .text-dark,
html[data-theme="dark"] .text-body {
    color: #d1d5db !important;
}

html[data-theme="dark"] .bg-white {
    background-color: #1c2736 !important;
}

html[data-theme="dark"] .bg-light,
html[data-theme="dark"] .bg-body-tertiary {
    background-color: #202c3d !important;
}

html[data-theme="dark"] .border,
html[data-theme="dark"] .dropdown-divider {
    border-color: #293548 !important;
}

html[data-theme="dark"] footer.app-footer {
    background-color: #161f2e;
    color: #9ca3af;
}

.chat-card {
    overflow: hidden;
}

.chat-head {
    background: color-mix(in srgb, var(--bs-body-bg) 72%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom-color: color-mix(in srgb, var(--primary) 14%, var(--card-border));
}

.chat-body {
    height: calc(100vh - 340px);
    min-height: 360px;
    overflow-y: auto;
    background: radial-gradient(circle at 12% 8%, color-mix(in srgb, var(--primary) 16%, transparent) 0, transparent 42%), radial-gradient(circle at 92% 88%, color-mix(in srgb, var(--primary) 12%, transparent) 0, transparent 46%), var(--body-bg);
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--primary) 35%, transparent) transparent;
}

.chat-row {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    align-items: flex-end;
    animation: chatIn .25s ease-out;
}

.chat-row.mine {
    justify-content: flex-end;
}

.chat-bubble {
    max-width: min(75%, 520px);
    padding: 9px 13px;
    border-radius: 16px;
    background: color-mix(in srgb, var(--bs-body-bg) 70%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--bs-body-color);
    border: 1px solid color-mix(in srgb, var(--bs-body-bg) 40%, var(--card-border));
    box-shadow: var(--shadow-sm);
    word-wrap: break-word;
    white-space: pre-line;
}

.chat-row.mine .chat-bubble {
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 92%, transparent), color-mix(in srgb, var(--primary-dark) 88%, transparent));
    color: #fff;
    border-color: transparent;
    border-bottom-right-radius: 5px;
    box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 28%, transparent);
}

.chat-row:not(.mine) .chat-bubble {
    border-bottom-left-radius: 5px;
}

.chat-row:not(.mine) .chat-bubble a {
    color: var(--primary);
}

.chat-meta {
    font-size: 11px;
    color: var(--bs-secondary-color);
    margin-top: 4px;
    text-align: right;
}

.chat-row.mine .chat-meta {
    color: rgba(255, 255, 255, .82);
}

.chat-bubble img {
    max-width: 220px;
    max-height: 220px;
    border-radius: 10px;
    display: block;
}

.chat-row.mine .chat-bubble a {
    color: #fff;
}

.chat-avatar {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent);
}

.chat-day {
    text-align: center;
    margin: 12px 0;
}

.chat-day span {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
    background: color-mix(in srgb, var(--bs-body-bg) 65%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid color-mix(in srgb, var(--primary) 12%, transparent);
}

.chat-reply-bar {
    background: color-mix(in srgb, var(--bs-body-bg) 75%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top-color: color-mix(in srgb, var(--primary) 14%, var(--card-border));
}

.chat-reply-bar textarea {
    background: color-mix(in srgb, var(--bs-body-bg) 60%, transparent);
    border-radius: 12px;
}

.chat-reply-bar textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--primary) 18%, transparent);
}

.chat-reply-bar #sendReply {
    border-radius: 12px;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 30%, transparent);
}

.chat-reply-bar label.btn {
    border-radius: 12px;
}


/* ---- Glass (default): unchanged look; the extra name / download icon stay hidden ---- */

.chat-theme-glass .chat-who-user,
.chat-theme-glass .chat-file-download {
    display: none;
}


/* ---- Shared by Minimal & Vivid: sender name and time show on hover ---- */

.chat-theme-minimal .chat-meta,
.chat-theme-vivid .chat-meta {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    overflow: hidden;
    transition: all .18s ease;
}

.chat-theme-minimal .chat-row:hover .chat-meta,
.chat-theme-vivid .chat-row:hover .chat-meta {
    max-height: 20px;
    opacity: 1;
    margin-top: 4px;
}

@media (hover: none) {
    .chat-theme-minimal .chat-meta,
    .chat-theme-vivid .chat-meta {
        max-height: 20px;
        opacity: 1;
        margin-top: 4px;
    }
}

.chat-theme-minimal .chat-avatar,
.chat-theme-vivid .chat-avatar {
    box-shadow: none;
}


/* ---- Minimal: plain background, soft grey pills, theme-coloured replies ---- */

.chat-theme-minimal .chat-body {
    background: var(--bs-body-bg);
}

.chat-theme-minimal .chat-bubble {
    background: var(--bs-tertiary-bg);
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-radius: 18px;
    padding: 10px 16px;
}

.chat-theme-minimal .chat-row.mine .chat-bubble {
    background: var(--primary);
    box-shadow: none;
    border-radius: 18px;
}

.chat-theme-minimal .chat-row:not(.mine) .chat-bubble {
    border-radius: 18px;
}

.chat-theme-minimal .chat-day span {
    background: transparent;
    border: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.chat-theme-minimal .chat-file {
    display: flex !important;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.chat-theme-minimal .chat-file-download {
    margin-left: auto;
}


/* ---- Vivid: theme-coloured background, see-through bubbles, white replies, file cards ---- */

.chat-theme-vivid .chat-body {
    background: linear-gradient(160deg, var(--primary), var(--primary-dark));
}

.chat-theme-vivid .chat-bubble {
    background: rgba(255, 255, 255, .16);
    color: #fff;
    border: 0;
    box-shadow: none;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 18px;
    padding: 10px 16px;
}

.chat-theme-vivid .chat-row:not(.mine) .chat-bubble {
    border-radius: 18px;
    border-top-left-radius: 6px;
}

.chat-theme-vivid .chat-row.mine .chat-bubble {
    background: #fff;
    color: #1f2433;
    border-radius: 18px;
    border-top-right-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
}

.chat-theme-vivid .chat-row:not(.mine) .chat-bubble a {
    color: #fff;
}

.chat-theme-vivid .chat-row.mine .chat-bubble a {
    color: var(--primary);
}

.chat-theme-vivid .chat-meta {
    color: rgba(255, 255, 255, .8);
}

.chat-theme-vivid .chat-row.mine .chat-meta {
    color: #7b8194;
}

.chat-theme-vivid .chat-avatar {
    border-color: rgba(255, 255, 255, .5) !important;
}

.chat-theme-vivid .chat-day span {
    color: #fff;
    background: rgba(255, 255, 255, .16);
    border-color: transparent;
}

.chat-theme-vivid .chat-body {
    scrollbar-color: rgba(255, 255, 255, .35) transparent;
}

.chat-theme-vivid .chat-file {
    display: flex !important;
    align-items: center;
    gap: 10px;
    min-width: 200px;
    padding: 8px 10px;
    border-radius: 14px;
    text-decoration: none;
    background: rgba(255, 255, 255, .12);
}

.chat-theme-vivid .chat-row.mine .chat-file {
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.chat-theme-vivid .chat-file-icon {
    font-size: 22px;
    margin: 0 !important;
}

.chat-theme-vivid .chat-file-download {
    margin-left: auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .18);
}

.chat-theme-vivid .chat-row.mine .chat-file-download {
    background: color-mix(in srgb, var(--primary) 14%, transparent);
}

@keyframes chatIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chat-row {
        animation: none;
    }
}

@media (max-width: 991.98px) {
    .chat-body {
        height: 60vh;
    }
}
/* ==========================================================================
   Sidebar: gap between submenu items, and hover looks different from active.
   Hover = light neutral grey; active = theme colour + left accent bar.
   ========================================================================== */

.sidebar-nav .submenu .nav-item {
    margin-bottom: 4px;
}

.sidebar-nav .nav-link:hover {
    background: rgba(15, 23, 42, 0.05);
    color: var(--sidebar-icon);
}

.sidebar-nav .nav-link:hover .bi {
    color: var(--sidebar-icon);
}

.sidebar-nav .nav-link.active,
.sidebar-nav .nav-link.active:hover {
    background: var(--sidebar-active-bg);
    color: var(--primary);
}

.sidebar-nav .nav-link.active .bi,
.sidebar-nav .nav-link.active:hover .bi {
    color: var(--primary);
}

.sidebar-nav .submenu .nav-link.active:not(.nav-group)::after {
    content: "";
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 3px;
    background: var(--primary);
}

html[data-theme="dark"] .sidebar-nav .nav-link:not(.active):hover {
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
}

html[data-theme="dark"] .sidebar-nav .nav-link:not(.active):hover .bi {
    color: #e2e8f0;
}
