/* =========================================================
   China System UI Rebuild - 2026-03-04
   Scope: View layer only (app/Views + CSS assets)
   ========================================================= */

:root {
    --cn-bg: #f3f5f7;
    --cn-surface: #ffffff;
    --cn-surface-soft: #f8fafb;
    --cn-border: #d8e0e7;
    --cn-border-strong: #c6d1db;

    --cn-text: #1c2e40;
    --cn-text-muted: #6b7f93;

    --cn-primary: #1f4e79;
    --cn-primary-strong: #163f63;
    --cn-primary-soft: #e8eef4;

    --cn-accent: #4a6f8e;
    --cn-accent-soft: #eef3f8;

    --cn-success: #2f855a;
    --cn-success-soft: #e8f8f0;

    --cn-warning: #a67c2d;
    --cn-warning-soft: #fff6e8;

    --cn-danger: #b44a5c;
    --cn-danger-soft: #fdeff2;

    --cn-radius-xs: 8px;
    --cn-radius-sm: 12px;
    --cn-radius-md: 16px;
    --cn-radius-lg: 20px;

    --cn-shadow-sm: 0 6px 16px rgba(16, 42, 67, 0.08);
    --cn-shadow-md: 0 16px 28px rgba(16, 42, 67, 0.12);

    --cn-space-1: 0.25rem;
    --cn-space-2: 0.5rem;
    --cn-space-3: 0.75rem;
    --cn-space-4: 1rem;
    --cn-space-5: 1.25rem;
    --cn-space-6: 1.5rem;
    --cn-space-8: 2rem;

    --sidebar-width: 288px;
    --topbar-height: 72px;
}

:root {
    --bs-primary: var(--cn-primary);
    --bs-primary-rgb: 31, 78, 121;
    --bs-secondary: #6f859b;
    --bs-success: var(--cn-success);
    --bs-success-rgb: 47, 133, 90;
    --bs-info: #436b89;
    --bs-warning: #b38834;
    --bs-danger: var(--cn-danger);
    --bs-danger-rgb: 180, 74, 92;
    --bs-light: #f5f8fb;
    --bs-dark: #102a43;
    --bs-border-color: var(--cn-border);
    --bs-link-color: var(--cn-primary);
    --bs-link-hover-color: var(--cn-primary-strong);
    --bs-body-bg: var(--cn-bg);
    --bs-body-color: var(--cn-text);
}

html,
body {
    min-height: 100%;
    background: var(--cn-bg);
    color: var(--cn-text);
}

body.china-ui {
    margin: 0;
    line-height: 1.5;
    font-family: 'Plus Jakarta Sans', 'Segoe UI', Tahoma, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.china-ui.lang-ar,
body.auth-page.lang-ar {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}

body.china-ui.lang-zh,
body.auth-page.lang-zh {
    font-family: 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--cn-text);
    font-weight: 700;
    letter-spacing: -0.01em;
}

a {
    color: var(--cn-primary);
    text-decoration: none;
}

a:hover {
    color: var(--cn-primary-strong);
}

.text-muted {
    color: var(--cn-text-muted) !important;
}

.table-search,
.dataTables_filter,
input.form-control[placeholder*="Search in table"],
input.form-control[placeholder*="search in table"],
input.form-control[placeholder*="ابحث"] {
    display: none !important;
}

.alerts-container {
    position: fixed;
    top: 1rem;
    inset-inline-end: 1rem;
    z-index: 1060;
}

/* =========================================================
   App Layout
   ========================================================= */

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns 0.24s ease;
}

body.sidebar-collapsed .app-shell {
    grid-template-columns: 0 minmax(0, 1fr);
}

.app-shell-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-main {
    flex: 1;
    padding: var(--cn-space-4) var(--cn-space-5) var(--cn-space-6);
}

#main-content > .col-md-12.p-4,
#main-content > .col-12.p-4,
#main-content > .container-fluid,
#main-content > .container {
    padding: 0 !important;
    margin: 0;
    max-width: 100%;
    animation: cn-fade-in 320ms ease-out;
}

#main-content > * + * {
    margin-top: var(--cn-space-5);
}

.app-footer {
    border-top: 1px solid var(--cn-border);
    background: #fff;
    padding: 0.9rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    color: var(--cn-text-muted);
}

.app-footer__start {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.app-footer__brand {
    color: var(--cn-text);
    font-weight: 700;
    line-height: 1.2;
}

.app-footer__meta,
.app-footer__end {
    font-size: 0.85rem;
}

.footer-logo {
    width: auto;
    height: 28px;
    object-fit: contain;
}

/* =========================================================
   Sidebar
   ========================================================= */

.app-sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: #ffffff;
    color: var(--cn-text);
    border-inline-end: 1px solid var(--cn-border);
    box-shadow: 0 0 0 1px rgba(10, 35, 60, 0.02), 8px 0 18px rgba(10, 35, 60, 0.04);
    z-index: 1045;
    transition: transform 0.24s ease, opacity 0.2s ease;
}

.app-sidebar__head {
    padding: 1rem 1rem 0.9rem;
    border-bottom: 1px solid var(--cn-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.app-sidebar__body {
    flex: 1;
    overflow: auto;
    padding: 0.9rem 0.75rem 1rem;
    scrollbar-width: thin;
}

.app-sidebar__foot {
    padding: 0.9rem 0.75rem 1rem;
    border-top: 1px solid var(--cn-border);
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--cn-text);
}

.app-brand:hover {
    color: var(--cn-primary);
}

.brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: contain;
    background: #edf2f7;
    padding: 0.25rem;
}

.brand-copy {
    display: inline-flex;
    flex-direction: column;
    min-width: 0;
}

.brand-title {
    font-size: 0.95rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: var(--cn-text-muted);
}

.app-nav-title {
    font-size: 0.73rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0.1rem 0.55rem 0.6rem;
    color: #7b8da0;
    font-weight: 700;
    display: none;
}

.app-nav-list {
    gap: 0.3rem;
}

.app-nav-link,
.app-nav-group-label,
.app-subnav-link {
    border-radius: var(--cn-radius-sm);
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 0.62rem;
    padding: 0.56rem 0.72rem;
    color: #2d4962;
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.app-nav-link i,
.app-nav-group-label i,
.app-subnav-link i {
    font-size: 1rem;
}

.app-nav-link:hover,
.app-subnav-link:hover,
.app-nav-group-label.active,
.app-nav-link.active,
.app-subnav-link.active {
    color: var(--cn-primary-strong);
    background: #edf3f8;
}

.app-nav-link.active,
.app-subnav-link.active {
    box-shadow: inset 0 0 0 1px #c3d2df;
}

.app-nav-link .badge {
    margin-inline-start: auto;
    font-weight: 700;
}

body.sidebar-collapsed .app-sidebar {
    transform: translateX(-104%);
    opacity: 0;
    pointer-events: none;
}

html[dir='rtl'] body.sidebar-collapsed .app-sidebar {
    transform: translateX(104%);
}

.app-subnav {
    margin: 0.25rem 0 0.2rem;
    padding-inline-start: 1.95rem;
    display: grid;
    gap: 0.22rem;
}

.app-subnav-link {
    min-height: 36px;
    padding-block: 0.4rem;
    font-size: 0.9rem;
}

.app-subnav-link i {
    font-size: 0.92rem;
}

/* =========================================================
   Topbar + Quick Chips
   ========================================================= */

.app-topbar {
    min-height: var(--topbar-height);
    position: sticky;
    top: 0;
    z-index: 1030;
    background: #fff;
    border-bottom: 1px solid var(--cn-border);
    padding: 0.75rem 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.app-topbar__left,
.app-topbar__actions {
    display: inline-flex;
    align-items: center;
    gap: 0.56rem;
}

.app-topbar__title-wrap {
    display: inline-flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar__kicker {
    margin: 0;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: none;
    color: var(--cn-text-muted);
    line-height: 1.1;
}

.app-topbar__title {
    margin: 0.05rem 0 0;
    font-size: 1.04rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-icon-btn,
.app-topbar .btn.btn-light,
.app-topbar .btn.btn-outline-danger {
    border-radius: 12px;
    border: 1px solid var(--cn-border);
    background: #fff;
    color: var(--cn-text);
    min-height: 38px;
    min-width: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.app-topbar .btn.btn-light:hover,
.app-icon-btn:hover,
.app-topbar .btn.btn-light:focus-visible {
    background: #f4f8fc;
    border-color: var(--cn-border-strong);
    color: var(--cn-primary-strong);
}

.app-alert-btn {
    position: relative;
}

#officeMsgBadge {
    position: absolute;
    inset-block-start: -7px;
    inset-inline-end: -6px;
    padding: 0.2rem 0.35rem;
    min-width: 1.1rem;
}

.app-chip-nav {
    border-bottom: 1px solid var(--cn-border);
    background: #fff;
}

@media (min-width: 992px) {
    .app-chip-nav {
        display: none !important;
    }

    body.sidebar-collapsed .app-chip-nav {
        display: block !important;
    }

    body.sidebar-collapsed .app-nav-scroll {
        padding-top: 0.46rem;
        padding-bottom: 0.46rem;
    }
}

.app-nav-scroll {
    overflow-x: auto;
    white-space: nowrap;
    padding: 0.5rem 1.1rem 0.6rem;
}

.nav-chips {
    display: inline-flex;
    flex-direction: row !important;
    flex-wrap: nowrap;
    gap: 0.45rem;
    align-items: center !important;
    width: max-content;
    min-width: 100%;
    justify-content: flex-start;
}

.nav-chips .nav-item {
    flex: 0 0 auto;
}

.nav-chip {
    border-radius: 999px;
    border: 1px solid var(--cn-border);
    background: #fff;
    color: var(--cn-text);
    min-height: 36px;
    padding: 0.35rem 0.78rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.86rem;
    font-weight: 600;
}

.nav-chip:hover,
.nav-chip.active {
    border-color: #b9c6d3;
    color: var(--cn-primary-strong);
    background: #edf3f8;
}

.nav-chip .badge {
    padding: 0.18rem 0.34rem;
}

.dropdown-menu {
    border: 1px solid var(--cn-border);
    border-radius: var(--cn-radius-sm);
    box-shadow: var(--cn-shadow-md);
    padding: 0.35rem;
}

.dropdown-item {
    border-radius: 10px;
    font-weight: 600;
    color: var(--cn-text);
    padding: 0.5rem 0.65rem;
}

.dropdown-item:hover,
.dropdown-item:focus,
.dropdown-item.active {
    background: var(--cn-primary-soft);
    color: var(--cn-primary-strong);
}

/* =========================================================
   Shared Components
   ========================================================= */

.page-header,
#main-content > .col-md-12.p-4 > .d-flex.justify-content-between.align-items-center.mb-4,
#main-content > .col-12.p-4 > .d-flex.justify-content-between.align-items-center.mb-4 {
    border: 1px solid var(--cn-border);
    background: #fff;
    border-radius: var(--cn-radius-md);
    box-shadow: var(--cn-shadow-sm);
    padding: 0.95rem 1.08rem;
}

.card,
.modal-content {
    border: 1px solid var(--cn-border);
    border-radius: var(--cn-radius-md);
    background: var(--cn-surface);
    box-shadow: var(--cn-shadow-sm);
    overflow: hidden;
}

.card-header,
.modal-header {
    background: #fff;
    border-bottom: 1px solid var(--cn-border);
    padding: 0.82rem 1rem;
}

.card-footer,
.modal-footer {
    background: var(--cn-surface-soft);
    border-top: 1px solid var(--cn-border);
}

.table-responsive {
    border: 1px solid var(--cn-border);
    border-radius: var(--cn-radius-sm);
    background: #fff;
}

.table {
    margin-bottom: 0;
    --bs-table-bg: transparent;
    --bs-table-striped-bg: #f6f9fc;
}

.table > :not(caption) > * > * {
    border-color: #e4ebf2;
    vertical-align: middle;
}

.table thead th {
    background: #f2f7fc;
    color: #17324d;
    font-weight: 700;
    font-size: 0.86rem;
    white-space: nowrap;
}

.table tbody td {
    color: #1a3651;
    font-size: 0.9rem;
}

.table-hover tbody tr:hover {
    background: #f7fbff;
}

.form-label {
    color: #27445f;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.form-control,
.form-select,
.input-group-text,
.form-check-input,
.btn {
    border-radius: 11px;
}

.form-control,
.form-select {
    border-color: var(--cn-border-strong);
    min-height: 42px;
    color: #17324d;
    background-color: #fff;
    box-shadow: none;
}

.form-control::placeholder {
    color: #6f859b;
    opacity: 1;
}

.form-control:focus,
.form-select:focus {
    border-color: #8daecb;
    box-shadow: 0 0 0 0.2rem rgba(15, 76, 129, 0.14);
}

.input-group-text {
    border: 1px solid var(--cn-border-strong);
    background: #f4f8fc;
    color: #53708a;
    font-weight: 600;
}

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

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

.btn {
    min-height: 40px;
    padding-inline: 0.82rem;
    font-weight: 700;
    border-width: 1px;
}

.btn-primary {
    background: var(--cn-primary);
    border-color: var(--cn-primary);
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background: var(--cn-primary-strong);
    border-color: var(--cn-primary-strong);
}

.btn-outline-primary {
    color: var(--cn-primary);
    border-color: #9db8d2;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus-visible {
    background: var(--cn-primary-soft);
    color: var(--cn-primary-strong);
    border-color: #88a9c8;
}

.btn-outline-secondary {
    color: #47647e;
    border-color: #b8c9d8;
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus-visible {
    color: #1f3f5a;
    background: #eaf2f8;
    border-color: #a8bdcf;
}

.btn-success {
    background: var(--cn-success);
    border-color: var(--cn-success);
}

.btn-info {
    background: #446b88;
    border-color: #446b88;
    color: #fff;
}

.btn-warning {
    background: #b38834;
    border-color: #b38834;
    color: #fff;
}

.btn-danger {
    background: var(--cn-danger);
    border-color: var(--cn-danger);
}

.badge {
    font-weight: 700;
    letter-spacing: 0.01em;
}

.badge.bg-primary,
.text-bg-primary {
    background: #dceafb !important;
    color: #0f4c81 !important;
}

.badge.bg-success,
.text-bg-success {
    background: #dff5e9 !important;
    color: #176944 !important;
}

.badge.bg-warning,
.text-bg-warning {
    background: #fff2db !important;
    color: #8d5f17 !important;
}

.badge.bg-danger,
.text-bg-danger {
    background: #f8dee5 !important;
    color: #8d2d42 !important;
}

.badge.bg-info,
.text-bg-info {
    background: #dff0f7 !important;
    color: #125574 !important;
}

.progress {
    border-radius: 999px;
    background: #e8eff6;
    overflow: hidden;
}

.progress-bar {
    border-radius: 999px;
}

.alert {
    border-radius: var(--cn-radius-sm);
    border: 1px solid transparent;
    box-shadow: var(--cn-shadow-sm);
}

.alert-success {
    background: var(--cn-success-soft);
    border-color: #bfe4d1;
    color: #1a6944;
}

.alert-warning {
    background: var(--cn-warning-soft);
    border-color: #f4d6a7;
    color: #8b5c12;
}

.alert-danger {
    background: var(--cn-danger-soft);
    border-color: #f1c6d1;
    color: #8a2b40;
}

.alert-info {
    background: #e5f3f8;
    border-color: #c2e1ec;
    color: #124b63;
}

.list-group-item {
    border-color: #e1e9f1;
}

.pagination {
    --bs-pagination-border-color: var(--cn-border);
    --bs-pagination-active-bg: var(--cn-primary);
    --bs-pagination-active-border-color: var(--cn-primary);
    --bs-pagination-color: #2a4966;
    --bs-pagination-hover-color: #163b5a;
    --bs-pagination-hover-bg: #eaf2fa;
}

.pagination .page-link {
    border-radius: 10px;
    margin-inline: 2px;
}

/* =========================================================
   Dashboard
   ========================================================= */

.dashboard-page {
    display: grid;
    gap: 1rem;
}

.dashboard-hero {
    background: #fff;
    color: var(--cn-text);
    border-radius: var(--cn-radius-md);
    border: 1px solid var(--cn-border);
    box-shadow: var(--cn-shadow-sm);
    padding: 1.15rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.dashboard-hero h2,
.dashboard-hero p,
.dashboard-hero .text-muted {
    color: var(--cn-text) !important;
}

.dashboard-hero__meta {
    color: var(--cn-text-muted);
    font-size: 0.88rem;
}

.dashboard-hero__actions {
    display: inline-flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.dashboard-hero .btn-light {
    background: #f2f6fa;
    color: var(--cn-primary);
    border-color: var(--cn-border);
}

.dashboard-hero .btn-outline-light {
    color: var(--cn-primary);
    border-color: #b8c7d5;
}

.dashboard-metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.9rem;
}

.dashboard-metric {
    border: 1px solid var(--cn-border);
    border-radius: var(--cn-radius-md);
    background: #fff;
    box-shadow: var(--cn-shadow-sm);
    padding: 0.9rem;
    display: grid;
    gap: 0.42rem;
    min-height: 140px;
}

.dashboard-metric__label {
    color: var(--cn-text-muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.dashboard-metric__value {
    font-size: 1.55rem;
    font-weight: 800;
    color: #102a43;
    line-height: 1.2;
}

.dashboard-metric__link {
    margin-top: auto;
    font-size: 0.84rem;
    font-weight: 700;
}

.dashboard-metric--clients {
    border-top: 4px solid #2a7bbb;
}

.dashboard-metric--cash-rmb {
    border-top: 4px solid #208c61;
}

.dashboard-metric--cash-usd {
    border-top: 4px solid #3f6b8a;
}

.dashboard-metric--today {
    border-top: 4px solid #6c8093;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr);
    gap: 0.9rem;
}

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

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

.dashboard-quick-card {
    border: 1px solid var(--cn-border);
    border-radius: var(--cn-radius-md);
    background: #fff;
    box-shadow: var(--cn-shadow-sm);
    padding: 0.9rem 0.75rem;
    text-align: center;
    color: #183b5b;
    font-weight: 700;
    min-height: 112px;
    display: grid;
    align-content: center;
    gap: 0.4rem;
}

.dashboard-quick-card i {
    font-size: 1.2rem;
}

.dashboard-quick-card:hover {
    transform: translateY(-2px);
    border-color: #9cb6cf;
    color: var(--cn-primary-strong);
}

.dashboard-limited-card .card-body {
    padding: 1rem 1.1rem;
}

/* =========================================================
   Auth / Login
   ========================================================= */

body.auth-page {
    margin: 0;
    min-height: 100vh;
    background: #f3f5f7;
    color: #17324d;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.95fr);
    align-items: stretch;
}

.auth-visual {
    position: relative;
    padding: clamp(1.6rem, 4vw, 3rem);
    color: #f4faff;
    background: #1f4e79;
    overflow: hidden;
}

.auth-visual::before,
.auth-visual::after {
    display: none;
}

.auth-visual::before {
    width: 340px;
    height: 340px;
    inset-block-start: -110px;
    inset-inline-end: -90px;
}

.auth-visual::after {
    width: 260px;
    height: 260px;
    inset-block-end: -90px;
    inset-inline-start: -70px;
}

.auth-visual__inner {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1.4rem;
}

.auth-branding {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
}

.auth-branding img {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.3rem;
}

.auth-branding strong {
    display: block;
    font-size: clamp(1.08rem, 2vw, 1.35rem);
}

.auth-branding span {
    display: block;
    opacity: 0.85;
    font-size: 0.92rem;
}

.auth-visual__headline {
    max-width: 560px;
}

.auth-visual__headline h1 {
    color: #f5fbff;
    font-size: clamp(1.7rem, 3.2vw, 2.45rem);
    margin-bottom: 0.75rem;
}

.auth-visual__headline p {
    color: rgba(245, 251, 255, 0.84);
    max-width: 45ch;
    margin: 0;
}

.auth-panel {
    padding: clamp(1.2rem, 4vw, 2.4rem);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    width: min(460px, 100%);
    background: #fff;
    border: 1px solid var(--cn-border);
    border-radius: var(--cn-radius-lg);
    box-shadow: var(--cn-shadow-md);
    padding: 1.4rem;
}

.auth-card h2 {
    margin-bottom: 0.25rem;
}

.auth-card p {
    color: var(--cn-text-muted);
    margin-bottom: 1rem;
}

.auth-lang-panel {
    display: inline-flex;
    padding: 0.25rem;
    border-radius: 999px;
    border: 1px solid var(--cn-border);
    background: #f6f9fc;
    margin-bottom: 1rem;
}

.auth-lang-link {
    min-width: 46px;
    text-align: center;
    padding: 0.28rem 0.5rem;
    border-radius: 999px;
    color: #3b5d7d;
    font-weight: 700;
    font-size: 0.82rem;
}

.auth-lang-link.is-active,
.auth-lang-link:hover {
    background: #fff;
    color: var(--cn-primary);
    box-shadow: 0 2px 6px rgba(15, 76, 129, 0.14);
}

.auth-field {
    margin-bottom: 0.9rem;
}

.auth-actions-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.auth-forgot-link {
    font-size: 0.85rem;
    font-weight: 700;
}

.auth-submit {
    width: 100%;
    min-height: 45px;
    font-size: 0.95rem;
}

.auth-foot {
    margin-top: 0.9rem;
    color: #7a8ea4;
    font-size: 0.78rem;
    text-align: center;
}

/* =========================================================
   Status Cards, Page Utilities, Existing Modules
   ========================================================= */

.card.bg-primary,
.card.bg-success,
.card.bg-info,
.card.bg-warning,
.card.bg-danger,
.card.text-white {
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: var(--cn-shadow-sm);
}

.card.bg-primary {
    background: #1f4e79 !important;
}

.card.bg-success {
    background: #2f855a !important;
}

.card.bg-info {
    background: #446b88 !important;
}

.card.bg-warning {
    background: #b38834 !important;
}

.card.bg-danger {
    background: #b44a5c !important;
}

.clients-page,
.transactions-page,
.loadings-list-page,
.loading-create-page,
.dashboard-page,
.exchange-rates-page,
.users-ui,
.shared-containers-page,
.cashbox-page,
.acd-page,
.settings-page,
.reports-page {
    display: grid;
    gap: 1rem;
}

/* =========================================================
   Loadings Page Tuning
   ========================================================= */

.loadings-hero-card,
.loadings-filter-card,
.loadings-table-card,
.loadings-stats-grid .stat-card {
    border: 1px solid var(--cn-border) !important;
    background: #fff !important;
    box-shadow: var(--cn-shadow-sm) !important;
}

.loadings-hero-card .card-body,
.loadings-filter-card .card-body {
    padding: 1rem !important;
}

.loadings-hero-card .h3 {
    font-size: 1.9rem;
}

.loadings-meta-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #f6f9fb !important;
    border: 1px solid var(--cn-border) !important;
    color: #4a6075 !important;
    border-radius: 999px;
    padding: 0.24rem 0.56rem;
    font-size: 0.82rem;
    font-weight: 600;
}

.chip strong {
    color: var(--cn-text);
    font-weight: 800;
}

.loadings-filter-card .text-muted.small {
    font-size: 0.78rem !important;
}

.loadings-stats-grid .stat-card .card-body {
    padding: 0.7rem;
}

.loadings-stats-grid .stat-card .stat-label {
    color: var(--cn-text-muted);
    font-size: 0.74rem;
    margin-bottom: 0.2rem;
}

.loadings-stats-grid .stat-card .stat-value {
    font-size: 1.08rem;
    font-weight: 800;
    color: var(--cn-text);
}

.loadings-table-wrap .table th,
.loadings-table-wrap .table td {
    white-space: nowrap;
}

.loadings-table-wrap .table td {
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
}

.loadings-table-wrap .action-btn-group .btn {
    min-width: 34px;
}

@media (max-width: 1199.98px) {
    .loadings-table-wrap .col-csr {
        display: none;
    }
}

@media (max-width: 767.98px) {
    .loadings-table-wrap .col-client-code {
        display: none;
    }

    .loadings-filter-card .card-body {
        padding: 0.82rem !important;
    }

    .loadings-table-wrap .table > :not(caption) > * > * {
        padding: 0.45rem 0.42rem;
    }
}

.no-print .card,
.no-print .table-responsive {
    animation: cn-fade-in 300ms ease-out;
}

/* =========================================================
   Overlays / Loader
   ========================================================= */

.app-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 27, 46, 0.48);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 29, 52, 0.55);
    z-index: 1090;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lang-switch-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 22, 39, 0.45);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lang-switch-overlay__panel {
    background: #fff;
    border: 1px solid var(--cn-border);
    border-radius: var(--cn-radius-sm);
    box-shadow: var(--cn-shadow-md);
    padding: 0.8rem 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    color: #1c3f5f;
    font-weight: 700;
}

.page-loader {
    position: fixed;
    inset: 0;
    z-index: 1085;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(8, 24, 40, 0.4);
}

.page-loader.active {
    display: flex;
}

/* =========================================================
   Animations
   ========================================================= */

@keyframes cn-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* =========================================================
   RTL
   ========================================================= */

html[dir='rtl'] .app-topbar__left,
html[dir='rtl'] .app-topbar__actions,
html[dir='rtl'] .dashboard-hero__actions,
html[dir='rtl'] .auth-actions-row {
    flex-direction: row-reverse;
}

html[dir='rtl'] .app-footer {
    flex-direction: row-reverse;
}

html[dir='rtl'] .app-subnav {
    padding-inline-start: 0;
    padding-inline-end: 1.95rem;
}

html[dir='rtl'] .dropdown-menu {
    text-align: right;
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1399.98px) {
    .dashboard-metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 1199.98px) {
    .app-main {
        padding: 1rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .app-topbar__title {
        max-width: 34vw;
    }
}

@media (max-width: 991.98px) {
    .app-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .app-sidebar {
        position: fixed;
        inset-block: 0;
        inset-inline-start: 0;
        width: min(90vw, 340px);
        max-width: 340px;
        transform: translateX(-102%);
        transition: transform 0.26s ease, visibility 0.26s ease;
        box-shadow: var(--cn-shadow-md);
        visibility: hidden;
        pointer-events: none;
        will-change: transform;
    }

    html[dir='rtl'] .app-sidebar {
        inset-inline-start: auto;
        inset-inline-end: 0;
        transform: translateX(102%);
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    body.sidebar-open .app-sidebar-backdrop {
        opacity: 1;
        visibility: visible;
    }

    body.sidebar-open {
        overflow: hidden;
        touch-action: none;
    }

    .app-topbar {
        padding: 0.6rem 0.8rem;
        min-height: 64px;
    }

    .app-topbar__title-wrap {
        max-width: 46vw;
    }

    .app-topbar__title {
        font-size: 0.95rem;
        max-width: 100%;
    }

    .app-topbar__kicker {
        font-size: 0.66rem;
    }

    .app-topbar .btn span,
    .app-topbar .dropdown-toggle span.d-none.d-sm-inline {
        display: none !important;
    }

    #navbarNav.app-chip-nav,
    .app-chip-nav,
    .app-chip-nav.show {
        display: none !important;
        visibility: hidden !important;
        max-height: 0 !important;
        overflow: hidden !important;
    }

    .page-header,
    #main-content > .col-md-12.p-4 > .d-flex.justify-content-between.align-items-center.mb-4,
    #main-content > .col-12.p-4 > .d-flex.justify-content-between.align-items-center.mb-4 {
        padding: 0.78rem 0.82rem;
    }

    .app-footer {
        padding: 0.78rem 0.9rem;
        flex-direction: column;
        align-items: flex-start;
    }

    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-visual {
        min-height: 220px;
    }

    .auth-visual__headline h1 {
        font-size: 1.55rem;
    }
}

@media (max-width: 575.98px) {
    .dashboard-metric-grid,
    .dashboard-quick-grid {
        grid-template-columns: 1fr;
    }

    .app-main {
        padding: 0.75rem;
    }

    .card-header,
    .card-body,
    .card-footer {
        padding-inline: 0.75rem;
    }

    .app-topbar__actions {
        gap: 0.36rem;
    }

    .app-topbar .btn,
    .app-icon-btn {
        min-height: 34px;
        min-width: 34px;
        padding-inline: 0.5rem;
    }

    .nav-chip {
        min-height: 34px;
        padding: 0.3rem 0.62rem;
    }
}

/* =========================================================
   Print
   ========================================================= */

@media print {
    .app-sidebar,
    .app-topbar,
    .app-chip-nav,
    .app-footer,
    .app-sidebar-backdrop,
    .page-loader,
    #page-loader,
    .no-print {
        display: none !important;
    }

    .app-shell,
    .app-shell-main,
    .app-main,
    #main-content {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        min-height: auto !important;
    }

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

    .card,
    .table-responsive {
        box-shadow: none !important;
        border-color: #d4dbe3 !important;
    }
}

/* =========================================================
   Layout Fix – Zoom-level stability (2026-03-29)

   Root causes addressed:
   1. Bootstrap .row.g-3 uses margin-top: -1rem which exactly
      cancels the CSS Grid gap: 1rem on .loadings-list-page,
      causing stats cards to render flush against the filter
      card with zero visual separation. At subpixel zoom levels
      (80%, 67%) pixel rounding made the overlap inconsistent,
      producing visible clipping against the card above.
      Fix: stats grid is now a clean CSS Grid — no negative margins.

   2. No scroll-padding-top meant the sticky topbar (72px) could
      cover the top of any section when scrolled into view.
      Fix: scroll-padding-top set to topbar height + buffer.

   3. Table had no guaranteed minimum width; action buttons could
      be squeezed to zero at certain intermediate viewport widths.
      Fix: explicit min-width on table and key columns.

   4. The cn-fade-in animation uses transform: translateY which
      creates a temporary stacking context during 320ms. Without
      isolation on the parent, this competed with the sticky
      topbar's z-index: 1030 stacking context.
      Fix: isolation: isolate on #main-content.
   ========================================================= */

/* 1. scroll-padding-top: content anchored behind sticky topbar
      is now correctly offset when scrolled into view */
html {
    scroll-padding-top: calc(var(--topbar-height) + 0.5rem);
}

/* 2. Stats grid: pure CSS Grid, no Bootstrap row/col negative
      margins. Equal-height cards are automatic in CSS Grid. */
.loadings-stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.75rem;
    /* spacing above/below is handled by parent .loadings-list-page gap */
    margin: 0;
}

@media (max-width: 1199.98px) {
    .loadings-stats-grid {
        grid-template-columns: repeat(3, minmax(120px, 1fr));
    }
}

@media (max-width: 767.98px) {
    .loadings-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* 3. Table: guaranteed minimum width so horizontal scroll
      kicks in cleanly rather than columns being crushed.
      Actions column is always fully visible. */
#loadings-table {
    min-width: 1050px;
    width: 100%;
}

/* Column floor widths – prevents any column from being squeezed
   below a readable threshold at any zoom level */
#loadings-table .col-date       { min-width: 88px;  }
#loadings-table .col-container  { min-width: 148px; }
#loadings-table .col-client-code { min-width: 76px; }
#loadings-table .col-csr        { min-width: 72px;  }
#loadings-table .col-bol-status { min-width: 100px; }

/* Actions column: sticky to the inline-end edge (left in RTL, right in LTR)
   so it is never clipped by horizontal overflow.
   Using inset-inline-end avoids overlapping the adjacent BOL Status column
   when the table scrolls horizontally. */
#loadings-table th.no-print,
#loadings-table td.no-print {
    min-width: 116px;
    width:     116px;
    position:  sticky;
    inset-inline-end: 0;
    z-index:   2;
    background-color: #fff;
}

/* Subtle separator so the sticky column stands out when scrolled */
#loadings-table th.no-print,
#loadings-table td.no-print {
    border-inline-start: 1px solid var(--bs-border-color, #dee2e6);
}

/* Match the table-hover background on the sticky cell */
.loadings-table-wrap .table-hover tbody tr:hover td.no-print {
    background-color: #f7fbff;
}

/* 4. Stacking context isolation: prevents the cn-fade-in
      transform from leaking into the topbar's stacking context */
#main-content.app-main {
    isolation: isolate;
}

/* 5. Column text truncation – prevents wide-text columns from
      pushing BOL Status / Actions off-screen.                        */

/* Client Name cell text (Arabic names can also be long) */
#loadings-table td.col-client-name .lh-sm > div,
#loadings-table td.col-client-name .lh-sm > small {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

/* TH header for client-name column */
#loadings-table th.col-client-name {
    min-width: 110px;
    max-width: 200px;
}
