/* Manage / Account / Admin pages (mg-*). Builds on app.css tokens (colours, --fs-*, --dur-*, --ease*). */

/* QR codes must stay dark-on-white in both themes to scan */
:root { --qr-bg: #ffffff; }

/* settings layout: side tabs + content */
.mg-layout { display: grid; grid-template-columns: 196px minmax(0, 1fr); gap: 28px; align-items: start; }
/* side tabs are kit .list / .list-item (the filled pill marks the current section) */
.mg-sidetabs { position: sticky; top: calc(var(--topbar) + var(--content-pad)); }
.mg-sidetabs .list-item { font-weight: 500; }
.mg-sidetabs .list-item svg { width: 15px; height: 15px; opacity: .85; flex: none; }
.mg-body { min-width: 0; max-width: 920px; }
.mg-body.mg-wide { max-width: 1180px; }

.mg-section { padding: 22px 0; border-top: 1px solid var(--border); display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: 24px; }
.mg-section:first-child { border-top: 0; padding-top: 4px; }
.mg-section-h h2 { font-size: var(--fs-4); }
.mg-section-h p { margin: 6px 0 0; font-size: var(--fs-2); line-height: 1.5; }
.mg-section-b { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
/* .wide: a table section — heading on top, the table full width beneath (a 490px column wrapped names and dates) */
.mg-section.wide { grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }
.mg-section.wide .mg-section-h p { max-width: 720px; }
.mg-save { justify-content: flex-end; padding-top: 6px; }
.mg-gap { margin-bottom: 6px; }
.mg-tight { margin: 4px 0 0; }
.mg-more { display: flex; justify-content: center; padding: 12px; }

/* number input with unit suffix */
.mg-unit { display: flex; align-items: stretch; }
.mg-unit input { border-top-right-radius: 0; border-bottom-right-radius: 0; width: 100%; }
.mg-unit span { display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--border-2); border-left: 0; border-radius: 0 var(--radius-s) var(--radius-s) 0; background: var(--panel-2); color: var(--muted); font-size: var(--fs-2); white-space: nowrap; }

/* retention rows */
.mg-ret-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 16px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.mg-ret-row:last-child { border-bottom: 0; }

/* secret / key display */
.mg-secret { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border: 1px solid var(--border-2); border-radius: var(--radius-s); background: var(--bg-2); font-family: var(--mono); font-size: var(--fs-2); }
.mg-secret code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: .02em; }
.mg-secret code.masked { color: var(--muted); letter-spacing: .12em; }

/* notices */
.mg-banner { display: flex; align-items: flex-start; gap: 12px; }
.mg-banner > svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--warn); }

/* checklists, steps */
.mg-check { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.mg-check li { display: flex; gap: 10px; align-items: flex-start; }
.mg-check li .dot { margin-top: 6px; }
.mg-step { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px; }
.mg-step > b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-bg); color: var(--accent-2); font-size: var(--fs-2); }
.mg-steps { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; counter-reset: step; flex-wrap: wrap; }
.mg-steps li { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 99px; color: var(--muted); font-size: var(--fs-2); transition: color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease); }
.mg-steps li::before { content: attr(data-step); width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--hover); color: var(--muted); font-size: var(--fs-1); font-weight: 600; transition: background-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease); }
.mg-steps li.on { color: var(--text-strong); background: var(--accent-bg); }
.mg-steps li.on::before { background: var(--accent); color: var(--on-primary); }
.mg-steps li.done { color: var(--text-2); }
.mg-steps li.done::before { content: '✓'; background: var(--ok-bg); color: var(--ok); }
.mg-switch-row { display: flex; align-items: center; gap: 10px; }
.mg-switch-row label { cursor: pointer; }
.mg-switch-row { flex-wrap: wrap; }
.mg-switch-row.pinned label { cursor: default; color: var(--text-2); }
/* a site setting pinned by app/config.php: read-only, with where to change it */
.pin-hint { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-1); color: var(--muted); white-space: nowrap; }
.pin-hint .icon { width: 12px; height: 12px; flex: none; }
.pin-hint code { font-size: inherit; }

/* player picker */
.mg-picker { position: relative; }
.mg-results { position: absolute; z-index: var(--z-menu); left: 0; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--border-2); border-radius: var(--radius-s); box-shadow: var(--shadow); padding: 4px; max-height: 260px; overflow-y: auto; animation: pop-in var(--dur-1) var(--ease-out); }
.mg-results button { display: flex; width: 100%; align-items: center; gap: var(--sp-2); padding: 7px 10px; border: 0; border-radius: var(--radius-s); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.mg-results button:hover, .mg-results button[aria-selected="true"] { background: var(--hover); }
.mg-results-meta { margin-left: auto; }
.mg-results-empty { padding: 8px 10px; }

/* option cards (command type, target type) */
.mg-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.mg-option { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-2); color: var(--text-2); cursor: pointer; text-align: left; font: inherit; transition: border-color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease); }
.mg-option:hover { border-color: var(--border-2); background: var(--hover); }
.mg-option:active { transform: scale(.985); }
.mg-option.on { border-color: var(--accent); background: var(--accent-bg); color: var(--text-strong); }
.mg-option b { display: flex; align-items: center; gap: 7px; font-size: var(--fs-3); color: var(--text); }
.mg-option b svg { width: 15px; height: 15px; }
.mg-option span { font-size: var(--fs-1); color: var(--muted); }
.mg-option.danger.on { border-color: var(--bad); background: var(--bad-bg); }

/* commands table */
.mg-cmd { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.mg-cmd svg { width: 15px; height: 15px; color: var(--muted); }
.mg-cmd-sum { display: block; max-width: 420px; }

/* flags & releases */
.mg-rollout { display: flex; align-items: center; gap: 10px; min-width: 130px; }
.mg-rollout .mg-flag-bar { flex: 1; }
.mg-flag-bar { position: relative; height: 6px; border-radius: 6px; background: var(--hover); overflow: hidden; min-width: 80px; }
.mg-flag-bar > i { position: absolute; inset: 0 auto 0 0; background: var(--ok); border-radius: 6px; transition: width var(--dur-3) var(--ease); }
.mg-flag-bar.off > i { background: var(--faint); }
.mg-rate { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.mg-rate .bar { flex: 1; }
.mg-kv-val { font-family: var(--mono); font-size: var(--fs-2); max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
/* value type: a quiet badge in the UI font (mono is for code and ids), like Metrics' kind badge */
.mg-type { display: inline-flex; align-items: center; height: 19px; padding: 0 7px; border-radius: 5px; background: var(--hover); color: var(--text-2); font-size: var(--fs-1); font-weight: 600; }

/* 2FA */
.mg-enrol { display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.mg-enrol > .stack { min-width: 240px; }
.mg-qr { width: 196px; height: 196px; padding: 10px; background: var(--qr-bg); border-radius: var(--radius); display: grid; place-items: center; flex: none; }
.mg-qr svg, .mg-qr img { width: 100%; height: 100%; display: block; }
.mg-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; padding: 14px 16px; border: 1px dashed var(--border-2); border-radius: var(--radius); background: var(--bg-2); font-family: var(--mono); font-size: var(--fs-4); letter-spacing: .06em; }
/* input.mg-otp outranks the kit's input rules without !important */
input.mg-otp.mg-otp { font: 600 var(--fs-kpi) var(--mono); letter-spacing: .32em; text-align: center; height: 48px; max-width: 220px; }
.mg-focus { max-width: 640px; margin: 4vh auto 0; }
.mg-focus-h { gap: 12px; }
.mg-focus-h > svg { width: 30px; height: 30px; flex: none; }

/* Open Cloud scope checklist */
.mg-feature { border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--panel); }
.mg-feature + .mg-feature { margin-top: 6px; }
.mg-feature summary { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; list-style: none; border-radius: var(--radius-s); transition: background-color var(--dur-1) var(--ease); }
.mg-feature summary::-webkit-details-marker { display: none; }
.mg-feature summary:hover { background: var(--hover); }
.mg-feature[open] summary { border-bottom: 1px solid var(--border); border-radius: var(--radius-s) var(--radius-s) 0 0; }
.mg-feature .mg-scopes { padding: 10px 12px; }
.mg-scopes { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 16px; }
.mg-scopes div { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: var(--fs-2); min-width: 0; }
.mg-scopes div span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* misc */
.mg-audit-detail { max-width: 520px; color: var(--muted); font-size: var(--fs-2); overflow-wrap: anywhere; }
.mg-danger { border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); border-radius: var(--radius); padding: 16px; background: var(--bad-bg); }
.mg-inline-edit { border: 1px solid transparent; background: transparent; height: var(--ctl-h-s); padding: 0 6px; width: 100%; min-width: 120px; color: var(--text-2); }
.mg-inline-edit:hover { border-color: var(--border-2); }
.mg-inline-edit:focus { background: var(--bg-2); }
/* release notes: the "Add a note…" hint shows on row hover / focus only (inline secondary actions stay quiet) */
.rel-note-text:empty { display: none; }
.rel-note .rel-note-text { display: none; }
.t tbody tr:not(:hover) .mg-inline-edit:placeholder-shown:not(:focus)::placeholder { color: transparent; }
/* release cards (phones): the saved note is text under the stats; ⋯ → Edit note… adds or changes it */
@container tcards (max-width: 640px) {
  .t-cards .rel-note .mg-inline-edit { display: none; }
  .t-cards .rel-note .rel-note-text:not(:empty) { display: block; }
  .t-cards .t td:has(> .rel-note > .rel-note-text:empty), .t-cards .t td:has(> .rel-note-text:empty) { display: none; }
  .t-cards .rel-note-text { overflow: hidden; text-overflow: ellipsis; font-size: var(--fs-2); }
}

@media (max-width: 900px) {
  .mg-layout { grid-template-columns: 1fr; gap: 12px; }
  .mg-sidetabs { position: static; flex-direction: row; overflow-x: auto; }
  .mg-sidetabs .list-item { white-space: nowrap; width: auto; }
  .mg-section { grid-template-columns: 1fr; gap: 12px; }
}
@media (max-width: 760px) {
  .mg-ret-row { grid-template-columns: minmax(0, 1fr) 120px; }
  .mg-codes { grid-template-columns: 1fr; }
  .mg-qr { width: 168px; height: 168px; }
  .mg-cmd-sum { max-width: 180px; }
}
.mg-redeem input { width: 100%; }

/* target picker, rollout wizard and panel */
.mg-options.mg-options-sm { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--sp-1); }
.mg-options-sm .mg-option { padding: var(--sp-2) var(--sp-3); }
.mg-reach { margin-top: var(--sp-2); min-height: 1.4em; }
.mg-serverpick { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow: auto; padding: var(--sp-1) var(--sp-2); border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--panel-2); }
.mg-serverpick .check { display: flex; align-items: center; gap: var(--sp-2); padding: 3px 0; }
.mg-progress { display: flex; flex-direction: column; gap: var(--sp-2); }
.mg-progress .bar { height: 8px; }
.mg-log { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow: auto; font-size: var(--fs-1); font-family: var(--mono); color: var(--muted); }
.mg-log > div { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-3); }
.mg-log > div > span:first-child { white-space: nowrap; }

/* moderation (bans.js, _mod.js, _manage.js) */
.mod-search { display: flex; gap: var(--gap-s); align-items: center; }
.mod-search .search { flex: 1; max-width: 520px; }
.mod-search .search input { width: 100%; }
.dur-picks { display: flex; flex-wrap: wrap; gap: var(--gap-s); }
.mod-hint:empty { display: none; }
.mod-actions { justify-content: flex-end; flex-wrap: nowrap; }
.mod-note { max-width: 360px; }
input.mod-uid { width: 200px; max-width: 100%; }
input.mod-hours { width: 96px; }
.mod-steps { margin: 0; padding-left: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-1); }
