/* Masters, Price Matrix, Price List and Customers (UI round 2b). Loaded after dialogs.css; only rules for these pages. */

/* helpers */
.only-phone-i { display: none; }
.m-off { opacity: .75; }
.tx-R { color: var(--err-text); }
.m-h { margin: 0; font-size: 14px; font-weight: 700; color: var(--o-heading); }
.m-note { background: var(--odoo-gray-100); border: 1px solid var(--o-border); border-radius: var(--r); padding: 12px 14px; font-size: 13px; color: var(--o-text2); margin-bottom: 14px; line-height: 1.65; }
.cat-no { width: 20px; height: 20px; border-radius: 50%; background: var(--o-action-lt); color: var(--o-on-tint); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mc-chk { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
table.cards tr.empty-row { grid-template-columns: none; }

/* Masters tabs and filter chips */
.pm-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
.bm-tagbtn.on { background: var(--o-action-lt); border-color: var(--o-action); color: var(--o-on-tint); }

/* Price Matrix: readable cells, sticky product column, no clipped numbers */
.pm-table .pm-prodh, .pm-table .pm-prodc { position: sticky; left: 0; z-index: 1; background: var(--o-surface); min-width: 200px; text-align: left; font-weight: 400; }
.pm-table th.pm-prodh { font-weight: 500; }
.pm-table td.pm-cell { min-width: 104px; }
.pm-table .pm-i { min-width: 72px; width: 100%; text-align: right; font-variant-numeric: tabular-nums; }
.pm-table th.pm-hd { min-width: 104px; white-space: nowrap; }

/* BOM templates list */
tr.bom-row { cursor: pointer; }
tr.bom-row:focus-visible { outline: 2px solid var(--o-action); outline-offset: -2px; }
.bom-chev { display: inline-block; width: 12px; height: 12px; background: currentColor; color: var(--o-text3); transition: transform .15s;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M3 1.5l3.5 3.5L3 8.5' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M3 1.5l3.5 3.5L3 8.5' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; }
tr.bom-row[aria-expanded="true"] .bom-chev { transform: rotate(90deg); }
.bm-ch { text-align: center; width: 22px; }
.bm-pill { display: inline-block; background: var(--o-action-lt); color: var(--o-on-tint); border-radius: 10px; font-size: 11px; padding: 1px 7px; margin-left: 4px; font-weight: 600; }
tr.bom-subrow { display: none; }
tr.bom-subrow.open { display: table-row; }
table.bom-sub { width: 100%; border-collapse: collapse; background: var(--odoo-gray-100); }
table.bom-sub td { padding: 6px 10px; font-size: 13px; border-bottom: 1px solid var(--o-border); color: var(--o-text); }
table.bom-sub td.bs-it { padding-left: 34px; }
.bs-n { color: var(--o-text3); margin-right: 6px; }
.bs-sz { color: var(--o-text3); font-size: 12px; margin-left: 6px; }
.bs-qt { text-align: center; font-weight: 700; }
.bs-rt, .bs-tt { text-align: right; }
table.bom-sub tr.bs-total td { font-weight: 700; background: var(--o-action-lt); color: var(--o-on-tint); border-bottom: 0; }
table.bom-sub tr.bs-total td:last-child { text-align: right; }

/* BOM template builder dialog */
.bb-note { font-size: 11px; color: var(--o-text3); }
.bb-fixed { color: var(--o-on-tint); font-weight: 600; }
.bb-miss { color: var(--err-text); }

/* Price List */
.pl-kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.pl-kpi-v { font-size: 24px; font-weight: 800; letter-spacing: -.03em; }
.pl-saved { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.pl-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; padding: 10px 14px; background: var(--o-surface); border: 1px solid var(--o-border); border-radius: var(--r3, 8px); }
.pl-seg { margin-left: auto; }
.pl-bulk { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 14px; background: var(--o-action-lt); border: 1px solid var(--o-action); border-radius: var(--r3, 8px); margin-bottom: 10px; }
.pl-bulk-n { font-size: 13px; font-weight: 700; color: var(--o-on-tint); }
.pl-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 11px 16px; border-bottom: 1px solid var(--o-border); background: var(--odoo-gray-100); }
.pl-title { font-size: 13px; font-weight: 700; color: var(--o-heading); }
.pl-head-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.pl-list td { padding: 8px 10px; }
.pl-list td.pl-pr { font-family: var(--mn); font-weight: 700; color: var(--ok-text); white-space: nowrap; }
.pl-list td.pl-mn, .pl-list td.pl-mx { font-family: var(--mn); color: var(--o-text2); }
.pl-in { width: 92px; min-width: 72px; text-align: right; font-variant-numeric: tabular-nums; }
tr.pl-cat-row td { background: var(--odoo-gray-100); }
.pl-pvh, .pl-pvn { position: sticky; left: 0; z-index: 1; background: var(--o-surface); text-align: left; }
.pl-pvn { padding: 8px 12px; font-size: 13px; font-weight: 600; }
.pl-pvh { font-weight: 500; }

/* Customers */
tr.cust-row { cursor: pointer; }
tr.cust-row:focus-visible, .mod-wrap .kpi:focus-visible { outline: 2px solid var(--o-action); outline-offset: -2px; }
.mod-wrap .kpi[role="link"] { cursor: pointer; }
tr.cust-arch td { color: var(--o-text3); }
.cust-table td.cc-gs { font-size: 12px; }
.rt-stars { display: inline-flex; align-items: center; gap: 1px; vertical-align: middle; }
.rt-stars .star-on { color: var(--star-on); fill: currentColor; }
.rt-stars .star-off { color: var(--o-text3); fill: none; }

/* ═════════════ PHONES (below 768): card rows ═════════════ */
@media (max-width: 767.98px) {
  .only-phone-i { display: inline; }
  .pl-kpi-grid { grid-template-columns: 1fr 1fr; }
  .pl-seg { margin-left: 0; }
  .pl-filters > input:not([type=checkbox]) { flex: 1 1 120px; min-width: 0; width: auto !important; }
  .pl-filters > select { flex: 1 1 140px; min-width: 0; }
  .pl-rl { display: none; }
  .pl-head { padding: 10px 12px; }
  .pm-chips { margin-left: -2px; }

  /* inputs inside a card get a visible box */
  table.cards td input:not([type=checkbox]):not([type=radio]), table.cards td select { width: 100%; border: 1px solid var(--o-border-input, var(--o-border)) !important; border-radius: var(--r) !important; padding: 4px 8px; background: var(--o-surface); }
  table.cards td input.pl-in { text-align: right; }
  table.cards td.mc-on { text-align: left !important; }

  /* Masters: brands */
  table.m-brands tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "nm ac" "ct ct" "nt nt" "on pc"; align-items: center; }
  table.m-brands .mc-nm { grid-area: nm; } table.m-brands .mc-ac { grid-area: ac; justify-self: end; } table.m-brands .mc-ct { grid-area: ct; } table.m-brands .mc-nt { grid-area: nt; }
  table.m-brands .mc-on { grid-area: on; } table.m-brands .mc-pc { grid-area: pc; justify-self: end; }
  /* Masters: products */
  table.m-prods tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "nm ac" "ct un" "sp sp" "sz sz" "on pc"; align-items: center; }
  table.m-prods .mc-nm { grid-area: nm; } table.m-prods .mc-ac { grid-area: ac; justify-self: end; } table.m-prods .mc-ct { grid-area: ct; } table.m-prods .mc-un { grid-area: un; min-width: 96px; }
  table.m-prods .mc-sp { grid-area: sp; } table.m-prods .mc-sz { grid-area: sz; } table.m-prods .mc-on { grid-area: on; } table.m-prods .mc-pc { grid-area: pc; justify-self: end; }
  table.m-prods tr { gap: 8px; }
  table.m-brands tr { gap: 8px; }
  .cat-grid { grid-template-columns: minmax(0, 1fr); }

  /* Masters: BOM templates */
  table.m-boms tr.bom-row { grid-template-columns: 24px minmax(0, 1fr) auto; grid-template-areas: "ch nm ac" ". ct ct" ". sp sp" ". it co"; align-items: center; }
  table.m-boms .bm-ch { grid-area: ch; } table.m-boms .bm-nm { grid-area: nm; } table.m-boms .bm-ac { grid-area: ac; justify-self: end; } table.m-boms .bm-ct { grid-area: ct; }
  table.m-boms .bm-sp { grid-area: sp; } table.m-boms .bm-it { grid-area: it; text-align: left !important; } table.m-boms .bm-co { grid-area: co; text-align: right; }
  table.m-boms tr.bom-subrow { display: none; padding: 0; }
  table.m-boms tr.bom-subrow.open { display: block; }
  table.m-boms tr.bom-subrow > td { width: 100%; }
  table.bom-sub, table.bom-sub tbody { display: block; width: 100%; }
  table.bom-sub tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "it it" "br qt" "rt tt"; gap: 2px 8px; padding: 8px 12px; border-bottom: 1px solid var(--o-border); }
  table.bom-sub td { display: block; padding: 0 !important; border: 0; }
  table.bom-sub .bs-it { grid-area: it; } table.bom-sub .bs-br { grid-area: br; color: var(--o-text2); } table.bom-sub .bs-qt { grid-area: qt; text-align: right; }
  table.bom-sub .bs-rt { grid-area: rt; text-align: left; } table.bom-sub .bs-tt { grid-area: tt; text-align: right; }
  table.bom-sub tr.bs-total { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "lb am"; }
  table.bom-sub tr.bs-total td:first-child { grid-area: lb; } table.bom-sub tr.bs-total td:last-child { grid-area: am; }

  /* Price List */
  table.pl-list tr { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "ck nm ac" ". ct cv" ". sp sp" ". pr pr" ". mn mx"; align-items: center; }
  table.pl-list.pl-brand tr { grid-template-areas: "ck nm ac" ". ct cv" ". sp sp" ". pr pr"; }
  table.pl-list .pl-ck { grid-area: ck; } table.pl-list .pl-nm { grid-area: nm; } table.pl-list .pl-ac { grid-area: ac; justify-self: end; } table.pl-list .pl-ct { grid-area: ct; }
  table.pl-list .pl-cv { grid-area: cv; justify-self: end; text-align: right !important; } table.pl-list .pl-sp { grid-area: sp; max-width: none !important; white-space: normal !important; }
  table.pl-list .pl-pr { grid-area: pr; text-align: left !important; } table.pl-list .pl-mn { grid-area: mn; text-align: left !important; } table.pl-list .pl-mx { grid-area: mx; text-align: right !important; }
  table.pl-list .pl-un { display: none; }
  table.pl-list td[data-l]::before { content: attr(data-l) ' '; font-size: var(--odoo-fs-small); color: var(--o-text3); font-family: inherit; font-weight: 400; }
  table.pl-list td.pl-pr .pl-in { width: 140px; }

  /* Customers */
  table.cust-table tr { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "nm nm ac" "ph ph ph" "ct ct ct" "rt qt dc"; align-items: center; }
  table.cust-table .cc-nm { grid-area: nm; } table.cust-table .cc-ac { grid-area: ac; justify-self: end; } table.cust-table .cc-ph { grid-area: ph; }
  table.cust-table .cc-ct { grid-area: ct; } table.cust-table .cc-rt { grid-area: rt; text-align: left !important; } table.cust-table .cc-qt { grid-area: qt; text-align: left !important; }
  table.cust-table .cc-dc { grid-area: dc; text-align: right !important; } table.cust-table .cc-gs { display: none; }
  .mod-wrap .kpi-row-4 { grid-template-columns: 1fr 1fr; gap: 8px; }
  .list-toolbar .filter-col > select { flex: 1 1 140px; }
}

/* the visually hidden header text (.sr-only is absolutely positioned) must stay inside its scrolling table, not stretch the page */
.m-brands th, .m-prods th, .m-boms th, .pl-list th, .pl-pivot th, .cust-table th, .bom-sub th, #bb-table-wrap th, table.bom-sub { position: relative; }
.pm-table .pm-prodh, .pm-table .pm-prodc, .pl-pivot th.pl-pvh, .pl-pivot th.pl-pvn { position: sticky; }
