:root{
  --bg:#f4f7fb; --card:#fff; --accent:#ff6b6b; --accent2:#2b8aef;
  --muted:#6b7280; --radius:12px; --pad:14px; font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial;
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:#0b1220}
.pm-container{max-width:1200px;margin:18px auto;padding:16px;display:grid;grid-template-columns:1fr 440px;grid-template-rows:auto 1fr auto;gap:20px;height:calc(100vh - 28px);min-height:560px;overflow:hidden}

/* Layout fixes: header spans both columns, left column = form, right column = lists */
.pm-header{grid-column:1 / -1;grid-row:1}
.pm-card{grid-column:1;grid-row:2}
.pm-right{grid-column:2;grid-row:2}

/* Make the prices section span both columns */
.pm-prices{grid-column:1 / -1;grid-row:3}

/* Prices panel: fixed-height (viewport-relative) with internal scrolling for the list */
.pm-prices{display:flex;flex-direction:column;gap:12px;height:34vh;min-height:180px;max-height:44vh;overflow:hidden;padding:12px}
.pm-prices > h2{margin:0 0 8px 0}
.pm-prices .prices-form{flex:0 0 auto}
.pm-prices #pmPricesList{flex:1 1 auto;min-height:80px;overflow-y:auto;padding-right:8px}

/* Make items inside prices list break long words */
#pmPricesList .product-row{word-break:break-word}
.pm-header{display:flex;justify-content:space-between;align-items:center;gap:20px}
.pm-header h1{margin:0;font-size:22px}
.pm-sub{color:var(--muted);margin:6px 0 0;font-size:13px}

.pm-card{background:var(--card);padding:18px;border-radius:var(--radius);box-shadow:0 8px 30px rgba(12,20,40,0.06);margin-top:0}
.row{margin-bottom:12px}
.row label{display:block;color:#223;margin-bottom:6px;font-size:13px}
.row input, .row textarea, .row select{width:100%;padding:10px;border-radius:10px;border:1px solid #eef3fb;background:#fff}
.row textarea{min-height:44px;resize:vertical}
.grid3{display:grid;grid-template-columns:1fr 1fr 140px;gap:12px;align-items:end}
/* Two-column helper for compact rows (price + vat) */
.grid2{display:grid;grid-template-columns:1fr 220px;gap:12px;align-items:end}
.align-bottom{display:flex;flex-direction:column;justify-content:flex-end}
.switch input{transform:scale(1.2)}
.actions{display:flex;gap:10px}
.btn{padding:10px 14px;border-radius:10px;border:1px solid #e6eefb;background:#fff;cursor:pointer}
.btn.primary{background:linear-gradient(180deg,var(--accent2),#1f6fd8);color:#fff;border:none}
.btn.ghost{background:transparent;border:1px solid #e6edf6;color:var(--muted)}

.pm-list.card{background:var(--card);padding:16px;border-radius:var(--radius);margin-top:0;box-shadow:0 8px 30px rgba(12,20,40,0.04)}

/* Right column wrapper */

.pm-right{display:flex;flex-direction:column;gap:12px;min-height:0;align-items:stretch}

/* Ensure the products list can scroll when there are many items; constrain by the middle grid row */
.pm-list.card .products{max-height:100%;overflow-y:auto;padding-right:6px}

/* Make right-column cards independently scrollable inside the grid middle row */
.pm-right .card{height:100%;min-height:0;overflow:auto;padding-right:6px;box-sizing:border-box}

/* Top cards fill the middle grid row and scroll internally so they don't push the prices panel */
.pm-card{align-self:stretch;height:100%;min-height:0;overflow:auto;box-sizing:border-box}

/* Make the right list card match the left card height exactly */
.pm-right > .pm-list.card{height:100%;display:flex;flex-direction:column}
.pm-right > .pm-list.card .products{flex:1 1 auto;min-height:0}

/* Make the left form and the right list have the same visual height */
.pm-card, .pm-list.card{
  height:100%;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(12,20,40,0.04);
}

/* Ensure .pm-list acts like a column so header stays visible */
 
.pm-list.card .list-header{flex:0 0 auto}
.pm-list.card .products{flex:1 1 auto;overflow-y:auto;padding-right:6px}

/* Prevent horizontal scrolling due to long text */
.product-row{word-wrap:break-word;word-break:break-word}
.list-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}
#pmSearch{width:260px;padding:8px;border-radius:8px;border:1px solid #eef3fb}

.products{display:flex;flex-direction:column;gap:8px}
.product-row{display:flex;align-items:center;justify-content:space-between;padding:10px;border-radius:8px;border:1px solid #f1f5f9;background:#fff}
.product-left{display:flex;flex-direction:column}
.product-name{font-weight:700}
.product-meta{color:var(--muted);font-size:13px;margin-top:6px}
.product-actions{display:flex;gap:8px}
.small{font-size:13px;color:var(--muted)}
.muted{color:var(--muted)}
@media (max-width:720px){.grid3{grid-template-columns:1fr}}

@media (max-width:980px){
  .pm-container{grid-template-columns:1fr;grid-template-rows:auto auto auto;max-width:980px}
  .pm-list.card{margin-top:16px}
}

/* ensure bottom content isn't hidden behind fixed controls */
.pm-container{padding-bottom:100px}

.tag-input-row{display:flex;gap:8px;align-items:center}
.tag-input-row input{flex:1}
.tag-list{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px;font-size:13px}
.tag-pill{padding:6px 10px;border-radius:999px;border:1px solid #e6edf6;background:#f9fbff;display:flex;gap:6px;align-items:center}
.tag-pill button{border:none;background:transparent;cursor:pointer;font-size:12px;color:#c0392b}

/* Prices form compact layout tweaks */
.prices-form label{font-size:13px;margin-bottom:6px}
.prices-form input, .prices-form select{padding:8px;border-radius:8px}
/* Make inputs fill their container to avoid overlap */
.prices-form input, .prices-form select{width:100%;box-sizing:border-box}

/* Center items vertically and keep the add-button aligned to the bottom */
.prices-form{align-items:center}
.prices-form > div:last-child{align-self:flex-end}

@media (max-width:980px){
  .prices-form{flex-direction:column}
}
