/*
 * NidhiBook clean UI layer.
 * Presentation-only overrides: existing classes, IDs and event hooks remain intact.
 */
:root {
    --nidhi-clean-primary: #f26522;
    --nidhi-clean-primary-hover: #d9551a;
    --nidhi-clean-primary-soft: #fff4ef;
    --nidhi-clean-primary-border: #fdc9b0;
    --nidhi-clean-primary-muted-text: #9a3412;
    --nidhi-clean-primary-rgb: 242, 101, 34;
    --nidhi-accent-dial: #c2410c;
    --nidhi-accent-second: #2563eb;
    --nidhi-clean-success: #15803d;
    --nidhi-clean-danger: #b91c1c;
    --nidhi-clean-info: #0369a1;
    --nidhi-clean-surface: #ffffff;
    /* Surface wash (backgrounds only) — never use for text color */
    --nidhi-clean-muted: #f8fafc;
    /* Readable secondary / hint text on light surfaces */
    --nidhi-clean-muted-text: #475569;
    --nidhi-clean-text: #0f172a;
    --nidhi-clean-border: #e2e8f0;
    --nidhi-brand: #f26522;
    /* Follows accent; remapped in nidhi-accents.css per data-accent */
    --nidhi-brand-section: var(--nidhi-clean-primary);
    --nidhi-brand-purple: #6a1f8e;
    --nidhi-chrome: #2563eb;
}

/*
 * Light-mode readability (app-wide).
 * - Legacy .text-muted is #cbd2dc (invisible on white).
 * - Some pages used --nidhi-clean-muted (a surface) as text color.
 * - Form controls must keep dark ink in light mode.
 */
html:not([data-theme="dark"]) .text-muted,
html:not([data-theme="dark"]) small.text-muted,
html:not([data-theme="dark"]) .small.text-muted,
html[data-theme="light"] .text-muted,
html[data-theme="light"] small.text-muted,
html[data-theme="light"] .small.text-muted {
    color: var(--nidhi-clean-muted-text, #475569) !important;
}

html:not([data-theme="dark"]) #app,
html:not([data-theme="dark"]) #app .card,
html:not([data-theme="dark"]) #app .card-body {
    color: var(--nidhi-clean-text, #334155);
}

/* Keep Font Awesome glyphs visible inside #app (SPA-injected fragments) */
#app .fa,
.module-cards-container .fa,
.nidhi-nav-icon .fa,
.nidhi-sidebar .fa {
    font-family: 'FontAwesome' !important;
    font-style: normal;
    font-weight: normal;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html:not([data-theme="dark"]) #app .form-control,
html:not([data-theme="dark"]) #app select.form-control,
html:not([data-theme="dark"]) #app textarea.form-control,
html:not([data-theme="dark"]) #app input.form-control,
html:not([data-theme="dark"]) #app select,
html:not([data-theme="dark"]) #app textarea,
html:not([data-theme="dark"]) #app input[type="text"],
html:not([data-theme="dark"]) #app input[type="number"],
html:not([data-theme="dark"]) #app input[type="email"],
html:not([data-theme="dark"]) #app input[type="password"],
html:not([data-theme="dark"]) #app input[type="date"],
html:not([data-theme="dark"]) #app input[type="search"],
html:not([data-theme="dark"]) #app input[type="tel"] {
    color: #0f172a !important;
    background-color: #ffffff !important;
    border-color: #cbd5e1 !important;
}

html:not([data-theme="dark"]) #app .form-control::placeholder,
html:not([data-theme="dark"]) #app input::placeholder,
html:not([data-theme="dark"]) #app textarea::placeholder {
    color: #64748b !important;
    opacity: 1;
}

html:not([data-theme="dark"]) #app .custom-control-label,
html:not([data-theme="dark"]) #app label {
    color: var(--nidhi-clean-text, #334155);
}

html:not([data-theme="dark"]) #app .select2-container--default .select2-selection--single .select2-selection__rendered,
html:not([data-theme="dark"]) #app .select2-container--default .select2-selection--multiple .select2-selection__choice {
    color: #0f172a !important;
}

html:not([data-theme="dark"]) #app .select2-container--default .select2-selection--single,
html:not([data-theme="dark"]) #app .select2-container--default .select2-selection--multiple {
    background-color: #ffffff !important;
    border-color: #cbd5e1 !important;
}

/*
 * Legacy assets/css/style.css sets `.alert-info { color:#81BECE; background:#9eecff }`
 * — nearly invisible. Restore readable alert text (same for warning/success/danger if washed out).
 */
.alert-info {
    color: #0c4a6e !important;
    background-color: #e0f2fe !important;
    border-color: #7dd3fc !important;
}
.alert-warning {
    color: #713f12 !important;
    background-color: #fef3c7 !important;
    border-color: #fcd34d !important;
}
.alert-success {
    color: #14532d !important;
    background-color: #dcfce7 !important;
    border-color: #86efac !important;
}
.alert-danger {
    color: #7f1d1d !important;
    background-color: #fee2e2 !important;
    border-color: #fca5a5 !important;
}
.alert-light {
    color: #334155 !important;
    background-color: #f8fafc !important;
    border-color: #e2e8f0 !important;
}

/*
 * More legacy low-contrast classes from style.css (same root cause as alert-info).
 */
.list-group-item-info {
    color: #0c4a6e !important;
    background-color: #e0f2fe !important;
}
.list-group-item-info.list-group-item-action:hover,
.list-group-item-info.list-group-item-action:focus {
    color: #0c4a6e !important;
    background-color: #bae6fd !important;
}
.list-group-item-info.list-group-item-action.active {
    color: #ffffff !important;
    background-color: #0369a1 !important;
    border-color: #0369a1 !important;
}

.tag-white {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1;
}
.tag-light {
    background-color: #f1f5f9 !important;
    color: #334155 !important;
    border: 1px solid #e2e8f0;
}
.tag-success,
.tag-green,
.badge-success {
    color: #14532d !important;
    background-color: #bbf7d0 !important;
}
.tag-warning,
.tag-yellow,
.badge-warning {
    color: #713f12 !important;
    background-color: #fde68a !important;
}
.bg-yellow {
    background-color: #fbbf24 !important;
    color: #1e293b !important;
}
.bg-green {
    background-color: #34d399 !important;
    color: #064e3b !important;
}

.selectgroup-button {
    color: #334155 !important;
}
html:not([data-theme="dark"]) .selectgroup-input:checked + .selectgroup-button {
    color: #0f172a !important;
}

/* Accent body text — mint/yellow were too light on white */
html:not([data-theme="dark"]) .text-success,
html:not([data-theme="dark"]) .text-green {
    color: #15803d !important;
}
html:not([data-theme="dark"]) .text-yellow {
    color: #a16207 !important;
}
html:not([data-theme="dark"]) .text-warning {
    color: #b45309 !important;
}

/* Placeholders outside #app (login, print popups, standalone forms) */
html:not([data-theme="dark"]) .form-control::placeholder,
html:not([data-theme="dark"]) input::placeholder,
html:not([data-theme="dark"]) textarea::placeholder {
    color: #64748b !important;
    opacity: 1;
}

/*
 * Legacy Bootstrap/style.css set kbd { color:#fff; background:#343a40 }.
 * Light chips need dark ink — also covers Settings Shortcut table.
 */
#app kbd,
.nidhi-shortcuts-overlay kbd,
.master-settings-page kbd,
.nidhi-sc-key {
    color: #0f172a !important;
    -webkit-text-fill-color: #0f172a !important;
    background: #e2e8f0 !important;
    background-color: #e2e8f0 !important;
    border: 1px solid #94a3b8;
    border-radius: 6px;
    font-weight: 700;
}
html[data-theme="dark"] #app kbd,
html[data-theme="dark"] .nidhi-shortcuts-overlay kbd,
html[data-theme="dark"] .master-settings-page kbd,
html[data-theme="dark"] .nidhi-sc-key {
    color: #f8fafc !important;
    -webkit-text-fill-color: #f8fafc !important;
    background: #334155 !important;
    background-color: #334155 !important;
    border-color: #64748b;
}

/*
 * Legacy assets/css/style.css sets `.bg-light { color:#fff !important }` which
 * makes table body / filter text invisible on light surfaces. Restore readable text.
 */
.bg-light {
    color: var(--nidhi-clean-text, #334155) !important;
}
.bg-light .form-control,
.bg-light select.form-control,
.bg-light input.form-control {
    color: var(--nidhi-clean-text, #0f172a) !important;
}
.table.bg-light tbody td,
.table.bg-light tbody th,
table.bg-light tbody td,
table.bg-light tbody th {
    color: var(--nidhi-clean-text, #0f172a) !important;
}

/* Buttons must keep white label text even inside .text-dark / .bg-light parents */
.btn-primary,
.btn-success,
.btn-danger,
.btn-info,
.btn-secondary,
.btn-dark,
a.btn-primary,
a.btn-success,
a.btn-danger,
a.btn-info,
.text-dark .btn-primary,
.text-dark .btn-success,
.text-dark .btn-danger,
.text-dark .btn-info,
.bg-light .btn-primary,
.bg-light .btn-success,
.bg-light .btn-danger,
.bg-light .btn-info {
    color: #ffffff !important;
}
.btn-warning,
a.btn-warning,
.text-dark .btn-warning,
.bg-light .btn-warning {
    color: #1e293b !important;
}

/* Preserve transparent logo artwork while making it readable on dark surfaces. */
html[data-theme="dark"] .header-brand-img.main-logo,
html[data-theme="dark"] .header-brand-img.icon-logo {
    filter: brightness(0) invert(1) drop-shadow(0 2px 5px rgba(0, 0, 0, .22)) !important;
}

/* Header brand: left-aligned logo/avatar + NidhiBook badge. */
.app-header .header-brand {
    display: inline-flex !important;
    align-items: center;
    justify-content: flex-start !important;
    gap: 10px;
    min-width: 0 !important;
    text-align: left !important;
}

.app-header .header-brand .header-brand-img.main-logo {
    height: 40px !important;
    width: auto !important;
    max-width: 120px;
    margin: 0 !important;
    object-fit: contain;
}

.app-header .header-brand .header-brand-img.company-logo-avatar {
    width: 40px !important;
    height: 40px !important;
    max-width: 40px !important;
    margin: 0 !important;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #dbe3ee;
    background: #ffffff;
    flex-shrink: 0;
}

.app-header .header-brand .nidhi-brand-badge {
    display: inline-flex;
    overflow: hidden;
    border-radius: 4px;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    line-height: 20px;
    margin: 0;
}

.app-header .header-brand .nidhi-brand-badge__nidhi {
    padding: 0 4px;
    background: #f26522;
}

.app-header .header-brand .nidhi-brand-badge__book {
    padding: 0 4px;
    background: #6a1f8e;
}

html[data-theme="dark"] .app-header .header-brand .header-brand-img.company-logo-avatar {
    filter: none !important;
    border-color: #475569;
    background: #1e293b;
}

/* Replace legacy gradients with restrained solid semantic colors. */
.bg-gradient-primary {
    background-color: var(--nidhi-clean-primary) !important;
    background-image: none !important;
    color: #ffffff !important;
}

.bg-gradient-info {
    background-color: var(--nidhi-clean-info) !important;
    background-image: none !important;
    color: #ffffff !important;
}

.bg-gradient-success {
    background-color: var(--nidhi-clean-success) !important;
    background-image: none !important;
    color: #ffffff !important;
}

.bg-gradient-danger {
    background-color: var(--nidhi-clean-danger) !important;
    background-image: none !important;
    color: #ffffff !important;
}

.bg-gradient-secondary {
    background-color: #475569 !important;
    background-image: none !important;
    color: #ffffff !important;
}

/* Warning is used heavily for page headings and secondary actions. */
.bg-gradient-warning {
    background-color: var(--nidhi-clean-muted) !important;
    background-image: none !important;
    border-color: var(--nidhi-clean-border) !important;
    color: var(--nidhi-clean-text) !important;
    text-shadow: none !important;
}

.bg-gradient-warning.text-white,
.bg-gradient-warning.text-light,
.bg-gradient-warning.text-primary,
.bg-gradient-warning * {
    color: var(--nidhi-clean-text) !important;
}

/* Standardize common gradient headings without changing their markup. */
h1[class*="bg-gradient-"],
h2[class*="bg-gradient-"],
h3[class*="bg-gradient-"],
h4[class*="bg-gradient-"] {
    border: 1px solid var(--nidhi-clean-border) !important;
    background-color: var(--nidhi-clean-surface) !important;
    background-image: none !important;
    color: #1e293b !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

/* Keep actions recognizable and accessible without gradients. */
.btn.bg-gradient-primary:hover { background-color: var(--nidhi-clean-primary-hover) !important; }
.btn.bg-gradient-info:hover { background-color: #075985 !important; }
.btn.bg-gradient-success:hover { background-color: #166534 !important; }
.btn.bg-gradient-danger:hover { background-color: #991b1b !important; }
.btn.bg-gradient-warning:hover { background-color: #f1f5f9 !important; }

/* Clean table headers retain strong, readable contrast. */
thead.bg-gradient-primary,
thead.bg-gradient-info,
thead.bg-gradient-success,
thead.bg-gradient-danger,
thead.bg-gradient-secondary,
thead.bg-gradient-warning,
.thead.bg-gradient-primary {
    background-color: #334155 !important;
    background-image: none !important;
    color: #ffffff !important;
}

thead[class*="bg-gradient-"] th,
.thead.bg-gradient-primary th {
    background-color: #334155 !important;
    background-image: none !important;
    color: #ffffff !important;
    text-shadow: none !important;
}

/* Remove decorative gradients that may be applied to cards and panels. */
.card[class*="bg-gradient-"],
.section-header[class*="bg-gradient-"] {
    background-color: var(--nidhi-clean-surface) !important;
    background-image: none !important;
    border-color: var(--nidhi-clean-border) !important;
    color: var(--nidhi-clean-text) !important;
}

.section-header[class*="bg-gradient-"] .card-title,
.card[class*="bg-gradient-"] .card-title {
    color: #1e293b !important;
}

/* Global loader system: used by existing loader containers and AJAX content. */
.nidhi-shimmer-loader {
    position: relative;
    display: inline-block;
    overflow: hidden;
    border-radius: 6px;
    background: #e9eef5;
    vertical-align: middle;
}

.nidhi-shimmer-loader::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .85), transparent);
    animation: nidhi-shimmer 1.25s ease-in-out infinite;
}

.nidhi-shimmer-loader--inline {
    width: 28px;
    height: 8px;
    margin: 0 3px;
    border-radius: 999px;
}

.nidhi-shimmer-loader--panel {
    width: min(320px, 80vw);
    height: 112px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background-color: #ffffff;
    background-image:
        linear-gradient(#e9eef5 0 0),
        linear-gradient(#e9eef5 0 0),
        linear-gradient(#e9eef5 0 0),
        linear-gradient(#e9eef5 0 0);
    background-repeat: no-repeat;
    background-position: 18px 18px, 18px 46px, 18px 70px, 18px 92px;
    background-size: 42% 12px, calc(100% - 36px) 9px, 78% 9px, 58% 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
}

#global-loader,
#global-loader-main {
    align-items: center;
    justify-content: center;
}

#global-loader {
    background: rgba(248, 250, 252, .92) !important;
}

#global-loader[style*="display: block"],
#global-loader-main[style*="display: block"] {
    display: flex !important;
}

@keyframes nidhi-shimmer {
    100% { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
    .nidhi-shimmer-loader::after { animation: none; }
}

/* Classic quick-add panels (Add Vendor / Add Customer on entry pages). */
.nidhi-quick-add-panel,
#displayCreateVendorMainDiv.nidhi-quick-add-panel,
#displayCreateCustomerMainDiv.nidhi-quick-add-panel,
#displayCreateLedgerMainDiv.nidhi-quick-add-panel {
    position: absolute;
    top: 18%;
    right: 8px;
    z-index: 30;
    width: min(420px, calc(100% - 16px));
    max-height: 450px;
    overflow: auto;
    padding: 10px;
    background: #ffffff !important;
    border: 5px solid #c3d3c6 !important;
    color: #000000 !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
}

/* Opening Ledger create panel: show full form, no inner scroll. */
#displayCreateLedgerMainDiv.nidhi-quick-add-panel {
    top: 8px;
    max-height: none;
    overflow: visible;
}

.nidhi-quick-add-panel > .badge {
    display: inline-block;
    font-size: 14px;
    font-weight: 700;
}

.nidhi-quick-add-panel .row {
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 8px;
    align-items: center;
}

.nidhi-quick-add-panel .row > [class*="col-"] {
    color: #000000;
    font-weight: 600;
}

.nidhi-quick-add-panel .form-control {
    background: #ffffff !important;
    color: #000000 !important;
}

.nidhi-quick-add-panel .btn-success {
    margin-top: 4px;
}

html[data-theme="dark"] .nidhi-quick-add-panel,
html[data-theme="dark"] #displayCreateVendorMainDiv.nidhi-quick-add-panel,
html[data-theme="dark"] #displayCreateCustomerMainDiv.nidhi-quick-add-panel,
html[data-theme="dark"] #displayCreateLedgerMainDiv.nidhi-quick-add-panel {
    background: #1e293b !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .nidhi-quick-add-panel .row > [class*="col-"],
html[data-theme="dark"] .nidhi-quick-add-panel label,
html[data-theme="dark"] .nidhi-quick-add-panel small {
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .nidhi-quick-add-panel .form-control {
    background: #0f172a !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

/* Related Ledger (and similar readonly payment fields) ? keep readable contrast. */
#app .form-control.payment-ledger,
.form-control.payment-ledger {
    background-color: #eef2f7 !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
    -webkit-text-fill-color: #0f172a !important;
    font-weight: 600;
}

html[data-theme="dark"] #app .form-control.payment-ledger,
html[data-theme="dark"] .form-control.payment-ledger {
    background-color: #1e293b !important;
    border-color: #475569 !important;
    color: #f8fafc !important;
    -webkit-text-fill-color: #f8fafc !important;
}

/* ?? Header dual calendar clock (EN + BS) ?? */
.header-rightmenu {
    align-items: center;
}

.nidhi-header-branch {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 220px;
    height: 36px;
    margin-right: 0.55rem;
    padding: 2px 8px 2px 8px;
    border-radius: 10px;
    background: var(--nidhi-clean-muted, #f1f5f9);
    color: var(--nidhi-clean-text, #1a202c);
}

.nidhi-header-branch > i {
    flex: 0 0 auto;
    font-size: 12px;
    opacity: 0.75;
}

.nidhi-header-branch select {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    height: 28px !important;
    padding: 0 4px !important;
    font-size: 12px !important;
    min-width: 0;
    max-width: 180px;
    color: inherit !important;
}

@media (max-width: 991.98px) {
    .nidhi-header-branch {
        display: none;
    }
}

.nidhi-header-clock {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto;
    min-width: 0;
    height: 44px;
    margin-right: 0.55rem;
    padding: 3px 10px 3px 4px;
    border-radius: 12px;
    background: var(--nidhi-clean-muted, #f1f5f9);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 4px 12px rgba(15, 23, 42, 0.05);
    color: var(--nidhi-clean-text, #1a202c);
}

.nidhi-header-clock__face {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
}

.nidhi-header-clock__face svg {
    display: block;
    overflow: visible;
    width: 34px;
    height: 34px;
}

.nidhi-header-clock__dial {
    fill: #fff;
    stroke: var(--nidhi-clean-primary, #2563eb);
    stroke-width: 1.6;
}

.nidhi-header-clock__ticks line {
    stroke: var(--nidhi-accent-dial, #1e40af);
    stroke-width: 1.15;
    stroke-linecap: round;
}

.nidhi-header-clock__hand {
    fill: none;
    stroke-linecap: round;
}

.nidhi-header-clock__hand--hour {
    stroke: var(--nidhi-accent-dial, #1e40af);
    stroke-width: 2.2;
}

.nidhi-header-clock__hand--minute {
    stroke: var(--nidhi-clean-primary, #2563eb);
    stroke-width: 1.6;
}

.nidhi-header-clock__hand--second {
    stroke: var(--nidhi-accent-second, #f97316);
    stroke-width: 1.15;
}

.nidhi-header-clock__cap {
    fill: var(--nidhi-accent-second, #f97316);
    stroke: #fff;
    stroke-width: 0.7;
}

.nidhi-header-clock__meta {
    display: flex;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    line-height: 1.15;
}

.nidhi-header-clock__time-row {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    min-height: 16px;
}

.nidhi-header-clock__time,
.nidhi-header-clock__time-np,
.nidhi-header-clock__ampm {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    letter-spacing: 0.02em;
}

.nidhi-header-clock__time {
    color: var(--nidhi-clean-primary-muted-text, #1e3a5f);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1;
}

.nidhi-header-clock__ampm {
    color: var(--nidhi-clean-primary, #2563eb);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.nidhi-header-clock__time-np {
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1;
}

.nidhi-header-clock__en,
.nidhi-header-clock__np {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nidhi-header-clock__en {
    color: #1a202c;
    font-size: 0.68rem;
    font-weight: 600;
}

.nidhi-header-clock__np {
    color: #0f3d45;
    font-size: 0.72rem;
    font-weight: 600;
}

@media (max-width: 1199.98px) {
    .nidhi-header-clock__time-np {
        display: none;
    }
}

@media (max-width: 991.98px) {
    .nidhi-header-clock__face {
        display: none;
    }

    .nidhi-header-clock {
        height: 42px;
        padding: 4px 10px;
        border-radius: 12px;
    }
}

@media (max-width: 767.98px) {
    .nidhi-header-clock {
        height: 40px;
        margin-right: 0.3rem;
        padding: 3px 8px;
    }

    .nidhi-header-clock__en {
        display: none;
    }

    .nidhi-header-clock__time {
        font-size: 0.86rem;
    }

    .nidhi-header-clock__np {
        font-size: 0.62rem;
    }
}

@media (max-width: 479.98px) {
    .nidhi-header-clock__np,
    .nidhi-header-clock__ampm {
        display: none;
    }

    .nidhi-header-clock {
        height: 32px;
        padding: 0 0.45rem;
        border-radius: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .nidhi-header-clock__hand {
        transition: none;
    }
}

/* ---------- Global search (header) ---------- */
.nidhi-global-search-slot {
    display: contents;
}

.nidhi-global-search__bar {
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
}

.nidhi-global-search__back {
    display: none;
}

.nidhi-global-search {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 560px;
    margin: 0 1rem 0 0.85rem;
    z-index: 1040;
}

.nidhi-global-search__field {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0 0.35rem 0 0.7rem;
    border: 1px solid var(--nidhi-clean-border, #e2e8f0);
    border-radius: 12px;
    background: var(--nidhi-clean-muted, #f1f5f9);
    box-shadow: 0 1px 2px rgba(15, 61, 69, 0.04);
    transition-property: border-color, box-shadow, background;
    transition-duration: 0.16s;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.nidhi-global-search__field:focus-within {
    background: var(--nidhi-clean-surface, #fff);
    border-color: #9ecfd6;
    box-shadow: 0 0 0 3px rgba(23, 104, 118, 0.12), 0 4px 14px rgba(15, 74, 84, 0.08);
}

.nidhi-global-search__icon {
    flex: 0 0 auto;
    margin-right: 0.45rem;
    color: var(--nidhi-clean-text, #64748b);
    font-size: 14px;
    opacity: 0.75;
}

.nidhi-global-search__field input {
    flex: 1 1 auto;
    min-width: 0;
    height: 38px;
    padding: 0 4.6rem 0 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--nidhi-clean-text, #1a202c);
    font-size: 0.9rem;
    line-height: 1.2;
}

.nidhi-global-search__field input::placeholder {
    color: #94a3b8;
}

.nidhi-global-search__field input::-webkit-search-cancel-button,
.nidhi-global-search__field input::-webkit-search-decoration {
    -webkit-appearance: none;
}

.nidhi-global-search__hint {
    position: absolute;
    right: 0.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 22px;
    padding: 0 0.4rem;
    border: 1px solid var(--nidhi-clean-border, #e2e8f0);
    border-radius: 6px;
    background: var(--nidhi-clean-surface, #fff);
    color: #64748b;
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1;
    pointer-events: none;
}

.nidhi-global-search__clear {
    position: absolute;
    right: 0.28rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    transition-property: background, color, transform;
    transition-duration: 0.15s;
}

.nidhi-global-search__clear:hover {
    background: var(--nidhi-clean-primary-soft, #eff6ff);
    color: var(--nidhi-clean-primary, #2563eb);
}

.nidhi-global-search__clear:active {
    transform: scale(0.96);
}

.nidhi-global-search__field:focus-within .nidhi-global-search__hint,
.nidhi-global-search.has-query .nidhi-global-search__hint {
    display: none;
}

.nidhi-global-search__dropdown {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    right: 0;
    max-height: min(420px, 70vh);
    overflow: auto;
    padding: 0.35rem;
    border: 1px solid var(--nidhi-clean-border, #e2e8f0);
    border-radius: 14px;
    background: var(--nidhi-clean-surface, #fff);
    box-shadow: 0 8px 28px rgba(15, 61, 69, 0.14), 0 2px 8px rgba(15, 61, 69, 0.06);
    z-index: 1050;
}

.nidhi-global-search__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.nidhi-global-search__item {
    display: flex;
    width: 100%;
    min-height: 44px;
    align-items: center;
    gap: 0.7rem;
    padding: 0.45rem 0.55rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--nidhi-clean-text, #1a202c);
    text-align: left;
    cursor: pointer;
    transition-property: background, transform;
    transition-duration: 0.15s;
}

.nidhi-global-search__item:hover,
.nidhi-global-search__item.is-active {
    background: var(--nidhi-clean-primary-soft, #eff6ff);
}

.nidhi-global-search__item:active {
    transform: scale(0.96);
}

.nidhi-global-search__item-icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(var(--nidhi-clean-primary-rgb, 37, 99, 235), 0.1);
    color: var(--nidhi-clean-primary, #2563eb);
    font-size: 14px;
}

.nidhi-global-search__item-body {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

.nidhi-global-search__item-title {
    overflow: hidden;
    color: var(--nidhi-clean-text, #1a202c);
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nidhi-global-search__item-title mark {
    padding: 0;
    background: rgba(var(--nidhi-clean-primary-rgb, 37, 99, 235), 0.18);
    color: inherit;
    font-weight: 800;
}

.nidhi-global-search__item-meta {
    overflow: hidden;
    color: #64748b;
    font-size: 0.72rem;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nidhi-global-search__item-aside {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.18rem;
    max-width: 42%;
}

.nidhi-global-search__item-balance {
    font-size: 0.78rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    white-space: nowrap;
    color: var(--nidhi-clean-text, #1a202c);
}

.nidhi-global-search__item-balance--dr {
    color: #b45309;
}

.nidhi-global-search__item-balance--cr {
    color: #047857;
}

.nidhi-global-search__item-balance--zero {
    color: #64748b;
}

.nidhi-global-search__item-type {
    flex: 0 0 auto;
    padding: 0.12rem 0.42rem;
    border-radius: 999px;
    background: var(--nidhi-clean-muted, #f1f5f9);
    color: #64748b;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.nidhi-global-search__item-type--vendor {
    background: rgba(63, 81, 181, 0.12);
    color: #3f51b5;
}

.nidhi-global-search__item-type--customer {
    background: rgba(156, 39, 176, 0.12);
    color: #9c27b0;
}

.nidhi-global-search__item-type--other {
    background: rgba(var(--nidhi-clean-primary-rgb, 37, 99, 235), 0.12);
    color: var(--nidhi-clean-primary, #2563eb);
}

.nidhi-global-search__item-type--product {
    background: rgba(76, 175, 80, 0.12);
    color: #2e7d32;
}

.nidhi-global-search__item-icon--ledger {
    background: rgba(var(--nidhi-clean-primary-rgb, 37, 99, 235), 0.12);
}

.nidhi-global-search__item-icon--product {
    background: rgba(76, 175, 80, 0.14);
    color: #2e7d32;
}

.nidhi-global-search__loading {
    display: flex;
    min-height: 36px;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.7rem;
    color: #64748b;
    font-size: 0.78rem;
}

.nidhi-global-search__empty {
    display: flex;
    flex-direction: column;
    min-height: 72px;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.9rem 0.85rem;
    color: #64748b;
    font-size: 0.85rem;
}

.nidhi-global-search__empty-msg {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
}

.nidhi-global-search__empty .fa {
    color: #cbd5e1;
}

.nidhi-global-search__empty-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
}

.nidhi-global-search__create-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: 0;
    border-radius: 999px;
    padding: 0.4rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    line-height: 1.2;
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.nidhi-global-search__create-btn:hover {
    filter: brightness(1.05);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.16);
}

.nidhi-global-search__create-btn:active {
    transform: translateY(1px);
}

.nidhi-global-search__create-btn--vendor {
    background: #2563eb;
}

.nidhi-global-search__create-btn--customer {
    background: #9333ea;
}

.nidhi-global-search__create-btn--product {
    background: #d97706;
}

.nidhi-global-search__add-product {
    list-style: none;
    padding: 8px 10px 10px;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
}

@media (max-width: 991.98px) {
    .nidhi-global-search {
        max-width: none;
        margin: 0 0.65rem 0 0.45rem;
    }

    .nidhi-global-search__hint {
        display: none;
    }

    .nidhi-global-search__field input {
        padding-right: 2.2rem;
    }
}

@media (max-width: 575.98px) {
    .nidhi-global-search__field input {
        font-size: 0.82rem;
    }

    .nidhi-global-search__field input::placeholder {
        font-size: 0.78rem;
    }
}

/* Fixed circular page-back control (top-right), ported from Pharma. */
.nidhi-page-back-wrap {
    position: fixed;
    top: calc(var(--nidhi-header-height, 68px) + 0.45rem);
    right: 1rem;
    z-index: 1025;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0;
    margin: 0;
    pointer-events: none;
}
.nidhi-page-back-wrap[hidden] {
    display: none !important;
}
.nidhi-header-back {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border: 0;
    border-radius: 999px;
    background: #16a34a;
    color: #fff;
    opacity: 0.48;
    box-shadow: 0 6px 16px rgba(22, 163, 74, 0.35);
    cursor: pointer;
    transition-property: opacity, transform, box-shadow;
    transition-duration: 0.18s;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}
.nidhi-header-back[hidden] {
    display: none !important;
}
.nidhi-header-back:hover,
.nidhi-header-back:focus {
    opacity: 1;
    color: #fff;
    outline: none;
    box-shadow: 0 8px 20px rgba(22, 163, 74, 0.45);
}
.nidhi-header-back:active {
    transform: scale(0.96);
}
@media (prefers-reduced-motion: reduce) {
    .nidhi-header-back { transition: none; }
    .nidhi-header-back:active { transform: none; }
}
@media print {
    .nidhi-header-back,
    .nidhi-page-back-wrap { display: none !important; }
}

/*
 * Global horizontal-overflow guards (all pages).
 * 1) Padding on .table-responsive + width:100% tables causes a few-px scrollbar.
 * 2) Nested ledger item tables with 100px side margins force parent overflow.
 * 3) Sidebar open/close is handled in nidhi-sidebar.css + sidemenu.js.
 */
.app-content .table-responsive {
    max-width: 100%;
    box-sizing: border-box;
}
.app-content .table-responsive.p-2,
.app-content .table-responsive.p-1,
.app-content .table-responsive.p-3 {
    /* Keep visual padding without expanding scrollWidth past the container */
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    overflow-x: auto;
}
.app-content .table-responsive > table {
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
    margin-bottom: 0;
}
.app-content .table-responsive > table th,
.app-content .table-responsive > table td {
    /* Prefer wrapping at spaces; only break ultra-long tokens — never mid-word character salad */
    word-break: normal;
    overflow-wrap: break-word;
}

/*
 * Entry list UIs (sales / purchase / returns): wide grids must scroll horizontally
 * instead of collapsing columns into one-character-per-line text.
 */
.app-content .sales-list-page .table-responsive,
.app-content .purchase-list-page .table-responsive,
.app-content .sales-return-list-page .table-responsive,
.app-content .purchase-return-list-page .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}
.app-content .sales-list-page .table-responsive > table,
.app-content .purchase-list-page .table-responsive > table,
.app-content .sales-return-list-page .table-responsive > table,
.app-content .purchase-return-list-page .table-responsive > table {
    width: max-content !important;
    min-width: 100%;
    max-width: none;
    table-layout: auto;
}
.app-content .sales-list-page .table-responsive > table th,
.app-content .sales-list-page .table-responsive > table td,
.app-content .purchase-list-page .table-responsive > table th,
.app-content .purchase-list-page .table-responsive > table td,
.app-content .sales-return-list-page .table-responsive > table th,
.app-content .sales-return-list-page .table-responsive > table td,
.app-content .purchase-return-list-page .table-responsive > table th,
.app-content .purchase-return-list-page .table-responsive > table td {
    word-break: normal;
    overflow-wrap: normal;
    vertical-align: middle;
}
.app-content .sales-list-page .table thead td,
.app-content .sales-list-page .table thead th,
.app-content .purchase-list-page .table thead td,
.app-content .purchase-list-page .table thead th,
.app-content .sales-return-list-page .table thead td,
.app-content .sales-return-list-page .table thead th,
.app-content .purchase-return-list-page .table thead td,
.app-content .purchase-return-list-page .table thead th {
    white-space: nowrap;
}
.app-content .sales-list-page .col-nowrap,
.app-content .purchase-list-page .col-nowrap,
.app-content .sales-return-list-page .col-nowrap,
.app-content .purchase-return-list-page .col-nowrap,
.app-content .sales-list-page .amt,
.app-content .purchase-list-page .amt,
.app-content .sales-return-list-page .amt,
.app-content .purchase-return-list-page .amt,
.app-content .sales-list-page .action-btns,
.app-content .purchase-list-page .action-btns,
.app-content .sales-return-list-page .action-btns,
.app-content .purchase-return-list-page .action-btns,
.app-content .sales-list-page .col-status,
.app-content .purchase-list-page .col-status,
.app-content .sales-return-list-page .col-status,
.app-content .purchase-return-list-page .col-status {
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
}
.app-content .sales-list-page .col-sn,
.app-content .purchase-list-page .col-sn,
.app-content .sales-return-list-page .col-sn,
.app-content .purchase-return-list-page .col-sn {
    min-width: 2.75rem;
    white-space: nowrap;
}
.app-content .sales-list-page .col-bill,
.app-content .purchase-list-page .col-bill,
.app-content .sales-return-list-page .col-bill,
.app-content .purchase-return-list-page .col-bill {
    min-width: 5rem;
    white-space: nowrap;
}
.app-content .sales-list-page .col-date,
.app-content .purchase-list-page .col-date,
.app-content .sales-return-list-page .col-date,
.app-content .purchase-return-list-page .col-date {
    min-width: 6.5rem;
    white-space: nowrap;
}
.app-content .sales-list-page .amt,
.app-content .purchase-list-page .amt,
.app-content .sales-return-list-page .amt,
.app-content .purchase-return-list-page .amt {
    min-width: 5.75rem;
}
.app-content .sales-list-page .col-status,
.app-content .purchase-list-page .col-status,
.app-content .sales-return-list-page .col-status,
.app-content .purchase-return-list-page .col-status {
    min-width: 5.5rem;
}
.app-content .sales-list-page .action-btns,
.app-content .purchase-list-page .action-btns,
.app-content .sales-return-list-page .action-btns,
.app-content .purchase-return-list-page .action-btns {
    min-width: 9rem;
}
.app-content .sales-list-page .col-party,
.app-content .purchase-list-page .col-party,
.app-content .sales-return-list-page .col-party,
.app-content .purchase-return-list-page .col-party {
    min-width: 160px;
    max-width: 280px;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
}
.app-content .sales-list-page .col-narration,
.app-content .purchase-list-page .col-narration,
.app-content .sales-return-list-page .col-narration,
.app-content .purchase-return-list-page .col-narration {
    min-width: 120px;
    max-width: 240px;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
}
html[data-theme="dark"] .sales-list-page .table-responsive,
html[data-theme="dark"] .purchase-list-page .table-responsive,
html[data-theme="dark"] .sales-return-list-page .table-responsive,
html[data-theme="dark"] .purchase-return-list-page .table-responsive {
    scrollbar-color: #475569 #1e293b;
}

.app-content .ledger-bill-items-table {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box !important;
}
.app-content .ledger-bill-items-row > td {
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
}
.app-content .card,
.app-content .card-body,
#reportSearchBar,
#reportSearchBar .row {
    max-width: 100%;
    min-width: 0;
}

/*
 * Entry pages (#displayBillTerm): keep hidden until JS removes .d-none and
 * injects content. When open, show as a centered modal overlay so the panel
 * is not clipped by parent overflow / absolute right positioning.
 */
#displayBillTerm:empty,
#displayBillTerm.d-none {
    display: none !important;
    overflow: hidden !important;
    height: 0 !important;
    max-height: 0 !important;
    border: 0 !important;
    padding: 0 !important;
    pointer-events: none !important;
}
#displayBillTerm:not(.d-none):not(:empty) {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 16px !important;
    border: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    overflow: auto !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    z-index: 1055 !important;
    background: rgba(15, 23, 42, 0.45) !important;
    pointer-events: auto !important;
    float: none !important;
    flex: none !important;
}
#displayBillTerm:not(.d-none):not(:empty) > .card {
    width: min(720px, 100%);
    max-height: min(85vh, 640px);
    margin: 0;
    overflow: auto;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.28);
}

/*
 * Select2 marks the original <select> as .select2-hidden-accessible but may still
 * leave an inline width:100% !important on it. That absolute element expands the
 * page horizontally (empty right-side scroll). JS clamps it; this is a backup for
 * cases without the clamp helper.
 */
.select2-hidden-accessible {
    max-width: 1px !important;
    min-width: 0 !important;
    overflow: hidden !important;
}

/* Tenant subscription expiry banners (shown in app shell when company open) */
.nidhi-tenant-banner {
    margin: 0 0 12px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.nidhi-tenant-banner__icon { flex-shrink: 0; margin-top: 2px; }
.nidhi-tenant-banner__body { flex: 1; min-width: 0; }
.nidhi-tenant-banner__text { line-height: 1.45; }
.nidhi-tenant-banner__img {
    display: block;
    max-width: 100%;
    max-height: 120px;
    width: auto;
    margin-bottom: 10px;
    border-radius: 6px;
    object-fit: contain;
}
.nidhi-tenant-banner--info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}
.nidhi-tenant-banner--warn {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fcd34d;
}
.nidhi-tenant-banner--critical {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

