/* 매입 단가표 (PC / 모바일 공용) */

/* 상단 고정이 동작하도록 단가표 화면에서만 overflow 방식을 변경 */
body:has(.pl),
#app:has(.pl) {
    overflow-x: clip;
}

.pl {
    --pl-top: 0px;
    --pl-price: #047857;
    max-width: 960px;
    margin: 0 auto;
}

.pl-loading {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-secondary);
}

.pl-notice {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.92rem;
}

/* 분류 (모바일) */
.pl-cats {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    padding-bottom: 0.6rem;
    scrollbar-width: none;
    position: relative;
}

.pl-cats::-webkit-scrollbar,
.pl-filters::-webkit-scrollbar {
    display: none;
}

.pl-cat {
    flex-shrink: 0;
    min-height: 40px;
    padding: 0 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: #fff;
    color: #475569;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
}

.pl-cat.active {
    background: var(--pl-price);
    border-color: var(--pl-price);
    color: #fff;
}

/* 검색 / 필터 (상단 고정) */
.pl-toolbar {
    position: sticky;
    top: var(--pl-top);
    z-index: 50;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0;
    padding: 1rem 1.25rem 0.75rem;
}

.pl-head,
.pl-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.pl-controls {
    margin-top: 0.75rem;
}

.pl-title {
    font-family: var(--font-heading), var(--font-body);
    font-size: 1.45rem;
    line-height: 1.3;
    color: var(--text-primary);
    white-space: nowrap;
}

.pl-title span {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.pl-search {
    position: relative;
    flex: 1;
    max-width: 340px;
}

.pl-search input {
    width: 100%;
    height: 42px;
    padding: 0 2.4rem 0 0.9rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: var(--text-primary);
    font: inherit;
    font-size: 1rem;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.pl-search input::-webkit-search-cancel-button {
    display: none;
}

.pl-search input:focus {
    border-color: var(--pl-price);
    box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.15);
}

.pl-search button {
    display: none;
    position: absolute;
    right: 0;
    top: 0;
    width: 40px;
    height: 42px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}

.pl-filters {
    display: flex;
    gap: 0.4rem;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.pl-filter {
    flex-shrink: 0;
    height: 36px;
    padding: 0 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    background: #f8fafc;
    color: #475569;
    font: inherit;
    font-size: 0.88rem;
    white-space: nowrap;
    cursor: pointer;
}

.pl-filter em,
.pl-group em {
    font-style: normal;
    font-size: 0.8em;
    opacity: 0.75;
}

.pl-filter.active {
    background: var(--pl-price);
    border-color: var(--pl-price);
    color: #fff;
    font-weight: 600;
}

.pl-count {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.pl-controls select {
    flex-shrink: 0;
    height: 36px;
    padding: 0 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
    color: var(--text-primary);
    font: inherit;
    font-size: 0.88rem;
}

/* 목록 */
#plList {
    background: #fff;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

.pl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.97rem;
}

.pl-table thead th {
    padding: 0.5rem 1.25rem;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: left;
}

.pl-table td {
    height: 44px;
    padding: 0.25rem 1.25rem;
    border-top: 1px solid #eef2f6;
    vertical-align: middle;
}

.pl-group th {
    padding: 0.6rem 1.25rem 0.5rem;
    background: #ecfdf5;
    border-top: 1px solid #d1fae5;
    color: #065f46;
    font-size: 0.92rem;
    font-weight: 700;
    text-align: left;
}

.pl-name {
    font-weight: 500;
    line-height: 1.4;
    word-break: keep-all;
    overflow-wrap: anywhere;
}

.pl-brand {
    display: inline-block;
    margin-right: 0.5rem;
    padding: 0 0.4rem;
    border-radius: 4px;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.78rem;
    font-weight: 400;
}

.pl-desc {
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 400;
}

.pl-table thead th.pl-price,
.pl-price {
    width: 1%;
    text-align: right;
    white-space: nowrap;
}

td.pl-price {
    color: var(--pl-price);
    font-weight: 700;
    font-size: 1.08rem;
    font-variant-numeric: tabular-nums;
}

.pl-price small {
    margin-left: 1px;
    font-size: 0.78em;
    font-weight: 500;
}

.pl-table .pl-action {
    width: 1%;
    padding-left: 0;
    text-align: right;
}

.pl-btn {
    min-height: 34px;
    padding: 0 0.8rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #334155;
    font: inherit;
    font-size: 0.86rem;
    white-space: nowrap;
    cursor: pointer;
}

.pl-btn-primary {
    min-height: 42px;
    padding: 0 1.1rem;
    border-color: var(--pl-price, #047857);
    background: var(--pl-price, #047857);
    color: #fff;
    font-weight: 600;
}

.pl button:focus-visible,
.pl select:focus-visible {
    outline: 2px solid var(--pl-price);
    outline-offset: 2px;
}

@media (hover: hover) {
    .pl-table tbody tr:not(.pl-group):hover td {
        background: #f8fafc;
    }

    .pl-btn:hover {
        border-color: #047857;
        color: #047857;
    }

    .pl-btn-primary:hover {
        background: #065f46;
        color: #fff;
    }
}

.pl-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-primary);
}

.pl-empty p {
    margin-bottom: 0.75rem;
    overflow-wrap: anywhere;
}

.pl-empty .pl-empty-sub {
    margin-top: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.pl-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #fff;
    font-size: 0.95rem;
}

.pl-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@media (max-width: 640px) {
    .pl-toolbar {
        padding: 0.7rem 0.75rem 0.6rem;
    }

    /* 제목 + 정렬 / 검색 / 필터 순서로 배치 */
    .pl-toolbar {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: 0.5rem;
    }

    .pl-head,
    .pl-controls {
        display: contents;
    }

    .pl-title {
        grid-area: 1 / 1;
    }

    .pl-controls select {
        grid-area: 1 / 2;
    }

    .pl-search {
        grid-area: 2 / 1 / auto / -1;
    }

    .pl-filters {
        grid-area: 3 / 1 / auto / -1;
    }

    .pl-title {
        font-size: 1.15rem;
    }

    .pl-title span {
        font-size: 0.9rem;
    }

    .pl-search {
        max-width: none;
    }

    /* iOS에서 입력 시 화면이 확대되지 않도록 16px 유지 */
    .pl-search input,
    .pl-controls select {
        font-size: 16px;
    }

    .pl-filter,
    .pl-controls select {
        height: 40px;
    }

    .pl-table td {
        height: 48px;
        padding: 0.25rem 0.75rem;
    }

    .pl-table thead th,
    .pl-group th {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .pl-name {
        font-size: 0.93rem;
    }

    td.pl-price {
        font-size: 1rem;
        padding-left: 0;
    }

    .pl-btn {
        min-height: 40px;
        padding: 0 0.7rem;
    }

    .pl-foot .pl-btn {
        width: 100%;
    }
}
