:root {
    --sp-navy: #0b1f33;
    --sp-navy-2: #123047;
    --sp-gold: #c9a227;
    --sp-gold-2: #e0b93a;
    --sp-bg: #eef2f6;
    --sp-card: #ffffff;
    --sp-text: #1b2a41;
    --sp-muted: #6b7c93;
    --sp-line: #dce3ec;
    --sp-sidebar-w: 260px;
}

* { box-sizing: border-box; }

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

body.app-body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--sp-bg);
    color: var(--sp-text);
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 0.55rem;
    background: linear-gradient(180deg, var(--sp-gold-2), var(--sp-gold));
    color: var(--sp-navy);
    font-weight: 800;
    font-size: 0.82rem;
    letter-spacing: 0.02em;
}

.app-logo {
    display: block;
    object-fit: contain;
    flex-shrink: 0;
}

.app-logo-sidebar {
    width: 2.5rem;
    height: 2.5rem;
}

.app-logo-login {
    width: 5.5rem;
    height: 5.5rem;
}

.app-logo-invoice {
    width: 3rem;
    height: 3rem;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sp-sidebar-w);
    background: linear-gradient(180deg, var(--sp-navy) 0%, #071422 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1040;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.15rem 1.1rem 1rem;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand:hover { color: #fff; }
.sidebar-brand strong { display: block; font-size: 0.92rem; letter-spacing: 0.04em; }
.sidebar-brand small { display: block; color: #9bb0c7; font-size: 0.72rem; }

.sidebar-label {
    margin: 1rem 1.1rem 0.35rem;
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #7f93aa;
}

.sidebar-nav { padding: 0 0.7rem; }

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #c5d3e3;
    padding: 0.62rem 0.8rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-size: 0.92rem;
    width: 100%;
    background: none;
    border: 0;
    text-align: left;
}

.sidebar .nav-link i { width: 1.15rem; }
.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: rgba(201, 162, 39, 0.16);
    color: #fff;
}

.sidebar .nav-toggle {
    justify-content: space-between;
    cursor: pointer;
}

.sidebar .nav-toggle span { display: flex; align-items: center; gap: 0.65rem; }
.sidebar .chevron { font-size: 0.75rem; transition: transform 0.2s ease; }
.sidebar .nav-group.open .chevron { transform: rotate(180deg); }
.sidebar .nav-sub {
    display: none;
    padding: 0 0 0.35rem 1.85rem;
}
.sidebar .nav-group.open .nav-sub { display: block; }
.sidebar .nav-sub .nav-link { font-size: 0.86rem; padding: 0.42rem 0.8rem; }

.sidebar-user {
    margin-top: auto;
    display: flex;
    gap: 0.7rem;
    align-items: center;
    padding: 1rem 1.1rem 1.2rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.user-avatar {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: var(--sp-gold);
    color: var(--sp-navy);
    display: inline-grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.78rem;
    flex-shrink: 0;
}

.user-avatar.sm { width: 2rem; height: 2rem; font-size: 0.72rem; }
.user-meta strong, .admin-chip strong { display: block; font-size: 0.85rem; line-height: 1.2; }
.user-meta small, .admin-chip small { display: block; color: #9bb0c7; font-size: 0.72rem; }

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

.topbar {
    background: var(--sp-card);
    border-bottom: 1px solid var(--sp-line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 0.85rem; }
.topbar h1 { margin: 0; font-size: 1.15rem; font-weight: 650; }
.topbar-sub { margin: 0; color: var(--sp-muted); font-size: 0.8rem; }

.sidebar-toggle {
    display: none;
    width: 2.35rem;
    height: 2.35rem;
    padding: 0;
    border: 1px solid var(--sp-line);
    background: #fff;
    color: var(--sp-navy);
}

.admin-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.25rem 0.55rem 0.25rem 0.25rem;
    border: 1px solid var(--sp-line);
    border-radius: 999px;
    background: #f8fafc;
}

.admin-chip small { color: var(--sp-muted); }

.btn-logout {
    border: 1px solid var(--sp-line);
    background: #fff;
    color: var(--sp-navy);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-logout:hover { background: #f8fafc; color: var(--sp-navy); }

.app-content { padding: 1.35rem 1.35rem 1rem; flex: 1; }

.welcome-panel {
    background: linear-gradient(120deg, var(--sp-navy) 0%, var(--sp-navy-2) 60%, #1a4a68 100%);
    color: #fff;
    border-radius: 1rem;
    padding: 1.35rem 1.45rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.15rem;
    box-shadow: 0 10px 24px rgba(11, 31, 51, 0.18);
}

.welcome-panel h2 { margin: 0 0 0.25rem; font-size: 1.35rem; }
.welcome-panel p { margin: 0; color: #c9d7e6; }
.welcome-meta { text-align: right; color: #d5e2ef; font-size: 0.85rem; }
.welcome-meta span { display: block; }

.stat-card {
    background: var(--sp-card);
    border: 1px solid var(--sp-line);
    border-radius: 0.9rem;
    padding: 1rem;
    display: flex;
    gap: 0.85rem;
    align-items: center;
    height: 100%;
    box-shadow: 0 6px 16px rgba(15, 36, 58, 0.04);
}

.stat-card p { margin: 0; color: var(--sp-muted); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.02em; }
.stat-card strong { display: block; font-size: 1.28rem; margin-top: 0.15rem; }
.stat-icon {
    width: 2.7rem;
    height: 2.7rem;
    border-radius: 0.75rem;
    display: grid;
    place-items: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.stat-customers .stat-icon { background: #e8f1ff; color: #2b6cb0; }
.stat-products .stat-icon { background: #eaf7ef; color: #2f855a; }
.stat-categories .stat-icon { background: #f4eaff; color: #6b46c1; }
.stat-invoices .stat-icon { background: #fff4e5; color: #c05621; }
.stat-sales .stat-icon { background: #fff8db; color: #b7791f; }

.panel {
    background: var(--sp-card);
    border: 1px solid var(--sp-line);
    border-radius: 0.9rem;
    padding: 1.1rem 1.15rem 1.2rem;
    box-shadow: 0 6px 16px rgba(15, 36, 58, 0.04);
}

.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.9rem; }
.panel-head h3 { margin: 0; font-size: 1rem; }

/* Title + search + filters + action — always one horizontal row */
.panel-toolbar-row {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 0.5rem;
    width: 100%;
}

.panel-toolbar-row > .panel-toolbar-title {
    flex: 0 0 auto;
    margin-right: 0.5rem;
}

.panel-toolbar-row > .input-group {
    flex: 1 1 auto;
    width: auto !important;
    min-width: 10rem;
}

.panel-toolbar-row > .form-select,
.panel-toolbar-row > input[type="date"],
.panel-toolbar-row > input.form-control:not(.input-group .form-control) {
    flex: 0 0 auto;
    width: auto !important;
}

.panel-toolbar-row > .form-select {
    min-width: 9.5rem;
}

.panel-toolbar-row > input[type="date"] {
    min-width: 9.5rem;
}

.panel-toolbar-row > .btn,
.panel-toolbar-row > a.btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

@media (max-width: 991.98px) {
    .panel-toolbar-row {
        flex-wrap: wrap !important;
        align-items: stretch !important;
    }

    .panel-toolbar-row > .panel-toolbar-title {
        flex: 1 1 100%;
        margin-right: 0;
    }

    .panel-toolbar-row > .input-group {
        flex: 1 1 100%;
        min-width: 0;
        width: 100% !important;
    }

    .panel-toolbar-row > .form-select,
    .panel-toolbar-row > input[type="date"],
    .panel-toolbar-row > input.form-control:not(.input-group .form-control) {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 0;
        width: auto !important;
        min-height: 2.75rem;
        font-size: 16px;
    }

    .panel-toolbar-row > .input-group .form-control {
        min-height: 2.75rem;
        font-size: 16px;
    }

    .panel-toolbar-row > .btn,
    .panel-toolbar-row > a.btn {
        flex: 1 1 auto;
        min-height: 2.7rem;
        justify-content: center;
        display: inline-flex;
        align-items: center;
    }
}

.quick-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.quick-link {
    border: 1px solid var(--sp-line);
    border-radius: 0.75rem;
    padding: 0.9rem;
    text-decoration: none;
    color: var(--sp-text);
    background: #f8fafc;
}

.quick-link:hover {
    border-color: var(--sp-gold);
    color: var(--sp-navy);
    background: #fff;
}

.quick-link i { color: var(--sp-gold); font-size: 1.15rem; }
.quick-link span { display: block; font-weight: 650; margin-top: 0.35rem; }
.quick-link small { color: var(--sp-muted); }

.empty-state {
    text-align: center;
    padding: 1.8rem 0.5rem 1.2rem;
    color: var(--sp-muted);
}

.empty-state i { font-size: 1.8rem; color: var(--sp-gold); display: block; margin-bottom: 0.55rem; }
.empty-state p { margin: 0; }

.app-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.35rem 1.1rem;
    color: var(--sp-muted);
    font-size: 0.78rem;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(7, 16, 28, 0.45);
    z-index: 1030;
}

@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-105%);
        transition: transform 0.22s ease;
        box-shadow: 12px 0 30px rgba(0,0,0,0.18);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .welcome-panel { flex-direction: column; }
    .welcome-meta { text-align: left; }
}

@media (max-width: 575.98px) {
    .quick-grid { grid-template-columns: 1fr; }
    .app-content { padding: 1rem; }
    .stat-card strong { font-size: 1.05rem; }
}

/* Login */
.login-card .btn-primary {
    background: var(--sp-navy);
    border-color: var(--sp-navy);
    font-weight: 650;
}

.login-card .btn-primary:hover {
    background: var(--sp-navy-2);
    border-color: var(--sp-navy-2);
}

.login-card {
    border-radius: 0.85rem;
}

/* Invoice form — searchable customer picker */
.customer-picker-search {
    position: relative;
}

.customer-picker-results {
    position: absolute;
    z-index: 1050;
    left: 0;
    right: 0;
    max-height: 280px;
    overflow-y: auto;
    margin-top: 0.25rem;
    border: 1px solid var(--sp-line);
    border-radius: 0.5rem;
    box-shadow: 0 8px 24px rgba(15, 36, 58, 0.12);
    background: #fff;
}

.customer-picker-results .list-group-item {
    border-left: none;
    border-right: none;
    cursor: pointer;
    padding: 0.65rem 0.85rem;
}

#customerSearchResults .list-group-item {
    padding: 0.32rem 0.7rem;
}

.customer-picker-result-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    min-width: 0;
}

.customer-picker-result-line .customer-picker-result-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
}

.customer-picker-result-ur {
    flex: 0 1 auto;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 48%;
}

.customer-picker-results .list-group-item:first-child {
    border-top: none;
}

.customer-picker-results .list-group-item:last-child {
    border-bottom: none;
}

.customer-picker-results .list-group-item:hover,
.customer-picker-results .list-group-item:focus {
    background: #f0f4f8;
}

.customer-picker-result-name {
    font-weight: 650;
    color: var(--sp-navy);
}

.customer-picker-result-meta {
    font-size: 0.8rem;
    color: var(--sp-muted);
}

.customer-picker-selected {
    border: 1px solid var(--sp-line);
    border-radius: 0.65rem;
    padding: 0.85rem 1rem;
    background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
}

.customer-picker-selected-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.customer-picker-empty {
    padding: 0.25rem 0;
}

.product-picker-search {
    max-width: 420px;
}

.product-line-card {
    line-height: 1.35;
}

.product-line-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.invoice-line-row.line-stock-over td {
    background-color: rgba(220, 53, 69, 0.06);
}

.js-line-stock-warning {
    font-weight: 500;
}

.table.data-table thead th {
    color: var(--sp-muted);
    font-size: 0.78rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom-color: var(--sp-line);
}

.table.data-table td {
    border-color: var(--sp-line);
}

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

.btn-primary:hover,
.btn-primary:focus {
    background: var(--sp-navy-2);
    border-color: var(--sp-navy-2);
}

.urdu-input,
.urdu-text {
    font-family: "Noto Nastaliq Urdu", "Noto Naskh Arabic", serif;
    direction: rtl;
    text-align: right;
}

.urdu-text {
    color: var(--sp-muted);
    margin-top: 0.15rem;
    line-height: 1.8;
}

.stock-badge {
    display: inline-block;
    margin-top: 0.35rem;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 650;
    letter-spacing: 0.02em;
}

.stock-in {
    background: #e8f7ef;
    color: #2f855a;
}

.stock-low {
    background: #fff4e5;
    color: #c05621;
}

.stock-out {
    background: #fde8e8;
    color: #c53030;
}

/* Invoice builder */
.invoice-builder-hero {
    background: linear-gradient(135deg, var(--sp-navy) 0%, var(--sp-navy-2) 100%);
    color: #fff;
    border: none;
    margin-bottom: 1rem;
}

.invoice-hero-grid {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.invoice-hero-label {
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #9bb0c7;
    margin: 0 0 0.25rem;
}

.invoice-hero-number {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.35rem;
    color: #fff;
}

.invoice-builder-hero .btn-outline-secondary {
    border-color: rgba(255,255,255,0.35);
    color: #fff;
}

.invoice-builder-hero .btn-outline-secondary:hover {
    background: rgba(255,255,255,0.12);
    border-color: #fff;
    color: #fff;
}

.invoice-builder-hero .btn-primary {
    background: var(--sp-gold);
    border-color: var(--sp-gold);
    color: var(--sp-navy);
    font-weight: 650;
}

.invoice-builder-hero .btn-primary:hover {
    background: var(--sp-gold-2);
    border-color: var(--sp-gold-2);
    color: var(--sp-navy);
}

.invoice-lines-panel .panel-head h3,
.invoice-meta-panel .panel-head h3,
.invoice-totals-panel .panel-head h3 {
    font-size: 0.95rem;
}

.invoice-lines-table thead th {
    font-size: 0.7rem;
    white-space: nowrap;
}

.invoice-lines-table td {
    vertical-align: middle;
    min-width: 0;
}

.invoice-line-product {
    min-width: 220px;
}

.invoice-line-qty,
.invoice-line-price,
.invoice-line-disc {
    min-width: 5.5rem;
}

.invoice-lines-table .js-line-qty,
.invoice-lines-table .js-line-price,
.invoice-lines-table .js-line-disc-value {
    min-width: 4.75rem;
    min-height: 2.4rem;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.35rem 0.5rem;
}

.invoice-lines-table .js-line-price,
.invoice-lines-table .js-line-disc-value {
    min-width: 6rem;
}

.invoice-line-remove-label {
    display: none;
}

.invoice-line-note-row td {
    padding-top: 0;
    border-top: none;
    padding-bottom: 0.7rem;
}

.js-line-note {
    display: block;
    width: 100%;
    max-width: none;
    min-height: 2.4rem;
    font-size: 1rem;
}

.invoice-lines-empty i {
    font-size: 1.4rem;
    color: var(--sp-gold);
    display: block;
    margin-bottom: 0.35rem;
}

.invoice-totals-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.invoice-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.35rem 0;
    border-bottom: 1px dashed var(--sp-line);
}

.invoice-total-row:last-child {
    border-bottom: none;
}

.invoice-total-discount {
    align-items: flex-start;
    border-bottom: none;
    padding-bottom: 0;
}

.invoice-grand-total {
    margin-top: 0.35rem;
    padding-top: 0.75rem;
    border-top: 2px solid var(--sp-navy);
    border-bottom: none;
    font-size: 1.05rem;
}

.invoice-grand-total strong {
    color: var(--sp-navy);
    font-size: 1.2rem;
}

.invoice-payment-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 650;
    min-height: 38px;
}

.invoice-payment-unpaid {
    background: #fde8e8;
    color: #c53030;
}

.invoice-payment-partial {
    background: #fff4e5;
    color: #c05621;
}

.invoice-payment-paid {
    background: #e8f7ef;
    color: #2f855a;
}

@media (max-width: 991.98px) {
    .invoice-lines-wrap {
        overflow: visible;
    }

    .invoice-lines-table,
    .invoice-lines-table tbody {
        display: block;
        width: 100%;
    }

    .invoice-lines-table thead {
        display: none;
    }

    .invoice-line-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.65rem 0.75rem;
        padding: 0.9rem;
        margin: 0;
        background: #fff;
        border: 1px solid var(--sp-line);
        border-bottom: none;
        border-radius: 0.75rem 0.75rem 0 0;
    }

    .invoice-line-row td {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-end;
        width: auto;
        min-width: 0 !important;
        padding: 0;
        border: none;
        text-align: start !important;
    }

    .invoice-line-row td[data-label]::before {
        content: attr(data-label);
        font-size: 0.72rem;
        font-weight: 650;
        color: var(--sp-muted);
        margin-bottom: 0.25rem;
        letter-spacing: 0.02em;
        text-transform: uppercase;
    }

    .invoice-line-product {
        grid-column: 1 / -1;
    }

    .invoice-line-total {
        justify-content: center;
    }

    .invoice-line-total .js-line-total {
        font-size: 1.15rem;
        min-height: 2.75rem;
        display: flex;
        align-items: center;
    }

    .invoice-line-actions {
        grid-column: 1 / -1;
        align-items: stretch;
    }

    .invoice-line-remove-label {
        display: inline;
    }

    .invoice-line-actions .js-remove-line {
        width: 100%;
        min-height: 2.5rem;
    }

    .invoice-lines-table .js-line-qty,
    .invoice-lines-table .js-line-price,
    .invoice-lines-table .js-line-disc-value,
    .invoice-lines-table .js-line-note {
        width: 100%;
        max-width: none;
        min-width: 0;
        min-height: 2.85rem;
        font-size: 16px;
        text-align: left !important;
    }

    .invoice-line-unit .js-line-unit {
        font-size: 1rem;
        min-height: 2.85rem;
        display: flex;
        align-items: center;
        font-weight: 600;
        color: var(--sp-navy);
    }

    .invoice-line-note-row {
        display: block;
        margin-bottom: 0.85rem;
    }

    .invoice-line-note-row td {
        display: block;
        padding: 0 0.9rem 0.9rem;
        border: 1px solid var(--sp-line);
        border-top: none;
        border-radius: 0 0 0.75rem 0.75rem;
        background: #fff;
    }

    #amount_paid,
    #discount_value {
        min-height: 2.75rem;
        font-size: 16px;
    }
}

@media (max-width: 767.98px) {
    .invoice-builder-hero-actions {
        width: 100%;
    }

    .invoice-builder-hero-actions .btn {
        flex: 1 1 auto;
    }
}

/* Form-wrapped scrollable modals: keep header/footer fixed, scroll the body */
.modal-dialog-scrollable .modal-content {
    max-height: calc(100vh - 3.5rem);
}

.modal-dialog-scrollable form.modal-content,
.modal-dialog-scrollable .modal-content > form {
    display: flex;
    flex-direction: column;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
}

.account-balance-box {
    padding: 0.75rem 0.9rem;
    border-radius: 0.55rem;
    background: #f4f7fa;
}

.account-balance-value {
    font-size: 1.65rem;
    font-weight: 750;
    line-height: 1.2;
    color: var(--sp-navy);
}

.account-balance-value.is-due {
    color: #c53030;
}

.account-balance-value.is-credit {
    color: #2f855a;
}

.account-balance-value.is-zero {
    color: var(--sp-muted);
}

.account-action-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
}

.account-action-option {
    margin: 0;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.account-page .form-control,
.account-search-group .form-control {
    min-height: 2.75rem;
    font-size: 1rem;
}

.account-search-group .input-group-text {
    font-size: 1.05rem;
}

.account-save-btn {
    min-height: 2.75rem;
    padding-left: 1.15rem;
    padding-right: 1.15rem;
}

@media (max-width: 767.98px) {
    .account-panel-head {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 0.65rem;
    }

    .account-panel-head > div {
        flex: 1 1 12rem;
    }

    .account-panel-head .btn {
        width: 100%;
        min-height: 2.6rem;
    }

    .account-action-options {
        flex-direction: column;
        gap: 0.55rem;
    }

    .account-action-option {
        width: 100%;
        padding: 0.75rem 0.9rem;
        border: 1px solid var(--sp-line);
        border-radius: 0.65rem;
        background: #f8fafc;
    }

    .account-save-btn {
        width: 100%;
    }

    .customer-picker-selected-head {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .stack-table-wrap {
        overflow: visible;
    }

    .stack-table,
    .stack-table tbody {
        display: block;
        width: 100%;
    }

    .stack-table thead {
        display: none;
    }

    .stack-table tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.45rem 0.75rem;
        margin-bottom: 0.75rem;
        padding: 0.85rem 0.9rem;
        background: #fff;
        border: 1px solid var(--sp-line);
        border-radius: 0.75rem;
    }

    .stack-table tbody td {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        width: auto;
        padding: 0;
        border: none;
        text-align: start !important;
        font-size: 1rem;
        font-weight: 600;
        word-break: break-word;
    }

    .stack-table tbody td[data-label]::before {
        content: attr(data-label);
        font-size: 0.72rem;
        font-weight: 650;
        color: var(--sp-muted);
        margin-bottom: 0.15rem;
        letter-spacing: 0.02em;
        text-transform: uppercase;
    }

    .stack-table tbody td.stack-full {
        grid-column: 1 / -1;
    }

    .stack-table tbody td.stack-empty,
    .stack-table tbody td[colspan] {
        grid-column: 1 / -1;
        display: block;
        text-align: center !important;
        font-weight: 500;
    }

    .stack-table tbody td.stack-empty::before,
    .stack-table tbody td[colspan]::before {
        display: none;
    }

    .invoice-list-table tbody td.invoice-list-actions {
        grid-column: 1 / -1;
        align-items: stretch;
    }

    .invoice-list-table .invoice-action-group {
        display: flex;
        width: 100%;
        flex-wrap: nowrap;
        justify-content: stretch;
    }

    .invoice-list-table .invoice-action-group .btn {
        flex: 1 1 0;
        min-width: 0;
        min-height: 2.7rem;
        font-size: 1.05rem;
    }
}

@media print {
    .stack-table-wrap {
        overflow: visible !important;
    }

    .stack-table {
        display: table !important;
        width: 100% !important;
    }

    .stack-table tbody {
        display: table-row-group !important;
    }

    .stack-table thead {
        display: table-header-group !important;
    }

    .stack-table tbody tr {
        display: table-row !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
        grid-template-columns: none !important;
    }

    .stack-table tbody td {
        display: table-cell !important;
        padding: 1.2mm 1.5mm !important;
        border: 1px solid #ccc !important;
        font-weight: 500;
    }

    .stack-table tbody td[data-label]::before {
        display: none !important;
    }
}
