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

body {
    margin: 0;
    background: #f4f6f8;
    color: #1d2833;
    font-family: "Segoe UI", Arial, sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

.cas-shell {
    display: flex;
}

.cas-main {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    margin-left: 280px;
    transition: margin-left 160ms ease;
}

.cas-main-public {
    margin-left: 0;
}

.cas-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: 280px;
    display: flex;
    flex-direction: column;
    background: #18212b;
    color: #f6f8fb;
    box-shadow: 1px 0 0 rgba(18, 29, 40, 0.16);
    transition: width 160ms ease;
    overflow: hidden;
}

.cas-sidebar.is-collapsed {
    width: 76px;
}

body.nav-collapsed .cas-main {
    margin-left: 76px;
}

.cas-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 68px;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex: 0 0 auto;
}

.cas-brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.cas-brand-mark {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 8px;
    background: #1f8a70;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0;
}

.cas-brand-text {
    font-size: 18px;
    font-weight: 700;
}

.cas-sidebar.is-collapsed .cas-brand-text,
.cas-sidebar.is-collapsed .cas-brand-mark,
.cas-sidebar.is-collapsed .cas-nav-label,
.cas-sidebar.is-collapsed .cas-nav-chevron,
.cas-sidebar.is-collapsed .cas-nav-submenu {
    display: none;
}

.cas-sidebar.is-collapsed .cas-brand {
    justify-content: center;
    padding: 0;
}

.cas-sidebar.is-collapsed .cas-brand-link {
    display: none;
}

.cas-icon-button {
    display: inline-grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.cas-nav {
    padding: 12px 10px;
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
}

.cas-nav-group {
    margin-bottom: 6px;
}

.cas-nav-menu {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 12px;
    padding: 11px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #e8edf3;
    text-align: left;
}

.cas-nav-menu:hover,
.cas-nav-menu.is-open {
    background: rgba(255, 255, 255, 0.09);
}

.cas-nav-icon {
    width: 24px;
    flex: 0 0 24px;
    text-align: center;
}

.cas-nav-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cas-nav-chevron {
    opacity: 0.72;
}

.cas-nav-submenu {
    display: none;
    padding: 4px 0 8px 36px;
}

.cas-nav-menu.is-open + .cas-nav-submenu {
    display: block;
}

.cas-nav-detail {
    display: block;
    padding: 8px 10px;
    border-radius: 6px;
    color: #cdd7e3;
    font-size: 14px;
}

.cas-nav-detail:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.cas-nav-empty {
    padding: 12px;
    color: #aeb9c5;
    font-size: 14px;
}

.cas-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 68px;
    gap: 16px;
    padding: 12px 24px;
    background: #fff;
    border-bottom: 1px solid #dfe5ec;
}

.cas-page-title {
    font-size: 20px;
    font-weight: 700;
}

.cas-user-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cas-topbar-icon-button {
    position: relative;
    display: inline-grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid #d4dde8;
    border-radius: 8px;
    background: #fff;
    color: #435266;
}

.cas-topbar-icon-button:hover {
    border-color: #1f8a70;
    color: #176b58;
}

.cas-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #d64545;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.cas-notification-panel {
    width: 320px;
    max-width: calc(100vw - 32px);
}

.cas-notification-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 2px 0 10px;
    border-bottom: 1px solid #e2e8f0;
    color: #243246;
    font-weight: 700;
}

.cas-notification-clear {
    border: 0;
    background: transparent;
    color: #1f6f62;
    font-size: 13px;
    font-weight: 600;
}

.cas-notification-items {
    display: grid;
    max-height: 340px;
    overflow-y: auto;
}

.cas-notification-item {
    display: grid;
    gap: 3px;
    padding: 11px 0;
    border-bottom: 1px solid #edf1f5;
}

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

.cas-notification-item.is-unread .cas-notification-message {
    font-weight: 700;
}

.cas-notification-message {
    color: #243246;
    font-size: 14px;
}

.cas-notification-meta {
    color: #657487;
    font-size: 12px;
}

.cas-notification-empty {
    padding: 18px 0 8px;
    color: #657487;
    text-align: center;
}

.cas-user-menu-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #d4dde8;
    border-radius: 8px;
    background: #fff;
    color: #435266;
}

.cas-user-menu-button:hover {
    border-color: #1f8a70;
    color: #176b58;
}

.cas-user-menu-caret {
    font-size: 12px;
    color: #657487;
}

.cas-user-name {
    color: #435266;
    font-weight: 600;
}

.cas-user-menu-popup {
    display: grid;
    gap: 2px;
    width: 180px;
    max-width: calc(100vw - 32px);
}

.cas-user-menu-item {
    display: block;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #243246;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.cas-user-menu-item:hover {
    background: #eef4f0;
    color: #176b58;
}

.cas-user-menu-logout-form {
    margin: 0;
}

.cas-user-menu-logout {
    color: #b3261e;
}

.cas-user-menu-logout:hover {
    background: #fbeceb;
    color: #b3261e;
}

.cas-content {
    flex: 1;
    padding: 24px;
}

.cas-login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #eef4f0 0%, #f7f7fb 52%, #edf3f8 100%);
}

.cas-login-panel {
    width: min(420px, 100%);
    padding: 28px;
    border: 1px solid #dce4ec;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 48px rgba(27, 40, 56, 0.12);
}

.cas-login-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.cas-login-header h1 {
    margin: 0;
    font-size: 24px;
}

.cas-login-header p,
.cas-section-header p {
    margin: 4px 0 0;
    color: #68798b;
}

.cas-field {
    margin-bottom: 16px;
}

.cas-field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.cas-form-row {
    margin: 8px 0 18px;
}

.cas-dashboard,
.cas-workspace {
    width: 100%;
}

.cas-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.cas-section-header h1 {
    margin: 0;
    font-size: 28px;
}

.cas-metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.cas-metric,
.cas-detail-surface,
.cas-branch-option {
    border: 1px solid #dce4ec;
    border-radius: 8px;
    background: #fff;
}

.cas-metric {
    padding: 18px;
}

.cas-metric span {
    display: block;
    margin-bottom: 8px;
    color: #657487;
    font-size: 13px;
}

.cas-metric strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: 18px;
}

.cas-toolbar,
.cas-action-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cas-link-button {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    gap: 8px;
    padding: 7px 12px;
    border: 1px solid #1f8a70;
    border-radius: 6px;
    background: #1f8a70;
    color: #fff;
    font-weight: 600;
}

.cas-link-button:hover {
    background: #176b58;
    color: #fff;
}

.cas-link-button.disabled {
    pointer-events: none;
    border-color: #ccd5df;
    background: #e8edf2;
    color: #7b8999;
}

.cas-detail-surface {
    padding: 20px;
}

.cas-action-row {
    margin-top: 18px;
}

.cas-branch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.cas-branch-option {
    display: flex;
    gap: 12px;
    padding: 16px;
    cursor: pointer;
}

.cas-branch-option input {
    margin-top: 4px;
}

.cas-branch-option span {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cas-branch-option small {
    color: #657487;
}

.cas-grid-action {
    color: #1f6f62;
    font-weight: 600;
}

.cas-grid-action + .cas-grid-action {
    margin-left: 12px;
}

.cas-grid-action-danger {
    border: 0;
    background: transparent;
    color: #b42318;
    font: inherit;
    font-weight: 600;
    padding: 0;
}

.cas-status-text-posted {
    color: #1D4ED8;
    font-weight: 600;
}

.cas-status-text-cancelled {
    color: #DC2626;
    font-weight: 600;
}

.cas-status-text-neutral {
    color: inherit;
}

.cas-master-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 18px;
}

.cas-filter-row {
    display: flex;
    align-items: end;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid #dfe5ec;
    border-radius: 8px;
    background: #fff;
}

.cas-filter-field {
    display: grid;
    gap: 6px;
    min-width: 180px;
    color: #435266;
    font-size: 13px;
    font-weight: 600;
}

.cas-master-field {
    display: grid;
    gap: 7px;
    min-width: 0;
    color: #435266;
    font-size: 13px;
    font-weight: 600;
}

.cas-master-field .dx-widget {
    font-weight: 400;
}

@media (max-width: 760px) {
    .cas-master-form {
        grid-template-columns: 1fr;
    }

    .cas-filter-row {
        align-items: stretch;
        flex-direction: column;
    }
}

.cas-user-detail {
    padding-bottom: 28px;
}

.cas-sales-detail {
    padding-bottom: 28px;
}

.cas-sales-detail .cas-subpanel {
    margin-top: 18px;
}

.cas-empty-state {
    display: grid;
    justify-items: center;
    gap: 14px;
    max-width: 620px;
    margin: 44px auto;
    padding: 34px 24px;
    border: 1px solid #dce4ec;
    border-radius: 8px;
    background: #fff;
    text-align: center;
}

.cas-empty-state h1 {
    margin: 0;
    color: #263443;
    font-size: 28px;
}

.cas-empty-state p {
    max-width: 480px;
    margin: 0;
    color: #5b6878;
}

.cas-empty-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: #eef5f3;
    color: #1f8a70;
    font-size: 26px;
}

.cas-link-button-secondary {
    border-color: #ccd5df;
    background: #fff;
    color: #263443;
}

.cas-link-button-secondary:hover {
    border-color: #9dafc0;
    background: #f5f8fb;
    color: #263443;
}

.cas-collapse-panel {
    margin-bottom: 14px;
    border: 1px solid #dce4ec;
    border-radius: 8px;
    background: #fff;
}

.cas-collapse-panel summary {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 16px;
    border-radius: 8px;
    color: #263443;
    cursor: pointer;
    font-weight: 700;
}

.cas-collapse-panel[open] summary {
    border-bottom: 1px solid #e4ebf2;
    border-radius: 8px 8px 0 0;
}

.cas-collapse-body {
    padding: 18px;
}

.cas-rights-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

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

.cas-subpanel-title {
    margin-bottom: 10px;
    color: #435266;
    font-weight: 700;
}

.dx-popup-content .cas-nav-detail {
    color: #263443;
}

.dx-popup-content .cas-nav-detail:hover {
    background: #edf3f8;
    color: #1f6f62;
}

/* Select Delivery Address popup (Sales Order/Invoice/DR Bill To cascade): DevExtreme's
   default dx-list-item-content truncates long text with an ellipsis, which cut off full
   delivery addresses. Wrap instead so the whole address is readable. */
.dx-popup-content .cas-address-item {
    white-space: normal;
    word-break: break-word;
    line-height: 1.4;
    padding: 6px 0;
}

@media (max-width: 900px) {
    .cas-sidebar {
        width: 76px;
    }

    .cas-brand-text,
    .cas-nav-label,
    .cas-nav-chevron,
    .cas-nav-submenu {
        display: none;
    }

    .cas-main {
        margin-left: 76px;
    }

    .cas-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .cas-user-area {
        flex-wrap: wrap;
    }

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

@media (max-width: 560px) {
    .cas-content {
        padding: 16px;
    }

    .cas-metric-grid {
        grid-template-columns: 1fr;
    }

    .cas-section-header {
        flex-direction: column;
    }

    .cas-rights-grid {
        grid-template-columns: 1fr;
    }
}
