/* ================================================================
   FinPubMax Hub — Glassmorphism SaaS Dashboard
   ================================================================ */

:root {
    /* Sidebar */
    --sidebar-w: 256px;
    --sidebar-bg: linear-gradient(180deg, #0c1222 0%, #141a33 50%, #1a1040 100%);

    /* Accent */
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.35);
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

    /* Semantic */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Surface */
    --bg: #f0f2f8;
    --glass: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.55);
    --glass-hover: rgba(255, 255, 255, 0.85);
    --card-bg: rgba(255, 255, 255, 0.78);
    --card-border: rgba(226, 232, 240, 0.6);

    /* Text */
    --text: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 20px rgba(15, 23, 42, 0.07), 0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.1), 0 4px 12px rgba(15, 23, 42, 0.04);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.12);

    /* Radius */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 20px;

    /* Topbar */
    --topbar-h: 60px;
}

/* ===== RESET / BASE ===== */

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Animated background mesh */
.hub-bg-mesh {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse 80% 60% at 10% 20%, rgba(99,102,241,0.08) 0%, transparent 55%),
        radial-gradient(ellipse 60% 50% at 85% 70%, rgba(139,92,246,0.06) 0%, transparent 50%),
        radial-gradient(ellipse 50% 40% at 50% 50%, rgba(99,102,241,0.03) 0%, transparent 50%);
    pointer-events: none;
}

/* ===== SIDEBAR ===== */

.hub-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar-bg);
    color: #94a3b8;
    overflow-y: auto;
    z-index: 1040;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.hub-sidebar::-webkit-scrollbar { width: 3px; }
.hub-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

.hub-sidebar-logo {
    padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.hub-sidebar-logo-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.hub-sidebar-logo h4 {
    margin: 0;
    font-weight: 800;
    font-size: 1.05rem;
    color: #fff;
    letter-spacing: -0.4px;
    line-height: 1.2;
}

.hub-sidebar-logo small {
    color: var(--accent-light);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.hub-sidebar-nav {
    padding: 8px 0;
}

/* Ad usage badge — small boxed number next to every ad name showing how
   many times that ad has been scheduled (pending + scheduled + sent rows;
   cancelled and failed don't count). Tier-coded so the operator can see
   usage saturation at a glance:
     tier="0"     → red    (never used — surface fresh ads)
     tier="1"     → blue   (used once)
     tier="2"     → yellow (used twice)
     tier="3plus" → orange (heavily used)
   Renderer (Jinja or JS) computes the tier from the raw count and stamps
   `data-tier` on the badge. */
.ad-usage-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.5;
    vertical-align: middle;
    color: #fff;
    background: #6c757d;  /* neutral fallback */
}
.ad-usage-badge[data-tier="0"]     { background: #dc3545; }                        /* red */
.ad-usage-badge[data-tier="1"]     { background: #0d6efd; }                        /* blue */
.ad-usage-badge[data-tier="2"]     { background: #eab308; color: #1a1a1a; }        /* yellow (dark text) */
.ad-usage-badge[data-tier="3plus"] { background: #f97316; }                        /* orange */

/* Advertiser-filter strip — sits between toolbar and calendar on both
   the per-brand scheduler and the master calendar. Each chip is a click-
   toggle filter; hovering shows the per-advertiser ad list in a tooltip.
   Active filter chip gets a colored fill + bold text. Dense + flat to
   match Hub's terminal feel. */
.advertiser-strip {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.advertiser-strip-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.74rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-top: 5px;
    flex-shrink: 0;
    min-width: 132px;
    border-right: 1px solid #f1f5f9;
    padding-right: 12px;
}
.advertiser-strip-label i { font-size: 0.9rem; }
.advertiser-strip-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}
.advertiser-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 8px;
    border-radius: 6px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    color: #334155;
    font-size: 0.78rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 120ms ease;
    position: relative;
    line-height: 1.4;
}
.advertiser-chip:hover {
    background: #fff;
    border-color: var(--advertiser-color, #cbd5e1);
    color: var(--advertiser-color, #0f172a);
}
.advertiser-chip.is-active {
    background: var(--advertiser-color, #2563eb);
    border-color: var(--advertiser-color, #2563eb);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.16);
}
.advertiser-chip.is-active .advertiser-chip-dot {
    background: #fff;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6);
}
.advertiser-chip.is-active .advertiser-chip-count {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}
.advertiser-chip-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: var(--advertiser-color, #9ca3af);
    flex-shrink: 0;
}
.advertiser-chip-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #e5e7eb;
    color: #475569;
    font-size: 0.68rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.advertiser-chip-all {
    background: #f1f5f9;
    font-weight: 600;
}
.advertiser-chip-all.is-active {
    background: #0f172a;
    border-color: #0f172a;
}
.advertiser-chip-unassigned {
    color: #94a3b8;
    font-style: italic;
}
.advertiser-chip-unassigned .advertiser-chip-dot {
    background: #cbd5e1 !important;
}
.advertiser-tooltip {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 30;
    min-width: 220px;
    max-width: 360px;
    background: #0f172a;
    color: #f8fafc;
    border-radius: 6px;
    padding: 8px 10px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.45;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 120ms ease, transform 120ms ease;
    text-align: left;
    cursor: default;
}
.advertiser-chip:hover .advertiser-tooltip,
.advertiser-chip:focus .advertiser-tooltip {
    opacity: 1;
    transform: translateY(0);
}
.advertiser-tooltip-header {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 5px;
    margin-bottom: 5px;
    font-weight: 700;
}
.advertiser-tooltip-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 0;
}
.advertiser-tooltip-brand {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #cbd5e1;
    margin-right: 4px;
    flex-shrink: 0;
}
.advertiser-tooltip-brand-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--brand-color, #94a3b8);
    display: inline-block;
}
.advertiser-tooltip-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.advertiser-tooltip-count {
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
@media (max-width: 768px) {
    .advertiser-strip { flex-direction: column; gap: 8px; }
    .advertiser-strip-label {
        border-right: none;
        border-bottom: 1px solid #f1f5f9;
        padding-right: 0;
        padding-bottom: 6px;
        width: 100%;
    }
}

/* Advertiser identity swatch — appears next to ad names in the pool tables,
   inside FullCalendar list rows, and in the per-event modal. The fill color
   comes from the inline `--advertiser-color` CSS variable so it stays
   deterministic per `advertiser_id`. */
.advertiser-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 8px;
    vertical-align: middle;
    background: var(--advertiser-color, #9ca3af);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

/* Mode switcher: two top-level pill buttons that swap which "lens" the
   sidebar is in. Inactive looks like a regular link with subtle bg;
   active gets the brand-color fill so it's obvious which mode we're in. */
.hub-sidebar-modes {
    padding: 12px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.hub-mode-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.12s, transform 0.08s, box-shadow 0.12s;
    border: 1px solid transparent;
}
.hub-mode-btn i {
    font-size: 0.95rem;
    width: 16px;
    text-align: center;
}
.hub-mode-btn-dedicated {
    background: rgba(13, 202, 240, 0.10);
    color: #67e8f9;
    border-color: rgba(13, 202, 240, 0.20);
}
.hub-mode-btn-dedicated:hover {
    background: rgba(13, 202, 240, 0.18);
    color: #a5f3fc;
}
.hub-mode-btn-dedicated.active {
    background: linear-gradient(135deg, #0dcaf0 0%, #06b6d4 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(13, 202, 240, 0.35);
}
.hub-mode-btn-site {
    background: rgba(99, 102, 241, 0.10);
    color: #c7d2fe;
    border-color: rgba(99, 102, 241, 0.20);
}
.hub-mode-btn-site:hover {
    background: rgba(99, 102, 241, 0.18);
    color: #e0e7ff;
}
.hub-mode-btn-site.active {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.hub-sidebar-section {
    padding: 18px 18px 6px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(148, 163, 184, 0.35);
    margin-top: 2px;
}

.hub-sidebar-link {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    margin: 2px 10px;
    color: #8892a8;
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    transition: all 0.15s ease;
    border-radius: var(--r-sm);
    position: relative;
}

.hub-sidebar-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
    text-decoration: none;
}

.hub-sidebar-link.active {
    background: rgba(99, 102, 241, 0.15);
    color: #fff;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.2);
}

.hub-sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent-gradient);
    border-radius: 0 3px 3px 0;
}

.hub-sidebar-link i {
    width: 20px;
    font-size: 0.95rem;
    margin-right: 10px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.hub-sidebar-link.active i,
.hub-sidebar-link:hover i {
    opacity: 1;
}

.hub-sidebar-footer {
    padding: 10px 0 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.35);
}

/* Brand status dot */
.brand-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
}

.brand-dot-online { background: var(--success); box-shadow: 0 0 8px rgba(16, 185, 129, 0.5); }
.brand-dot-cached { background: var(--warning); box-shadow: 0 0 8px rgba(245, 158, 11, 0.4); }
.brand-dot-offline { background: var(--danger); box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }

/* ===== MAIN CONTENT ===== */

.hub-main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    position: relative;
}

/* ===== TOPBAR ===== */

.hub-topbar {
    height: var(--topbar-h);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid rgba(226, 232, 240, 0.5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.hub-topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.hub-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.hub-breadcrumb a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.hub-breadcrumb a:hover { text-decoration: underline; }
.hub-breadcrumb .sep { color: #cbd5e1; }

/* Search */
.hub-search-wrapper {
    position: relative;
    width: 100%;
}

.hub-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.82rem;
    color: var(--text-muted);
    pointer-events: none;
}

.hub-search-input {
    width: 100%;
    padding: 8px 14px 8px 34px;
    font-size: 0.82rem;
    font-family: inherit;
    background: rgba(241, 245, 249, 0.8);
    border: 1px solid var(--card-border);
    border-radius: var(--r-sm);
    color: var(--text);
    outline: none;
    transition: all 0.2s ease;
}

.hub-search-input:focus {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.hub-search-input::placeholder { color: var(--text-muted); }

.hub-content {
    padding: 28px;
    max-width: 1400px;
}

/* Sidebar toggle — visible on all viewports. Mobile: slide-in. Desktop: collapse-to-hidden so the main content can use full width. */
.hub-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}
.hub-sidebar-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
}

/* Desktop collapsed state — sidebar slides off-screen, main reclaims the space.
   Content's normal max-width cap is also removed so the body can actually
   expand into the new horizontal real-estate. */
.hub-sidebar.collapsed {
    transform: translateX(-100%);
}
.hub-main.collapsed {
    margin-left: 0;
}
.hub-main.collapsed .hub-content {
    max-width: none;
}

/* ===== FLASH MESSAGES ===== */

.hub-flash {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: var(--r-md);
    font-size: 0.86rem;
    font-weight: 500;
    margin-bottom: 16px;
    backdrop-filter: blur(12px);
    animation: flashSlide 0.3s ease;
}

@keyframes flashSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.hub-flash-success {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.15);
    color: #059669;
}

.hub-flash-danger {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

.hub-flash-warning {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.15);
    color: #d97706;
}

.hub-flash-info {
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.12);
    color: var(--accent);
}

/* ===== GLASS CARD (universal) ===== */

.hub-form-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: var(--r-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

.hub-form-card:hover {
    box-shadow: var(--shadow-md);
}

/* ===== BRAND CARDS (Dashboard — Legacy) ===== */

.brand-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: var(--r-lg);
    border: 1px solid var(--card-border);
    border-left: 4px solid #333;
    padding: 22px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
    box-shadow: var(--shadow-sm);
}

.brand-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.brand-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.brand-card-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.3px;
}

.brand-card-name i { font-size: 1.1rem; }

.brand-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.brand-stat-item {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.brand-stat-item strong {
    display: block;
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 1px;
    font-weight: 700;
}

.brand-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ===== BRAND CARDS V2 (Modern Dashboard) ===== */

.brand-card-v2 {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--r-xl);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
    border: 1px solid var(--card-border);
}

.brand-card-v2:hover {
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    transform: translateY(-4px);
    border-color: rgba(99, 102, 241, 0.15);
}

.brand-card-v2-header {
    padding: 20px 24px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.brand-card-v2-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 60%);
    pointer-events: none;
}

.brand-card-v2-header::after {
    content: '';
    position: absolute;
    top: -40%;
    right: -15%;
    width: 140px;
    height: 140px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 50%;
    pointer-events: none;
}

.brand-card-v2-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    color: #fff;
    flex-shrink: 0;
}

.brand-card-v2-name {
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.brand-card-v2-url {
    font-size: 0.68rem;
    opacity: 0.6;
    font-weight: 400;
    letter-spacing: 0.2px;
}

.brand-card-v2-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    backdrop-filter: blur(8px);
}

.brand-card-v2-status.online { background: rgba(255,255,255,0.2); color: #fff; }
.brand-card-v2-status.cached { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.8); }
.brand-card-v2-status.offline { background: rgba(239,68,68,0.25); color: #fff; }

.brand-card-v2-body {
    padding: 22px 24px 20px;
}

.brand-card-v2-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.brand-card-v2-stat {
    text-align: center;
    padding: 14px 8px;
    background: rgba(241, 245, 249, 0.7);
    border-radius: var(--r-md);
    border: 1px solid rgba(226, 232, 240, 0.4);
    transition: all 0.15s ease;
}

.brand-card-v2-stat:hover {
    background: rgba(241, 245, 249, 0.95);
    border-color: rgba(99, 102, 241, 0.15);
}

.brand-card-v2-stat-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.brand-card-v2-stat-label {
    font-size: 0.64rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-top: 4px;
}

.brand-card-v2-actions {
    display: flex;
    gap: 8px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(241, 245, 249, 0.8);
}

/* ===== STATUS BADGES ===== */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    backdrop-filter: blur(8px);
}

.status-online  { background: rgba(16,185,129,0.1);  color: #059669; }
.status-cached   { background: rgba(245,158,11,0.1);  color: #d97706; }
.status-offline  { background: rgba(239,68,68,0.1);   color: #dc2626; }
.status-running  { background: rgba(99,102,241,0.1);  color: var(--accent); }
.status-idle     { background: rgba(100,116,139,0.07); color: var(--text-secondary); }
.status-success  { background: rgba(16,185,129,0.1);  color: #059669; }
.status-failed   { background: rgba(239,68,68,0.1);   color: #dc2626; }
.status-cancelled { background: rgba(245,158,11,0.1); color: #d97706; }

/* ===== PIPELINE TRACKER ===== */

.pipeline-tracker {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 16px 0;
    overflow-x: auto;
}

.pipeline-stage {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
}

.pipeline-stage-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    border: 2px solid #e2e8f0;
    background: #fff;
    color: #cbd5e1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pipeline-stage-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: #cbd5e1;
    margin-top: 4px;
    text-align: center;
    white-space: nowrap;
}

.pipeline-stage-connector {
    width: 32px;
    height: 2px;
    background: #e2e8f0;
    flex-shrink: 0;
    transition: background 0.3s ease;
}

.pipeline-stage.completed .pipeline-stage-dot {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

.pipeline-stage.completed .pipeline-stage-label { color: var(--success); }

.pipeline-stage.completed + .pipeline-stage-connector,
.pipeline-stage-connector.completed { background: var(--success); }

.pipeline-stage.active .pipeline-stage-dot {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    animation: pulse-stage 2s infinite;
    box-shadow: 0 2px 14px var(--accent-glow);
}

.pipeline-stage.active .pipeline-stage-label { color: var(--accent); }

@keyframes pulse-stage {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
    50% { box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
}

/* ===== STAT CARDS ===== */

.stat-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: var(--r-md);
    border: 1px solid var(--card-border);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow-xs);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(99, 102, 241, 0.12);
}

.stat-card:hover::before { opacity: 1; }

.stat-card-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.stat-card-label {
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* ===== LLM BADGES ===== */

.llm-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.llm-openai       { background: #dcfce7; color: #166534; }
.llm-claude       { background: #ede9fe; color: #5b21b6; }
.llm-claude_haiku { background: #f3e8ff; color: #6b21a8; }
.llm-gpt_image    { background: #fce7f3; color: #9d174d; }
.llm-gemini       { background: #dbeafe; color: #1e40af; }   /* legacy */
.llm-gemini_image { background: #dbeafe; color: #1e40af; }   /* legacy */
.llm-kimi         { background: #ffedd5; color: #9a3412; }   /* legacy */
.llm-unknown      { background: #f1f5f9; color: var(--text-secondary); }

/* ===== CATEGORY BADGES ===== */

.category-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.66rem;
    font-weight: 600;
    background: rgba(241, 245, 249, 0.8);
    color: var(--text-secondary);
}

/* ===== TABLES ===== */

.hub-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: var(--r-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--card-border);
}

.hub-table thead th {
    background: rgba(248, 250, 252, 0.9);
    padding: 12px 16px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--card-border);
    white-space: nowrap;
}

.hub-table tbody td {
    padding: 12px 16px;
    font-size: 0.86rem;
    border-bottom: 1px solid rgba(241, 245, 249, 0.7);
    vertical-align: middle;
}

.hub-table tbody tr {
    transition: background 0.1s ease;
}

.hub-table tbody tr:hover {
    background: rgba(248, 250, 252, 0.8);
}

.hub-table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== LOGIN ===== */

.hub-login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0c1222 0%, #141a33 40%, #1a1040 100%);
    position: relative;
    overflow: hidden;
}

.hub-login-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 50% 40% at 25% 30%, rgba(99,102,241,0.18) 0%, transparent 55%),
        radial-gradient(ellipse 40% 35% at 75% 75%, rgba(139,92,246,0.12) 0%, transparent 50%),
        radial-gradient(ellipse 30% 25% at 50% 10%, rgba(99,102,241,0.06) 0%, transparent 50%);
    animation: loginGlow 20s ease-in-out infinite alternate;
}

@keyframes loginGlow {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-2%, -2%) scale(1.02); }
}

.hub-login-card {
    background: rgba(20, 26, 51, 0.55);
    backdrop-filter: blur(32px) saturate(150%);
    -webkit-backdrop-filter: blur(32px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--r-xl);
    padding: 44px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255,255,255,0.04);
    position: relative;
}

.hub-login-card h2 {
    color: #fff;
    font-weight: 800;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.hub-login-card .subtitle {
    color: var(--accent-light);
    font-size: 0.84rem;
    margin-bottom: 32px;
    font-weight: 500;
}

.hub-login-card .form-control {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
    padding: 12px 16px;
    border-radius: var(--r-sm);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.hub-login-card .form-control:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15), 0 0 20px rgba(99, 102, 241, 0.1);
    color: #fff;
}

.hub-login-card .form-control::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.hub-login-card .btn-primary {
    background: var(--accent-gradient);
    border: none;
    padding: 12px;
    border-radius: var(--r-sm);
    font-weight: 700;
    width: 100%;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    letter-spacing: -0.2px;
}

.hub-login-card .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 28px rgba(99, 102, 241, 0.4);
}

/* ===== WRITER CARDS ===== */

.writer-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: var(--r-md);
    border: 1px solid var(--card-border);
    padding: 20px;
    height: 100%;
    box-shadow: var(--shadow-xs);
    transition: all 0.2s ease;
}

.writer-card:hover { box-shadow: var(--shadow-md); }

.writer-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.writer-card h6 {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 2px;
    letter-spacing: -0.2px;
}

.writer-card .writer-title {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-style: italic;
}

.writer-card .writer-style {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.5;
}

/* ===== PAGINATION ===== */

.hub-pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
}

.hub-pagination .page-link {
    border-radius: var(--r-sm);
    font-size: 0.85rem;
    padding: 6px 12px;
}

/* ===== EMPTY STATE ===== */

.hub-empty {
    text-align: center;
    padding: 60px 24px;
    color: #cbd5e1;
}

.hub-empty i {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
    opacity: 0.4;
}

.hub-empty h5 {
    color: var(--text-secondary);
    font-weight: 700;
    letter-spacing: -0.3px;
}

.hub-empty p { font-size: 0.88rem; }

/* ===== ERROR / ALERT BANNERS ===== */

.hub-error-banner {
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.12);
    border-radius: var(--r-md);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 0.86rem;
    color: #dc2626;
    backdrop-filter: blur(8px);
}

.hub-error-banner i { font-size: 1.1rem; flex-shrink: 0; }

/* ===== COST CHART ===== */

.cost-chart-container {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: var(--r-lg);
    border: 1px solid var(--card-border);
    padding: 24px;
    margin-top: 24px;
    box-shadow: var(--shadow-sm);
}

/* ===== TRIGGER BUTTON ===== */

.btn-trigger {
    background: var(--accent-gradient);
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 0.82rem;
    padding: 8px 18px;
    border-radius: var(--r-sm);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.1px;
}

.btn-trigger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 18px var(--accent-glow);
    color: #fff;
}

.btn-stop {
    background: var(--danger);
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 0.82rem;
    padding: 8px 18px;
    border-radius: var(--r-sm);
    transition: all 0.15s ease;
}

.btn-stop:hover {
    background: #dc2626;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

/* ===== BRAND NAV SUBITEMS ===== */

.hub-sidebar-link.brand-sublink {
    padding-left: 44px;
    font-size: 0.8rem;
    color: rgba(148, 163, 184, 0.55);
}

.hub-sidebar-link.brand-sublink:hover { color: #e2e8f0; }

.hub-sidebar-link.brand-sublink.active {
    color: #fff;
    background: rgba(99, 102, 241, 0.15);
}

/* ===== SCHEDULE ===== */

.schedule-day-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--card-border);
    border-radius: var(--r-sm);
    margin: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.schedule-day-check:has(input:checked) {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 2px 10px var(--accent-glow);
}

.schedule-day-check input { display: none; }

/* ===== ANIMATIONS ===== */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.hub-content > * {
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== COLOR PICKER ===== */

.color-picker-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.color-picker-wrapper input[type="color"] {
    width: 40px;
    height: 40px;
    border: 2px solid var(--card-border);
    border-radius: var(--r-sm);
    cursor: pointer;
    padding: 2px;
    transition: border-color 0.15s ease;
}

.color-picker-wrapper input[type="color"]:hover {
    border-color: var(--accent);
}

/* ===== SCROLLBAR ===== */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== BUTTONS ===== */

.btn-sm {
    border-radius: var(--r-sm);
    font-size: 0.82rem;
    font-weight: 500;
    padding: 6px 14px;
    transition: all 0.15s ease;
}

.btn-outline-secondary {
    border-color: var(--card-border);
    color: var(--text-secondary);
    background: transparent;
}

.btn-outline-secondary:hover {
    background: rgba(248, 250, 252, 0.8);
    border-color: #cbd5e1;
    color: var(--text);
}

/* ===== ALERTS (Bootstrap override) ===== */

.alert {
    border-radius: var(--r-md);
    font-size: 0.86rem;
    border: none;
    box-shadow: var(--shadow-sm);
}

.alert-success { background: rgba(16,185,129,0.08); color: #059669; }
.alert-danger  { background: rgba(239,68,68,0.08);  color: #dc2626; }
.alert-warning { background: rgba(245,158,11,0.08); color: #d97706; }

/* ===== RESPONSIVE ===== */

@media (max-width: 991.98px) {
    .hub-sidebar { transform: translateX(-100%); }
    .hub-sidebar.show { transform: translateX(0); }
    .hub-main { margin-left: 0; }
    .hub-sidebar-toggle { display: block; }

    .hub-sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        backdrop-filter: blur(4px);
        z-index: 1035;
    }
    .hub-sidebar-overlay.show { display: block; }
}

@media (max-width: 575.98px) {
    .hub-content { padding: 16px; }
    .brand-card { padding: 16px; }
    .pipeline-tracker { padding: 12px 0; }
    .stat-card-value { font-size: 1.4rem; }
}
