* { box-sizing: border-box; }
html, body { height: 100%; }

/* ─────────────── login gate (fail-closed) ─────────────── */
/* Shown by default in the markup (covers everything); app.js adds .hidden only
   after a valid token is verified. Opaque so the admin UI never shows through. */
.login-gate {
    position: fixed;
    inset: 0;
    z-index: 6000;            /* above modals (1000), toasts (2000), inflight (2050) */
    background: #0e1117;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-gate.hidden { display: none; }
.login-box {
    width: 360px;
    max-width: 100%;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 30px 26px;
    text-align: center;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
}
.login-logo { font-size: 34px; line-height: 1; margin-bottom: 8px; }
.login-box h1 { margin: 0 0 14px; font-size: 18px; font-weight: 600; color: #e6edf3; }
.login-msg { font-size: 13px; color: #8b949e; margin: 0 0 14px; line-height: 1.5; }
.login-box input {
    width: 100%;
    background: #0d1117;
    border: 1px solid #30363d;
    color: #e6edf3;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    margin-bottom: 12px;
}
.login-box input:focus { border-color: #58a6ff; outline: none; }
.login-box .btn.primary { width: 100%; padding: 10px; font-size: 14px; }
.login-error {
    margin-top: 12px;
    font-size: 12px;
    color: #f85149;
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.4);
    border-radius: 6px;
    padding: 8px 10px;
    line-height: 1.5;
}
.login-error[hidden] { display: none; }
body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    background: #0e1117;
    color: #e6edf3;
    font-size: 13px;
}

/* ─────────────── header ─────────────── */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 22px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
}
header h1 { margin: 0; font-size: 17px; font-weight: 600; }
.status { font-size: 11px; color: #8b949e; font-family: ui-monospace, monospace; }
.status.ok { color: #3fb950; }
.status.err { color: #f85149; }
.logout-btn {
    background: none; border: 1px solid rgba(248,81,73,.4); color: #f85149;
    border-radius: 7px; padding: 3px 10px; font-size: 12px; cursor: pointer; margin-left: 4px;
}
.logout-btn:hover { background: rgba(248,81,73,.1); }

/* ─────────────── tabs ─────────────── */
.tabs {
    display: flex;
    background: #0d1117;
    border-bottom: 1px solid #30363d;
    padding: 0 22px;
}
.tab {
    background: transparent;
    border: 0;
    color: #8b949e;
    padding: 12px 18px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-right: 4px;
}
.tab:hover { color: #e6edf3; }
.tab.active { color: #58a6ff; border-bottom-color: #58a6ff; }

/* ─────────────── panels ─────────────── */
.panel { display: none; padding: 16px 22px 40px; }
.panel.active { display: block; }

/* ─────────────── toolbar ─────────────── */
.toolbar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.toolbar label {
    display: flex; flex-direction: column;
    font-size: 11px; color: #8b949e; gap: 4px;
}
.toolbar input, .toolbar select,
.modal-body input, .modal-body select, .modal-body textarea {
    background: #0d1117;
    border: 1px solid #30363d;
    color: #e6edf3;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    min-width: 180px;
    font-family: inherit;
}
.modal-body textarea { font-family: ui-monospace, monospace; min-width: 100%; min-height: 140px; }

/* ─────────────── buttons ─────────────── */
.btn {
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.1s, border-color 0.1s;
}
.btn:hover { background: #30363d; border-color: #58a6ff; }
.btn.primary { background: #238636; border-color: #2ea043; color: #fff; }
.btn.primary:hover { background: #2ea043; }
.btn.danger { background: #21262d; color: #f85149; }
.btn.danger:hover { background: #3a1d1d; border-color: #f85149; }
.btn.small { padding: 4px 10px; font-size: 11px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.busy {
    opacity: 0.75;
    cursor: progress;
    animation: busy-pulse 1.2s ease-in-out infinite;
}
@keyframes busy-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(88, 166, 255, 0.5); }
    50%  { box-shadow: 0 0 0 4px rgba(88, 166, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(88, 166, 255, 0); }
}

/* ─────────────── tables ─────────────── */
.counter, .bulk-counter { font-size: 11px; color: #8b949e; margin-left: auto; align-self: center; }
.table-wrap {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    overflow: hidden;
    overflow-x: auto;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.data-table th, .data-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #21262d;
    vertical-align: middle;
}
.data-table th {
    background: #161b22;
    color: #8b949e;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
}
.data-table tbody tr:hover { background: #161b22; }
.data-table tbody tr.selected { background: #1a2030; }

/* Token-keeper pause_reason='checkpoint': Meta requires manual selfie/web
   verify on this account. Highlight in red so the operator can spot
   accounts that won't recover via cron retry. Stripe on the left is
   subtler than a full-row tint and survives the .selected/.hover
   states without fighting them. */
.data-table tbody tr.row-checkpoint {
    background: rgba(248, 81, 73, 0.08);
    box-shadow: inset 3px 0 0 #f85149;
}
.data-table tbody tr.row-checkpoint:hover { background: rgba(248, 81, 73, 0.14); }
.data-table tbody tr.row-checkpoint.selected { background: rgba(248, 81, 73, 0.18); }
/* The row whose modal is currently open. A blue left-stripe + tint so the
   operator can match the open modal to its profile at a glance. Layered to
   win over :hover/.selected but not fight .row-checkpoint's red. */
.data-table tbody tr.modal-active {
    background: rgba(56, 139, 253, 0.28);
    box-shadow: inset 5px 0 0 #58a6ff;
}
.data-table tbody tr.modal-active:hover { background: rgba(56, 139, 253, 0.36); }
.data-table tbody tr.modal-active.selected { background: rgba(56, 139, 253, 0.40); }
.data-table tbody tr.flash {
    animation: row-flash 1.2s ease-out;
}
@keyframes row-flash {
    0%   { background: rgba(63, 185, 80, 0.40); }
    40%  { background: rgba(63, 185, 80, 0.20); }
    100% { background: transparent; }
}
.data-table .col-check { width: 32px; }
.data-table .empty {
    text-align: center;
    color: #6e7681;
    padding: 30px;
}
.data-table .actions-cell {
    display: flex; gap: 4px; flex-wrap: wrap;
}
.mono { font-family: ui-monospace, monospace; font-size: 11px; }
.dim { color: #6e7681; }

/* pills / badges */
.pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: #21262d;
    color: #8b949e;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.pill.ok      { background: #1a3a1a; color: #3fb950; }
.pill.danger  { background: #3a1a1a; color: #f85149; }

/* Compact GPM-status dot, sits inline with the email. Color = state,
   tooltip carries the human label. Open = green pulse so an active
   profile pops out when scrolling 100+ rows. */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    cursor: help;
}
.status-dot.status-open    { background: #3fb950; animation: status-pulse 1.6s ease-in-out infinite; }
.status-dot.status-closed  { background: #4d5560; }
.status-dot.status-unknown { background: #d29922; }

@keyframes status-pulse {
    0%, 100% { opacity: 1;    transform: scale(1); }
    50%      { opacity: 0.35; transform: scale(0.85); }
}
.pill.warn    { background: #3a2a1a; color: #d29922; }
.pill.err     { background: #3a1d1d; color: #f85149; }
.pill.info    { background: #1d2d3a; color: #58a6ff; }
.pill.muted   { background: #21262d; color: #8b949e; }

/* ─────────────── quick filter chips ─────────────── */
/* One-click filters above the table. Single-select for clarity:
   clicking a chip swaps the active filter (no multi-select combos).
   The count next to each chip mirrors what the operator will see
   when they click it. */
.filter-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

/* ─────────────── checkpoint alert banner ─────────────── */
.checkpoint-alert.hidden { display: none; }
.checkpoint-alert {
    margin-bottom: 12px;
    padding: 10px 14px;
    background: rgba(248, 81, 73, 0.08);
    border: 1px solid rgba(248, 81, 73, 0.4);
    border-left: 4px solid #f85149;
    border-radius: 6px;
    color: #ffa198;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.checkpoint-alert .ca-icon { font-size: 16px; }
.checkpoint-alert .ca-text { flex: 1; line-height: 1.5; }
.checkpoint-alert .ca-text strong { color: #ff7b72; }
.checkpoint-alert .ca-text .reason-chip {
    display: inline-block;
    background: rgba(248, 81, 73, 0.15);
    padding: 1px 6px;
    border-radius: 4px;
    margin: 0 3px;
    font-family: ui-monospace, monospace;
    font-size: 10px;
}
.checkpoint-alert .ca-actions { display: flex; gap: 6px; }
.checkpoint-alert .ca-actions .btn {
    background: transparent;
    border: 1px solid rgba(248, 81, 73, 0.5);
    color: #ffa198;
    font-size: 11px;
    padding: 4px 10px;
}
.checkpoint-alert .ca-actions .btn:hover {
    background: rgba(248, 81, 73, 0.15);
}
.chip {
    background: #161b22;
    border: 1px solid #30363d;
    color: #8b949e;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.chip:hover { color: #c9d1d9; border-color: #58a6ff; }
.chip.active { background: #1d2d3a; color: #58a6ff; border-color: #58a6ff; }
.chip .chip-count { opacity: 0.75; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* ─────────────── bulk action bar ─────────────── */
.bulk-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    flex-wrap: wrap;
}
.bulk-bar .select-all {
    display: flex; align-items: center; gap: 6px;
    color: #8b949e; font-size: 12px;
    margin-right: 8px;
}

/* ─────────────── queue tab ─────────────── */
.queue-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 14px;
    align-items: start;
}
.queue-log h3 {
    margin: 0 0 8px;
    font-size: 12px;
    text-transform: uppercase;
    color: #8b949e;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.output {
    background: #010409;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 12px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 11px;
    color: #c9d1d9;
    white-space: pre-wrap;
    word-break: break-word;
    height: 480px;
    overflow-y: auto;
    margin: 0 0 8px;
}

/* ─────────────── modal ─────────────── */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(1, 4, 9, 0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-backdrop.hidden { display: none; }
.modal {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    width: 540px;
    max-width: 92vw;
    max-height: 90vh;
    display: flex; flex-direction: column;
    box-shadow: 0 12px 48px rgba(0,0,0,0.6);
}
.modal-header {
    padding: 14px 18px;
    border-bottom: 1px solid #30363d;
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { margin: 0; font-size: 14px; }
.modal-close {
    background: transparent; border: 0; color: #8b949e;
    font-size: 22px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: #f85149; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-body .form-row {
    display: flex; flex-direction: column;
    gap: 4px; margin-bottom: 12px;
    font-size: 12px; color: #8b949e;
}
.modal-body input, .modal-body select, .modal-body textarea {
    width: 100%;
    color: #e6edf3;
}
.modal-footer {
    padding: 12px 18px;
    border-top: 1px solid #30363d;
    display: flex; gap: 8px; justify-content: flex-end;
}

/* Sticky inline result panel between body and footer. Survives across
   submits — operator returning to the tab can read the outcome at-a-
   glance without relying on the transient toast. */
.modal-result {
    margin: 0 18px 14px;
    padding: 0;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.5;
    display: none;
    border: 1px solid transparent;
    background: transparent;
    max-height: 280px;
    overflow-y: auto;
}
.modal-result.ok,
.modal-result.err,
.modal-result.warn,
.modal-result.info,
.modal-result.pending {
    display: block;
    padding: 10px 12px;
}
.modal-result.ok {
    background: rgba(63, 185, 80, 0.08);
    border-color: rgba(63, 185, 80, 0.4);
    color: #7ee787;
}
.modal-result.err {
    background: rgba(248, 81, 73, 0.08);
    border-color: rgba(248, 81, 73, 0.4);
    color: #ff7b72;
}
.modal-result.warn {
    background: rgba(210, 153, 34, 0.10);
    border-color: rgba(210, 153, 34, 0.4);
    color: #e3b341;
}
.modal-result.info {
    background: rgba(88, 166, 255, 0.10);
    border-color: rgba(88, 166, 255, 0.4);
    color: #79c0ff;
}
.modal-result.pending {
    background: rgba(139, 148, 158, 0.10);
    border-color: rgba(139, 148, 158, 0.35);
    color: #c9d1d9;
}

/* Prior-result banner at the top of action modals — how this op last went
   for the profile (from the meta_actions audit log). Color-coded by the
   latest status; subtler than .modal-result, which is for the live result. */
.prior-result {
    margin: 0 0 12px;
    padding: 7px 10px;
    border-radius: 6px;
    background: #0d1117;
    border: 1px solid #21262d;
    border-left: 3px solid #6e7681;
}
.prior-result.none, .prior-result.loading { border-left-color: #30363d; }
.prior-result.ok   { border-left-color: #3fb950; }
.prior-result.err  { border-left-color: #f85149; }
.prior-result.warn { border-left-color: #d29922; }
.prior-result.info, .prior-result.muted { border-left-color: #58a6ff; }
.prior-result-label {
    font-size: 10px;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: #6e7681;
    margin-bottom: 3px;
}
.modal-result-title {
    font-weight: 600;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.modal-result-title .timestamp {
    color: #6e7681;
    font-size: 10px;
    font-weight: normal;
    margin-left: auto;
}
.modal-result-msg {
    color: #c9d1d9;
    white-space: pre-wrap;
    word-break: break-word;
}
.modal-result details {
    margin-top: 8px;
    font-size: 11px;
    color: #8b949e;
}
.modal-result details summary {
    cursor: pointer;
    user-select: none;
    color: #8b949e;
}
.modal-result details summary:hover { color: #c9d1d9; }
.modal-result details pre {
    background: #0d1117;
    border: 1px solid #30363d;
    padding: 8px;
    border-radius: 4px;
    overflow: auto;
    margin: 6px 0 0;
    color: #8b949e;
    font-size: 11px;
    max-height: 200px;
    white-space: pre-wrap;
    word-break: break-all;
}
.modal-result.pending .modal-result-title::before {
    content: "";
    width: 10px; height: 10px;
    border: 2px solid #8b949e;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─────────────── upload progress bar ─────────────── */
.upload-progress {
    margin-top: 6px;
    font-family: ui-monospace, monospace;
    font-size: 11px;
}
.upload-progress-bar {
    width: 100%;
    height: 12px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 6px;
    overflow: hidden;
}
.upload-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #238636, #2ea043);
    transition: width 0.15s ease-out;
}
.upload-progress-text {
    color: #8b949e;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}

/* ─────────────── in-flight tracker (sticky top-right) ─────────────── */
/* Persists across modal close so the operator never loses track of a
   pending Add Card (which can take 30-120s through the browser bridge). */
.inflight-container {
    position: fixed;
    top: 18px; right: 18px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 2050;  /* above toasts */
    max-width: 460px;
    pointer-events: none;  /* let underlying UI clicks pass through gaps */
}
.inflight-card {
    pointer-events: auto;  /* but the card itself IS clickable */
    background: #21262d;
    border-left: 3px solid #58a6ff;
    color: #e6edf3;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.4);
    animation: slidein 0.18s ease;
}
.inflight-card.ok  { border-left-color: #3fb950; }
.inflight-card.err { border-left-color: #f85149; }
.inflight-card.info { border-left-color: #58a6ff; }
.inflight-msg { flex: 1; line-height: 1.45; word-break: break-word; }
.inflight-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ─────────────── toast ─────────────── */
.toast-container {
    position: fixed;
    bottom: 18px; right: 18px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 2000;
}
.toast {
    background: #21262d;
    border-left: 3px solid #58a6ff;
    color: #e6edf3;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 12px;
    min-width: 240px;
    max-width: 420px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.4);
    animation: slidein 0.18s ease;
}
.toast.ok { border-left-color: #3fb950; }
.toast.err { border-left-color: #f85149; }
.toast.warn { border-left-color: #d29922; }
@keyframes slidein {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 1100px) {
    .queue-grid { grid-template-columns: 1fr; }
}

/* ───────────────────────────── Users tab ───────────────────────────── */
.user-badge {
    font-size: 12px;
    color: #c9d1d9;
    padding: 3px 10px;
    background: #1d2d3a;
    border-radius: 10px;
    align-self: center;
}
.user-badge[hidden] { display: none; }

/* Once-only plaintext token box (create / rotate) */
.user-token-box {
    margin: 10px 0 14px;
    padding: 12px 14px;
    background: #16271a;
    border: 1px solid #2f6b45;
    border-radius: 6px;
}
.user-token-box.hidden { display: none; }
.user-token-head {
    font-weight: 600;
    color: #3fb950;
    margin-bottom: 6px;
    font-size: 13px;
}
.user-token-value {
    display: block;
    font-size: 14px;
    color: #e6edf3;
    word-break: break-all;
    padding: 6px 8px;
    background: #0d1117;
    border-radius: 4px;
}
.user-token-warn {
    font-size: 12px;
    color: #d29922;
    margin: 8px 0;
}
.user-token-actions { display: flex; gap: 8px; }

/* Inline assignments editor */
.user-assign-panel {
    margin-top: 14px;
    padding: 12px 14px;
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 6px;
}
.user-assign-panel.hidden { display: none; }
.user-assign-list {
    max-height: 320px;
    overflow-y: auto;
    margin-top: 8px;
    border: 1px solid #21262d;
    border-radius: 4px;
    padding: 6px;
}
.user-assign-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    cursor: pointer;
}
.user-assign-row:hover { background: #21262d; }
.user-assign-row.hidden { display: none; }
.user-assign-row span { font-size: 13px; color: #c9d1d9; }
/* Locked = profile already owned by another user (double-share guard) */
.user-assign-row.locked { cursor: not-allowed; opacity: 0.6; }
.user-assign-row.locked span { color: #8b949e; }
.user-assign-row .assign-owner-tag {
    margin-left: auto;
    font-size: 11px;
    color: #d29922;
    white-space: nowrap;
}
/* Per-user commission tier rows: label · master-rate tag · override input */
.user-comm-row { cursor: default; }
.user-comm-label { flex: 1; font-size: 13px; color: #c9d1d9; }
.user-comm-row .assign-owner-tag { margin-left: 0; }
.user-comm-input {
    width: 100px; min-width: 100px;
    background: #0d1117; border: 1px solid #30363d; color: #e6edf3;
    padding: 4px 8px; border-radius: 6px; font-size: 12px;
}

/* ── Vault "Card Wallet" — glanceable, grouped by physical card ─────────── */
.vault-summary {
    display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
    padding: 12px 18px; margin-bottom: 16px;
    background: #161b22; border: 1px solid #21262d; border-radius: 10px;
}
.vs-stat { display: flex; flex-direction: column; gap: 1px; }
.vs-num { font-size: 21px; font-weight: 700; color: #e6edf3; line-height: 1.1; }
.vs-num .vs-unit { font-size: 12px; font-weight: 500; color: #8b949e; margin-left: 3px; }
.vs-label { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: #8b949e; }
.vs-sep { width: 1px; align-self: stretch; background: #30363d; }

/* Codes (Gift) tab headline — reuses the .vs-stat / .vs-num / .vs-label /
   .vs-sep building blocks above; coloured numbers per metric so consumed /
   pending-consume / refunded read at a glance. */
.codes-stats {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 10px 16px; margin-bottom: 14px;
    background: #161b22; border: 1px solid #21262d; border-radius: 10px;
}
.codes-stats .vs-num { font-size: 19px; }
.codes-stats .vs-stat.dim { opacity: .45; }
.codes-stats .vs-num.ok   { color: #3fb950; }
.codes-stats .vs-num.warn { color: #d29922; }
.codes-stats .vs-num.err  { color: #f85149; }
.codes-stats .vs-num.dim  { color: #8b949e; }
/* Clickable stats — each filters the table to its subset (view=<key>). */
.codes-stats .vs-stat.clickable {
    cursor: pointer; border-radius: 8px; padding: 3px 9px;
    border: 1px solid transparent; transition: background .12s, border-color .12s;
}
.codes-stats .vs-stat.clickable:hover { background: #1c232c; border-color: #30363d; }
.codes-stats .vs-stat.active { background: #1d2d3a; border-color: #2f5a86; }
.codes-stats .vs-stat.active .vs-label { color: #c9d1d9; }
.vault-search { margin-left: auto; position: relative; display: flex; align-items: center; }
.vault-search input {
    background: #0d1117; border: 1px solid #30363d; border-radius: 8px;
    color: #e6edf3; padding: 8px 12px 8px 32px; font-size: 12px; width: 230px;
}
.vault-search input:focus { border-color: #58a6ff; outline: none; }
.vault-search .vs-icon { position: absolute; left: 10px; font-size: 12px; opacity: .55; pointer-events: none; }

.vault-wallet {
    display: grid; gap: 14px; align-content: start;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}
.vault-empty { color: #6e7681; padding: 24px; text-align: center; grid-column: 1 / -1; }

.vcard {
    border-radius: 14px; padding: 15px 17px; color: #fff;
    border: 1px solid rgba(255,255,255,.10);
    background: linear-gradient(135deg, #1f6feb 0%, #0d419d 100%);
    box-shadow: 0 1px 3px rgba(0,0,0,.45);
    transition: transform .12s ease, box-shadow .12s ease; cursor: default;
    display: flex; flex-direction: column;
}
.vcard:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.55); }
.vcard.brand-mc    { background: linear-gradient(135deg, #e0512f 0%, #7a2417 100%); }
.vcard.brand-amex  { background: linear-gradient(135deg, #1a936f 0%, #0d5c43 100%); }
.vcard.brand-disc  { background: linear-gradient(135deg, #e07a1f 0%, #8a4710 100%); }
.vcard.brand-other { background: linear-gradient(135deg, #57606a 0%, #2d333b 100%); }
.vcard.hide { display: none; }

.vcard-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.vcard-brand { font-weight: 700; letter-spacing: .6px; text-transform: uppercase; display: flex; align-items: center; }
.vcard-health { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 7px; flex: none; }
.vcard-health.good { background: #56d364; box-shadow: 0 0 7px #3fb950; }
.vcard-health.warn { background: #e3b341; box-shadow: 0 0 7px #d29922; }
.vcard-health.bad  { background: #ff7b72; box-shadow: 0 0 7px #f85149; }
.vcard-country { font-size: 12px; opacity: .9; }
.vcard-pan {
    font-family: ui-monospace, monospace; font-size: 18px; letter-spacing: 1.5px;
    margin: 16px 0 2px; font-weight: 600; text-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.vcard-exprow { font-size: 11px; opacity: .82; display: flex; justify-content: space-between; }
.vcard-hero {
    margin-top: 13px; padding-top: 11px; border-top: 1px solid rgba(255,255,255,.20);
    display: flex; align-items: baseline; gap: 7px;
}
.vcard-hero .gifts-num { font-size: 24px; font-weight: 800; line-height: 1; }
.vcard-hero .gifts-lbl { font-size: 12px; opacity: .92; }
.vcard-hero .delivered { font-size: 11px; opacity: .9; margin-left: auto; white-space: nowrap; }
.vcard-sub { font-size: 11px; opacity: .8; margin-top: 7px; display: flex; gap: 12px; flex-wrap: wrap; }
.vcard-actions { margin-top: 13px; display: flex; gap: 8px; }
.vcard-actions button {
    flex: 1; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.24);
    color: #fff; border-radius: 8px; padding: 7px 6px; font-size: 11px; cursor: pointer; font-weight: 600;
    transition: background .1s;
}
.vcard-actions button:hover { background: rgba(255,255,255,.30); }
.vcard-actions button:disabled { opacity: .4; cursor: not-allowed; }

/* Refund-trail table inside the modal */
.trail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; color: #c9d1d9; }
.trail-head .pill { font-size: 11px; }
.trail-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.trail-table th { text-align: left; color: #8b949e; font-weight: 500; font-size: 10px; text-transform: uppercase; letter-spacing: .3px; padding: 5px 8px; border-bottom: 1px solid #30363d; }
.trail-table td { padding: 6px 8px; border-bottom: 1px solid #1c2128; }
.trail-table tr:last-child td { border-bottom: none; }

/* Collapsible "Stats by BIN" */
.vault-bins-toggle {
    background: none; border: none; color: #8b949e; cursor: pointer;
    font-size: 12px; padding: 4px 0; display: flex; align-items: center; gap: 6px;
}
.vault-bins-toggle:hover { color: #c9d1d9; }

/* ── Refund-by-BIN scorecard ───────────────────────────────────────────── */
.refund-bin-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.refund-bin-days {
    background: #0d1117; border: 1px solid #30363d; border-radius: 7px;
    color: #e6edf3; padding: 4px 8px; font-size: 12px;
}
.refund-bin-days:focus { border-color: #58a6ff; outline: none; }
.refund-bin-table th.vt-num, .refund-bin-table td.vt-num { text-align: right; white-space: nowrap; }
.refund-bin-table tbody tr.refund-bin-bad { background: #2a1414; }
.refund-bin-table tbody tr.refund-bin-bad:hover { background: #361818; }
.refund-hot { color: #f85149; }
.refund-bin-table th.sortable { cursor: pointer; user-select: none; }
.refund-bin-table th.sortable:hover { color: #e6edf3; }
.refund-bin-table th.sorted { color: #58a6ff; }
.refund-bin-table th .sort-ind { margin-left: 4px; font-size: 10px; color: #58a6ff; }

/* ── Vault TABLE (one row per physical card, grouped by pan_fp) ─────────── */
.toolbar .vault-search { margin-left: auto; position: relative; display: flex; align-items: center; }
.toolbar .vault-search input {
    background: #0d1117; border: 1px solid #30363d; border-radius: 7px;
    color: #e6edf3; padding: 6px 10px 6px 28px; font-size: 12px; width: 220px;
}
.toolbar .vault-search input:focus { border-color: #58a6ff; outline: none; }
.toolbar .vault-search .vs-icon { position: absolute; left: 8px; font-size: 11px; opacity: .55; pointer-events: none; }

.vault-table th.vt-num, .vault-table td.vt-num { text-align: right; white-space: nowrap; }
.vault-table th.vt-act, .vault-table td.vt-act { text-align: right; white-space: nowrap; width: 1%; }
.vault-table td.vt-card { white-space: nowrap; }
.vault-table tbody tr.card-row { cursor: pointer; }
.vault-table tbody tr.card-row.open { background: #1a2030; }

.hdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: middle; flex: none; }
.hdot.good { background: #3fb950; }
.hdot.warn { background: #d29922; }
.hdot.bad  { background: #f85149; }
.brand-tag { font-weight: 600; }
.vault-gifts { font-weight: 700; font-size: 13px; color: #e6edf3; }
.vault-gifts.zero { color: #6e7681; font-weight: 400; }
.vault-gifts .vg-del { font-weight: 400; font-size: 11px; color: #3fb950; margin-left: 4px; }
.vault-gifts .vg-und { color: #d29922; }
.add-ok { color: #3fb950; }
.add-bad { color: #f85149; }

.vault-trail-row > td { background: #0d1117; padding: 12px 16px; }
.vault-trail-row .trail-prof { font-size: 11px; color: #8b949e; margin-bottom: 8px; }
.vault-trail-row .trail-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.vault-trail-row .trail-table th { text-align: left; color: #8b949e; font-weight: 500; font-size: 10px; text-transform: uppercase; letter-spacing: .3px; padding: 4px 8px; border-bottom: 1px solid #30363d; }
.vault-trail-row .trail-table td { padding: 5px 8px; border-bottom: 1px solid #1c2128; }
.vault-trail-row .trail-table tr:last-child td { border-bottom: none; }

/* ── Refund status — animated icons (replaces the ✓/text badge) ────────── */
.refund-ic { display: inline-block; font-size: 15px; line-height: 1; cursor: default; will-change: transform; }
.refund-ic.clean    { animation: refundBreathe 2.6s ease-in-out infinite; }
.refund-ic.refunded { animation: refundShake 0.9s ease-in-out infinite; }
.refund-ic.pending  { animation: refundSpin 1.8s linear infinite; opacity: .75; }
@keyframes refundBreathe {
  0%, 100% { transform: scale(1);    filter: drop-shadow(0 0 0 rgba(63,185,80,0)); }
  50%      { transform: scale(1.22); filter: drop-shadow(0 0 5px rgba(63,185,80,.75)); }
}
@keyframes refundShake {
  0%, 100% { transform: translateX(0) rotate(0);     filter: drop-shadow(0 0 3px rgba(248,81,73,.75)); }
  25%      { transform: translateX(-2.5px) rotate(-8deg); }
  75%      { transform: translateX(2.5px) rotate(8deg); }
}
@keyframes refundSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .refund-ic.clean, .refund-ic.refunded, .refund-ic.pending { animation: none; }
}

/* ── Friendly icons (tabs / chips) ────────────────────────────────────── */
.tab-ic { margin-right: 6px; font-size: 13px; line-height: 1; vertical-align: -1px; }
.chip-ic { margin-right: 5px; font-size: 12px; vertical-align: -1px; }

/* ── Vault: friendly icons + ambient animation ────────────────────────── */
.vth-ic { margin-right: 5px; opacity: .7; font-size: 12px; }
/* health dots come alive per status */
.hdot.good { animation: hdotPulse 2.8s ease-in-out infinite; }
.hdot.warn { animation: hdotWarn 1.8s ease-in-out infinite; }
.hdot.bad  { animation: hdotBad 1s ease-in-out infinite; }
@keyframes hdotPulse {
  0%, 70%, 100% { box-shadow: 0 0 0 0 rgba(63,185,80,.55); }
  35%           { box-shadow: 0 0 0 5px rgba(63,185,80,0); }
}
@keyframes hdotWarn {
  0%, 100% { opacity: .55; box-shadow: 0 0 0 0 rgba(210,153,34,.0); }
  50%      { opacity: 1;   box-shadow: 0 0 6px 1px rgba(210,153,34,.55); }
}
@keyframes hdotBad { 0%, 100% { opacity: 1; } 50% { opacity: .28; } }
/* gift icon gently bobs (only on cards that bought gifts) */
.vgift-ic { display: inline-block; margin-right: 4px; animation: vgiftBob 3s ease-in-out infinite; }
@keyframes vgiftBob {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50%      { transform: translateY(-2px) rotate(6deg); }
}
/* interactive button icons */
.reuse-ic, .trail-ic { display: inline-block; }
.vault-reuse:hover .reuse-ic { animation: vSpin .6s ease; }
.vault-trail:hover .trail-ic { animation: vNudge .5s ease; }
@keyframes vSpin { to { transform: rotate(360deg); } }
@keyframes vNudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(3px); } }
/* rows fade/slide in on (re)load — JS sets a small per-row stagger delay */
.vault-table tbody tr.card-row { animation: vRowIn .34s ease both; }
@keyframes vRowIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
/* summary count icons */
.vs-ic { margin: 0 4px 0 2px; }
@media (prefers-reduced-motion: reduce) {
  .hdot.good, .hdot.warn, .hdot.bad, .vgift-ic,
  .vault-table tbody tr.card-row { animation: none !important; }
}

/* ── Vault: card-level REFUND flag (spot a refund without opening trail) ── */
.vault-refunded {
    color: #f85149; font-weight: 700; font-size: 12px; margin-left: 6px;
    display: inline-block; animation: refundShake 0.9s ease-in-out infinite;
}
.vault-table tbody tr.card-row.has-refund {
    box-shadow: inset 3px 0 0 0 #f85149;          /* red left rail */
    background: rgba(248,81,73,.06);
}
.vault-table tbody tr.card-row.has-refund:hover { background: rgba(248,81,73,.12); }

/* ── Vault Trail: per-gift money + refund amount (migration 048) ───────── */
.trail-table .gift-amt { font-variant-numeric: tabular-nums; font-weight: 600; color: #c9d1d9; white-space: nowrap; }
.trail-table .gift-amt.approx { font-weight: 500; color: #8b949e; }   /* catalog-price fallback */
.trail-table .refund-amt { font-variant-numeric: tabular-nums; font-weight: 700; color: #f85149; margin-left: 2px; white-space: nowrap; }
.trail-refunded-total {
    margin-top: 8px; padding: 6px 9px; border-radius: 6px;
    background: rgba(248,81,73,.08); border: 1px solid rgba(248,81,73,.28);
    color: #f0a5a0; font-size: 11px; font-weight: 600;
}
/* ── Order-addon self-purchase chip — a real charge, NOT a gift (no kho code) */
.vault-addon {
    color: #a371f7; font-weight: 600; font-size: 11px; margin-left: 6px;
    padding: 0 5px; border-radius: 4px; white-space: nowrap;
    background: rgba(163,113,247,.12); border: 1px solid rgba(163,113,247,.30);
}
/* ── Commission ("hoa hồng") — gold accent, distinct from refund red ───── */
.vault-commission { color: #e3b341; font-weight: 700; font-size: 12px; margin-left: 4px; white-space: nowrap; }
.vs-commission { color: #e3b341; font-weight: 700; }
.trail-table .gift-comm { font-variant-numeric: tabular-nums; font-weight: 600; color: #e3b341; white-space: nowrap; }
.trail-table .gift-comm.void { text-decoration: line-through; color: #8b949e; font-weight: 500; }
.trail-commission-total {
    margin-top: 8px; padding: 6px 9px; border-radius: 6px;
    background: rgba(227,179,65,.08); border: 1px solid rgba(227,179,65,.28);
    color: #e3b341; font-size: 11px; font-weight: 600;
}
/* ── Paid-out ("đã trả" — commission paid to the tenant, migration 077) ──
   green = a settled, completed state, distinct from gold-earned + red-refund */
.vault-paidout {
    color: #3fb950; font-weight: 600; font-size: 11px; margin-left: 6px;
    padding: 0 5px; border-radius: 4px; white-space: nowrap;
    background: rgba(63,185,80,.12); border: 1px solid rgba(63,185,80,.30);
}
.vs-paidout { color: #3fb950; font-weight: 600; cursor: pointer; }
.vs-paidout:hover { text-decoration: underline; }
.trail-paidout-total {
    margin-top: 6px; padding: 6px 9px; border-radius: 6px;
    background: rgba(63,185,80,.08); border: 1px solid rgba(63,185,80,.28);
    color: #3fb950; font-size: 11px; font-weight: 600;
}
/* health legend */
.vault-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 8px 2px; font-size: 11px; color: #8b949e; }
.vault-legend-key { display: inline-flex; align-items: center; gap: 5px; }
.vault-legend-key .hdot { animation: none; }   /* static dots in the legend */

/* ── Vault: quick filters + sortable headers ──────────────────────────── */
.vault-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px 2px; }
.vchip {
    background: #161b22; border: 1px solid #30363d; border-radius: 999px;
    color: #8b949e; padding: 4px 12px; font-size: 12px; cursor: pointer;
    transition: background .1s, color .1s, border-color .1s;
}
.vchip:hover { color: #e6edf3; border-color: #58a6ff; }
.vchip.active { background: #1f6feb; border-color: #1f6feb; color: #fff; }
.vchip.muted { opacity: .45; }
.vault-table th.sortable { cursor: pointer; user-select: none; }
.vault-table th.sortable:hover { color: #e6edf3; }
.vault-table th.sorted { color: #58a6ff; }
.vault-table th .sort-ind { margin-left: 4px; font-size: 10px; color: #58a6ff; }

/* ── Vault: 4-day refund-watch countdown + new-card badge ─────────────── */
.watch { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; }
.watch-bar { width: 54px; height: 6px; border-radius: 3px; background: #21262d; overflow: hidden; flex: none; }
.watch-bar > i { display: block; height: 100%; border-radius: 3px; transition: width .4s ease; }
.watch.active .watch-bar > i { background: #58a6ff; }
.watch.soon   .watch-bar > i { background: #d29922; animation: watchPulse 1.4s ease-in-out infinite; }
.watch.soon   .watch-lbl { color: #d29922; font-weight: 600; }
.watch.settled { color: #3fb950; }
.watch-lbl { color: #8b949e; white-space: nowrap; }
@keyframes watchPulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
.new-badge {
    background: #1f6feb; color: #fff; border-radius: 4px; padding: 0 5px;
    font-size: 10px; font-weight: 700; margin-left: 7px; vertical-align: 1px;
    animation: newPop 2s ease-in-out infinite;
}
@keyframes newPop { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .watch.soon .watch-bar > i, .new-badge { animation: none; } }

/* Vault summary: clickable "in watch" pill */
.vs-watching { color: #58a6ff; font-weight: 600; cursor: pointer; }
.vs-watching:hover { text-decoration: underline; }

/* Vault filter chip count badge */
.vchip-n {
    margin-left: 6px; padding: 0 6px; border-radius: 999px;
    background: rgba(255,255,255,.10); font-size: 11px; font-weight: 600;
    font-variant-numeric: tabular-nums; min-width: 14px; display: inline-block; text-align: center;
}
.vchip.active .vchip-n { background: rgba(255,255,255,.28); color: #fff; }
.vchip.muted .vchip-n { background: rgba(255,255,255,.06); }
.vchip-m {
    margin-left: 5px; font-size: 10px; font-weight: 600; color: #e3b341;
    font-variant-numeric: tabular-nums;
}
.vchip.active .vchip-m { color: #fde68a; }

/* ===== Users-table stat cells: colored-ratio (ustat-) =====
   The SUCCESS count is the signal: bold green, no pills, one line.
   Grafts: V3 amber-denominator as the partial cue (green never flips to
   amber); V1 refund-only-when->0; brighter green (#56d364, the existing
   .vcard-health.good token) on a perfect score. No td-level padding — the
   cells inherit .data-table td (8px 12px, vertical-align:middle) so they
   keep identical height to sibling mono cells (preserves fleet-wide row
   rhythm). All single-line + mono so they stay narrow in the dense 9-col
   table and survive the #161b22 hover. */
.ustat {
    font-family: ui-monospace, monospace;
    font-size: 11px;
    white-space: nowrap;          /* stay single-line at narrow widths */
    line-height: 1.3;
}

/* success count — the headline (green) */
.ustat-ok            { color: #3fb950; font-weight: 600; }
/* full success: every attempt landed — brighter so 12/12 out-ranks 7/9 */
.ustat-ok.ustat-full { color: #56d364; }
/* nothing succeeded but there WERE attempts → the count goes red */
.ustat-ok.ustat-zero { color: #f85149; }

/* the "/total" denominator — recede it (dim) */
.ustat-tot           { color: #6e7681; }
/* on a partial result, tint the denominator amber as the peripheral
   "some failed" cue — green success number NEVER flips to amber */
.ustat-tot.ustat-partial { color: #d29922; }

/* trailing faint percentage (11px so it stays readable on dark) */
.ustat-pct           { color: #8b949e; margin-left: 4px; font-size: 11px; }

/* thin separator dot between orders' delivered + refund clauses */
.ustat-sep           { color: #30363d; margin: 0 5px; }

/* refund clause — only rendered when refund > 0 (red, can't be missed) */
.ustat-refund        { color: #f85149; font-weight: 600; }
.ustat-refund .ustat-pct { color: #f85149; opacity: .85; }

/* per-user commission — gold = DONE (withdrawable), dim = pending, + withdraw btn */
.ucommission         { color: #e3b341; font-weight: 600; white-space: nowrap; }
.ucomm-cell          { white-space: nowrap; }
.ucomm-pending       { color: #8b949e; font-weight: 500; font-size: 11px; }
.ucomm-skip          { color: #d29922; background: rgba(210,153,34,.12); border: 1px solid rgba(210,153,34,.35); border-radius: 4px; padding: 0 5px; font-size: 10px; font-weight: 600; }
/* refund-after-payout (clawback) badge — red, clickable, opens the item trail */
.ucomm-clawback      { color: #f85149; background: rgba(248,81,73,.10); border: 1px solid rgba(248,81,73,.35); border-radius: 4px; padding: 0 5px; margin-left: 6px; font-size: 10px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.ucomm-clawback:hover { background: rgba(248,81,73,.18); }
/* red money figure in the clawback item-trail modal */
.ustat-bad           { color: #f85149; font-weight: 600; }
.ucomm-withdraw, .ucomm-history { margin-left: 6px; vertical-align: middle; }
/* pending payout-request queue on the Users tab */
.commission-requests { margin: 8px 0 12px; padding: 10px 12px; border-radius: 8px;
    background: rgba(227,179,65,.07); border: 1px solid rgba(227,179,65,.3); }
.commission-requests h3 { margin: 0 0 8px; font-size: 14px; }
.creq-list { display: flex; flex-direction: column; gap: 7px; }
.creq-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.creq-user { font-weight: 600; min-width: 120px; }
.creq-amt b { color: #e3b341; font-variant-numeric: tabular-nums; }

/* the quiet "no refund" state — barely-there, confirms it was checked */
.ustat-clean         { color: #6e7681; font-size: 11px; }

/* Consume button armed (inline two-click confirm) — amber "click again" state */
.vault-consume-arm, .consume-arm { background: #d29922 !important; border-color: #d29922 !important; color: #1a1100 !important; font-weight: 600; }

/* ─────────────── Profiles render-window "load more" sentinel ─────────────── */
/* Appended row when the filtered fleet has more profiles than the painted
   window. It is NOT a data row — never tint it on hover. */
.data-table tbody tr.load-more-row,
.data-table tbody tr.load-more-row:hover,
.data-table tbody tr.vault-load-more-row,
.data-table tbody tr.vault-load-more-row:hover { background: transparent; }
.load-more-cell { text-align: center; padding: 14px 12px; }
.load-more-info { margin-left: 10px; font-size: 11px; }
/* "load more" sentinel inside the Users → Assignments editor list (windowed). */
.assign-load-more { text-align: center; padding: 10px 6px; }
.assign-load-more .dim { margin-left: 8px; font-size: 11px; }

/* ════════════════════════════════════════════════════════════════════════
   MOBILE / SMALL-SCREEN LAYOUT
   Desktop layout is unchanged — every rule below lives inside a media query.
   Tables stay as tables but scroll horizontally with momentum; the chrome
   (header / tabs / toolbar / bars / modals / toasts) reflows to fit a phone.
   ════════════════════════════════════════════════════════════════════════ */
@media (max-width: 820px) {
    body { font-size: 13px; -webkit-text-size-adjust: 100%; }

    /* header — title row wraps, the long status banner drops to its own line
       and truncates instead of overflowing. */
    header { padding: 10px 12px; flex-wrap: wrap; gap: 6px 10px; }
    header h1 { font-size: 15px; flex: 1 1 auto; }
    .user-badge { font-size: 11px; padding: 2px 8px; }
    .status {
        flex: 1 1 100%; order: 5; min-width: 0;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        font-size: 10px;
    }

    /* tabs — single swipeable row instead of wrapping to 3 lines. */
    .tabs {
        padding: 0 6px; flex-wrap: nowrap;
        overflow-x: auto; -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab { flex: 0 0 auto; white-space: nowrap; padding: 11px 12px; margin-right: 2px; }

    /* panels — reclaim side padding for table width. */
    .panel { padding: 12px 10px 32px; }

    /* toolbar — controls go full-width and stack cleanly. */
    .toolbar { gap: 10px; }
    .toolbar label { flex: 1 1 100%; }
    .toolbar input, .toolbar select { min-width: 0; width: 100%; }
    .toolbar .btn { flex: 1 1 auto; }
    .counter, .bulk-counter { margin-left: 0; flex: 1 1 100%; }

    /* search box on the vault/codes toolbars — full width, not right-pinned. */
    .vault-search, .toolbar .vault-search { flex: 1 1 100%; margin-left: 0; }
    .vault-search input, .toolbar .vault-search input { width: 100%; }

    /* filter + bulk bars — tappable, wrap, stay inside the viewport. */
    .filter-chips { gap: 6px; }
    .bulk-bar { gap: 8px 10px; padding: 8px 10px; }
    .bulk-bar .select-all { margin-right: 0; }

    /* tables — let columns keep their natural width and scroll sideways with
       momentum rather than crushing 8+ columns into 360px. */
    .table-wrap { -webkit-overflow-scrolling: touch; border-radius: 6px; }
    .data-table { width: auto; min-width: 100%; }
    .data-table th, .data-table td { padding: 7px 9px; }
    /* slightly larger, more tappable action buttons in dense rows */
    .actions-cell { gap: 5px; }
    .actions-cell .btn, .data-table .btn.small { padding: 6px 10px; font-size: 11px; }

    /* queue tab — log under the list, shorter pane. */
    .queue-grid { grid-template-columns: 1fr; }
    .output { height: 300px; }

    /* modals fill the small screen; footer buttons wrap. */
    .modal { width: 96vw; max-width: 96vw; max-height: 92vh; }
    .modal-body { padding: 14px; }
    .modal-footer { padding: 10px 14px; flex-wrap: wrap; }
    .modal-footer .btn { flex: 1 1 auto; }

    /* toasts + in-flight cards span the width at the bottom/top edge. */
    .toast-container { left: 8px; right: 8px; bottom: 10px; }
    .toast { min-width: 0; max-width: none; width: 100%; }
    .inflight-container { left: 8px; right: 8px; top: 10px; max-width: none; }

    /* the "load more" sentinel stacks its label under the button on a phone. */
    .load-more-cell { padding: 12px 8px; }
    .load-more-info { display: block; margin: 6px 0 0; }

    /* Money tab summary reflows onto its own full-width line (mirrors .counter). */
    .toolbar #money-summary, .toolbar #subs-summary { flex: 1 1 100%; margin-left: 0; }

    /* Codes/Addons headline stat bar — tighten + drop the vertical separators
       (they read as stray lines once the row wraps on a narrow phone). */
    .codes-stats { gap: 8px 12px; padding: 8px 12px; }
    .codes-stats .vs-num { font-size: 16px; }
    .codes-stats .vs-sep { display: none; }

    /* Users inline editor panels (assign / clone / commission): rows + tags
       wrap instead of clipping; the count inputs go full-width. */
    .user-assign-row { flex-wrap: wrap; }
    .user-assign-row .assign-owner-tag { margin-left: 0; flex: 1 1 100%; white-space: normal; }
    .user-comm-row { flex-wrap: wrap; }
    .user-assign-panel .toolbar input[type="number"] { min-width: 0; max-width: none; width: 100%; }
}

/* very small phones — trim further so nothing clips. */
@media (max-width: 480px) {
    header h1 { font-size: 14px; }
    .logout-btn { padding: 3px 8px; font-size: 11px; }
    .tab { padding: 10px 10px; font-size: 12px; }
    .panel { padding: 10px 8px 28px; }
    .data-table th, .data-table td { padding: 6px 8px; }
    .data-table th { font-size: 9px; }
    h3 { font-size: 13px; }
}

/* ───────── Subscriptions cashflow panel (Subs tab) ───────── */
.subs-money { margin: 4px 0 14px; }
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 8px;
}
.kpi {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 10px 12px;
}
.kpi-v { font-size: 19px; font-weight: 700; color: #c9d1d9; line-height: 1.1; }
.kpi-l { font-size: 11px; color: #8b949e; margin-top: 3px; }
.kpi-s { font-size: 10.5px; color: #6e7681; margin-top: 2px; }
.kpi.ok   { border-left: 3px solid #3fb950; }
.kpi.info { border-left: 3px solid #58a6ff; }
.kpi.warn { border-left: 3px solid #d29922; }
.kpi.err  { border-left: 3px solid #f85149; }
.kpi.ok   .kpi-v { color: #3fb950; }
.subs-money-tables {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin-top: 12px;
}
.subs-money-h { margin: 0 0 6px; font-size: 12px; color: #8b949e; font-weight: 600; }
.data-table.compact th, .data-table.compact td { padding: 4px 8px; font-size: 11.5px; }
