/* ===== Purchases & Suppliers pages ===== */

.pur-overview {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.pur-overview-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pur-panel {
    margin-bottom: 24px;
    padding: 22px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.pur-panel[hidden] {
    display: none;
}

.pur-panel h3 {
    margin-bottom: 6px;
    font-size: 19px;
    color: #173d2c;
}

.pur-panel > p,
.pur-toolbar p {
    margin-bottom: 14px;
    color: var(--muted);
}

/* Buttons */

.pur-btn {
    padding: 11px 18px;
    border: 1px solid #176b45;
    border-radius: 9px;
    background: #176b45;
    color: #ffffff;
    font-weight: 650;
    white-space: nowrap;
}

.pur-btn:hover {
    background: #105638;
}

.pur-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.pur-btn-light {
    background: #ffffff;
    color: #176b45;
}

.pur-btn-light:hover {
    background: #e8f4ec;
}

/* Inputs */

.pur-page input,
.pur-page select {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid #d8e1db;
    border-radius: 9px;
    background: #fbfcfb;
    color: var(--text);
    font: inherit;
}

.pur-page input:focus,
.pur-page select:focus {
    outline: none;
    border-color: #258458;
    box-shadow: 0 0 0 3px rgba(37, 132, 88, 0.12);
}

/* Toolbar */

.pur-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}

.pur-filters {
    display: flex;
    gap: 10px;
}

.pur-filters input[type="search"] {
    width: 240px;
}

.pur-filters input[type="date"] {
    width: 150px;
}

/* Tables (app.css ki 950px width yahan kam ki) */

.pur-table {
    min-width: 720px;
}

.pur-due {
    color: #dc2626;
    font-weight: 700;
}

/* Form */

.pur-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.pur-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.pur-field label {
    font-size: 13px;
    font-weight: 650;
    color: #43564a;
}

.pur-inline {
    display: flex;
    gap: 8px;
}

.pur-subheading {
    margin: 6px 0 10px;
    font-size: 15px;
}

.pur-item {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fafcfb;
}

.pur-item-main {
    display: grid;
    grid-template-columns: minmax(0, 2fr) 90px 110px 120px 40px;
    gap: 10px;
    align-items: center;
}

.pur-line {
    font-weight: 700;
    text-align: right;
}

.pur-remove {
    width: 40px;
    height: 40px;
    border: 1px solid #f2d0d0;
    border-radius: 9px;
    background: #fff0f0;
    color: #b4232f;
}

.pur-newbook {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}

.pur-newbook[hidden] {
    display: none;
}

.pur-totals {
    margin-top: 18px;
}

.pur-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin: 12px 0;
    font-size: 15px;
}

.pur-summary p {
    margin: 0;
}

.pur-actions {
    display: flex;
    gap: 10px;
}

.pur-message {
    min-height: 18px;
    margin: 10px 0 0;
    color: #176b45;
    font-size: 13px;
}

.pur-message.error {
    color: #b42323;
}

/* Mobile */

@media (max-width: 768px) {
    .pur-overview {
        gap: 8px;
    }

    .pur-overview .stat-card {
        padding: 12px 8px;
        text-align: center;
    }

    .pur-overview .stat-card p {
        font-size: 11px;
        line-height: 1.3;
    }

    .pur-overview .stat-card h4 {
        font-size: 16px;
    }

    .pur-panel {
        padding: 14px;
    }

    .pur-toolbar {
        flex-direction: column;
    }

    .pur-filters {
        flex-direction: column;
        width: 100%;
    }

    .pur-filters input[type="search"],
    .pur-filters input[type="date"] {
        width: 100%;
    }

    .pur-form-grid {
        grid-template-columns: 1fr;
    }

    .pur-item-main {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .pur-item-main .pur-book {
        grid-column: 1 / -1;
    }

    .pur-newbook {
        grid-template-columns: 1fr;
    }

    .topbar .pur-btn {
        width: 100%;
    }
}
/* Stat cards ke labels hamesha ek line mein */
.pur-overview .stat-card p {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .pur-overview .stat-card {
        padding: 12px 4px;
    }

    .pur-overview .stat-card p {
        font-size: 10px;
        letter-spacing: 0;
        line-height: 1.2;
    }
}

@media (max-width: 360px) {
    .pur-overview .stat-card p {
        font-size: 9px;
    }
}
/* ===== Book search picker (Purchases form) ===== */

.pur-picker {
    position: relative;
    min-width: 0;
}

.pur-picker-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.pur-picker-row .pur-search-input {
    flex: 1;
    min-width: 0;
}

.pur-new-book {
    flex: none;
    width: auto;
    padding: 0 14px;
    min-height: 42px;
}

.pur-search-input.pur-selected {
    border-color: #258458;
    background: #eef7f1;
    font-weight: 600;
}

.pur-search-input:disabled {
    background: #f1f4f2;
    cursor: not-allowed;
}

.pur-results {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 30;
    max-height: 280px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #d8e1db;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(16, 60, 40, 0.16);
}

.pur-results[hidden] {
    display: none;
}

.pur-result {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid #eef2ef;
    background: #ffffff;
    text-align: left;
    cursor: pointer;
}

.pur-result:last-child {
    border-bottom: 0;
}

.pur-result:hover,
.pur-result:focus {
    background: #e8f4ec;
    outline: none;
}

.pur-result strong {
    color: #173d2c;
    font-size: 14px;
}

.pur-result span {
    color: var(--muted);
    font-size: 12px;
}

.pur-result-empty {
    padding: 12px;
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 768px) {
    .pur-item-main .pur-picker {
        grid-column: 1 / -1;
    }

    .pur-item-main .pur-line {
        text-align: right;
    }
}


/* ===== Purchases timeline list ===== */

.pur-sticky {
    position: sticky;
    top: var(--mobile-header-h, 0px);
    z-index: 50;
    margin: 0 0 6px;
    padding: 8px 0 10px;
    background: #f4f7f5;
}

.pur-search-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.pur-search-row input[type="search"] {
    flex: 1;
    min-width: 0;
    min-height: 46px;
    padding: 11px 14px;
    border: 1px solid #d8e1db;
    border-radius: 12px;
    background: #ffffff;
    color: #1b2a22;
    font: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.pur-search-row input[type="search"]:focus {
    outline: none;
    border-color: #258458;
    box-shadow: 0 0 0 3px rgba(37, 132, 88, 0.12);
}

.pur-dates-toggle {
    flex: none;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #d8e1db;
    border-radius: 12px;
    background: #ffffff;
    color: #55685d;
    cursor: pointer;
}

.pur-dates-toggle.on {
    border-color: #176b45;
    color: #176b45;
}

.pur-dates {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.pur-dates[hidden] {
    display: none;
}

.pur-dates label {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: 3px;
    font-size: 12px;
    color: #667a6f;
}

.pur-dates input[type="date"] {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid #d8e1db;
    border-radius: 10px;
    background: #ffffff;
    font: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.pur-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}

.pur-chips::-webkit-scrollbar {
    display: none;
}

.pur-chip {
    flex: none;
    padding: 8px 14px;
    border: 1px solid #d8e1db;
    border-radius: 999px;
    background: #ffffff;
    color: #1b2a22;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.pur-chip.on {
    background: #176b45;
    border-color: #176b45;
    color: #ffffff;
}

.pur-count {
    margin: 4px 2px 6px;
    font-size: 12px;
    color: #667a6f;
}

.pur-group-title {
    margin: 14px 2px 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #667a6f;
}

.pur-group {
    background: #ffffff;
    border: 1px solid #e1e9e4;
    border-radius: 14px;
}

.pur-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 8px 12px 12px;
    border-bottom: 1px solid #eef2ef;
    cursor: pointer;
}

.pur-row:first-child {
    border-radius: 14px 14px 0 0;
}

.pur-row:last-child {
    border-bottom: 0;
    border-radius: 0 0 14px 14px;
}

.pur-row:only-child {
    border-radius: 14px;
}

.pur-row:hover {
    background: #f7faf8;
}

.pur-date-box {
    flex: none;
    width: 42px;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.1;
}

.pur-date-box b {
    font-size: 22px;
    color: #173d2c;
}

.pur-date-box span {
    font-size: 11px;
    font-weight: 600;
    color: #667a6f;
}

.pur-row-main {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: 3px;
}

.pur-row-main b {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #1b2a22;
}

.pur-row-main small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #667a6f;
    font-size: 12px;
}

.pur-row-side {
    flex: none;
    display: grid;
    justify-items: end;
    gap: 4px;
}

.pur-row-side b {
    font-size: 15px;
    color: #1b2a22;
}

.pur-pill {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.pur-pill-due {
    background: #fdeaea;
    color: #b4232f;
}

.pur-pill-ok {
    background: #e6f4ec;
    color: #176b45;
}

.pur-menu-wrap {
    position: relative;
    flex: none;
}

.pur-dots {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #55685d;
    cursor: pointer;
}

.pur-dots:hover {
    background: #eef3ef;
}

.pur-menu {
    position: absolute;
    top: 34px;
    right: 0;
    z-index: 60;
    min-width: 130px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #d8e1db;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(16, 60, 40, 0.18);
}

.pur-menu[hidden] {
    display: none;
}

.pur-menu button {
    display: block;
    width: 100%;
    padding: 11px 14px;
    border: 0;
    border-bottom: 1px solid #eef2ef;
    background: #ffffff;
    color: #1b2a22;
    font: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.pur-menu button:last-child {
    border-bottom: 0;
}

.pur-menu button:hover {
    background: #eef6f1;
}

.pur-menu .pur-menu-delete {
    color: #b4232f;
}

.pur-empty {
    padding: 24px 12px;
    text-align: center;
    color: #667a6f;
}

.pur-fab {
    position: fixed;
    right: 18px;
    bottom: 28px;
    z-index: 80;
    width: 58px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #176b45;
    color: #ffffff;
    font-size: 32px;
    line-height: 1;
    box-shadow: 0 6px 18px rgba(23, 107, 69, 0.4);
    cursor: pointer;
}

.pur-fab:hover {
    background: #105638;
}

@media (max-width: 768px) {
    .pur-fab {
        bottom: calc(86px + env(safe-area-inset-bottom, 0px));
    }

    .pur-row-side b {
        font-size: 14px;
    }
}

.pur-fab[hidden] {
    display: none;
}

#pur-add-item {
    margin-bottom: 18px;
}


/* ===== Laptop / desktop (1024px and wider) ===== */
@media (min-width: 1024px) {
    .pur-overview,
    .pur-sticky,
    .pur-count,
    #pur-list,
    .pur-panel,
    .pur-message {
        max-width: 1000px;
    }

    .pur-sticky {
        top: 0;
        padding-top: 12px;
    }

    .pur-row {
        padding: 14px 12px 14px 18px;
        gap: 18px;
    }

    .pur-date-box b {
        font-size: 24px;
    }

    .pur-row-main b {
        font-size: 16px;
    }

    .pur-row-main small {
        font-size: 13px;
    }

    .pur-row-side {
        min-width: 130px;
    }

    .pur-row-side b {
        font-size: 16px;
    }

    .pur-pill {
        font-size: 12px;
    }

    /* "+" button becomes a labelled button */
    .pur-fab {
        width: auto;
        height: 50px;
        padding: 0 22px 0 18px;
        gap: 8px;
        border-radius: 999px;
        font-size: 28px;
        right: 32px;
        bottom: 32px;
    }

    .pur-fab::after {
        content: "New Purchase";
        font-size: 15px;
        font-weight: 600;
        font-family: inherit;
    }
}