:root {
    --bg-color: #080e1e;
    --surface: #111827;
    --surface-elevated: rgba(30, 41, 59, 0.75);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-color: #818cf8;
    --accent-hover: #6366f1;
    --accent-glow: rgba(129, 140, 248, 0.3);
    --accent-subtle: rgba(129, 140, 248, 0.08);
    --glass-bg: rgba(17, 24, 39, 0.6);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
    --success-color: #22c55e;
    --success-glow: rgba(34, 197, 94, 0.25);
    --warning-color: #eab308;
    --error-color: #ef4444;
    --sidebar-width: 240px;
    --bottom-nav-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

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

body {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Dynamic Animated Background */
.background-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.25) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.2) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.15) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(99, 102, 241, 0.15) 0px, transparent 50%);
    filter: blur(60px);
    animation: pulseBG 15s ease-in-out infinite alternate;
}

@keyframes pulseBG {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

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

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

/* Glass Header */
.glass-header {
    background: rgba(8, 14, 30, 0.5);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    box-shadow: var(--glass-shadow);
    margin-bottom: 2rem;
}

.header-main-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: drop-shadow(0 0 10px var(--accent-glow));
}

.logo i {
    font-size: 1.4rem;
    color: var(--accent-color);
    filter: drop-shadow(0 0 10px var(--accent-glow));
}

.logo h1 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.4px;
    background: linear-gradient(135deg, #f1f5f9, var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo i {
    font-size: 2rem;
    color: var(--accent-color);
    filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.5));
}

.logo h1 {
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.5px;
}

.header-title-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.header-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.4px;
    background: linear-gradient(135deg, #f1f5f9, var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-subtitle {
    font-size: 0.65rem;
    color: var(--text-muted);
    line-height: 1.2;
    margin-top: 1px;
}

@media (min-width: 769px) {
    .header-title {
        font-size: 1.5rem;
    }
    .header-subtitle {
        font-size: 0.75rem;
    }
}

/* ==========================================
   LAYOUT: Sidebar + Content
   ========================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: rgba(8, 14, 30, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    z-index: 900;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
    padding: 1.25rem 1.25rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-header i {
    font-size: 1.4rem;
    color: var(--accent-color);
    filter: drop-shadow(0 0 10px var(--accent-glow));
}

.sidebar-header span {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, var(--accent-color), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav a, .sidebar-nav button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    background: none;
    border: none;
    font-size: 0.875rem;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    width: 100%;
    text-align: left;
    position: relative;
}

.sidebar-nav a i, .sidebar-nav button i {
    width: 1.25rem;
    text-align: center;
    font-size: 1rem;
    transition: transform var(--transition-fast);
}

.sidebar-nav a:hover, .sidebar-nav button:hover {
    background: var(--accent-subtle);
    color: var(--text-primary);
}

.sidebar-nav a:hover i, .sidebar-nav button:hover i {
    transform: translateX(2px);
}

.sidebar-nav a.active, .sidebar-nav button.active {
    background: var(--accent-subtle);
    color: var(--accent-color);
    font-weight: 600;
}

.sidebar-nav a.active::before, .sidebar-nav button.active::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    border-radius: 0 3px 3px 0;
    background: var(--accent-color);
    box-shadow: 0 0 8px var(--accent-glow);
}

.sidebar-nav a.active i, .sidebar-nav button.active i {
    color: var(--accent-color);
}

.sidebar-nav .nav-logout-btn {
    color: var(--error-color);
    border-top: 1px solid var(--glass-border);
    margin-top: 0.5rem;
    padding-top: 1rem;
}

.sidebar-nav .nav-logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
}

.sidebar-section-label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0.75rem 0.9rem 0.25rem;
    opacity: 0.6;
}

.sidebar-footer {
    padding: 0.6rem;
    border-top: 1px solid var(--glass-border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    transition: background var(--transition-fast);
}

.sidebar-user:hover {
    background: rgba(255,255,255,0.03);
}

.sidebar-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 1.5rem 2rem 2rem;
    min-height: 100vh;
    max-width: 1400px;
}

/* ==========================================
   BOTTOM NAVIGATION (Mobile)
   ========================================== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--bottom-nav-height);
    background: rgba(8, 14, 30, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    z-index: 900;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav a, .bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.55rem;
    cursor: pointer;
    font-family: var(--font-sans);
    text-decoration: none;
    padding: 0.4rem 0.4rem;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
    min-width: 48px;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.bottom-nav a i, .bottom-nav button i {
    font-size: 1.2rem;
    transition: all var(--transition-fast);
}

.bottom-nav a:hover, .bottom-nav button:hover {
    color: var(--text-secondary);
}

.bottom-nav a.active, .bottom-nav button.active {
    color: var(--accent-color);
}

.bottom-nav a.active i, .bottom-nav button.active i {
    filter: drop-shadow(0 0 8px var(--accent-glow));
    transform: translateY(-1px);
}

.bottom-nav a.active::after, .bottom-nav button.active::after {
    content: '';
    position: absolute;
    top: 2px;
    width: 20px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--accent-color);
    box-shadow: 0 0 6px var(--accent-glow);
}

.bottom-nav a:active, .bottom-nav button:active {
    transform: scale(0.92);
}

#bnav-logout {
    color: var(--error-color);
}
#bnav-logout:hover {
    color: #fca5a5;
}

/* Mobile sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 800;
}

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

/* ==========================================
   SIDEBAR TOGGLE BUTTON (mobile)
   ========================================== */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.4rem;
}

/* ==========================================
   FLOATING ACTION BUTTON (Speed Dial)
   ========================================== */
.fab-accordion {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    animation: fabSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

@keyframes fabSlideIn {
    from { opacity: 0; transform: translateX(60px) scale(0.85); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

.fab-toggle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), #6366f1);
    border: none;
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 4px 20px var(--accent-glow);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.fab-toggle:hover {
    transform: scale(1.08);
}

.fab-toggle:active {
    transform: scale(0.92);
}

.fab-toggle i {
    transition: transform var(--transition-base);
}

.fab-accordion.expanded .fab-toggle i {
    transform: rotate(45deg);
}

.fab-menu-items {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.2s ease;
}

.fab-accordion.expanded .fab-menu-items {
    max-height: 150px;
    opacity: 1;
}

.fab-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: var(--glass-shadow);
    transition: all var(--transition-fast);
}

.fab-menu-item:hover {
    background: rgba(30, 41, 59, 0.85);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.fab-menu-item i {
    font-size: 1.1rem;
    color: var(--accent-color);
    flex-shrink: 0;
}

.fab-menu-text {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    line-height: 1.3;
}

.fab-menu-text span:last-child {
    font-size: 0.6rem;
    color: var(--accent-color);
    opacity: 0.85;
    font-weight: 500;
    letter-spacing: 0.3px;
}

@media (max-width: 768px) {
    .fab-accordion {
        top: 14px;
        right: 14px;
    }
    .fab-toggle {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: all var(--transition-base);
}

.dot.connected {
    background-color: var(--success-color);
    box-shadow: 0 0 8px var(--success-glow);
}

.dot.disconnected {
    background-color: var(--error-color);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.status-text {
    font-size: 0.75rem;
    margin-left: 6px;
    color: var(--text-muted);
}

/* Error Container */
.login-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.1rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    font-family: var(--font-sans);
}

.login-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.login-input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

/* Fix for select dropdown options in dark mode */
.login-input option {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper .login-input {
    padding-right: 2.8rem;
}

.toggle-password {
    position: absolute;
    right: 0.5rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    font-size: 1.1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

.toggle-password:hover {
    color: var(--text-primary);
}

.error-container {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    padding: 1rem;
    color: #fca5a5;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.device-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    letter-spacing: -0.3px;
}

/* Device Grid */
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

/* Glass Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.glass-panel:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
}

.device-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.device-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(129, 140, 248, 0.04), transparent 60%);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-base);
}

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

.success-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(16, 185, 129, 0.4);
}

.danger-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.danger-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(239, 68, 68, 0.4);
}

.device-icon-wrapper {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    background: rgba(255,255,255,0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.device-icon {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--accent-color);
    transition: all 0.3s ease;
}

/* Animation for active devices */
@keyframes pulse-glow {
    0% { transform: scale(1); filter: drop-shadow(0 0 2px var(--accent-color)); }
    50% { transform: scale(1.1); filter: drop-shadow(0 0 10px var(--accent-color)); }
    100% { transform: scale(1); filter: drop-shadow(0 0 2px var(--accent-color)); }
}

.device-card.active .device-icon {
    color: #6ee7b7; /* Greenish for ON */
    animation: pulse-glow 2s infinite ease-in-out;
}

.device-card.active .device-icon-wrapper {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent-color);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.device-info {
    flex: 1;
}

.device-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.device-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Custom Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255,255,255,0.1);
    transition: .4s;
    border: 1px solid var(--glass-border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

input:checked + .slider:before {
    transform: translateX(24px);
    background-color: white;
    box-shadow: 0 0 10px rgba(255,255,255,0.8);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Skeleton Loading */
.skeleton {
    animation: shimmer 2s infinite linear;
    background: linear-gradient(to right, #1e293b 4%, #334155 25%, #1e293b 36%);
    background-size: 1000px 100%;
}
.toggle-switch input:disabled + .slider {
    background-color: rgba(255, 255, 255, 0.1);
    cursor: not-allowed;
    opacity: 0.6;
}

.toggle-switch input:disabled:checked + .slider {
    background-color: var(--accent-color);
    opacity: 0.4;
}

.skeleton-icon {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    background: rgba(255,255,255,0.05);
}

.skeleton-text {
    height: 20px;
    width: 60%;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-text.small {
    width: 40%;
    height: 12px;
}

@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

/* Responsive */
@media (max-width: 768px) {
    .glass-header {
        padding: 1rem;
    }

    .device-grid {
        grid-template-columns: 1fr;
    }
}

/* Advanced Data Badges */
.device-details {
    width: 100%;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.detail-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.detail-badge i {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.device-card:hover .detail-badge {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
}

/* ========================
   Header Right Group
   ======================== */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--accent-subtle);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.logout-btn-icon {
    color: var(--error-color) !important;
}

.logout-btn-icon:hover {
    color: #fca5a5 !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
    background: rgba(239, 68, 68, 0.1) !important;
}

/* Dashboard button inside device card */
.card-dashboard-btn {
    width: 100%;
    padding: 0.85rem 0;
    margin-top: 0.25rem;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(99, 102, 241, 0.2));
    border: 1px solid rgba(99, 102, 241, 0.35);
    color: #a5b4fc;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-decoration: none;
    transition: all 0.3s ease;
    flex-shrink: 0;
    order: 10;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.15);
}

.card-dashboard-btn:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.45), rgba(99, 102, 241, 0.35));
    border-color: var(--accent-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

.card-options-btn {
    order: 11;
}

/* ========================
   Device Card Clickable
   ======================== */
.device-card {
    cursor: pointer;
}

.device-card:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* ========================
   Modal Overlay
   ======================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: var(--radius-xl);
    padding: 2rem;
    animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(30px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.history-modal-width {
    max-width: 900px;
}

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

.modal-header h3 {
    font-size: 1.3rem;
    font-weight: 700;
}

.close-modal-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.close-modal-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: var(--error-color);
}

.modal-back-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.modal-back-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.12);
}

@media (max-width: 640px) {
    .modal-header h3 {
        font-size: 1.1rem;
    }
    .modal-back-btn {
        font-size: 0.8rem;
        padding: 4px 10px;
    }
}

.modal-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.2rem;
}

.modal-divider {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.08);
    margin: 1.5rem 0;
}

/* ========================
   Metric Toggles
   ======================== */
.metric-toggles {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.metric-toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    transition: background 0.2s ease;
}

.metric-toggle-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.metric-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.metric-toggle-label i {
    color: var(--accent-color);
    width: 16px;
    text-align: center;
}

.dashboard-btn {
    width: 100%;
    padding: 0.85rem 1rem;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
    margin-bottom: 0;
}

.dashboard-btn:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: var(--accent-color);
    color: white;
}

/* ========================
   Danger Button
   ======================== */
.danger-btn {
    width: 100%;
    padding: 0.85rem 1rem;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.danger-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: var(--error-color);
    color: white;
}

.success-btn {
    padding: 0.6rem 1rem;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.success-btn:hover {
    background: rgba(16, 185, 129, 0.25);
    color: white;
}

/* ========================
   Toggle Row (in Settings)
   ======================== */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.toggle-row input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle-row input[type="checkbox"]:checked {
    background: var(--accent, #818cf8);
}

.toggle-row input[type="checkbox"]::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    transition: transform 0.2s;
}

.toggle-row input[type="checkbox"]:checked::before {
    transform: translateX(16px);
}

/* ========================
   Billing Mode Selector
   ======================== */
.billing-mode-selector {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.billing-mode-selector .toggle-row {
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    transition: all 0.2s ease;
}

.billing-mode-selector .toggle-row:has(input[type="radio"]:checked) {
    border-color: var(--accent-color);
    background: rgba(129, 140, 248, 0.1);
}

.billing-mode-selector .toggle-row input[type="radio"] {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s;
}

.billing-mode-selector .toggle-row input[type="radio"]:checked {
    border-color: var(--accent-color);
    background: var(--accent-color);
    box-shadow: inset 0 0 0 3px var(--card-bg);
}

.billing-mode-selector .mode-label {
    flex: 1;
    font-size: 0.85rem;
    line-height: 1.3;
}

/* ========================
   Hidden Devices List
   ======================== */
.hidden-devices-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.hidden-device-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
}

.hidden-device-name {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.hidden-device-name i {
    color: var(--text-secondary);
}

.text-muted {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
    padding: 1rem;
}

/* ========================
   Tabs & Billing
   ======================== */
.tabs-header {
    display: flex;
    gap: 10px;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.tab-btn {
    padding: 0.8rem 1.2rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    position: relative;
    transition: all 0.3s ease;
}

.tab-btn.active {
    color: var(--accent-color);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-color);
    box-shadow: 0 -2px 10px var(--accent-color);
}

.grid-2-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.upload-area {
    border: 2px dashed rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 3rem 1rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.05);
}

.result-card {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 12px;
    padding: 1.2rem;
}

.result-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.result-row.total {
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 1.1rem;
    color: #6ee7b7;
}

.secondary-btn {
    background: rgba(255,255,255,0.1);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    margin-top: 1rem;
}


/* ========================
   Footer
   ======================== */
.app-footer {
    border-top: 1px solid var(--glass-border);
    padding: 1.5rem 1.5rem;
    margin-top: 3rem;
    text-align: center;
}

.footer-credit {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.footer-credit a {
    color: var(--text-secondary);
    text-decoration: none;
}

.footer-credit a:hover {
    color: var(--accent-color);
}

.footer-brand-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.footer-brand-row i {
    font-size: 1.5rem;
    color: var(--success-color);
    filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.6));
}

.footer-mission {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.footer-tagline {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-style: italic;
    margin-bottom: 1.25rem;
    opacity: 0.8;
}

.footer-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    color: var(--text-secondary);
    opacity: 0.4;
}

.footer-divider::before,
.footer-divider::after {
    content: '';
    width: 40px;
    height: 1px;
    background: currentColor;
}

.footer-author {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.footer-author i {
    color: var(--success-color);
}

.footer-contact {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.footer-contact-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.footer-contact i {
    color: var(--accent-color);
    font-size: 0.9rem;
}

.footer-contact a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
}

.footer-contact a:hover {
    color: var(--success-color);
}

.footer-tech-row {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.tech-pill {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--success-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tech-pill i {
    font-size: 0.75rem;
}

.footer-version {
    margin-top: 1.5rem;
    font-size: 0.65rem;
    color: var(--text-secondary);
    opacity: 0.5;
}

@media (max-width: 600px) {
    .app-footer {
        padding: 2rem 1rem;
    }
    .footer-contact {
        flex-direction: column;
        gap: 0.75rem;
    }
    .footer-tech-row {
        gap: 0.5rem;
    }
    .tech-pill {
        padding: 0.25rem 0.5rem;
        font-size: 0.6rem;
    }
}

/* Live Clock */
.live-clock {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-muted);
}
.live-clock i {
    color: var(--accent-color);
    font-size: 0.75rem;
    opacity: 0.7;
}
.clock-sep {
    opacity: 0.15;
}
#clock-time {
    color: var(--text-secondary);
    min-width: 55px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 768px) {
    .live-clock { display: none; }
}

/* Settings Group */
.settings-group {
    margin-bottom: 2rem;
}
.settings-group h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 0.5rem;
}
.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ========================
   Mobile Responsiveness
    ======================== */
@media (max-width: 768px) {
    .header-main-row {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .header-left {
        order: 1;
        flex: 1;
        min-width: 0;
    }

    .glass-header {
        padding: 0.5rem 0.75rem;
        border-radius: var(--radius-md);
        margin-bottom: 1.25rem;
    }

    .live-clock {
        order: 2;
        margin-left: auto;
        font-size: 0.75rem;
    }

    .header-right {
        order: 3;
        flex: 1 1 100%;
        gap: 0.5rem;
    }

    .sidebar-toggle {
        display: flex;
        margin-left: -0.25rem;
        padding: 0.4rem;
    }

    #billing-btn, #change-pass-btn {
        display: none !important;
    }

    .logo i {
        font-size: 1.2rem;
    }

    .logo h1 {
        font-size: 1rem;
    }

    .device-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    .device-section h2 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
        padding: 1.5rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    .pdf-modal-body {
        flex-direction: column !important;
        gap: 0.5rem !important;
        padding: 0.5rem !important;
    }
    .pdf-modal-body > div:first-child {
        flex: none !important;
        height: 50vh;
    }
    .pdf-modal-body > div:last-child {
        flex: none !important;
        max-height: 35vh;
    }
    .pdf-modal-body .pdf-data-panel {
        max-height: 35vh;
    }
    .pdf-modal-body.no-pdf > div:last-child,
    .pdf-modal-body.no-pdf .pdf-data-panel {
        flex: 1 !important;
        max-height: none !important;
    }
    .pdf-modal-body.no-data > div:first-child {
        flex: 1 !important;
        height: 100% !important;
    }
    #pdf-review-modal .modal-content {
        padding: 0;
    }
    #pdf-review-modal .modal-header {
        padding: 0.6rem 0.75rem !important;
    }
    #pdf-review-modal .modal-header h3 {
        font-size: 0.85rem;
    }

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-wrapper table {
        min-width: 600px;
    }

    .grid-2-col {
        grid-template-columns: 1fr;
    }

    .input-row {
        grid-template-columns: 1fr;
    }

    .live-clock {
        display: none;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 2rem 1.25rem;
    }
    
    .logo i {
        font-size: 1.2rem;
    }

    .modal-footer {
        padding: 12px !important;
        gap: 6px !important;
    }
    .modal-footer button {
        font-size: 0.75rem;
        padding: 8px 12px;
    }
}

.badge-auto, .badge-manual {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-auto {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
}
.badge-manual {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.history-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* Responsive Table (Cards on Mobile) */
@media (max-width: 600px) {
    .user-table {
        min-width: auto !important;
    }
    .user-table thead {
        display: none;
    }
    .user-table, .user-table tbody, .user-table tr, .user-table td {
        display: block;
        width: 100%;
    }
    .user-table tr {
        margin-bottom: 20px;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 16px;
        padding: 15px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    }
    .user-table td {
        text-align: right;
        padding: 10px 5px;
        position: relative;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    .user-table td:last-child {
        border-bottom: none;
    }
    .user-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 5px;
        font-weight: 700;
        color: var(--accent-color);
        font-size: 0.85rem;
    }
    .user-table td div {
        justify-content: flex-end !important;
    }
    .history-actions {
        flex-wrap: wrap !important;
        justify-content: flex-end !important;
    }
}

/* ==========================================
   RESPONSIVE: Sidebar → Bottom Nav
   ========================================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem 1rem calc(var(--bottom-nav-height) + 1rem);
    }

    .bottom-nav {
        display: flex;
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #nav-logout,
    #sidebar-logout {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .sidebar-overlay {
        display: none !important;
    }
}

/* ==========================================
   BOTTOM SHEET MODALS (Mobile)
   ========================================== */
@media (max-width: 640px) {
    .bottom-sheet {
        align-items: flex-end;
    }
    .bottom-sheet .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        max-height: 92vh;
        animation: bottomSheetIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0));
    }
    @keyframes bottomSheetIn {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
}

/* ==========================================
   PER-DEVICE BILLING ESTIMATE (compact)
   ========================================== */
.device-estimate {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.4rem;
    font-size: 0.72rem;
    line-height: 1.4;
}
.device-estimate .est-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}
.device-estimate .est-header i {
    color: var(--accent-color);
}
.device-estimate .est-body {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.device-estimate .est-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
}
.device-estimate .est-row.est-total {
    font-weight: 700;
    color: var(--accent-color);
    font-size: 0.78rem;
}
.device-estimate .est-adj {
    font-size: 0.68rem;
    padding: 0.15rem 0;
}
.device-estimate .est-adj.pos { color: #6ee7b7; }
.device-estimate .est-adj.neg { color: #fca5a5; }
.device-estimate .est-bar {
    height: 3px;
    background: rgba(255,255,255,0.06);
    border-radius: 2px;
    overflow: hidden;
    margin: 0.2rem 0;
}
.device-estimate .est-bar-fill {
    height: 100%;
    background: var(--accent-gradient, linear-gradient(90deg, #3b82f6, #8b5cf6));
    border-radius: 2px;
    transition: width 0.5s ease;
}
.device-estimate .est-sub {
    font-size: 0.65rem;
    color: var(--text-secondary);
}
.device-estimate .est-lc-panel {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}
.device-estimate .est-lc-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.6rem;
    font-weight: 700;
    color: #16a34a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}
.device-estimate .est-lc-header i { font-size: 0.7rem; }
.device-estimate .est-lc-body { }
.device-estimate .est-lc-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 3px;
}
.device-estimate .est-lc-row span:last-child { font-weight: 600; color: var(--text-primary); }
.device-estimate .est-lc-total {
    font-weight: 700;
    color: #6ee7b7;
    font-size: 0.8rem;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid rgba(110,231,183,0.2);
}
.device-estimate .est-lc-total span:last-child { color: #6ee7b7; }
.device-estimate .est-lc-ref {
    font-size: 0.62rem;
    color: var(--text-secondary);
    margin: 6px 0 0;
    font-family: monospace;
}
.device-estimate .est-lc-empty {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-style: italic;
}
.device-estimate .est-lc-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-top: 10px;
    padding: 6px 12px;
    background: #f0fdf4;
    border: 1px solid #16a34a;
    border-radius: 6px;
    color: #16a34a;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.device-estimate .est-lc-btn:hover { background: #dcfce7; }
.device-estimate .est-lc-btn i { font-size: 0.65rem; }

/* ==========================================
   GLOBAL ESTIMATE PANEL
   ========================================== */
.global-estimate {
    padding: 1rem 1.25rem;
    font-size: 0.85rem;
}

.global-estimate-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.global-estimate-header h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.estimate-mode-badge {
    font-size: 0.7rem;
    padding: 2px 10px;
    border-radius: 20px;
    background: rgba(129, 140, 248, 0.15);
    color: var(--accent-color);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.global-estimate-body {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.ge-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.ge-cost {
    font-weight: 700;
    color: var(--accent-color);
    font-size: 1rem;
}

.ge-bar-container {
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
    margin: 0.3rem 0;
}

.ge-bar-fill {
    height: 100%;
    background: var(--accent-gradient, linear-gradient(90deg, #3b82f6, #8b5cf6));
    border-radius: 3px;
    transition: width 0.5s ease;
}

.ge-sub {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

@media (max-width: 640px) {
    .global-estimate {
        padding: 0.75rem 1rem;
        font-size: 0.8rem;
    }
    .global-estimate-header h4 {
        font-size: 0.8rem;
    }
    .ge-cost {
        font-size: 0.9rem;
    }
}

/* ==========================================
   ACCENT COLOR GLOW UPDATE
   ========================================== */
.logo i {
    filter: drop-shadow(0 0 10px var(--accent-glow));
}

/* ==========================================
   RENAME SECTION (device settings modal)
   ========================================== */
.rename-section {
    margin-bottom: 1rem;
}
.rename-section .input-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
}
.rename-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.rename-row .login-input {
    flex: 1;
}
.rename-row .primary-btn {
    white-space: nowrap;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}
.text-btn {
    background: none;
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.3rem 0;
    text-decoration: underline;
    opacity: 0.8;
}
.text-btn:hover {
    opacity: 1;
}

/* ==========================================
   EMULATION BANNER
   ========================================== */
.emulation-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #1a1a2e;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 2px 12px rgba(245, 158, 11, 0.4);
}
.emulation-banner .text-btn {
    color: #1a1a2e;
    text-decoration: underline;
    font-weight: 700;
    font-size: 0.82rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
}
.emulation-banner .text-btn:hover {
    opacity: 0.75;
}
body.emulating {
    padding-top: 36px;
}

/* ==========================================
   BAN OVERLAY
   ========================================== */
.ban-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.ban-card {
    text-align: center;
    max-width: 400px;
}
.ban-icon {
    font-size: 4rem;
    color: var(--error-color);
    margin-bottom: 1rem;
    opacity: 0.8;
}
.ban-card h2 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.8rem;
    color: #fff;
}
.ban-card p {
    font-size: 1rem;
    color: #94a3b8;
    line-height: 1.6;
}

/* ==========================================
   PROFILE MODAL
   ========================================== */
#profile-modal .input-group {
    margin-bottom: 1rem;
}
#profile-status-msg {
    min-height: 1.2em;
}

/* ==========================================
   USER LIST WITH PROFILE
   ========================================== */
.user-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.user-item:hover {
    background: var(--accent-subtle);
}
.user-item:last-child {
    border-bottom: none;
}
.user-item-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.user-item-info {
    flex: 1;
    min-width: 0;
}
.user-item-name {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-item-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-item-actions {
    display: flex;
    gap: 0.3rem;
    flex-shrink: 0;
}
.user-item-actions .icon-btn {
    font-size: 0.85rem;
    padding: 0.3rem 0.4rem;
}
.user-badge-banned {
    display: inline-block;
    font-size: 0.65rem;
    background: var(--error-color);
    color: #fff;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.3rem;
    font-weight: 600;
}
.user-badge-admin {
    display: inline-block;
    font-size: 0.65rem;
    background: var(--accent-color);
    color: #fff;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.3rem;
    font-weight: 600;
}

.user-badge-biller {
    display: inline-block;
    font-size: 0.65rem;
    background: #22c55e;
    color: #fff;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.3rem;
    font-weight: 600;
}

.billing-feature { display: none !important; }

/* ==========================================
   ADMIN DEVICES MODAL
   ========================================== */
.admin-devices-content {
    max-width: 600px;
}

.admin-devices-add {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.admin-devices-add input {
    flex: 1;
    font-family: monospace;
    font-size: 0.8rem;
}

.admin-devices-add button {
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.admin-devices-info {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    line-height: 1.4;
}

.admin-devices-info i {
    margin-top: 0.15rem;
    flex-shrink: 0;
}

.admin-devices-list {
    min-height: 100px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.admin-device-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.8rem;
    gap: 0.5rem;
    transition: background 0.2s;
}

.admin-device-item:hover {
    background: rgba(255,255,255,0.07);
}

.admin-device-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
}

.admin-device-icon {
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-color);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.admin-device-id {
    font-family: monospace;
    font-size: 0.78rem;
    word-break: break-all;
    color: var(--text-primary);
    line-height: 1.3;
}

.admin-device-delete-btn {
    font-size: 0.75rem;
    padding: 0.35rem 0.7rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
}

/* Mobile layout for admin devices */
@media (max-width: 640px) {
    .admin-devices-content {
        max-width: 100%;
    }
    .admin-devices-add input {
        font-size: 0.75rem;
    }
    .admin-devices-add button span {
        display: none;
    }
    .admin-device-item {
        padding: 0.5rem 0.6rem;
    }
    .admin-device-icon {
        width: 1.6rem;
        height: 1.6rem;
        font-size: 0.75rem;
    }
    .admin-device-id {
        font-size: 0.7rem;
    }
    .admin-device-delete-btn .del-label {
        display: none;
    }
    .admin-device-delete-btn {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
    }
}

/* Wide desktop layout */
@media (min-width: 1024px) {
    .admin-devices-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    .admin-device-item {
        padding: 0.7rem 1rem;
    }
}

/* ==========================================
   Help Modal
   ========================================== */
.help-body {
    padding: 0 0.5rem;
}
.help-section {
    margin-bottom: 1.5rem;
}
.help-section h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    gap: 6px;
}
.help-step {
    display: flex;
    gap: 10px;
    padding: 6px 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.help-step:last-child {
    border-bottom: none;
}
.help-step .help-num {
    background: var(--accent-color);
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}
.help-step i {
    color: var(--accent-color);
}

/* ==========================================
   TUYA ACCOUNT LINKING
   ========================================== */
.tuya-step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin: 0 0 1.5rem 0;
}
.tuya-step {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border-color, rgba(255,255,255,0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.3s ease;
    flex-shrink: 0;
}
.tuya-step.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #fff;
    box-shadow: 0 0 12px var(--accent-glow);
}
.tuya-step-line {
    width: 32px;
    height: 2px;
    background: var(--border-color, rgba(255,255,255,0.1));
}
.tuya-step-content {
    animation: fadeIn 0.3s ease;
}

/* Tuya device list */
.tuya-device-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--surface);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.tuya-device-item:hover {
    border-color: var(--accent-color);
    background: var(--accent-subtle);
}
.tuya-device-item.selected {
    border-color: var(--accent-color);
    background: var(--accent-subtle);
    box-shadow: 0 0 8px var(--accent-glow);
}
.tuya-device-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--accent-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--accent-color);
    flex-shrink: 0;
}
.tuya-device-info {
    flex: 1;
    min-width: 0;
}
.tuya-device-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tuya-device-detail {
    font-size: 0.72rem;
    color: var(--text-muted);
}
.tuya-device-radio {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    flex-shrink: 0;
    transition: all 0.2s ease;
}
.tuya-device-item.selected .tuya-device-radio {
    border-color: var(--accent-color);
    background: var(--accent-color);
    box-shadow: inset 0 0 0 3px var(--surface);
}

/* Tuya spinner */
.tuya-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 1rem;
    color: var(--accent-color);
    font-size: 0.9rem;
}

/* Admin Tuya link request items */
.tuya-link-request-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px;
    margin-bottom: 6px;
    background: var(--surface);
    border: 1px solid var(--border-color, rgba(255,255,255,0.06));
    border-radius: 8px;
}
.tuya-link-req-info {
    flex: 1;
    min-width: 0;
}
.tuya-link-req-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

