/* ==========================================================================
   STG Portal V3: admin screens (Users & Groups, user detail, permissions, invites, activity log)
   + shared pickers/sheets. Built on app.css / stg.css / portal.css tokens. No pink, no line art.
   ========================================================================== */

/* ---------- Busy buttons (spinner while a request runs) ---------- */
.btn.is-busy { opacity: .8 !important; pointer-events: none; }
.btn.is-busy > .ico { display: none; }
.btn.is-busy::before { content: ""; width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }

/* ---------- Common bits ---------- */
.ax-tabs { margin: 0 0 14px; max-width: 420px; }
.ax-tools { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; z-index: 2; padding: 6px 0 8px; background: var(--paper); }
.ax-chips { flex-wrap: nowrap; }
.ax-chips .chip { white-space: nowrap; gap: 5px; }
.ax-chips .chip .ico { width: 15px; height: 15px; }
.ax-chips + .ax-chips { margin-top: -2px; }
@media (min-width: 1024px) { .ax-chips { margin: 0; padding-left: 0; padding-right: 0; flex-wrap: wrap; } }
.ax-pills { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; min-width: 0; }
.ax-imeta { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.ax-help { font-size: var(--fs-sm); margin: 0 4px 12px; }
.ax-opt { font-style: normal; font-weight: 600; color: var(--faint); font-size: var(--fs-xs); margin-left: 4px; }
.ax-mono { font-variant-numeric: tabular-nums; color: var(--text-2); }
.ax-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-group); background: var(--teal-soft); color: var(--teal-strong); font-size: var(--fs-sm); font-weight: 600; margin: 0 0 14px; line-height: 1.45; }
.ax-note .ico { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.ax-note.violet { background: var(--violet-soft); color: var(--violet); }
:root[data-theme="dark"] .ax-note.violet { color: #B9BBF7; }
.ax-empty-card { display: flex; gap: 12px; align-items: flex-start; color: var(--muted); font-size: var(--fs-sm); }
.ax-empty-card .ico { flex: none; color: var(--teal-strong); width: 22px; height: 22px; }
.ax-empty-card p { margin: 0; line-height: 1.5; }
.avatar.av-xs { width: 28px; height: 28px; font-size: 11px; }

/* ---------- Users list ---------- */
.ax-urow .avatar { width: 40px; height: 40px; font-size: 15px; }
.ax-urow .row-main { overflow: hidden; }
.ax-mcount { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; font-size: 11px; color: var(--muted); font-weight: 650; }
.ax-mcount b { font-size: var(--fs-md); color: var(--text); font-variant-numeric: tabular-nums; }
.ax-dt td { max-width: 260px; }
.ax-cell-name { display: inline-flex; align-items: center; gap: 10px; }

/* ---------- Forms in sheets / cards ---------- */
.ax-form .field:last-child { margin-bottom: 0; }
.ax-row2 { grid-template-columns: 1fr; gap: 0; }
@media (min-width: 520px) { .ax-row2 { grid-template-columns: 1fr 1fr; gap: 12px; } }
.ax-seg-sm button { height: 34px; font-size: 13px; }
.ax-seg-sm button[disabled] { opacity: .45; }
.ax-switches { padding: 4px 16px; }
.ax-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; cursor: pointer; }
.ax-switches .ax-switch-row + .ax-switch-row { border-top: 1px solid var(--line); }
.ax-switch-row b { display: block; font-weight: 700; }
.ax-switch-row small { display: block; color: var(--muted); font-size: var(--fs-xs); margin-top: 2px; line-height: 1.35; }
.ax-radio .row { cursor: pointer; align-items: flex-start; }
.ax-radio input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--teal); flex: none; }

/* gymnast chips inside forms */
.ax-gchips { display: flex; flex-wrap: wrap; gap: 8px; }
.ax-gchip { display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 4px 0 12px; border-radius: var(--r-pill); background: var(--teal-soft); color: var(--teal-strong); font-weight: 700; font-size: var(--fs-sm); max-width: 100%; }
.ax-gchip button { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: inherit; }
.ax-gchip button:active { background: rgba(0,0,0,.08); }
.ax-gchip .ico-xs, .ax-gadd .ico-sm { width: 15px; height: 15px; }
.ax-gadd { border-style: dashed; }

/* pickers */
.ax-pick-chips { margin-top: 10px; margin-bottom: 4px; }
.ax-pick-list { margin-top: 8px; }
.ax-pick-list .list { border: 0; background: transparent; }
.ax-pick { background: transparent; border-radius: 12px; }
.ax-pick.on { background: var(--teal-soft); }
.ax-check { width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center; box-shadow: inset 0 0 0 2px var(--line-2); color: #fff; }
.ax-pick.on .ax-check { background: var(--teal); box-shadow: none; }

/* invite sent */
.ax-sent { text-align: center; }
.ax-sent p { color: var(--text-2); margin: 0 0 14px; }
.ax-sent-ic { width: 56px; height: 56px; margin: 4px auto 12px; border-radius: 18px; display: grid; place-items: center; background: var(--teal-soft); color: var(--teal-strong); }
.ax-sent-ic.warn { background: var(--amber-soft); color: var(--amber); }
.ax-link { padding: 12px; border-radius: var(--r-input); background: var(--surface-3); font-size: 12.5px; word-break: break-all; text-align: left; margin-bottom: 12px; color: var(--text-2); }

/* ---------- User detail ---------- */
.ax-uhead { display: flex; gap: 16px; align-items: flex-start; }
.ax-uname { font-size: var(--fs-2xl, 24px); line-height: 1.15; margin: 2px 0 2px; overflow-wrap: anywhere; }
.ax-uid { margin: 4px 0 0; color: var(--text); font-size: var(--fs-lg); font-weight: 700; overflow-wrap: anywhere; }
.ax-umeta { margin: 10px 0 0; font-size: var(--fs-xs); color: var(--muted); line-height: 1.5; }
.ax-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0; }
.ax-actions:empty { display: none; }
.ax-actions .btn { height: 44px; padding: 0 10px; font-size: var(--fs-sm); }
@media (min-width: 700px) { .ax-actions { grid-template-columns: repeat(4, max-content); } .ax-actions .btn { padding: 0 18px; } }
.ax-profile { padding: 16px; }
.ax-form-foot { display: flex; justify-content: flex-end; margin-top: 4px; }
@media (max-width: 600px) { .ax-form-foot .btn { flex: 1; } }
.ax-col > .section:first-child, .ax-col.section { margin-top: 26px; }
.ax-ugrid .row .btn-sm { flex: none; }
.ax-ugrid .row > a.tap { color: inherit; text-decoration: none; }
.ax-danger .card p { margin: 0; font-size: var(--fs-sm); }
@media (min-width: 1024px) {
  .ax-ugrid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 0 28px; align-items: start; }
  .ax-profile { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }
  .ax-profile .ax-wide { grid-column: 1 / -1; }
  .ax-profile .field:last-child { margin-bottom: 14px; }
}

/* ---------- Permissions ---------- */
.ax-ptools { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.ax-pick-field { margin: 0; }
@media (min-width: 1024px) { .ax-ptools { flex-direction: row; align-items: flex-end; } .ax-ptools .ax-pick-field { flex: 0 1 360px; } .ax-ptools .search-bar { flex: 0 1 320px; } }
.ax-legend { font-size: var(--fs-xs); margin: 0 4px 4px; line-height: 1.5; }
.ax-legend b { color: var(--text-2); }
.ax-pcard { padding: 12px 14px; transition: box-shadow .15s; }
.card.ax-pcard + .card.ax-pcard { margin-top: 10px; }
.ax-pc-head { display: flex; align-items: center; gap: 12px; }
.ax-pc-head .row-icon { width: 32px; height: 32px; border-radius: 10px; }
.ax-pc-head .row-icon .ico { width: 18px; height: 18px; }
.ax-pc-head b { display: block; font-weight: 750; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ax-pc-head small, .ax-tname small { display: block; color: var(--faint); font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ax-pc-sw { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: none; }
.ax-pc-sw small { font-size: 10.5px; font-weight: 750; color: var(--muted); }
.ax-pc-grid { display: grid; grid-template-columns: 54px repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; align-items: end; }
.ax-pc-grid label { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ax-pc-grid small { font-size: 11px; font-weight: 750; color: var(--muted); padding-left: 2px; }
.ax-sw { display: inline-block; vertical-align: middle; width: 46px; height: 28px; }
.ax-sw span::after { width: 24px; height: 24px; }
.ax-sw input:checked + span::after { transform: translateX(18px); }
.select.ax-sel { min-height: 38px; height: 38px; padding: 6px 24px 6px 10px; font-size: 14px; font-weight: 650; border-radius: 10px; background-position: right 5px center; background-size: 16px; }
.select.ax-sel.lv0 { color: var(--muted); }
.select.ax-sel.lv3 { color: var(--teal-strong); border-color: color-mix(in srgb, var(--teal) 45%, transparent); }
.select.ax-sel:disabled { opacity: .6; }
.is-inherit .ax-pc-grid, .is-inherit td:nth-child(n+3) { opacity: .7; }
.ax-pcard.is-changed { box-shadow: inset 3px 0 0 var(--gold), var(--shadow-1); }
.ax-ptable tr.is-changed td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
.ax-ptable td, .ax-ptable th { padding: 8px 12px; }
.ax-ptable th.c, .ax-ptable td.c { text-align: center; width: 80px; }
.ax-ptable td .select.ax-sel { width: 120px; }
.ax-ptable tbody tr { cursor: default; }
.ax-ptable tbody tr:hover { background: transparent; }
.ax-tname { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.ax-tname > .ico { color: var(--teal-strong); flex: none; }
.ax-tname b { font-weight: 700; }
.ax-tname span, .ax-tname b, .ax-tname small { min-width: 0; }
.ax-tname > b + small { display: none; }
.ax-ptable .ax-tname { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; }
.ax-ptable .ax-tname > .ico { grid-row: span 2; }
.ax-ptable .ax-tname > b + small { display: block; }
.ax-savebar { position: sticky; bottom: calc(var(--tabbar-space, 0px) - 8px); z-index: 5; display: flex; align-items: center; gap: 8px; margin-top: 18px;
  padding: 10px 10px 10px 16px; border-radius: 18px; background: var(--ink); color: #fff; box-shadow: var(--shadow-3); font-weight: 700; font-size: var(--fs-sm); }
.ax-savebar[hidden] { display: none; }
.ax-savebar .btn-outline { color: #fff; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.35); }
:root[data-theme="dark"] .ax-savebar { background: #23306E; border: 1px solid rgba(255,255,255,.1); }
@media (min-width: 1024px) { .ax-savebar { bottom: 16px; } }
.ax-perms { padding-bottom: 8px; }

/* ---------- Invites ---------- */
.ax-irow { align-items: flex-start; }
.ax-irow .row-icon { margin-top: 2px; }
.ax-irow .chev { margin-top: 8px; color: var(--faint); width: 18px; height: 18px; flex: none; }
.ax-irow .ax-pills { flex-wrap: nowrap; }

/* ---------- Activity log ---------- */
.ax-log .ax-lrow + .ax-lrow { border-top: 1px solid var(--line); }
.ax-log .row { align-items: flex-start; }
.ax-log .avatar { margin-top: 2px; }
.ax-ltext { font-weight: 550; overflow-wrap: anywhere; }
.ax-ltext b { font-weight: 800; }
.ax-lchev { transition: transform .2s; margin-top: 6px; width: 18px; height: 18px; color: var(--faint); flex: none; }
.ax-lrow.open .ax-lchev { transform: rotate(180deg); }
.ax-lrow.open > .row { background: var(--surface-2); }
.ax-diff { padding: 4px 16px 14px 64px; background: var(--surface-2); }
@media (max-width: 420px) { .ax-diff { padding-left: 16px; } }
.ax-dnote { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 8px; font-size: var(--fs-sm); color: var(--text-2); }
.ax-dnote .ico { flex: none; margin-top: 2px; color: var(--teal-strong); }
.ax-kv { margin: 0; display: grid; gap: 1px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--line); }
.ax-kv > div { display: grid; grid-template-columns: minmax(90px, 34%) 1fr; gap: 10px; padding: 8px 10px; background: var(--surface); font-size: 13px; }
.ax-kv dt { font-weight: 750; color: var(--muted); overflow-wrap: anywhere; }
.ax-kv dd { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; overflow-wrap: anywhere; min-width: 0; -webkit-user-select: text; user-select: text; }
.ax-kv dd .ico { color: var(--faint); flex: none; }
.ax-old { color: var(--coral-strong); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--coral-strong) 45%, transparent); }
.ax-new { color: var(--green); font-weight: 650; }
.ax-kv dd > .ax-new:only-child, .ax-kv dd > .ax-old:only-child { color: var(--text); text-decoration: none; font-weight: 550; }
.ax-dmeta { margin: 8px 0 0; font-size: 11.5px; color: var(--faint); }
