/* ===== Low Stock / Reorder page ===== */
:root {
    --rd-red: #c62828;
    --rd-red-soft: #fdecec;
    --rd-amber: #b26a00;
    --rd-amber-soft: #fff3df;
    --rd-green: #1b7a43;
    --rd-green-soft: #e6f3ec;
    --rd-ink: #1f2933;
    --rd-muted: #6b7785;
    --rd-line: #e3e8ee;
    --rd-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

.rd-page { min-width: 0; padding-bottom: 90px; }

.rd-header { margin-bottom: 22px; }
.rd-header h2 { margin: 0 0 4px; font-size: 28px; letter-spacing: -.3px; color: var(--rd-ink); }
.rd-header p { margin: 0; font-size: 14px; color: var(--rd-muted); }

.rd-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.rd-card { position: relative; background: #fff; border: 1px solid var(--rd-line); border-radius: 14px; padding: 18px 20px 18px 24px; min-width: 0; box-shadow: var(--rd-shadow); overflow: hidden; }
.rd-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--rd-green); }
.rd-card-red::before { background: var(--rd-red); }
.rd-card-amber::before { background: #e59a1c; }
.rd-card p { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--rd-muted); }
.rd-card h4 { margin: 0; font-size: 28px; line-height: 1.1; color: var(--rd-ink); overflow-wrap: anywhere; }
.rd-card-red h4 { color: var(--rd-red); }
.rd-card-amber h4 { color: var(--rd-amber); }

.rd-panel { background: #fff; border: 1px solid var(--rd-line); border-radius: 14px; padding: 20px; min-width: 0; box-shadow: var(--rd-shadow); }

.rd-filters { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) 150px; gap: 12px; align-items: end; }
.rd-input { border: 1px solid #d3dae2; border-radius: 10px; padding: 11px 14px; font-size: 14px; font-family: inherit; background: #fff; box-sizing: border-box; min-width: 0; width: 100%; color: var(--rd-ink); }
.rd-input:focus { outline: 0; border-color: var(--rd-green); box-shadow: 0 0 0 3px rgba(27, 122, 67, .15); }
.rd-search { padding-left: 38px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7785' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px 50% / 18px; }
select.rd-input { -webkit-appearance: none; appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, #6b7785 50%), linear-gradient(135deg, #6b7785 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.rd-min { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--rd-muted); }

.rd-note { margin: 12px 0 0; font-size: 12px; color: var(--rd-muted); }
.rd-listhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 14px 2px 10px; }
.rd-count { margin: 0; font-size: 13px; font-weight: 600; color: var(--rd-muted); }
.rd-selectall { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--rd-ink); cursor: pointer; white-space: nowrap; }
.rd-selectall input { width: 18px; height: 18px; accent-color: var(--rd-green); cursor: pointer; }

.rd-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--rd-line); border-radius: 12px; }
.rd-table { width: 100%; min-width: 900px; border-collapse: collapse; font-size: 14px; }
.rd-table th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--rd-muted); padding: 12px 14px; background: #f7f9fb; border-bottom: 1px solid var(--rd-line); white-space: nowrap; }
.rd-table td { padding: 12px 14px; border-bottom: 1px solid #eef1f5; vertical-align: middle; color: var(--rd-ink); }
.rd-table tbody tr:last-child td { border-bottom: 0; }
.rd-table tbody tr:hover { background: #f9fbfa; }
.rd-table tbody tr.rd-picked { background: #f1f8f4; }
.rd-check { width: 44px; }
.rd-table input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--rd-green); cursor: pointer; }
.rd-empty { text-align: center; color: var(--rd-muted); padding: 40px 10px !important; }

.rd-book b { display: block; font-size: 14px; }
.rd-book small { color: var(--rd-muted); font-size: 12px; }

.rd-badge { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.rd-badge.out { background: var(--rd-red-soft); color: var(--rd-red); }
.rd-badge.low { background: var(--rd-amber-soft); color: var(--rd-amber); }
.rd-min-text { display: block; margin-top: 3px; font-size: 11px; color: var(--rd-muted); }

.rd-qty { width: 84px; padding: 8px 10px; text-align: center; font-weight: 700; }

.rd-bar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 1500; display: flex; align-items: center; justify-content: space-between; gap: 18px; width: min(560px, calc(100% - 32px)); padding: 12px 14px 12px 20px; background: #1f2933; color: #fff; border-radius: 14px; box-shadow: 0 10px 30px rgba(16, 24, 40, .35); }
.rd-bar[hidden] { display: none; }
.rd-bar strong { display: block; font-size: 15px; }
.rd-bar span { font-size: 12px; color: #c4ccd4; }

.rd-btn { border: 1px solid #d3dae2; background: #fff; color: var(--rd-ink); border-radius: 10px; padding: 11px 18px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit; text-decoration: none; display: inline-block; text-align: center; }
.rd-btn-light { background: #f4f6f8; }
.rd-btn-green { background: var(--rd-green); border-color: var(--rd-green); color: #fff; }
.rd-btn:disabled { opacity: .55; cursor: default; }

.rd-message { min-height: 20px; margin: 14px 0 0; font-size: 14px; font-weight: 600; color: var(--rd-green); }
.rd-message.error { color: var(--rd-red); }

/* order list popup */
.rd-modal { position: fixed; inset: 0; background: rgba(16, 24, 40, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 2000; }
.rd-modal[hidden] { display: none; }
.rd-card-modal { background: #fff; border-radius: 16px; padding: 22px; width: 100%; max-width: 680px; max-height: 92vh; overflow-y: auto; box-sizing: border-box; box-shadow: 0 20px 50px rgba(16, 24, 40, .3); }
.rd-modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
.rd-modal-head h3 { margin: 0; font-size: 20px; color: var(--rd-ink); }
.rd-modal-head p { margin: 4px 0 0; font-size: 13px; color: var(--rd-muted); }

.rd-group { border: 1px solid var(--rd-line); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.rd-group-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.rd-group-head b { font-size: 15px; }
.rd-group-head small { display: block; color: var(--rd-muted); font-size: 12px; }
.rd-group textarea { width: 100%; box-sizing: border-box; border: 1px solid #d3dae2; border-radius: 10px; padding: 12px; font-size: 13px; font-family: inherit; line-height: 1.5; resize: vertical; min-height: 130px; }
.rd-group-btns { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.rd-group-btns .rd-btn { padding: 9px 16px; font-size: 13px; }
.rd-modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

#rd-printable { display: none; }
@media print {
    body.rd-printing > *:not(#rd-printable) { display: none !important; }
    body.rd-printing #rd-printable { display: block; padding: 10px; font-family: Arial, sans-serif; color: #000; }
    #rd-printable h2 { margin: 0 0 4px; }
    #rd-printable h3 { margin: 18px 0 4px; }
    #rd-printable table { width: 100%; min-width: 0; border-collapse: collapse; margin-top: 6px; font-size: 12px; }
    #rd-printable th, #rd-printable td { border: 1px solid #999; padding: 5px 6px; text-align: left; }
    #rd-printable td.num, #rd-printable th.num { text-align: right; }
}

@media (max-width: 900px) {
    .rd-cards { grid-template-columns: 1fr; gap: 12px; }
    .rd-card h4 { font-size: 24px; }
    .rd-filters { grid-template-columns: 1fr 1fr; }
    .rd-search { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
    .rd-header h2 { font-size: 24px; }
    .rd-panel { padding: 14px; }
    .rd-page { padding-bottom: 150px; }

    .rd-table-wrap { border: 0; overflow: visible; }
    .rd-table { min-width: 0; display: block; }
    .rd-table thead { display: none; }
    .rd-table tbody { display: block; }
    .rd-table tbody tr { display: block; position: relative; border: 1px solid var(--rd-line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; background: #fff; }
    .rd-table tbody tr.rd-picked { background: #f1f8f4; border-color: #bfdccb; }
    .rd-table td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border: 0; }
    .rd-table td[data-label]::before { content: attr(data-label); font-size: 12px; font-weight: 600; color: var(--rd-muted); text-transform: uppercase; letter-spacing: .4px; }
    .rd-table td.rd-check { position: absolute; top: 12px; right: 14px; width: auto; padding: 0; }
    .rd-table td.rd-first { padding-right: 34px; padding-bottom: 10px; border-bottom: 1px solid #eef1f5; margin-bottom: 4px; }
    .rd-table td.rd-empty { display: block; }

    .rd-bar { bottom: 84px; }
    .rd-modal { padding: 0; align-items: flex-end; }
    .rd-card-modal { border-radius: 16px 16px 0 0; max-height: 94vh; padding: 18px; }
}