.purchases-page {
    min-height: 100%;
    width: 100%;
    max-width: 1680px;
    margin-inline: auto;
    padding: clamp(14px, 2vw, 26px);
    background: #eef5ff;
    direction: rtl;
}

.pd-header,
.pd-actions,
.pd-panel-head,
.pd-alert,
.pd-quick-link {
    display: flex;
    align-items: center;
}

.pd-header {
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.pd-header > div:first-child {
    min-width: 260px;
    flex: 1 1 380px;
}

.pd-title {
    margin: 0;
    color: #132144;
    font-size: clamp(1.55rem, 3vw, 2.5rem);
    font-weight: 900;
    line-height: 1.15;
}

.pd-subtitle {
    margin: 8px 0 0;
    color: #475569;
}

.pd-actions {
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.pd-actions .btn,
.pd-actions .form-select,
.pd-date-pill {
    min-height: 50px;
    border-radius: 15px;
}

.pd-actions .btn {
    gap: 8px;
}

.pd-actions .form-select {
    width: 150px;
}

.pd-date-pill {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px 15px;
    color: #334155;
    background: #fff;
    border: 1px solid rgba(99, 102, 241, .16);
    box-shadow: 0 10px 24px rgba(15, 23, 42, .06);
}

.pd-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 20px;
}

.pd-kpi-card,
.pd-panel {
    background: #fff;
    border: 1px solid rgba(148, 163, 184, .16);
    border-radius: 24px;
    box-shadow: 0 18px 46px rgba(15, 23, 42, .05);
}

.pd-kpi-card {
    min-width: 0;
    padding: clamp(16px, 2vw, 22px);
}

.pd-kpi-card span,
.pd-kpi-card small {
    display: block;
    color: #64748b;
}

.pd-kpi-card strong {
    display: block;
    margin-top: 8px;
    color: #0f172a;
    font-size: clamp(1.45rem, 2.4vw, 2rem);
    font-weight: 900;
    overflow-wrap: anywhere;
}

.pd-kpi-card small {
    margin-top: 8px;
}

.pd-kpi-accent {
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #6366f1);
}

.pd-kpi-accent span,
.pd-kpi-accent strong,
.pd-kpi-accent small {
    color: #fff;
}

.pd-panel {
    overflow: hidden;
    min-width: 0;
}

.pd-quick-panel {
    margin-bottom: 18px;
}

.pd-panel-head {
    justify-content: space-between;
    gap: 12px;
    padding: clamp(14px, 2vw, 18px) clamp(14px, 2vw, 20px);
    border-bottom: 1px solid rgba(148, 163, 184, .12);
    flex-wrap: wrap;
}

.pd-panel-head h5,
.pd-panel-head p {
    margin: 0;
}

.pd-panel-head h5 {
    color: #0f172a;
    font-weight: 800;
}

.pd-panel-head p {
    margin-top: 4px;
    color: #64748b;
    font-size: .9rem;
}

.pd-panel-head a {
    color: #2563eb;
    font-size: .85rem;
    font-weight: 800;
    text-decoration: none;
}

.pd-chip {
    padding: 6px 11px;
    color: #475569;
    background: #f1f5f9;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 800;
}

.pd-quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    padding: 18px 20px 20px;
}

.pd-quick-link {
    min-height: 62px;
    gap: 13px;
    padding: 15px;
    color: #0f172a;
    background: #f8fbff;
    border: 1px solid rgba(148, 163, 184, .18);
    border-radius: 18px;
    font-weight: 700;
    text-decoration: none;
    transition: .18s ease;
}

.pd-quick-link:hover {
    color: #0f172a;
    background: #eef4ff;
    border-color: rgba(96, 165, 250, .3);
    transform: translateY(-2px);
    box-shadow: 0 18px 30px rgba(99, 102, 241, .08);
}

.pd-quick-link i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    color: #2563eb;
    background: rgba(37, 99, 235, .12);
    border-radius: 14px;
    font-size: 1.2rem;
}

.pd-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 18px;
}

.pd-span-12 { grid-column: span 12; }
.pd-span-7 { grid-column: span 7; }
.pd-span-5 { grid-column: span 5; }
.pd-span-4 { grid-column: span 4; }

.pd-alert-grid,
.pd-document-list,
.pd-supplier-ranking,
.pd-mini-chart {
    display: grid;
    gap: 10px;
    padding: 18px 20px 20px;
}

.pd-alert {
    gap: 12px;
    padding: 12px;
    color: inherit;
    background: #f8fbff;
    border: 1px solid rgba(148, 163, 184, .16);
    border-radius: 16px;
    text-decoration: none;
}

.pd-alert i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    font-size: 1.15rem;
}

.pd-alert div {
    flex: 1;
}

.pd-alert strong,
.pd-alert small {
    display: block;
}

.pd-alert strong {
    color: #0f172a;
}

.pd-alert small {
    margin-top: 3px;
    color: #64748b;
}

.pd-alert em {
    min-width: 34px;
    padding: 6px 9px;
    color: #fff;
    background: #132144;
    border-radius: 10px;
    font-style: normal;
    font-weight: 800;
    text-align: center;
}

.pd-alert-warning { color: #b45309; background: #fef3c7; }
.pd-alert-danger { color: #b91c1c; background: #fee2e2; }
.pd-alert-info { color: #1d4ed8; background: #dbeafe; }

.pd-financial-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 18px 20px 8px;
}

.pd-financial-grid div {
    padding: 14px;
    background: #f8fafc;
    border: 1px solid #eef2f7;
    border-radius: 16px;
}

.pd-financial-grid span,
.pd-financial-grid strong {
    display: block;
}

.pd-financial-grid span {
    color: #64748b;
    font-size: .8rem;
}

.pd-financial-grid strong {
    margin-top: 7px;
    color: #0f172a;
    font-size: 1.15rem;
    font-weight: 900;
}

.pd-financial-grid .pd-financial-accent {
    background: #132144;
}

.pd-financial-accent span,
.pd-financial-accent strong {
    color: #fff;
}

.chart-row {
    display: grid;
    grid-template-columns: 72px 1fr 82px;
    gap: 8px;
    align-items: center;
    direction: ltr;
    font-size: .75rem;
}

.chart-track,
.supplier-bar {
    height: 9px;
    overflow: hidden;
    background: #e2e8f0;
    border-radius: 999px;
}

.chart-fill,
.supplier-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #2563eb, #60a5fa);
}

.chart-value,
.supplier-total {
    color: #0f172a;
    font-weight: 800;
    text-align: end;
}

.pd-flow {
    display: grid;
    grid-template-columns: minmax(110px, 1fr) 32px minmax(110px, 1fr) 32px minmax(110px, 1fr) 32px minmax(110px, 1fr) 32px minmax(110px, 1fr);
    align-items: center;
    gap: 8px;
    padding: 22px 20px 24px;
}

.pd-flow div {
    min-width: 0;
    text-align: center;
}

.pd-flow i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    margin: 0 auto 8px;
    color: #2563eb;
    background: #eff6ff;
    border-radius: 17px;
    font-size: 1.35rem;
}

.pd-flow strong,
.pd-flow span,
.pd-flow small {
    display: block;
}

.pd-flow strong {
    color: #0f172a;
    font-size: 1.3rem;
    font-weight: 900;
}

.pd-flow span {
    color: #334155;
    font-weight: 800;
}

.pd-flow small {
    color: #64748b;
    font-size: .72rem;
}

.pd-flow b {
    width: 100%;
    height: 2px;
    background: #dbeafe;
}

.pd-table {
    direction: rtl;
    min-width: 760px;
}

.pd-table th,
.pd-table td {
    padding: 12px 14px;
}

.pd-table th {
    color: #64748b;
    font-size: .78rem;
}

.pd-table a,
.document-card a {
    color: #2563eb;
    font-weight: 800;
    text-decoration: none;
}

.supplier-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 82px;
    gap: 10px;
    direction: ltr;
}

.supplier-name {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    color: #0f172a;
    font-size: .82rem;
    font-weight: 800;
}

.supplier-name small {
    color: #64748b;
}

.document-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px;
    background: #f8fbff;
    border: 1px solid rgba(148, 163, 184, .16);
    border-radius: 15px;
}

.document-card > div:first-child {
    min-width: 0;
}

.document-card a,
.document-card small {
    overflow-wrap: anywhere;
}

.document-card small {
    display: block;
    margin-top: 3px;
    color: #64748b;
    font-size: .75rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    color: #475569;
    background: #e2e8f0;
    font-size: .68rem;
    font-weight: 800;
}

.status-DRAFT,
.status-NONE,
.status-NOT_RECEIVED,
.status-NOT_INVOICED { color: #075985; background: #e0f2fe; }
.status-SUBMITTED,
.status-PARTIAL,
.status-SENT,
.status-PRICED { color: #92400e; background: #fef3c7; }
.status-APPROVED,
.status-POSTED,
.status-FULL,
.status-CLOSED { color: #166534; background: #dcfce7; }
.status-REJECTED,
.status-CANCELLED { color: #991b1b; background: #fee2e2; }

.empty-state {
    padding: 18px;
    color: #64748b;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 15px;
    text-align: center;
}

@media (max-width: 1200px) {
    .pd-span-7,
    .pd-span-5,
    .pd-span-4 { grid-column: span 12; }
}

@media (max-width: 1024px) {
    .purchases-page {
        padding-top: 58px;
    }

    .pd-header {
        align-items: stretch;
    }

    .pd-actions {
        width: 100%;
        justify-content: stretch;
    }

    .pd-actions .btn,
    .pd-actions .form-select,
    .pd-date-pill {
        flex: 1 1 180px;
    }
}

@media (max-width: 900px) {
    .pd-flow {
        grid-template-columns: 1fr;
    }

    .pd-flow b {
        width: 2px;
        height: 18px;
        justify-self: center;
    }

    .pd-alert-grid,
    .pd-document-list,
    .pd-supplier-ranking,
    .pd-mini-chart {
        padding: 14px;
    }

    .pd-financial-grid {
        grid-template-columns: 1fr;
        padding: 14px;
    }
}

@media (max-width: 600px) {
    .purchases-page {
        padding-inline: 10px;
        padding-bottom: 14px;
    }

    .pd-kpis,
    .pd-quick-grid,
    .pd-financial-grid { grid-template-columns: 1fr; }

    .pd-actions .btn,
    .pd-actions .form-select,
    .pd-date-pill {
        flex-basis: 100%;
        width: 100%;
        min-height: 44px;
    }

    .pd-panel,
    .pd-kpi-card {
        border-radius: 18px;
    }

    .pd-quick-link,
    .pd-alert,
    .document-card {
        border-radius: 14px;
    }

    .pd-alert {
        align-items: flex-start;
    }

    .pd-alert em {
        align-self: center;
    }

    .document-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .chart-row {
        grid-template-columns: 58px 1fr 72px;
    }
}

@media (min-width: 1600px) {
    .pd-kpis {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}
