/*
 * DarajaERP clean application shell
 * Keeps the existing permission-aware menu and routes while reducing chrome.
 */

:root {
    --d-clean-sidebar-width: 248px;
    --d-clean-sidebar-collapsed: 72px;
    --d-clean-ink: #11213f;
    --d-clean-muted: #71809a;
    --d-clean-line: #e4eaf2;
    --d-clean-soft: #f4f7fb;
    --d-clean-active: #e7f6fc;
    --d-clean-blue: #009cd5;
    --d-clean-blue-dark: #08638d;
}

/* Sidebar shell */
.side-bar.d-sidebar {
    width: var(--d-clean-sidebar-width) !important;
    min-width: var(--d-clean-sidebar-width);
    height: 100vh;
    position: sticky;
    top: 0;
    align-self: flex-start;
    overflow: hidden;
    background: #fff !important;
    color: var(--d-clean-ink) !important;
    border: 0 !important;
    border-right: 1px solid var(--d-clean-line) !important;
    box-shadow: none !important;
}

.d-sidebar-logo-clean {
    display: flex;
    align-items: center;
    height: 78px;
    padding: 17px 26px 13px;
    flex: 0 0 auto;
    border-bottom: 0;
    background: #fff;
}

.d-sidebar-logo-clean img {
    display: block;
    width: 150px;
    height: 48px;
    object-fit: contain;
    object-position: left center;
}

.d-sidebar-logo-mark {
    display: none !important;
}

.d-sidebar-workspace {
    position: relative;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 16px;
    align-items: center;
    gap: 10px;
    min-height: 64px;
    margin: 9px 18px 11px;
    padding: 10px 12px;
    border: 1px solid #dce5ef;
    border-radius: 14px;
    background: #f8fafc;
}

.d-sidebar-workspace-avatar,
.d-sidebar-account-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    color: #fff;
    background: linear-gradient(135deg, #123b68, var(--d-clean-blue));
    font-weight: 800;
    letter-spacing: .05em;
}

.d-sidebar-workspace-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 11px;
}

.d-sidebar-workspace-copy,
.d-sidebar-account-copy {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.d-sidebar-workspace-copy strong,
.d-sidebar-account-copy strong {
    overflow: hidden;
    color: var(--d-clean-ink);
    font-size: 12px;
    font-weight: 750;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.d-sidebar-workspace-copy span,
.d-sidebar-account-copy span {
    color: var(--d-clean-muted);
    font-size: 10px;
    line-height: 1.25;
}

.d-sidebar-workspace-chevron {
    color: #9aa8bb;
    font-size: 9px;
}

.d-sidebar-workspace .d-business-selector {
    position: absolute !important;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

/* Permission-aware navigation */
#side-bar.d-sidebar-menu {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 2px;
    padding: 2px 18px 18px !important;
    overflow-x: hidden;
    overflow-y: auto;
    background: #fff !important;
    scrollbar-width: thin;
    scrollbar-color: #dbe4ee transparent;
}

#side-bar::-webkit-scrollbar {
    width: 4px;
}

#side-bar::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: #dbe4ee;
}

#side-bar .d-sidebar-menu-header {
    margin: 14px 0 5px;
    padding: 0 10px;
    color: #96a5ba;
    font-size: 9px;
    font-weight: 800;
    line-height: 1.4;
    letter-spacing: .18em;
    text-transform: uppercase;
}

#side-bar .d-sidebar-group {
    gap: 2px;
}

#side-bar .d-sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 40px;
    margin: 0;
    padding: 5px 10px;
    overflow: visible;
    color: #243653 !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 10px;
    box-shadow: none !important;
    transform: none !important;
}

#side-bar .d-sidebar-link::before {
    display: none !important;
}

#side-bar .d-sidebar-link:hover,
#side-bar .d-sidebar-link.is-open {
    color: var(--d-clean-blue-dark) !important;
    background: #f1f7fb !important;
}

#side-bar .d-sidebar-link.is-active {
    color: #075f89 !important;
    background: var(--d-clean-active) !important;
    font-weight: 700;
}

#side-bar .d-sidebar-icon-shell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    margin: 0;
    color: #26415f;
    background: #eef3f8 !important;
    border: 0 !important;
    border-radius: 8px;
    box-shadow: none !important;
}

#side-bar .d-sidebar-link:hover .d-sidebar-icon-shell,
#side-bar .d-sidebar-link.is-open .d-sidebar-icon-shell {
    color: var(--d-clean-blue-dark);
    background: #e2f2f9 !important;
}

#side-bar .d-sidebar-link.is-active .d-sidebar-icon-shell {
    color: #fff !important;
    background: var(--d-clean-blue) !important;
}

#side-bar .d-sidebar-link i,
#side-bar .d-sidebar-link svg {
    width: 14px !important;
    height: 14px !important;
    font-size: 13px;
    stroke-width: 1.8;
}

#side-bar .d-sidebar-link-label {
    color: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -.01em;
}

#side-bar .d-sidebar-chevron {
    width: 18px;
    height: 18px;
    margin-left: auto;
    color: #9aa8bb !important;
    background: transparent !important;
    border: 0 !important;
}

#side-bar .d-sidebar-chevron .svg {
    width: 12px !important;
    height: 12px !important;
}

#side-bar .d-sidebar-group-list {
    position: relative;
    padding: 3px 0 6px 37px;
}

#side-bar .d-sidebar-group-line {
    position: absolute;
    top: 3px;
    bottom: 8px;
    left: 23px;
    width: 1px;
    background: #e2e8f0;
}

#side-bar .d-sidebar-group-items {
    display: grid;
    gap: 1px;
}

#side-bar .d-sidebar-sublink {
    display: flex;
    align-items: center;
    min-height: 31px;
    padding: 5px 9px;
    color: #64748b !important;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 550;
}

#side-bar .d-sidebar-sublink:hover,
#side-bar .d-sidebar-sublink.is-active {
    color: #075f89 !important;
    background: #f1f7fb;
}

#side-bar .d-sidebar-sublink-dot {
    display: none;
}

/* Compact support and account footer */
.d-sidebar-clean-footer {
    flex: 0 0 auto;
    padding: 10px 18px 14px;
    background: #fff;
    border-top: 1px solid #edf1f5;
}

.d-sidebar-help {
    position: relative;
    margin-bottom: 10px;
}

.d-sidebar-help > summary {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) 14px;
    align-items: center;
    gap: 9px;
    min-height: 50px;
    padding: 8px 10px;
    color: #fff;
    background: linear-gradient(135deg, #112542, #096c98);
    border-radius: 12px;
    cursor: pointer;
    list-style: none;
}

.d-sidebar-help > summary::-webkit-details-marker {
    display: none;
}

.d-sidebar-help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 9px;
    font-size: 11px;
}

.d-sidebar-help summary span:nth-child(2) {
    display: grid;
    gap: 2px;
}

.d-sidebar-help summary strong {
    font-size: 11px;
    line-height: 1.2;
}

.d-sidebar-help summary small {
    color: rgba(255, 255, 255, .68);
    font-size: 9px;
}

.d-sidebar-help-arrow {
    font-size: 9px;
}

.d-sidebar-help-menu {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 7px);
    z-index: 20;
    display: grid;
    gap: 3px;
    padding: 7px;
    background: #fff;
    border: 1px solid var(--d-clean-line);
    border-radius: 11px;
    box-shadow: 0 14px 35px rgba(17, 33, 63, .16);
}

.d-sidebar-help-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 6px 8px;
    color: #334155;
    border-radius: 7px;
    font-size: 11px;
}

.d-sidebar-help-menu a:hover {
    color: #075f89;
    background: #eef8fc;
}

.d-sidebar-account {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 28px;
    align-items: center;
    gap: 9px;
    min-height: 44px;
    padding: 4px 5px;
}

.d-sidebar-account-avatar {
    width: 34px;
    height: 34px;
    overflow: hidden;
    border-radius: 10px;
    font-size: 10px;
}

.d-sidebar-account-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.d-sidebar-account-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: #93a1b4;
    border-radius: 8px;
}

.d-sidebar-account-action:hover {
    color: #075f89;
    background: #edf7fb;
}

/* Clean header */
.daraja-app-header.d-header {
    width: 100%;
    min-height: 64px;
    background: rgba(255, 255, 255, .97) !important;
    border: 0 !important;
    border-bottom: 1px solid var(--d-clean-line) !important;
    box-shadow: none !important;
    backdrop-filter: blur(14px);
}

.daraja-app-header .daraja-header-inner,
.d-ui-v2 .daraja-app-header .daraja-header-inner {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(280px, 420px) minmax(360px, 1fr);
    align-items: center;
    min-height: 64px;
    padding: 10px 24px;
    gap: 22px;
}

.daraja-app-header .daraja-header-left {
    display: flex;
    align-items: center;
    justify-self: start;
    min-width: 0;
}

.daraja-app-header .d-header-center {
    width: 100%;
    min-width: 0;
}

.daraja-app-header .daraja-header-actions {
    display: flex;
    align-items: center;
    justify-self: end;
    gap: 8px;
    min-width: 0;
}

.daraja-app-header .d-header-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #93a1b4;
    font-size: 11px;
    white-space: nowrap;
}

.daraja-app-header .d-header-breadcrumb i {
    color: #c1cad6;
    font-style: normal;
}

.daraja-app-header .d-header-breadcrumb strong {
    color: var(--d-clean-ink);
    font-weight: 750;
}

.daraja-app-header .d-header-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    min-width: 36px;
    height: 36px;
    padding: 0;
    color: #31435f;
    background: #fff !important;
    border: 1px solid #dde5ee !important;
    border-radius: 10px;
    box-shadow: none !important;
}

.daraja-app-header .d-header-icon-btn:hover,
.daraja-app-header .d-header-icon-btn:focus-visible {
    color: #08638d;
    background: #f1f8fb !important;
    border-color: #b9ddeb !important;
}

.daraja-app-header .d-header-icon-btn > i {
    font-size: 13px;
}

.daraja-app-header .d-header-command {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 36px;
    padding: 0 8px 0 12px;
    color: #8795a9;
    background: #fff;
    border: 1px solid #dde5ee;
    border-radius: 10px;
    box-shadow: none;
}

.daraja-app-header .d-header-command:hover {
    color: #52647e;
    border-color: #b9ddeb;
    background: #fafdff;
}

.daraja-app-header .d-header-command span {
    min-width: 0;
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.daraja-app-header .d-header-command kbd {
    margin-left: auto;
    padding: 3px 6px;
    color: #9aa8ba;
    background: #f5f7fa;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    box-shadow: none;
    font-size: 9px;
}

.daraja-app-header .d-header-pos-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 104px;
    height: 36px;
    padding: 0 14px;
    color: #fff !important;
    background: linear-gradient(135deg, #0789bd, #00a8dc);
    border: 1px solid #0789bd;
    border-radius: 10px;
    box-shadow: 0 5px 12px rgba(0, 156, 213, .18);
    font-size: 11px;
    font-weight: 750;
    text-decoration: none !important;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.daraja-app-header .d-header-pos-button:hover,
.daraja-app-header .d-header-pos-button:focus-visible {
    color: #fff !important;
    background: linear-gradient(135deg, #077aa8, #009ccf);
    box-shadow: 0 7px 16px rgba(0, 156, 213, .25);
    transform: translateY(-1px);
}

.daraja-app-header .d-header-pos-button i {
    font-size: 12px;
}

.daraja-app-header .d-user-avatar {
    width: 28px;
    min-width: 28px;
    height: 28px;
    color: #fff;
    background: linear-gradient(135deg, #123b68, var(--d-clean-blue));
    border: 0;
    border-radius: 8px;
    box-shadow: none;
    font-size: 10px;
}

.daraja-app-header .d-header-user-btn {
    width: auto;
    padding: 3px 7px 3px 3px;
    gap: 7px;
}

.daraja-app-header .d-user-name {
    max-width: 90px;
    color: #31435f;
    font-size: 11px;
}

.daraja-app-header .d-header-chevron {
    width: auto;
    height: auto;
    color: #9aa8ba;
    font-size: 8px;
}

.daraja-app-header .d-header-notif-badge {
    top: 5px;
    right: 5px;
    border-color: #fff;
}

.daraja-app-header .d-header-dropdown {
    color: #334155;
}

/* Approved account menu */
body.d-account-menu-open .daraja-app-header {
    z-index: 2200;
}

.daraja-app-header .d-account-menu-root {
    position: relative;
    z-index: 2201;
}

.daraja-app-header .d-account-menu-root > summary {
    list-style: none;
}

.daraja-app-header .d-account-menu-root > summary::-webkit-details-marker {
    display: none;
}

.daraja-app-header .d-account-menu-trigger {
    min-width: 138px;
    height: 40px;
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) 12px;
    align-items: center;
    gap: 8px;
    padding: 4px 9px 4px 4px;
    border: 1px solid transparent;
    border-radius: 11px;
    color: var(--d-clean-ink);
    background: transparent;
    cursor: pointer;
    transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.daraja-app-header .d-account-menu-trigger:hover,
.daraja-app-header .d-account-menu-trigger:focus-visible,
.daraja-app-header .d-account-menu-root[open] .d-account-menu-trigger {
    border-color: #d8e4ec;
    background: #f3f8fb;
}

.daraja-app-header .d-account-menu-trigger:focus-visible,
.daraja-app-header .d-account-menu-action:focus-visible {
    outline: 3px solid rgba(0, 156, 213, .2);
    outline-offset: 2px;
}

.daraja-app-header .d-account-menu-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    overflow: hidden;
    border-radius: 9px;
    color: #fff;
    background: linear-gradient(135deg, #10375f, var(--d-clean-blue));
    font-weight: 800;
    letter-spacing: .03em;
}

.daraja-app-header .d-account-menu-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.daraja-app-header .d-account-menu-avatar--trigger {
    width: 30px;
    height: 30px;
    font-size: 9px;
}

.daraja-app-header .d-account-menu-trigger-copy {
    min-width: 0;
    display: grid;
    gap: 1px;
    text-align: left;
}

.daraja-app-header .d-account-menu-trigger-copy strong,
.daraja-app-header .d-account-menu-trigger-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.daraja-app-header .d-account-menu-trigger-copy strong {
    color: #243653;
    font-size: 11px;
    font-weight: 750;
    line-height: 1.2;
}

.daraja-app-header .d-account-menu-trigger-copy small {
    color: #8996a8;
    font-size: 8px;
    font-weight: 600;
    line-height: 1.25;
}

.daraja-app-header .d-account-menu-chevron {
    color: #8e9bad;
    font-size: 8px;
    transition: transform .16s ease;
}

.daraja-app-header .d-account-menu-root[open] .d-account-menu-chevron {
    transform: rotate(180deg);
}

.daraja-app-header .d-account-menu-panel {
    position: absolute;
    z-index: 2202;
    top: calc(100% + 10px);
    right: 0;
    width: 312px;
    max-width: calc(100vw - 20px);
    border: 1px solid #dce5ed;
    border-radius: 16px;
    color: #263852;
    background: rgba(255, 255, 255, .99);
    box-shadow: 0 22px 52px rgba(15, 31, 57, .16), 0 3px 12px rgba(15, 31, 57, .06);
    animation: d-account-menu-enter .15s ease-out both;
}

.daraja-app-header .d-account-menu-panel::before {
    position: absolute;
    top: -6px;
    right: 25px;
    width: 11px;
    height: 11px;
    border-top: 1px solid #dce5ed;
    border-left: 1px solid #dce5ed;
    content: "";
    background: #f9fcfd;
    transform: rotate(45deg);
}

@keyframes d-account-menu-enter {
    from {
        opacity: 0;
        transform: translateY(-5px) scale(.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.daraja-app-header .d-account-menu-identity {
    position: relative;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 8px;
    align-items: center;
    gap: 11px;
    padding: 16px;
    border-bottom: 1px solid #e8edf2;
    border-radius: 15px 15px 0 0;
    background: radial-gradient(circle at 90% 0, rgba(0, 166, 220, .1), transparent 8rem), #f8fbfd;
}

.daraja-app-header .d-account-menu-avatar--large {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 11px;
    box-shadow: 0 7px 16px rgba(0, 156, 213, .15);
}

.daraja-app-header .d-account-menu-identity-copy {
    min-width: 0;
    display: grid;
}

.daraja-app-header .d-account-menu-identity-copy > small {
    color: #8a96a7;
    font-size: 8px;
    font-weight: 750;
    letter-spacing: .06em;
    line-height: 1.2;
    text-transform: uppercase;
}

.daraja-app-header .d-account-menu-identity-copy > strong,
.daraja-app-header .d-account-menu-identity-copy > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.daraja-app-header .d-account-menu-identity-copy > strong {
    margin-top: 4px;
    color: var(--d-clean-ink);
    font-size: 13px;
    font-weight: 780;
    line-height: 1.25;
}

.daraja-app-header .d-account-menu-identity-copy > span {
    margin-top: 2px;
    color: #748297;
    font-size: 10px;
}

.daraja-app-header .d-account-menu-online {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #24b885;
    box-shadow: 0 0 0 4px rgba(36, 184, 133, .11);
}

.daraja-app-header .d-account-menu-workspace {
    min-width: 0;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    margin: 10px 11px 5px;
    padding: 9px;
    border: 1px solid #e1e8ee;
    border-radius: 10px;
    background: #f7f9fc;
}

.daraja-app-header .d-account-menu-workspace-copy {
    min-width: 0;
    display: grid;
}

.daraja-app-header .d-account-menu-workspace-copy small {
    color: #8b96a7;
    font-size: 8px;
}

.daraja-app-header .d-account-menu-workspace-copy strong {
    margin-top: 2px;
    overflow: hidden;
    color: #243653;
    font-size: 10px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.daraja-app-header .d-account-menu-role {
    max-width: 84px;
    padding: 4px 7px;
    overflow: hidden;
    border-radius: 999px;
    color: #08739e;
    background: #e6f6fc;
    font-size: 8px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.daraja-app-header .d-account-menu-icon {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 9px;
    color: #52647b;
    background: #eef2f6;
    font-size: 11px;
}

.daraja-app-header .d-account-menu-icon--cyan {
    color: #08759f;
    background: #e5f6fc;
}

.daraja-app-header .d-account-menu-icon--amber {
    color: #a86b15;
    background: #fff2de;
}

.daraja-app-header .d-account-menu-icon--red {
    color: #bd5252;
    background: #ffeded;
}

.daraja-app-header .d-account-menu-actions {
    display: grid;
    padding: 5px 7px 8px;
}

.daraja-app-header .d-account-menu-action {
    width: 100%;
    min-height: 52px;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) 12px;
    align-items: center;
    gap: 10px;
    padding: 8px 9px;
    border: 0;
    border-radius: 10px;
    color: #263852;
    background: transparent;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: color .14s ease, background-color .14s ease;
}

.daraja-app-header .d-account-menu-action:hover,
.daraja-app-header .d-account-menu-action:focus-visible {
    color: #075f89;
    background: #f1f7fa;
    text-decoration: none;
}

.daraja-app-header .d-account-menu-action-copy {
    min-width: 0;
    display: grid;
}

.daraja-app-header .d-account-menu-action-copy strong {
    color: inherit;
    font-size: 11px;
    font-weight: 750;
    line-height: 1.25;
}

.daraja-app-header .d-account-menu-action-copy small {
    margin-top: 3px;
    overflow: hidden;
    color: #8390a3;
    font-size: 9px;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.daraja-app-header .d-account-menu-action-arrow {
    color: #98a5b5;
    font-size: 9px;
}

.daraja-app-header .d-account-menu-footer {
    display: grid;
    gap: 4px;
    padding: 8px 7px 9px;
    border-top: 1px solid #e8edf2;
    border-radius: 0 0 15px 15px;
    background: #fafbfd;
}

.daraja-app-header .d-account-menu-footer form {
    margin: 0;
}

.daraja-app-header .d-account-menu-signout {
    grid-template-columns: 32px minmax(0, 1fr);
}

.daraja-app-header .d-account-menu-signout:hover,
.daraja-app-header .d-account-menu-signout:focus-visible {
    color: #a94343;
    background: #fff0f0;
}

.daraja-app-header .d-account-menu-signout .d-account-menu-action-copy strong {
    color: #ad4949;
}

.daraja-app-header .d-account-menu-version {
    padding: 0 9px;
    color: #a0a9b7;
    font-size: 8px;
    text-align: right;
}

.daraja-app-header .d-header-desktop-toggle {
    display: none !important;
}

.daraja-app-header .d-header-mobile-toggle {
    display: none !important;
}

/* Collapsed rail */
body.sidebar-collapse .side-bar.d-sidebar {
    width: var(--d-clean-sidebar-collapsed) !important;
    min-width: var(--d-clean-sidebar-collapsed);
}

body.sidebar-collapse .d-sidebar-logo-clean {
    height: 64px;
    padding: 14px 17px;
}

body.sidebar-collapse .d-sidebar-logo-clean img {
    width: 38px;
    height: 38px;
    object-fit: contain;
}

body.sidebar-collapse .d-sidebar-logo-full {
    display: none !important;
}

body.sidebar-collapse .d-sidebar-logo-mark {
    display: block !important;
}

body.sidebar-collapse .d-sidebar-workspace,
body.sidebar-collapse .d-sidebar-clean-footer,
body.sidebar-collapse #side-bar .d-sidebar-menu-header,
body.sidebar-collapse #side-bar .d-sidebar-link-copy,
body.sidebar-collapse #side-bar .d-sidebar-chevron,
body.sidebar-collapse #side-bar .d-sidebar-group-list {
    display: none !important;
}

body.sidebar-collapse #side-bar.d-sidebar-menu {
    align-items: stretch;
    padding: 12px 14px !important;
}

body.sidebar-collapse #side-bar .d-sidebar-link {
    justify-content: center;
    width: 44px;
    min-height: 44px;
    padding: 8px;
}

body.sidebar-collapse #side-bar .d-sidebar-icon-shell {
    width: 30px;
    min-width: 30px;
    height: 30px;
}

@media (min-width: 1024px) {
    .daraja-app-header .d-header-desktop-toggle {
        display: inline-flex !important;
    }
}

@media (max-width: 1180px) {
    .daraja-app-header .daraja-header-inner,
    .d-ui-v2 .daraja-app-header .daraja-header-inner {
        grid-template-columns: minmax(185px, .8fr) minmax(220px, 1fr) auto;
        gap: 14px;
        padding-inline: 18px;
    }

    .daraja-app-header .d-header-pos-button {
        min-width: 94px;
        padding-inline: 11px;
    }

    .daraja-app-header .d-user-name,
    .daraja-app-header .d-header-chevron {
        display: none;
    }

    .daraja-app-header .d-header-user-btn {
        width: 36px;
        padding: 3px;
    }
}

/* ── Mobile drawer (single source of truth) ──────────────────────
   Breakpoint is 1023.98px to match the Tailwind `lg:` at which the
   static sidebar (`lg:tw-flex` on the aside) takes over — this closes
   the old 992–1023px "dead zone" where neither the drawer trigger nor
   the sidebar was available. The sidebar element itself becomes the
   off-canvas drawer: rendered (display:flex) but translated off-screen,
   sliding in on `.is-open`. One state class, one transform, no more
   competing `left:-280px !important` from daraja-layout.css. */
@media (max-width: 1023.98px) {
    .side-bar.d-sidebar {
        display: flex !important;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;          /* fallback */
        height: 100dvh;
        width: 18rem;
        max-width: 86vw;
        z-index: 1050;
        transform: translateX(-102%);
        transition: transform .28s cubic-bezier(.4, 0, .2, 1);
        box-shadow: var(--shadow-2xl, 0 25px 50px -12px rgba(15, 23, 42, .35));
        will-change: transform;
    }

    .side-bar.d-sidebar.is-open {
        transform: translateX(0);
    }

    .daraja-app-header .daraja-header-inner,
    .d-ui-v2 .daraja-app-header .daraja-header-inner {
        grid-template-columns: minmax(150px, .8fr) minmax(180px, 1fr) auto;
        padding: 8px 16px;
    }

    .daraja-app-header .d-header-mobile-toggle {
        display: inline-flex !important;
    }

    .daraja-app-header .d-header-desktop-toggle {
        display: none !important;
    }
}
@media (prefers-reduced-motion: reduce) {
    .side-bar.d-sidebar { transition: none; }
}

@media (max-width: 767.98px) {
    .daraja-app-header .daraja-header-inner,
    .d-ui-v2 .daraja-app-header .daraja-header-inner {
        grid-template-columns: auto minmax(140px, 1fr) auto;
        gap: 8px;
    }

    .daraja-app-header .d-header-breadcrumb {
        display: none;
    }

    .daraja-app-header .d-account-menu-trigger {
        min-width: 54px;
        grid-template-columns: 30px 10px;
        gap: 5px;
        padding-right: 6px;
    }

    .daraja-app-header .d-account-menu-trigger-copy {
        display: none;
    }
}

@media (max-width: 640px) {
    .daraja-app-header .daraja-header-inner,
    .d-ui-v2 .daraja-app-header .daraja-header-inner {
        grid-template-columns: auto minmax(36px, 1fr) auto;
        min-height: 56px;
        padding: 8px 10px;
        gap: 8px;
    }

    .daraja-app-header .d-header-breadcrumb span,
    .daraja-app-header .d-header-breadcrumb i,
    .daraja-app-header .d-header-command span,
    .daraja-app-header .d-header-command kbd,
    .daraja-app-header .d-user-name,
    .daraja-app-header .d-header-chevron {
        display: none;
    }

    .daraja-app-header .d-header-command {
        width: 36px;
        min-width: 36px;
        padding: 0;
        justify-content: center;
    }

    .daraja-app-header .d-header-pos-button {
        width: 36px;
        min-width: 36px;
        padding: 0;
    }

    .daraja-app-header .d-header-pos-button span {
        display: none;
    }

    .daraja-app-header .daraja-header-actions {
        gap: 5px;
    }

    .daraja-app-header .d-header-user-btn {
        width: 36px;
        padding: 3px;
    }

    .daraja-app-header .d-account-menu-panel {
        width: 300px;
        max-width: calc(100vw - 20px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .daraja-app-header .d-account-menu-panel,
    .daraja-app-header .d-account-menu-chevron {
        animation: none;
        transition: none;
    }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE BOTTOM NAVIGATION  (.d-bottomnav) — phone-only, ≤767.98px
   Rendered from layouts/app.blade.php. Hidden ≥768px and on POS
   pages (which own the full viewport). Thumb-reachable primary nav.
   ═══════════════════════════════════════════════════════════════ */
.d-bottomnav { display: none; }

@media (max-width: 767.98px) {
    .d-bottomnav {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 1040;
        display: flex;
        align-items: stretch;
        height: calc(58px + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: #fff;
        border-top: 1px solid var(--d-border-light, #DCE3ED);
        box-shadow: 0 -6px 20px -12px rgba(15, 23, 42, .3);
    }
    .d-bottomnav__item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-height: 44px;
        border: none;
        background: none;
        color: var(--d-text-tertiary, #64748B);
        font-size: 10.5px;
        font-weight: 600;
        text-decoration: none;
        cursor: pointer;
        position: relative;
        -webkit-tap-highlight-color: transparent;
    }
    .d-bottomnav__item i { font-size: 17px; line-height: 1; }
    .d-bottomnav__item span { line-height: 1; }
    .d-bottomnav__item.is-on { color: var(--d-primary-600, #008EC2); }
    .d-bottomnav__item.is-on::before {
        content: "";
        position: absolute;
        top: 0;
        width: 26px;
        height: 3px;
        border-radius: 0 0 3px 3px;
        background: linear-gradient(90deg, var(--d-brand-cyan, #00A6DE), var(--d-brand-purple, #8B61C2));
    }
    /* raised centre action → POS */
    .d-bottomnav__fab { color: var(--d-primary-700, #0878AD); }
    .d-bottomnav__fab .d-bottomnav__fabc {
        width: 46px; height: 46px;
        margin-top: -18px;
        border-radius: 15px;
        background: linear-gradient(140deg, var(--d-brand-cyan, #00A6DE), var(--d-primary-600, #008EC2));
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 19px;
        box-shadow: 0 8px 20px -4px rgba(0, 142, 194, .6);
    }
    .d-bottomnav__fab.is-on::before { display: none; }

    /* reserve space so page content clears the bar */
    #scrollable-container {
        padding-bottom: calc(58px + env(safe-area-inset-bottom));
    }
    /* the drawer scrim and the drawer itself sit above the bar */
    .overlay { z-index: 1045; }
    .side-bar.d-sidebar { z-index: 1050; }
}

/* POS pages own the viewport — no bottom bar there */
body.pos-layout-active .d-bottomnav { display: none !important; }
body.pos-layout-active #scrollable-container { padding-bottom: 0; }

/* ═══════════════════════════════════════════════════════════════
   DATATABLES RESPONSIVE — child rows + mobile control row
   Pairs with the `responsive` default enabled in common.js. Styles
   the collapsed-column child row on-brand and stops the length/
   buttons/search control row from stacking three-deep on phones.
   ═══════════════════════════════════════════════════════════════ */

/* the inline expand control — Responsive puts it on the first column's
   ::before in `dtr-inline` mode (not a `.dtr-control` class). Brand it. */
table.dataTable.dtr-inline.collapsed > tbody > tr > td:first-child::before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th:first-child::before {
    content: "+";
    top: 50%;
    left: 8px;
    height: 20px;
    width: 20px;
    margin-top: -10px;
    line-height: 18px;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    background: linear-gradient(140deg, var(--d-brand-cyan, #00A6DE), var(--d-primary-600, #008EC2));
    border: none;
    border-radius: 6px;
    box-shadow: 0 2px 6px -2px rgba(0, 142, 194, .6);
}
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td:first-child::before,
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > th:first-child::before {
    content: "\2212"; /* minus */
    background: var(--d-text-tertiary, #64748B);
    box-shadow: none;
}

/* the collapsed-column child row */
table.dataTable > tbody > tr.child {
    background: var(--d-bg-hover, #F1F5F9);
}
table.dataTable > tbody > tr.child td {
    padding: 0 !important;
}
table.dataTable > tbody > tr.child ul.dtr-details {
    display: block;
    width: 100%;
    margin: 0;
    padding: 6px 14px 10px;
    list-style: none;
}
table.dataTable > tbody > tr.child ul.dtr-details > li {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--d-border-subtle, #EFF3F8);
}
table.dataTable > tbody > tr.child ul.dtr-details > li:last-child {
    border-bottom: none;
}
table.dataTable > tbody > tr.child ul.dtr-details > li .dtr-title {
    flex: 0 0 40%;
    max-width: 40%;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--d-text-tertiary, #64748B);
}
table.dataTable > tbody > tr.child ul.dtr-details > li .dtr-data {
    flex: 1;
    min-width: 0;
    font-size: 13.5px;
    color: var(--d-text-primary, #0B1220);
    word-break: break-word;
}
table.dataTable > tbody > tr.child ul.dtr-details > li .dtr-data .btn-group,
table.dataTable > tbody > tr.child ul.dtr-details > li .dtr-data .btn,
table.dataTable > tbody > tr.child ul.dtr-details > li .dtr-data .tw-dw-btn {
    margin: 2px 4px 2px 0;
}

/* Compact the BS3 control row on phones so length / export / search
   don't each take a full-width line above every table. */
@media (max-width: 767.98px) {
    .dataTables_wrapper .row.margin-bottom-20 {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        margin-bottom: 12px;
        text-align: left;
    }
    .dataTables_wrapper .row.margin-bottom-20 > [class*="col-sm-"] {
        width: auto;
        flex: 0 0 auto;
        float: none;
        padding: 0;
    }
    .dataTables_wrapper .row.margin-bottom-20 > .col-sm-3 {
        flex: 1 1 100%;
        order: -1; /* search first, full width */
    }
    .dataTables_wrapper .dataTables_filter input {
        width: 100%;
    }
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        text-align: left;
    }
    /* keep exports from overflowing the viewport */
    .dataTables_wrapper .dt-buttons {
        flex-wrap: wrap;
    }
}
