/* ============================================================
   WHMCS Clone — Premium Design System
   Modern, professional, user-attractive look for client area + admin.
   Works alongside the Tailwind CDN: these classes add the premium layer.
   ============================================================ */
:root {
  --pm-font: var(--font-sans);
  --pm-bg: var(--stroke);                 /* slate-100 page background */
  --pm-card: var(--surface-1);
  --pm-border: var(--stroke);             /* slate-200 */
  --pm-text: var(--text-1);               /* slate-900 */
  --pm-muted: var(--text-3);              /* slate-500 */
  --pm-accent1: var(--brand);            /* indigo-600 */
  --pm-accent2: var(--brand);            /* violet-600 */
  --pm-grad: var(--grad-brand);
  --pm-grad-soft: linear-gradient(135deg, var(--brand-soft) 0%, var(--brand-soft) 100%);
  --pm-sidebar: var(--side-2);            /* deep navy */
  --pm-sidebar-2: var(--side-1);
  --pm-shadow: 0 1px 2px var(--ai-04), 0 8px 24px -12px var(--ai-12);
  --pm-shadow-lg: 0 2px 4px var(--ai-05), 0 16px 40px -16px var(--ab-25);
  --pm-radius: 1rem;
}

*, *::before, *::after { box-sizing: border-box; }
* { font-family: var(--pm-font); }
html, body { overflow-x: hidden; overflow-x: clip; max-width: 100%; }
body { background: var(--pm-bg); color: var(--pm-text); -webkit-font-smoothing: antialiased; font-size: var(--fs-md); line-height: var(--lh-base); }

/* ---------- typography scale ---------- */
.pm-content h1 { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.02em; line-height: var(--lh-tight); }
.pm-content h2 { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.01em; line-height: var(--lh-tight); }
.pm-content h3 { font-size: var(--fs-lg); font-weight: 700; line-height: var(--lh-tight); }
.pm-content h4 { font-size: var(--fs-md); font-weight: 600; line-height: var(--lh-base); }
.pm-text-sm { font-size: var(--fs-sm); }
.pm-text-xs { font-size: var(--fs-xs); }
.pm-muted { color: var(--pm-muted); }
.pm-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- links (inside content only; sidebar/topbar unaffected) ---------- */
/* LAYOUT-REPAIR 2026-10-24: merged :not(list) + component exclusions —
   see the matching note in ui-v6.css (the summed-:not chain out-ranked
   component link colours, e.g. .cfg-link.active at 1.3:1). */
.pm-content a:not(.pm-btn, .pm-action, .pm-badge, .pm-page, .pm-tab, .pm-ftab, .pm-tab-active, .pm-kpi, .pm-qa, .pm-stat, .cfg-link, .sup-cat) {
  color: var(--pm-accent1); text-decoration: none;
}
.pm-content a:not(.pm-btn, .pm-action, .pm-badge, .pm-page, .pm-tab, .pm-ftab, .pm-tab-active, .pm-kpi, .pm-qa, .pm-stat, .cfg-link, .sup-cat):hover {
  text-decoration: underline;
}
.pm-link { color: var(--pm-accent1); font-weight: 600; text-decoration: none; }
.pm-link:hover { text-decoration: underline; }
a.pm-btn, a.pm-btn:hover { text-decoration: none !important; }

/* ---------- layout shell ---------- */
.pm-shell { display: flex; min-height: 100vh; }
.pm-sidebar {
  width: 260px; flex-shrink: 0; background: linear-gradient(180deg, var(--pm-sidebar) 0%, var(--pm-sidebar-2) 100%);
  color: var(--text-4); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  box-shadow: 4px 0 24px -8px var(--ai-35); z-index: 40;
}
.pm-brand { padding: 1.25rem 1.25rem 1rem; display: flex; align-items: center; gap: .75rem; border-bottom: 1px solid var(--am-12); }
.pm-brand-mark {
  width: 40px; height: 40px; border-radius: 12px; background: var(--pm-grad); display: grid; place-items: center;
  color: var(--brand-ink); font-weight: 800; font-size: var(--fs-lg); box-shadow: 0 6px 16px -4px var(--ab-50);
}
.pm-brand-name { color: var(--brand-ink); font-weight: 700; font-size: var(--fs-lg); line-height: var(--lh-tight); }
.pm-brand-sub { color: var(--side-muted); font-size: var(--fs-xs); letter-spacing: .08em; text-transform: uppercase; }
.pm-nav { flex: 1; overflow-y: auto; padding: .9rem .8rem; display: flex; flex-direction: column; gap: 2px; }
.pm-nav-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .12em; color: var(--side-label); padding: .8rem .75rem .35rem; font-weight: 700; }
.pm-nav a {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: .7rem;
  color: var(--side-text); font-size: var(--fs-sm); font-weight: 500; text-decoration: none;
  transition: all .18s ease; border: 1px solid transparent;
}
.pm-nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.pm-nav a:hover { background: var(--am-08); color: var(--brand-ink); }
.pm-nav a.pm-active { background: var(--pm-grad); color: var(--brand-ink); box-shadow: 0 6px 18px -6px var(--ab-55); }
.pm-nav a.pm-active svg { opacity: 1; }
.pm-side-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--am-12); font-size: var(--fs-sm); color: var(--side-muted); }
.pm-side-foot a { color: var(--side-muted); text-decoration: none; }
.pm-side-foot a:hover { color: var(--brand-ink); }

.pm-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pm-topbar {
  position: sticky; top: 0; z-index: 30; background: var(--aw-82); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--pm-border); padding: .8rem 1.75rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
/* 2026-10-26 product-add fix (Issues 1–2): the sticky .pm-topbar (~82px)
   sits over the top of the viewport, so a submit button scrolled to the
   viewport top was parked UNDER it and a click landed on the topbar
   instead of the button (Enter-key submit always worked — no click
   coordinates involved). scroll-margin keeps every admin submit button
   clear of the sticky header on any scroll-into-view. */
.pm-main button[type="submit"], .pm-main form button:not([type]), .pm-main input[type="submit"] { scroll-margin-top: 100px; }
.pm-page-title { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.01em; margin: 0; }
.pm-page-sub { font-size: var(--fs-sm); color: var(--pm-muted); margin-top: 2px; }
.pm-top-actions { display: flex; align-items: center; gap: .75rem; }
.pm-avatar {
  width: 38px; height: 38px; border-radius: 9999px; background: var(--pm-grad); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 700; font-size: var(--fs-sm);
  box-shadow: 0 4px 12px -4px var(--ab-50);
}
.pm-hamburger { display: none; background: none; border: 1px solid var(--pm-border); border-radius: .6rem; padding: .45rem .6rem; cursor: pointer; }
.pm-content { padding: 1.75rem; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ---------- cards & panels ---------- */
.pm-card {
  background: var(--pm-card); border: 1px solid var(--pm-border); border-radius: var(--pm-radius);
  box-shadow: var(--pm-shadow); margin-bottom: 1.25rem; overflow: hidden;
  transition: box-shadow .2s ease, transform .2s ease;
}
.pm-card:hover { box-shadow: var(--pm-shadow-lg); }
.pm-card-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--pm-border); display: flex; align-items: center; justify-content: space-between; background: linear-gradient(180deg, var(--surface-1), var(--surface-3)); }
.pm-card-head h2, .pm-card-head h3 { font-weight: 700; font-size: var(--fs-md); color: var(--pm-text); margin: 0; }
.pm-card-body { padding: 1.25rem; }
.pm-card-body.flush { padding: 0; }

/* ---------- stat cards ---------- */
.pm-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.pm-stat {
  border-radius: var(--pm-radius); padding: 1.25rem; color: var(--brand-ink); position: relative; overflow: hidden;
  box-shadow: var(--pm-shadow-lg); transition: transform .2s ease;
}
.pm-stat:hover { transform: translateY(-3px); }
.pm-stat::after { content: ''; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: var(--aw-12); }
.pm-stat .pm-stat-val { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -.02em; line-height: var(--lh-tight); }
/* SWEEP-FIX 2026-10-26 (S21): .pm-stat-num renders the SAME look but is
   never touched by ui.js count-up — .pm-stat-val is auto-parsed and
   animated (900ms), so a mid-animation read showed 1 for a true 2 and
   the cards "flipped" between loads. Stat tiles always show the final
   server-rendered value now. */
.pm-stat .pm-stat-num { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -.02em; line-height: var(--lh-tight); }
.pm-stat .pm-stat-label { font-size: var(--fs-xs); opacity: .88; margin-top: .25rem; font-weight: 500; }
.pm-stat .pm-stat-icon { position: absolute; right: 1rem; bottom: 1rem; opacity: .35; }
.pm-stat .pm-stat-icon svg { width: 34px; height: 34px; }
/* LAYOUT-REPAIR 2026-10-24: variants point at the deepened --grad-stat-*
   tokens — every stop now holds white text ≥3:1 in both themes (the old
   ok/info/warn stops measured 2.0–2.5:1; stat-6's text-2→text-1 gradient
   inverted to a near-white surface in dark theme). */
.pm-stat-1 { background: var(--grad-brand); }
.pm-stat-2 { background: var(--grad-stat-5); }
.pm-stat-3 { background: var(--grad-stat-3); }
.pm-stat-4 { background: var(--grad-stat-4); }
.pm-stat-5 { background: var(--grad-rose); }
.pm-stat-6 { background: var(--grad-stat-6); }

/* ---------- tables ---------- */
.pm-table-wrap { overflow-x: auto; border-radius: 0 0 var(--pm-radius) var(--pm-radius); }
table.pm-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.pm-table thead th {
  text-align: left; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--pm-muted); padding: .7rem 1rem; background: var(--surface-3); border-bottom: 1px solid var(--pm-border); white-space: nowrap;
}
.pm-table tbody td { padding: .8rem 1rem; border-bottom: 1px solid var(--stroke); vertical-align: middle; }
.pm-table tbody tr:last-child td { border-bottom: none; }
.pm-table tbody tr { transition: background .15s ease; }
.pm-table tbody tr:hover { background: var(--surface-3); }

/* ---------- badges ---------- */
.pm-badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .65rem; border-radius: 9999px;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em; white-space: nowrap;
}
.pm-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.pm-b-green { background: var(--b-ok-bg); color: var(--b-ok-fg); }
.pm-b-red { background: var(--b-bad-bg); color: var(--b-bad-fg); }
.pm-b-yellow { background: var(--b-warn-bg); color: var(--b-warn-fg); }
.pm-b-blue { background: var(--b-info-bg); color: var(--b-info-fg); }
.pm-b-gray { background: var(--stroke); color: var(--text-3); }
.pm-b-purple { background: var(--b-purp-bg); color: var(--b-purp-fg); }
.pm-b-orange { background: var(--b-orng-bg); color: var(--b-orng-fg); }
.pm-b-teal { background: var(--b-teal-bg); color: var(--b-teal-fg); }
.pm-b-cyan { background: var(--b-info-bg); color: var(--b-info-fg); }
.pm-b-amber { background: var(--b-warn-bg); color: var(--b-warn-fg); }
.pm-b-sky { background: var(--b-info-bg); color: var(--b-info-fg); }
.pm-b-indigo { background: var(--brand-soft); color: var(--b-purp-fg); }

/* ---------- buttons ---------- */
.pm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .55rem 1.1rem; border-radius: .7rem; font-size: var(--fs-sm); font-weight: 600;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: all .18s ease; white-space: nowrap;
}
.pm-btn svg { width: 15px; height: 15px; }
.pm-btn-primary { background: var(--pm-grad); color: var(--brand-ink); box-shadow: 0 6px 16px -6px var(--ab-55); }
.pm-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px -6px var(--ab-60); filter: brightness(1.06); }
.pm-btn-danger { background: linear-gradient(135deg, var(--bad), var(--bad-deep)); color: var(--brand-ink); box-shadow: 0 6px 16px -6px var(--abd-50); }
.pm-btn-danger:hover { transform: translateY(-1px); filter: brightness(1.06); }
.pm-btn-ghost { background: var(--surface-1); border-color: var(--pm-border); color: var(--pm-text); }
.pm-btn-ghost:hover { border-color: var(--ab-35); background: var(--surface-3); color: var(--pm-accent1); }
.pm-btn-sm { padding: .35rem .75rem; font-size: var(--fs-xs); border-radius: .55rem; }
.pm-btn-lg { padding: .8rem 1.6rem; font-size: var(--fs-md); border-radius: .85rem; }

/* module action buttons (service detail) */
.pm-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.pm-action {
  display: inline-flex; align-items: center; gap: .5rem; padding: .6rem 1.05rem; border-radius: .75rem;
  font-size: var(--fs-sm); font-weight: 600; background: var(--surface-1); border: 1px solid var(--pm-border); color: var(--pm-text);
  cursor: pointer; transition: all .18s ease; box-shadow: 0 1px 2px var(--ai-05);
}
.pm-action:hover { border-color: var(--pm-accent1); color: var(--pm-accent1); transform: translateY(-1px); box-shadow: var(--pm-shadow); }
.pm-action.pm-action-danger:hover { border-color: var(--bad); color: var(--bad-deep); }
.pm-action svg { width: 16px; height: 16px; }

/* ---------- tabs (admin client profile) ---------- */
.pm-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.25rem; padding: .4rem; background: var(--surface-1); border: 1px solid var(--pm-border); border-radius: .9rem; box-shadow: var(--pm-shadow); }
.pm-tabs a {
  padding: .5rem .95rem; border-radius: .65rem; font-size: var(--fs-sm); font-weight: 600; color: var(--pm-muted);
  text-decoration: none; transition: all .16s ease; border: 1px solid transparent;
}
.pm-tabs a:hover { color: var(--pm-accent1); background: var(--brand-soft); }
.pm-tabs a.pm-tab-active { background: var(--pm-grad); color: var(--brand-ink); box-shadow: 0 4px 12px -4px var(--ab-50); }

/* ---------- forms ---------- */
.pm-field { margin-bottom: 1rem; }
.pm-field label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); margin-bottom: .35rem; }
.pm-input, .pm-select {
  width: 100%; border: 1px solid var(--pm-border); border-radius: .7rem; padding: .6rem .85rem;
  font-size: var(--fs-sm); background: var(--surface-1); transition: all .16s ease; color: var(--pm-text);
}
.pm-input:focus, .pm-select:focus { outline: none; border-color: var(--pm-accent1); box-shadow: 0 0 0 3px var(--ab-14); }
.pm-help { font-size: var(--fs-xs); color: var(--pm-muted); margin-top: .3rem; }

/* ---------- alerts ---------- */
.pm-alert { padding: .85rem 1.1rem; border-radius: .8rem; font-size: var(--fs-sm); margin-bottom: 1.1rem; border: 1px solid; display: flex; gap: .6rem; align-items: flex-start; }
.pm-alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.pm-alert-error { background: var(--b-bad-bg); border-color: var(--b-bad-bg); color: var(--b-bad-fg); }
.pm-alert-success { background: var(--b-ok-bg); border-color: var(--ao-40); color: var(--b-ok-fg); }
.pm-alert-warn { background: var(--b-warn-bg); border-color: var(--awn-45); color: var(--b-warn-fg); }
.pm-alert-info { background: var(--b-info-bg); border-color: var(--ain-35); color: var(--b-info-fg); }

/* ---------- page header ---------- */
.pm-pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.pm-pagehead h1 { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.02em; margin: 0; }
.pm-pagehead p { color: var(--pm-muted); font-size: var(--fs-sm); margin: .25rem 0 0; }

/* ---------- CSS bar chart (no JS) ---------- */
.pm-bars { display: flex; align-items: flex-end; gap: 10px; height: 120px; padding: 1rem 1.25rem .5rem; }
.pm-bar { flex: 1; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, var(--brand-hi), var(--brand)); min-height: 6px; position: relative; transition: filter .15s; }
.pm-bar:hover { filter: brightness(1.15); }
.pm-bar span { position: absolute; bottom: -1.35rem; left: 50%; transform: translateX(-50%); font-size: var(--fs-xs); color: var(--pm-muted); font-weight: 600; white-space: nowrap; }
.pm-bar-v { background: linear-gradient(180deg, var(--b-purp-fg), var(--brand)); }

/* ---------- list rows ---------- */
.pm-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 0; border-bottom: 1px solid var(--stroke); font-size: var(--fs-sm); }
.pm-row:last-child { border-bottom: none; }
.pm-kv { display: grid; grid-template-columns: 150px 1fr; gap: .4rem 1rem; font-size: var(--fs-sm); }
.pm-kv dt { color: var(--pm-muted); font-weight: 500; }
.pm-kv dd { margin: 0; font-weight: 600; }

/* ---------- storefront polish ---------- */
.pm-hero { background: var(--grad-hero); border-radius: 1.5rem; color: var(--brand-ink); padding: 3rem 2.5rem; position: relative; overflow: hidden; margin-bottom: 2rem; }
.pm-hero::before { content: ''; position: absolute; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, var(--ab-35), transparent 70%); right: -120px; top: -120px; }
.pm-hero::after { content: ''; position: absolute; width: 300px; height: 300px; border-radius: 50%; background: radial-gradient(circle, var(--ab-30), transparent 70%); left: -80px; bottom: -100px; }
.pm-hero h1 { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -.02em; position: relative; z-index: 1; margin: 0 0 .75rem; }
.pm-hero p { color: var(--ab-35); font-size: var(--fs-lg); position: relative; z-index: 1; max-width: 560px; }
.pm-price-card { transition: transform .22s ease, box-shadow .22s ease; }
.pm-price-card:hover { transform: translateY(-6px); box-shadow: var(--pm-shadow-lg); }

/* ---------- footer ---------- */
.pm-footer { margin-top: auto; padding: 1.25rem 1.75rem; color: var(--pm-muted); font-size: var(--fs-xs); border-top: 1px solid var(--pm-border); background: var(--surface-1); }

/* ---------- responsive ---------- */
.pm-overlay { display: none; }
@media (max-width: 900px) {
  .pm-sidebar { position: fixed; left: 0; top: 0; transform: translateX(-105%); transition: transform .25s ease; }
  body.pm-nav-open .pm-sidebar { transform: translateX(0); }
  body.pm-nav-open .pm-overlay { display: block; position: fixed; inset: 0; background: var(--ai-50); z-index: 35; }
  .pm-hamburger { display: inline-flex; }
  .pm-content { padding: 1.1rem; }
  .pm-topbar { padding: .7rem 1.1rem; }
  .pm-hero { padding: 2rem 1.5rem; }
  .pm-hero h1 { font-size: var(--fs-xl); }
}

/* ============================================================
   DESIGN SYSTEM v2 — extensions (all additions, back-compat)
   ============================================================ */

/* ---------- tables: serial column + zebra ---------- */
.pm-srno { width: 3.2rem; text-align: center; color: var(--pm-muted); font-weight: 600; }
th.pm-srno, td.pm-srno { text-align: center; }
.pm-table-striped tbody tr:nth-child(even) { background: var(--surface-3); }
.pm-table-striped tbody tr:nth-child(even):hover { background: var(--surface-3); }

/* ---------- semantic status badges (same palette as .pm-b-*) ---------- */
.pm-badge-active { background: var(--b-ok-bg); color: var(--b-ok-fg); }
.pm-badge-completed { background: var(--b-ok-bg); color: var(--b-ok-fg); }
.pm-badge-paid { background: var(--b-ok-bg); color: var(--b-ok-fg); }
.pm-badge-complete { background: var(--b-ok-bg); color: var(--b-ok-fg); }
.pm-badge-pending { background: var(--b-warn-bg); color: var(--b-warn-fg); }
.pm-badge-onhold { background: var(--b-warn-bg); color: var(--b-warn-fg); }
.pm-badge-suspended { background: var(--b-orng-bg); color: var(--b-orng-fg); }
.pm-badge-unpaid { background: var(--b-bad-bg); color: var(--b-bad-fg); }
.pm-badge-incomplete { background: var(--b-bad-bg); color: var(--b-bad-fg); }
.pm-badge-failed { background: var(--b-bad-bg); color: var(--b-bad-fg); }
.pm-badge-overdue { background: var(--b-bad-bg); color: var(--b-bad-fg); }
.pm-badge-open { background: var(--b-info-bg); color: var(--b-info-fg); }
.pm-badge-processing { background: var(--b-info-bg); color: var(--b-info-fg); }
.pm-badge-answered { background: var(--b-teal-bg); color: var(--b-teal-fg); }
.pm-badge-closed { background: var(--stroke); color: var(--text-3); }
.pm-badge-cancelled { background: var(--stroke); color: var(--text-3); }
.pm-badge-terminated { background: var(--stroke); color: var(--text-3); }
.pm-badge-draft { background: var(--stroke); color: var(--text-3); }
.pm-badge-fraud { background: var(--b-purp-bg); color: var(--b-purp-fg); }
.pm-badge-refunded { background: var(--brand-soft); color: var(--b-purp-fg); }
.pm-badge-inprogress { background: var(--b-info-bg); color: var(--b-info-fg); }
.pm-badge-customerreply { background: var(--b-info-bg); color: var(--b-info-fg); }
.pm-badge-default { background: var(--stroke); color: var(--text-3); }

/* ---------- buttons: extra variants + xs ---------- */
.pm-btn-secondary { background: var(--surface-1); border-color: var(--ab-35); color: var(--pm-accent1); }
.pm-btn-secondary:hover { background: var(--brand-soft); border-color: var(--pm-accent1); }
.pm-btn-success { background: linear-gradient(135deg, var(--ok), var(--ok-deep)); color: var(--brand-ink); box-shadow: 0 6px 16px -6px var(--ao-50); }
.pm-btn-success:hover { transform: translateY(-1px); filter: brightness(1.06); }
.pm-btn-warning { background: linear-gradient(135deg, var(--warn), var(--warn-deep)); color: var(--brand-ink); box-shadow: 0 6px 16px -6px var(--awn-50); }
.pm-btn-warning:hover { transform: translateY(-1px); filter: brightness(1.06); }
.pm-btn-xs { padding: .22rem .55rem; font-size: var(--fs-xs); border-radius: .45rem; }

/* ---------- tabs: line variant (real tab look) ---------- */
.pm-tabs-line { display: flex; flex-wrap: wrap; gap: 1rem; border-bottom: 2px solid var(--pm-border); margin-bottom: 1.25rem; }
.pm-tabs-line a {
  padding: .6rem .25rem; font-size: var(--fs-sm); font-weight: 500; color: var(--pm-muted);
  text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s ease;
}
.pm-tabs-line a:hover { color: var(--pm-accent1); text-decoration: none !important; }
.pm-tabs-line a.pm-tab-active { color: var(--pm-accent1); border-bottom-color: var(--pm-accent1); font-weight: 700; }

/* ---------- pagination ---------- */
.pm-pagination { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; margin-top: 1.1rem; }
.pm-page {
  display: inline-flex; align-items: center; justify-content: center; min-width: 2.1rem;
  padding: .4rem .7rem; border: 1px solid var(--pm-border); border-radius: .6rem;
  font-size: var(--fs-sm); font-weight: 600; color: var(--pm-text); background: var(--surface-1);
  text-decoration: none; transition: all .15s ease; line-height: var(--lh-tight);
}
a.pm-page { color: var(--pm-text); }
.pm-content a.pm-page:hover, a.pm-page:hover { border-color: var(--pm-accent1); color: var(--pm-accent1); text-decoration: none; }
.pm-page.pm-active { background: var(--pm-grad); color: var(--brand-ink); border-color: transparent; box-shadow: 0 4px 12px -4px var(--ab-50); }
span.pm-page.pm-disabled { color: var(--text-4); background: var(--surface-3); cursor: default; }
.pm-pageinfo { margin-left: auto; font-size: var(--fs-xs); color: var(--pm-muted); }

/* ---------- empty state ---------- */
.pm-empty { text-align: center; padding: 2.5rem 1rem; color: var(--pm-muted); font-size: var(--fs-sm); }
.pm-empty h3 { color: var(--pm-text); font-size: var(--fs-lg); font-weight: 700; margin: 0 0 .35rem; }

/* ---------- topbar / inline search ---------- */
.pm-search {
  border: 1px solid var(--pm-border); border-radius: 999px; padding: .45rem .9rem;
  font-size: var(--fs-sm); width: 220px; outline: none; background: var(--surface-1); color: var(--pm-text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.pm-search:focus { border-color: var(--pm-accent1); box-shadow: 0 0 0 3px var(--ab-14); }

/* generic content-link rule must not recolor tab components (later + equal specificity) */
.pm-content .pm-tabs a { color: var(--pm-muted); }
.pm-content .pm-tabs a:hover { color: var(--pm-accent1); }
.pm-content .pm-tabs a.pm-tab-active { color: var(--brand-ink); }
.pm-content .pm-tabs-line a { color: var(--pm-muted); }
.pm-content .pm-tabs-line a:hover { color: var(--pm-accent1); text-decoration: none; }
.pm-content .pm-tabs-line a.pm-tab-active { color: var(--pm-accent1); }

/* ============================================================
   DESIGN SYSTEM v3 — HORIZONTAL OVERFLOW FIX (F1)
   Root causes fixed here (measured at 1366px: docScrollW was
   1399 = 33px page overflow, 4th stat card right edge 1371):
   1) No box-sizing reset of our own — layout depended on the
      Tailwind CDN preflight. width:100% + padding elements
      (.pm-content, topbar, store wrappers) overflowed by their
      padding whenever the CDN was slow/blocked.
   2) Grid/flex children kept their automatic minimum size
      (min-content), so a wide table/row forced its track wider
      than the viewport instead of scrolling internally.
   3) Tables with nowrap headers/cells and unwrapped tables
      could widen cards; long values had no wrap discipline.
   ============================================================ */

/* ---------- shell: never wider than the viewport ---------- */
.pm-shell { width: 100%; max-width: 100vw; }
.pm-main { max-width: 100%; }
.pm-content { box-sizing: border-box; min-width: 0; }
.pm-topbar { box-sizing: border-box; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.pm-topbar > * { min-width: 0; }
.pm-top-actions { flex-wrap: wrap; min-width: 0; }
.pm-top-actions form { min-width: 0; }
.pm-search { max-width: 100%; }
.pm-page-title { overflow-wrap: break-word; }

/* ---------- grid/flex children must be allowed to shrink ---------- */
.pm-content .grid > *, .pm-stats > *, .pm-kv > * { min-width: 0; }
.pm-card { min-width: 0; max-width: 100%; }
.pm-card-head { flex-wrap: wrap; gap: .5rem; min-width: 0; }
.pm-card-head > * { min-width: 0; }
.pm-card-body { min-width: 0; }
.pm-pagehead > * { min-width: 0; }
.pm-row { flex-wrap: wrap; min-width: 0; }
.pm-row > * { min-width: 0; }
.pm-row > :last-child { overflow-wrap: anywhere; }
.pm-kv { grid-template-columns: minmax(0, 150px) minmax(0, 1fr); }
.pm-kv dd { overflow-wrap: anywhere; }

/* ---------- stat cards: fit 4 across at 1280–1366, wrap below ---------- */
.pm-stats { grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); max-width: 100%; }
.pm-stat { min-width: 0; }
.pm-stat .pm-stat-val { overflow-wrap: anywhere; }
.pm-stat .pm-stat-label { overflow-wrap: break-word; }

/* ---------- tables: scroll inside their wrapper, never widen the page ---------- */
.pm-table-wrap { max-width: 100%; -webkit-overflow-scrolling: touch; }
.pm-content .overflow-x-auto { max-width: 100%; }
.pm-table td { overflow-wrap: break-word; }
.pm-table td.pm-num, .pm-table th.pm-num { overflow-wrap: normal; }
/* safety net: a table placed directly in a card body (no wrapper)
   becomes its own scroll container instead of widening the card */
.pm-card-body > table.pm-table, .pm-card > table.pm-table {
  display: block; overflow-x: auto; max-width: 100%;
}
.pm-content table { max-width: 100%; }
.pm-content img, .pm-content video, .pm-content iframe { max-width: 100%; }
.pm-content pre { max-width: 100%; overflow-x: auto; }
.pm-content input, .pm-content select, .pm-content textarea, .pm-content form { max-width: 100%; }

/* ---------- layout fallbacks: premium layout must not depend on
   the Tailwind CDN for its grid structure (CDN slow/blocked =
   stacked full-width cards + stretched tables before this fix) ---------- */
.pm-content .grid { display: grid; }
.pm-content .gap-2 { gap: .5rem; } .pm-content .gap-3 { gap: .75rem; }
.pm-content .gap-4 { gap: 1rem; } .pm-content .gap-5 { gap: 1.25rem; }
.pm-content .gap-6 { gap: 1.5rem; } .pm-content .gap-x-6 { column-gap: 1.5rem; }
.pm-content .grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pm-content .grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 640px) {
  .pm-content .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 768px) {
  .pm-content .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pm-content .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pm-content .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .pm-content .md\:grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .pm-content .md\:grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* ---------- tighter content padding as the viewport narrows ---------- */
@media (max-width: 1200px) {
  .pm-content { padding: 1.35rem; }
  .pm-topbar { padding: .75rem 1.25rem; }
}
@media (max-width: 640px) {
  .pm-search { width: 150px; }
  .pm-stats { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); }
  .pm-kv { grid-template-columns: minmax(0, 110px) minmax(0, 1fr); }
}

/* ============================================================
   DESIGN SYSTEM v3 — filled filter tabs (F2 fix)
   Filter/tab bars must NEVER render as bare text links: the
   container has a visible slate background and every item is
   a pill with its own background; the active pill is filled
   with the indigo→violet gradient.
   ============================================================ */

/* ---------- filled filter tabs (horizontal) ---------- */
.pm-filter-tabs {
  display: flex; flex-wrap: wrap; align-items: center; gap: .45rem;
  background: var(--surface-3); border: 1px solid var(--pm-border); border-radius: .9rem;
  padding: .5rem; margin-bottom: 1.25rem;
}
.pm-filter-tabs .pm-filter-label {
  font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: var(--pm-muted); padding: 0 .5rem 0 .35rem; white-space: nowrap;
}
.pm-ftab {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem .95rem; border-radius: 9999px;
  background: var(--surface-1); border: 1px solid var(--pm-border);
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-2);
  text-decoration: none !important; line-height: var(--lh-tight); white-space: nowrap;
  box-shadow: 0 1px 2px var(--ai-05);
  transition: all .16s ease; cursor: pointer;
}
.pm-ftab:hover { border-color: var(--brand-hi); color: var(--pm-accent1); background: var(--brand-soft); text-decoration: none !important; transform: translateY(-1px); }
.pm-ftab.active, .pm-ftab.pm-ftab-active {
  background: var(--pm-grad); color: var(--brand-ink) !important; border-color: transparent;
  box-shadow: 0 6px 16px -6px var(--ab-55);
}
.pm-ftab.active:hover, .pm-ftab.pm-ftab-active:hover { color: var(--brand-ink) !important; background: var(--pm-grad); filter: brightness(1.07); }
.pm-ftab .pm-ftab-count, .pm-ftab-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.35rem; padding: .08rem .42rem; border-radius: 9999px;
  background: var(--brand-soft); color: var(--pm-accent1);
  font-size: var(--fs-xs); font-weight: 700; line-height: var(--lh-tight);
}
.pm-ftab.active .pm-ftab-count, .pm-ftab.pm-ftab-active .pm-ftab-count { background: var(--aw-24); color: var(--brand-ink); }
.pm-ftab-spacer { margin-left: auto; display: inline-flex; align-items: center; gap: .5rem; }

/* ---------- filled filter tabs (vertical sidebar variant) ---------- */
.pm-side-filter {
  background: var(--pm-card); border: 1px solid var(--pm-border); border-radius: var(--pm-radius);
  box-shadow: var(--pm-shadow); padding: .9rem; margin-bottom: 1.25rem;
}
.pm-side-filter .pm-filter-label {
  display: block; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: var(--pm-muted); padding: .15rem .5rem .6rem;
}
.pm-filter-tabs--vertical { flex-direction: column; align-items: stretch; background: var(--surface-3); }
.pm-filter-tabs--vertical .pm-ftab { justify-content: space-between; width: 100%; border-radius: .65rem; }
.pm-side-filter .pm-filter-tabs { margin-bottom: 0; }
.pm-side-links { border-top: 1px solid var(--pm-border); margin-top: .8rem; padding-top: .8rem; display: flex; flex-direction: column; gap: .45rem; }
.pm-side-links .pm-ftab { justify-content: flex-start; }

/* generic content-link rule must not recolor filled tabs */
.pm-content .pm-filter-tabs a.pm-ftab { color: var(--text-2); }
.pm-content .pm-filter-tabs a.pm-ftab:hover { color: var(--pm-accent1); text-decoration: none; }
.pm-content .pm-filter-tabs a.pm-ftab.active,
.pm-content .pm-filter-tabs a.pm-ftab.pm-ftab-active { color: var(--brand-ink); }
.pm-content .pm-filter-tabs a.pm-ftab.active:hover,
.pm-content .pm-filter-tabs a.pm-ftab.pm-ftab-active:hover { color: var(--brand-ink); text-decoration: none; }

/* ---------- global plain-look fixes (no default browser look) ---------- */
.pm-content input[type="checkbox"], .pm-content input[type="radio"] {
  accent-color: var(--pm-accent1); width: 16px; height: 16px; cursor: pointer; vertical-align: middle;
}
.pm-content ul.pm-list { list-style: none; margin: 0; padding: 0; }
.pm-content ul.pm-list li { padding: .45rem 0 .45rem 1.35rem; position: relative; font-size: var(--fs-sm); border-bottom: 1px solid var(--stroke); }
.pm-content ul.pm-list li:last-child { border-bottom: none; }
.pm-content ul.pm-list li::before {
  content: ''; position: absolute; left: .3rem; top: .85rem; width: 7px; height: 7px;
  border-radius: 50%; background: var(--pm-grad);
}
.pm-content h1, .pm-content h2, .pm-content h3, .pm-content h4 { font-family: var(--pm-font); color: var(--pm-text); }

/* ============================================================
   GLASS + MOTION v4 — glassmorphism layer + animations
   (Worker B — ALL rules below are ADDITIVE overrides layered
   on top of v1–v3; no v1–v3 selector was renamed or removed.
   Identity kept: dark navy + indigo→violet, dark text on light
   glass / light text on dark glass only — contrast stays AA.)
   ============================================================ */

/* ---------- gradient-mesh page backdrop ----------
   position:fixed + inset:0 + z-index:-1 + pointer-events:none:
   it paints behind the whole shell, never scrolls, and can
   never widen the page — the v3 overflow guards stay intact. */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(640px 440px at 10% -6%, var(--ab-17), transparent 65%),
    radial-gradient(580px 430px at 90% 2%, var(--ab-14), transparent 65%),
    radial-gradient(760px 540px at 55% 110%, var(--ain-13), transparent 65%),
    radial-gradient(440px 330px at 80% 62%, var(--ab-08), transparent 65%);
}

/* ---------- glass utilities (also added as classes in layouts) ---------- */
.pm-glass {
  background: var(--aw-75);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--aw-65);
  box-shadow: 0 1px 2px var(--ai-04), 0 12px 32px -16px var(--ai-16), inset 0 1px 0 var(--aw-70);
}
.pm-glass-dark {
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
}

/* ---------- glass cards & panels ----------
   Translucent white over the mesh; text stays slate-900. */
.pm-card {
  background: var(--aw-78);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  border-color: var(--aw-65);
  box-shadow: 0 1px 2px var(--ai-04), 0 12px 32px -16px var(--ai-16), inset 0 1px 0 var(--aw-70);
}
.pm-card-head {
  background: linear-gradient(180deg, var(--aw-85), var(--aw-50));
  border-bottom-color: var(--as-75);
}
.pm-side-filter, .pm-tabs {
  background: var(--aw-78);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  border-color: var(--aw-65);
}
.pm-filter-tabs {
  background: var(--as-82);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  backdrop-filter: blur(12px) saturate(150%);
}
.pm-ftab { background: var(--aw-88); }
.pm-btn-ghost { background: var(--aw-85); }
.pm-btn-ghost:hover { background: var(--aw-95); }
.pm-search, .pm-input, .pm-select { background: var(--aw-92); }
.pm-footer {
  background: var(--aw-72);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  backdrop-filter: blur(12px) saturate(150%);
  border-top-color: var(--aw-65);
}

/* ---------- glass-dark sidebar ----------
   Deep navy at ~90% alpha over the mesh: still unmistakably
   dark, so the existing light sidebar text keeps AA contrast. */
.pm-sidebar {
  background: var(--grad-side);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
  border-right: 1px solid var(--am-16);
}

/* ---------- sticky glass topbar ---------- */
.pm-topbar, .pm-glass-bar {
  background: var(--aw-78);
  -webkit-backdrop-filter: blur(16px) saturate(170%);
  backdrop-filter: blur(16px) saturate(170%);
  border-bottom: 1px solid var(--aw-65);
  box-shadow: 0 10px 28px -20px var(--ai-35), inset 0 -1px 0 var(--as-60);
}

/* ---------- glass stat cards ----------
   Brand gradients kept (white text needs the saturated base)
   but at 93% alpha + blur + a glass top highlight, so they
   read as tinted glass rather than flat blocks. */
.pm-stat {
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--aw-35);
  box-shadow: 0 2px 4px var(--ai-05), 0 16px 40px -16px var(--ab-28), inset 0 1px 0 var(--aw-35);
}
.pm-stat-1 { background: var(--grad-brand); }
.pm-stat-2 { background: var(--grad-stat-5); }
.pm-stat-3 { background: var(--grad-stat-3); }
.pm-stat-4 { background: var(--grad-stat-4); }
.pm-stat-5 { background: var(--grad-rose); }
.pm-stat-6 { background: var(--grad-stat-6); }

/* ---------- fallback: no backdrop-filter support → solid surfaces ---------- */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .pm-card, .pm-side-filter, .pm-tabs, .pm-glass { background: var(--surface-1); }
  .pm-card-head { background: linear-gradient(180deg, var(--surface-1), var(--surface-3)); }
  .pm-topbar { background: var(--aw-97); }
  .pm-footer { background: var(--surface-1); }
  .pm-filter-tabs { background: var(--surface-3); }
  .pm-ftab, .pm-btn-ghost, .pm-search, .pm-input, .pm-select { background: var(--surface-1); }
  .pm-sidebar { background: linear-gradient(180deg, var(--pm-sidebar) 0%, var(--pm-sidebar-2) 100%); }
}

/* ---------- motion (v4) ----------
   Transform/opacity ONLY (no layout animation, no thrash).
   Everything in this section lives inside the no-preference
   query; the reduce block at the end hard-disables motion. */
@media (prefers-reduced-motion: no-preference) {
  @keyframes pm-v4-fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  @keyframes pm-v4-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  /* page content entrance — fill-mode backwards only, so no
     transform is retained after the animation (fixed-position
     descendants/modals inside content are never re-parented). */
  .pm-content { animation: pm-v4-fade-up .45s cubic-bezier(.22,.61,.36,1) backwards; }
  .pm-topbar { animation: pm-v4-fade-in .35s ease backwards; }

  /* dashboard stat cards: staggered entrance via nth-child */
  .pm-stats > * { animation: pm-v4-fade-up .55s cubic-bezier(.22,.61,.36,1) backwards; }
  .pm-stats > *:nth-child(1) { animation-delay: .04s; }
  .pm-stats > *:nth-child(2) { animation-delay: .10s; }
  .pm-stats > *:nth-child(3) { animation-delay: .16s; }
  .pm-stats > *:nth-child(4) { animation-delay: .22s; }
  .pm-stats > *:nth-child(5) { animation-delay: .28s; }
  .pm-stats > *:nth-child(6) { animation-delay: .34s; }
  .pm-stats > *:nth-child(7) { animation-delay: .40s; }
  .pm-stats > *:nth-child(8) { animation-delay: .46s; }

  /* generic cards rise in gently (no stagger — long pages stay calm) */
  .pm-content > .pm-card, .pm-content .pm-side-filter { animation: pm-v4-fade-up .4s cubic-bezier(.22,.61,.36,1) backwards; }

  /* hover lift: cards + the button variants that lacked it
     (primary/danger/success/warning already lift in v1–v3) */
  .pm-card:hover { transform: translateY(-2px); }
  .pm-btn-ghost:hover, .pm-btn-secondary:hover { transform: translateY(-2px); box-shadow: var(--pm-shadow); }
  .pm-price-card:hover { transform: translateY(-6px); }

  /* sidebar links: hover slide (transform only; the colour/bg
     transition already ships in v1) */
  .pm-nav a:hover { transform: translateX(3px); }
  .pm-nav a.pm-active:hover { transform: none; }

  /* tabs / filter pills / pages: smoother state changes */
  .pm-ftab, .pm-tabs a, .pm-tabs-line a, .pm-page, .pm-badge {
    transition: background-color .22s ease, color .22s ease, border-color .22s ease, box-shadow .22s ease, transform .22s ease, filter .22s ease;
  }
  .pm-ftab:hover { transform: translateY(-2px); }
  .pm-page:hover { transform: translateY(-1px); }

  /* table rows: fade the hover wash in/out */
  .pm-table tbody tr { transition: background-color .22s ease; }

  /* subtle sheen sweep on stat cards (hover only) */
  .pm-stat::before {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(105deg, transparent 30%, var(--aw-18) 48%, transparent 62%);
    transform: translateX(-130%); transition: transform .7s ease;
  }
  .pm-stat:hover::before { transform: translateX(130%); }

  /* subtle badge shimmer (hover only — stays tasteful) */
  .pm-badge { position: relative; overflow: hidden; }
  .pm-badge::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(105deg, transparent 40%, var(--aw-45) 50%, transparent 60%);
    transform: translateX(-130%); transition: transform .6s ease;
  }
  .pm-badge:hover::after { transform: translateX(130%); }
}

/* ---------- reduced motion: hard off switch (all versions) ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .pm-card:hover, .pm-stat:hover, .pm-btn:hover, .pm-ftab:hover, .pm-nav a:hover { transform: none !important; }
}
