:root {
  --pm-ink: #17211d;
  --pm-muted: #637069;
  --pm-line: #d9e0dc;
  --pm-soft: #f3f6f4;
  --pm-panel: #ffffff;
  --pm-green: #247447;
  --pm-green-dark: #185637;
  --pm-teal: #176d73;
  --pm-orange: #d97706;
  --pm-red: #b42318;
  --pm-shadow: 0 18px 45px rgba(23, 33, 29, 0.16);
}

body.pm-modal-open { overflow: hidden; }

.pm-root {
  color: var(--pm-ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

.pm-root [hidden] { display: none !important; }

.pm-root *, .pm-root *::before, .pm-root *::after { box-sizing: border-box; }
.pm-root button, .pm-root input, .pm-root select, .pm-root textarea { font: inherit; letter-spacing: 0; }
.pm-root button { cursor: pointer; }
.pm-root button:disabled { cursor: not-allowed; opacity: 0.52; }

.pm-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px 20px;
  background: #173f34;
  color: #fff;
}

.pm-heading h1 { margin: 2px 0 0; font-size: 30px; line-height: 1.08; }
.pm-kicker { display: block; color: #c9ded4; font-size: 12px; font-weight: 800; text-transform: uppercase; }
.pm-heading-actions, .pm-row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.pm-btn, .pm-icon-btn {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 800;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.pm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 14px; }
.pm-btn:hover, .pm-icon-btn:hover { transform: translateY(-1px); }
.pm-btn-primary { background: var(--pm-green); color: #fff; }
.pm-btn-primary:hover { background: var(--pm-green-dark); }
.pm-btn-secondary { background: #fff; border-color: #c8d3cd; color: #263c32; }
.pm-btn-warning { background: #fff4d8; border-color: #e7b74f; color: #805000; }
.pm-btn-warning:hover { background: #ffe8ad; }
.pm-btn-danger { background: #fff; border-color: #efc3bf; color: var(--pm-red); }
.pm-btn-sm { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.pm-heading .pm-btn-secondary { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.38); color: #fff; }
.pm-icon-btn { width: 40px; padding: 0; background: #fff; border-color: #c8d3cd; color: #263c32; font-size: 20px; }
.pm-icon-btn.danger { color: var(--pm-red); }
.pm-heading .pm-icon-btn { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.38); color: #fff; }

.pm-tabs {
  display: flex;
  gap: 0;
  padding: 0 28px;
  background: #fff;
  border-bottom: 1px solid var(--pm-line);
}

.pm-tabs button {
  min-width: 132px;
  padding: 15px 18px 13px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--pm-muted);
  font-weight: 800;
}

.pm-tabs button.active { color: var(--pm-green-dark); border-bottom-color: var(--pm-orange); }
.pm-root > section { padding: 22px 28px 30px; background: #f7f9f8; }

.pm-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--pm-line);
  border-radius: 6px;
  background: var(--pm-line);
}

.pm-kpis > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-height: 72px; padding: 16px; background: #fff; }
.pm-kpis span { color: var(--pm-muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.pm-kpis strong { font-size: 25px; color: var(--pm-ink); }

.pm-toolbar, .pm-section-toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
}

.pm-section-toolbar { align-items: center; justify-content: space-between; }
.pm-section-toolbar h2 { margin: 0 0 3px; font-size: 21px; }
.pm-section-toolbar span { color: var(--pm-muted); font-size: 13px; }
.pm-toolbar label { display: grid; gap: 6px; min-width: 145px; }
.pm-toolbar label > span, .pm-form-grid label > span, .pm-form-stack label > span,
.pm-recipe-search label > span, .pm-transfer-notes > span, .pm-image-field > span:first-child {
  color: #4b5d54;
  font-size: 12px;
  font-weight: 800;
}
.pm-toolbar .pm-search { flex: 1 1 340px; }

.pm-root input, .pm-root select, .pm-root textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #c8d3cd;
  border-radius: 6px;
  background: #fff;
  color: var(--pm-ink);
  outline: none;
}
.pm-root textarea { resize: vertical; }
.pm-root input:focus, .pm-root select:focus, .pm-root textarea:focus { border-color: var(--pm-teal); box-shadow: 0 0 0 3px rgba(23, 109, 115, 0.12); }

.pm-table-wrap { width: 100%; overflow: auto; border: 1px solid var(--pm-line); border-radius: 6px; background: #fff; }
.pm-table { width: 100%; min-width: 900px; border-collapse: collapse; font-size: 13px; }
.pm-products-table { min-width: 1320px; }
.pm-table th { position: sticky; top: 0; z-index: 1; padding: 11px 12px; background: #e9efec; color: #48574f; font-size: 11px; text-align: left; text-transform: uppercase; white-space: nowrap; }
.pm-table td { padding: 11px 12px; border-top: 1px solid #e5ebe8; vertical-align: middle; }
.pm-table tbody tr:hover { background: #f7faf8; }
.pm-table td > small, .pm-table td > span + small, .pm-table td strong + small { display: block; margin-top: 3px; color: var(--pm-muted); font-size: 11px; }
.pm-table input[type="number"] { min-width: 110px; min-height: 34px; padding: 6px 8px; }
.pm-row-discontinued { background: #f1f2f2; color: #6f7773; }
.pm-row-no-stock { background: #fff9ed; }
.pm-money { font-variant-numeric: tabular-nums; font-weight: 800; white-space: nowrap; }
.pm-code { font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; white-space: nowrap; }
.pm-empty { padding: 34px !important; color: var(--pm-muted); text-align: center !important; }
.pm-error { color: var(--pm-red); }

.pm-sort { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: transparent; color: inherit; font-size: inherit; font-weight: inherit; text-transform: inherit; }
.pm-sort span { color: #7d8983; }
.pm-product-cell { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.pm-thumb { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 42px; overflow: hidden; border: 1px solid var(--pm-line); border-radius: 5px; background: #fff; }
.pm-thumb img { width: 100%; height: 100%; object-fit: contain; }
.pm-thumb-empty { color: #9aa69f; font-size: 23px; }

.pm-status { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 900; white-space: nowrap; }
.pm-status.ok { background: #e4f3e9; color: #176138; }
.pm-status.warning { background: #fff0cd; color: #8d5200; }
.pm-status.danger { background: #fbe8e6; color: #96261d; }
.pm-status.muted { background: #edf1ef; color: #5b6861; }
.pm-status.recipe { background: #e8f1ed; color: #315d4a; }
.pm-recipe-stock-note { max-width: 130px; color: #52655c; font-size: 11px; font-weight: 800; line-height: 1.25; }

.pm-action-menu { position: relative; }
.pm-action-menu summary { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--pm-line); border-radius: 5px; background: #fff; font-size: 20px; cursor: pointer; list-style: none; }
.pm-action-menu summary::-webkit-details-marker { display: none; }
.pm-action-menu > div { position: absolute; right: 0; z-index: 12; width: 180px; padding: 5px; border: 1px solid var(--pm-line); border-radius: 6px; background: #fff; box-shadow: 0 12px 28px rgba(23, 33, 29, 0.2); }
.pm-action-menu button { width: 100%; padding: 9px 10px; border: 0; border-radius: 4px; background: transparent; color: var(--pm-ink); text-align: left; font-size: 12px; font-weight: 700; }
.pm-action-menu button:hover { background: var(--pm-soft); }
.pm-action-menu button.danger { color: var(--pm-red); }

.pm-pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; color: var(--pm-muted); font-size: 13px; }
.pm-pagination > div { display: flex; gap: 7px; }

.pm-location-status { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 15px; padding: 14px 16px; border-left: 4px solid var(--pm-orange); background: #fff; }
.pm-location-status span { display: block; color: var(--pm-muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.pm-location-status strong { font-size: 20px; }
.pm-location-status p { margin: 0; color: var(--pm-muted); font-size: 13px; }
.pm-inventory-toolbar .pm-btn { margin-left: auto; }
.pm-transfer-line { display: block; margin: 2px 0; }
.pm-inventory-movements-heading { margin-top: 24px; }
.pm-movements-table { min-width: 980px; }
.pm-quantity { font-variant-numeric: tabular-nums; font-weight: 900; white-space: nowrap; }
.pm-quantity.positive { color: var(--pm-green-dark); }
.pm-quantity.negative { color: var(--pm-red); }

.pm-toast { position: fixed; top: 18px; left: 50%; z-index: 1500; width: min(620px, calc(100vw - 28px)); transform: translateX(-50%); padding: 12px 16px; border: 1px solid #cdd8d2; border-radius: 6px; background: #fff; box-shadow: var(--pm-shadow); font-weight: 700; }
.pm-toast.success { border-color: #8fc7a5; color: #185f37; }
.pm-toast.error { border-color: #e5aaa4; color: #8e251c; }

.pm-modal[hidden] { display: none !important; }
.pm-modal { position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; padding: 22px; background: rgba(15, 24, 20, 0.64); }
.pm-modal-dialog { display: flex; flex-direction: column; width: min(1240px, 100%); max-height: calc(100vh - 44px); overflow: hidden; border-radius: 8px; background: #fff; box-shadow: var(--pm-shadow); }
.pm-product-dialog { max-width: 1240px; }
.pm-transfer-dialog { max-width: 920px; }
.pm-small-dialog { max-width: 520px; }
.pm-modal-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 22px; border-bottom: 1px solid var(--pm-line); }
.pm-modal-heading h2 { margin: 2px 0 0; font-size: 23px; }
.pm-modal-heading .pm-kicker { color: var(--pm-teal); }
.pm-modal-dialog form { display: flex; min-height: 0; flex: 1; flex-direction: column; }
.pm-form-scroll { min-height: 0; overflow: auto; }
.pm-form-section { padding: 20px 22px; border-bottom: 1px solid var(--pm-line); }
.pm-form-section h3 { margin: 0 0 14px; font-size: 16px; }
.pm-section-title { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.pm-section-title h3 { margin: 0; }
.pm-section-title > span { color: var(--pm-muted); font-size: 12px; }
.pm-form-grid { display: grid; gap: 14px; }
.pm-form-grid label { display: grid; align-content: start; gap: 6px; }
.pm-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pm-grid-pricing { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.pm-grid-media { grid-template-columns: 170px minmax(240px, 1fr) 150px; align-items: start; }
.pm-span-2 { grid-column: span 2; }
.pm-span-all { grid-column: 1 / -1; }

.pm-tax-fieldset { display: flex; align-items: center; gap: 12px; min-height: 66px; margin: 0; padding: 9px 12px; border: 1px solid var(--pm-line); border-radius: 6px; }
.pm-tax-fieldset legend { padding: 0 4px; color: #4b5d54; font-size: 12px; font-weight: 800; }
.pm-tax-fieldset label, .pm-toggle-label { display: inline-flex !important; align-items: center; gap: 7px; color: var(--pm-ink); font-size: 12px; font-weight: 700; }
.pm-tax-fieldset input, .pm-toggle-label input { width: 18px; min-height: 18px; margin: 0; accent-color: var(--pm-green); }
.pm-suffix-input { position: relative; }
.pm-suffix-input input { padding-right: 35px; }
.pm-suffix-input span { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--pm-muted); font-weight: 800; }
.pm-form-grid output { display: flex; align-items: center; min-height: 42px; padding: 9px 11px; border: 1px solid var(--pm-line); border-radius: 6px; background: var(--pm-soft); font-weight: 900; }

.pm-image-field input[type="file"] { padding: 7px; font-size: 12px; }
.pm-file-name { color: var(--pm-muted); font-size: 11px; }
.pm-image-preview { display: grid; place-items: center; width: 150px; aspect-ratio: 1; overflow: hidden; border: 1px dashed #b9c6bf; border-radius: 6px; background: var(--pm-soft); color: var(--pm-muted); font-size: 12px; }
.pm-image-preview img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.pm-description-actions { display: flex; align-items: center; gap: 12px; }
.pm-description-actions > span { color: var(--pm-muted); font-size: 12px; }

.pm-recipe-search { position: relative; margin-bottom: 13px; }
.pm-recipe-search label { display: grid; gap: 6px; }
.pm-suggestions { position: absolute; top: calc(100% + 3px); left: 0; right: 0; z-index: 20; max-height: 290px; overflow: auto; border: 1px solid var(--pm-line); border-radius: 6px; background: #fff; box-shadow: 0 12px 28px rgba(23, 33, 29, 0.18); }
.pm-suggestions button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid #edf1ef; background: #fff; text-align: left; }
.pm-suggestions button:hover { background: var(--pm-soft); }
.pm-suggestions button span { color: var(--pm-muted); font-size: 11px; }
.pm-suggestion-empty { padding: 16px; color: var(--pm-muted); text-align: center; }
.pm-recipe-table { min-width: 620px; }

.pm-modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 22px; border-top: 1px solid var(--pm-line); background: #f7f9f8; }
.pm-form-stack { display: grid; gap: 14px; padding: 20px 22px; }
.pm-form-stack label { display: grid; gap: 6px; }
.pm-selected-product { padding: 12px; border-left: 4px solid var(--pm-green); background: var(--pm-soft); }
.pm-selected-product strong, .pm-selected-product span { display: block; }
.pm-selected-product span { margin-top: 3px; color: var(--pm-muted); font-size: 12px; }
.pm-transfer-notes { display: grid; gap: 6px; margin: 15px 22px 20px; }

.pm-busy::after { content: ""; position: fixed; inset: 0; z-index: 2000; background: rgba(255,255,255,.34); cursor: progress; }

@media (max-width: 1080px) {
  .pm-kpis { grid-template-columns: repeat(3, 1fr); }
  .pm-toolbar { flex-wrap: wrap; }
  .pm-toolbar label { flex: 1 1 180px; }
  .pm-grid-4, .pm-grid-pricing { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pm-grid-media { grid-template-columns: 1fr 1fr; }
  .pm-image-preview { grid-column: 2; grid-row: 1 / span 2; }
}

@media (max-width: 720px) {
  .pm-heading { align-items: flex-start; flex-direction: column; padding: 18px; }
  .pm-heading h1 { font-size: 24px; }
  .pm-heading-actions { width: 100%; justify-content: flex-start; }
  .pm-heading-actions .pm-btn { min-width: 0; }
  .pm-tabs { padding: 0 12px; overflow: auto; }
  .pm-tabs button { min-width: 108px; padding-inline: 12px; }
  .pm-root > section { padding: 14px 12px 24px; }
  .pm-kpis { grid-template-columns: repeat(2, 1fr); }
  .pm-kpis > div:last-child { grid-column: 1 / -1; }
  .pm-kpis > div { min-height: 60px; padding: 12px; }
  .pm-kpis strong { font-size: 20px; }
  .pm-toolbar { align-items: stretch; }
  .pm-toolbar label, .pm-toolbar .pm-search { flex-basis: 100%; }
  .pm-inventory-toolbar .pm-btn { width: 100%; margin-left: 0; }
  .pm-location-status { align-items: flex-start; flex-direction: column; }
  .pm-modal { padding: 0; place-items: stretch; }
  .pm-modal-dialog { width: 100%; max-height: 100dvh; border-radius: 0; }
  .pm-form-section { padding: 17px 15px; }
  .pm-grid-4, .pm-grid-pricing, .pm-grid-media { grid-template-columns: 1fr; }
  .pm-span-2 { grid-column: auto; }
  .pm-image-preview { grid-column: auto; grid-row: auto; width: min(180px, 100%); }
  .pm-tax-fieldset { flex-wrap: wrap; }
  .pm-modal-actions { padding: 12px 15px; }
  .pm-modal-actions .pm-btn { flex: 1; }
  .pm-section-toolbar { align-items: stretch; flex-direction: column; }
  .pm-products-table th:last-child, .pm-products-table td:last-child,
  .pm-inventory-table th:last-child, .pm-inventory-table td:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    background: #fff;
    box-shadow: -8px 0 12px rgba(23, 33, 29, 0.06);
  }
  .pm-products-table th:last-child, .pm-inventory-table th:last-child { background: #e9efec; }
  .pm-products-table .pm-row-no-stock td:last-child, .pm-inventory-table .pm-row-no-stock td:last-child { background: #fff9ed; }
  .pm-products-table .pm-row-discontinued td:last-child { background: #f1f2f2; }
}
