/* ============================================================
   InterSpace CMS — POLISH LAYER (v3)
   Loaded AFTER artist-dashboard.css. Elevates the existing
   dark + light system. Identity preserved: #DE0A26 accent,
   Space Grotesk, near-black surfaces. Nothing here changes
   the brand — it perfects states, motion, a11y, and adds the
   missing feedback components (alerts, toasts, skeletons…).

   Dark is the default (:root). Every addition has a light
   counterpart under [data-theme="light"].
   ============================================================ */

/* ════════════════════════════════════════════════════════════
   1 · TOKENS  (additive — merges with the base :root)
   ════════════════════════════════════════════════════════════ */
:root {
    /* Premium easing curves (no bounce / elastic) */
    --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
    --ease-out-expo:  cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-soft:  cubic-bezier(0.33, 1, 0.68, 1);
    --ease-in-out:    cubic-bezier(0.65, 0, 0.35, 1);

    /* Durations */
    --dur-1: 120ms;
    --dur-2: 180ms;
    --dur-3: 240ms;
    --dur-4: 320ms;

    /* Refine the global transitions to use the premium curve.
       Propagates to every existing component that uses these. */
    --transition:    var(--dur-2) var(--ease-out-quart);
    --transition-md: var(--dur-4) var(--ease-out-quart);

    /* Spacing scale (for new work; existing px untouched) */
    --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
    --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;

    /* Elevation — layered, dark-tuned */
    --shadow-sm: 0 1px 2px rgba(0,0,0,.45), 0 1px 1px rgba(0,0,0,.30);
    --shadow-md: 0 6px 22px rgba(0,0,0,.50);
    --shadow-xl: 0 18px 55px rgba(0,0,0,.66);

    /* Focus + accent rings */
    --ring-accent:  0 0 0 3px rgba(222,10,38,.30);
    --ring-danger:  0 0 0 3px rgba(255,59,59,.28);
    --ring-success: 0 0 0 3px rgba(16,185,129,.26);

    /* Semantic z-index scale (existing values preserved, gaps filled) */
    --z-raised: 10;
    --z-sticky: 100;
    --z-overlay: 150;
    --z-sidebar: 200;
    --z-dropdown: 300;
    --z-modal-backdrop: 900;
    --z-modal: 901;
    --z-toast: 1000;
    --z-tooltip: 1100;

    /* Control sizing */
    --control-h: 40px;
    --control-h-sm: 32px;
    --control-h-lg: 48px;
    --r-pill: 9999px;

    /* Compat aliases — these token names are referenced across the
       codebase (login, signup, verify-otp, shared header, 3 admin
       pages) but were NEVER defined, so they fell back to #fff and
       went invisible on light surfaces. Aliasing the real tokens
       fixes all 17 usages in both themes at once. */
    --text-1: var(--text);
    --text-4: var(--text-3);

    /* More undefined tokens referenced across pages (audited):
       --border-1 (5 release pages: create/dsp/review/schedule/tracks)
       had no fallback, so those borders never rendered at all.
       --surface-1/--input-bg fell back to fixed dark/translucent
       values that broke in light mode. --err/--error fixed too. */
    --border-1: var(--border);
    --surface-1: var(--surface);
    --input-bg: var(--bg-3);
    --err: var(--danger);
    --error: var(--danger);
}

[data-theme="light"] {
    --shadow-sm: 0 1px 2px rgba(60,40,100,.10), 0 1px 1px rgba(60,40,100,.06);
    --shadow-md: 0 6px 22px rgba(60,40,100,.12);
    --shadow-xl: 0 18px 55px rgba(60,40,100,.20);
    --ring-accent: 0 0 0 3px rgba(222,10,38,.18);
}

/* ════════════════════════════════════════════════════════════
   2 · GLOBAL BASE ENHANCEMENTS
   ════════════════════════════════════════════════════════════ */
html { -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
body { font-feature-settings: "ss01", "cv01", "tnum" 0; }

/* Tabular numerals where numbers must align (stats, money, tables) */
.stat-value, .balance-amount, .data-table td, .sub-price, .pricing-amount,
.tnum, [data-tnum] { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* Native form controls inherit the brand */
input[type="checkbox"], input[type="radio"], progress,
input[type="range"] { accent-color: var(--accent); }

/* Selection */
::selection { background: rgba(222,10,38,.30); color: #fff; }
[data-theme="light"] ::selection { background: rgba(222,10,38,.22); color: var(--text); }

/* Refined scrollbars — slightly more grabbable, inset look.
   (Narrow component scrollbars like .sidebar-nav keep their own.) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.16);
    border: 2px solid transparent;
    background-clip: padding-box;
    border-radius: var(--r-pill);
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.28); border: 2px solid transparent; background-clip: padding-box; }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0,0,0,.20); border: 2px solid transparent; background-clip: padding-box; }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.30); border: 2px solid transparent; background-clip: padding-box; }
[data-theme="light"] * { scrollbar-color: rgba(0,0,0,.22) transparent; }

/* Keyboard focus — visible everywhere, never for mouse users.
   Inputs keep their own accent ring (below); this covers the rest. */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}
a:focus-visible, .nav-item:focus-visible, .topbar-icon-btn:focus-visible,
.topbar-avatar-btn:focus-visible, .filter-pill:focus-visible, .dsp-chip:focus-visible,
.sidebar-plan-badge:focus-visible, .sidebar-logout-btn:focus-visible,
.topbar-dropdown-item:focus-visible, .modal-close:focus-visible,
.ryl-tab:focus-visible, .menu-item:focus-visible, .tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
/* On the solid-red primary, a red ring is invisible — use a haloed ring */
.btn-primary:focus-visible {
    outline: none;
    box-shadow: 0 4px 16px rgba(222,10,38,.35), 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}
[data-theme="light"] .btn-primary:focus-visible {
    box-shadow: 0 4px 16px rgba(222,10,38,.30), 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}
/* Mouse users: never show the box on click */
:focus:not(:focus-visible) { outline: none; }

/* ════════════════════════════════════════════════════════════
   3 · BUTTONS — complete state matrix
   ════════════════════════════════════════════════════════════ */
.btn { -webkit-tap-highlight-color: transparent; user-select: none; will-change: transform; }
.btn:active { transform: translateY(0) scale(.985); }
.btn-primary:active { transform: translateY(0) scale(.985); box-shadow: 0 2px 10px rgba(222,10,38,.40); }

.btn:disabled, .btn[disabled], .btn.is-disabled {
    opacity: .5;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
    transform: none;
    filter: saturate(.7);
}

/* Loading state — text hidden, spinner centred */
.btn.is-loading { color: transparent !important; pointer-events: none; position: relative; }
.btn.is-loading > * { opacity: 0; }
.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 16px; height: 16px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-top-color: transparent;
    color: #fff;
    animation: is-spin .6s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after { color: var(--text); }

/* Square icon-only button that matches .btn height */
.btn-icon { padding: 9px; aspect-ratio: 1; }
.btn-icon.btn-sm { padding: 6px; }
.btn-icon.btn-lg { padding: 13px; }

/* Success / warning variants to complete the semantic set */
.btn-success { background: var(--success-dim); color: var(--success); border: 1px solid rgba(16,185,129,.22); }
.btn-success:hover { background: rgba(16,185,129,.2); }
.btn-warning { background: var(--warning-dim); color: var(--warning); border: 1px solid rgba(245,158,11,.24); }
.btn-warning:hover { background: rgba(245,158,11,.2); }

/* ════════════════════════════════════════════════════════════
   4 · FORMS — hover, disabled, validation, controls
   ════════════════════════════════════════════════════════════ */
.form-input:hover:not(:focus):not(:disabled),
.form-select:hover:not(:focus):not(:disabled),
.form-textarea:hover:not(:focus):not(:disabled) { border-color: var(--border-2); }

.form-input:disabled, .form-select:disabled, .form-textarea:disabled,
.form-input[readonly] {
    opacity: .6;
    cursor: not-allowed;
    background: var(--bg-2);
}

/* Validation states */
.form-input.is-invalid, .form-select.is-invalid, .form-textarea.is-invalid,
[aria-invalid="true"].form-input, [aria-invalid="true"].form-select, [aria-invalid="true"].form-textarea {
    border-color: var(--danger);
}
.form-input.is-invalid:focus, .form-select.is-invalid:focus, .form-textarea.is-invalid:focus { box-shadow: var(--ring-danger); }
.form-input.is-valid, .form-select.is-valid, .form-textarea.is-valid { border-color: var(--success); }
.form-input.is-valid:focus, .form-textarea.is-valid:focus { box-shadow: var(--ring-success); }

.form-error, .form-success {
    display: flex; align-items: center; gap: 5px;
    font-size: .75rem; font-weight: 500; margin-top: 6px;
}
.form-error { color: var(--danger); }
.form-success { color: var(--success); }
.form-error svg, .form-success svg { width: 13px; height: 13px; flex-shrink: 0; }

/* Select chevron (selects had no arrow) — themed via SVG stroke */
.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23A8A8B3' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 38px;
}
[data-theme="light"] .form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238D8BA2' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

/* Custom checkbox / radio (opt-in) */
.form-check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: .875rem; color: var(--text-2); user-select: none; }
.form-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.form-check-box {
    width: 18px; height: 18px; flex-shrink: 0;
    border: 1.5px solid var(--border-2);
    border-radius: 5px;
    background: var(--bg-3);
    display: grid; place-items: center;
    transition: all var(--transition);
}
.form-check input[type="radio"] ~ .form-check-box { border-radius: 50%; }
.form-check-box::after {
    content: ""; width: 10px; height: 10px;
    background: #fff; border-radius: 2px;
    transform: scale(0); transition: transform var(--dur-2) var(--ease-out-quart);
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
}
.form-check input[type="radio"] ~ .form-check-box::after { border-radius: 50%; clip-path: none; width: 8px; height: 8px; }
.form-check input:checked ~ .form-check-box { background: var(--accent); border-color: var(--accent); }
.form-check input:checked ~ .form-check-box::after { transform: scale(1); }
.form-check input:focus-visible ~ .form-check-box { outline: 2px solid var(--accent); outline-offset: 2px; }
.form-check:hover .form-check-box { border-color: var(--accent); }

/* Switch (labelled, builds on existing .toggle-track look) */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
    width: 44px; height: 24px; flex-shrink: 0;
    background: rgba(255,255,255,.12);
    border-radius: var(--r-pill);
    position: relative;
    transition: background var(--transition);
}
[data-theme="light"] .switch-track { background: rgba(0,0,0,.15); }
.switch-track::after {
    content: ""; position: absolute; top: 3px; left: 3px;
    width: 18px; height: 18px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3);
    transition: transform var(--dur-3) var(--ease-out-quart);
}
.switch input:checked ~ .switch-track { background: var(--accent); }
.switch input:checked ~ .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible ~ .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Input adornment group */
.input-group { display: flex; align-items: stretch; }
.input-group .form-input { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group .input-addon {
    display: inline-flex; align-items: center; padding: 0 14px;
    background: var(--bg-2); border: 1px solid var(--border); border-left: none;
    border-radius: 0 var(--r-md) var(--r-md) 0;
    color: var(--text-3); font-size: .875rem; white-space: nowrap;
}

/* ════════════════════════════════════════════════════════════
   5 · CARDS
   ════════════════════════════════════════════════════════════ */
.card-interactive { transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition); cursor: pointer; }
.card-interactive:hover { border-color: var(--border-2); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card-interactive:active { transform: translateY(0); }
.card-pad-lg { padding: 28px; }
.card-pad-sm { padding: 14px; }

/* ════════════════════════════════════════════════════════════
   6 · BADGES & CHIPS
   ════════════════════════════════════════════════════════════ */
.badge-sm { font-size: .65rem; padding: 2px 7px; }
.badge-info { background: var(--info-dim); color: var(--info); }
.badge-success { background: var(--success-dim); color: var(--success); }
.badge-warning { background: var(--warning-dim); color: var(--warning); }
.badge-danger { background: var(--danger-dim); color: var(--danger); }
.badge-neutral { background: rgba(255,255,255,.08); color: var(--text-2); }
[data-theme="light"] .badge-neutral { background: rgba(0,0,0,.06); }
/* Outline variant */
.badge-outline { background: transparent; border: 1px solid var(--border-2); color: var(--text-2); }
/* Soft pulsing live dot */
.badge .badge-dot.live { position: relative; }
.badge .badge-dot.live::after {
    content: ""; position: absolute; inset: -3px; border-radius: 50%;
    border: 1px solid currentColor; opacity: .6;
    animation: is-ping 1.8s var(--ease-out-quart) infinite;
}

/* ════════════════════════════════════════════════════════════
   7 · TABLES
   ════════════════════════════════════════════════════════════ */
.table-wrap { border-radius: var(--r-lg); }
.data-table.is-zebra tbody tr:nth-child(even) td { background: rgba(255,255,255,.018); }
[data-theme="light"] .data-table.is-zebra tbody tr:nth-child(even) td { background: rgba(0,0,0,.018); }
.data-table.sticky-head th {
    position: sticky; top: 0; z-index: 1;
    background: var(--surface);
    backdrop-filter: blur(6px);
}
.data-table td .cell-strong { color: var(--text); font-weight: 600; }
.data-table-empty { text-align: center; color: var(--text-3); padding: 40px 16px; font-size: .875rem; }

/* ════════════════════════════════════════════════════════════
   8 · ALERTS / BANNERS  (NEW — there was no generic .alert)
   ════════════════════════════════════════════════════════════ */
.alert {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 16px;
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: .875rem; line-height: 1.55;
    color: var(--text-2);
    position: relative;
}
.alert-icon { flex-shrink: 0; width: 20px; height: 20px; margin-top: 1px; display: grid; place-items: center; }
.alert-icon svg { width: 20px; height: 20px; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-size: .9rem; font-weight: 700; color: var(--text); margin-bottom: 2px; letter-spacing: -.01em; }
.alert-actions { display: flex; gap: 8px; margin-top: 10px; }
.alert-close {
    flex-shrink: 0; width: 24px; height: 24px; margin: -2px -4px 0 0;
    border: none; background: transparent; color: var(--text-3);
    border-radius: 6px; cursor: pointer; display: grid; place-items: center;
    transition: all var(--transition);
}
.alert-close:hover { background: rgba(255,255,255,.08); color: var(--text); }
[data-theme="light"] .alert-close:hover { background: rgba(0,0,0,.06); }

.alert-success { background: var(--success-dim); border-color: rgba(16,185,129,.25); color: #6ee7b7; }
.alert-success .alert-title, .alert-success .alert-icon { color: var(--success); }
.alert-danger  { background: var(--danger-dim);  border-color: rgba(255,59,59,.25); color: #fca5a5; }
.alert-danger .alert-title, .alert-danger .alert-icon { color: var(--danger); }
.alert-warning { background: var(--warning-dim); border-color: rgba(245,158,11,.28); color: #fcd34d; }
.alert-warning .alert-title, .alert-warning .alert-icon { color: var(--warning); }
.alert-info    { background: var(--info-dim);    border-color: rgba(99,102,241,.28); color: #a5b4fc; }
.alert-info .alert-title, .alert-info .alert-icon { color: var(--info); }
.alert-accent  { background: var(--accent-dim);  border-color: rgba(222,10,38,.28); color: #fca5b0; }
.alert-accent .alert-title, .alert-accent .alert-icon { color: var(--accent); }

/* In light mode, soft body text should read as a deeper shade of the hue */
[data-theme="light"] .alert-success { color: #047857; }
[data-theme="light"] .alert-danger  { color: #b91c1c; }
[data-theme="light"] .alert-warning { color: #b45309; }
[data-theme="light"] .alert-info    { color: #4338ca; }
[data-theme="light"] .alert-accent  { color: #b3071e; }

/* ════════════════════════════════════════════════════════════
   9 · TOASTS  (NEW — global feedback, driven by js/polish.js)
   ════════════════════════════════════════════════════════════ */
.toast-container {
    position: fixed; z-index: var(--z-toast);
    top: 16px; right: 16px;
    display: flex; flex-direction: column; gap: 10px;
    width: 360px; max-width: calc(100vw - 32px);
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex; align-items: flex-start; gap: 12px;
    padding: 13px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border-2);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xl);
    color: var(--text);
    position: relative; overflow: hidden;
    animation: toast-in var(--dur-4) var(--ease-out-expo) both;
}
.toast.toast--out { animation: toast-out var(--dur-3) var(--ease-out-quart) both; }
.toast-icon { flex-shrink: 0; width: 22px; height: 22px; display: grid; place-items: center; margin-top: 1px; }
.toast-icon svg { width: 20px; height: 20px; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: .875rem; font-weight: 700; letter-spacing: -.01em; }
.toast-msg { font-size: .8125rem; color: var(--text-2); line-height: 1.5; margin-top: 1px; word-wrap: break-word; }
.toast-close {
    flex-shrink: 0; width: 22px; height: 22px; margin: -1px -3px 0 0;
    border: none; background: transparent; color: var(--text-3);
    border-radius: 6px; cursor: pointer; display: grid; place-items: center;
    transition: all var(--transition);
}
.toast-close:hover { background: rgba(255,255,255,.1); color: var(--text); }
[data-theme="light"] .toast-close:hover { background: rgba(0,0,0,.06); }
/* Left accent rail + progress (allowed: full-height rail is structural, not a side-stripe alert hack) */
.toast::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.toast-progress { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--accent); transform-origin: left; opacity: .55; }
.toast.is-timing .toast-progress { animation: toast-progress linear forwards; animation-duration: var(--toast-dur, 4000ms); }
.toast-success { --_tc: var(--success); } .toast-success .toast-icon { color: var(--success); }
.toast-danger  { --_tc: var(--danger); }  .toast-danger .toast-icon  { color: var(--danger); }
.toast-warning { --_tc: var(--warning); } .toast-warning .toast-icon { color: var(--warning); }
.toast-info    { --_tc: var(--info); }    .toast-info .toast-icon    { color: var(--info); }
.toast-success::before, .toast-success .toast-progress { background: var(--success); }
.toast-danger::before,  .toast-danger .toast-progress  { background: var(--danger); }
.toast-warning::before, .toast-warning .toast-progress { background: var(--warning); }
.toast-info::before,    .toast-info .toast-progress    { background: var(--info); }

@media (max-width: 600px) {
    .toast-container { top: auto; bottom: 12px; left: 12px; right: 12px; width: auto; }
    .toast { animation-name: toast-in-up; }
}

/* ════════════════════════════════════════════════════════════
   10 · MODALS — entrance/exit motion, body/footer, sizes
   ════════════════════════════════════════════════════════════ */
.modal-backdrop { animation: backdrop-in var(--dur-3) var(--ease-out-quart) both; }
.modal { animation: modal-in var(--dur-4) var(--ease-out-expo) both; }
.modal-body { font-size: .9rem; color: var(--text-2); line-height: 1.6; }
.modal-footer {
    display: flex; align-items: center; justify-content: flex-end; gap: 10px;
    margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border);
}
.modal-footer.spread { justify-content: space-between; }
.modal--sm { max-width: 380px; }
.modal--lg { max-width: 640px; }
.modal--xl { max-width: 840px; }
/* Bottom-sheet entrance on mobile (matches existing breakpoint behaviour) */
@media (max-width: 600px) { .modal { animation-name: sheet-in; } }

/* ════════════════════════════════════════════════════════════
   11 · DROPDOWN / MENU  (generic, escapes clipping via fixed/portal)
   ════════════════════════════════════════════════════════════ */
.menu {
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r-lg);
    padding: 6px;
    box-shadow: var(--shadow-xl);
    animation: menu-in var(--dur-2) var(--ease-out-quart) both;
}
.menu-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); padding: 8px 10px 4px; }
.menu-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 9px 11px;
    border: none; background: transparent; text-align: left;
    border-radius: var(--r-sm); color: var(--text-2); font-size: .875rem;
    cursor: pointer; transition: all var(--transition);
}
.menu-item svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-3); }
.menu-item:hover { background: rgba(255,255,255,.05); color: var(--text); }
.menu-item:hover svg { color: var(--text-2); }
[data-theme="light"] .menu-item:hover { background: rgba(0,0,0,.04); }
.menu-item.is-active { background: var(--accent-dim); color: var(--accent); }
.menu-item.is-active svg { color: var(--accent); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-dim); }
.menu-divider { height: 1px; background: var(--border); margin: 5px 0; }

/* ════════════════════════════════════════════════════════════
   12 · TOOLTIP  (CSS-only, data-tooltip attribute)
   ════════════════════════════════════════════════════════════ */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute; bottom: calc(100% + 8px); left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: var(--surface-3); color: var(--text);
    border: 1px solid var(--border-2);
    padding: 6px 10px; border-radius: 8px;
    font-size: .75rem; font-weight: 500; white-space: nowrap;
    box-shadow: var(--shadow-md);
    opacity: 0; pointer-events: none;
    transition: opacity var(--transition), transform var(--transition);
    z-index: var(--z-tooltip);
}
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }
[data-tooltip-pos="bottom"]::after { bottom: auto; top: calc(100% + 8px); }

/* ════════════════════════════════════════════════════════════
   13 · TABS + SEGMENTED CONTROL  (generic)
   ════════════════════════════════════════════════════════════ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 11px 14px; margin-bottom: -1px;
    border: none; background: transparent; cursor: pointer; white-space: nowrap;
    font-size: .875rem; font-weight: 600; color: var(--text-3);
    border-bottom: 2px solid transparent;
    transition: color var(--transition), border-color var(--transition);
}
.tab:hover { color: var(--text-2); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.tab svg { width: 16px; height: 16px; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--r-md); }
.segmented-opt {
    padding: 6px 14px; border: none; background: transparent; cursor: pointer;
    font-size: .8125rem; font-weight: 600; color: var(--text-2);
    border-radius: calc(var(--r-md) - 4px); transition: all var(--transition);
}
.segmented-opt:hover { color: var(--text); }
.segmented-opt.is-active { background: var(--surface-2); color: var(--text); box-shadow: var(--shadow-sm); }
[data-theme="light"] .segmented-opt.is-active { background: #fff; }

/* ════════════════════════════════════════════════════════════
   14 · SKELETON · SPINNER · PROGRESS
   ════════════════════════════════════════════════════════════ */
.skeleton {
    position: relative; overflow: hidden;
    background: rgba(255,255,255,.05);
    border-radius: var(--r-sm);
}
[data-theme="light"] .skeleton { background: rgba(0,0,0,.05); }
.skeleton::after {
    content: ""; position: absolute; inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent);
    animation: skeleton-shimmer 1.5s infinite;
}
[data-theme="light"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(0,0,0,.05), transparent); }
.skeleton-text { height: .72em; margin: .35em 0; border-radius: 4px; }
.skeleton-text.w-60 { width: 60%; } .skeleton-text.w-40 { width: 40%; } .skeleton-text.w-80 { width: 80%; }
.skeleton-circle { border-radius: 50%; }

/* :not(svg) so we never draw a ring around an existing inline-SVG spinner
   (e.g. checkout.php uses <svg class="spinner">) */
.spinner:not(svg) {
    display: inline-block; width: 20px; height: 20px;
    border: 2px solid var(--border-2); border-top-color: var(--accent);
    border-radius: 50%; animation: is-spin .6s linear infinite;
}
.spinner-sm:not(svg) { width: 14px; height: 14px; border-width: 2px; }
.spinner-lg:not(svg) { width: 32px; height: 32px; border-width: 3px; }

/* Linear progress (indeterminate option) */
.progress-bar.is-indeterminate { position: relative; }
.progress-bar.is-indeterminate .progress-fill { position: absolute; width: 40%; animation: progress-indeterminate 1.3s var(--ease-in-out) infinite; }

/* ════════════════════════════════════════════════════════════
   15 · EMPTY STATE
   ════════════════════════════════════════════════════════════ */
.empty-state { text-align: center; padding: 48px 24px; max-width: 420px; margin: 0 auto; }
.empty-state-icon {
    width: 64px; height: 64px; margin: 0 auto 18px;
    border-radius: var(--r-xl);
    background: var(--bg-3);
    display: grid; place-items: center;
    color: var(--text-3);
}
.empty-state-icon svg { width: 30px; height: 30px; }
.empty-state-title { font-size: 1.0625rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; margin-bottom: 6px; }
.empty-state-text { font-size: .875rem; color: var(--text-3); line-height: 1.6; margin-bottom: 18px; }

/* ════════════════════════════════════════════════════════════
   16 · AVATAR
   ════════════════════════════════════════════════════════════ */
.avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--surface-3); color: var(--text);
    display: inline-grid; place-items: center; overflow: hidden;
    font-size: .85rem; font-weight: 700; flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 30px; height: 30px; font-size: .72rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }
.avatar-group { display: inline-flex; }
.avatar-group .avatar { border: 2px solid var(--bg); margin-left: -10px; }
.avatar-group .avatar:first-child { margin-left: 0; }

/* ════════════════════════════════════════════════════════════
   17 · CHROME REFINEMENTS  (sidebar / topbar / nav)
   ════════════════════════════════════════════════════════════ */
/* Active nav item: a crisp accent rail that reads instantly */
.nav-item.active::before {
    content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 3px; height: 18px; background: var(--accent); border-radius: 0 3px 3px 0;
}
.nav-item { transition: background var(--transition), color var(--transition); }
.nav-icon svg { transition: stroke var(--transition); }

/* Topbar gets a touch more depth when content scrolls under it */
.topbar { transition: box-shadow var(--transition), background var(--transition); }
.topbar.is-scrolled { box-shadow: 0 6px 24px rgba(0,0,0,.28); }
[data-theme="light"] .topbar.is-scrolled { box-shadow: 0 6px 24px rgba(60,40,100,.10); }

/* Admin badge counts in the sidebar — consistent pill */
.admin-sidebar-badge {
    margin-left: auto; flex-shrink: 0;
    background: var(--accent); color: #fff;
    font-size: .65rem; font-weight: 800; line-height: 1;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: var(--r-pill); display: inline-flex; align-items: center; justify-content: center;
}

/* Mobile drawer: smoother overlay fade */
.sidebar-overlay { transition: opacity var(--transition); }

/* ════════════════════════════════════════════════════════════
   18 · MOTION UTILITIES + KEYFRAMES
   ════════════════════════════════════════════════════════════ */
.fade-in { animation: fadeIn var(--dur-4) var(--ease-out-quart) both; }
.stagger > * { animation: fadeIn var(--dur-4) var(--ease-out-quart) both; }
.stagger > *:nth-child(1){animation-delay:.02s}.stagger > *:nth-child(2){animation-delay:.06s}
.stagger > *:nth-child(3){animation-delay:.10s}.stagger > *:nth-child(4){animation-delay:.14s}
.stagger > *:nth-child(5){animation-delay:.18s}.stagger > *:nth-child(6){animation-delay:.22s}
.stagger > *:nth-child(7){animation-delay:.26s}.stagger > *:nth-child(8){animation-delay:.30s}

@keyframes is-spin { to { transform: rotate(360deg); } }
@keyframes is-ping { 75%, 100% { transform: scale(1.9); opacity: 0; } }
@keyframes skeleton-shimmer { 100% { transform: translateX(100%); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-in-up { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px) scale(.98); } }
@keyframes toast-progress { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes progress-indeterminate { 0% { left: -40%; } 100% { left: 100%; } }

/* ════════════════════════════════════════════════════════════
   19 · ACCESSIBILITY — reduced motion + touch targets + sr-only
   ════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
    .btn-primary:hover, .stat-card:hover, .release-card:hover,
    .card-interactive:hover, .collab-card:hover { transform: none; }
}

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Comfortable tap targets on touch devices */
@media (pointer: coarse) {
    .btn, .topbar-icon-btn, .nav-item, .menu-item, .tab, .filter-pill { min-height: 40px; }
    .toast-close, .alert-close, .modal-close { min-width: 36px; min-height: 36px; }
}
