/* packagingRules.css — admin "Packaging Rules" page. Tokens match the rest of RMS
   (ink/line/accent values lifted from style.css's .lg-wrap custom properties). */
#packagingRules { background: #f8fafc; min-height: 100%; }
.pkr-wrap { padding: 24px 32px 60px; }
.pkr-loading { padding: 40px; text-align: center; color: #94a3b8; }

.pkr-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.pkr-title { font-size: 20px; font-weight: 800; color: #0f172a; }
.pkr-sub { font-size: 12.5px; color: #64748b; margin-top: 3px; max-width: 640px; }

.pkr-flag { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 9px 13px; }
.pkr-flag-title { font-size: 12px; font-weight: 700; color: #0f172a; }
.pkr-flag-sub { font-size: 10.5px; color: #94a3b8; margin-top: 1px; }
.pkr-switch { width: 34px; height: 19px; border-radius: 999px; background: #cbd5e1; position: relative; flex: none; cursor: pointer; transition: background .12s; }
.pkr-switch.on { background: #16a34a; }
.pkr-switch i { position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .12s; }
.pkr-switch.on i { transform: translateX(15px); }

.pkr-cols { display: grid; grid-template-columns: 1fr 1.15fr; gap: 24px; align-items: start; }
@media (max-width: 1080px) { .pkr-cols { grid-template-columns: 1fr; } }
.pkr-mat-section, .pkr-rules-section { margin-bottom: 28px; min-width: 0; }
.pkr-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.pkr-section-title { font-size: 14.5px; font-weight: 800; color: #0f172a; }
.pkr-section-sub { font-size: 11.5px; color: #94a3b8; margin-top: 2px; max-width: 480px; }

.pkr-add { background: #0f172a; color: #fff; border: none; border-radius: 9px; padding: 9px 15px; font-size: 12.5px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.pkr-add:hover { background: #1e293b; }

/* ── standalone materials table ── */
.pkr-mat-table { background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; overflow: hidden; }
.pkr-mat-row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; align-items: center; gap: 14px; padding: 13px 18px; border-bottom: 1px solid #f1f5f9; }
.pkr-mat-row:last-child { border-bottom: none; }
.pkr-mat-row-head { background: #fafbfc; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: #94a3b8; padding: 10px 18px; }
.pkr-mat-row.out { background: #fef2f2; }
.pkr-mat-name { font-size: 13.5px; font-weight: 700; color: #0f172a; }
.pkr-mat-name .req { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; font-size: 10px; font-weight: 800; color: #16a34a; background: #ecfdf5; border: 1px solid #bbf7d0; border-radius: 999px; padding: 2px 8px; vertical-align: middle; }
.pkr-out-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 800; color: #dc2626; background: #fee2e2; border: 1px solid #fecaca; border-radius: 999px; padding: 3px 9px; margin-top: 4px; }
.pkr-stock-val { font-family: Consolas, "SF Mono", monospace; font-size: 16px; font-weight: 800; color: #0f172a; }
.pkr-stock-val.out { color: #dc2626; }
.pkr-stock-lbl { font-size: 10px; color: #94a3b8; text-transform: uppercase; letter-spacing: .04em; margin-top: 1px; }
.pkr-batch-val { font-family: Consolas, "SF Mono", monospace; font-size: 13px; font-weight: 700; color: #334155; }
.pkr-batch-lbl { font-size: 10px; color: #94a3b8; text-transform: uppercase; letter-spacing: .04em; margin-top: 1px; }

/* ── thumbnails, reused in rules table + modal ── */
.pkr-thumb { border-radius: 8px; object-fit: cover; flex: none; background: #f1f5f9; }
.pkr-thumb.ph { display: flex; align-items: center; justify-content: center; font-size: 16px; }

/* ── rules table ── */
.pkr-table { background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; overflow: hidden; }
.pkr-row { display: grid; grid-template-columns: 1.6fr .6fr 2fr auto; align-items: center; gap: 14px; padding: 13px 18px; border-bottom: 1px solid #f1f5f9; }
.pkr-row:last-child { border-bottom: none; }
.pkr-row-head { background: #fafbfc; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: #94a3b8; padding: 10px 18px; }

.pkr-prod { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pkr-prod-name { font-size: 13px; font-weight: 700; color: #0f172a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pkr-prod-sku { font-size: 10.5px; color: #94a3b8; font-family: Consolas, "SF Mono", monospace; }

.pkr-qty-badge { font-family: Consolas, monospace; font-size: 13px; font-weight: 800; background: #f1f5f9; border-radius: 7px; padding: 4px 0; text-align: center; }
.pkr-mats { display: flex; flex-wrap: wrap; gap: 6px; }
.pkr-mat-chip { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; border-radius: 7px; padding: 3px 9px; font-size: 11px; font-weight: 600; }
.pkr-row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.pkr-edit, .pkr-delete { background: #fff; border: 1px solid #cbd5e1; color: #475569; border-radius: 7px; padding: 6px 12px; font-size: 12px; font-weight: 700; cursor: pointer; }
.pkr-edit:hover { border-color: #2563eb; color: #2563eb; }
.pkr-delete:hover { border-color: #dc2626; color: #dc2626; }

/* ── Add/Edit rule modal — wide, two-pane. Material-form modal reuses the same shell at 440px ── */
.pkr-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 500; }
.pkr-modal { width: 100%; max-width: 920px; max-height: 90vh; background: #fff; border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.35); display: flex; flex-direction: column; overflow: hidden; }
.pkr-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid #e2e8f0; flex: none; }
.pkr-modal-title { font-size: 16px; font-weight: 800; color: #0f172a; }
.pkr-modal-x { border: none; background: none; font-size: 16px; color: #94a3b8; cursor: pointer; }
.pkr-modal-x:hover { color: #475569; }
.pkr-modal-body { overflow-y: auto; flex: 1; }
.pkr-modal-split { display: grid; grid-template-columns: 1fr 1.2fr; gap: 0; }
.pkr-modal-left { padding: 18px 22px; border-right: 1px solid #e2e8f0; }
.pkr-modal-right { padding: 18px 22px; }
@media (max-width: 760px) { .pkr-modal-split { grid-template-columns: 1fr; } .pkr-modal-left { border-right: none; border-bottom: 1px solid #e2e8f0; } }
.pkr-modal-foot { padding: 14px 22px; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 10px; flex: none; }

.pkr-field-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #94a3b8; margin-bottom: 6px; }
.pkr-search-input { width: 100%; box-sizing: border-box; border: 1.5px solid #cbd5e1; border-radius: 9px; padding: 9px 12px; font-size: 13.5px; }
.pkr-search-input:focus { outline: none; border-color: #2563eb; }
.pkr-search-results { margin-top: 6px; max-height: 240px; overflow-y: auto; border: 1px solid #e2e8f0; border-radius: 9px; }
.pkr-search-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #f1f5f9; font-size: 12.5px; }
.pkr-search-row:last-child { border-bottom: none; }
.pkr-search-row:hover { background: #eff6ff; }
.pkr-search-hint { padding: 10px 12px; font-size: 12px; color: #94a3b8; }
.pkr-picked-prod { display: flex; align-items: center; gap: 10px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 9px; padding: 9px 12px; font-size: 13px; }
.pkr-clear-prod { margin-left: auto; background: none; border: none; color: #2563eb; font-size: 11.5px; font-weight: 700; cursor: pointer; text-decoration: underline; }

.pkr-seg { display: inline-flex; background: #fff; border: 1px solid #cbd5e1; border-radius: 9px; overflow: hidden; }
.pkr-seg button { border: 0; background: none; padding: 7px 18px; font-weight: 700; font-size: 13px; color: #475569; border-right: 1px solid #e2e8f0; cursor: pointer; }
.pkr-seg button:last-child { border-right: 0; }
.pkr-seg button.on { background: #0f172a; color: #fff; }

.pkr-mat-list { display: flex; flex-direction: column; gap: 7px; max-height: 420px; overflow-y: auto; }
.pkr-mrow { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: 10px; padding: 9px 11px; }
.pkr-mrow.checked { border-color: #2563eb; background: #eff6ff; }
.pkr-cb { width: 18px; height: 18px; border-radius: 5px; border: 2px solid #cbd5e1; background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; flex: none; font-size: 11px; color: #fff; font-weight: 900; }
.pkr-mrow.checked .pkr-cb { background: #2563eb; border-color: #2563eb; }
.pkr-mname { font-size: 12.5px; font-weight: 700; cursor: pointer; min-width: 0; }
.pkr-mstock { font-size: 10.5px; color: #94a3b8; font-weight: 500; margin-top: 1px; }
.pkr-mstock.out { color: #dc2626; font-weight: 700; }
.pkr-mqty { display: flex; align-items: center; gap: 5px; flex: none; }
.pkr-qty-btn { width: 24px; height: 24px; border-radius: 6px; border: 1px solid #cbd5e1; background: #fff; font-size: 14px; font-weight: 700; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #0f172a; }
.pkr-qty-btn:hover { background: #f1f5f9; }
.pkr-qty-val { width: 28px; text-align: center; font-family: Consolas, monospace; font-size: 12.5px; font-weight: 700; }

.pkr-btn { border: none; border-radius: 9px; padding: 9px 16px; font-size: 13px; font-weight: 700; cursor: pointer; }
.pkr-btn.ghost { background: #fff; border: 1.5px solid #cbd5e1; color: #475569; }
.pkr-btn.primary { background: #0f172a; color: #fff; }
.pkr-btn.primary:hover { background: #2563eb; }
