﻿/* ==========================================================
   DMS APPLICATION STYLES
   ========================================================== */

/* ==========================================================
   GLOBAL RESET
   ========================================================== */
html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    color: #0f172a;
    background: #f6f7fb;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

*, *::before, *::after {
    box-sizing: border-box;
}

#app, .mud-application-layout, .mud-layout {
    height: 100%;
}

/* Utilities */
.text-right {
    text-align: right;
}

/* ==========================================================
   DIALOG STANDARD
   ========================================================== */
.mud-dialog {
    border-radius: 8px !important;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.28) !important;
}

.mud-dialog-width-sm {
    max-width: min(520px, calc(100vw - 32px)) !important;
}

.mud-dialog-width-md {
    max-width: min(860px, calc(100vw - 40px)) !important;
}

.mud-dialog-width-lg {
    max-width: min(1120px, calc(100vw - 48px)) !important;
}

.mud-dialog-width-xl {
    max-width: min(1480px, calc(100vw - 48px)) !important;
}

.mud-dialog-full-width {
    width: calc(100vw - 48px) !important;
}

.mud-dialog .mud-dialog-title {
    padding: 18px 20px 10px !important;
}

.mud-dialog .mud-dialog-content {
    padding: 16px 20px !important;
    max-height: calc(85vh - 128px);
    overflow-y: auto;
}

.mud-dialog .mud-dialog-actions {
    min-height: 56px;
    padding: 10px 12px !important;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    background: #fff;
}

.mud-dialog .mud-dialog-actions .mud-button-root {
    min-height: 36px;
}

@media (max-width: 640px) {
    .mud-dialog {
        margin: 12px !important;
    }

    .mud-dialog-full-width {
        width: calc(100vw - 24px) !important;
    }

    .mud-dialog .mud-dialog-content {
        max-height: calc(88vh - 128px);
        padding: 14px !important;
    }
}

.partner-address-header {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center !important;
    height: 30px;
    min-height: 30px;
    margin-bottom: 10px;
}

.partner-address-header .mud-checkbox {
    margin: 0 !important;
}

.partner-address-header .mud-typography {
    line-height: 30px;
}

.partner-address-header-spacer {
    flex: 0 0 auto;
    min-width: 1px;
}

.partner-same-billing-check {
    height: 30px;
    margin: 0 !important;
    display: flex;
    align-items: center;
}

.partner-same-billing-check .mud-button-root {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* ==========================================================
   MAIN LAYOUT
   ========================================================== */
.dms-layout {
    height: 100%;
}

.dms-main {
    height: 100%;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #f6f7fb;
    overflow: hidden;
    padding-top: 0 !important;
}

.dms-body {
    --dms-body-bottom-gap: 8px;
    flex: 1;
    min-height: 0;
    min-width: 0;
    padding: 20px 20px 8px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
}

/* ==========================================================
   AUTH PAGES
   ========================================================== */
.auth-layout {
    min-height: 100vh;
    width: 100%;
    display: flex;
    background: #ffffff;
    color: #0f172a;
}

.login-page {
    width: 100%;
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(560px, 1.15fr) minmax(420px, 0.85fr);
    align-items: stretch;
    gap: 0;
    padding: 0;
    background: #ffffff;
}

.login-brand-panel,
.login-card {
    border-radius: 0;
    border: 0;
    box-shadow: none;
}

.login-brand-panel {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: clamp(32px, 5vh, 72px);
    padding: clamp(40px, 5vw, 84px);
    color: #f8fafc;
    background:
        linear-gradient(135deg, rgba(11, 18, 32, 0.98), rgba(19, 55, 80, 0.96)),
        #0b1220;
    position: relative;
    overflow: hidden;
}

.login-brand-panel::after {
    content: "";
    position: absolute;
    inset: auto -14% -28% 24%;
    height: 58%;
    border: 1px solid rgba(125, 211, 252, 0.16);
    border-radius: 50%;
    transform: rotate(-8deg);
    pointer-events: none;
}

.login-brand-panel > * {
    position: relative;
    z-index: 1;
}

.login-brand-lockup {
    display: flex;
    align-items: center;
    gap: 14px;
}

.login-brand-lockup-logo {
    gap: 18px;
}

.login-brand-mark {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.20);
    background: rgba(255,255,255,0.10);
    font-weight: 900;
    letter-spacing: 0.3px;
}

.login-brand-logo-frame {
    width: min(240px, 42vw);
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.18);
    background: #ffffff;
    box-shadow: 0 12px 26px rgba(2, 6, 23, 0.18);
}

.login-brand-logo {
    display: block;
    width: 100%;
    max-height: 40px;
    object-fit: contain;
}

.login-brand-name {
    font-weight: 800;
    font-size: 16px;
}

.login-brand-subtitle {
    color: rgba(226, 232, 240, 0.76);
    font-size: 13px;
}

.login-brand-copy {
    max-width: 620px;
}

.login-eyebrow {
    margin: 0 0 10px;
    color: #0b5ed7;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.login-brand-copy .login-eyebrow {
    color: #7dd3fc;
}

.login-brand-copy h1 {
    margin: 0;
    max-width: 820px;
    font-size: clamp(36px, 4.6vw, 72px);
    line-height: 1.05;
    font-weight: 900;
}

.login-brand-copy p:last-child {
    max-width: 680px;
    margin: 22px 0 0;
    color: rgba(226, 232, 240, 0.82);
    font-size: 16px;
    line-height: 1.65;
}

.login-assurance-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.login-assurance-grid div {
    min-width: 0;
    padding: 14px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.08);
}

.login-assurance-grid span {
    display: block;
    margin-bottom: 6px;
    color: #7dd3fc;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.login-assurance-grid strong {
    display: block;
    color: #f8fafc;
    font-size: 13px;
    line-height: 1.35;
}

.login-card {
    width: 100%;
    max-width: 540px;
    min-height: 100vh;
    justify-self: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(40px, 5vw, 72px);
    background: transparent;
}

.login-card-header h2 {
    margin: 0;
    font-size: 30px;
    line-height: 1.1;
    font-weight: 900;
}

.login-card-header p:last-child {
    margin: 10px 0 0;
    color: #64748b;
    line-height: 1.5;
}

.login-alert {
    margin-top: 22px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid rgba(220, 38, 38, 0.18);
    background: #fef2f2;
    color: #991b1b;
    font-size: 14px;
    line-height: 1.45;
}

.login-form {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

.login-field {
    display: grid;
    gap: 7px;
}

.login-field span,
.login-check span {
    color: #334155;
    font-size: 13px;
    font-weight: 800;
}

.login-field input {
    width: 100%;
    min-height: 46px;
    border: 1px solid rgba(15, 23, 42, 0.18);
    border-radius: 8px;
    padding: 0 14px;
    color: #0f172a;
    background: #fff;
    font: inherit;
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.login-field input::placeholder {
    color: #94a3b8;
}

.login-field input:focus {
    border-color: #0b5ed7;
    box-shadow: 0 0 0 3px rgba(11, 94, 215, 0.14);
}

.login-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 24px;
}

.login-check {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.login-check input {
    width: 16px;
    height: 16px;
    accent-color: #0b5ed7;
}

.login-submit {
    width: 100%;
    min-height: 46px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    background: #0b5ed7;
    box-shadow: 0 10px 20px rgba(11, 94, 215, 0.22);
    font: inherit;
    font-weight: 900;
    cursor: pointer;
    transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.login-submit:hover {
    background: #094db2;
    box-shadow: 0 12px 24px rgba(11, 94, 215, 0.26);
}

.login-submit:active {
    transform: translateY(1px);
}

.login-footnote {
    margin: 22px 0 0;
    padding-top: 18px;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    color: #64748b;
    font-size: 12px;
    line-height: 1.55;
}

@media (max-width: 1020px) {
    .login-page {
        grid-template-columns: 1fr;
        min-height: 100vh;
    }

    .login-brand-panel {
        min-height: 430px;
    }

    .login-card {
        min-height: auto;
        max-width: 640px;
        padding-top: 44px;
        padding-bottom: 44px;
    }
}

@media (max-width: 640px) {
    .login-page {
        display: block;
    }

    .login-assurance-grid {
        grid-template-columns: 1fr;
    }

    .login-brand-panel,
    .login-card {
        padding: 22px;
    }

    .login-brand-lockup-logo {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .login-brand-logo-frame {
        width: min(240px, 100%);
    }

    .login-brand-panel {
        min-height: auto;
    }
}

/* ==========================================================
   SIDEBAR
   ========================================================== */
.dms-drawer,
.dms-drawer .mud-drawer-paper {
    background: #0b1220 !important;
    color: #e5e7eb !important;
    border-right: none !important;
}

    .dms-drawer .mud-drawer-content {
        background: #0b1220 !important;
    }

.dms-sidebar-shell {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.dms-logo {
    flex: 0 0 auto;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.dms-nav-main {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 12px;
}

.dms-nav .mud-nav-link,
.dms-nav .mud-nav-group,
.dms-nav .mud-nav-link *,
.dms-nav .mud-nav-group * {
    color: #e5e7eb !important;
}

    .dms-nav .mud-nav-link:hover,
    .dms-nav .mud-nav-group:hover {
        background: rgba(255,255,255,0.06) !important;
    }

.dms-nav .mud-nav-link-active {
    background: rgba(255,255,255,0.10) !important;
    border-radius: 8px;
}

.dms-logout-form {
    flex: 0 0 auto;
    margin: auto 8px 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.14);
}

.dms-logout-button {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 8px;
    color: #e5e7eb !important;
}

.dms-logout-button:hover {
    background: rgba(255,255,255,0.06);
}

/* ==========================================================
   PAGE
   ========================================================== */
.dms-page {
    width: 100%;
    min-width: 0;
}

.dms-page--full {
    flex: 1;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dms-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.dms-title {
    font-weight: 800;
    letter-spacing: -0.3px;
}

/* ==========================================================
   CARD + TOOLBAR
   ========================================================== */
.dms-card {
    width: 100%;
    min-width: 0;
    border-radius: 14px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: #ffffff;
    overflow: hidden;
    box-shadow: 0 6px 18px rgba(15,23,42,0.05);
}

.dms-card--fill {
    flex: 1;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.dms-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    flex-wrap: wrap;
    background: linear-gradient(to bottom, #ffffff, #fbfcff);
}

.dms-search {
    flex: 1;
    min-width: 320px;
}

/* ==========================================================
   DATAGRID (SAFE CORPORATE SKIN ONLY)
   ========================================================== */
/* IMPORTANT:
   We intentionally DO NOT force height:100% / overflow rules on MudDataGrid internals.
   Those are what caused:
   - first row showing at the bottom
   - empty space after pager
   - pager disappearing
*/

/* Description truncation */
.truncate {
    display: inline-block;
    max-width: 520px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

/* Corporate DataGrid look */
.dms-grid {
    width: 100%;
}

    /* Header */
    .dms-grid th {
        font-weight: 800;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.65px;
        color: rgba(15,23,42,0.60);
        background: #fbfcff;
        border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    }

    /* Cells */
    .dms-grid td {
        padding-top: 10px;
        padding-bottom: 10px;
        border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    }

    /* Hover */
    .dms-grid tbody tr:hover td {
        background: rgba(2, 132, 199, 0.06);
    }

    /* Pager area (just styling; no layout forcing) */
    .dms-grid .mud-table-pager,
    .dms-grid .mud-data-grid-pager {
        border-top: 1px solid rgba(15, 23, 42, 0.08);
        background: #fff;
    }

/* Record-list row numbering */
.dms-indexed-table table tbody {
    counter-reset: dms-row-number;
}

.dms-indexed-table table thead tr::before,
.dms-indexed-table table tbody tr::before {
    display: table-cell;
    width: 54px;
    min-width: 54px;
    max-width: 54px;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    border-right: 1px solid rgba(15, 23, 42, 0.08);
    vertical-align: middle;
    text-align: right;
    white-space: nowrap;
}

.dms-indexed-table table thead tr::before {
    content: "#";
    font-weight: 800;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.65px;
    color: rgba(15,23,42,0.60);
    background: #fbfcff;
}

.dms-indexed-table table tbody tr::before {
    counter-increment: dms-row-number;
    content: counter(dms-row-number);
    color: rgba(15,23,42,0.70);
    background: rgba(248,250,252,0.68);
}

.dms-indexed-table table tbody tr:last-child > td,
.dms-indexed-table table tbody tr:last-child > th,
.dms-indexed-table table tbody tr:last-child::before {
    border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
}

.dms-indexed-table.dms-index-narrow table thead tr::before,
.dms-indexed-table.dms-index-narrow table tbody tr::before {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    padding: 10px 10px;
}

/* Long single-table reports and multi-table work pages keep the page/table scrollable. */
.dms-table-scroll,
.dms-compact-table-scroll {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.dms-table-scroll .mud-table-container {
    flex: 1 1 auto;
    min-height: 0;
    height: auto !important;
    max-height: clamp(280px, calc(100vh - 300px), 520px);
    overflow-y: auto;
}

.dms-table-scroll table thead,
.dms-compact-table-scroll table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.dms-table-scroll .mud-table-pagination,
.dms-table-scroll .mud-table-pager,
.dms-table-scroll .mud-data-grid-pager,
.dms-compact-table-scroll .mud-table-pagination,
.dms-compact-table-scroll .mud-table-pager,
.dms-compact-table-scroll .mud-data-grid-pager {
    flex: 0 0 auto;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    background: #fff;
    z-index: 3;
}

.dms-visible-pager {
    position: relative;
    overflow: visible;
    padding-bottom: 56px;
}

.dms-visible-pager .mud-table-pagination,
.dms-visible-pager .mud-table-pager {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 56px;
    display: flex;
    align-items: center;
    background: #fff;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.dms-page-scroll {
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

.dms-finance-page {
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    padding-bottom: 20px;
}

.dms-finance-card {
    overflow: hidden;
}

/* Reusable frame for full-height table work pages.
   The outside gap matches the layout side gutter while preserving a visible pager. */
.dms-table-page-frame {
    --dms-table-page-edge-gap: 20px;
    width: 100%;
    min-width: 0;
    height: 100%;
    min-height: 0;
    padding-right: 0 !important;
    padding-bottom: max(0px, calc(var(--dms-table-page-edge-gap) - var(--dms-body-bottom-gap, 0px))) !important;
}

.dms-table-page-scroll {
    overflow-y: auto;
    overflow-x: hidden;
}

.dms-body > .inv-page,
.dms-body > .dash-page {
    --dms-table-page-edge-gap: 20px;
    height: 100%;
    min-height: 0;
    padding-bottom: max(0px, calc(var(--dms-table-page-edge-gap) - var(--dms-body-bottom-gap, 0px)));
    overflow-y: auto;
    overflow-x: hidden;
}

.dms-table-page-card {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dms-table-page-card > .mud-table,
.dms-table-fill {
    flex: 1 1 auto;
    min-height: 0;
}

.dms-table-page-card > .inv-grid-wrap,
.dms-table-page-card > .inv-grid-wrap > .mud-data-grid {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dms-table-fill .mud-table-container {
    flex: 1 1 auto;
    min-height: 0;
    height: auto !important;
    max-height: none !important;
    overflow-y: auto;
}

.dms-body > .inv-page:not(.dms-finance-page):not(.dms-fiscal-page):not(.dms-general-ledger-page) > .inv-card:last-child:has(.mud-table-container) {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.dms-body > .inv-page:not(.dms-finance-page):not(.dms-fiscal-page):not(.dms-general-ledger-page) > .inv-card:last-child > .mud-table.dms-table-scroll {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.dms-body > .inv-page:not(.dms-finance-page):not(.dms-fiscal-page):not(.dms-general-ledger-page) > .inv-card:last-child > .mud-table.dms-table-scroll .mud-table-container {
    flex: 1 1 auto;
    min-height: 0;
    height: auto !important;
    max-height: none !important;
    overflow-y: auto;
}

.dms-body > .inv-page:not(.dms-finance-page):not(.dms-fiscal-page):not(.dms-general-ledger-page) > .inv-card:last-child > .inv-grid-wrap > .mud-data-grid .mud-table-container {
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0;
    max-height: none !important;
    overflow-y: auto;
}

.dms-body > .inv-page:not(.dms-finance-page):not(.dms-fiscal-page):not(.dms-general-ledger-page) > .inv-card:last-child > .mud-table.dms-table-scroll .mud-table-pagination,
.dms-body > .inv-page:not(.dms-finance-page):not(.dms-fiscal-page):not(.dms-general-ledger-page) > .inv-card:last-child > .mud-table.dms-table-scroll .mud-table-pager,
.dms-body > .inv-page:not(.dms-finance-page):not(.dms-fiscal-page):not(.dms-general-ledger-page) > .inv-card:last-child > .inv-grid-wrap > .mud-data-grid .mud-data-grid-pager {
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    background: #fff;
}

.dms-page-scroll-loose {
    height: auto;
    min-height: 100%;
    overflow: visible;
    padding-bottom: 24px;
}

.dms-fiscal-page {
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.dms-fiscal-card {
    overflow: visible !important;
}

.dms-fiscal-card:last-child {
    margin-bottom: 0;
}

.dms-fiscal-bottom-spacer {
    flex: 0 0 24px;
    height: 24px;
}

.dms-general-ledger-page {
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.dms-general-ledger-card {
    overflow: visible !important;
}

.dms-general-ledger-card .mud-expand-panel-content {
    overflow: visible;
}

.dms-general-ledger-table .mud-table-container {
    max-height: none;
    overflow: visible;
}

.dms-general-ledger-bottom-spacer {
    flex: 0 0 24px;
    height: 24px;
}

.dms-fill-table-page {
    flex: 1;
    min-height: 0;
}

.dms-fill-table-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.dms-fill-table-card > .mud-table,
.dms-fill-table-card > .mud-data-grid {
    flex: 1;
    min-height: 0;
}

.dms-fill-table-card .mud-table-container {
    max-height: calc(100vh - 185px);
    overflow-y: auto;
}

.dms-compact-table-scroll .mud-table-container {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 300px;
    overflow-y: auto;
}

.dms-accounts-table .mud-table-container {
    height: clamp(420px, calc(100vh - 165px), 900px);
    max-height: clamp(420px, calc(100vh - 165px), 900px);
}

.dms-accounts-card {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.dms-accounts-card > .inv-grid-wrap,
.dms-accounts-card > .inv-grid-wrap > .mud-table {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.dms-accounts-card .mud-table-container {
    flex: 1 1 auto !important;
    min-height: 0;
    height: auto !important;
    max-height: none !important;
    overflow-y: auto;
}

.dms-ledger-card {
    flex: 1 1 auto !important;
    min-height: 0;
    display: flex !important;
    flex-direction: column;
    justify-content: flex-start;
}

.dms-ledger-card > .invoice-list-filter-panel,
.dms-ledger-card > .mud-divider,
.dms-ledger-card > .partner-card-summary {
    flex: 0 0 auto;
}

.dms-ledger-table {
    flex: 1 1 auto !important;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.dms-ledger-table .mud-table-container {
    flex: 1 1 auto !important;
    min-height: 0;
    height: auto !important;
    max-height: none !important;
    overflow-y: auto;
}

.dms-tasks-table .mud-table-container {
    height: clamp(420px, calc(100vh - 340px), 840px);
    max-height: clamp(420px, calc(100vh - 340px), 840px);
    overflow-y: auto;
}

.dms-tasks-table.dms-tasks-table--composer-open .mud-table-container {
    height: auto !important;
    max-height: clamp(220px, calc(100vh - 620px), 360px);
    overflow-y: auto;
}

.dms-journal-table .mud-table-container {
    height: 310px !important;
    max-height: 310px;
}

.dms-journal-table.dms-visible-pager {
    position: relative;
    padding-bottom: 56px;
}

.dms-journal-table.dms-visible-pager .mud-table-pagination,
.dms-journal-table.dms-visible-pager .mud-table-pager {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 56px;
    display: flex;
    align-items: center;
    background: #fff;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.dms-mapping-table .mud-table-container {
    flex: 1 1 auto !important;
    min-height: 0;
    height: auto !important;
    max-height: none !important;
    overflow-y: auto;
}

.dms-mapping-intro {
    flex: 0 0 auto;
    padding: 14px 16px;
    background: linear-gradient(to bottom, #ffffff, #fbfcff);
}

.dms-mapping-table .mud-input-control {
    width: 100%;
}

.dms-fiscal-years-table .mud-table-container {
    height: auto !important;
    max-height: none;
    overflow: visible !important;
}

.dms-fiscal-periods-table .mud-table-container {
    height: auto !important;
    max-height: none;
    overflow: visible !important;
}

.dms-fiscal-opening-table .mud-table-container {
    height: auto !important;
    max-height: none;
    overflow: visible !important;
}

/* ==========================================================
   SAFETY
   ========================================================== */
.mud-main-content, .mud-paper, .mud-container, .mud-layout, .mud-table {
    max-width: 100%;
    min-width: 0;
}

/* ==========================================================
   INVENTORY PAGE (full-width + corporate)
   ========================================================== */
.inv-page {
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.inv-header {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-top: 0;
    margin-top: 0;
}

/* Remove default h4 margins from MudText */
.inv-title {
    font-weight: 800;
    letter-spacing: -0.3px;
    margin: 0 !important;
    line-height: 1.1;
}

.inv-subtitle {
    color: rgba(15,23,42,0.65);
    margin: 2px 0 0 0 !important;
}

.inv-card {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    border-radius: 8px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: #fff;
    box-shadow: 0 6px 18px rgba(15,23,42,0.05);
    overflow: hidden;
}

.inv-card > .invoice-list-filter-panel,
.inv-card > .mud-divider,
.inv-card > .partner-card-summary {
    flex: 0 0 auto;
}

.inv-toolbar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    flex-wrap: wrap;
    background: linear-gradient(to bottom, #ffffff, #fbfcff);
}

.inv-chips {
    flex: 0 0 auto;
}

.inv-search {
    flex: 1 1 520px;
    min-width: 320px;
}

/* Wrapper ensures grid uses the full card width */
.inv-grid-wrap {
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.inv-grid {
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.inv-grid .mud-table-container {
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0;
    max-height: none !important;
    margin-top: 0 !important;
}

.inv-grid .mud-data-grid-pager,
.inv-grid .mud-table-pagination,
.inv-grid .mud-table-pager {
    flex: 0 0 auto;
    margin-top: 0;
}

.training-card {
    flex: 1 1 auto;
    min-height: 0;
}

.training-tabs {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.training-tabs .mud-tabs-toolbar {
    flex: 0 0 auto;
}

.training-tabs .mud-tabs-panels,
.training-tabs .mud-tabs-panels > div,
.training-tabs .mud-tab-panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.training-form-panel {
    flex: 0 0 auto;
    padding: 12px;
    background: linear-gradient(to bottom, #ffffff, #fbfcff);
}

.training-form-panel-secondary {
    padding-top: 10px;
}

.training-form-grid {
    align-items: center;
}

.training-action-item {
    display: flex;
    align-items: center;
}

.training-action-button {
    min-height: 40px;
    white-space: nowrap;
}

.training-filter-toolbar {
    flex: 0 0 auto;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
}

.training-grid-wrap {
    flex: 1 1 auto;
    min-height: 0;
}

.training-grid-wrap-only {
    border-top: 1px solid rgba(15, 23, 42, 0.06);
}

/* Truncate description */
.inv-truncate {
    display: inline-block;
    max-width: 520px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.inv-right {
    text-align: right;
}

.inv-empty {
    padding: 16px;
}

/* Corporate DataGrid skin */
.inv-grid th {
    font-weight: 800;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.65px;
    color: rgba(15,23,42,0.60);
    background: #fbfcff;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.inv-grid td {
    padding-top: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.inv-grid tbody tr:hover td {
    background: rgba(2, 132, 199, 0.06);
}

/* ==========================================================
   SNACKBAR (GLOBAL OVERRIDE) - MudBlazor renders snackbars in a portal
   so provider Class cannot scope it.
   ========================================================== */

/* Position */
.mud-snackbar-location-top-right,
.mud-snackbar-location-bottom-right {
    top: auto !important;
    right: 20px !important;
    bottom: 20px !important;
    transform: none !important;
}

/* Corporate look */
.mud-snackbar {
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
    font-weight: 600;
}

/* ==========================================================
   PRODUCT - CHILD ROW DETAILS (compact, looks like normal rows)
   ========================================================== */

.prod-child-cell {
    padding: 0 !important;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    background: #ffffff;
}

.prod-child-wrap {
    width: 100%;
}

/* each inventory row inside child details */
.prod-child-row {
    display: grid;
    grid-template-columns: 1fr 80px;
    align-items: center;
    padding: 6px 14px;
    font-size: 12px;
    color: rgba(15, 23, 42, 0.75);
    border-top: 1px solid rgba(15, 23, 42, 0.06);
    background: rgba(2, 132, 199, 0.03);
}

/* name aligned left */
.prod-child-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* qty aligned right */
.prod-child-qty {
    text-align: right;
    font-weight: 700;
    color: rgba(15, 23, 42, 0.85);
}

/* empty state */
.prod-child-empty {
    padding: 8px 14px;
    font-size: 12px;
    color: rgba(15, 23, 42, 0.55);
    background: rgba(2, 132, 199, 0.03);
}

/* ==========================================================
   PRINT LAYOUT
   ========================================================== */

/* Only affects SalesPrint page */
.sales-print.print-page {
    background: #eef1f7;
    padding: 16px;
    overflow: auto;
    height: 100%;
    min-height: 0;
}

.sales-print .print-sheet {
    box-sizing: border-box;
    width: 210mm;
    max-width: 210mm;
    min-height: 297mm;
    margin: 0 auto 16px;
    background: white;
    padding: 14mm 14mm;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.10);
    display: flex;
    flex-direction: column;
    break-after: page;
    page-break-after: always;
}

.sales-document-print .print-sheet {
    height: 297mm;
    max-height: 297mm;
    overflow: hidden;
}

.sales-print .print-sheet:last-child {
    margin-bottom: 0;
    break-after: auto;
    page-break-after: auto;
}

    /* Prevent huge logos */
    .sales-print .print-sheet img,
    .sales-print .print-sheet svg {
        max-width: 180px !important;
        max-height: 70px !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
    }

.sales-print .print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
}

.sales-print .print-header-compact {
    padding-bottom: 8px;
}

.sales-print .print-brand-block {
    display: block;
    align-items: flex-start;
    min-width: 0;
}

.sales-print .print-sheet .print-logo {
    display: block;
    max-width: 52mm !important;
    max-height: 24mm !important;
    object-fit: contain;
    transform: translateY(2mm);
}

.sales-print .print-sheet.print-sheet-first .print-logo {
    max-width: 74.88mm !important;
    max-height: 34.56mm !important;
}

.sales-print .print-brand {
    font-size: 18px;
    font-weight: 800;
}

.sales-print .print-title {
    font-size: 18px;
    font-weight: 800;
    text-align: right;
    margin-bottom: 8px;
}

.sales-print .print-right {
    text-align: right;
    line-height: 1.3;
}

.sales-print .print-muted {
    color: #64748b;
    font-size: 12px;
}

.sales-print .print-notice {
    border: 1px solid #f59e0b;
    color: #92400e;
    background: #fffbeb;
    border-radius: 8px;
    padding: 8px 10px;
    margin-top: 12px;
    margin-bottom: 14px;
    font-size: 12px;
    font-weight: 700;
}

.sales-print .print-notice-placeholder {
    visibility: hidden;
}

.sales-print .print-envelope-row {
    display: block;
    margin: 18mm 0 12px;
}

.sales-print .print-envelope-address {
    min-height: 35mm;
    padding: 0 0 0 1mm;
}

.sales-print .print-sheet-first .print-envelope-address {
    min-height: 25mm;
}

.sales-print .print-sender-line {
    display: inline-block;
    max-width: 88mm;
    margin-bottom: 5mm;
    border-bottom: 1px solid #94a3b8;
    color: #0f172a;
    font-size: 9px;
    line-height: 1.25;
    white-space: nowrap;
}

.sales-print .print-recipient-address {
    color: #0f172a;
    font-size: 12.5px;
    line-height: 1.35;
    white-space: pre-line;
}

.sales-print .print-continuation-label,
.sales-print .print-continued {
    color: #64748b;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: 0.35px;
}

.sales-print .print-continuation-label {
    margin-top: 8px;
    text-transform: uppercase;
}

.sales-print .print-bold {
    font-weight: 700;
}

.sales-print .print-line-meta {
    margin-top: 2px;
    color: #475569;
    font-size: 10.8px;
    line-height: 1.25;
}

.sales-print .print-blocks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 12px 0;
}

.sales-print .print-sheet-first .print-blocks {
    margin-top: 18px;
    transform: translateY(-2px);
}

.sales-document-print .print-sheet-first .print-table {
    transform: translateY(-8px);
}

.sales-document-print .print-sheet:not(.print-sheet-first) .print-table {
    transform: translateY(10px);
}

.sales-print .print-box {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px;
}

.sales-print .print-tax-notes {
    margin-top: 12px;
}

.sales-document-print .print-sheet:not(.print-sheet-first) .print-table + .print-tax-notes {
    transform: translateY(5px);
}

.sales-print .print-continued {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 28px;
    padding: 0;
    text-align: right;
}

.sales-print .print-sheet-first .print-table {
    margin-top: 18px;
}

.sales-document-print .print-sheet-first .print-continued {
    transform: translateY(-4px);
}

.sales-document-print .print-sheet:not(.print-sheet-first) .print-continued {
    transform: translateY(6px);
}

.sales-print .print-box-title {
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 6px;
    color: #0f172a;
}

.sales-print .print-address {
    white-space: pre-line;
}

.sales-print .print-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin-top: 8px;
}

    .sales-print .print-table th,
    .sales-print .print-table td {
        border-bottom: 1px solid #e5e7eb;
        padding: 8px 6px;
        vertical-align: top;
        font-size: 12.5px;
    }

    .sales-print .print-table th {
        font-size: 12px;
        color: #334155;
        text-align: left;
    }

    .sales-print .print-table th.text-right,
    .sales-print .print-table td.text-right {
        text-align: right;
    }

    .sales-print .print-table th:nth-child(n+3),
    .sales-print .print-table td:nth-child(n+3) {
        white-space: nowrap;
    }

    .sales-print .print-table th:nth-child(2),
    .sales-print .print-table td:nth-child(2) {
        overflow-wrap: anywhere;
    }

.sales-print .packing-line-detail td {
    padding-top: 0;
    color: #64748b;
    font-size: 11px;
}

.sales-print .print-footer {
    display: grid;
    grid-template-columns: 1.3fr 0.7fr;
    gap: 12px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e5e7eb;
}

.sales-print .print-totals {
    min-width: 0;
}

.sales-print .print-totals .row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(90px, auto);
    align-items: baseline;
    gap: 12px;
    margin: 0;
    padding: 6px 0;
    font-size: 12.5px;
}

.sales-print .print-totals .row > div {
    min-width: 0;
}

.sales-print .print-totals .row > div:first-child {
    overflow-wrap: anywhere;
}

.sales-print .print-totals .total {
    font-weight: 900;
    font-size: 13.5px;
    border-top: 1px solid #e5e7eb;
    padding-top: 10px;
}

.sales-print .print-section-title {
    margin-top: 12px;
    padding-top: 4px;
    color: #0f172a;
    font-size: 12px;
    font-weight: 900;
}

.sales-print .packing-signature-line {
    height: 42px;
    border-bottom: 1px solid #94a3b8;
    margin: 8px 0 6px;
}

.sales-print.packing-print .print-notice {
    margin-bottom: 10px;
}

.sales-print.packing-print .packing-print-blocks {
    gap: 8px;
    margin: 10px 0;
}

.sales-print.packing-print .print-box {
    padding: 8px;
}

.sales-print.packing-print .print-table th,
.sales-print.packing-print .print-table td {
    padding: 6px 5px;
    font-size: 11.5px;
}

.sales-print.packing-print .packing-print-table th:nth-child(6),
.sales-print.packing-print .packing-print-table td:nth-child(6),
.sales-print.packing-print .packing-print-table th:nth-child(7),
.sales-print.packing-print .packing-print-table td:nth-child(7) {
    white-space: normal;
    overflow-wrap: anywhere;
}

.sales-print.packing-print .print-line-meta {
    font-size: 10.2px;
}

.sales-print.packing-print .print-section-title {
    margin-top: 8px;
}

.sales-print.packing-print .packing-goods-title,
.sales-print.packing-print .packing-section-after-lines {
    margin-top: 30px;
}

.sales-print.packing-print .packing-closing-blocks {
    margin-top: 30px;
}

.sales-print.packing-print .print-sheet {
    position: relative;
    padding-bottom: 34mm;
}

.sales-print.packing-print .print-sheet:not(.print-sheet-first) .print-table {
    transform: none;
}

.sales-print.packing-print .print-sheet:not(.print-sheet-first) .packing-section-after-lines {
    margin-top: 18px;
}

.sales-print.packing-print .print-sheet:not(.print-sheet-first) .packing-closing-blocks {
    margin-top: 18px;
}

.sales-print .packing-signature-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.sales-print .print-page-bottom {
    margin-top: auto;
    padding-top: 4px;
}

.sales-print.packing-print .print-page-bottom {
    position: absolute;
    left: 14mm;
    right: 14mm;
    bottom: 14mm;
    margin-top: 0;
}

.sales-print .company-document-footer {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #cbd5e1;
    display: grid;
    grid-template-columns: 1.15fr 1.15fr 1fr 1.1fr;
    gap: 12px;
    color: #0f172a;
    font-size: 8.5px;
    line-height: 1.35;
}

.sales-document-print .print-page-bottom .company-document-footer {
    margin-top: 0;
}

.sales-print .company-footer-col {
    min-width: 0;
}

.sales-print .company-footer-strong {
    font-weight: 800;
}

.sales-print .print-page-number {
    min-height: 12px;
    padding-top: 1px;
    color: #64748b;
    font-size: 10.5px;
    line-height: 1.2;
    text-align: right;
}

.company-logo-preview {
    width: 180px;
    min-height: 76px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: #fff;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 700;
}

.company-logo-preview img {
    max-width: 160px;
    max-height: 58px;
    object-fit: contain;
}

.company-square-logo-preview {
    width: 76px;
    height: 76px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: #fff;
    color: #64748b;
    font-size: 12px;
    font-weight: 900;
}

.company-square-logo-preview img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.company-branding-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
    gap: 12px;
    margin-bottom: 16px;
}

.company-branding-tile {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto minmax(220px, 0.72fr);
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 8px;
    background: linear-gradient(to bottom, #ffffff, #fbfcff);
}

.company-branding-tile-square {
    grid-template-columns: minmax(160px, 1fr) auto minmax(190px, 0.74fr);
}

.company-branding-copy {
    min-width: 0;
}

.company-upload-row {
    min-width: 0;
    display: grid;
    gap: 6px;
    justify-items: start;
}

.company-upload-input {
    max-width: 100%;
    color: #475569;
    font-size: 12px;
}

.company-file-name {
    max-width: 100%;
}

.company-file-name .mud-typography {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 1280px) {
    .company-branding-panel {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .company-branding-tile,
    .company-branding-tile-square {
        grid-template-columns: 1fr;
        align-items: start;
    }
}

.print-preview-frame-shell {
    height: min(78vh, calc(100vh - 150px));
    min-height: 420px;
    overflow: hidden;
    border-radius: 10px;
    background: #f6f7fb;
}

.print-preview-frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 10px;
}

.sales-print.print-preview-mode {
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}

.sales-document-print.print-preview-mode .print-sheet {
    height: 297mm;
    min-height: 297mm;
    max-height: 297mm;
}

.sales-print.print-preview-mode .company-document-footer {
    margin-top: auto;
}

@page {
    size: A4 portrait;
    margin: 0;
}

@media print {
    html, body {
        background: white !important;
        width: auto !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    .print-layout-root {
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    .sales-print.print-page {
        padding: 0 !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
        background: white !important;
    }

    .sales-print .print-sheet {
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        display: flex !important;
        flex-direction: column !important;
        position: relative !important;
        width: 210mm !important;
        max-width: 210mm !important;
        min-height: 297mm !important;
        margin: 0 !important;
        padding: 14mm !important;
        break-after: page;
        page-break-after: always;
    }

    .sales-print.packing-print .print-sheet {
        padding-bottom: 34mm !important;
    }

    .sales-print.packing-print .print-page-bottom {
        position: absolute !important;
        left: 14mm !important;
        right: 14mm !important;
        bottom: 14mm !important;
        margin-top: 0 !important;
    }

    .sales-document-print .print-sheet {
        height: 297mm !important;
        max-height: 297mm !important;
        overflow: hidden !important;
    }

    .sales-print .print-sheet:last-child {
        break-after: auto;
        page-break-after: auto;
    }

    .sales-print .print-page-bottom {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .sales-print .print-page-number {
        position: static;
        min-height: 12px;
        padding-top: 1px;
        font-size: 10.5px;
        line-height: 1.2;
    }

    .sales-print .print-header,
    .sales-print .print-notice,
    .sales-print .print-blocks,
    .sales-print .print-box,
    .sales-print .print-footer,
    .sales-print .company-document-footer {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .sales-print .print-table {
        page-break-inside: auto;
    }

    .sales-print .print-table thead {
        display: table-header-group;
    }

    .sales-print .print-table tbody {
        display: table-row-group;
    }

    .sales-print .print-table tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .sales-print .print-sheet .print-logo {
        max-width: 52mm !important;
        max-height: 24mm !important;
    }

    .sales-print .print-sheet.print-sheet-first .print-logo {
        max-width: 74.88mm !important;
        max-height: 34.56mm !important;
    }

    /* hide app chrome */
    .mud-appbar,
    .mud-drawer,
    .mud-dialog-container,
    .mud-snackbar,
    .mud-overlay {
        display: none !important;
    }
}
/* ==========================================================
   PAGE AND COMPONENT STYLES
   ========================================================== */

/* Print layout shell */
/* Minimal wrapper for print pages (no sidebar/app chrome) */
    .print-layout-root {
        height: 100%;
        min-height: 0;
        overflow: hidden;
        background: #f6f7fb;
    }

.packing-editor-table-wrap {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

.packing-editor-table-wrap .mud-input-control {
    margin-top: 0;
}

.packing-package-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    background: #fff;
}

.packing-package-header {
    margin-bottom: 8px;
}

/* Dashboard */
.dash-page {
        width: 100%;
        min-width: 0;
        flex: 1 1 auto;
        height: 100%;
        min-height: 0;
        overflow: hidden;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .dms-body > .dash-page {
        overflow: hidden;
        padding-bottom: 0;
    }

    .dash-header {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        flex: 0 0 auto;
    }

    .dash-header-actions {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }

    .dash-updated-pill {
        min-height: 34px;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 5px 10px;
        border: 1px solid rgba(15,23,42,0.10);
        border-radius: 8px;
        background: rgba(255,255,255,0.78);
        color: rgba(15,23,42,0.68);
        box-shadow: 0 6px 16px rgba(15,23,42,0.04);
        white-space: nowrap;
    }

    .dash-updated-label {
        display: block;
        color: rgba(15,23,42,0.48);
        font-size: 10px;
        line-height: 1;
        text-transform: uppercase;
        letter-spacing: 0;
    }

    .dash-updated-time {
        display: block;
        color: #0f172a;
        font-size: 12px;
        font-weight: 750;
        line-height: 1.2;
    }

    .dash-refresh-button {
        min-height: 34px;
        border-radius: 8px;
        box-shadow: 0 6px 16px rgba(37,99,235,0.24);
    }

    .dash-title {
        font-weight: 800;
        letter-spacing: 0;
        margin: 0 !important;
        line-height: 1.1;
    }

    .dash-subtitle {
        color: rgba(15,23,42,0.65);
        margin: 2px 0 0 0 !important;
    }

    .dash-kpi-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
        gap: 8px;
        flex: 0 0 auto;
    }

    .dash-kpi,
    .dash-panel {
        border: 1px solid rgba(15, 23, 42, 0.08);
        border-radius: 8px;
        background: #fff;
        box-shadow: 0 6px 18px rgba(15,23,42,0.05);
    }

    .dash-kpi {
        padding: 9px 10px;
        border-left: 4px solid #2563eb;
        min-height: 76px;
    }

    .dash-kpi-top {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
    }

    .dash-kpi-label,
    .dash-kpi-detail,
    .dash-row-muted {
        color: rgba(15,23,42,0.62);
    }

    .dash-kpi-value {
        font-weight: 850;
        margin: 6px 0 1px 0 !important;
        letter-spacing: 0;
        line-height: 1.05;
    }

    .dash-grid {
        display: grid;
        gap: 8px;
        min-width: 0;
        min-height: 0;
    }

    .dash-grid-primary {
        grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
        flex: 0 0 clamp(220px, 31vh, 300px);
    }

    .dash-panel-wide {
        grid-column: auto;
    }

    .dash-grid-secondary {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        flex: 0 0 clamp(180px, 22vh, 230px);
    }

    .dash-grid-bottom {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        flex: 1 1 0;
        padding-bottom: 0;
        min-height: 0;
    }

    .dash-panel {
        min-width: 0;
        min-height: 0;
        padding: 10px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .dash-panel-head {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
        margin-bottom: 6px;
        flex: 0 0 auto;
    }

    .dash-panel-title {
        font-weight: 800;
        margin: 0 !important;
    }

    .dash-chart {
        height: auto;
        min-height: 0;
        flex: 1 1 auto;
        position: relative;
    }

    .dash-chart-tall {
        min-height: 150px;
    }

    .dash-chart-compact {
        min-height: 110px;
        margin-top: 2px;
    }

    .dash-chart canvas {
        width: 100% !important;
        height: 100% !important;
    }

    .dash-chart-empty {
        min-height: 110px;
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 8px;
        color: rgba(15,23,42,0.58);
        text-align: center;
        border: 1px dashed rgba(15,23,42,0.14);
        border-radius: 8px;
        background: rgba(248,250,252,0.78);
        margin-top: 2px;
    }

    .dash-today-list,
    .dash-alert-list,
    .dash-activity-list,
    .dash-split-list {
        display: flex;
        flex-direction: column;
        gap: 4px;
        min-height: 0;
        overflow-y: auto;
        padding-right: 2px;
    }

    .dash-today-row,
    .dash-alert-row,
    .dash-activity-row,
    .dash-mini-row {
        display: grid;
        align-items: center;
        gap: 8px;
        min-width: 0;
        padding: 6px 0;
        border-bottom: 1px solid rgba(15,23,42,0.06);
        color: inherit;
        text-decoration: none;
    }

    .dash-today-row {
        grid-template-columns: 24px minmax(0, 1fr) auto;
    }

    .dash-alert-row {
        grid-template-columns: 24px minmax(0, 1fr);
    }

    .dash-activity-row {
        grid-template-columns: 74px minmax(0, 1fr) auto;
    }

    .dash-mini-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .dash-row-title,
    .dash-section-label {
        font-size: 13px;
        font-weight: 750;
        color: #0f172a;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .dash-row-muted {
        font-size: 12px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .dash-row-number,
    .dash-activity-value,
    .dash-mini-row b {
        font-weight: 850;
        color: #0f172a;
        white-space: nowrap;
    }

    .dash-activity-type {
        font-size: 11px;
        font-weight: 800;
        color: rgba(15,23,42,0.60);
        text-transform: uppercase;
        letter-spacing: 0;
    }

    .dash-section-label {
        color: rgba(15,23,42,0.55);
        text-transform: uppercase;
        font-size: 11px;
        margin: 2px 0 4px 0;
    }

    .dash-empty {
        font-size: 13px;
        color: rgba(15,23,42,0.55);
        padding: 8px 0;
    }

    @media (max-width: 1400px) {
        .dash-grid-primary,
        .dash-grid-secondary,
        .dash-grid-bottom {
            grid-template-columns: repeat(2, minmax(0, 1fr));
        }
    }

    @media (max-width: 900px) {
        .dash-header,
        .dash-panel-head {
            flex-direction: column;
            align-items: stretch;
        }

        .dash-header-actions {
            width: 100%;
            justify-content: space-between;
        }

        .dash-updated-pill {
            flex: 1;
        }

        .dash-kpi-grid,
        .dash-grid-primary,
        .dash-grid-secondary,
        .dash-grid-bottom {
            grid-template-columns: 1fr;
        }

        .dash-panel-wide {
            grid-column: auto;
        }

        .dash-chart,
        .dash-chart-tall,
        .dash-chart-compact {
            height: 260px;
            min-height: 260px;
        }
    }

/* Invoice editors */
.invoicein-card-pad {
    padding: 16px 18px;
}

.dms-body > .invoicein-page {
    overflow: hidden;
    padding-bottom: 0;
}

.invoicein-page > .inv-header {
    flex: 0 0 auto;
}

.invoicein-page > .invoicein-card-pad {
    flex: 1 1 auto;
    min-height: 0;
}

.invoicein-editor-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

    .invoicein-addline {
        flex-wrap: nowrap;
        width: 100%;
        min-width: 0;
        align-items: center;
    }

    .invoicein-addline-type {
        flex: 0 0 240px;
    }

    .invoicein-addline-main,
    .invoicein-addline-category,
    .invoicein-addline-description {
        flex: 1 1 0;
        min-width: 0;
    }

    .invoicein-addline-button {
        flex: 0 0 auto;
        height: 40px;
        align-self: center;
    }

.invoicein-table-scroll {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    padding-bottom: 6px;
    margin-top: 10px;
}

    .invoicein-table-scroll .mud-table-container {
        overflow-y: visible !important;
    }

    .sales-invoice-lines-scroll {
        overflow-y: hidden;
        max-height: none;
    }

.sales-invoice-lines-scroll--active {
    overflow-y: auto;
    max-height: clamp(260px, calc(100vh - 620px), 560px);
}

    .invoicein-lines-table {
        width: 100%;
        min-width: 0;
        table-layout: fixed;
    }

    .invoicein-lines-table th,
    .invoicein-lines-table td {
        overflow: hidden;
        vertical-align: middle;
    }

    .invoicein-lines-table th {
        white-space: nowrap;
    }

    .invoicein-col-type {
        width: 6%;
    }

    .invoicein-col-item {
        width: 17%;
    }

    .invoicein-col-description {
        width: 17%;
    }

    .invoicein-col-qty {
        width: 8%;
    }

    .invoicein-col-price {
        width: 9%;
    }

    .invoicein-col-vat {
        width: 8%;
    }

    .invoicein-col-total {
        width: 9%;
    }

    .invoicein-col-lot {
        width: 11%;
    }

    .invoicein-col-expiry {
        width: 12%;
    }

    .invoicein-col-actions {
        width: 44px;
    }

    .invoicein-line-text {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .invoicein-cell-control {
        width: 100%;
        min-width: 0;
    }

    .invoicein-footer {
        position: sticky;
        bottom: 0;
        flex: 0 0 auto;
        background: white;
        z-index: 5;
        border-top: 1px solid rgba(15,23,42,0.08);
        padding-top: 10px;
        margin-top: auto;
        width: 100%;
    }
    .text-right { text-align: right; }
    .invoicein-total-strong { font-weight: 700; }

@media (max-width: 1100px) {
    .dms-body > .invoicein-page {
        overflow-y: auto;
        padding-bottom: 20px;
    }

    .invoicein-page > .invoicein-card-pad,
    .invoicein-editor-body,
    .invoicein-table-scroll {
        flex: 0 0 auto;
    }

    .invoicein-addline {
        flex-wrap: wrap;
    }

    .invoicein-addline-type,
    .invoicein-addline-main,
    .invoicein-addline-category,
    .invoicein-addline-description {
        flex: 1 1 280px;
    }

    .invoicein-lines-table {
        min-width: 980px;
    }

    .sales-invoice-lines-scroll--active {
        max-height: clamp(420px, calc(100vh - 470px), 700px);
    }
}

.expense-filter-panel {
    padding: 14px 16px 12px;
}

.expense-filter-control {
    width: 100%;
}

.expense-filter-switch,
.expense-filter-actions {
    display: flex;
    align-items: center;
    min-height: 40px;
}

.expense-filter-actions {
    justify-content: flex-end;
    gap: 8px;
}

.expense-filter-actions .mud-button {
    min-width: 92px;
}

.invoice-list-filter-panel {
    padding: 12px;
    background: linear-gradient(to bottom, #ffffff, #fbfcff);
}

.invoice-list-filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
}

.invoice-list-filter-control {
    flex: 0 0 auto;
    min-width: 0;
}

.invoice-list-search {
    flex: 1 1 520px;
}

.invoice-list-select {
    flex-basis: 264px;
}

.invoice-list-date {
    flex-basis: 170px;
}

.invoice-list-filter-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: 0 0 auto;
    flex-wrap: nowrap;
}

.invoice-list-filter-actions .mud-button {
    min-width: 92px;
}

.partner-card-summary {
    display: grid;
    grid-template-columns: repeat(6, minmax(130px, 1fr));
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.partner-card-kpi {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 12px;
    background: #ffffff;
}

.partner-card-kpi-label {
    color: #64748b;
    font-size: 12px;
}

.partner-card-kpi-value {
    margin-top: 4px;
    font-weight: 700;
    font-size: 18px;
}

.partner-card-amount-zero {
    color: #16a34a;
}

.partner-card-amount-owe {
    color: #f97316;
}

.partner-card-amount-receivable {
    color: #dc2626;
}

@media (max-width: 900px) {
    .invoice-list-filter-row {
        flex-wrap: wrap;
    }

    .invoice-list-search,
    .invoice-list-select,
    .invoice-list-date {
        flex: 1 1 260px;
    }

    .invoice-list-filter-actions {
        flex: 1 1 100%;
    }

    .expense-filter-actions,
    .invoice-list-filter-actions {
        justify-content: flex-start;
    }

    .partner-card-summary {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
    }
}

/* Product child details */
/* Compact child rows (no card, minimal padding) */
    .prod-child-wrap {
        padding: 6px 14px 10px 14px;
    }

    .prod-child-muted {
        font-size: 12px;
        color: rgba(15,23,42,0.55);
    }

    .prod-child-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px 18px;
        font-size: 12px;
        margin-bottom: 10px;
        color: rgba(15,23,42,0.78);
    }

    .prod-child-label {
        text-transform: uppercase;
        font-size: 10px;
        color: rgba(15,23,42,0.5);
        margin-bottom: 2px;
    }

    .prod-child-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 12px;
    }

        .prod-child-table th {
            text-transform: uppercase;
            letter-spacing: 0;
            font-size: 11px;
            color: rgba(15,23,42,0.55);
            padding: 4px 6px;
            border-bottom: 1px solid rgba(15,23,42,0.08);
        }

        .prod-child-table td {
            padding: 4px 6px;
            border-bottom: 1px solid rgba(15,23,42,0.06);
        }

/* Tasks inbox */
.tasks-page {
    width: 100%;
    min-width: 0;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    padding-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tasks-page--composer-open {
    padding-bottom: 28px;
}

.tasks-header,
.tasks-composer-head,
.tasks-toolbar,
.tasks-item-title-row,
.tasks-actions,
.tasks-meta,
.tasks-activity {
    display: flex;
    align-items: center;
}

.tasks-header,
.tasks-composer-head,
.tasks-toolbar,
.tasks-item-title-row {
    justify-content: space-between;
    gap: 16px;
}

.tasks-header {
    align-items: flex-start;
}

.tasks-header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.tasks-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 10px;
}

.tasks-stat,
.tasks-card,
.tasks-composer,
.tasks-item {
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: #fff;
    box-shadow: 0 6px 18px rgba(15,23,42,0.05);
}

.tasks-stat {
    border-radius: 8px;
    padding: 12px;
}

.tasks-stat span {
    display: block;
    color: rgba(15,23,42,0.58);
    font-size: 12px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.tasks-stat b {
    display: block;
    margin-top: 6px;
    font-size: 24px;
    line-height: 1;
    color: #0f172a;
}

.tasks-card,
.tasks-composer {
    border-radius: 8px;
    overflow: hidden;
}

.tasks-card {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.tasks-card > .mud-table {
    min-height: 0;
}

.tasks-composer {
    padding: 16px;
    overflow: visible;
}

.tasks-panel-title,
.tasks-item-title {
    font-weight: 800;
    margin: 0 !important;
}

.tasks-composer-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 2px;
}

.tasks-toolbar {
    padding: 12px;
    flex-wrap: wrap;
    background: linear-gradient(to bottom, #ffffff, #fbfcff);
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.tasks-search {
    flex: 1 1 420px;
    min-width: 260px;
}

.tasks-filter {
    flex: 0 0 auto;
}

.tasks-list {
    display: flex;
    flex-direction: column;
}

.tasks-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    padding: 14px 16px;
    border-width: 0 0 1px 0;
    box-shadow: none;
}

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

.tasks-item--completed {
    background: rgba(22, 163, 74, 0.035);
}

.tasks-item--cancelled {
    opacity: 0.72;
}

.tasks-item-main {
    min-width: 0;
}

.tasks-badges,
.tasks-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.tasks-description {
    margin-top: 6px !important;
    color: rgba(15,23,42,0.72);
    max-width: 980px;
}

.tasks-meta {
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 10px;
    color: rgba(15,23,42,0.58);
    font-size: 12px;
}

.tasks-meta span,
.tasks-activity {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.tasks-activity {
    margin-top: 8px;
    color: rgba(15,23,42,0.55);
    font-size: 12px;
}

.tasks-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 180px;
    padding: 24px;
}

@media (max-width: 900px) {
    .tasks-header,
    .tasks-composer-head,
    .tasks-toolbar,
    .tasks-item-title-row {
        align-items: stretch;
        flex-direction: column;
    }

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

    .tasks-item {
        grid-template-columns: 1fr;
    }

    .tasks-actions,
    .tasks-badges {
        justify-content: flex-start;
    }
}
