/* =====================================================
   H N Builders | Dynamic Purchase Reports
   CakePHP 2.x
===================================================== */

.purchase-report {
    --pr-primary: #4263eb;
    --pr-text: #25334b;
    --pr-muted: #8591a5;
    --pr-border: #e7ecf4;
    --pr-bg: #f5f7fb;

    padding: 22px;
    min-height: 100vh;
    background: var(--pr-bg);
    color: var(--pr-text);
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 13px;
    line-height: 1.55;
}

.purchase-report *,
.purchase-report *::before,
.purchase-report *::after {
    box-sizing: border-box;
}

.purchase-report a {
    text-decoration: none;
}

.pr-topbar,
.pr-heading,
.pr-topright,
.pr-actions,
.pr-section-heading,
.pr-panel-head,
.pr-table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.pr-topbar {
    min-height: 40px;
    margin-bottom: 25px;
}

.pr-crumb {
    color: #8793a7;
    font-size: 12px;
}

.pr-crumb span {
    padding: 0 8px;
    color: #c2cad7;
}

.pr-crumb strong {
    color: #34425b;
}

.pr-topright {
    justify-content: flex-end;
}

.pr-pill {
    padding: 8px 12px;
    border: 1px solid var(--pr-border);
    border-radius: 8px;
    background: #fff;
    color: #63718a;
    font-size: 11px;
    white-space: nowrap;
}

.pr-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e6edff;
    color: #355bc2;
    font-weight: 800;
}

.pr-heading {
    align-items: flex-end;
    margin-bottom: 25px;
}

.pr-eyebrow {
    margin-bottom: 7px;
    color: #5274dc;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 2px;
}

.pr-heading h1 {
    margin: 0 0 7px;
    color: #1e2d45;
    font-size: clamp(22px, 2.2vw, 30px);
    font-weight: 800;
    letter-spacing: -.6px;
    line-height: 1.25;
}

.pr-heading p {
    margin: 0;
    color: #8490a4;
    font-size: 12px;
}

.pr-actions {
    flex-shrink: 0;
}

.pr-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 39px;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: 7px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: .18s ease;
}

.pr-btn:hover {
    transform: translateY(-1px);
}

.pr-btn-primary {
    border-color: #4263eb;
    background: #4263eb;
    color: #fff !important;
}

.pr-btn-primary:hover {
    border-color: #304fcd;
    background: #304fcd;
}

.pr-btn-light {
    border-color: #dfe5ef;
    background: #fff;
    color: #52617a !important;
}

.pr-btn-light:hover {
    background: #f2f5fb;
}

.pr-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 6px;
    margin-bottom: 20px;
    border: 1px solid var(--pr-border);
    border-radius: 10px;
    background: #fff;
}

.pr-tab {
    display: inline-flex;
    align-items: center;
    padding: 10px 15px;
    border-radius: 7px;
    color: #758197;
    font-size: 12px;
    font-weight: 650;
    transition: .18s ease;
}

.pr-tab:hover {
    background: #f2f5ff;
    color: #355bd1;
}

.pr-tab.active {
    background: #4263eb;
    color: #fff;
    box-shadow: 0 3px 9px rgba(66, 99, 235, .18);
}

.pr-filter-card {
    padding: 19px;
    margin-bottom: 25px;
    border: 1px solid var(--pr-border);
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 3px 12px rgba(27, 45, 78, .025);
}

.pr-filter-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
    align-items: end;
    gap: 13px;
}

.pr-field {
    min-width: 0;
}

.pr-field label {
    display: block;
    margin-bottom: 7px;
    color: #78859a;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .7px;
}

.pr-field input,
.pr-field select {
    display: block;
    width: 100%;
    height: 41px;
    padding: 8px 10px;
    border: 1px solid #dfe5ef;
    border-radius: 7px;
    outline: none;
    background: #fff;
    color: #34435a;
    font-family: inherit;
    font-size: 12px;
}

.pr-field input:focus,
.pr-field select:focus {
    border-color: #7592f5;
    box-shadow: 0 0 0 3px rgba(66, 99, 235, .09);
}

.pr-filter-buttons {
    display: flex;
    align-items: center;
    gap: 7px;
}

.pr-section-heading {
    margin-bottom: 17px;
}

.pr-section-heading h2 {
    margin: 0 0 4px;
    color: #26364e;
    font-size: 19px;
    font-weight: 800;
}

.pr-section-heading p {
    margin: 0;
    color: #8b96a8;
    font-size: 11px;
}

.pr-count {
    padding: 7px 11px;
    border-radius: 20px;
    background: #eaf0ff;
    color: #3f5dc4;
    font-size: 11px;
    font-weight: 750;
    white-space: nowrap;
}

.pr-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.pr-kpi {
    position: relative;
    overflow: hidden;
    min-width: 0;
    padding: 20px;
    border: 1px solid var(--pr-border);
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 3px 12px rgba(27, 45, 78, .025);
}

.pr-kpi::before {
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent);
    content: "";
}

.pr-kpi-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 15px;
    color: #748198;
    font-size: 12px;
    font-weight: 650;
}

.pr-kpi-head span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--soft);
    color: var(--accent);
    font-size: 16px;
    font-weight: 800;
}

.pr-kpi h3 {
    margin: 0;
    overflow-wrap: anywhere;
    color: #25344b;
    font-size: clamp(18px, 1.7vw, 25px);
    font-weight: 800;
    letter-spacing: -.5px;
    line-height: 1.35;
}

.pr-kpi p {
    margin: 12px 0 0;
    color: #97a1b2;
    font-size: 11px;
}

.pr-panels {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
    gap: 17px;
    margin-bottom: 22px;
}

.pr-panel {
    min-width: 0;
    overflow: hidden;
    margin-bottom: 22px;
    border: 1px solid var(--pr-border);
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 3px 12px rgba(27, 45, 78, .025);
}

.pr-panels .pr-panel {
    margin-bottom: 0;
}

.pr-panel-head {
    padding: 19px 21px;
    border-bottom: 1px solid #edf0f6;
}

.pr-panel-head h3 {
    margin: 0 0 4px;
    color: #293850;
    font-size: 15px;
    font-weight: 800;
}

.pr-panel-head p {
    margin: 0;
    color: #929db0;
    font-size: 11px;
}

.pr-small-label {
    padding: 6px 9px;
    border: 1px solid #e6eaf2;
    border-radius: 6px;
    color: #718099;
    background: #fafbfe;
    font-size: 10px;
    white-space: nowrap;
}

.pr-chart {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr);
    height: 270px;
    padding: 18px 20px 10px;
}

.pr-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0 10px 24px 0;
    color: #929db0;
    font-size: 9px;
    text-align: right;
}

.pr-bars {
    position: relative;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    gap: 9px;
    min-width: 0;
    padding: 0 2px 25px;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 24%,
        #edf1f7 25%,
        transparent 25.5%
    );
    border-bottom: 1px solid #e5eaf2;
}

.pr-bar-wrap {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    height: 100%;
}

.pr-bar {
    width: min(70%, 32px);
    min-height: 2px;
    border-radius: 5px 5px 0 0;
    background: linear-gradient(180deg, #6381f4, #4263eb);
    transition: opacity .2s ease;
}

.pr-bar:hover {
    opacity: .7;
}

.pr-bar.teal {
    background: linear-gradient(180deg, #40d3be, #12a995);
}

.pr-bar-wrap span {
    position: absolute;
    bottom: 4px;
    overflow: hidden;
    max-width: 14%;
    color: #8490a5;
    font-size: 9px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pr-donut-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    min-height: 270px;
    padding: 22px;
}

.pr-donut {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 155px;
    height: 155px;
    border-radius: 50%;
}

.pr-donut-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 105px;
    height: 105px;
    padding: 7px;
    border-radius: 50%;
    background: #fff;
    text-align: center;
}

.pr-donut-center b {
    max-width: 100%;
    overflow-wrap: anywhere;
    color: #293750;
    font-size: 14px;
    font-weight: 800;
}

.pr-donut-center small {
    margin-top: 4px;
    color: #929db0;
    font-size: 10px;
}

.pr-legend {
    flex: 1;
    min-width: 0;
}

.pr-legend-row {
    display: grid;
    grid-template-columns: 9px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
    color: #66738a;
    font-size: 10px;
}

.pr-legend-row i {
    width: 8px;
    height: 8px;
    border-radius: 3px;
}

.pr-legend-row span {
    overflow-wrap: anywhere;
}

.pr-legend-row strong {
    color: #34425b;
    font-size: 10px;
}

.pr-table-panel {
    margin-bottom: 22px;
}

.pr-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.pr-table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
    border-spacing: 0;
}

.pr-table th,
.pr-table td {
    padding: 13px 15px;
    border-bottom: 1px solid #edf0f5;
    text-align: left;
    vertical-align: middle;
    font-size: 11px;
}

.pr-table thead th {
    background: #fafbfe;
    color: #8390a5;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .65px;
    white-space: nowrap;
}

.pr-table tbody td {
    color: #596780;
}

.pr-table tbody tr:hover {
    background: #f8faff;
}

.pr-table tbody tr:last-child td {
    border-bottom: 1px solid #edf0f5;
}

.pr-table tbody td strong {
    color: #34435a;
    font-weight: 700;
}

.pr-table td small {
    display: block;
    margin-top: 3px;
    color: #9aa4b5;
    font-size: 9px;
}

.pr-table tfoot th {
    padding: 14px 15px;
    border: 0;
    background: #f7f9fd;
    color: #2c3b53;
    font-size: 10px;
    font-weight: 800;
}

.pr-amount {
    color: #2c3d5a !important;
    font-weight: 750;
    white-space: nowrap;
}

.pr-positive {
    color: #109477 !important;
    font-weight: 650;
    white-space: nowrap;
}

.pr-negative {
    color: #d18a24 !important;
    font-weight: 650;
    white-space: nowrap;
}

.pr-invoice {
    display: inline-block;
    padding: 5px 7px;
    border-radius: 5px;
    background: #edf2ff;
    color: #4263bd;
    font-size: 10px;
    font-weight: 750;
    white-space: nowrap;
}

.pr-supplier {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 140px;
    color: #475670;
    font-weight: 650;
}

.pr-supplier-icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 29px;
    height: 29px;
    border-radius: 8px;
    background: #eaf0ff;
    color: #4263eb;
    font-size: 11px;
    font-weight: 800;
}

.pr-status {
    display: inline-block;
    padding: 5px 8px;
    border-radius: 20px;
    font-size: 9px;
    font-weight: 750;
    white-space: nowrap;
}

.pr-status.paid {
    background: #e3faf2;
    color: #10866b;
}

.pr-status.partial {
    background: #fff3df;
    color: #c17c14;
}

.pr-status.due {
    background: #ffe9e7;
    color: #cb5148;
}

.pr-table-footer {
    flex-wrap: wrap;
    padding: 13px 17px;
    color: #919caf;
    font-size: 10px;
}

.pr-empty {
    padding: 32px 14px !important;
    color: #8e9aaf !important;
    text-align: center !important;
}

.pr-notice {
    margin-bottom: 18px;
    padding: 14px 17px;
    border: 1px solid #f1dfb2;
    border-radius: 8px;
    background: #fff8e8;
    color: #75551b;
    font-size: 11px;
}

.pr-notice code {
    padding: 2px 4px;
    border-radius: 3px;
    background: rgba(255, 255, 255, .8);
}

.pr-footnote {
    padding: 13px 17px;
    border-top: 1px solid #edf0f5;
    color: #8995a8;
    font-size: 10px;
}

.pr-footer {
    padding: 10px 0 3px;
    color: #9aa5b6;
    font-size: 9px;
    letter-spacing: .3px;
    text-align: center;
}

/* Responsive */
@media (max-width: 1200px) {
    .pr-filter-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pr-filter-buttons {
        grid-column: 1 / -1;
    }

    .pr-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pr-panels {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .purchase-report {
        padding: 12px;
    }

    .pr-topbar {
        align-items: flex-start;
    }

    .pr-topright {
        gap: 6px;
    }

    .pr-pill {
        display: none;
    }

    .pr-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .pr-actions {
        width: 100%;
    }

    .pr-actions .pr-btn {
        flex: 1;
    }

    .pr-tabs {
        gap: 3px;
    }

    .pr-tab {
        padding: 9px 10px;
        font-size: 10px;
    }

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

    .pr-filter-buttons {
        grid-column: auto;
    }

    .pr-filter-buttons .pr-btn {
        flex: 1;
    }

    .pr-section-heading {
        align-items: flex-start;
    }

    .pr-kpis {
        grid-template-columns: 1fr;
        gap: 11px;
    }

    .pr-kpi {
        padding: 17px;
    }

    .pr-kpi h3 {
        font-size: 22px;
    }

    .pr-panel-head {
        align-items: flex-start;
        padding: 15px;
    }

    .pr-chart {
        grid-template-columns: 55px minmax(0, 1fr);
        height: 230px;
        padding: 15px 10px 8px;
    }

    .pr-axis {
        font-size: 8px;
    }

    .pr-bars {
        gap: 4px;
    }

    .pr-bar {
        width: 65%;
    }

    .pr-donut-area {
        flex-direction: column;
        gap: 12px;
        padding: 18px;
    }

    .pr-legend {
        width: 100%;
    }

    .pr-legend-row {
        font-size: 11px;
    }
}

/* Print */
@media print {
    @page {
        size: landscape;
        margin: 10mm;
    }

    body {
        background: #fff !important;
    }

    .purchase-report {
        min-height: 0;
        padding: 0;
        background: #fff !important;
        color: #111;
        font-size: 10px;
    }

    .no-print,
    .pr-tabs,
    .pr-filter-card,
    .pr-actions {
        display: none !important;
    }

    .pr-topbar {
        margin-bottom: 10px;
    }

    .pr-heading {
        margin-bottom: 12px;
    }

    .pr-heading h1 {
        font-size: 20px;
    }

    .pr-kpis {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 8px;
    }

    .pr-kpi,
    .pr-panel {
        box-shadow: none;
        break-inside: avoid;
    }

    .pr-kpi {
        padding: 11px;
    }

    .pr-kpi h3 {
        font-size: 15px;
    }

    .pr-panels {
        grid-template-columns: 1.3fr 1fr;
        gap: 10px;
    }

    .pr-chart {
        height: 210px;
    }

    .pr-table-wrap {
        overflow: visible;
    }

    .pr-table {
        min-width: 0;
    }

    .pr-table th,
    .pr-table td {
        padding: 7px 5px;
        font-size: 8px;
    }

    .pr-table thead {
        display: table-header-group;
    }

    .pr-table tr {
        break-inside: avoid;
    }

    .pr-status,
    .pr-invoice {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .pr-footer {
        margin-top: 10px;
    }
}