/* Temp invoicing workbench — Phase 1 */

.invoices-page {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.4rem 0.55rem 0.45rem;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    background: linear-gradient(180deg, #f7f9fc 0%, #eef2f7 100%);
}

.invoices-page__header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    flex-shrink: 0;
}

.invoices-page__title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--ent-navy, #03142e);
    letter-spacing: -0.015em;
    line-height: 1.25;
}

.invoices-page__subtitle {
    margin: 0;
    font-size: 0.875rem;
    color: var(--ent-muted, #64748b);
    font-weight: 600;
}

.invoices-page__banner {
    margin: 0;
    padding: 0.4rem 0.65rem;
    border-radius: 6px;
    background: #eef6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a5f;
    font-size: 0.8125rem;
    font-weight: 600;
    flex-shrink: 0;
}

.invoices-page__error {
    margin: 0;
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-shrink: 0;
}

.invoices-page__error button {
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.invoices-page__grid {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.invoices-page .iffys-sf-grid-host {
    flex: 1 1 0;
    min-height: 0;
}

.invoices-page__filter {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #334155;
}

.invoices-page__filter select,
.invoices-page__days {
    min-height: 2.25rem;
    font-size: 0.875rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    background: #fff;
}

.invoices-page__days {
    width: 4.5rem;
}

.inv-number-link {
    border: none;
    background: none;
    color: #0b5ed7;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    font-size: inherit;
}

/* ── Invoice product picker (Angular product-dialog parity) ──
   Must beat syncfusion.css `.e-dialog { z-index: 3000 !important }` so the
   picker opens fully above the invoice dialog (25000 / stacked 47000). */
.invoice-product-picker-dialog.e-dialog {
    --ipp-z: 56000;
    z-index: var(--ipp-z) !important;
    width: min(92vw, calc(100vw - 1.25rem)) !important;
    max-width: min(92vw, calc(100vw - 1.25rem)) !important;
    height: min(88vh, calc(100dvh - 1rem)) !important;
    max-height: min(88vh, calc(100dvh - 1rem)) !important;
    min-height: 0 !important;
    border-radius: 8px !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    margin: 0 !important;
    pointer-events: auto !important;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.28) !important;
}

.e-dlg-overlay:has(+ .invoice-product-picker-dialog),
.e-dlg-overlay.e-dlg-overlay--ipp {
    z-index: 55990 !important;
}

.invoice-product-picker-dialog.e-dialog > .e-dlg-header-content {
    flex: 0 0 auto !important;
}

.invoice-product-picker-dialog.e-dialog > .e-dlg-content {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: hidden !important;
    padding: 0.45rem 0.55rem !important;
    display: flex !important;
    flex-direction: column !important;
}

.invoice-product-picker-dialog.e-dialog > .e-footer-content {
    flex: 0 0 auto !important;
}

.invoice-product-picker-dialog.e-dialog .e-dlg-content {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    padding: 0.55rem 0.65rem 0.4rem;
}

.ipp-shell {
    --ipp-rail-bg: #d6e8f8;
    --ipp-card-bg: #0b3a6e;
    --ipp-card-bg-2: #14508f;
    --ipp-ink: #0a2748;
    --ipp-amber: #c98500;
    display: flex;
    flex-direction: row;
    gap: 0;
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.ipp-main {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    transition: flex-basis 180ms ease;
}

.ipp-shell--rail .ipp-main {
    flex: 0 0 80%;
    max-width: 80%;
}

.ipp-rail {
    display: none;
    flex-direction: column;
    position: relative;
    flex: 0 0 20%;
    max-width: 20%;
    min-width: 260px;
    margin-left: 0.55rem;
    border-radius: 12px;
    overflow: hidden;
    color: var(--ipp-ink);
    background:
        linear-gradient(180deg, #e8f3fc 0%, var(--ipp-rail-bg) 55%, #c5ddf2 100%);
    border: 1px solid #9fc0e0;
    box-shadow: 0 8px 22px rgba(20, 70, 120, 0.12);
}

.ipp-shell--rail .ipp-rail {
    display: flex;
}

.ipp-rail__glow {
    display: none;
}

.ipp-rail__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.9rem 1rem 0.6rem;
    position: relative;
    z-index: 1;
}

.ipp-rail__title {
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ipp-ink);
}

.ipp-rail__badge {
    min-width: 1.85rem;
    height: 1.85rem;
    padding: 0 0.45rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 800;
    color: #fff;
    background: var(--ipp-card-bg);
}

.ipp-rail__cards {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.4rem 0.75rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    position: relative;
    z-index: 1;
    scrollbar-width: thin;
    scrollbar-color: #7aa7d0 transparent;
}

.ipp-rail__empty {
    margin: auto 0.25rem;
    padding: 1.4rem 0.85rem;
    text-align: center;
    color: #3d5f82;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
}

.ipp-rail__empty i {
    font-size: 1.85rem;
    opacity: 0.75;
    color: var(--ipp-card-bg);
}

.ipp-card {
    display: grid;
    grid-template-columns: 76px 1fr;
    gap: 0.6rem;
    padding: 0.65rem;
    border-radius: 10px;
    background: linear-gradient(155deg, var(--ipp-card-bg-2) 0%, var(--ipp-card-bg) 100%);
    border: 1px solid #0a2f5a;
    box-shadow: 0 6px 14px rgba(8, 40, 80, 0.22);
    color: #fff;
    animation: ipp-card-in 260ms ease-out;
}

@keyframes ipp-card-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.ipp-card__media {
    width: 76px;
    height: 76px;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.ipp-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ipp-card__ph {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.55);
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.06);
}

.ipp-card__body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.32rem;
}

.ipp-card__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
}

.ipp-card__sku {
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #ffd56a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ipp-card__del {
    flex: 0 0 auto;
    width: 1.7rem;
    height: 1.7rem;
    border: 0;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.14);
    color: #ffe0e0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
}

.ipp-card__del:hover {
    background: rgba(185, 28, 28, 0.55);
    color: #fff;
}

.ipp-card__desc {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.3;
    color: #fff;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ipp-card__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
    margin-top: auto;
}

.ipp-card__qty {
    display: inline-flex;
    align-items: center;
    border-radius: 7px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.ipp-card__qty button {
    width: 1.7rem;
    height: 1.9rem;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
}

.ipp-card__qty button:hover {
    background: rgba(255, 255, 255, 0.12);
}

.ipp-card__qty input {
    width: 2.6rem;
    height: 1.9rem;
    border: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    background: transparent;
    color: #fff;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 700;
    -moz-appearance: textfield;
}

.ipp-card__qty input::-webkit-outer-spin-button,
.ipp-card__qty input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ipp-card__price {
    text-align: right;
    line-height: 1.2;
}

.ipp-card__unit {
    display: block;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
}

.ipp-card__line {
    display: block;
    font-size: 1.05rem;
    font-weight: 800;
    color: #fff;
}

.ipp-rail__totals {
    position: relative;
    z-index: 1;
    margin-top: auto;
    padding: 0.85rem 1rem 1rem;
    border-top: 1px solid #9fc0e0;
    background: rgba(255, 255, 255, 0.45);
}

.ipp-rail__tot-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--ipp-ink);
    padding: 0.12rem 0;
}

.ipp-rail__tot-row--grand {
    font-size: 1.15rem;
    font-weight: 850;
    color: var(--ipp-ink);
}

.ipp-rail__tot-row--grand span:last-child {
    color: var(--ipp-card-bg);
    letter-spacing: 0.01em;
}

.ipp-history.iffys-sf-grid-host {
    flex: 0 0 210px;
    min-height: 160px;
    max-height: 240px;
}

.ipp-searchbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.55rem;
    background: #000080;
    border: 2px double #001a4d;
    border-radius: 4px;
    flex-shrink: 0;
}

.ipp-check {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
    cursor: pointer;
}

.ipp-searchbar .ipp-ddl,
.ipp-searchbar .ipp-tb,
.ipp-searchbar .e-input-group,
.ipp-searchbar .e-ddl {
    background: #fff !important;
    border-radius: 3px;
}

.ipp-searchbar input.ipp-tb {
    height: 2rem;
    min-height: 2rem;
    font-size: 0.8125rem;
    border: 1px solid #cbd5e1;
    padding: 0.2rem 0.45rem;
}

.ipp-searchbar input.ipp-tb-combo:focus {
    outline: 2px solid #f2c14b;
    outline-offset: 1px;
    border-color: #f2c14b;
}

.ipp-count {
    color: #fff;
    font-weight: 800;
    font-size: 0.8125rem;
    margin-left: auto;
}

.ipp-results.iffys-sf-grid-host {
    flex: 1 1 auto;
    min-height: 180px;
}

.ipp-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 100px;
    color: #64748b;
    font-size: 0.9rem;
    font-weight: 600;
}

.ipp-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.85rem;
    height: 1.85rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #f8fafc;
    color: #0f172a;
    cursor: pointer;
    padding: 0;
}

.ipp-icon-btn:hover:not(:disabled) {
    background: #fff;
    border-color: #94a3b8;
}

.ipp-icon-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.ipp-icon-btn--light {
    background: #e2e8f0;
    border-color: #94a3b8;
    color: #03142e;
}

.ipp-qty {
    width: 4.25rem;
    text-align: center;
    margin: 0 auto;
    display: inline-block;
}

/* —— Release quotation dialog —— 88vh centered shell; .rel-scroll is the only scroller. */
.invoice-release-dialog.e-dialog {
    width: min(1100px, calc(100vw - 1.25rem)) !important;
    height: auto !important;
    max-height: min(88vh, calc(100dvh - 1rem)) !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    border-radius: 12px !important;
}

.invoice-release-dialog.e-dialog > .e-dlg-header-content,
.invoice-release-dialog.e-dialog > .e-footer-content {
    flex: 0 0 auto !important;
}

.invoice-release-dialog.e-dialog > .e-dlg-content {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
}

.invoice-release-dialog .rel-scroll {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.65rem 0.75rem 0.85rem;
    max-height: calc(min(88vh, 100dvh - 1rem) - 7.25rem);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
}

/* Compact balance row — never use cust-balance--fill inside a scroll host */
.invoice-release-dialog .rel-balance.cust-balance {
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 0 !important;
    width: 100%;
    max-width: 100%;
    display: grid !important;
    grid-template-columns: minmax(180px, 220px) minmax(0, 1fr) !important;
    grid-template-rows: auto !important;
    align-items: center;
    overflow: hidden;
}

.invoice-release-dialog .rel-balance .cust-balance__stats {
    justify-content: center;
    align-self: center;
}

.invoice-release-dialog .rel-balance .cust-balance__chart {
    flex: none !important;
    height: var(--cab-h) !important;
    min-height: var(--cab-h) !important;
    max-height: var(--cab-h) !important;
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.invoice-release-dialog .rel-balance .cab-chart {
    width: 100%;
    height: 100%;
    min-width: 0;
}

.invoice-release-dialog .rel-title {
    font-size: 1rem;
    font-weight: 800;
    color: #03142e;
    margin-bottom: 0.5rem;
}

.invoice-release-dialog .rel-section-title {
    font-size: 0.8125rem;
    font-weight: 800;
    margin: 0.65rem 0 0.35rem;
    color: #03142e;
}

.invoice-release-dialog .rel-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    margin-top: 0.5rem;
}

.invoice-release-dialog .rel-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.65rem;
    margin-top: 0.5rem;
}

.invoice-release-dialog .nq-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.invoice-release-dialog .rel-table-host {
    max-height: 180px;
    overflow: auto;
}

.invoice-release-dialog .rel-table-host--lines {
    max-height: 240px;
}

@media (max-width: 800px) {
    .invoice-release-dialog .rel-grid-2,
    .invoice-release-dialog .rel-grid-3 {
        grid-template-columns: 1fr;
    }
}

.ipp-dlg-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
}

.ipp-ai-open {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(180deg, #4f46e5 0%, #312e81 100%);
    color: #fff;
    font-weight: 700;
    font-size: 0.8125rem;
    padding: 0.28rem 0.75rem;
    cursor: pointer;
}

.ipp-ai-open:hover:not(:disabled) {
    filter: brightness(1.08);
}

.ipp-ai-open:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.invoice-product-ai-dialog.e-dialog {
    width: min(780px, calc(100vw - 1.25rem)) !important;
    height: min(88vh, calc(100dvh - 1rem)) !important;
    max-height: min(88vh, calc(100dvh - 1rem)) !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.invoice-product-ai-dialog.e-dialog > .e-dlg-header-content,
.invoice-product-ai-dialog.e-dialog > .e-footer-content {
    flex: 0 0 auto !important;
}

.invoice-product-ai-dialog.e-dialog > .e-dlg-content {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
}

.invoice-product-ai-dialog .ipp-ai-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0.65rem 0.75rem 0.85rem;
    max-height: calc(min(88vh, 100dvh - 1rem) - 9.5rem);
    box-sizing: border-box;
}

.ipp-ai-head {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.ipp-ai-head__sub {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
}

.ipp-ai-messages {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.ipp-ai-empty {
    text-align: center;
    color: #64748b;
    padding: 2rem 1rem;
}

.ipp-ai-empty i {
    font-size: 1.6rem;
    color: #4f46e5;
}

.ipp-ai-msg {
    max-width: 92%;
}

.ipp-ai-msg--user {
    align-self: flex-end;
}

.ipp-ai-msg--bot {
    align-self: flex-start;
}

.ipp-ai-msg__text {
    background: #eef2ff;
    border-radius: 10px;
    padding: 0.5rem 0.7rem;
    font-size: 0.875rem;
}

.ipp-ai-msg--user .ipp-ai-msg__text {
    background: #03142e;
    color: #fff;
}

.ipp-ai-lines {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.45rem;
}

.ipp-ai-line {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.45rem 0.55rem;
    background: #fff;
}

.ipp-ai-line--match {
    border-color: #86efac;
}

.ipp-ai-line--multiplematch {
    border-color: #fcd34d;
}

.ipp-ai-line--nomatch {
    border-color: #fca5a5;
}

.ipp-ai-line__top {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}

.ipp-ai-line__status {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ipp-ai-line__body,
.ipp-ai-cand {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    font-size: 0.8125rem;
}

.ipp-ai-cands {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.ipp-ai-cand {
    text-align: left;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #f8fafc;
    padding: 0.4rem 0.5rem;
    cursor: pointer;
}

.ipp-ai-cand.is-selected {
    border-color: #4f46e5;
    background: #eef2ff;
}

.ipp-ai-composer {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.4rem;
    align-items: end;
    width: 100%;
    margin-bottom: 0.45rem;
}

.ipp-ai-input {
    width: 100%;
    min-height: 2.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.4rem 0.5rem;
    font-size: 0.875rem;
    resize: vertical;
}

.ipp-ai-footer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
}

.ipp-ai-send {
    min-height: 2.25rem;
}

.ipp-ai-draft {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.ipp-ai-draft__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.8125rem;
    color: #475569;
}

.ipp-ai-check {
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.ipp-ai-remove {
    margin-left: auto;
    border: 0;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.1rem 0.25rem;
}

.ipp-ai-remove:hover {
    color: #b91c1c;
}

.ipp-ai-line__edit {
    display: flex;
    gap: 0.45rem;
    align-items: center;
    margin-top: 0.35rem;
}

.ipp-ai-qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    overflow: hidden;
}

.ipp-ai-qty button {
    width: 1.75rem;
    height: 1.75rem;
    border: 0;
    background: #f1f5f9;
    cursor: pointer;
}

.ipp-ai-qty input {
    width: 3rem;
    border: 0;
    text-align: center;
    height: 1.75rem;
}

.ipp-ai-unit {
    width: 5.5rem;
    height: 1.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0 0.4rem;
    font-size: 0.8125rem;
}
