/* Paywall (js/entitlements.js): dialog, product cards, lock badges on the view buttons, customer BOM drawer.
   Tokens mirror the New UI shell (css/layouts.css --l-*), dark by default, light under body.theme-light. */
.pw-scope{
  --l-bg:#0d1526; --l-surface:#121d33; --l-surface2:#16233d; --l-border:#27344f;
  --l-text:#e8edf5; --l-muted:#9aa7bd; --l-accent:#10b981; --l-accent-ink:#06281d; --l-warn:#f59e0b;
  --l-shadow:0 8px 30px rgba(0,0,0,.42); --l-radius:14px;
}
body.theme-light .pw-scope{
  --l-bg:#eef1f5; --l-surface:#ffffff; --l-surface2:#f5f7fa; --l-border:#e2e8f0;
  --l-text:#0f172a; --l-muted:#5b6675; --l-accent:#0ea371; --l-accent-ink:#ffffff; --l-warn:#b45309;
  --l-shadow:0 8px 28px rgba(16,24,40,.14);
}

/* ---- dialog ---- */
.pw-dialog{
  width:min(720px,calc(100vw - 32px)); max-height:min(92dvh,900px); padding:0; margin:auto;
  border:1px solid var(--l-border); border-radius:var(--l-radius); background:var(--l-surface); color:var(--l-text);
  box-shadow:var(--l-shadow); font:14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif; overflow:hidden;
}
.pw-dialog[open]{ display:flex; flex-direction:column; }
.pw-dialog::backdrop{ background:rgba(6,12,24,.72); }
.pw-dialog header,.pw-dialog footer{ display:flex; align-items:center; gap:12px; padding:14px 18px; flex:none; }
.pw-dialog header{ justify-content:space-between; border-bottom:1px solid var(--l-border); }
.pw-dialog h2{ margin:0; font-size:17px; font-weight:700; letter-spacing:-.01em; }
.pw-dialog p{ margin:0 0 10px; }
.pw-x{ width:34px; height:34px; border-radius:8px; border:0; background:transparent; color:var(--l-muted); display:grid; place-items:center; cursor:pointer; flex:none; }
.pw-x:hover{ background:var(--l-surface2); color:var(--l-text); }
.pw-body{ padding:16px 18px; overflow:auto; overscroll-behavior:contain; min-height:0; }
.pw-why{ color:var(--l-muted); font-size:13px; }
.pw-dialog footer{ border-top:1px solid var(--l-border); flex-wrap:wrap; justify-content:flex-end; }
.pw-total{ display:flex; align-items:baseline; gap:8px; margin-right:auto; }
.pw-total span{ color:var(--l-muted); font-size:12px; text-transform:uppercase; letter-spacing:.06em; }
.pw-total b{ font-size:20px; font-variant-numeric:tabular-nums; }
.pw-msg{ flex:1 1 100%; order:3; margin:0; color:var(--l-muted); font-size:13px; }
.pw-msg:empty{ display:none; }
.pw-primary,.pw-secondary{ font:inherit; font-weight:700; border-radius:9px; padding:10px 18px; cursor:pointer; min-height:42px; }
.pw-primary{ border:0; background:var(--l-accent); color:var(--l-accent-ink); }
.pw-primary:disabled{ opacity:.45; cursor:default; }
.pw-secondary{ border:1px solid var(--l-border); background:var(--l-surface2); color:var(--l-text); }
.pw-dialog :focus-visible{ outline:2px solid var(--l-accent); outline-offset:2px; }

/* ---- product cards ---- */
.pw-cards{ display:grid; grid-template-columns:repeat(auto-fill,minmax(250px,1fr)); gap:10px; }
.pw-bundle{ margin-top:10px; }
.pw-card{ display:flex; gap:10px; align-items:flex-start; padding:12px 13px; border:1px solid var(--l-border); border-radius:11px; background:var(--l-surface2); cursor:pointer; }
.pw-card:has(input:checked){ border-color:var(--l-accent); box-shadow:inset 3px 0 0 var(--l-accent); }
.pw-card.pw-unlocks{ border-style:solid; }
.pw-card input{ width:18px; height:18px; margin:2px 0 0; flex:none; accent-color:var(--l-accent); }
.pw-card-main{ min-width:0; flex:1; }
.pw-card-top{ display:flex; justify-content:space-between; gap:8px; align-items:baseline; }
.pw-card-top strong{ font-size:14px; }
.pw-price{ font-weight:700; white-space:nowrap; font-variant-numeric:tabular-nums; }
.pw-card p{ margin:4px 0 0; font-size:12.5px; color:var(--l-muted); }
.pw-inc{ margin:6px 0 0; padding-left:17px; font-size:12px; color:var(--l-muted); list-style:disc; }
.pw-soon{ opacity:.6; cursor:default; }
.pw-soon .pw-price{ color:var(--l-warn); font-size:12px; text-transform:uppercase; letter-spacing:.05em; }
.pw-card-bundle{ background:var(--l-bg); }

/* ---- My projects ---- */
.pw-projects{ list-style:none; margin:0; padding:0; display:grid; gap:6px; }
.pw-project{ width:100%; display:flex; justify-content:space-between; gap:10px; padding:11px 12px; border:1px solid var(--l-border); border-radius:10px; background:var(--l-surface2); color:var(--l-text); font:inherit; text-align:left; cursor:pointer; }
.pw-project:hover,.pw-project.pw-current{ border-color:var(--l-accent); }
.pw-project span{ color:var(--l-muted); font-size:12px; white-space:nowrap; }

/* ---- lock badges on locked view buttons (New UI) ---- */
.pw-lock{ display:inline-flex; vertical-align:-1px; margin-left:4px; opacity:.85; }
.pw-lock svg{ width:11px; height:11px; }
.lyt-views button.pw-locked{ color:var(--l-muted); }
.lyt-viewmenu button.pw-locked{ opacity:.85; }

/* ---- customer BOM drawer: quantities without prices / section totals ---- */
.pw-bom-note{ padding:10px 12px; border:1px solid var(--l-border); border-radius:10px; background:var(--l-surface2); color:var(--l-text); font-size:12.5px; }
.pw-bom-note p{ margin:0 0 6px; }
.pw-link{ border:0; background:transparent; color:var(--l-accent); font:inherit; font-weight:700; padding:2px 0; cursor:pointer; }
.pw-totals{ width:100%; border-collapse:collapse; margin:4px 0 8px; font-variant-numeric:tabular-nums; }
.pw-totals td{ padding:4px 2px; border-bottom:1px solid var(--l-border); }
.pw-totals td:last-child{ text-align:right; }
.pw-total-row td{ font-weight:700; border-bottom:0; }
/* Only the app's own BOM table (a direct child), never the injected .pw-totals table inside #pw-bom-note. */
body.pw-no-pricing #project-summary > table th:nth-child(4),
body.pw-no-pricing #project-summary > table td:nth-child(4),
body.pw-no-pricing #bom-tbody tr:last-child,
body.pw-no-pricing #lyt-total-seg{ display:none !important; }
/* The dealer's Markup % and misc-item editor are staff tools: hidden from every customer while the paywall applies. */
body.pw-on #project-summary > .grid{ display:none !important; }
body.pw-no-materials #project-summary > table,
body.pw-no-materials #bom-takeoff-summary{ display:none !important; }

@media (max-width:640px){
  .pw-dialog{ width:100%; max-width:100%; height:100dvh; max-height:100dvh; border-radius:0; border:0; }
  .pw-dialog header,.pw-dialog footer,.pw-body{ padding-left:16px; padding-right:16px; }
  .pw-cards{ grid-template-columns:1fr; }
  .pw-dialog footer{ align-items:stretch; }
  .pw-primary{ flex:1; }
}
@media print{ .pw-dialog{ display:none !important; } }
