/* ===== ZAP SAC — Professional SaaS Theme ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;900&family=JetBrains+Mono:wght@500&display=swap');

:root {
    --bg-primary: #0F172A;
    --bg-secondary: #1E293B;
    --bg-card: #1E293B;
    --bg-card-hover: #263548;
    --bg-glass: rgba(30, 41, 59, 0.85);
    --glass-border: rgba(148, 163, 184, 0.12);
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --accent: #3B82F6;
    --accent-glow: rgba(59, 130, 246, 0.25);
    --accent2: #2563EB;
    --accent3: #F59E0B;
    --green: #10B981;
    --green-glow: rgba(16, 185, 129, 0.15);
    --red: #EF4444;
    --red-glow: rgba(239, 68, 68, 0.15);
    --yellow: #F59E0B;
    --blue: #3B82F6;
    --gradient-main: linear-gradient(135deg, #2563EB 0%, #3B82F6 50%, #60A5FA 100%);
    --gradient-card: linear-gradient(135deg, rgba(37, 99, 235, 0.06), rgba(59, 130, 246, 0.04));
    --gradient-sidebar: linear-gradient(180deg, #0F172A 0%, #1E293B 100%);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-glow: 0 0 12px var(--accent-glow);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Global form element dark theme */
input,
select,
textarea {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    padding: 10px 14px;
    transition: var(--transition);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #64748B;
}

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.08) 0%, transparent 70%);
    top: -200px;
    right: -100px;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.06) 0%, transparent 70%);
    bottom: -100px;
    left: -50px;
}

@keyframes pulse-glow {

    0%,
    100% {
        opacity: 0.5;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

.login-left {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: relative;
    z-index: 2;
}

.login-right {
    width: 45%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.login-right img {
    max-height: 85vh;
    object-fit: contain;
    opacity: 0.9;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-12px);
    }
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    box-shadow: var(--shadow-md);
}

.login-card .logo {
    font-size: 28px;
    font-weight: 900;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
    text-align: center;
}

/* === NEW UTILITIES === */
.loading-spinner {
    border: 4px solid var(--bg-card);
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
    margin: auto;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.fade-in-section {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.fade-in-section.visible {
    opacity: 1;
    transform: none;
}
    font-size: 28px;
    font-weight: 900;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
    text-align: center;
}

.login-card .logo-sub {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-top: 4px;
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

select,
.form-group select,
.company-select {
    background-color: var(--bg-card) !important;
    color: var(--text-primary);
}

select option,
.form-group select option,
.company-select option {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 8px 12px;
}

select option:checked,
.company-select option:checked {
    background: rgba(59, 130, 246, 0.3);
    color: #fff;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-main);
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 30px var(--accent-glow);
}

.btn-danger {
    background: var(--red);
    color: white;
}

.btn-danger:hover {
    background: #e8434e;
    box-shadow: 0 0 20px var(--red-glow);
}

.btn-success {
    background: var(--green);
    color: white;
}

.btn-success:hover {
    box-shadow: 0 0 20px var(--green-glow);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== ADMIN LAYOUT ===== */
.admin-container {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 240px;
    background: var(--gradient-sidebar);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--glass-border);
    text-align: center;
}

.sidebar-header .brand {
    font-size: 22px;
    font-weight: 900;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
}

.sidebar-header .brand-sub {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-top: 2px;
}

.sidebar-header .brand-mascot {
    width: 110px;
    height: 110px;
    object-fit: contain;
    margin-top: 10px;
    filter: drop-shadow(0 0 18px var(--accent-glow));
    border-radius: 50%;
    transition: var(--transition);
}

.sidebar-header .brand-mascot:hover {
    transform: scale(1.08);
    filter: drop-shadow(0 0 25px var(--accent-glow));
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    font-weight: 500;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(59, 130, 246, 0.06);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 600;
}

.nav-item .icon {
    font-size: 16px;
    width: 22px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--glass-border);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 24px 28px;
    min-height: 100vh;
    position: relative;
}

.main-content .section {
    display: none;
}

.main-content .section.active {
    display: block;
    min-height: calc(100vh - 72px);
    position: relative;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

/* ===== STAT CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-main);
    opacity: 0;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(59, 130, 246, 0.2);
    background: var(--gradient-card);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card .stat-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
}

.stat-card .stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

.stat-card .stat-sub {
    font-size: 11px;
    color: var(--accent);
    margin-top: 4px;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* ===== OPERATORS GRID (table container) ===== */
.operators-grid {
    display: block;
    width: 100%;
}

.operator-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
}

.operator-card:hover {
    border-color: rgba(59, 130, 246, 0.2);
}

.operator-card.connected {
    border-color: rgba(0, 200, 83, 0.3);
}

/* ===== TABLE — unified dark theme, high-contrast headers ===== */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
    contain: layout style;
}

table {
    width: 100%;
    border-collapse: collapse;
    /* avoid layout thrash on long lists */
    contain: layout style;
}

thead {
    background: rgba(30, 41, 59, 0.8);
}

th {
    text-align: left;
    padding: 11px 16px;
    font-size: 11px;
    font-weight: 700;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: #1E293B;
    z-index: 1;
}

td {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(148, 163, 184, 0.06);
}

tr:hover td {
    background: rgba(59, 130, 246, 0.04);
}

/* Long lists: hide off-screen rows from layout/paint */
tbody tr {
    content-visibility: auto;
    contain-intrinsic-size: auto 48px;
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-green {
    background: var(--green-glow);
    color: var(--green);
}

.badge-red {
    background: var(--red-glow);
    color: var(--red);
}

.badge-yellow {
    background: rgba(255, 193, 7, 0.15);
    color: var(--yellow);
}

.badge-purple {
    background: var(--accent-glow);
    color: var(--accent);
}

/* ===== TIER BADGES ===== */
.tier-diamond {
    border-left: 3px solid #b9f2ff;
}

.tier-gold {
    border-left: 3px solid #ffd700;
}

.tier-silver {
    border-left: 3px solid #c0c0c0;
}

.tier-bronze {
    border-left: 3px solid #cd7f32;
}

/* ===== CAMPAIGN BAR ===== */
.campaign-bar {
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-top: 10px;
    border: 1px solid var(--glass-border);
}

.campaign-bar.active {
    background: rgba(0, 200, 83, 0.06);
    border-color: rgba(0, 200, 83, 0.2);
}

/* ===== COMPANY SELECTOR ===== */
.company-select {
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    width: 100%;
}

.company-select:focus {
    border-color: var(--accent);
    outline: none;
}

.company-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* ===== DECORATIVE RENDERS (disabled) ===== */
.yuji-decoration,
.header-yuji,
.header-character,
.brand-mascot,
.loading-character {
    display: none !important;
}

/* ===== FUNNEL CHART ===== */
.funnel-bar {
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    margin-bottom: 8px;
    transition: var(--transition);
    min-width: 80px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ===== RESPONSIVE ===== */
/* Old 768px/480px queries moved to comprehensive mobile section at bottom */


/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section.active {
    animation: fadeIn 0.3s ease-out;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.loading {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}


/* ===== PREMIUM CORPORATE DESIGN SYSTEM ===== */

/* --- Glass-morphism Stat Cards --- */
.stat-card {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
    backdrop-filter: blur(20px);
    border: 1px solid rgba(59, 130, 246, 0.12);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3B82F6, #60A5FA, #93C5FD);
    transform: scaleX(0);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: left;
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: rgba(59, 130, 246, 0.25);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4), 0 0 32px rgba(59, 130, 246, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.stat-card:hover::after {
    transform: scaleX(1);
}

.stat-card .stat-icon {
    font-size: 32px;
    margin-bottom: 12px;
    filter: drop-shadow(0 2px 8px rgba(59, 130, 246, 0.3));
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, #F1F5F9, #E2E8F0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- Premium Sidebar --- */
.sidebar {
    background: linear-gradient(180deg, #0B1120 0%, #0F172A 40%, #131D33 100%) !important;
    border-right: 1px solid rgba(59, 130, 246, 0.1) !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse 200% 100% at 100% 0%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse 100% 200% at 0% 100%, rgba(37, 99, 235, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.sidebar>* {
    position: relative;
    z-index: 1;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(59, 130, 246, 0.1);
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.04), transparent);
}

.sidebar-header .brand {
    font-size: 22px;
    font-weight: 900;
    background: linear-gradient(135deg, #60A5FA, #3B82F6, #2563EB);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
    position: relative;
}

.sidebar-header .brand::after {
    content: '';
    display: none;
}

.sidebar-header .brand-logo {
    border-radius: 12px;
    margin-top: 12px;
    filter: drop-shadow(0 4px 12px rgba(59, 130, 246, 0.2));
    transition: all 0.3s ease;
}

.sidebar-header .brand-logo:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 6px 20px rgba(59, 130, 246, 0.35));
}

/* --- Nav Items Premium Hover --- */
.nav-item {
    border-left: 3px solid transparent;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0 8px 8px 0;
    margin: 2px 8px 2px 0;
}

.nav-item:hover {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.08), transparent);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.03));
    color: #60A5FA;
    border-left-color: #3B82F6;
    font-weight: 600;
    box-shadow: inset 3px 0 12px rgba(59, 130, 246, 0.1);
}

/* --- Card Premium Glass --- */
.card {
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.85), rgba(15, 23, 42, 0.9));
    backdrop-filter: blur(12px);
    border: 1px solid rgba(148, 163, 184, 0.08);
}

.card:hover {
    border-color: rgba(59, 130, 246, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 0 16px rgba(59, 130, 246, 0.05);
    transform: translateY(-1px);
}

.card-header {
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.04), transparent);
    border-bottom: 1px solid rgba(59, 130, 246, 0.08);
}

/* --- Section Headers Premium --- */
.section-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(135deg, #F1F5F9, #94A3B8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- Operator Card Premium --- */
.operator-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
    backdrop-filter: blur(12px);
}

.operator-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3), 0 0 20px rgba(59, 130, 246, 0.06);
    border-color: rgba(59, 130, 246, 0.2);
}

/* --- Premium Buttons --- */
.btn-cleanup {
    background: linear-gradient(135deg, #1E293B, #0F172A);
    color: #60A5FA;
    border: 1px solid rgba(59, 130, 246, 0.2);
    font-size: 11px;
}

.btn-cleanup:hover {
    border-color: #3B82F6;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.15);
    background: linear-gradient(135deg, #1E293B, #172040);
}

/* --- Mode Badges Corporate --- */
.mode-badge-ai {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(37, 99, 235, 0.12));
    border: 1px solid rgba(59, 130, 246, 0.25);
    color: #60A5FA;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    animation: subtle-pulse 3s ease-in-out infinite;
}

.mode-badge-normal {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #34D399;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- Premium Background Ambience --- */
.main-content::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse 120% 80% at 70% 20%, rgba(59, 130, 246, 0.03) 0%, transparent 60%),
        radial-gradient(ellipse 80% 120% at 20% 80%, rgba(37, 99, 235, 0.02) 0%, transparent 60%);
    pointer-events: none;
    z-index: -1;
    animation: ambient-breathe 15s ease-in-out infinite;
}

@keyframes ambient-breathe {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

@keyframes subtle-pulse {
    0%, 100% { opacity: 0.8; box-shadow: 0 0 0 rgba(59, 130, 246, 0); }
    50% { opacity: 1; box-shadow: 0 0 12px rgba(59, 130, 246, 0.1); }
}

/* --- Enhanced Table Premium --- */
thead {
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.9));
}

th {
    background: linear-gradient(180deg, #1E293B, #172135);
    font-weight: 700;
    color: #60A5FA;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-size: 10px;
}

tr:hover td {
    background: rgba(59, 130, 246, 0.04);
}

/* --- Premium Toast --- */
.toast-msg {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98)) !important;
    backdrop-filter: blur(20px) !important;
    border-left: 3px solid #3B82F6 !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 20px rgba(59, 130, 246, 0.08) !important;
    border-radius: 12px !important;
}

/* --- Premium Scrollbar --- */
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #3B82F6, #2563EB);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

/* --- Stagger Animation for Dashboard --- */
.anim-stagger .anim-item {
    opacity: 0;
    transform: translateY(20px);
    animation: stagger-in 0.5s ease-out forwards;
}
.anim-stagger .anim-item:nth-child(1) { animation-delay: 0.05s; }
.anim-stagger .anim-item:nth-child(2) { animation-delay: 0.1s; }
.anim-stagger .anim-item:nth-child(3) { animation-delay: 0.15s; }
.anim-stagger .anim-item:nth-child(4) { animation-delay: 0.2s; }
.anim-stagger .anim-item:nth-child(5) { animation-delay: 0.25s; }

@keyframes stagger-in {
    to { opacity: 1; transform: translateY(0); }
}

/* --- Chart Container Glass --- */
.chart-container,
canvas {
    border-radius: 12px;
}

/* --- Decorative Renders DISABLED --- */
.yuji-decoration,
.header-yuji,
.header-character,
.brand-mascot,
.loading-character,
.jjk-badge,
.special-grade::before {
    display: none !important;
}

.special-grade::before {
    content: none;
}

/* --- JJK Legacy Overrides --- */
.jjk-loading-overlay { display: none !important; }
.jjk-badge { display: none !important; }



/* ===== OPERATOR / CHAT LAYOUT ===== */
.chat-layout {
    display: flex;
    height: 100vh;
    background: var(--bg-primary);
}

.chat-sidebar {
    width: 340px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.chat-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--glass-border);
}

.chat-sidebar-header .operator-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-sidebar-header .operator-avatar {
    width: 40px;
    height: 40px;
    background: var(--gradient-main);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 16px;
}

.chat-sidebar-header .operator-name {
    font-weight: 600;
    font-size: 14px;
}

.operator-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.op-status-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 11px;
    padding: 2px 6px;
    font-family: inherit;
    cursor: pointer;
}

.sidebar-actions {
    display: flex;
    gap: 6px;
}

.wa-connection-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 12px;
    border-bottom: 1px solid var(--glass-border);
}

.wa-conn-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.op-balance-card {
    padding: 12px 16px;
    border-bottom: 1px solid var(--glass-border);
}

.balance-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.balance-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.balance-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--green);
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    gap: 8px;
    border-bottom: 1px solid var(--glass-border);
}

.search-input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    padding: 8px 0;
    outline: none;
    font-family: inherit;
}

.search-input-wrapper input::placeholder {
    color: var(--text-muted);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.conversation-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.conversation-item.active {
    background: rgba(200, 80, 192, 0.08);
}

.contact-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--gradient-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 18px;
    margin-right: 14px;
    flex-shrink: 0;
}

.contact-details {
    flex: 1;
    min-width: 0;
}

.contact-details-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contact-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.contact-time {
    font-size: 11px;
    color: var(--text-muted);
}

.contact-details-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contact-last-msg {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--glass-border);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.sent {
    background: rgba(200, 80, 192, 0.2);
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.message.received {
    background: var(--bg-card);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.message .msg-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}

.chat-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--glass-border);
}

.chat-input-area input,
.chat-input-area textarea {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
}

.chat-input-area input:focus,
.chat-input-area textarea:focus {
    border-color: var(--accent);
}

.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: fadeIn 0.3s ease-out;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--glass-border);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Operator page responsive */
@media (max-width: 768px) {
    .chat-sidebar {
        width: 100%;
        position: fixed;
        z-index: 10;
    }

    .chat-main {
        display: none;
    }

    .chat-main.active {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 20;
    }
}

/* ===== ANIM STAGGER ===== */
.anim-stagger .anim-item {
    animation: fadeIn 0.4s ease-out both;
}

.anim-stagger .anim-item:nth-child(1) {
    animation-delay: 0.05s;
}

.anim-stagger .anim-item:nth-child(2) {
    animation-delay: 0.1s;
}

.anim-stagger .anim-item:nth-child(3) {
    animation-delay: 0.15s;
}

.anim-stagger .anim-item:nth-child(4) {
    animation-delay: 0.2s;
}

.anim-stagger .anim-item:nth-child(5) {
    animation-delay: 0.25s;
}

.anim-stagger .anim-item:nth-child(6) {
    animation-delay: 0.3s;
}

/* ===== Tooltip ===== */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 10, 18, 0.95);
    color: #e2e8f0;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    white-space: normal;
    max-width: 280px;
    min-width: 180px;
    width: max-content;
    z-index: 99999;
    border: 1px solid rgba(200, 80, 192, 0.25);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 12px rgba(200, 80, 192, 0.1);
    pointer-events: none;
    animation: tooltipFadeIn 0.25s ease-out;
    text-align: left;
}

[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: rgba(10, 10, 18, 0.95);
    z-index: 99999;
    pointer-events: none;
    animation: tooltipFadeIn 0.25s ease-out;
}

@keyframes tooltipFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(4px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== SPRINT 2: UX ENHANCEMENTS ===== */

/* --- Live Status Pulse Dot --- */
@keyframes live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 200, 83, 0.5); }
    70% { box-shadow: 0 0 0 8px rgba(0, 200, 83, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 200, 83, 0); }
}

.live-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.live-dot.online {
    background: var(--green);
    animation: live-pulse 2s infinite;
}

.live-dot.offline {
    background: var(--red);
}

.live-dot.connecting {
    background: var(--yellow);
    animation: live-pulse 1s infinite;
}

/* --- Enhanced Toast Messages --- */
@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toast-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.toast-msg {
    background: var(--bg-card) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--radius) !important;
    padding: 14px 18px !important;
    font-size: 13px !important;
    color: var(--text-primary) !important;
    animation: toast-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
    max-width: 380px !important;
    backdrop-filter: blur(12px);
    border-left: 3px solid var(--accent) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(200, 80, 192, 0.1) !important;
    position: relative;
    overflow: hidden;
}

.toast-msg.toast-exit {
    animation: toast-out 0.3s ease-in forwards !important;
}

.toast-msg.toast-success {
    border-left-color: var(--green) !important;
}

.toast-msg.toast-error {
    border-left-color: var(--red) !important;
}

.toast-msg.toast-warning {
    border-left-color: var(--yellow) !important;
}

/* Toast progress bar (duration via --toast-duration var, default 4s) */
.toast-msg::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--accent);
    animation: toast-progress var(--toast-duration, 4000ms) linear forwards;
}

.toast-msg.toast-success::after { background: var(--green); }
.toast-msg.toast-error::after { background: var(--red); }
.toast-msg.toast-warning::after { background: var(--yellow); }

@keyframes toast-progress {
    from { width: 100%; }
    to { width: 0%; }
}

/* --- System Health Dashboard Card --- */
.health-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: var(--transition);
}

.health-card:hover {
    border-color: rgba(200, 80, 192, 0.2);
    transform: translateY(-1px);
}

.health-card .health-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.health-card .health-icon.healthy { background: var(--green-glow); }
.health-card .health-icon.warning { background: rgba(255, 193, 7, 0.15); }
.health-card .health-icon.critical { background: var(--red-glow); }

.health-card .health-info { flex: 1; }
.health-card .health-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.health-card .health-detail { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* --- Conversation with unread glow --- */
.conversation-item.has-unread {
    border-left: 3px solid var(--accent);
    background: rgba(200, 80, 192, 0.04);
}

.conversation-item.has-unread .contact-name {
    color: white;
    font-weight: 700;
}

/* --- Typing indicator --- */
@keyframes typing-dot {
    0%, 20% { opacity: 0.3; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-3px); }
    80%, 100% { opacity: 0.3; transform: translateY(0); }
}

.typing-indicator {
    display: inline-flex;
    gap: 3px;
    align-items: center;
    padding: 6px 12px;
    background: var(--bg-card);
    border-radius: 16px;
    align-self: flex-start;
}

.typing-indicator .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing-dot 1.4s infinite;
}

.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

/* --- AI-generated message indicator --- */
.message.is-ai {
    position: relative;
}

.message.is-ai::before {
    content: '🤖';
    position: absolute;
    top: -6px;
    right: -4px;
    font-size: 10px;
    opacity: 0.6;
}

/* --- Empty state --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.empty-state .empty-icon {
    font-size: 52px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state .empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.empty-state .empty-desc {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 300px;
    line-height: 1.5;
}

/* --- Notification badge on sidebar nav --- */
.nav-item .nav-badge {
    background: var(--red);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    animation: live-pulse 2s infinite;
}

/* --- Glassmorphism modal enhancement --- */
.modal {
    background: rgba(18, 18, 26, 0.95) !important;
    backdrop-filter: blur(20px) !important;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5), 0 0 40px rgba(200, 80, 192, 0.08) !important;
}

/* --- Card subtle gradient on hover --- */
.card:hover {
    background: linear-gradient(135deg, rgba(65, 88, 208, 0.03), rgba(200, 80, 192, 0.02));
}

/* --- Operator card online glow --- */
.operator-card.connected {
    box-shadow: 0 0 20px rgba(0, 200, 83, 0.08);
}

.operator-card.connected:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3), 0 0 25px rgba(0, 200, 83, 0.12);
}

/* --- Smooth page transitions --- */
.section.active {
    animation: fadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Keyboard shortcut hint --- */
.kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 10px;
    font-family: 'Inter', monospace;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    line-height: 1.4;
}

/* --- System Health Cards --- */
.health-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    transition: all 0.25s ease;
}

.health-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.health-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.health-icon.healthy {
    background: rgba(0, 200, 83, 0.12);
}

.health-icon.warning {
    background: rgba(255, 193, 7, 0.15);
}

.health-icon.critical {
    background: rgba(244, 67, 54, 0.15);
}

.health-info {
    flex: 1;
    min-width: 0;
}

.health-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.health-detail {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* --- Badge colors --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-green {
    background: rgba(0, 200, 83, 0.15);
    color: #00c853;
}

.badge-yellow {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
}

.badge-red {
    background: rgba(244, 67, 54, 0.15);
    color: #f44336;
}

/* ===== MODAL OVERLAY (Company Edit Popup) ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-overlay .modal-content {
    width: 100%;
    max-width: 860px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5), 0 0 40px var(--accent-glow);
    transform: translateY(20px) scale(0.97);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-content .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 2;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-content .modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-content .modal-header .modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-content .modal-header .modal-close:hover {
    background: rgba(244, 67, 54, 0.15);
    border-color: rgba(244, 67, 54, 0.3);
    color: var(--red);
    transform: rotate(90deg);
}

.modal-content .modal-body {
    padding: 24px;
}

.modal-content .modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid var(--glass-border);
    position: sticky;
    bottom: 0;
    background: var(--bg-card);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ===== COMPANY LIST TABLE ===== */
.company-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.company-list-header .search-box {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    flex: 1;
    max-width: 320px;
    transition: var(--transition);
}

.company-list-header .search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.company-list-header .search-box input {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    padding: 8px 0;
    outline: none;
    width: 100%;
}

.company-stats-bar {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.company-stats-bar .mini-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.company-stats-bar .mini-stat strong {
    color: var(--text-primary);
    font-weight: 700;
}

.company-table {
    width: 100%;
    border-collapse: collapse;
}

.company-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.02);
}

.company-table td {
    padding: 12px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

.company-table tr {
    transition: var(--transition);
}

.company-table tr:hover td {
    background: rgba(200, 80, 192, 0.04);
}

.company-table .company-name-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.company-table .company-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
}

.company-table .company-name-info h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.company-table .company-name-info span {
    font-size: 11px;
    color: var(--text-muted);
    font-family: monospace;
}

.company-table .company-actions {
    display: flex;
    gap: 4px;
}

.company-table .company-actions button {
    opacity: 0.6;
    transition: var(--transition);
}

.company-table tr:hover .company-actions button {
    opacity: 1;
}

/* Modal scrollbar */
.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
    background: rgba(200, 80, 192, 0.3);
    border-radius: 3px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: rgba(200, 80, 192, 0.5);
}

/* ===== MOBILE RESPONSIVE ===== */

/* Mobile hamburger toggle (hidden on desktop) */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.mobile-menu-toggle:active {
    transform: scale(0.92);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
    opacity: 1;
}

/* ===== TABLET (≤ 768px) ===== */
@media (max-width: 768px) {

    /* Show hamburger as a floating overlay button (full sidebar drawer trigger) */
    .mobile-menu-toggle {
        display: flex;
        position: fixed;
        top: 8px;
        right: 8px;
        left: auto;
        z-index: 1001;
        width: 40px;
        height: 40px;
        border-radius: 12px;
        background: rgba(20, 20, 35, 0.85);
        border: 1px solid rgba(124, 58, 237, 0.35);
        color: var(--text-primary);
        font-size: 20px;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), 0 0 12px rgba(124, 58, 237, 0.18);
        backdrop-filter: blur(8px);
        will-change: transform;
        transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-menu-toggle:active {
        transform: scale(0.92);
    }

    /* Sidebar: bottom tabbar by default; full drawer when .mobile-open */
    .sidebar {
        width: 100% !important;
        height: 60px !important;
        max-height: 60px !important;
        overflow: visible !important;
        position: fixed !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        z-index: 1000 !important;
        flex-direction: row !important;
        transform: translate3d(0, 0, 0);
        transition: max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1) !important;
        border-right: none !important;
        border-top: 1px solid rgba(124, 58, 237, 0.25) !important;
        border-bottom: none !important;
        box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5) !important;
        will-change: max-height;
        contain: layout style;
        backface-visibility: hidden;
        padding: 0 !important;
    }

    .sidebar.mobile-open {
        max-height: 100vh !important;
        height: 100vh !important;
        flex-direction: column !important;
        overflow-y: auto !important;
    }

    /* Header & footer hidden when collapsed (tabbar mode) */
    .sidebar-header,
    .sidebar-footer {
        display: none;
    }

    .sidebar.mobile-open .sidebar-header {
        display: flex;
        padding: 14px 16px;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        text-align: left;
    }

    .sidebar.mobile-open .sidebar-footer {
        display: block;
        padding: 10px 16px;
        border-top: 1px solid var(--glass-border);
    }

    .sidebar-header .brand-sub,
    .sidebar-header .brand-mascot {
        display: none;
    }

    /* Tabbar: horizontal scroll of nav-items */
    .sidebar-nav {
        display: flex;
        flex-direction: row;
        flex: 1;
        gap: 0;
        padding: 0;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
    }

    .sidebar-nav::-webkit-scrollbar {
        display: none;
    }

    .sidebar.mobile-open .sidebar-nav {
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 4px 0 8px;
    }

    .sidebar-nav>div[style*="border-top"] {
        display: none;
    }

    .sidebar.mobile-open .sidebar-nav>div[style*="border-top"] {
        display: block;
    }

    /* Tabbar item: icon-on-top, label below, equal touch targets */
    .nav-item {
        flex-direction: column;
        gap: 2px;
        padding: 8px 14px;
        min-width: 72px;
        font-size: 10px;
        font-weight: 600;
        text-align: center;
        border-left: none !important;
        border-bottom: 2px solid transparent;
        scroll-snap-align: start;
        white-space: nowrap;
        justify-content: center;
    }

    .nav-item .icon {
        font-size: 18px;
        margin: 0;
    }

    .nav-item.active {
        border-left: none !important;
        border-bottom-color: var(--accent);
        background: rgba(200, 80, 192, 0.12);
        color: var(--accent);
    }

    .sidebar.mobile-open .nav-item {
        flex-direction: row;
        gap: 10px;
        padding: 12px 20px;
        min-width: 0;
        font-size: 13px;
        text-align: left;
        border-bottom: none;
        justify-content: flex-start;
    }

    .sidebar.mobile-open .nav-item.active {
        border-bottom: none;
    }

    .sidebar.mobile-open .nav-item .icon {
        font-size: 16px;
    }

    .sidebar .nav-item span:not(.icon) {
        display: inline !important;
    }

    /* Main content: full width, with bottom space for tabbar */
    .main-content {
        margin-left: 0 !important;
        padding: 56px 14px 76px;
    }

    /* Login page */
    .login-page {
        flex-direction: column;
    }

    .login-right {
        display: none;
    }

    .login-left {
        padding: 24px 16px;
    }

    .login-card {
        padding: 28px 20px;
        max-width: 100%;
    }

    /* Stats grid: clamp typography + responsive auto-fit, never overflow */
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
        gap: 10px;
        margin-bottom: 16px;
    }

    .stat-card {
        padding: 14px 14px;
        contain: layout style;
        min-width: 0;
    }

    .stat-card .stat-value {
        font-size: clamp(20px, 6.4vw, 26px);
        line-height: 1.15;
        word-break: break-word;
    }

    .stat-card .stat-label {
        font-size: 10px;
        letter-spacing: 0.6px;
    }

    .stat-card .stat-icon {
        font-size: 22px;
        margin-bottom: 4px;
    }

    .stat-card .stat-sub {
        font-size: 10px;
    }

    /* Operators grid */
    .operators-grid {
        grid-template-columns: 1fr !important;
    }

    /* Section headers */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .section-header h2 {
        font-size: 18px;
    }

    /* Tables: horizontal scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    /* Cards */
    .card {
        padding: 16px;
    }

    .card-body {
        padding: 16px;
    }

    /* Modals: full width on mobile */
    .modal,
    .modal-overlay .modal-content {
        width: 95% !important;
        max-width: 95vw !important;
        max-height: 90vh;
        margin: auto;
    }

    .modal-body {
        max-height: 60vh;
        overflow-y: auto;
    }

    /* Toast container — keep clear of bottom tabbar */
    #toastContainer {
        left: 12px !important;
        right: 12px !important;
        top: 60px !important;
        bottom: auto !important;
    }

    /* Plans grid */
    .plans-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    .plans-hero h1 {
        font-size: 26px !important;
    }

    .plans-container {
        padding: 24px 16px !important;
    }

    .plan-price {
        font-size: 32px !important;
    }

    /* Chat layout */
    .chat-container {
        flex-direction: column;
    }

    .chat-sidebar {
        width: 100% !important;
        height: auto;
        max-height: 40vh;
        position: relative !important;
    }

    .chat-main {
        flex: 1;
    }

    /* Company table responsive */
    .company-table {
        font-size: 12px;
    }

    /* Charts */
    canvas {
        max-height: 250px;
    }

    /* Onboarding overlay */
    #onboardingCard {
        width: 96% !important;
        max-width: 96vw !important;
        border-radius: 16px !important;
    }

    /* PIX modal */
    .pix-card {
        width: 95% !important;
        padding: 24px 16px !important;
    }
}

/* ===== PHONE (≤ 480px) ===== */
@media (max-width: 480px) {

    .mobile-menu-toggle {
        top: 8px;
        right: 8px;
        left: auto;
        width: 38px;
        height: 38px;
        font-size: 18px;
    }

    .main-content {
        padding: 52px 10px 76px !important;
    }

    /* Tabbar: tighter spacing on small phones */
    .nav-item {
        min-width: 64px;
        padding: 8px 10px;
    }

    .nav-item .icon {
        font-size: 17px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)) !important;
    }

    .section-header h2 {
        font-size: 16px;
    }

    .card {
        border-radius: 10px;
    }

    .login-card {
        padding: 24px 16px;
    }

    .login-card .logo {
        font-size: 24px;
    }

    /* Smaller modals */
    .modal,
    .modal-overlay .modal-content {
        width: 98% !important;
        border-radius: 12px !important;
    }

    .modal-body {
        padding: 12px !important;
    }

    /* Plans */
    .plan-card {
        padding: 20px 16px !important;
    }

    .plan-price {
        font-size: 28px !important;
    }

    .plans-hero h1 {
        font-size: 22px !important;
    }

    /* Onboarding */
    #onboardingCard {
        border-radius: 12px !important;
        max-height: 95vh !important;
    }

    .ob-title {
        font-size: 18px !important;
    }

    .ob-icon {
        font-size: 36px !important;
    }

    /* Register page */
    .register-card {
        padding: 24px 16px !important;
    }
}

/* ===== EXTRA SMALL (≤ 360px) ===== */
@media (max-width: 360px) {

    .main-content {
        padding: 48px 8px 72px !important;
    }

    /* Tabbar: hide labels, keep icons (smallest screens) */
    .sidebar:not(.mobile-open) .nav-item span:not(.icon) {
        display: none !important;
    }

    .nav-item {
        min-width: 54px;
        padding: 8px 8px;
    }

    .login-card .logo {
        font-size: 20px;
    }

    .btn {
        font-size: 12px;
        padding: 8px 12px;
    }
}

/* ===== LANDSCAPE PHONE ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .login-left {
        padding: 12px;
    }

    .login-card {
        padding: 16px;
    }

    .sidebar {
        padding-top: 0;
    }

    .sidebar-header {
        padding: 12px 16px;
    }
}

/* =============================================================
   ===== SHARED UI UTILITIES (added by frontend audit) =========
   ============================================================= */

/* ----- Skeleton loaders ----- */
@keyframes sk-shimmer {
    0% { background-position: -480px 0; }
    100% { background-position: 480px 0; }
}

.skeleton {
    display: inline-block;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.04) 0%,
            rgba(255, 255, 255, 0.10) 50%,
            rgba(255, 255, 255, 0.04) 100%);
    background-size: 480px 100%;
    animation: sk-shimmer 1.4s linear infinite;
    border-radius: 6px;
    height: 14px;
    width: 100%;
    vertical-align: middle;
}

.skeleton.skeleton-line { height: 12px; margin: 6px 0; }
.skeleton.skeleton-line.short { width: 40%; }
.skeleton.skeleton-line.medium { width: 70%; }
.skeleton.skeleton-block { height: 60px; border-radius: 10px; }
.skeleton.skeleton-circle { width: 40px; height: 40px; border-radius: 50%; }
.skeleton.skeleton-row { height: 36px; margin: 4px 0; border-radius: 8px; }

.skeleton-table {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 0;
}

.skeleton-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ----- Empty / Error states (consistent across modules) ----- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 36px 18px;
    color: var(--text-muted);
    gap: 6px;
}

.empty-state .empty-icon {
    font-size: 42px;
    opacity: 0.35;
    line-height: 1;
    margin-bottom: 4px;
}

.empty-state .empty-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.empty-state .empty-sub {
    font-size: 12px;
    color: var(--text-muted);
    max-width: 380px;
    line-height: 1.5;
}

.empty-state.compact { padding: 18px 12px; }
.empty-state.compact .empty-icon { font-size: 30px; }

.empty-state.error .empty-icon { color: var(--red); opacity: 0.7; }
.empty-state.error .empty-title { color: var(--red); }

.empty-state .empty-action {
    margin-top: 10px;
}

/* Empty / loading / error rows inside <table><tbody> */
tbody .table-empty td,
tbody .table-loading td,
tbody .table-error td {
    text-align: center;
    padding: 28px 12px !important;
    color: var(--text-muted);
    font-size: 12px;
    background: rgba(255, 255, 255, 0.01);
}
tbody .table-error td { color: var(--red); }

/* ----- Inline spinner ----- */
@keyframes sk-spin { to { transform: rotate(360deg); } }
.sk-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(200, 80, 192, 0.18);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: sk-spin 0.85s linear infinite;
    vertical-align: middle;
}
.sk-spinner.lg { width: 28px; height: 28px; border-width: 3px; }

/* ----- Scroll-to-bottom floating button (chat) ----- */
.scroll-to-bottom-btn {
    position: absolute;
    right: 14px;
    bottom: 78px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(20, 20, 35, 0.92);
    color: var(--text-primary);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    transition: var(--transition);
    font-size: 16px;
}
.scroll-to-bottom-btn:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(99, 102, 241, 0.5);
    transform: translateY(-2px);
}
.scroll-to-bottom-btn.visible { display: flex; }
.scroll-to-bottom-btn .unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 6px;
    min-width: 16px;
    text-align: center;
}

/* ----- Toast tweaks: ensure container stacks consistently ----- */
#toastContainer { pointer-events: none; }
#toastContainer > * { pointer-events: auto; }

/* On smaller screens, toasts span full width but capped */
@media (max-width: 480px) {
    .toast-msg { max-width: calc(100vw - 24px) !important; min-width: 0 !important; }
}

/* ----- Generic modal-overlay safety nets ----- */
.modal-overlay[hidden] { display: none !important; }

/* When opened with .active toggle (not display flex inline), align children */
.modal-overlay .modal-content.modal-narrow { max-width: 520px; }
.modal-overlay .modal-content.modal-wide { max-width: 1100px; }

/* Modal body scroll polish */
.modal-overlay .modal-content .modal-body {
    overflow-y: auto;
}

/* Improve modal-close target on mobile */
@media (max-width: 480px) {
    .modal-content .modal-header .modal-close {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
}

/* ----- Sortable table header styling ----- */
table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 22px !important;
    transition: color 0.15s;
}
table th.sortable:hover { color: var(--accent); }
table th.sortable::after {
    content: '⇅';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.35;
    font-size: 11px;
}
table th.sortable.sort-asc::after { content: '▲'; opacity: 0.95; color: var(--accent); }
table th.sortable.sort-desc::after { content: '▼'; opacity: 0.95; color: var(--accent); }

/* ----- Mobile chat modal (operator-panel) ----- */
@media (max-width: 768px) {
    #chatModal > div {
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        height: 100dvh !important;
        border-radius: 0 !important;
    }
    #chatToolbar { gap: 4px !important; padding: 6px 10px !important; }
    #chatToolbar button { font-size: 11px !important; padding: 4px 8px !important; }
    #toolsCheatsheetGrid { grid-template-columns: 1fr !important; }
    #aiPreviewModal > div { padding: 0 8px !important; }
    #aiPreviewModal [style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* =============================================================
   ===== PERFORMANCE & FLUIDITY (mirrors ai-chat-widget.js) =====
   ============================================================= */

/* GPU-promote big animated/positioned containers — avoid CPU fallbacks */
.sidebar,
.modal-overlay .modal-content,
.scroll-to-bottom-btn {
    will-change: transform;
    backface-visibility: hidden;
    transform: translate3d(0, 0, 0);
}

/* Long lists: hide off-screen items from layout/paint
   (matches the .yc-msg pattern from ai-chat-widget.js) */
.conversation-item,
#chatMessages > div,
#opsScheduledBody tr,
#opsCheckoutsBody tr,
#opsAuctionsBody tr,
#leadsTable tbody tr,
.message,
.lead-row {
    content-visibility: auto;
    contain-intrinsic-size: auto 64px;
    contain: layout style;
}

/* Containment on layout-bound regions (cards, sections, sidebars) */
.card,
.stat-card,
.health-card,
.operator-card,
.section.active,
.main-content {
    contain: layout style;
}

/* Sidebar slide animation as transform (already !important elsewhere; this
   is a no-op where transform is overridden, but ensures GPU on hover/tap) */
.sidebar.mobile-open {
    transform: translate3d(0, 0, 0);
}

/* Drop expensive blurs on mobile (keep on desktop where it's cheap-ish) */
@media (max-width: 768px) {
    .modal,
    .modal-overlay,
    .yuji-tooltip,
    .toast-msg,
    .scroll-to-bottom-btn {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    /* Compensate readability with a slightly more opaque solid bg */
    .modal-overlay {
        background: rgba(0, 0, 0, 0.78) !important;
    }
    .modal,
    .modal-overlay .modal-content {
        background: rgba(20, 18, 38, 0.98) !important;
    }
}

/* Reduced-motion: respect user OS preference, kill heavy animations */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.05s !important;
        scroll-behavior: auto !important;
    }
    .jjk-loading-overlay .domain-circle,
    .live-dot.online,
    .live-dot.connecting {
        animation: none !important;
    }
}

/* Keep scrollable regions from rubber-banding into the page */
.table-container,
#chatMessages,
.sidebar-nav,
.modal-content,
.modal-body {
    overscroll-behavior: contain;
}