:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --secondary: #64748b;
    --bg-dark: #0f172a;
    --card-bg: #1e293b;
    --sidebar-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --glass-blur: none;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --input-bg: #0f172a;
    --input-bg-focus: #1e293b;
    --hover-bg: #334155;
    --title-grad: #f8fafc;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    color-scheme: dark;
}

[data-theme="light"] {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --bg-dark: #f8fafc;
    --card-bg: #ffffff;
    --sidebar-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #2563eb;
    --input-bg: #ffffff;
    --input-bg-focus: #f8fafc;
    --hover-bg: #f1f5f9;
    --title-grad: #0f172a;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    color-scheme: light;
}

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: 'Inter', sans-serif;
            background-color: var(--bg-dark);
            color: var(--text-main);
            min-height: 100vh;
            display: flex;
            overflow: hidden;
        }

/* Animated Background Removed for solid Admin feel */
.bg-gradient {
    display: none;
}

        h1,
        h2,
        h3,
        .card-title {
            font-family: 'Outfit', sans-serif;
        }

        /* Login Screen */
        #loginScreen {
            position: fixed;
            inset: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            background: rgba(0, 0, 0, 0.8);
            z-index: 1000;
            backdrop-filter: blur(10px);
        }

.login-card {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
    text-align: center;
}

.login-card h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--title-grad);
}

        .login-card p {
            color: var(--text-muted);
            margin-bottom: 2rem;
        }

        input,
        select {
            width: 100%;
            background: var(--input-bg);
            border: 1px solid var(--border-color);
            color: var(--text-main);
            padding: 1rem 1.25rem;
            border-radius: 12px;
            font-size: 1rem;
            transition: all 0.3s ease;
            outline: none;
            margin-bottom: 1rem;
            box-shadow: 0 1px 2px rgba(0,0,0,0.05);
        }

        select {
            appearance: none;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 1rem center;
            background-size: 1.2em;
            padding-right: 2.5rem;
        }

        input:focus,
        select:focus {
            border-color: var(--primary);
            background: var(--input-bg-focus);
            box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
        }

        .dashboard-filter {
            width: 250px !important;
            margin-bottom: 0 !important;
            background: var(--input-bg);
        }

button {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.85rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

button:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

        button:disabled {
            opacity: 0.7;
            cursor: not-allowed;
            transform: none;
        }

        /* Main App Layout */
        #appContainer {
            display: none;
            width: 100%;
            height: 100vh;
        }

        .sidebar {
            width: 260px;
            background: var(--sidebar-bg);
            border-right: 1px solid var(--border-color);
            backdrop-filter: var(--glass-blur);
            padding: 2rem 1rem;
            display: flex;
            flex-direction: column;
            transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            overflow: visible;
            flex-shrink: 0;
            position: relative;
        }

        .sidebar.collapsed {
            width: 76px;
            padding: 2rem 0.5rem;
        }

        .sidebar.collapsed .sidebar-title {
            opacity: 0;
            width: 0;
            display: none;
        }

        .sidebar.collapsed .sidebar-header {
            padding-left: 0;
            justify-content: center !important;
            flex-direction: column;
            gap: 1.5rem !important;
        }

        .sidebar.collapsed .sidebar-header > div {
            justify-content: center;
        }

        .sidebar.collapsed .nav-text,
        .sidebar.collapsed .sidebar-footer {
            display: none;
        }

        .sidebar.collapsed .nav-item {
            justify-content: center;
            padding: 1rem 0;
        }

        .sidebar.collapsed .sidebar-status-card {
            padding: 0.85rem 0;
            justify-content: center;
        }

        .sidebar.collapsed .sidebar-status-card span:not(.status-pulse-dot) {
            display: none !important;
        }

        .sidebar.collapsed .user-info {
            display: none !important;
        }

        .sidebar.collapsed .user-profile {
            padding: 12px 0;
            justify-content: center;
        }

        .collapse-btn {
            position: absolute;
            top: 2rem;
            right: -12px;
            width: 24px;
            height: 24px;
            background: var(--sidebar-bg);
            border: 1px solid var(--border-color);
            color: var(--text-muted);
            cursor: pointer;
            padding: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: transform 0.3s ease, background 0.2s ease, color 0.2s ease;
            border-radius: 50%;
            z-index: 100;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        
        .sidebar.collapsed .collapse-btn {
            transform: rotate(180deg);
        }

        .collapse-btn:hover {
            background: var(--primary);
            color: white;
            border-color: var(--primary);
        }

        .sidebar-header {
            margin-bottom: 2.5rem;
            padding-left: 1rem;
        }

        .sidebar-header h2 {
            font-size: 1.5rem;
            color: var(--text-main);
            font-weight: 700;
        }

        .nav-item {
            padding: 1rem;
            color: var(--text-muted);
            font-weight: 500;
            cursor: pointer;
            border-radius: 12px;
            transition: all 0.2s;
            margin-bottom: 0.5rem;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .nav-item:hover {
            background: var(--hover-bg);
            color: var(--text-main);
        }

        .nav-item.active {
            background: var(--primary);
            color: white;
            font-weight: 600;
            box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
        }

        .sidebar-status-card {
            margin: 0.75rem 0;
            padding: 0.85rem 1rem;
            background: rgba(16, 185, 129, 0.06);
            border: 1px solid rgba(16, 185, 129, 0.2);
            border-radius: 14px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            cursor: pointer;
            transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
        }

        .sidebar-status-card:hover {
            background: rgba(16, 185, 129, 0.14);
            border-color: rgba(16, 185, 129, 0.4);
            transform: translateY(-1px);
            box-shadow: 0 4px 14px rgba(16, 185, 129, 0.15);
        }

        .status-pulse-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            position: relative;
            display: inline-block;
            flex-shrink: 0;
        }

        .status-pulse-dot.green {
            background-color: #10b981;
            box-shadow: 0 0 10px rgba(16, 185, 129, 0.8);
        }

        .status-pulse-dot.green::after {
            content: '';
            position: absolute;
            top: -4px;
            left: -4px;
            right: -4px;
            bottom: -4px;
            border-radius: 50%;
            border: 2px solid #10b981;
            animation: statusPulseGreen 2s infinite ease-in-out;
            opacity: 0.8;
        }

        .status-pulse-dot.red {
            background-color: #ef4444;
            box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
        }

        .status-pulse-dot.red::after {
            content: '';
            position: absolute;
            top: -4px;
            left: -4px;
            right: -4px;
            bottom: -4px;
            border-radius: 50%;
            border: 2px solid #ef4444;
            animation: statusPulseRed 2s infinite ease-in-out;
            opacity: 0.8;
        }

        @keyframes statusPulseGreen {
            0% { transform: scale(0.7); opacity: 0.9; }
            50% { transform: scale(1.6); opacity: 0; }
            100% { transform: scale(0.7); opacity: 0; }
        }

        @keyframes statusPulseRed {
            0% { transform: scale(0.7); opacity: 0.9; }
            50% { transform: scale(1.6); opacity: 0; }
            100% { transform: scale(0.7); opacity: 0; }
        }

        /* Floating Instatus Widget */
        .instatus-floating-widget {
            position: fixed;
            bottom: 24px;
            right: 24px;
            z-index: 9999;
            background: #090d16;
            border: 1px solid rgba(255, 255, 255, 0.18);
            border-radius: 14px;
            box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 15px rgba(16, 185, 129, 0.15);
            padding: 10px 16px;
            min-width: 240px;
            cursor: pointer;
            transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
            backdrop-filter: blur(12px);
            box-sizing: border-box;
        }

        .instatus-floating-widget:hover {
            border-color: rgba(16, 185, 129, 0.45);
            transform: translateY(-2px);
            box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(16, 185, 129, 0.25);
        }

        .instatus-widget-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
        }

        button.instatus-widget-btn {
            width: 26px !important;
            min-width: 26px !important;
            max-width: 26px !important;
            height: 26px !important;
            min-height: 26px !important;
            max-height: 26px !important;
            padding: 0 !important;
            margin: 0 !important;
            background: rgba(255, 255, 255, 0.12) !important;
            border: 1px solid rgba(255, 255, 255, 0.2) !important;
            border-radius: 6px !important;
            display: inline-flex !important;
            align-items: center !important;
            justify-content: center !important;
            cursor: pointer !important;
            box-shadow: none !important;
            transition: all 0.2s ease !important;
            flex-shrink: 0 !important;
        }

        button.instatus-widget-btn:hover {
            background: rgba(255, 255, 255, 0.25) !important;
            border-color: rgba(255, 255, 255, 0.4) !important;
            box-shadow: none !important;
        }

        button.instatus-widget-btn svg {
            width: 12px !important;
            height: 12px !important;
            stroke: #ffffff !important;
            display: block !important;
        }

        .instatus-floating-widget.minimized {
            min-width: auto;
            padding: 8px 14px;
            border-radius: 24px;
        }
        .instatus-floating-widget.minimized #floatingWidgetText {
            display: none;
        }

        .sidebar-footer {
            margin-top: auto;
            padding: 1rem 0 0 0;
            display: flex;
            gap: 10px;
            align-items: center;
        }

        .logout-btn {
            background: transparent;
            color: var(--danger);
            border: 1px solid var(--danger);
            height: 48px;
            width: 48px;
            border-radius: 24px;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            box-shadow: none;
            flex-shrink: 0;
            cursor: pointer;
        }

        .logout-btn:hover {
            background: rgba(239, 68, 68, 0.1);
            box-shadow: none;
        }

        /* Main Content Area */
        .content-area {
            flex: 1;
            padding: 2.5rem;
            overflow-y: auto;
            overflow-x: hidden;
            scroll-behavior: smooth;
            display: flex;
            flex-direction: column;
            min-width: 0;
        }

        .top-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
            width: 100%;
        }

        .page-title {
            font-size: 2rem;
            font-weight: 700;
            margin: 0;
            letter-spacing: -0.02em;
        }
        
        .btn-refresh {
            background: rgba(79, 70, 229, 0.1) !important;
            color: var(--primary) !important;
            border: 1px solid rgba(79, 70, 229, 0.2) !important;
            font-weight: 600;
            box-shadow: none !important;
            transition: all 0.2s ease !important;
        }
        
        .btn-refresh:hover {
            background: var(--primary) !important;
            color: white !important;
            box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3) !important;
            transform: translateY(-1px);
        }

        .section {
            display: none;
            animation: slideUp 0.4s ease forwards;
        }

        .section.active {
            display: block;
        }

        @keyframes slideUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        /* Dashboard Grid */
        .kpi-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 1.5rem;
        }

        .dashboard-grid > div, .kpi-grid > div, .glos-grid > div, .stream-grid > div, .challan-grid > div {
            min-width: 0;
        }

        .kpi-card {
            background: var(--card-bg);
            border-radius: 12px;
            padding: 1.75rem;
            border: 1px solid var(--border-color);
            transition: transform 0.2s, box-shadow 0.2s;
            box-shadow: var(--shadow);
        }

        .kpi-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        }

        .kpi-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1rem;
        }

        .kpi-title {
            font-size: 0.85rem;
            font-weight: 600;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }

        .kpi-value {
            font-size: 2.75rem;
            font-family: 'Outfit';
            font-weight: 700;
            line-height: 1;
        }

        .kpi-desc {
            font-size: 0.85rem;
            color: var(--text-muted);
            margin-top: 0.5rem;
        }

        .badge {
            padding: 0.25rem 0.75rem;
            border-radius: 99px;
            font-size: 0.7rem;
            font-weight: 600;
        }

        .badge.green {
            background: rgba(16, 185, 129, 0.15);
            color: var(--success);
        }

        .badge.yellow {
            background: rgba(245, 158, 11, 0.15);
            color: var(--warning);
        }

        .badge.red {
            background: rgba(239, 68, 68, 0.15);
            color: var(--danger);
        }

        .badge.blue {
            background: rgba(59, 130, 246, 0.15);
            color: var(--info);
        }

        /* Data Tables */
        .table-container {
            background: var(--card-bg);
            border-radius: 20px;
            border: 1px solid var(--border-color);
            overflow: hidden;
            backdrop-filter: var(--glass-blur);
            margin-top: 1.5rem;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            text-align: left;
        }

        th,
        td {
            padding: 1.25rem 1.5rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        }

        th {
            font-size: 0.85rem;
            font-weight: 600;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.05em;
            background: transparent; border-bottom: 2px solid var(--border-color);
        }

        tr:hover td {
            background: rgba(255, 255, 255, 0.02);
        }

        .status-badge {
            padding: 4px 10px;
            border-radius: 6px;
            font-size: 0.75rem;
            font-weight: 600;
        }

        .status-paid {
            background: rgba(16, 185, 129, 0.2);
            color: #6ee7b7;
            border: 1px solid rgba(16, 185, 129, 0.3);
        }

        .status-pending {
            background: rgba(245, 158, 11, 0.2);
            color: #fcd34d;
            border: 1px solid rgba(245, 158, 11, 0.3);
        }

        /* Toast Notifications */
        #toast {
            position: fixed;
            bottom: 30px;
            right: 30px;
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            padding: 1rem 1.5rem;
            border-radius: 12px;
            backdrop-filter: blur(10px);
            color: var(--text-main);
            transform: translateX(150%);
            transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            z-index: 9999;
        }

        #toast.show {
            transform: translateX(0);
        }
        .theme-toggle {
            width: 100%;
            height: 48px;
            border-radius: 24px;
            background: #000;
            cursor: pointer;
            position: relative;
            display: flex;
            align-items: center;
            box-sizing: border-box;
            margin-bottom: 0;
            overflow: hidden;
            flex: 1;
            transition: background 0.3s ease;
        }

        [data-theme="light"] .theme-toggle {
            background: #e5e5e5;
        }

        .theme-toggle-text {
            font-size: 14px;
            font-weight: 700;
            color: #fff;
            position: absolute;
            transition: opacity 0.3s ease;
            pointer-events: none;
            letter-spacing: 0.5px;
            font-family: 'Outfit', sans-serif;
        }

        .text-night {
            right: 15px;
            opacity: 1;
        }

        .text-day {
            left: 15px;
            opacity: 0;
            color: #000;
        }

        [data-theme="light"] .text-night {
            opacity: 0;
        }

        [data-theme="light"] .text-day {
            opacity: 1;
        }

        .theme-toggle-thumb {
            width: 40px;
            height: 40px;
            background: #fff;
            border-radius: 50%;
            position: absolute;
            left: 4px;
            transition: left 0.3s ease;
            display: flex;
            justify-content: center;
            align-items: center;
            box-shadow: 0 1px 3px rgba(0,0,0,0.2);
        }

        [data-theme="light"] .theme-toggle-thumb {
            left: calc(100% - 44px);
            box-shadow: inset 0 0 0 1px #ccc, 0 1px 3px rgba(0,0,0,0.1);
        }

        .icon-moon,
        .icon-sun {
            width: 22px;
            height: 22px;
            position: absolute;
            transition: opacity 0.3s ease;
        }

        .icon-moon {
            opacity: 1;
        }

        .icon-sun {
            opacity: 0;
        }

        [data-theme="light"] .icon-moon {
            opacity: 0;
        }

        [data-theme="light"] .icon-sun {
            opacity: 1;
        }




.segmented-control {
    display: inline-flex; 
    background: var(--hover-bg); 
    padding: 4px; 
    border-radius: 10px; 
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
    min-height: 42px;
}
.toggle-btn {
    border: none; 
    padding: 0 20px; 
    border-radius: 6px; 
    font-size: 14px;
    font-weight: 500; 
    cursor: pointer; 
    transition: all 0.2s ease;
    background: transparent !important;
    color: var(--text-muted) !important;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
}
.toggle-btn:hover {
    color: var(--text-main) !important;
    background: var(--hover-bg) !important;
}
.toggle-btn.active {
    background: var(--primary) !important;
    color: white !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}


/* Stream Status Monitor Specific Styles */
.search-wrapper {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0 12px;
    height: 40px;
    margin-bottom: 1rem;
    width: 100%;
    transition: border-color 0.2s;
}

.search-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-wrapper svg {
    color: var(--text-muted);
    flex-shrink: 0;
    margin-right: 10px;
}

.search-wrapper input {
    border: none !important;
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100%;
    height: 100%;
    font-size: 14px;
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
}

/* Super compact KPI cards for detail view */
#streamAssetContainer .kpi-card {
    padding: 0.75rem 1.25rem !important;
}

#streamAssetContainer .kpi-card h3 {
    font-size: 0.85rem !important;
    margin-bottom: 0.25rem !important;
}

#streamAssetContainer .kpi-value {
    font-size: 1.5rem !important;
}

/* Custom Multi-Select */
.custom-multi-select {
    position: relative;
    width: 100%;
    user-select: none;
}
.custom-multi-select .select-box {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.85rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-main);
    font-size: 0.95rem;
}
.custom-multi-select .dropdown-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 4px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
.custom-multi-select.open .dropdown-options {
    display: block;
}
.custom-multi-select .option {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9rem;
    color: var(--text-main);
}
.custom-multi-select .option:hover {
    background: var(--hover-bg);
}
.custom-multi-select input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    margin: 0;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-muted);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive Design Overrides */
.mobile-header {
    display: none; /* hidden on desktop */
}

.sidebar-overlay {
    display: none; /* hidden on desktop */
}

.token-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.token-grid > div:last-child {
    grid-column: span 2;
}

@media (max-width: 1024px) {
    /* Main Layout */
    #appContainer {
        flex-direction: column !important;
    }

    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem;
        background: var(--sidebar-bg);
        border-bottom: 1px solid var(--border-color);
        z-index: 990;
    }

    .hamburger-btn {
        background: transparent;
        color: var(--text-main);
        border: none;
        padding: 0.5rem;
        width: auto;
        box-shadow: none;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .hamburger-btn:hover {
        background: var(--hover-bg);
        box-shadow: none;
    }

    /* Sidebar as an Overlay Drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px; /* hidden off-screen */
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.5);
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        backdrop-filter: blur(2px);
        z-index: 995;
        display: none; /* toggled via JS */
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Content Area */
    .content-area {
        flex: 1;
        padding: 2.5rem;
        overflow-y: auto;
        overflow-x: hidden;
        scroll-behavior: smooth;
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    /* Grids */
    .kpi-grid,
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    .stream-grid {
        grid-template-columns: 1fr !important;
    }

    /* Modals */
    .modal-content,
    #analyticsRowModal > div,
    #challanManagementModal > div {
        padding: 1rem !important;
        margin: 1rem;
        width: calc(100% - 2rem) !important;
    }

    /* Tables */
    .table-responsive,
    #assetsTableContainer {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }

    /* Action Headers (like Asset Manager's top bar) */
    .action-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 1rem;
    }

    .top-bar {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }
    
    .top-bar > div {
        width: 100%;
        flex-direction: column;
        align-items: stretch !important;
    }
    
    .dashboard-filter {
        width: 100% !important;
        max-width: none !important;
    }

    .search-box {
        width: 100% !important;
        max-width: none !important;
    }

    .token-grid {
        grid-template-columns: 1fr !important;
    }
    
    .token-grid > div {
        grid-column: span 1 !important;
    }
    
    .segmented-control {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        display: flex;
    }
    
    .segmented-control::-webkit-scrollbar {
        display: none;
    }
}

/* --- Premium User Widget Redesign --- */
.user-widget {
    margin-top: auto;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    position: relative;
    overflow: hidden;
}

.user-widget::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 100%;
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.03) 0%, transparent 100%);
    pointer-events: none;
}

.user-widget:hover {
    border-color: var(--primary);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    transform: translateY(-2px);
}

.user-widget-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-widget .user-avatar {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    position: relative;
}

.user-widget .user-avatar::after {
    content: '';
    position: absolute;
    bottom: -2px; right: -2px;
    width: 12px; height: 12px;
    background: #10b981;
    border: 2px solid var(--card-bg);
    border-radius: 50%;
}

.user-widget .user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.user-widget #userNameDisplay {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-widget #userRoleDisplay {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-top: 2px;
}

.user-widget #userEmailDisplay {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.8;
    margin-top: 2px;
}

.user-widget-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.user-widget-actions .theme-toggle.mini {
    width: 100%;
    height: 38px;
    border-radius: 10px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: all 0.2s ease;
}

.user-widget-actions .theme-toggle.mini:hover {
    background: var(--hover-bg);
    border-color: var(--primary);
}

.user-widget-actions .theme-toggle.mini .theme-toggle-thumb {
    width: auto; height: auto;
    background: transparent;
    box-shadow: none;
    position: static;
    transform: none !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-widget-actions .theme-toggle.mini svg {
    width: 18px; height: 18px;
    stroke: var(--text-main);
}

[data-theme="light"] .user-widget-actions .theme-toggle.mini svg {
    stroke: var(--text-main);
}

.user-widget-actions .theme-toggle.mini .icon-moon { display: block; }
.user-widget-actions .theme-toggle.mini .icon-sun { display: none; }
[data-theme="light"] .user-widget-actions .theme-toggle.mini .icon-moon { display: none; }
[data-theme="light"] .user-widget-actions .theme-toggle.mini .icon-sun { display: block; }

.user-widget-actions .logout-btn.mini {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}

.user-widget-actions .logout-btn.mini:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.sidebar.collapsed .user-widget {
    padding: 8px;
    border-radius: 12px;
}
.sidebar.collapsed .user-widget-main .user-info { display: none; }
.sidebar.collapsed .user-widget-main .user-avatar::after { border-color: transparent; }
.sidebar.collapsed .user-widget-actions { display: none; }

/* Mobile Enhancements */
@media (max-width: 768px) {
    .content-area {
        padding: 1rem;
    }
    .dashboard-grid, .stream-grid, .glos-grid, .challan-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    .kpi-card {
        padding: 0.75rem !important;
    }
    .kpi-card h3 {
        font-size: 0.85rem !important;
        margin-bottom: 0.5rem !important;
    }
    .kpi-value {
        font-size: 1.25rem !important;
    }
    h2, h3 {
        font-size: 1.1rem !important;
    }
    .action-header, .top-bar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 1rem;
    }
    .action-header button:not(.btn-icon), .top-bar button:not(.btn-icon), .action-header input, .top-bar input, .top-bar select, .top-bar-controls {
        width: 100% !important;
        max-width: none !important;
        flex-direction: column !important;
        justify-content: stretch !important;
    }
    .table-responsive, .table-container {
        white-space: nowrap;
        overflow-x: auto;
    }
    .dashboard-grid > div, .kpi-grid > div, .glos-grid > div, .stream-grid > div, .challan-grid > div {
        min-width: 0;
    }
    #ownerDetailsContent, #analyticsChartContainer, #alertMessageText {
        grid-template-columns: 1fr !important;
    }
}
