/* Purchasing — Open Orders dashboard */

.purchasing-page {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    padding: 0.6rem 0.8rem 0.9rem;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    background:
        radial-gradient(1200px 280px at 8% -10%, rgba(130, 11, 11, 0.10), transparent 55%),
        radial-gradient(900px 240px at 92% 0%, rgba(15, 76, 117, 0.12), transparent 50%),
        linear-gradient(180deg, #f4f7fb 0%, #e8eef6 100%);
}

.purchasing-page__header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    flex-shrink: 0;
}

.purchasing-page__title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
    color: #03142e;
    letter-spacing: -0.02em;
}

.purchasing-page__error {
    margin: 0;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    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;
}

.purchasing-page__error button {
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.purchasing-page__date,
.purchasing-page__ddl {
    min-height: 2.25rem;
    font-size: 0.875rem;
}

.purchasing-page__search {
    min-height: 2.25rem;
    min-width: 12rem;
    padding: 0.3rem 0.65rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.875rem;
}

.purchasing-top {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    align-items: stretch;
    flex-shrink: 0;
}

.purchasing-card--charts {
    overflow: hidden;
}

.purchasing-chart-split {
    display: grid;
    grid-template-columns: minmax(0, 8fr) minmax(0, 2fr);
    grid-template-rows: 260px;
    gap: 0.4rem;
    padding: 0.35rem 0.5rem 0.5rem;
    min-height: 260px;
    align-items: stretch;
}

.purchasing-chart-pane {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    width: 100%;
}

.purchasing-chart-dl {
    font-size: 10px;
    font-weight: 700;
    color: #334155;
    white-space: nowrap;
}

.purchasing-chart-pane--fill {
    padding: 0.35rem 0.5rem 0.5rem;
}

.purchasing-balance-grid {
    min-width: 0;
    min-height: 0;
    height: 260px;
    border: none;
    overflow: hidden;
}

.purchasing-balance-grid .e-grid .e-rowcell,
.purchasing-balance-grid .e-grid .e-headercell {
    padding: 0.15rem 0.35rem !important;
    font-size: 0.75rem !important;
}

.purchasing-balance-grid .iffys-sf-icon-btn {
    width: 1.7rem !important;
    height: 1.7rem !important;
    min-height: 1.7rem !important;
}

.payable-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.5rem;
}

.payable-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 0.45rem;
}

.payable-grid-host {
    flex: 1 1 auto;
    min-height: 18rem;
    height: 100%;
}

.vendor-editor-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem 0.75rem;
    margin-bottom: 0.65rem;
}

.vendor-pay-layout--split {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.8fr);
    gap: 0.75rem;
}

.vendor-pay-form {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.payable-dialog.e-dialog,
.feature-dialog.payable-dialog.e-dialog {
    width: min(1180px, calc(100vw - 1.25rem)) !important;
}

.vendor-editor-dialog.e-dialog,
.feature-dialog.vendor-editor-dialog.e-dialog {
    width: min(980px, calc(100vw - 1.25rem)) !important;
}

.vendor-payment-dialog.e-dialog,
.feature-dialog.vendor-payment-dialog.e-dialog {
    width: min(980px, calc(100vw - 1.25rem)) !important;
}

.work-orders-dialog.e-dialog,
.feature-dialog.work-orders-dialog.e-dialog {
    width: min(1100px, calc(100vw - 1.25rem)) !important;
}

.payable-scroll,
.vendor-editor-scroll,
.vendor-payment-scroll,
.work-orders-scroll {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: none;
    height: 100%;
}

.purchasing-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(0, 1fr);
    gap: 0.75rem;
    flex: 1 1 0;
    min-height: 0;
    align-items: stretch;
    overflow: hidden;
}

.purchasing-page > .purchasing-card--grid {
    flex: 1 1 0;
    min-height: 0;
}

.purchasing-card {
    background: #fff;
    border: 1px solid #cfd9e6;
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(3, 20, 46, 0.08);
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.purchasing-card__title {
    margin: 0;
    padding: 0.5rem 0.8rem;
    font-size: 0.92rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.01em;
    background: linear-gradient(90deg, #03142e 0%, #0f4c75 72%, #820b0b 160%);
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-shrink: 0;
}

.purchasing-card__count {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.28);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
}

.purchasing-placeholder {
    min-height: 168px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    color: #475569;
    font-size: 0.875rem;
    font-weight: 700;
    background:
        linear-gradient(180deg, rgba(15, 76, 117, 0.06), transparent 55%),
        repeating-linear-gradient(-45deg, #f8fafc, #f8fafc 10px, #f1f5f9 10px, #f1f5f9 20px);
}

.purchasing-placeholder i {
    font-size: 1.65rem;
    color: #820b0b;
    opacity: 0.85;
}

.purchasing-placeholder--tall {
    min-height: 380px;
}

.purchasing-tabs {
    display: flex;
    gap: 0.2rem;
    border-bottom: 3px solid #03142e;
    flex-shrink: 0;
}

.purchasing-tabs__btn,
.purchasing-subtabs__btn {
    border: none;
    background: transparent;
    padding: 0.45rem 1.05rem;
    font-size: 0.875rem;
    font-weight: 800;
    color: #475569;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
}

.purchasing-tabs__btn.is-active,
.purchasing-subtabs__btn.is-active {
    color: #fff;
    background: #03142e;
}

.purchasing-subtabs {
    display: flex;
    gap: 0.15rem;
    padding: 0.35rem 0.5rem 0;
    flex-shrink: 0;
}

.purchasing-filterbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.6rem;
    background: linear-gradient(90deg, #334155, #0f4c75);
    border-bottom: 1px solid #03142e;
    flex-shrink: 0;
}

.purchasing-filterbar--end {
    justify-content: flex-end;
}

.purchasing-filterbar .ent-cmdbar__btn {
    background: #fff;
    color: #03142e;
    font-weight: 700;
    font-size: 0.875rem;
    min-height: 2.25rem;
    border: 1px solid #c5d0de;
}

.purchasing-filterbar .ent-cmdbar__btn:hover:not(:disabled) {
    background: #eaf1f8;
    border-color: #9db0c7;
    color: #0f4c75;
}

.purchasing-filterbar .ent-cmdbar__btn--primary {
    background: #0f766e;
    border-color: #0f766e;
    color: #fff;
}

.purchasing-filterbar .ent-cmdbar__btn--primary:hover:not(:disabled) {
    background: #0d9488;
    border-color: #0d9488;
    color: #fff;
}

.purchasing-filterbar .ent-cmdbar__btn--refresh {
    background: #0f766e;
    border-color: #0f766e;
    color: #fff;
}

.purchasing-page .iffys-sf-icon-btn,
.po-viewer-dialog .iffys-sf-icon-btn,
.po-onorder-dialog .iffys-sf-icon-btn,
.po-viewer-side-card .iffys-sf-icon-btn {
    width: 2.1rem !important;
    height: 2.1rem !important;
    min-height: 2.1rem !important;
    padding: 0 !important;
    border: 1px solid #c5d0de !important;
    background: #fff !important;
    color: #0f4c75 !important;
    border-radius: 7px !important;
    font-size: 0.95rem !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

.purchasing-page .iffys-sf-icon-btn:hover:not(:disabled),
.po-viewer-dialog .iffys-sf-icon-btn:hover:not(:disabled),
.po-onorder-dialog .iffys-sf-icon-btn:hover:not(:disabled),
.po-viewer-side-card .iffys-sf-icon-btn:hover:not(:disabled) {
    background: #eaf1f8 !important;
    border-color: #9db0c7 !important;
    color: #03142e !important;
}

.purchasing-page .iffys-sf-icon-btn--danger,
.po-viewer-dialog .iffys-sf-icon-btn--danger,
.po-viewer-side-card .iffys-sf-icon-btn--danger {
    color: #991b1b !important;
    border-color: #fecaca !important;
}

.purchasing-page .iffys-sf-icon-btn--danger:hover:not(:disabled),
.po-viewer-dialog .iffys-sf-icon-btn--danger:hover:not(:disabled),
.po-viewer-side-card .iffys-sf-icon-btn--danger:hover:not(:disabled) {
    background: #fef2f2 !important;
    border-color: #f87171 !important;
}

.purchasing-page .iffys-sf-icon-btn:disabled,
.po-viewer-dialog .iffys-sf-icon-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.purchasing-page .iffys-sf-actions,
.po-viewer-dialog .iffys-sf-actions {
    gap: 0.3rem;
}

.purchasing-grid-host {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.purchasing-grid-host .iffys-sf-grid-host {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    border: none;
    border-radius: 0;
}

.purchasing-grid-host .ent-table-empty {
    padding: 1.5rem;
}

.po-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 4.5rem;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
}

.po-badge--open {
    background: #dbeafe;
    color: #1e3a8a;
}

.po-badge--ordered {
    background: #dcfce7;
    color: #166534;
}

.po-viewer-dialog.e-dialog,
.feature-dialog.po-viewer-dialog.e-dialog {
    width: 90vw !important;
    max-width: 90vw !important;
}

.po-viewer-dialog .e-dlg-content,
.po-viewer-dialog .feature-scroll {
    min-width: 0;
}

.po-viewer-main .iffys-sf-grid-host .e-gridcontent,
.po-viewer-main .e-grid .e-content {
    overflow-x: auto !important;
}

.po-viewer-scroll {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    overflow: hidden !important;
    max-height: none;
    height: 100%;
}

.po-viewer-hero {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.65rem;
    align-items: center;
    padding: 0.35rem 0.45rem 0.35rem 0.55rem;
    background: linear-gradient(90deg, #03142e, #0f4c75);
    color: #fff;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 700;
}

.po-viewer-hero__stats {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.45rem 0.85rem;
    align-items: center;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

.po-viewer-hero__stat {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    min-width: 0;
}

.po-viewer-hero__filters {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.35rem;
    flex: 0 0 auto;
    margin-left: auto;
    padding: 0.22rem 0.3rem;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    white-space: nowrap;
}

.po-viewer-hero__search,
.po-viewer-hero__filters .purchasing-page__search {
    min-width: 13.5rem;
    width: 15rem;
    min-height: 2rem;
    height: 2rem;
    padding: 0 0.55rem;
    border: none;
    background: #fff;
    color: #0f172a;
}

.po-viewer-hero__stat span {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.72;
}

.po-viewer-hero__stat b {
    font-size: 0.88rem;
}

.po-viewer-hero .po-badge {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.po-viewer-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

.po-viewer-body {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(252px, 294px) minmax(0, 1fr);
    gap: 0.6rem;
}

.po-viewer-side {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.po-viewer-side-card {
    flex: 1 1 0;
    min-height: 0;
    border: 1px solid #dbe3ee;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.po-viewer-side-card h4 {
    margin: 0;
    padding: 0.35rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 800;
    color: #fff;
    background: #03142e;
}

.po-viewer-side-card .iffys-sf-grid-host,
.po-viewer-main .iffys-sf-grid-host {
    flex: 1 1 auto;
    min-height: 0;
    border: none;
    border-radius: 0;
}

.po-viewer-main {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid #dbe3ee;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.po-viewer-charts {
    display: grid;
    grid-template-columns: minmax(231px, 294px) minmax(0, 1fr);
    gap: 0.5rem;
}

.po-viewer-chart {
    min-height: 128px;
    border: 1px solid #dbe3ee;
    border-radius: 8px;
    background: #fff;
    padding: 0.2rem 0.35rem 0;
}

.po-viewer-chart__title {
    font-size: 0.72rem;
    font-weight: 800;
    color: #03142e;
    padding: 0.2rem 0.35rem 0;
}

.po-viewer-selected {
    font-size: 0.8rem;
    font-weight: 700;
    color: #334155;
}

.po-viewer-img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 4px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.po-viewer-num {
    width: 4.4rem;
    min-height: 1.85rem;
    text-align: right;
    padding: 0.15rem 0.3rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.8125rem;
}

.po-viewer-num--key {
    width: 5.4rem;
    min-height: 2.15rem;
    padding: 0.2rem 0.4rem;
    font-size: 1rem;
    font-weight: 800;
    color: #03142e;
    background: #fde68a;
    border: 1.5px solid #d97706;
    border-radius: 6px;
}

.po-viewer-num--key:focus {
    outline: 2px solid #b45309;
    outline-offset: 1px;
    background: #fcd34d;
}

.po-viewer-key-text {
    display: inline-flex;
    min-width: 4.8rem;
    justify-content: flex-end;
    padding: 0.2rem 0.45rem;
    font-size: 1rem;
    font-weight: 800;
    color: #03142e;
    background: #fde68a;
    border: 1.5px solid #d97706;
    border-radius: 6px;
}

.po-viewer-total {
    margin-right: auto;
    font-weight: 800;
    font-size: 0.98rem;
    color: #03142e;
}

.po-viewer-dialog > .e-footer-content {
    background: #fde68a !important;
    border-top: 2px solid #d97706 !important;
    justify-content: flex-end !important;
}

.po-viewer-subtotals {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: flex-end;
    gap: 1.35rem;
    width: 100%;
    color: #03142e;
}

.po-viewer-subtotals span {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
}

.po-viewer-subtotals em {
    font-style: normal;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #92400e;
}

.po-viewer-subtotals b {
    font-size: 1.15rem;
    font-weight: 800;
    color: #03142e;
}

.po-viewer-dialog .ent-cmdbar__btn--ok {
    background: #166534;
    border-color: #166534;
    color: #fff;
}

.po-viewer-dialog .ent-cmdbar__btn--ok:hover:not(:disabled) {
    background: #15803d;
    border-color: #15803d;
    color: #fff;
}

.po-viewer-hero__filters .po-viewer-toggle {
    min-height: 2rem;
    padding: 0 0.55rem;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 6px;
    background: rgba(3, 20, 46, 0.28);
    color: #fff;
}

.po-viewer-hero__filters .ent-cmdbar__btn {
    min-height: 2rem;
    background: #fff;
    border-color: #c5d0de;
    color: #03142e;
    font-weight: 800;
    font-size: 0.8125rem;
}

.po-viewer-hero__filters .ent-cmdbar__btn--primary {
    background: #0f766e;
    border-color: #0f766e;
    color: #fff;
}

.po-viewer-hero__filters .ent-cmdbar__btn--ok {
    background: #166534;
    border-color: #166534;
    color: #fff;
}

.po-viewer-hero__filters .ent-cmdbar__btn--refresh {
    width: 2rem;
    padding: 0;
    background: rgba(3, 20, 46, 0.28);
    border-color: rgba(255, 255, 255, 0.28);
    color: #fff;
}

.po-viewer-hero__filters .ent-cmdbar__btn--refresh:hover:not(:disabled) {
    background: rgba(3, 20, 46, 0.5);
    color: #fff;
}

.po-group-row.is-active td {
    background: #dbeafe !important;
}

.po-onorder-link {
    border: none;
    background: none;
    padding: 0;
    color: #0f4c75;
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 0.15em;
    cursor: pointer;
}

.po-onorder-link:hover {
    color: #03142e;
}

.po-onorder-dialog.e-dialog,
.feature-dialog.po-onorder-dialog.e-dialog {
    width: min(820px, calc(100vw - 1.25rem)) !important;
    height: min(72vh, calc(100dvh - 1rem)) !important;
    max-height: min(72vh, calc(100dvh - 1rem)) !important;
}

.po-onorder-scroll {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: none;
    height: 100%;
}

.po-onorder-desc {
    font-size: 0.82rem;
    font-weight: 700;
    color: #334155;
}

.po-onorder-dialog .ent-table-host {
    flex: 1 1 auto;
    min-height: 0;
}

@media (max-width: 1400px) {
    .purchasing-split {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    }
}

@media (max-width: 1180px) {
    .purchasing-top {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1100px) {
    .po-viewer-body,
    .po-viewer-charts {
        grid-template-columns: 1fr;
    }

    .po-viewer-side {
        flex-direction: row;
        min-height: 12rem;
    }
}
