/* Admin Panel → User Permissions: three-panel glass workspace (see user-permissions.js). Everything is scoped under .upm-host / .upm. */
.upm-host { container: upm / inline-size; width: 100%; }
.upm {
  --bg: #020D1D; --panel: rgba(7, 28, 52, .78); --panel2: rgba(10, 38, 70, .72); --blue: #087BFF; --cyan: #00D8FF;
  --tx: #F4F8FF; --mut: #9DB4D0; --warn: #FFB547; --dng: #F04455; --ok: #27D18B; --line: rgba(0, 216, 255, .16); --line2: rgba(0, 216, 255, .32);
  --ease: 180ms cubic-bezier(.2, .7, .3, 1);
  position: relative; color: var(--tx); font-size: 13px; line-height: 1.4; display: flex; flex-direction: column; gap: 14px;
  padding: 16px; border-radius: 18px; border: 1px solid var(--line);
  background: radial-gradient(900px 380px at 12% -10%, rgba(8, 123, 255, .20), transparent 60%), radial-gradient(700px 360px at 100% 0, rgba(0, 216, 255, .10), transparent 60%), var(--bg);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .04);
}
.upm *, .upm *::before, .upm *::after { box-sizing: border-box; }
.upm svg { flex: none; display: block; }
.upm button { font: inherit; color: inherit; }
.upm h2, .upm h3, .upm p { margin: 0; }
.upm [hidden] { display: none !important; }

/* header */
.upm-head { display: flex; align-items: center; gap: 14px; }
.upm-head-ic { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; color: var(--cyan); background: linear-gradient(145deg, rgba(8, 123, 255, .35), rgba(0, 216, 255, .12)); border: 1px solid var(--line2); }
.upm-head-tx { flex: 1; min-width: 0; }
.upm-head-tx h2 { font-size: 22px; font-weight: 800; letter-spacing: .1px; color: var(--tx); }
.upm-head-tx p { color: var(--mut); font-size: 13px; margin-top: 2px; }
.upm-ghost { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line2); background: rgba(255, 255, 255, .03); font-weight: 600; cursor: not-allowed; opacity: .75; white-space: nowrap; }
.upm-ghost em { font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; padding: 2px 6px; border-radius: 6px; background: rgba(255, 181, 71, .16); color: var(--warn); }
.upm-notice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 12px; background: rgba(255, 181, 71, .10); border: 1px solid rgba(255, 181, 71, .35); color: #ffe2b3; }
.upm-notice svg { color: var(--warn); margin-top: 1px; }

/* grid */
.upm-grid { position: relative; display: grid; grid-template-columns: minmax(214px, 270px) minmax(176px, 214px) minmax(0, 1fr); gap: 12px; height: clamp(540px, calc(100vh - 300px), 900px); min-height: 0; }
.upm-panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); box-shadow: 0 10px 28px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .05); padding: 14px; gap: 10px; }
.upm-ph { display: flex; align-items: center; gap: 10px; }
.upm-ph h3 { font-size: 17px; font-weight: 800; color: var(--tx); flex: 1; }
.upm-count { min-width: 28px; text-align: center; padding: 2px 9px; border-radius: 99px; background: rgba(8, 123, 255, .28); border: 1px solid var(--line2); color: var(--cyan); font-weight: 700; font-size: 12px; }
.upm-x { width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line); background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--mut); }

/* inputs */
.upm-search { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 40px; border-radius: 11px; border: 1px solid var(--line); background: rgba(2, 13, 29, .6); color: var(--mut); transition: border-color var(--ease), box-shadow var(--ease); }
.upm-search:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0, 216, 255, .14); }
.upm .upm-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--tx); font-size: 13px; padding: 0; height: 100%; box-shadow: none; }
.upm .upm-search input::placeholder { color: var(--mut); opacity: .8; }
.upm-selwrap { position: relative; display: block; width: 100%; }
.upm-selwrap svg { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--mut); }
.upm .upm-selwrap select { width: 100%; height: 40px; padding: 0 34px 0 12px; border-radius: 11px; border: 1px solid var(--line); background: rgba(2, 13, 29, .6); color: var(--tx); font-size: 13px; appearance: none; -webkit-appearance: none; outline: 0; cursor: pointer; text-overflow: ellipsis; }
.upm .upm-selwrap select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0, 216, 255, .14); }
.upm .upm-selwrap select:disabled { opacity: .55; cursor: not-allowed; }
.upm .upm-selwrap option { background: #071c34; color: var(--tx); }

/* users list */
.upm-ulist, .upm-clist, .upm-dbody { overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: rgba(0, 216, 255, .3) transparent; }
.upm-ulist { flex: 1; display: flex; flex-direction: column; gap: 7px; padding: 2px 3px 2px 0; }
.upm-u { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 13px; border: 1px solid transparent; background: rgba(255, 255, 255, .025); cursor: pointer; transition: background var(--ease), border-color var(--ease), box-shadow var(--ease); position: relative; outline: 0; }
.upm-u:hover, .upm-u:focus-visible { background: rgba(8, 123, 255, .14); border-color: var(--line); }
.upm-u:focus-visible { box-shadow: 0 0 0 2px rgba(0, 216, 255, .5); }
.upm-u.sel { background: linear-gradient(135deg, rgba(8, 123, 255, .55), rgba(8, 123, 255, .22)); border-color: var(--cyan); box-shadow: 0 0 0 1px rgba(0, 216, 255, .25), 0 6px 18px rgba(8, 123, 255, .28); }
.upm-av { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800; color: #fff; flex: none; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .12); }
.upm-av.lg { width: 56px; height: 56px; font-size: 18px; }
.upm-un { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.upm-un b { font-size: 13px; font-weight: 700; color: var(--tx); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upm-un small { font-size: 11.5px; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upm-rb { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; border: 1px solid transparent; }
.upm-rb.adm { background: rgba(157, 180, 208, .14); color: #c8d6e8; border-color: rgba(157, 180, 208, .3); }
.upm-rb.mc { background: rgba(39, 209, 139, .12); color: #5ff0b4; border-color: rgba(39, 209, 139, .45); }
.upm-rb.co { background: rgba(8, 123, 255, .16); color: #8cc4ff; border-color: rgba(8, 123, 255, .45); }
.upm-rm { position: absolute; top: -7px; right: -5px; width: 22px; height: 22px; box-shadow: 0 2px 8px rgba(0,0,0,.4); border-radius: 7px; border: 0; background: rgba(240, 68, 85, .18); color: #ff8b97; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity var(--ease); }
.upm-u:hover .upm-rm, .upm-u:focus-within .upm-rm, .upm-u.sel .upm-rm { opacity: 1; }
.upm-rm:hover { background: var(--dng); color: #fff; }
.upm-empty { padding: 22px 12px; text-align: center; color: var(--mut); }
.upm-empty.big { padding: 60px 24px; font-size: 14px; }
.upm-add { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }

/* buttons */
.upm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line2); background: rgba(255, 255, 255, .04); color: var(--tx); font-weight: 600; font-size: 12.5px; cursor: pointer; white-space: nowrap; transition: background var(--ease), border-color var(--ease), transform var(--ease), box-shadow var(--ease); }
.upm-btn:hover:not(:disabled) { background: rgba(8, 123, 255, .2); border-color: var(--cyan); }
.upm-btn:focus-visible, .upm-c:focus-visible, .upm-sw:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.upm-btn:active:not(:disabled) { transform: translateY(1px); }
.upm-btn:disabled { opacity: .42; cursor: not-allowed; }
.upm-btn[data-idle="1"] { opacity: .65; }
.upm-btn.primary { background: linear-gradient(135deg, #0a84ff, #0663d6); border-color: rgba(0, 216, 255, .55); box-shadow: 0 6px 16px rgba(8, 123, 255, .35); }
.upm-btn.primary:hover:not(:disabled) { background: linear-gradient(135deg, #2a96ff, #0a76f2); }
.upm-btn.dng { background: rgba(240, 68, 85, .18); border-color: rgba(240, 68, 85, .6); color: #ffb4bc; }
.upm-btn.dng:hover:not(:disabled) { background: rgba(240, 68, 85, .35); border-color: var(--dng); }
.upm-btn.wide { width: 100%; height: 44px; font-size: 13.5px; }

/* categories */
.upm-clist { flex: 1; display: flex; flex-direction: column; gap: 6px; padding-right: 2px; }
.upm-c { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 10px; border-radius: 12px; border: 1px solid transparent; background: transparent; cursor: pointer; text-align: left; color: #cfe0f5; transition: background var(--ease), border-color var(--ease), color var(--ease), box-shadow var(--ease); position: relative; }
.upm-c:hover { background: rgba(8, 123, 255, .13); color: var(--tx); }
.upm-c.sel { background: linear-gradient(135deg, rgba(8, 123, 255, .6), rgba(8, 123, 255, .26)); border-color: var(--cyan); color: #fff; box-shadow: 0 0 0 1px rgba(0, 216, 255, .2), 0 6px 18px rgba(8, 123, 255, .3); }
.upm-ci { color: var(--mut); display: grid; place-items: center; }
.upm-c.sel .upm-ci, .upm-c:hover .upm-ci { color: var(--cyan); }
.upm-c.danger .upm-ci { color: var(--warn); }
.upm-cn { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; line-height: 1.25; }
.upm-cc { min-width: 30px; text-align: center; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: rgba(157, 180, 208, .14); color: #c8d6e8; font-variant-numeric: tabular-nums; }
.upm-c.sel .upm-cc { background: rgba(255, 255, 255, .22); color: #fff; }
.upm-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(255, 181, 71, .18); }

/* details */
.upm-details { padding: 0; gap: 0; overflow: hidden; }
.upm-dhead { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(8, 123, 255, .10), transparent); position: relative; }
.upm-who { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 250px; }
.upm-wtx { min-width: 0; }
.upm-wn { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.upm-wn b { font-size: 20px; font-weight: 800; color: var(--tx); }
.upm-wm { display: flex; align-items: center; gap: 12px; color: var(--mut); font-size: 12.5px; margin-top: 3px; flex-wrap: wrap; }
.upm-st { display: inline-flex; align-items: center; gap: 6px; }
.upm-st i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(39, 209, 139, .18); }
.upm-st.off i { background: var(--dng); box-shadow: 0 0 0 3px rgba(240, 68, 85, .18); }
.upm-tools { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.upm-preset { display: flex; flex-direction: column; gap: 4px; width: 188px; }
.upm-preset > span { font-size: 11px; color: var(--mut); }
.upm-dirtyline { flex-basis: 100%; display: flex; align-items: center; gap: 8px; color: var(--warn); font-weight: 600; font-size: 12.5px; }
.upm-dirtyline i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.upm-dnone { display: flex; align-items: center; gap: 10px; color: var(--mut); }
.upm-dbody { flex: 1; padding: 16px; }
.upm-sec.fade { animation: upmFade 200ms ease both; }
@keyframes upmFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.upm-sech { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.upm-sico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--cyan); background: rgba(8, 123, 255, .2); border: 1px solid var(--line2); }
.upm-sech h3 { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upm-sech h3 em { font-style: normal; font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: rgba(8, 123, 255, .22); border: 1px solid var(--line2); color: #9ccfff; }
.upm-sech h3 em.on { background: rgba(39, 209, 139, .12); border-color: rgba(39, 209, 139, .4); color: #5ff0b4; }
.upm-sech p { color: var(--mut); margin-top: 3px; }
.upm-snote { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 14px; padding: 10px 12px; border-radius: 11px; background: rgba(8, 123, 255, .08); border: 1px solid var(--line); color: #b8cde6; font-size: 12.5px; }
.upm-snote svg { color: var(--cyan); margin-top: 1px; }
.upm-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 12px; }
.upm-card { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel2); cursor: pointer; transition: background var(--ease), border-color var(--ease), box-shadow var(--ease); position: relative; }
.upm-card:hover { background: rgba(14, 52, 96, .78); border-color: var(--line2); }
.upm-card.on { border-color: rgba(8, 123, 255, .5); }
.upm-card.mod { border-color: rgba(255, 181, 71, .65); box-shadow: inset 3px 0 0 var(--warn); }
.upm-card.warn.on { border-color: rgba(255, 181, 71, .55); }
.upm-cico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: #8cc4ff; background: rgba(8, 123, 255, .16); border: 1px solid rgba(8, 123, 255, .3); flex: none; }
.upm-card.on .upm-cico { color: var(--cyan); background: rgba(0, 216, 255, .12); border-color: rgba(0, 216, 255, .4); }
.upm-card.warn .upm-cico { color: var(--warn); background: rgba(255, 181, 71, .12); border-color: rgba(255, 181, 71, .4); }
.upm-ctx { flex: 1; min-width: 0; }
.upm-ctit { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.upm-ctit b { font-size: 13.5px; font-weight: 700; color: var(--tx); }
.upm-csub { color: var(--mut); font-size: 12px; margin-top: 3px; overflow-wrap: anywhere; }
.upm-cnote { display: flex; gap: 6px; align-items: flex-start; margin-top: 7px; font-size: 11.5px; color: #ffd9a1; }
.upm-cnote svg { margin-top: 1px; color: var(--warn); }
.upm-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 800; letter-spacing: .3px; text-transform: uppercase; padding: 2px 7px; border-radius: 6px; }
.upm-tag.warn { background: rgba(255, 181, 71, .16); color: var(--warn); border: 1px solid rgba(255, 181, 71, .45); }
.upm-tag.mod { background: rgba(255, 181, 71, .12); color: #ffd18a; }

/* switch */
.upm-sw { flex: none; position: relative; width: 46px; height: 26px; border-radius: 99px; border: 1px solid rgba(157, 180, 208, .25); background: #2a3d57; cursor: pointer; padding: 0; transition: background var(--ease), border-color var(--ease), box-shadow var(--ease); margin-top: 2px; }
.upm-sw i { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #8aa0bd; transition: transform var(--ease), background var(--ease); }
.upm-sw[aria-checked="true"] { background: linear-gradient(135deg, #1a8cff, #0a6cf0); border-color: rgba(0, 216, 255, .6); box-shadow: 0 0 14px rgba(8, 123, 255, .5); }
.upm-sw[aria-checked="true"] i { transform: translateX(20px); background: #fff; }
.upm-sw:disabled { opacity: .5; cursor: not-allowed; }

/* bulk email */
.upm-bulk-in { display: flex; align-items: center; gap: 14px 18px; flex-wrap: wrap; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(14px); }
.upm-bico { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; color: var(--cyan); background: rgba(8, 123, 255, .22); border: 1px solid var(--line2); }
.upm-btx { flex: 1 1 280px; min-width: 0; }
.upm-btx h3 { font-size: 16px; font-weight: 800; }
.upm-btx p { color: var(--mut); margin-top: 2px; font-size: 12.5px; }
.upm-btx b { color: var(--tx); }
.upm-bwarn { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 11px; background: rgba(255, 181, 71, .09); border: 1px solid rgba(255, 181, 71, .4); color: #ffe2b3; font-size: 12px; max-width: 250px; }
.upm-bwarn svg { color: var(--warn); }
.upm-bbtns { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 100%; }

/* action bar */
.upm-bar { position: sticky; bottom: 0; z-index: 5; margin: 0 -4px -4px; }
.upm-bar-in { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(5, 22, 42, .92); backdrop-filter: blur(16px); box-shadow: 0 -8px 24px rgba(0, 0, 0, .3); transition: border-color var(--ease); }
.upm-bar-in.dirty { border-color: rgba(255, 181, 71, .55); }
.upm-bsp { flex: 1; }
.upm-bs { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 13px; flex-wrap: wrap; }
.upm-bs i { width: 9px; height: 9px; border-radius: 50%; background: var(--mut); flex: none; }
.upm-bs small { font-weight: 500; color: var(--mut); font-size: 12px; }
.upm-bs.dirty { color: var(--warn); } .upm-bs.dirty i { background: var(--warn); }
.upm-bs.ok { color: var(--ok); } .upm-bs.ok i { background: var(--ok); animation: upmPop 380ms ease both; }
.upm-bs.err { color: #ff8b97; } .upm-bs.err i { background: var(--dng); }
.upm-bs.save { color: var(--cyan); } .upm-bs.save i { background: var(--cyan); animation: upmPulse 900ms ease-in-out infinite; }
.upm-bs.idle { color: var(--mut); font-weight: 600; }
@keyframes upmPop { 0% { transform: scale(.4); } 70% { transform: scale(1.5); } 100% { transform: scale(1); } }
@keyframes upmPulse { 50% { opacity: .35; } }

.upm-only-narrow { display: none !important; }
.upm-backdrop { display: none; }

/* ── tablet: the Users panel becomes a drawer ── */
@container upm (max-width: 790px) {
  .upm-grid { grid-template-columns: minmax(180px, 215px) minmax(0, 1fr); }
  .upm-users { position: absolute; z-index: 20; top: 0; bottom: 0; left: 0; width: min(330px, 92%); transform: translateX(-108%); transition: transform 220ms cubic-bezier(.2, .7, .3, 1); background: rgba(5, 22, 42, .97); box-shadow: 0 0 40px rgba(0, 0, 0, .6); }
  .upm[data-users-open="1"] .upm-users { transform: none; }
  .upm[data-users-open="1"] .upm-backdrop { display: block; position: absolute; inset: 0; z-index: 19; background: rgba(2, 13, 29, .6); border-radius: 16px; }
  .upm-only-narrow { display: inline-flex !important; }
  .upm-ph .upm-x.upm-only-narrow { display: grid !important; }
  .upm-userbtn { width: 38px; padding: 0; }
}
/* ── phone: categories become a compact selector, one column of cards ── */
@container upm (max-width: 640px) {
  .upm { padding: 10px; border-radius: 14px; gap: 10px; }
  .upm-grid { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 0; }
  .upm-cats { display: none; }
  .upm-details { min-height: 420px; }
  .upm-dbody { overflow: visible; }
  .upm-users { position: fixed; z-index: 1000; top: 0; bottom: 0; left: 0; width: min(340px, 92vw); border-radius: 0 16px 16px 0; }
  .upm[data-users-open="1"] .upm-backdrop { position: fixed; z-index: 999; border-radius: 0; }
  .upm-catsel.upm-only-narrow { display: block !important; padding: 10px 14px 0; }
  .upm-head-tx p { display: none; }
  .upm-head { flex-wrap: wrap; }
  .upm-head-ic { width: 40px; height: 40px; }
  .upm-head-tx { flex: 1 1 140px; }
  .upm-head-tx h2 { font-size: 19px; }
  .upm-ghost { width: 100%; justify-content: center; }
  .upm-ghost em { display: none; }
  .upm-sech { align-items: flex-start; }
  .upm-tools { margin-left: 0; width: 100%; }
  .upm-preset { width: 100%; }
  .upm-tools .upm-btn { flex: 1 1 140px; }
  .upm-cards { grid-template-columns: 1fr; }
  .upm-sw { width: 52px; height: 30px; } .upm-sw i { width: 24px; height: 24px; } .upm-sw[aria-checked="true"] i { transform: translateX(22px); }
  .upm-bar-in { flex-wrap: wrap; }
  .upm-bar-in .upm-btn { flex: 1 1 120px; height: 44px; }
  .upm-rm { opacity: 1; }
  .upm-bwarn { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  .upm *, .upm *::before, .upm *::after { animation: none !important; transition: none !important; }
}
