﻿/* ???????????????????????????????????????????????????????????????????
   CSA Media Portal — Design System v2
   ??????????????????????????????????????????????????????????????????? */

/* ?? Design Tokens — Dark (default) ???????????????????????????????? */
:root,
:root[data-theme="dark"] {
    color-scheme: dark;
    /* Surfaces — deep, almost-black with a hint of cool navy */
    --surface-base:     #07090d;
    --surface-raised:   #0d1015;
    --surface-overlay:  #151a22;
    --surface-card:     #11151c;
    --surface-subtle:   #1a1f2a;
    --surface-muted:    #222836;
    --surface-border:   #2b3243;

    /* Elevated gradient accents (premium glow) */
    --gradient-brand:   linear-gradient(135deg, #00c260 0%, #00a651 55%, #007a3d 100%);
    --gradient-accent:  linear-gradient(135deg, #00ffa3 0%, #00c260 50%, #ffe033 120%);
    --gradient-surface: linear-gradient(180deg, rgba(255,255,255,0.025) 0%, rgba(255,255,255,0) 60%);
    --gradient-ambient: radial-gradient(1200px 600px at 85% -10%, rgba(0,194,96,0.08), transparent 60%),
                        radial-gradient(900px 500px at -10% 110%, rgba(59,130,246,0.05), transparent 60%);

    /* Brand */
    --brand-primary:     #00c260;
    --brand-primary-dim: #007a3d;
    --brand-primary-lit: #3ee48a;
    --brand-accent:      #ffe033;
    --brand-glow:        rgba(0, 194, 96, 0.14);
    --brand-glow-strong: rgba(0, 194, 96, 0.28);

    /* Text */
    --text-primary:   #f4f6fa;
    --text-secondary: #95a1b7;
    --text-muted:     #5a6476;
    --text-disabled:  #3a4354;
    --text-inverse:   #07090d;

    /* Border */
    --border-subtle:  rgba(255,255,255,0.06);
    --border-default: rgba(255,255,255,0.1);
    --border-strong:  rgba(255,255,255,0.18);
    --border-brand:   rgba(0, 194, 96, 0.4);

    /* Status */
    --status-success: #00a651;
    --status-warning: #f59e0b;
    --status-danger:  #ef4444;
    --status-info:    #3b82f6;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.35);
    --shadow-sm: 0 2px 6px rgba(0,0,0,0.45), 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 6px 20px rgba(0,0,0,0.55), 0 2px 6px rgba(0,0,0,0.35);
    --shadow-lg: 0 20px 48px rgba(0,0,0,0.65), 0 6px 16px rgba(0,0,0,0.4);
    --shadow-brand: 0 0 24px rgba(0, 166, 81, 0.3);
    --shadow-inset: inset 0 1px 0 rgba(255,255,255,0.04);

    /* Spacing scale */
    --space-1:  4px;
    --space-2:  8px;
    --space-3:  12px;
    --space-4:  16px;
    --space-5:  20px;
    --space-6:  24px;
    --space-7:  28px;
    --space-8:  32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* Radius */
    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   14px;
    --radius-xl:   20px;
    --radius-2xl:  28px;
    --radius-full: 9999px;

    /* Typography */
    --font-sans:    'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono:    'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
    --font-display: 'Space Grotesk', 'Inter', var(--font-sans);

    /* Layout */
    --sidebar-width:     248px;
    --sidebar-collapsed:  60px;
    --topbar-height:      58px;
    --content-max-width: 1440px;

    /* Transitions */
    --transition-fast: 110ms ease;
    --transition-base: 190ms ease;
    --transition-slow: 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ?? Design Tokens — Light ??????????????????????????????????????? */
:root[data-theme="light"] {
    color-scheme: light;
    /* Surfaces — crisp paper-white with soft cool greys */
    --surface-base:     #f5f7fb;
    --surface-raised:   #ffffff;
    --surface-overlay:  #f0f3f8;
    --surface-card:     #ffffff;
    --surface-subtle:   #eef2f7;
    --surface-muted:    #e3e8f0;
    --surface-border:   #d5dbe5;

    --gradient-brand:   linear-gradient(135deg, #00c260 0%, #00a651 55%, #007a3d 100%);
    --gradient-accent:  linear-gradient(135deg, #00ffa3 0%, #00c260 50%, #ffd000 120%);
    --gradient-surface: linear-gradient(180deg, rgba(0,0,0,0.012) 0%, rgba(0,0,0,0) 60%);
    --gradient-ambient: radial-gradient(1200px 600px at 85% -10%, rgba(0,166,81,0.08), transparent 60%),
                        radial-gradient(900px 500px at -10% 110%, rgba(59,130,246,0.05), transparent 60%);

    --brand-primary:     #009147;
    --brand-primary-dim: #006d36;
    --brand-primary-lit: #00a651;
    --brand-accent:      #f5b800;
    --brand-glow:        rgba(0, 145, 71, 0.1);
    --brand-glow-strong: rgba(0, 145, 71, 0.22);

    --text-primary:   #0c1220;
    --text-secondary: #4a5468;
    --text-muted:     #6b7689;
    --text-disabled:  #a6aebd;
    --text-inverse:   #ffffff;

    --border-subtle:  rgba(12,18,32,0.06);
    --border-default: rgba(12,18,32,0.1);
    --border-strong:  rgba(12,18,32,0.18);
    --border-brand:   rgba(0, 145, 71, 0.35);

    --shadow-xs: 0 1px 2px rgba(16,24,40,0.06);
    --shadow-sm: 0 2px 6px rgba(16,24,40,0.08), 0 1px 2px rgba(16,24,40,0.05);
    --shadow-md: 0 10px 30px rgba(16,24,40,0.1), 0 4px 10px rgba(16,24,40,0.06);
    --shadow-lg: 0 24px 60px rgba(16,24,40,0.16), 0 8px 20px rgba(16,24,40,0.08);
    --shadow-brand: 0 0 28px rgba(0,166,81,0.22);
    --shadow-inset: inset 0 1px 0 rgba(255,255,255,0.6);
}

/* ?? Reset ???????????????????????????????????????????????????????? */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--font-sans);
    background: var(--surface-base);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background var(--transition-base), color var(--transition-base);
}

/* Display typography helper */
.display-font { font-family: var(--font-display); letter-spacing: -0.03em; }

a { color: var(--brand-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--brand-primary-lit); }

img, svg { display: block; }

button { font-family: inherit; }

/* ?? App Shell ???????????????????????????????????????????????????? */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: var(--surface-base);
    background-image: var(--gradient-ambient);
    position: relative;
}

/* ???????????????????????????????????????????????????????????????????
   SIDEBAR
   ??????????????????????????????????????????????????????????????????? */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: linear-gradient(180deg, var(--surface-raised) 0%, var(--surface-base) 100%);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width var(--transition-slow), background var(--transition-base);
    z-index: 100;
    position: relative;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--gradient-brand);
    box-shadow: 0 0 12px rgba(0,194,96,0.4);
    z-index: 1;
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--surface-muted); border-radius: var(--radius-full); }

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: 0 var(--space-5);
    height: var(--topbar-height);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.sidebar-brand-logo {
    height: 44px;
    width: auto;
    flex-shrink: 0;
    display: block;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

.sidebar-brand-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.sidebar-brand-sub {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    white-space: nowrap;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    padding: var(--space-3) var(--space-3) var(--space-4);
    display: flex;
    flex-direction: column;
}

.sidebar-section-label {
    font-size: 9.5px;
    font-weight: 700;
    color: var(--text-disabled);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: var(--space-5) var(--space-3) var(--space-2);
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 9px var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
    position: relative;
    text-decoration: none;
    letter-spacing: 0.01em;
}

.sidebar-nav-item + .sidebar-nav-item { margin-top: 1px; }

.sidebar-nav-item:hover {
    background: var(--surface-overlay);
    color: var(--text-primary);
}

.sidebar-nav-item.active {
    background: var(--brand-glow);
    color: var(--brand-primary);
    font-weight: 600;
}

.sidebar-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 25%;
    height: 50%;
    width: 2.5px;
    background: var(--brand-primary);
    border-radius: 0 var(--radius-full) var(--radius-full) 0;
    box-shadow: 0 0 6px var(--brand-primary);
}

.sidebar-nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.65;
    transition: opacity var(--transition-fast);
}

.sidebar-nav-item.active .sidebar-nav-icon,
.sidebar-nav-item:hover .sidebar-nav-icon { opacity: 1; }

.sidebar-nav-badge {
    margin-left: auto;
    background: var(--brand-primary);
    color: #fff;
    font-size: 9.5px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    line-height: 1.7;
    letter-spacing: 0.03em;
}

/* Sidebar Footer / User */
.sidebar-footer {
    padding: var(--space-3);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.sidebar-user:hover { background: var(--surface-overlay); }

.sidebar-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--brand-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--brand-primary);
    flex-shrink: 0;
    border: 1px solid var(--border-brand);
}

.sidebar-user-info { flex: 1; min-width: 0; }

.sidebar-user-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.sidebar-user-role {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.sidebar-attribution {
    margin-top: var(--space-3);
    padding: 0 var(--space-3);
    font-size: 9.5px;
    color: var(--text-disabled);
    text-align: center;
    letter-spacing: 0.01em;
    line-height: 1.5;
    opacity: 0.7;
}

.sidebar-attribution-link {
    color: var(--text-disabled);
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 1px;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.sidebar-attribution-link:hover {
    color: var(--text-muted);
    border-bottom-color: rgba(255, 255, 255, 0.14);
}

/* ???????????????????????????????????????????????????????????????????
   MAIN AREA
   ??????????????????????????????????????????????????????????????????? */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: var(--surface-base);
}

/* Top Bar — premium glass */
.topbar {
    height: var(--topbar-height);
    background: color-mix(in srgb, var(--surface-raised) 78%, transparent);
    -webkit-backdrop-filter: saturate(140%) blur(14px);
    backdrop-filter: saturate(140%) blur(14px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 var(--space-7);
    gap: var(--space-5);
    flex-shrink: 0;
    z-index: 50;
    transition: box-shadow var(--transition-base), background var(--transition-base);
}

.topbar.scrolled {
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.topbar-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.02em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.topbar-search {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--surface-overlay);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 7px var(--space-4);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
    min-width: 200px;
}

.topbar-search:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-glow);
    background: var(--surface-subtle);
}

.topbar-search input {
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 12.5px;
    outline: none;
    width: 100%;
    font-family: inherit;
}

.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-search-icon { color: var(--text-muted); width: 13px; height: 13px; flex-shrink: 0; }

/* kbd shortcut hint */
.topbar-search-kbd {
    font-size: 10px;
    color: var(--text-disabled);
    background: var(--surface-muted);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 1px 5px;
    font-family: var(--font-mono);
    white-space: nowrap;
    flex-shrink: 0;
}

.icon-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--surface-overlay);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

.icon-btn svg { width: 15px; height: 15px; }

/* Topbar divider */
.topbar-divider {
    width: 1px;
    height: 20px;
    background: var(--border-subtle);
    flex-shrink: 0;
}

/* ???????????????????????????????????????????????????????????????????
   PAGE CONTENT
   ??????????????????????????????????????????????????????????????????? */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-8) var(--space-8);
    width: 100%;
}

.page-content::-webkit-scrollbar { width: 5px; }
.page-content::-webkit-scrollbar-track { background: transparent; }
.page-content::-webkit-scrollbar-thumb { background: var(--surface-muted); border-radius: var(--radius-full); }

/* Page Header */
.page-header { margin-bottom: var(--space-8); }

.page-header-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--brand-primary);
    margin-bottom: var(--space-2);
}

/* Small dot before eyebrow */
.page-header-eyebrow::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--brand-primary);
    flex-shrink: 0;
}

.page-header-title {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: -0.035em;
    background: linear-gradient(180deg, var(--text-primary) 30%, color-mix(in srgb, var(--text-primary) 70%, transparent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

.page-header-subtitle {
    margin-top: var(--space-2);
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.page-header-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-5);
    flex-wrap: wrap;
}

/* ???????????????????????????????????????????????????????????????????
   CARDS
   ??????????????????????????????????????????????????????????????????? */
.card {
    background: var(--surface-raised);
    background-image: var(--gradient-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm), var(--shadow-inset);
    transition: border-color var(--transition-base), transform var(--transition-slow), box-shadow var(--transition-slow);
    position: relative;
}

.card:hover { border-color: var(--border-default); box-shadow: var(--shadow-md), var(--shadow-inset); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
    gap: var(--space-4);
}

.card-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
    line-height: 1.5;
}

/* ?? Stat Cards ??????????????????????????????????????????????????? */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}

.stat-card {
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-5) var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    box-shadow: var(--shadow-xs), var(--shadow-inset);
    transition: border-color var(--transition-base), transform var(--transition-slow), box-shadow var(--transition-slow);
    position: relative;
    overflow: hidden;
}

/* Subtle gradient gloss on stat card */
.stat-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.015) 0%, transparent 60%);
    pointer-events: none;
    border-radius: inherit;
}

.stat-card:hover {
    border-color: var(--border-default);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.stat-card-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1.3;
}

.stat-card-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card-icon svg { width: 16px; height: 16px; }

.stat-card-value {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -0.045em;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

.stat-card-delta {
    font-size: 11.5px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    line-height: 1.4;
}

.stat-card-delta.up   { color: #4ade80; }
.stat-card-delta.down { color: #f87171; }

/* Icon bg variants */
.icon-bg-green  { background: rgba(0, 166, 81, 0.12);  color: #34d399; }
.icon-bg-blue   { background: rgba(59, 130, 246, 0.12); color: #60a5fa; }
.icon-bg-amber  { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.icon-bg-purple { background: rgba(139, 92, 246, 0.12); color: #a78bfa; }
.icon-bg-rose   { background: rgba(239, 68, 68, 0.12);  color: #f87171; }
.icon-bg-teal   { background: rgba(20, 184, 166, 0.12); color: #2dd4bf; }

/* ?? Content Grid ????????????????????????????????????????????????? */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: var(--space-6);
    margin-bottom: var(--space-8);
    align-items: start;
}

/* ?? Media Grid ??????????????????????????????????????????????????? */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-4);
}

/* ???????????????????????????????????????????????????????????????????
   BUTTONS
   ??????????????????????????????????????????????????????????????????? */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 8px var(--space-5);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast),
                box-shadow var(--transition-fast), transform var(--transition-fast), color var(--transition-fast);
    border: 1px solid transparent;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.5;
    letter-spacing: 0.01em;
    font-family: inherit;
}

.btn:active { transform: scale(0.97); }
.btn:disabled, .btn[disabled] { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-primary {
    background: var(--gradient-brand);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(0,166,81,0.32), inset 0 1px 0 rgba(255,255,255,0.15);
    position: relative;
    overflow: hidden;
}
.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.18) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 600ms ease;
    pointer-events: none;
}
.btn-primary:hover {
    filter: brightness(1.08);
    box-shadow: 0 0 0 3px var(--brand-glow), 0 6px 18px rgba(0,166,81,0.45), inset 0 1px 0 rgba(255,255,255,0.2);
    color: #fff;
    transform: translateY(-1px);
}
.btn-primary:hover::after { transform: translateX(100%); }

.btn-secondary {
    background: var(--surface-overlay);
    color: var(--text-primary);
    border-color: var(--border-default);
}
.btn-secondary:hover {
    background: var(--surface-subtle);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--surface-overlay);
    color: var(--text-primary);
}

.btn-danger {
    background: rgba(239,68,68,0.1);
    color: #f87171;
    border-color: rgba(239,68,68,0.2);
}
.btn-danger:hover {
    background: rgba(239,68,68,0.2);
    border-color: rgba(239,68,68,0.4);
    color: #fca5a5;
}

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 10px var(--space-6); font-size: 14px; }

/* ???????????????????????????????????????????????????????????????????
   BADGES
   ??????????????????????????????????????????????????????????????????? */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.6;
}

.badge-green  { background: rgba(0,166,81,0.14);   color: #4ade80; border: 1px solid rgba(0,166,81,0.2); }
.badge-blue   { background: rgba(59,130,246,0.14);  color: #60a5fa; border: 1px solid rgba(59,130,246,0.2); }
.badge-amber  { background: rgba(245,158,11,0.14);  color: #fbbf24; border: 1px solid rgba(245,158,11,0.2); }
.badge-red    { background: rgba(239,68,68,0.14);   color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.badge-purple { background: rgba(139,92,246,0.14);  color: #a78bfa; border: 1px solid rgba(139,92,246,0.2); }
.badge-muted  { background: var(--surface-subtle);  color: var(--text-muted); border: 1px solid var(--border-subtle); }

/* ???????????????????????????????????????????????????????????????????
   MEDIA CARD
   ??????????????????????????????????????????????????????????????????? */
.media-card {
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--transition-base), transform var(--transition-slow), box-shadow var(--transition-slow);
    cursor: pointer;
}

.media-card:hover {
    border-color: var(--border-brand);
    transform: translateY(-4px);
    box-shadow: var(--shadow-md), 0 0 0 1px var(--border-brand);
}
.media-card:hover .media-card-thumb img,
.media-card:hover .video-thumb-canvas { transform: scale(1.04); }
.media-card-thumb img,
.media-card .video-thumb-canvas { transition: transform 500ms cubic-bezier(0.4, 0, 0.2, 1); }

.media-card-thumb {
    aspect-ratio: 16/9;
    background: var(--surface-subtle);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-card-thumb-icon { color: var(--text-muted); opacity: 0.3; }
.media-card-thumb-icon svg { width: 36px; height: 36px; }

.video-thumb-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: var(--surface-subtle);
}

.media-card-type-badge {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
}

.media-card-body { padding: var(--space-4); }

.media-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.media-card-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* ???????????????????????????????????????????????????????????????????
   UPLOAD ZONE
   ??????????????????????????????????????????????????????????????????? */
.upload-zone {
    border: 1.5px dashed var(--border-default);
    border-radius: var(--radius-xl);
    padding: var(--space-16) var(--space-8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition-base), background var(--transition-base), box-shadow var(--transition-base);
    background: var(--surface-raised);
    position: relative;
    overflow: hidden;
}

/* Subtle radial highlight at centre */
.upload-zone::before {
    content: '';
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%,-50%);
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(0,166,81,0.04) 0%, transparent 70%);
    pointer-events: none;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--brand-primary);
    background: var(--brand-glow);
    box-shadow: 0 0 0 4px var(--brand-glow), 0 12px 40px rgba(0,166,81,0.18);
    transform: translateY(-1px);
}

.upload-zone-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-xl);
    background: var(--surface-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-2);
    border: 1px solid var(--border-default);
    transition: border-color var(--transition-base), background var(--transition-base);
}

.upload-zone:hover .upload-zone-icon,
.upload-zone.drag-over .upload-zone-icon {
    background: var(--brand-glow-strong);
    border-color: var(--border-brand);
}

.upload-zone-icon svg { width: 26px; height: 26px; color: var(--brand-primary); }

.upload-zone-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.upload-zone-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 340px;
    line-height: 1.6;
}

.upload-zone-hint {
    font-size: 11.5px;
    color: var(--text-muted);
    background: var(--surface-subtle);
    padding: 4px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
}

/* ???????????????????????????????????????????????????????????????????
   FILTER BAR
   ??????????????????????????????????????????????????????????????????? */
.filter-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-5);
}

.filter-search {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--surface-overlay);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 8px var(--space-4);
    flex: 1;
    min-width: 200px;
    max-width: 340px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.filter-search:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-glow);
}

.filter-search input {
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 12.5px;
    outline: none;
    width: 100%;
    font-family: inherit;
}

.filter-search input::placeholder { color: var(--text-muted); }
.filter-search svg { width: 13px; height: 13px; color: var(--text-muted); flex-shrink: 0; }

.filter-chip-group { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.filter-chip {
    padding: 5px 13px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    font-family: inherit;
    letter-spacing: 0.01em;
}

.filter-chip:hover { border-color: var(--border-default); color: var(--text-primary); background: var(--surface-overlay); }
.filter-chip.active { background: var(--brand-glow); border-color: var(--border-brand); color: var(--brand-primary); font-weight: 600; }

/* ???????????????????????????????????????????????????????????????????
   TABLE
   ??????????????????????????????????????????????????????????????????? */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.data-table td {
    padding: 13px var(--space-4);
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover { background: var(--surface-overlay); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ???????????????????????????????????????????????????????????????????
   FORM CONTROLS
   ??????????????????????????????????????????????????????????????????? */
.form-group { display: flex; flex-direction: column; gap: var(--space-2); }

.form-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.form-control {
    background: var(--surface-overlay);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 9px var(--space-4);
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
    width: 100%;
    font-family: inherit;
}

.form-control::placeholder { color: var(--text-muted); }

.form-control:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-glow);
    background: var(--surface-subtle);
}

.form-control:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: var(--surface-raised);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234e5868' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

/* ???????????????????????????????????????????????????????????????????
   EMPTY STATE
   ??????????????????????????????????????????????????????????????????? */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-16) var(--space-8);
    text-align: center;
    gap: var(--space-3);
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-xl);
    background: var(--surface-subtle);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-3);
    box-shadow: var(--shadow-inset);
}

.empty-state-icon svg { width: 28px; height: 28px; color: var(--text-disabled); }

.empty-state-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.empty-state-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 300px;
    line-height: 1.65;
}

/* ???????????????????????????????????????????????????????????????????
   SETTINGS CARDS
   ??????????????????????????????????????????????????????????????????? */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-5);
}

.settings-card-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.settings-card-icon svg { width: 15px; height: 15px; }

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border-subtle);
}

.settings-row:last-child { border-bottom: none; padding-bottom: 0; }

.settings-row-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.settings-row-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    font-feature-settings: "tnum";
}

/* ???????????????????????????????????????????????????????????????????
   ACTIVITY LIST
   ??????????????????????????????????????????????????????????????????? */
.activity-list { display: flex; flex-direction: column; }

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--border-subtle);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
    width: 7px;
    height: 7px;
    border-radius: var(--radius-full);
    background: var(--brand-primary);
    margin-top: 7px;
    flex-shrink: 0;
}

.activity-dot.share  { background: #3b82f6; }
.activity-dot.approve { background: #f59e0b; }
.activity-dot.delete  { background: #ef4444; }

.activity-body { flex: 1; }
.activity-text { font-size: 13px; color: var(--text-secondary); line-height: 1.55; }
.activity-text strong { color: var(--text-primary); font-weight: 600; }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ???????????????????????????????????????????????????????????????????
   MISC COMPONENTS
   ??????????????????????????????????????????????????????????????????? */

/* Divider */
.divider { height: 1px; background: var(--border-subtle); margin: var(--space-5) 0; }

/* Alerts */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-size: 13px;
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    line-height: 1.55;
}

.alert svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.alert-info    { background: rgba(59,130,246,0.08);  border-color: rgba(59,130,246,0.2);  color: #93c5fd; }
.alert-success { background: rgba(0,166,81,0.08);    border-color: rgba(0,166,81,0.2);    color: #4ade80; }
.alert-warning { background: rgba(245,158,11,0.08);  border-color: rgba(245,158,11,0.2);  color: #fcd34d; }
.alert-danger  { background: rgba(239,68,68,0.08);   border-color: rgba(239,68,68,0.2);   color: #fca5a5; }

/* User cell */
.user-cell { display: flex; align-items: center; gap: var(--space-3); }

.user-row-avatar {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-full);
    background: var(--brand-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--brand-primary);
    border: 1px solid var(--border-brand);
    flex-shrink: 0;
}

.user-name { font-weight: 600; color: var(--text-primary); font-size: 13px; line-height: 1.3; }
.user-email { font-size: 11px; color: var(--text-muted); }

/* System status strip */
.system-strip {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    padding: var(--space-3) var(--space-5);
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-8);
    box-shadow: var(--shadow-xs);
}

.system-strip-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 12px;
    color: var(--text-muted);
}

.system-strip-item:not(:last-child)::after {
    content: '';
    display: block;
    width: 1px;
    height: 14px;
    background: var(--border-subtle);
    margin-left: var(--space-5);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.status-dot-green  { background: #00a651; box-shadow: 0 0 6px rgba(0,166,81,0.5); }
.status-dot-amber  { background: #f59e0b; }
.status-dot-red    { background: #ef4444; }

/* Quick action list */
.action-list { display: flex; flex-direction: column; gap: var(--space-2); }

.action-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--surface-overlay);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    text-decoration: none;
}

.action-item:hover {
    background: var(--surface-subtle);
    border-color: var(--border-default);
    color: var(--text-primary);
}

.action-item-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.action-item-icon svg { width: 13px; height: 13px; }

.action-item-text { flex: 1; }
.action-item-arrow { color: var(--text-disabled); }
.action-item-arrow svg { width: 12px; height: 12px; }

/* Scrollbar global */
* { scrollbar-width: thin; scrollbar-color: var(--surface-muted) transparent; }

/* ???????????????????????????????????????????????????????????????????
   RESPONSIVE
   ??????????????????????????????????????????????????????????????????? */
@media (max-width: 1100px) {
    .content-grid { grid-template-columns: 1fr; }
    .asset-detail-layout { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
    /* Stack the tournament tree above the asset list on smaller screens */
    .structured-layout { grid-template-columns: 1fr !important; }
    .structured-layout > .card { position: static !important; max-height: none !important; }
}

@media (max-width: 768px) {
    .sidebar { width: var(--sidebar-collapsed); }
    .sidebar-brand-text,
    .sidebar-nav-item span,
    .sidebar-section-label,
    .sidebar-user-info,
    .sidebar-nav-badge,
    .sidebar-attribution { display: none; }
    .sidebar-brand { justify-content: center; padding: 0; }
    .sidebar-brand-logo { height: 30px; }
    .sidebar-nav-item { justify-content: center; padding: var(--space-3); }
    .sidebar-user { justify-content: center; }
    .page-content { padding: var(--space-4); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .settings-grid { grid-template-columns: 1fr; }
    .system-strip { display: none; }

    /* Vertical stacking for media grid on mobile — NO horizontal carousel */
    .media-grid {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }

    /* Page header stacks vertically */
    .page-header-row {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
    }
    .page-header-row .btn { align-self: flex-start; }

    /* Filter bar wraps and search fills width */
    .filter-bar {
        gap: var(--space-2);
    }
    .filter-search {
        min-width: 0;
        max-width: none;
        flex: 1 1 100%;
    }
    .filter-chip-group {
        flex: 1 1 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }
    .filter-chip-group::-webkit-scrollbar { display: none; }
    .filter-chip { flex-shrink: 0; }

    /* Topbar compresses */
    .topbar { padding: 0 var(--space-4); gap: var(--space-3); }
    .topbar-title { font-size: 13px; }
    .topbar-search { display: none; }
    .topbar-divider { display: none; }

    /* Content grid stacks */
    .content-grid { grid-template-columns: 1fr !important; }

    /* Asset detail layout stacks */
    .asset-detail-layout { grid-template-columns: 1fr; }
    .asset-action-row { flex-direction: column; }
    .asset-action-row .btn { width: 100%; justify-content: center; }

    /* Share panel and share URL row */
    .share-url-row { flex-direction: column; }

    /* Bulk action bar stacks on mobile */
    .bulk-action-bar {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
        padding: var(--space-3);
    }
    .bulk-action-bar > div {
        flex-wrap: wrap;
    }
    .bulk-action-bar .btn-sm {
        flex: 1 1 auto;
        justify-content: center;
        min-width: 0;
    }

    /* Pagination stacks on mobile */
    .pagination-bar {
        flex-direction: column;
        align-items: center;
        gap: var(--space-3);
    }
    .pagination-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Data tables scroll horizontally */
    .data-table { min-width: 600px; }

    /* Upload success panel stacks */
    .upload-success-panel {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
        padding: var(--space-4);
    }
    .upload-success-actions {
        flex-direction: column;
    }
    .upload-success-actions .btn { width: 100%; justify-content: center; }
    .upload-success-meta { flex-wrap: wrap; }

    /* Upload zone compresses */
    .upload-zone {
        padding: var(--space-8) var(--space-4);
    }
    .upload-zone-hint { font-size: 10px; text-align: center; }

    /* Empty state compresses */
    .empty-state { padding: var(--space-8) var(--space-4); }

    /* Meta list rows stack on very narrow screens */
    .meta-row {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-1);
    }
    .meta-value { text-align: left; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-header-title { font-size: 18px; }
    .page-content { padding: var(--space-3); }
    .page-header { margin-bottom: var(--space-5); }

    /* Cards reduce padding */
    .card { padding: var(--space-4); }
    .card-header { margin-bottom: var(--space-4); }

    /* Media card body tightens */
    .media-card-body { padding: var(--space-3); }
    .media-card-title { font-size: 12px; }
    .media-card-meta { font-size: 10px; }

    /* Badges shrink */
    .badge { font-size: 9.5px; padding: 1px 6px; }

    /* Form controls slightly smaller */
    .form-control { font-size: 13px; padding: 8px var(--space-3); }
    .form-label { font-size: 11px; }

    /* Stat card value shrinks */
    .stat-card-value { font-size: 22px; }
    .stat-card { padding: var(--space-4); }
}

/* ???????????????????????????????????????????????????????????????????
   UPLOAD SUCCESS PANEL
   ??????????????????????????????????????????????????????????????????? */
.upload-success-panel {
    display: flex;
    align-items: flex-start;
    gap: var(--space-5);
    padding: var(--space-6);
    background: rgba(0, 166, 81, 0.07);
    border: 1px solid rgba(0, 166, 81, 0.25);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-8);
    box-shadow: var(--shadow-xs);
}

.upload-success-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: rgba(0, 166, 81, 0.15);
    border: 1px solid rgba(0, 166, 81, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.upload-success-icon svg {
    width: 22px;
    height: 22px;
    color: var(--brand-primary);
}

.upload-success-body {
    flex: 1;
    min-width: 0;
}

.upload-success-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--brand-primary);
    margin-bottom: var(--space-1);
}

.upload-success-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
}

.upload-success-meta {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 12px;
    color: var(--text-muted);
}

.upload-success-actions {
    display: flex;
    gap: var(--space-2);
    flex-shrink: 0;
    align-items: flex-start;
}

/* ???????????????????????????????????????????????????????????????????
   UPLOAD PROGRESS BAR
   ??????????????????????????????????????????????????????????????????? */
.upload-progress-track {
    height: 4px;
    background: var(--surface-subtle);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.upload-progress-bar {
    height: 100%;
    background: var(--brand-primary);
    border-radius: var(--radius-full);
    transition: width 0.25s ease;
    box-shadow: 0 0 8px rgba(0, 166, 81, 0.5);
}

/* ???????????????????????????????????????????????????????????????????
   ASSET DETAIL PAGE
   ??????????????????????????????????????????????????????????????????? */
.asset-detail-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: var(--space-6);
    align-items: start;
}

@media (max-width: 1100px) {
    .asset-detail-layout { grid-template-columns: 1fr; }
}

.asset-detail-left { display: flex; flex-direction: column; gap: var(--space-5); }
.asset-detail-right { display: flex; flex-direction: column; gap: 0; }

/* Preview panel */
.asset-preview-panel {
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    touch-action: pan-y pinch-zoom;
}

.asset-preview-image {
    width: 100%;
    max-height: 600px;
    object-fit: contain;
    display: block;
    background: var(--surface-base);
}

.asset-preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    min-height: 320px;
    background: var(--surface-subtle);
    color: var(--text-muted);
    font-size: 13px;
}

.asset-preview-placeholder svg {
    width: 56px;
    height: 56px;
    color: var(--text-disabled);
    opacity: 0.5;
}

.asset-preview-video {
    background: linear-gradient(135deg, var(--surface-subtle) 0%, var(--surface-muted) 100%);
    min-height: 360px;
    position: relative;
}

.asset-preview-video-icon {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-3);
}

.asset-preview-video-icon svg {
    width: 36px;
    height: 36px;
    color: #a78bfa;
    opacity: 1;
}

.asset-preview-footer {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-overlay);
}

/* Action row */
.asset-action-row {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
}

/* Metadata definition list */
.meta-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.meta-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border-subtle);
}

.meta-row:last-child { border-bottom: none; }

.meta-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    white-space: nowrap;
    flex-shrink: 0;
}

.meta-value {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: right;
    word-break: break-all;
    min-width: 0;
}

.meta-mono {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-secondary);
}

/* ???????????????????????????????????????????????????????????????????
   PHASE 4 — SHARE LINK PANEL
   ??????????????????????????????????????????????????????????????????? */

/* Inline collapsible panel below asset actions */
.share-panel {
    display: none;
    flex-direction: column;
    background: var(--surface-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    animation: panelIn 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

.share-panel-open { display: flex; }

@keyframes panelIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.share-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface-overlay);
    flex-shrink: 0;
}

/* Share URL copy row */
.share-url-row {
    display: flex;
    gap: var(--space-3);
    align-items: stretch;
}

.share-url-row .form-control {
    flex: 1;
    background: var(--surface-subtle);
    cursor: text;
    color: var(--brand-primary);
}

/* ?? Toggle switch ???????????????????????????????????????????????? */
.toggle-switch {
    position: relative;
    display: inline-flex;
    cursor: pointer;
    flex-shrink: 0;
}

.toggle-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    display: block;
    width: 42px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--surface-muted);
    border: 1px solid var(--border-default);
    transition: background var(--transition-base), border-color var(--transition-base);
    position: relative;
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: var(--radius-full);
    background: var(--text-muted);
    transition: transform var(--transition-base), background var(--transition-base);
}

.toggle-switch input:checked + .toggle-track {
    background: var(--brand-glow-strong);
    border-color: var(--border-brand);
}

.toggle-switch input:checked + .toggle-track::after {
    transform: translateX(18px);
    background: var(--brand-primary);
}

/* ???????????????????????????????????????????????????????????????????
   PHASE 6 — BULK ACTION BAR
   ??????????????????????????????????????????????????????????????????? */
.bulk-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-5);
    background: var(--surface-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-xs);
}

.media-card-wrapper {
    position: relative;
}

.bulk-checkbox-wrap {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(0,0,0,0.5);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(4px);
}

/* ?? Tournament tree node (structured view) ????????????????????? */
.tournament-tree-node {
    border-bottom: 1px solid var(--border-subtle);
    padding: var(--space-2) var(--space-3) var(--space-2) var(--space-3);
}

.tournament-tree-node:last-child { border-bottom: none; }

/* ???????????????????????????????????????????????????????????????????
   PHASE 6 — SPIN ANIMATION
   ??????????????????????????????????????????????????????????????????? */
@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.spin-slow {
    animation: spin-slow 1.2s linear infinite;
}

/* ???????????????????????????????????????????????????????????????????
   PAGINATION
   ??????????????????????????????????????????????????????????????????? */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.pagination-info {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.pagination-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.pagination-page:hover {
    background: var(--surface-overlay);
    color: var(--text-primary);
}

.pagination-page.active {
    background: var(--brand-glow);
    color: var(--brand-primary);
    font-weight: 700;
    border: 1px solid var(--border-brand);
}

/* ╔═══════════════════════════════════════════════════════════════════
   BULK UPLOAD FILE ROWS
   ═══════════════════════════════════════════════════════════════════ */
.bulk-file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast);
}

.bulk-file-row:hover {
    border-color: var(--border-default);
}

/* ╔═══════════════════════════════════════════════════════════════════
   DOWNLOAD PROGRESS OVERLAY
   ═══════════════════════════════════════════════════════════════════ */
.download-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: dlOverlayIn 180ms ease;
}

@keyframes dlOverlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.download-panel {
    background: var(--surface-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-6) var(--space-8);
    min-width: 360px;
    max-width: 460px;
    width: 90vw;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-5);
    animation: dlPanelIn 220ms cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}

@keyframes dlPanelIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.download-panel-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.download-panel-icon.dl-loading {
    background: var(--brand-glow-strong);
    border: 1px solid var(--border-brand);
    color: var(--brand-primary);
}

.download-panel-icon.dl-success {
    background: rgba(0, 166, 81, 0.18);
    border: 1px solid rgba(0, 166, 81, 0.35);
    color: #4ade80;
}

.download-panel-icon.dl-error {
    background: rgba(239, 68, 68, 0.14);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #f87171;
}

.download-panel-icon svg {
    width: 22px;
    height: 22px;
}

.download-panel-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.download-panel-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    max-width: 320px;
}

.download-progress-track {
    width: 100%;
    height: 6px;
    background: var(--surface-subtle);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.download-progress-bar {
    height: 100%;
    background: var(--brand-primary);
    border-radius: var(--radius-full);
    transition: width 0.2s ease;
    box-shadow: 0 0 10px rgba(0, 166, 81, 0.5);
    min-width: 2%;
}

.download-progress-bar.dl-error-bar {
    background: #ef4444;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.download-progress-bar.dl-indeterminate {
    width: 30% !important;
    animation: dlIndeterminate 1.4s ease-in-out infinite;
}

@keyframes dlIndeterminate {
    0%   { margin-left: 0;   width: 30%; }
    50%  { margin-left: 40%; width: 30%; }
    100% { margin-left: 0;   width: 30%; }
}

.download-progress-text {
    font-size: 11px;
    color: var(--text-muted);
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

.download-panel .btn {
    margin-top: var(--space-2);
}

/* ╔═══════════════════════════════════════════════════════════════════
   THEME-AWARE LOGO SWAP
   White logo → visible in dark mode
   Green logo → visible in light mode
   ═══════════════════════════════════════════════════════════════════ */
.logo-white { display: block; }
.logo-green { display: none; }
:root[data-theme="light"] .logo-white { display: none; }
:root[data-theme="light"] .logo-green { display: block; }

/* ╔═══════════════════════════════════════════════════════════════════
   THEME TOGGLE
   ═══════════════════════════════════════════════════════════════════ */
.theme-toggle {
    position: relative;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--surface-overlay);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
    overflow: hidden;
}
.theme-toggle:hover {
    background: var(--surface-subtle);
    border-color: var(--border-default);
    color: var(--brand-primary);
    transform: translateY(-1px);
}
.theme-toggle svg { width: 15px; height: 15px; transition: opacity var(--transition-base), transform var(--transition-base); }
.theme-toggle .icon-sun  { position: absolute; opacity: 0; transform: rotate(-90deg) scale(0.6); }
.theme-toggle .icon-moon { opacity: 1; transform: rotate(0) scale(1); }
:root[data-theme="light"] .theme-toggle .icon-sun  { opacity: 1; transform: rotate(0) scale(1); }
:root[data-theme="light"] .theme-toggle .icon-moon { opacity: 0; transform: rotate(90deg) scale(0.6); }

/* ╔═══════════════════════════════════════════════════════════════════
   LIGHT-MODE COMPONENT REFINEMENTS
   ═══════════════════════════════════════════════════════════════════ */
:root[data-theme="light"] .sidebar {
    background: linear-gradient(180deg, #ffffff 0%, #f5f7fb 100%);
}
:root[data-theme="light"] .sidebar-brand-name { color: var(--text-primary); }
:root[data-theme="light"] .topbar {
    background: color-mix(in srgb, #ffffff 78%, transparent);
}
:root[data-theme="light"] .topbar.scrolled {
    box-shadow: 0 4px 20px rgba(16,24,40,0.06);
}
:root[data-theme="light"] .form-control {
    background: #ffffff;
}
:root[data-theme="light"] .form-control:focus {
    background: #ffffff;
}
:root[data-theme="light"] .btn-secondary {
    background: #ffffff;
    color: var(--text-primary);
    border-color: var(--border-default);
}
:root[data-theme="light"] .btn-secondary:hover {
    background: var(--surface-overlay);
    border-color: var(--border-strong);
}
:root[data-theme="light"] .badge-green  { background: rgba(0,145,71,0.1);    color: #047636; border-color: rgba(0,145,71,0.22); }
:root[data-theme="light"] .badge-blue   { background: rgba(59,130,246,0.1);  color: #1d4ed8; border-color: rgba(59,130,246,0.22); }
:root[data-theme="light"] .badge-amber  { background: rgba(245,158,11,0.12); color: #a16207; border-color: rgba(245,158,11,0.25); }
:root[data-theme="light"] .badge-red    { background: rgba(239,68,68,0.1);   color: #b91c1c; border-color: rgba(239,68,68,0.22); }
:root[data-theme="light"] .badge-purple { background: rgba(139,92,246,0.1);  color: #6d28d9; border-color: rgba(139,92,246,0.22); }
:root[data-theme="light"] .stat-card-delta.up   { color: #047636; }
:root[data-theme="light"] .stat-card-delta.down { color: #b91c1c; }
:root[data-theme="light"] .sidebar-nav-item.active::before { box-shadow: 0 0 4px rgba(0,145,71,0.4); }

/* Subtle page-content fade-in for premium feel */
@keyframes pageIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.page-content > * { animation: pageIn 320ms cubic-bezier(0.4, 0, 0.2, 1) both; }
.page-content > *:nth-child(2) { animation-delay: 40ms; }
.page-content > *:nth-child(3) { animation-delay: 80ms; }
.page-content > *:nth-child(4) { animation-delay: 120ms; }

/* Respect user preference */
@media (prefers-reduced-motion: reduce) {
    .page-content > * { animation: none; }
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}