/* POS UMKM UI/UX polish - 20260602
   Safe visual layer only: readability, action clarity, dense form grouping.
*/

:root {
    --ux-surface: var(--app-surface, #ffffff);
    --ux-surface-soft: var(--app-surface-soft, #f8fafc);
    --ux-text: var(--app-text, #0f172a);
    --ux-heading: var(--app-heading, #0f172a);
    --ux-muted: var(--app-muted, #64748b);
    --ux-border: var(--app-border, #dbe4ef);
    --ux-border-soft: var(--app-border-soft, #e9eff7);
    --ux-primary: var(--app-primary, #2563eb);
    --ux-primary-soft: var(--app-primary-soft, #e8f0ff);
    --ux-success: var(--app-success, #059669);
    --ux-success-soft: var(--app-success-soft, #e8f8f1);
    --ux-warning: var(--app-warning, #d97706);
    --ux-warning-soft: var(--app-warning-soft, #fff7e6);
    --ux-danger: var(--app-danger, #dc2626);
    --ux-danger-soft: var(--app-danger-soft, #fff1f2);
    --ux-radius: var(--app-radius, 13px);
    --ux-radius-lg: var(--app-radius-lg, 18px);
    --ux-shadow-sm: var(--app-shadow-sm, 0 8px 22px rgba(15,23,42,.06));
}

.app-nav-trigger:after {
    content: "\25BE" !important;
}

.login-shell {
    max-height: calc(100vh - 48px);
}

.login-intro {
    justify-content: center;
}

.login-brand-logo {
    image-rendering: auto;
}

.app-brand-logo {
    flex: 0 0 auto;
}

.branch-pill,
.user-button {
    min-width: 0;
}

.branch-pill strong,
.user-button span:nth-child(2) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ux-note,
.ux-warning,
.ux-danger-note,
.ux-success-note,
.stock-context-note,
.opname-impact-note,
.return-impact-note,
.cash-impact-note {
    display: block;
    margin: 0 0 14px;
    padding: 12px 14px;
    border: 1px solid var(--ux-border);
    border-radius: var(--ux-radius-lg);
    background: var(--ux-surface-soft);
    color: var(--ux-text);
    line-height: 1.5;
    box-shadow: var(--ux-shadow-sm);
}

.ux-note,
.stock-context-note,
.cash-impact-note {
    background: linear-gradient(135deg, var(--ux-primary-soft), var(--ux-surface));
    border-color: color-mix(in srgb, var(--ux-primary) 22%, var(--ux-border));
}

.ux-warning,
.opname-impact-note,
.return-impact-note {
    background: var(--ux-warning-soft);
    border-color: color-mix(in srgb, var(--ux-warning) 30%, var(--ux-border));
    color: var(--ux-text);
}

.ux-danger-note {
    background: var(--ux-danger-soft);
    border-color: color-mix(in srgb, var(--ux-danger) 30%, var(--ux-border));
    color: var(--ux-text);
}

.ux-success-note {
    background: linear-gradient(135deg, var(--ux-success-soft), var(--ux-surface));
    border-color: color-mix(in srgb, var(--ux-success) 30%, var(--ux-border));
    color: var(--ux-text);
}

.ux-note strong,
.ux-warning strong,
.ux-danger-note strong,
.ux-success-note strong,
.stock-context-note strong,
.opname-impact-note strong,
.return-impact-note strong,
.cash-impact-note strong {
    color: var(--ux-heading);
}

.debt-payment-alert {
    display: grid;
    gap: 5px;
    border-left: 5px solid var(--ux-danger);
}

.debt-payment-success {
    border-left-color: var(--ux-success);
}

.debt-payment-alert span {
    display: block;
}

.debt-payment-success span {
    color: var(--ux-text);
    font-weight: 750;
}

.debt-payment-alert small {
    display: block;
    color: var(--ux-muted);
    font-weight: 750;
}

.ux-flow-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 14px;
}

.ux-flow-steps span {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--ux-surface-soft);
    border: 1px solid var(--ux-border);
    color: var(--ux-muted);
    font-size: 12px;
    font-weight: 850;
}

.ux-flow-steps span.is-primary {
    background: var(--ux-primary-soft);
    border-color: color-mix(in srgb, var(--ux-primary) 26%, var(--ux-border));
    color: var(--ux-primary);
}

.ux-summary-grid,
.return-impact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin: 12px 0 14px;
}

.ux-money-card,
.return-impact-card {
    min-height: 76px;
    padding: 12px;
    border-radius: var(--ux-radius-lg);
    border: 1px solid var(--ux-border-soft);
    background: var(--ux-surface-soft);
}

.ux-money-card span,
.return-impact-card span {
    display: block;
    color: var(--ux-muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.ux-money-card strong,
.return-impact-card strong {
    display: block;
    margin-top: 4px;
    color: var(--ux-heading);
    font-size: 18px;
    line-height: 1.2;
}

.return-impact-card.is-active,
.ux-money-card.is-total {
    background: linear-gradient(135deg, var(--ux-primary-soft), var(--ux-surface));
    border-color: color-mix(in srgb, var(--ux-primary) 28%, var(--ux-border));
}

.ux-money-card.is-hpp {
    background: linear-gradient(135deg, var(--ux-success-soft), var(--ux-surface));
    border-color: color-mix(in srgb, var(--ux-success) 28%, var(--ux-border));
}

.ux-field-hidden {
    display: none !important;
}

.payment-box,
.debt-payment-box {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--ux-border-soft);
    border-radius: var(--ux-radius-lg);
    background: var(--ux-surface-soft);
}

.payment-box .payment-grid,
.debt-payment-box .payment-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(120px, .8fr);
    gap: 8px;
}

.inline-meta,
.table-meta,
.debt-date-meta {
    color: var(--ux-muted);
    font-size: 13px;
    line-height: 1.45;
}

.debt-filter-form {
    grid-template-columns: minmax(220px, 1.4fr) minmax(160px, .8fr) minmax(110px, .45fr) minmax(110px, .45fr);
}

.debt-table-card {
    overflow: auto;
}

.debt-table-card table {
    min-width: 1160px;
}

.debt-due-wrap {
    margin-top: 7px;
}

.debt-due-badge {
    margin-top: 0 !important;
    letter-spacing: .02em;
    white-space: nowrap;
}

.debt-due-badge.is-danger {
    background: var(--ux-danger-soft);
    color: var(--ux-danger);
    border: 1px solid color-mix(in srgb, var(--ux-danger) 28%, var(--ux-border));
}

.debt-due-badge.is-warning {
    background: var(--ux-warning-soft);
    color: var(--ux-warning);
    border: 1px solid color-mix(in srgb, var(--ux-warning) 28%, var(--ux-border));
}

.debt-due-badge.is-safe {
    background: var(--ux-success-soft);
    color: var(--ux-success);
    border: 1px solid color-mix(in srgb, var(--ux-success) 28%, var(--ux-border));
}

.debt-due-badge.is-neutral {
    background: var(--ux-surface-soft);
    color: var(--ux-muted);
    border: 1px solid var(--ux-border);
}

.debt-pay-trigger {
    min-width: 76px;
    margin-right: 6px;
}

.debt-pay-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, .54);
}

.debt-pay-modal-backdrop.show {
    display: flex;
}

.debt-pay-modal {
    width: min(620px, 100%);
    max-height: calc(100vh - 36px);
    overflow: auto;
    border: 1px solid var(--ux-border);
    border-radius: var(--ux-radius-lg);
    background: var(--ux-surface);
    color: var(--ux-text);
    box-shadow: 0 24px 70px rgba(15, 23, 42, .26);
}

.debt-pay-modal-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 12px;
    border-bottom: 1px solid var(--ux-border-soft);
}

.debt-pay-modal-header h3 {
    margin: 0;
    color: var(--ux-heading);
}

.debt-pay-modal-header p {
    margin: 4px 0 0;
    color: var(--ux-muted);
}

.debt-modal-close {
    width: 36px;
    height: 36px;
    border: 1px solid var(--ux-border);
    border-radius: 999px;
    background: var(--ux-surface-soft);
    color: var(--ux-text);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.debt-payment-modal-form {
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 18px;
}

.debt-modal-summary {
    display: grid;
    grid-template-columns: minmax(120px, .65fr) minmax(0, 1fr);
    gap: 8px 12px;
    padding: 12px;
    border: 1px solid var(--ux-border-soft);
    border-radius: var(--ux-radius-lg);
    background: var(--ux-surface-soft);
}

.debt-modal-summary span {
    color: var(--ux-muted);
    font-size: 12px;
    font-weight: 850;
}

.debt-modal-summary strong {
    color: var(--ux-heading);
    text-align: right;
}

.debt-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}

.danger-action,
.btn-danger,
.btn.btn-danger {
    box-shadow: 0 10px 24px rgba(220, 38, 38, .14);
}

.audit-log-page .card:has(table) {
    overflow: auto;
}

.audit-log-page table {
    min-width: 1120px;
}

.audit-log-page .audit-json-cell {
    min-width: 260px;
    max-width: 420px;
}

.audit-log-page details summary {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--ux-primary-soft);
    color: var(--ux-primary);
    border: 1px solid color-mix(in srgb, var(--ux-primary) 24%, var(--ux-border));
}

.audit-log-page pre,
.audit-json,
.log-json {
    max-width: 100% !important;
    background: #0f172a !important;
    color: #e5e7eb !important;
    border: 1px solid #334155 !important;
    border-radius: 12px !important;
    font-size: 12px !important;
    line-height: 1.5 !important;
}

.purchase-direct-page .direct-cost-summary > div,
.purchase-receiving-page .receiving-cost-summary > div {
    background: var(--ux-surface-soft) !important;
    border-color: var(--ux-border-soft) !important;
}

.purchase-direct-page .direct-cost-summary > div:nth-last-child(-n+2),
.purchase-receiving-page .receiving-cost-summary > div:nth-last-child(-n+2) {
    background: linear-gradient(135deg, var(--ux-primary-soft), var(--ux-surface)) !important;
    border-color: color-mix(in srgb, var(--ux-primary) 24%, var(--ux-border)) !important;
}

.purchase-direct-page .direct-cost-summary strong,
.purchase-receiving-page .receiving-cost-summary strong,
.purchase-direct-page .purchase-item-subtotal strong,
.purchase-receiving-page .receiving-total-box strong {
    color: var(--ux-heading) !important;
}

.purchase-receiving-page .receiving-total-box {
    min-width: 176px !important;
    background: var(--ux-surface-soft) !important;
    border-color: var(--ux-border-soft) !important;
    box-shadow: none !important;
}

.purchase-receiving-page .receiving-total-box span {
    color: var(--ux-muted) !important;
}

.purchase-direct-page .po-fast-entry,
.po-professional-page .po-fast-entry {
    align-items: end;
}

.purchase-direct-page .po-selected-product {
    border-style: solid;
}

.stock-page .inventory-card-title h3,
.stock-page .card h3 {
    line-height: 1.25;
}

.stock-page .form-stack .card {
    border-left: 4px solid transparent;
}

.stock-page .form-stack .card:nth-child(1) {
    border-left-color: var(--ux-success);
}

.stock-page .form-stack .card:nth-child(2) {
    border-left-color: var(--ux-danger);
}

.stock-page .form-stack .card:nth-child(3) {
    border-left-color: var(--ux-warning);
}

.permission-toolbar {
    box-shadow: var(--ux-shadow-sm);
}

.permission-card {
    min-width: 0;
}

.permission-code,
.permission-name {
    overflow-wrap: anywhere;
}

.branch-logo-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid var(--ux-border-soft);
    border-radius: var(--ux-radius-lg);
    background: var(--ux-surface-soft);
}

.branch-logo-preview img,
.branch-logo-thumb {
    width: 70px;
    height: 70px;
    object-fit: contain;
    border: 1px solid var(--ux-border);
    border-radius: 12px;
    background: #fff;
    padding: 6px;
}

.branch-logo-thumb {
    width: 42px;
    height: 42px;
    padding: 3px;
}

.inline-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 850;
    color: var(--ux-text);
}

.inline-checkbox input[type="checkbox"] {
    width: auto;
    min-height: auto;
    accent-color: var(--ux-primary);
}

@supports not (color: color-mix(in srgb, #000 50%, #fff)) {
    .ux-note,
    .stock-context-note,
    .cash-impact-note,
    .ux-flow-steps span.is-primary,
    .return-impact-card.is-active,
    .ux-money-card.is-total,
    .purchase-direct-page .direct-cost-summary > div:nth-last-child(-n+2),
    .purchase-receiving-page .receiving-cost-summary > div:nth-last-child(-n+2) {
        border-color: var(--ux-primary);
    }
}

@media (max-width: 1180px) {
    .login-shell {
        max-height: none;
    }

    .debt-filter-form {
        grid-template-columns: 1fr 1fr;
    }

    .payment-box .payment-grid,
    .debt-payment-box .payment-grid {
        grid-template-columns: 1fr;
    }
}

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

    .debt-pay-modal-backdrop {
        align-items: flex-end;
        padding: 0;
    }

    .debt-pay-modal {
        width: 100%;
        max-height: 88vh;
        border-radius: 18px 18px 0 0;
    }

    .debt-modal-summary {
        grid-template-columns: 1fr;
    }

    .debt-modal-summary strong {
        text-align: left;
    }

    .debt-modal-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .ux-flow-steps {
        display: grid;
        grid-template-columns: 1fr;
    }

    .ux-flow-steps span,
    .return-impact-grid,
    .ux-summary-grid {
        width: 100%;
    }
}

body.theme-dark .ux-note,
body.theme-dark .stock-context-note,
body.theme-dark .cash-impact-note,
body.theme-dark .ux-money-card,
body.theme-dark .return-impact-card,
body.theme-dark .payment-box,
body.theme-dark .debt-payment-box,
body.theme-dark .debt-pay-modal,
body.theme-dark .debt-modal-summary,
body.theme-dark .debt-modal-close,
body.theme-dark .purchase-receiving-page .receiving-total-box,
body.theme-dark .purchase-direct-page .direct-cost-summary > div,
body.theme-dark .purchase-receiving-page .receiving-cost-summary > div {
    background: rgba(15, 23, 42, .88) !important;
    border-color: rgba(51, 65, 85, .92) !important;
    color: #dbe7f5 !important;
}

body.theme-dark .debt-pay-modal-header {
    border-color: rgba(71, 85, 105, .86) !important;
}

body.theme-dark .debt-pay-modal-header h3,
body.theme-dark .debt-modal-summary strong,
body.theme-dark .purchase-receiving-page .receiving-total-box strong {
    color: #ffffff !important;
}

body.theme-dark .debt-pay-modal-header p,
body.theme-dark .debt-modal-summary span,
body.theme-dark .purchase-receiving-page .receiving-total-box span {
    color: #a9bed8 !important;
}

body.theme-dark .debt-due-badge.is-danger {
    background: rgba(127, 29, 29, .32) !important;
    border-color: rgba(251, 113, 133, .32) !important;
    color: #fecdd3 !important;
}

body.theme-dark .debt-due-badge.is-warning {
    background: rgba(120, 53, 15, .28) !important;
    border-color: rgba(251, 191, 36, .30) !important;
    color: #fde68a !important;
}

body.theme-dark .debt-due-badge.is-safe {
    background: rgba(6, 78, 59, .30) !important;
    border-color: rgba(52, 211, 153, .30) !important;
    color: #bbf7d0 !important;
}

body.theme-dark .debt-due-badge.is-neutral {
    background: rgba(30, 41, 59, .92) !important;
    border-color: rgba(71, 85, 105, .86) !important;
    color: #cbd5e1 !important;
}

body.theme-dark .ux-warning,
body.theme-dark .opname-impact-note,
body.theme-dark .return-impact-note {
    background: rgba(120, 53, 15, .28) !important;
    border-color: rgba(251, 191, 36, .30) !important;
    color: #fde68a !important;
}

body.theme-dark .ux-danger-note {
    background: rgba(127, 29, 29, .32) !important;
    border-color: rgba(251, 113, 133, .32) !important;
    color: #fecdd3 !important;
}

body.theme-dark .ux-note strong,
body.theme-dark .ux-warning strong,
body.theme-dark .ux-danger-note strong,
body.theme-dark .stock-context-note strong,
body.theme-dark .opname-impact-note strong,
body.theme-dark .return-impact-note strong,
body.theme-dark .cash-impact-note strong,
body.theme-dark .ux-money-card strong,
body.theme-dark .return-impact-card strong {
    color: #ffffff !important;
}

body.theme-dark .ux-flow-steps span,
body.theme-dark .return-impact-card.is-active,
body.theme-dark .ux-money-card.is-total,
body.theme-dark .ux-money-card.is-hpp,
body.theme-dark .purchase-direct-page .direct-cost-summary > div:nth-last-child(-n+2),
body.theme-dark .purchase-receiving-page .receiving-cost-summary > div:nth-last-child(-n+2) {
    background: rgba(30, 41, 59, .92) !important;
    border-color: rgba(96, 165, 250, .30) !important;
    color: #dbeafe !important;
}

body.theme-dark .audit-log-page details summary {
    background: rgba(30, 41, 59, .92) !important;
    border-color: rgba(96, 165, 250, .30) !important;
    color: #bfdbfe !important;
}

body.theme-dark .audit-log-page pre,
body.theme-dark .audit-json,
body.theme-dark .log-json {
    background: #020617 !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

body.theme-dark .branch-logo-preview {
    background: rgba(30, 41, 59, .72) !important;
    border-color: rgba(71, 85, 105, .86) !important;
}

/* Kasir popup keyboard active row - soft dark-mode fix 20260602
   Tetap jelas untuk navigasi keyboard, tapi tidak terlalu menyala. */
body.theme-dark #modalProductResults .search-result.search-result-active,
body.theme-dark #modalCustomerResults .search-result.search-result-active,
body.theme-dark #modalProductResults .search-result[aria-selected="true"],
body.theme-dark #modalCustomerResults .search-result[aria-selected="true"] {
    position: relative !important;
    background: rgba(37, 99, 235, .24) !important;
    background-image: linear-gradient(135deg, rgba(30, 64, 175, .42) 0%, rgba(124, 58, 237, .28) 100%) !important;
    border: 2px solid rgba(147, 197, 253, .86) !important;
    color: #f8fafc !important;
    box-shadow:
        0 0 0 1px rgba(147, 197, 253, .22),
        0 10px 24px rgba(15, 23, 42, .38),
        inset 4px 0 0 rgba(251, 191, 36, .86) !important;
    transform: translateY(-1px) !important;
    z-index: 5 !important;
}

body.theme-dark #modalProductResults .search-result.search-result-active::before,
body.theme-dark #modalCustomerResults .search-result.search-result-active::before,
body.theme-dark #modalProductResults .search-result[aria-selected="true"]::before,
body.theme-dark #modalCustomerResults .search-result[aria-selected="true"]::before {
    content: "" !important;
    position: absolute !important;
    left: 0 !important;
    top: 10px !important;
    bottom: 10px !important;
    width: 4px !important;
    height: auto !important;
    min-width: 0 !important;
    padding: 0 !important;
    border-radius: 0 999px 999px 0 !important;
    background: #fbbf24 !important;
    box-shadow: 0 0 12px rgba(251, 191, 36, .38) !important;
    transform: none !important;
}

body.theme-dark #modalProductResults .search-result.search-result-active > div,
body.theme-dark #modalCustomerResults .search-result.search-result-active > div,
body.theme-dark #modalProductResults .search-result[aria-selected="true"] > div,
body.theme-dark #modalCustomerResults .search-result[aria-selected="true"] > div {
    padding-left: 12px !important;
}

body.theme-dark #modalProductResults .search-result.search-result-active .result-title,
body.theme-dark #modalCustomerResults .search-result.search-result-active .result-title,
body.theme-dark #modalProductResults .search-result[aria-selected="true"] .result-title,
body.theme-dark #modalCustomerResults .search-result[aria-selected="true"] .result-title {
    color: #ffffff !important;
    font-weight: 900 !important;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .28) !important;
}

body.theme-dark #modalProductResults .search-result.search-result-active .result-meta,
body.theme-dark #modalCustomerResults .search-result.search-result-active .result-meta,
body.theme-dark #modalProductResults .search-result[aria-selected="true"] .result-meta,
body.theme-dark #modalCustomerResults .search-result[aria-selected="true"] .result-meta {
    color: #dbeafe !important;
    font-weight: 700 !important;
}

body.theme-dark #modalProductResults .search-result.search-result-active .btn,
body.theme-dark #modalCustomerResults .search-result.search-result-active .btn,
body.theme-dark #modalProductResults .search-result[aria-selected="true"] .btn,
body.theme-dark #modalCustomerResults .search-result[aria-selected="true"] .btn {
    background: rgba(96, 165, 250, .22) !important;
    border: 1px solid rgba(147, 197, 253, .72) !important;
    color: #eff6ff !important;
    box-shadow: none !important;
}

body.theme-dark #modalProductResults .search-result:not(.search-result-active):not([aria-selected="true"]),
body.theme-dark #modalCustomerResults .search-result:not(.search-result-active):not([aria-selected="true"]) {
    background: rgba(15, 23, 42, .82) !important;
    border-color: rgba(51, 65, 85, .95) !important;
}

/* 20260603 - Full app readability pass.
   Visual-only layer: compact lists, clearer actions, safer print defaults. */
body:not(.pos-page) {
    text-rendering: optimizeLegibility;
}

.container,
.page-container {
    width: min(100% - 28px, 1360px);
}

.page-header {
    gap: 14px;
    margin-bottom: 16px;
}

.page-header h1,
.page-header h2 {
    line-height: 1.18;
    letter-spacing: 0;
}

.page-header p,
.page-subtitle,
.muted,
.hint,
.form-help {
    line-height: 1.48;
}

.page-actions,
.form-actions,
.actions,
.debt-success-actions,
.purchase-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.btn,
button.btn,
a.btn,
input[type="submit"].btn {
    align-items: center;
    justify-content: center;
    min-height: 36px;
    line-height: 1.15;
    white-space: nowrap;
}

.btn-sm,
.btn-small,
.btn-tiny,
.btn-xs,
td .btn,
.actions .btn,
.inline-form .btn {
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 9px;
    font-size: 12px;
}

td .actions,
td .inline-form,
.action-cell,
.debt-action-group {
    gap: 6px;
}

td .inline-form {
    display: inline-flex;
    margin: 0;
    vertical-align: middle;
}

.filter-form,
.compact-filter-form,
.master-toolbar,
.filter-bar {
    align-items: end;
    gap: 10px;
}

.filter-form .form-group,
.compact-filter-form .form-group,
.master-toolbar .form-group,
.filter-bar .form-group {
    min-width: 0;
}

.filter-form input,
.filter-form select,
.filter-form button,
.filter-bar input,
.filter-bar select,
.master-toolbar input,
.master-toolbar select {
    min-height: 38px;
}

input,
select,
textarea {
    line-height: 1.35;
}

label {
    line-height: 1.35;
}

.form-grid,
.form-grid-2,
.form-grid-3 {
    gap: 12px;
}

.form-group {
    min-width: 0;
}

.form-group label {
    margin-bottom: 5px;
}

textarea {
    min-height: 78px;
    resize: vertical;
}

.card,
.summary-card,
.kpi-card,
.quick-card,
.mini-card {
    min-width: 0;
}

.summary-grid {
    gap: 12px;
}

.summary-card {
    min-height: 86px;
}

.summary-title {
    letter-spacing: .02em;
}

.summary-value,
.kpi-value,
.month-summary strong {
    line-height: 1.16;
    font-variant-numeric: tabular-nums;
}

.dashboard-page .kpi-grid {
    gap: 12px;
}

.dashboard-page .kpi-card,
.dashboard-page .dashboard-shift-card {
    border-radius: 14px;
}

.dashboard-page .quick-grid {
    gap: 10px;
}

.dashboard-page .quick-card {
    min-height: 72px;
}

.table-wrap,
.table-responsive,
.debt-table-card,
.price-level-table-wrap,
.dashboard-table-wrap {
    scrollbar-gutter: stable;
}

table {
    font-variant-numeric: tabular-nums;
}

th {
    letter-spacing: .015em;
}

td,
th {
    overflow-wrap: anywhere;
}

td.text-right,
th.text-right,
td.amount,
td.money,
td[class*="amount"],
td[class*="total"],
td[class*="price"],
td[class*="saldo"],
td[class*="nominal"] {
    text-align: right;
    white-space: nowrap;
}

.table-link,
table a:not(.btn) {
    font-weight: 800;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.badge,
[class*="status-"],
.role-access-badge,
.override-badge {
    line-height: 1.15;
    white-space: nowrap;
}

.empty-state,
.empty-cell {
    color: var(--ux-muted);
    line-height: 1.5;
}

.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 32px;
    padding: 5px 9px;
    border-radius: 9px;
    text-decoration: none;
    font-weight: 800;
}

.page-link.btn-disabled {
    opacity: .52;
    cursor: not-allowed;
}

.active-page,
.page-link.active-page {
    background: var(--ux-primary) !important;
    color: #fff !important;
    border-color: var(--ux-primary) !important;
}

.permission-toolbar {
    position: sticky;
    top: 74px;
    z-index: 20;
}

.permission-list {
    gap: 10px;
}

.permission-card {
    border-radius: 12px;
}

.po-professional-page .po-product-results {
    scroll-behavior: smooth;
}

.po-professional-page .po-result-item.active,
.po-professional-page .po-result-item[aria-selected="true"],
.po-professional-page .po-result-item.po-result-item-compact.active {
    position: relative;
    background: linear-gradient(135deg, rgba(37, 99, 235, .13), rgba(99, 102, 241, .08)) !important;
    border-color: rgba(37, 99, 235, .46) !important;
    box-shadow:
        inset 4px 0 0 rgba(37, 99, 235, .95),
        0 8px 18px rgba(37, 99, 235, .12) !important;
    transform: translateY(-1px);
}

.po-professional-page .po-result-item.active .po-result-name,
.po-professional-page .po-result-item[aria-selected="true"] .po-result-name {
    color: #1d4ed8 !important;
    font-weight: 900;
}

.po-professional-page .po-result-item.active .po-result-meta,
.po-professional-page .po-result-item[aria-selected="true"] .po-result-meta {
    color: #334155 !important;
    font-weight: 750;
}

body.theme-dark .table-link,
body.theme-dark table a:not(.btn) {
    color: #bfdbfe;
}

body.theme-dark .page-link {
    background: rgba(15, 23, 42, .82);
    border-color: rgba(71, 85, 105, .78);
    color: #dbeafe;
}

body.theme-dark .page-link.btn-disabled {
    color: #94a3b8;
}

body.theme-dark .active-page,
body.theme-dark .page-link.active-page {
    background: #3b82f6 !important;
    border-color: #60a5fa !important;
    color: #fff !important;
}

body.theme-dark .po-professional-page .po-result-item.active,
body.theme-dark .po-professional-page .po-result-item[aria-selected="true"],
body.theme-dark .po-professional-page .po-result-item.po-result-item-compact.active,
body.theme-dark.po-professional-page .po-result-item.active,
body.theme-dark.po-professional-page .po-result-item[aria-selected="true"],
body.theme-dark.po-professional-page .po-result-item.po-result-item-compact.active {
    background: linear-gradient(135deg, rgba(37, 99, 235, .40), rgba(79, 70, 229, .32)) !important;
    border-color: rgba(147, 197, 253, .82) !important;
    color: #f8fafc !important;
    box-shadow:
        inset 4px 0 0 rgba(251, 191, 36, .95),
        0 10px 24px rgba(15, 23, 42, .38) !important;
}

body.theme-dark .po-professional-page .po-result-item.active .po-result-name,
body.theme-dark .po-professional-page .po-result-item[aria-selected="true"] .po-result-name,
body.theme-dark.po-professional-page .po-result-item.active .po-result-name,
body.theme-dark.po-professional-page .po-result-item[aria-selected="true"] .po-result-name {
    color: #ffffff !important;
}

body.theme-dark .po-professional-page .po-result-item.active .po-result-meta,
body.theme-dark .po-professional-page .po-result-item[aria-selected="true"] .po-result-meta,
body.theme-dark.po-professional-page .po-result-item.active .po-result-meta,
body.theme-dark.po-professional-page .po-result-item[aria-selected="true"] .po-result-meta {
    color: #dbeafe !important;
}

@media (max-width: 980px) {
    .container,
    .page-container {
        width: min(100% - 20px, 100%);
    }

    .page-header,
    .pagination-bar {
        align-items: stretch;
    }

    .page-actions,
    .form-actions,
    .actions {
        width: 100%;
    }

    .filter-form,
    .compact-filter-form,
    .master-toolbar,
    .filter-bar {
        grid-template-columns: 1fr 1fr !important;
    }
}

@media (max-width: 640px) {
    .filter-form,
    .compact-filter-form,
    .master-toolbar,
    .filter-bar,
    .pagination-bar {
        grid-template-columns: 1fr !important;
        flex-direction: column;
    }

    .btn,
    button.btn,
    a.btn,
    input[type="submit"].btn {
        width: 100%;
    }

    td .btn,
    .actions .btn,
    .inline-form .btn {
        width: auto;
    }

    .pagination {
        width: 100%;
    }

    .page-link {
        flex: 1 1 auto;
    }
}

@media print {
    @page {
        margin: 10mm;
    }

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

    .app-navbar,
    .print-toolbar,
    .screen-actions,
    .no-print,
    .theme-toggle-btn,
    .mobile-menu-label,
    .mobile-menu-toggle,
    .page-actions,
    .form-actions,
    .filter-form,
    .filter-bar,
    .master-toolbar,
    .pagination-bar,
    button,
    .btn {
        display: none !important;
    }

    .container,
    .page-container,
    .card,
    .summary-card,
    .table-wrap,
    .table-responsive {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        box-shadow: none !important;
        background: #fff !important;
        color: #111827 !important;
    }

    .card,
    .summary-card {
        border: 1px solid #d1d5db !important;
        break-inside: avoid;
    }

    table {
        width: 100% !important;
        border-collapse: collapse !important;
        page-break-inside: auto;
    }

    thead {
        display: table-header-group;
    }

    tfoot {
        display: table-footer-group;
    }

    tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    th,
    td {
        color: #111827 !important;
        border-color: #d1d5db !important;
        background: #fff !important;
    }

    th {
        background: #f3f4f6 !important;
        font-weight: 800 !important;
    }

    a {
        color: #111827 !important;
        text-decoration: none !important;
    }
}


/* 20260602 - Form entry UX helpers */
.ux-field-attention {
    outline: 3px solid rgba(59, 130, 246, .32) !important;
    box-shadow: 0 0 0 5px rgba(59, 130, 246, .12) !important;
    border-color: rgba(59, 130, 246, .85) !important;
    transition: outline .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.theme-dark .ux-field-attention {
    outline-color: rgba(125, 164, 255, .42) !important;
    box-shadow: 0 0 0 5px rgba(125, 164, 255, .16) !important;
    border-color: rgba(147, 197, 253, .95) !important;
}
.ux-danger-note {
    border: 1px solid rgba(239, 68, 68, .28);
    background: rgba(239, 68, 68, .08);
    color: #991b1b;
    border-radius: 14px;
    padding: 12px 14px;
    margin: 12px 0;
    display: grid;
    gap: 4px;
}
.theme-dark .ux-danger-note {
    color: #fecaca;
    background: rgba(239, 68, 68, .12);
    border-color: rgba(248, 113, 113, .32);
}

/* 20260602 - Hutang supplier status tabs + payment print UX */
.debt-status-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0 12px;
}
.debt-status-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, .35);
    background: rgba(248, 250, 252, .92);
    color: #334155;
    font-weight: 800;
    text-decoration: none;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .05);
}
.debt-status-tab:hover,
.debt-status-tab.active {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    border-color: rgba(37, 99, 235, .72);
    color: #fff;
    box-shadow: 0 12px 24px rgba(37, 99, 235, .18);
}
.debt-success-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.debt-print-link {
    margin-top: 4px;
}
.btn-xs {
    min-height: 26px;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 12px;
}
.theme-dark .debt-status-tab,
body.theme-dark .debt-status-tab {
    background: rgba(15, 23, 42, .88);
    border-color: rgba(71, 85, 105, .8);
    color: #cbd5e1;
    box-shadow: 0 10px 22px rgba(0, 0, 0, .2);
}
.theme-dark .debt-status-tab:hover,
.theme-dark .debt-status-tab.active,
body.theme-dark .debt-status-tab:hover,
body.theme-dark .debt-status-tab.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, .95), rgba(99, 102, 241, .95));
    border-color: rgba(147, 197, 253, .65);
    color: #fff;
    box-shadow: 0 14px 30px rgba(37, 99, 235, .26);
}

/* 20260602 - Hutang supplier action cell + sort polish */
.debt-filter-form {
    grid-template-columns: minmax(220px, 1.35fr) minmax(150px, .75fr) minmax(190px, .9fr) minmax(92px, .42fr) minmax(92px, .42fr);
    align-items: end;
}
.debt-action-cell {
    min-width: 150px;
    width: 150px;
}
.debt-action-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    max-width: 150px;
}
.debt-action-group .btn,
.debt-action-group button.btn {
    min-width: 66px;
    min-height: 32px;
    padding: 6px 10px;
    margin: 0 !important;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.15;
    white-space: nowrap;
}
.debt-action-group .btn-success {
    flex: 1 1 100%;
}
.debt-action-muted {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    font-size: 12px;
}
.debt-payment-success {
    scroll-margin-top: 92px;
}
@media (max-width: 1180px) {
    .debt-filter-form {
        grid-template-columns: 1fr 1fr;
    }
}
@media (max-width: 720px) {
    .debt-filter-form {
        grid-template-columns: 1fr;
    }
    .debt-action-cell {
        min-width: 130px;
        width: 130px;
    }
    .debt-action-group {
        max-width: 130px;
    }
}
.debt-row-highlight {
    outline: 2px solid rgba(59, 130, 246, .55);
    box-shadow: inset 4px 0 0 rgba(59, 130, 246, .85);
    background: rgba(59, 130, 246, .06) !important;
}
.return-row-highlight {
    outline: 2px solid rgba(5, 150, 105, .55);
    box-shadow: inset 4px 0 0 rgba(5, 150, 105, .85);
    background: rgba(5, 150, 105, .07) !important;
}
.theme-dark .debt-row-highlight,
body.theme-dark .debt-row-highlight {
    outline-color: rgba(96, 165, 250, .58);
    box-shadow: inset 4px 0 0 rgba(96, 165, 250, .95);
    background: rgba(59, 130, 246, .13) !important;
}
.theme-dark .return-row-highlight,
body.theme-dark .return-row-highlight {
    outline-color: rgba(52, 211, 153, .58);
    box-shadow: inset 4px 0 0 rgba(52, 211, 153, .95);
    background: rgba(16, 185, 129, .13) !important;
}

/* Global flash modal - v22: action result popup without changing backend logic */
.global-flash-modal {
    position: fixed;
    inset: 0;
    z-index: 9998;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(2, 6, 23, .58);
    backdrop-filter: blur(5px);
}
.global-flash-modal.is-open { display: flex; }
.global-flash-dialog {
    width: min(560px, 100%);
    display: grid;
    grid-template-columns: 54px 1fr;
    gap: 16px;
    padding: 22px;
    border-radius: 22px;
    background: var(--surface, #ffffff);
    color: var(--text, #0f172a);
    border: 1px solid var(--border, rgba(148, 163, 184, .32));
    box-shadow: 0 28px 70px rgba(2, 6, 23, .35);
}
.theme-dark .global-flash-dialog,
body.theme-dark .global-flash-dialog {
    background: #0f172a;
    color: #e5e7eb;
    border-color: rgba(148, 163, 184, .35);
}
.global-flash-icon {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 28px;
    background: rgba(59, 130, 246, .14);
    color: #2563eb;
}
.global-flash-modal[data-type="success"] .global-flash-icon {
    background: rgba(34, 197, 94, .16);
    color: #16a34a;
}
.global-flash-modal[data-type="error"] .global-flash-icon {
    background: rgba(239, 68, 68, .16);
    color: #ef4444;
}
.global-flash-content h3 {
    margin: 0 0 8px;
    font-size: 20px;
    line-height: 1.25;
    letter-spacing: .01em;
}
.global-flash-body {
    color: var(--muted, #475569);
    line-height: 1.65;
    font-size: 15px;
    white-space: pre-line;
}
.theme-dark .global-flash-body,
body.theme-dark .global-flash-body { color: #cbd5e1; }
.global-flash-hint {
    margin: 12px 0 0;
    font-size: 13px;
    color: var(--muted, #64748b);
}
.theme-dark .global-flash-hint,
body.theme-dark .global-flash-hint { color: #94a3b8; }

/* Report screen header must stay readable over the dark report banner in both themes. */
@media screen {
    body.report-page .page-header h1,
    body.report-page .page-header h2,
    body.finance-report-page .page-header h1,
    body.finance-report-page .page-header h2 {
        color: #ffffff !important;
    }
}
.global-flash-actions {
    grid-column: 2;
    display: flex;
    justify-content: flex-end;
    margin-top: 2px;
}
.global-flash-actions .btn {
    min-width: 150px;
    justify-content: center;
}
.global-flash-source-highlight {
    outline: 3px solid rgba(59, 130, 246, .35);
    box-shadow: 0 0 0 6px rgba(59, 130, 246, .12);
}
@media (max-width: 640px) {
    .global-flash-dialog {
        grid-template-columns: 1fr;
    }
    .global-flash-actions {
        grid-column: 1;
    }
}

/* 20260605 - Responsive navbar hardening for WebView/small monitors.
   Keep desktop behavior above 1180px. Below that, use hamburger + click dropdown,
   not hover/fixed dropdown overlays that can block other menus. */
@media screen and (max-width: 1180px) {
    .app-navbar {
        z-index: 1200;
    }

    .app-navbar-inner {
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 10px !important;
        padding: 10px 14px !important;
    }

    .app-brand {
        min-width: 0 !important;
        flex: 0 0 auto !important;
    }

    .app-brand-logo {
        max-width: 138px !important;
        height: auto !important;
    }

    .mobile-menu-label {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin-left: auto !important;
        color: #fff !important;
        background: rgba(255,255,255,.12) !important;
        border: 1px solid rgba(255,255,255,.14) !important;
        padding: 9px 13px !important;
        border-radius: 12px !important;
        cursor: pointer !important;
        font-size: 13px !important;
        font-weight: 900 !important;
        line-height: 1 !important;
        min-height: 40px !important;
    }

    .mobile-menu-toggle {
        position: absolute !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    .app-nav-main,
    .app-nav-right {
        display: none !important;
        flex: 0 0 100% !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    .mobile-menu-toggle:checked ~ .app-nav-main {
        display: flex !important;
        order: 3 !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        overflow: visible !important;
        padding: 8px 0 0 !important;
    }

    .mobile-menu-toggle:checked ~ .app-nav-right {
        display: flex !important;
        order: 4 !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        gap: 8px !important;
        flex-wrap: wrap !important;
        padding-top: 4px !important;
    }

    .app-nav-link,
    .app-nav-trigger {
        width: 100% !important;
        justify-content: flex-start !important;
        background: rgba(255,255,255,.08) !important;
        min-height: 42px !important;
    }

    .app-nav-group {
        width: 100% !important;
        position: relative !important;
    }

    .app-dropdown,
    .app-dropdown-wide,
    .app-dropdown-ops,
    .app-dropdown-master,
    .app-dropdown-report {
        position: static !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: min(64vh, 520px) !important;
        overflow-y: auto !important;
        display: none !important;
        grid-template-columns: 1fr !important;
        margin-top: 8px !important;
        border-radius: 14px !important;
        box-shadow: none !important;
        z-index: auto !important;
    }

    .app-nav-group:hover .app-dropdown,
    .app-nav-group:focus-within .app-dropdown,
    .app-nav-group:hover .app-dropdown-wide,
    .app-nav-group:focus-within .app-dropdown-wide {
        display: none !important;
    }

    .app-nav-group.is-open > .app-dropdown,
    .app-nav-group.is-open > .app-dropdown-wide {
        display: block !important;
    }

    .app-nav-group.is-open > .app-dropdown-ops,
    .app-nav-group.is-open > .app-dropdown-master,
    .app-nav-group.is-open > .app-dropdown-report {
        display: block !important;
    }

    .app-dropdown-column {
        min-width: 0 !important;
    }

    .app-nav-right .theme-toggle-btn,
    .app-nav-right .branch-pill,
    .app-nav-right .user-menu,
    .app-nav-right .user-button {
        width: auto !important;
        max-width: 100% !important;
    }

    .user-dropdown {
        position: static !important;
        width: 100% !important;
        margin-top: 8px !important;
        box-shadow: none !important;
    }
}

@media screen and (max-width: 760px) {
    .app-navbar-inner {
        padding: 9px 10px !important;
    }

    .app-brand-logo {
        max-width: 112px !important;
    }

    .mobile-menu-toggle:checked ~ .app-nav-right .theme-toggle-btn,
    .mobile-menu-toggle:checked ~ .app-nav-right .branch-pill,
    .mobile-menu-toggle:checked ~ .app-nav-right .user-menu,
    .mobile-menu-toggle:checked ~ .app-nav-right .user-button {
        width: 100% !important;
    }

    .app-dropdown a {
        padding: 10px 10px !important;
    }
}

/* Final report screen header guard: loaded last, wins over generic page-header polish. */
@media screen {
    body.report-page .page-header h1,
    body.report-page .page-header h2,
    body.finance-report-page .page-header h1,
    body.finance-report-page .page-header h2 {
        color: #ffffff !important;
    }
}
