@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

html {
    font-size: var(--root-size, 14px);
    height: 100%;
}

:root {
    /* Dynamic Theme Core */
    --accent-h: 221;
    --accent-s: 83%;
    --accent-l: 53%;
    
    /* Primary Derived Colors */
    --primary-color: hsl(var(--accent-h), var(--accent-s), var(--accent-l));
    --primary-light: hsl(var(--accent-h), var(--accent-s), 96%);
    --primary-soft: hsla(var(--accent-h), var(--accent-s), var(--accent-l), 0.1);
    
    --secondary-color: #7c3aed;
    --bg-color: #f8fafc;
    --panel-bg: #ffffff;
    --sidebar-bg: #ffffff;
    --topbar-bg: rgba(248, 250, 252, 0.8);
    --glass-border: #e2e8f0;
    --glass-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --sidebar-width-full: 240px;
    --sidebar-width-compact: 80px;
    --sidebar-width: var(--sidebar-width-full);
    --header-height: 52px;
    --radius-small: 6px;
    --radius-medium: 10px;
    --radius-large: 16px;
}

[data-theme="dark"] {
    /* Dynamic Theme Core - Dark Adjustment */
    --accent-l: 60%;
    
    --primary-light: rgba(255, 255, 255, 0.05);
    --primary-soft: hsla(var(--accent-h), var(--accent-s), var(--accent-l), 0.15);
    
    --bg-color: #0f172a;
    --panel-bg: #1e293b;
    --sidebar-bg: #1e293b;
    --topbar-bg: rgba(15, 23, 42, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --nav-bg: rgba(15, 23, 42, 0.8);
}

:root.sidebar-compact {
    --sidebar-width: var(--sidebar-width-compact);
}

.nav-footer-mobile {
    display: none;
    flex-direction: column;
    gap: 1.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
    width: 100%;
    margin-top: auto;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s, color 0.3s;
}

body.auth-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent flex blowout */
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--glass-border);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s ease;
    overflow: hidden;
}

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

.sidebar-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-menu {
    flex: 1;
    padding: 1rem 0.5rem;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    margin-bottom: 0.25rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.sidebar-compact .menu-item {
    justify-content: center;
    padding: 0.6rem;
    margin: 0.25rem 0.5rem;
}

.sidebar-compact .menu-item span,
.sidebar-compact .sidebar-logo span,
.sidebar-compact .sidebar-menu > div {
    display: none;
}

.breadcrumb-nav, .dashboard-header-modern, .top-header, main {
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-item:hover, .menu-item.active {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

.menu-item.active {
    background: var(--primary-color);
    color: white;
}

/* Elegant Project Card Design */
.project-card {
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 1.25rem;
    position: relative;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-decoration: none;
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: var(--primary-soft);
}

.project-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    opacity: 0;
    transition: opacity 0.3s;
}

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

.project-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.project-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.project-card:hover .project-card-icon {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1) rotate(5deg);
}

.project-card-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    position: relative;
}

.status-dot.pulse::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    background: inherit;
    animation: status-pulse 2s infinite;
}

@keyframes status-pulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(3); opacity: 0; }
}

/* Mobile Health Dashboard Styles */
.m-health-card {
    background: var(--panel-bg); border: 1px solid var(--glass-border);
    border-radius: 24px; padding: 1.25rem 1.5rem; margin: 1rem 1.5rem;
    display: flex; justify-content: space-between; align-items: center;
    box-shadow: var(--glass-shadow);
}
.m-health-stat { text-align: center; flex: 1; }
.m-health-stat:not(:last-child) { border-right: 1px solid var(--glass-border); }
.m-health-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 0.25rem; font-weight: 700; }
.m-health-value { font-size: 1.5rem; font-weight: 900; color: var(--text-primary); }
.m-health-online { color: var(--success); }
.m-health-offline { color: var(--danger); }

.status-dot.active-pulse::after {
    content: ''; position: absolute; inset: 0; border-radius: 50%;
    background: inherit; animation: status-pulse 2s infinite;
}

.project-card-body {
    flex: 1;
}

.project-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.project-card-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.project-card-footer {
    padding-top: 0.75rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: flex-end;
}

.project-card-link {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: gap 0.2s;
}

.project-card:hover .project-card-link {
    gap: 0.5rem;
}

/* Theme Picker Styles */
.theme-picker-overlay {
    position: fixed;
    top: 60px;
    right: 20px;
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    z-index: 2000;
    display: none;
}

.theme-picker-overlay.active { display: block; }

.theme-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.theme-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
}

.theme-dot:hover { transform: scale(1.15); }
.theme-dot.active { border-color: var(--text-primary); }

/* Button Styling */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--primary-color);
    color: #ffffff !important;
    box-shadow: 0 4px 14px 0 rgba(var(--accent-h), var(--accent-s), var(--accent-l), 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--accent-h), var(--accent-s), var(--accent-l), 0.4);
    background: var(--secondary-color);
}

.btn-secondary {
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary) !important;
}

.btn-secondary:hover {
    background: var(--primary-soft);
    border-color: var(--primary-color);
    color: var(--primary-color) !important;
}

/* Dashboard Layout Extensions */
.dashboard-layout {
    display: flex;
    gap: 1.5rem;
    width: 100%;
    transition: all 0.3s ease;
    align-items: flex-start;
}

.main-content-area {
    flex: 1;
    min-width: 0;
    transition: all 0.3s ease;
}

.secondary-sidebar {
    width: 280px;
    height: auto;
    max-height: calc(100vh - var(--header-height) - 2rem);
    position: sticky;
    top: calc(var(--header-height) + 1rem);
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    z-index: 10;
    box-shadow: var(--card-shadow);
}

.secondary-sidebar.collapsed {
    width: 0;
    margin-left: -1.5rem;
    overflow: hidden;
    border: 1px solid transparent;
    box-shadow: none;
}

.node-list-item {
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 1px solid var(--glass-border);
    transition: all 0.2s ease;
}

.node-list-item:last-child {
    border-bottom: none;
}

.node-list-item:hover {
    background: var(--primary-soft);
    color: var(--primary-color);
}

.node-list-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
}

/* Enhanced Breadcrumbs */
.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    margin-bottom: 2rem;
    color: var(--text-muted);
    font-weight: 500;
}

.breadcrumb-item {
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

.breadcrumb-item:hover { 
    color: var(--primary-color); 
    background: var(--primary-soft);
}

.breadcrumb-item.active {
    color: var(--text-primary);
}

.breadcrumb-separator { 
    opacity: 0.3; 
    font-size: 0.7rem;
}

/* Modern Dashboard Header */
.dashboard-header-modern {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    gap: 2rem;
}

.project-branding {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.project-badge {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: var(--primary-color);
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.1), 
                0 0 0 1px rgba(var(--accent-h), var(--accent-s), var(--accent-l), 0.1);
    position: relative;
    overflow: hidden;
}

.project-badge::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, var(--primary-soft) 0%, transparent 70%);
    opacity: 0.5;
}

.project-info h1, .page-title-modern {
    font-size: 2.0rem;
    font-weight: 800;
    letter-spacing: -1.5px;
    margin: 0;
    color: var(--text-primary);
    line-height: 1.2;
}

.page-title-utility {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.8px;
    margin: 0;
    color: var(--text-primary);
    line-height: 1.3;
}

.project-info p {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.header-action-group {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.header-action-group .btn {
    height: 42px;
    padding: 0 1.25rem !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 12px;
    white-space: nowrap;
}

.status-badge-bar {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
    overflow-x: auto;
    padding-bottom: 5px;
    max-width: 60vw;
    scrollbar-width: none; /* Firefox */
}

.status-badge-bar::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    padding: 0.4rem 0.8rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Metadata & Registry Cards */
.metadata-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.metadata-card {
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 1.5rem;
    position: relative;
}

.metadata-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.metadata-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.token-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--primary-soft);
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.9rem;
    color: var(--primary-color);
    border: 1px solid rgba(var(--accent-h), var(--accent-s), var(--accent-l), 0.2);
    margin-top: 0.5rem;
    word-break: break-all;
}

.copy-btn {
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
    flex-shrink: 0;
}

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

/* Builder & Configuration Forms */
.builder-card {
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 3rem;
}

.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    background: var(--bg-color);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 0.8rem 1rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--panel-bg);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.form-input::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='currentColor'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

/* Configured Widget Cards */
.widget-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding-bottom: 3rem;
}

.configured-widget-card {
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.configured-widget-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: var(--card-shadow);
}

.widget-info-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    background: var(--primary-soft);
    color: var(--primary-color);
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* Analytics & Statistics Grid */
.analytics-dashboard {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
    padding-bottom: 3.5rem;
}

.stat-card-modern {
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: all 0.25s ease;
    box-shadow: var(--glass-shadow);
}

.stat-card-modern:hover {
    transform: translateY(-4px);
    border-color: var(--primary-color);
    box-shadow: var(--card-shadow);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-label-modern {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.stat-icon-badge {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--primary-soft);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.stat-value-modern {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.stat-trend {
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.stat-trend {
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

/* Modern Widget Cards (High Density) */
.widget-card-modern {
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    transition: all 0.25s ease;
    box-shadow: var(--glass-shadow);
    min-height: 180px;
}

.widget-card-modern:hover {
    transform: translateY(-4px);
    border-color: var(--primary-color);
    box-shadow: var(--card-shadow);
}

.widget-pin-badge {
    font-size: 0.65rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    background: var(--primary-soft);
    color: var(--primary-color);
    padding: 4px 8px;
    border-radius: 6px;
}

.val-display-modern {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}

.val-display-modern .main-val {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1;
}

.val-display-modern .unit-val {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
}

.btn-control-modern {
    width: 100%;
    background: var(--bg-color);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-control-modern:hover {
    background: var(--primary-soft);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-control-modern.on {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px var(--primary-soft);
}

.widget-footer-modern {
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--glass-border);
}

.status-pill-small {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Auth Pages (Login/Register) */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.auth-card {
    width: 100%;
    max-width: 400px;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-header p {
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 210, 255, 0.2);
}

.btn {
    display: inline-block;
    width: 100%;
    padding: 0.5rem 0.85rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-align: center;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.4);
}

/* Dashboard Layout */
.btn-xs {
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-xs:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

.btn-xs.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* iOS-style sliding toggle */
.theme-toggle-wrap {
    display: inline-flex;
    align-items: center;
    margin-left: 1rem;
    cursor: pointer;
    flex-shrink: 0;
}
.toggle-track {
    position: relative;
    width: 44px;
    height: 24px;
    background: #3a3f5c;
    border-radius: 999px;
    transition: background 0.3s;
    flex-shrink: 0;
}
[data-theme="light"] .toggle-track {
    background: var(--primary-color);
}
.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), box-shadow 0.3s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
[data-theme="light"] .toggle-thumb {
    transform: translateX(20px);
}

.main-footer {
    width: calc(100% - var(--sidebar-width));
    margin-left: var(--sidebar-width);
    padding: 1.25rem 0;
    margin-top: auto;
    background: var(--topbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 800;
}

.top-header {
    height: var(--header-height);
    background: var(--topbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 900;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
}

body.auth-page .top-header {
    margin-left: 0;
    width: 100%;
}

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

.header-search {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(0,0,0,0.03);
    border: 1px solid var(--glass-border);
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    width: 300px;
}

[data-theme="dark"] .header-search {
    background: rgba(255,255,255,0.05);
}

.header-search input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    outline: none;
    width: 100%;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

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

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* Hamburger Menu Toggle */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1100;
    margin-left: 1rem;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.menu-toggle .bar {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--text-primary);
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-toggle.active .bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.menu-toggle.active .bar:nth-child(2) {
    opacity: 0;
    transform: translateX(10px);
}

.menu-toggle.active .bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.nav-links {
    display: flex;
    align-items: center;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    margin-left: 1.5rem;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--primary-color);
}

.dashboard-container {
    padding: 1.25rem 4%;
    flex-grow: 1;
}

/* Grid & Cards */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
}

.stat-card .title {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

.stat-card.temp .value { color: #f59e0b; }
.stat-card.humid .value { color: #0ea5e9; }

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

.text-center { text-align: center; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.link { color: var(--primary-color); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* Fleet Management Utilities */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.project-card {
    transition: transform 0.3s ease, border-color 0.3s ease;
    display: flex;
    flex-direction: column;
}

.project-card:hover {
    border-color: rgba(0, 210, 255, 0.3);
}

.badge {
    background: rgba(0, 210, 255, 0.1);
    color: var(--primary-color);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.device-list-compact {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--glass-border) transparent;
}

.device-item-compact {
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    transition: background 0.2s;
}

.device-item-compact:hover {
    background: rgba(255, 255, 255, 0.05);
}

.token-copy-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0,0,0,0.3);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin-top: 0.25rem;
}

.token-text {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--primary-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.copy-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.copy-btn:hover {
    color: var(--primary-color);
}

.metadata-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
    margin-top: 0.5rem;
}

/* Theme Toggle (Phase 3 Skeleton) */
.theme-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 1000;
    box-shadow: var(--glass-shadow);
}

/* Maximized Widget View */
.widget-card.maximized {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    margin: 0;
    border-radius: 0;
    backdrop-filter: blur(20px);
    background: rgba(15, 23, 42, 0.95);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
}

.widget-card.maximized .widget-header {
    margin-bottom: 2rem;
}

.widget-card.maximized .widget-header .widget-title {
    font-size: 1.5rem;
}

.widget-card.maximized .widget-map-container {
    flex: 1 !important;
    height: 100% !important;
}

.maximize-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 0.75rem;
}

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

/* Media History Floating Window */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(8px);
    z-index: 12000; display: none; align-items: center; justify-content: center;
    padding: 2rem; opacity: 0; transition: opacity 0.3s ease;
}

.modal-overlay.show { display: flex; opacity: 1; }

.modal-content {
    background: var(--panel-bg); backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border); border-radius: 16px;
    width: 100%; max-width: 950px; max-height: 90vh;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.95); transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="dark"] .modal-content {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.modal-overlay.show .modal-content { transform: scale(1); }

.modal-header {
    background: var(--primary-soft); padding: 1.25rem 2rem; border-bottom: 1px solid var(--glass-border);
    display: flex; justify-content: space-between; align-items: center;
}

.modal-body {
    padding: 1.5rem; overflow-y: auto; flex: 1;
    background: var(--bg-color);
}

.history-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.5rem;
}

.history-item {
    background: var(--panel-bg); border: 1px solid var(--glass-border);
    border-radius: 12px; overflow: hidden; transition: all 0.2s ease;
    box-shadow: var(--glass-shadow);
}

.history-item:hover { transform: translateY(-4px); border-color: var(--primary-color); box-shadow: var(--card-shadow); }

.history-media { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: #000; border-bottom: 1px solid var(--glass-border); }

.history-info { padding: 0.75rem; font-size: 0.8rem; color: var(--text-muted); text-align: center; font-weight: 500; }

.audio-history-list { display: flex; flex-direction: column; gap: 0.75rem; }

.audio-history-item {
    display: flex; align-items: center; gap: 1rem; padding: 1rem;
    background: var(--panel-bg); border: 1px solid var(--glass-border); border-radius: 12px;
    box-shadow: var(--glass-shadow);
}

.history-btn {
    background: var(--primary-soft); border: 1px solid var(--glass-border);
    color: var(--primary-color); width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s;
}

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

.modal-footer {
    padding: 1.25rem 2rem; border-top: 1px solid var(--glass-border);
    display: flex; justify-content: space-between; align-items: center;
    background: var(--panel-bg);
}

.pagination-controls { display: flex; align-items: center; gap: 1rem; }

.pagination-btn {
    background: var(--panel-bg); border: 1px solid var(--glass-border);
    color: var(--text-primary); padding: 0.6rem 1.2rem; border-radius: 10px; cursor: pointer;
    transition: all 0.2s; font-size: 0.875rem; font-weight: 600;
}

.pagination-btn:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary-color); border-color: var(--primary-color); }
.pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.history-table { width: 100%; border-collapse: collapse; background: var(--panel-bg); border-radius: 12px; overflow: hidden; border: 1px solid var(--glass-border); }
.history-table th { text-align: left; padding: 1.25rem 1rem; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--glass-border); background: var(--bg-color); }
.history-table td { padding: 1rem; border-bottom: 1px solid var(--glass-border); color: var(--text-primary); font-size: 0.9rem; }
.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: var(--primary-soft); }

.spinner {
    width: 32px; height: 32px; border: 3px solid var(--primary-soft);
    border-top-color: var(--primary-color); border-radius: 50%;
    animation: spin 0.8s linear infinite; margin: 3rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ===================== */
/* Global Search (Cmd+K) */
/* ===================== */

.nav-search-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
    margin-right: 0.5rem;
}

.nav-search-btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.15);
    color: var(--text-primary);
}

.nav-search-kbd {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-family: 'Inter', sans-serif;
    color: var(--text-muted);
    line-height: 1.6;
}

.nav-search-text {
    opacity: 0.7;
}

/* Search Overlay */
.search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 5000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.search-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Search Dialog */
.search-dialog {
    width: 100%;
    max-width: 640px;
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.5);
    overflow: hidden;
    transform: scale(0.96) translateY(-10px);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    max-height: 70vh;
}

.search-overlay.active .search-dialog {
    transform: scale(1) translateY(0);
}

/* Search Input */
.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.search-icon {
    color: var(--primary-color);
    flex-shrink: 0;
}

.search-field {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    caret-color: var(--primary-color);
}

.search-field::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.search-kbd {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    flex-shrink: 0;
}

/* Search Results */
.search-results {
    overflow-y: auto;
    flex: 1;
    min-height: 100px;
    max-height: 50vh;
    scrollbar-width: thin;
    scrollbar-color: var(--glass-border) transparent;
}

.search-empty-state {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--text-muted);
}

.search-loading {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.search-group-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.5rem 1rem 0.2rem;
}

.node-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    text-decoration: none;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--glass-border);
}

.node-list-item:hover {
    background: var(--primary-soft);
}

.node-list-item-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.node-list-item-wrapper .rename-btn {
    position: absolute;
    right: 1rem;
    opacity: 0;
    transition: all 0.2s ease;
    background: white;
    border: 1px solid var(--glass-border);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.node-list-item-wrapper:hover .rename-btn {
    opacity: 1;
}

.rename-btn:hover {
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    transform: scale(1.1);
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 1rem;
    text-decoration: none;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s ease;
    border-left: 3px solid transparent;
}

.search-result-item:hover,
.search-result-item.selected {
    background: rgba(0, 210, 255, 0.06);
    border-left-color: var(--primary-color);
}

.search-result-icon {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--primary-color);
    flex-shrink: 0;
}

.search-result-body {
    flex: 1;
    min-width: 0;
}

.search-result-title {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-title mark {
    background: rgba(0, 210, 255, 0.25);
    color: var(--primary-color);
    padding: 0 2px;
    border-radius: 3px;
}

.search-result-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Search Footer */
.search-footer {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.6rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.7rem;
    color: var(--text-muted);
}

.search-footer kbd {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-family: 'Inter', sans-serif;
    margin: 0 1px;
}

/* Light theme overrides */
[data-theme="light"] .search-dialog {
    background: rgba(255, 255, 255, 0.97);
    border-color: rgba(0,0,0,0.1);
    box-shadow: 0 25px 60px rgba(0,0,0,0.15);
}

[data-theme="light"] .search-result-item:hover,
[data-theme="light"] .search-result-item.selected {
    background: rgba(37, 99, 235, 0.06);
}

[data-theme="light"] .search-result-title mark {
    background: rgba(37, 99, 235, 0.15);
    color: var(--primary-color);
}

[data-theme="light"] .nav-search-btn {
    background: rgba(0,0,0,0.04);
    border-color: rgba(0,0,0,0.1);
}

[data-theme="light"] .nav-search-btn:hover {
    background: rgba(0,0,0,0.08);
}

/* Responsive */
@media (max-width: 992px) {
    .nav-search-text,
    .nav-search-kbd {
        display: none;
    }
    .nav-search-btn {
        margin-right: 0;
        padding: 0.5rem;
    }
}

@media (max-width: 992px) {
    .dashboard-nav {
        padding: 0.75rem 1.25rem;
    }

    .dashboard-nav .logo {
        font-size: 1.25rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .menu-toggle {
        display: flex !important;
        position: relative;
        z-index: 2000;
    }

    .nav-desktop-actions {
        display: none !important;
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 240px;
        background: rgba(15, 23, 42, 0.98); /* More opaque for dark theme */
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        flex-direction: column;
        align-items: flex-start;
        padding: 5rem 2rem 2rem;
        z-index: 1050;
        transform: translateX(100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
        border-left: 1px solid var(--glass-border);
    }

    [data-theme="light"] .nav-links {
        background: rgba(241, 245, 249, 0.98); /* More opaque for light theme */
    }

    .nav-links.active {
        transform: translateX(0);
    }

    .nav-links a {
        margin: 0;
        padding: 1rem 0;
        width: 100%;
        font-size: 1.1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .nav-footer-mobile {
        display: flex;
    }

    .nav-footer-mobile .theme-toggle-wrap {
        margin-left: 0;
        margin-top: 0.5rem;
    }

    .search-dialog {
        max-width: calc(100vw - 2rem);
        margin: 0 1rem;
    }
    
    .search-result-meta {
        display: none;
    }

    /* Fix for horizontal scroll on mobile */
    body.menu-open {
        overflow: hidden;
    }
    
    /* Universal Mobile Grid Collapse */
    .grid-dashboard, 
    .scene-grid, 
    .builder-grid, 
    .widget-list, 
    .analytics-grid, 
    .stats-grid, 
    .project-grid, 
    .grid-container,
    .responsive-grid-2,
    .responsive-grid-3,
    .responsive-grid-form {
        grid-template-columns: 1fr !important;
    }
    
    /* Improved mobile paddings to reclaim screen space */
    .dashboard-container { padding: 1.5rem 1rem !important; }
    .widget-card, .glass-panel { padding: 1rem !important; }
    .auth-container { padding: 1rem; }
    .modal-content { margin: 1rem; width: auto; max-height: calc(100vh - 2rem); }
}

/* Responsive Grid Helper Classes */
.responsive-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.responsive-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.responsive-grid-320 { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.5rem; }
.responsive-grid-form { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 1rem; }

.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    box-shadow: var(--card-shadow);
    padding: 1.5rem;
    transition: all 0.3s ease;
}

[data-theme="dark"] .glass-panel {
    background: var(--panel-bg);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* Normalized Widget Grid */
.grid-dashboard { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); 
    gap: 1.5rem; 
}

.widget-card { 
    background: var(--panel-bg); 
    border: 1px solid var(--glass-border); 
    border-radius: 18px; 
    padding: 1.5rem; 
    display: flex; 
    flex-direction: column; 
    justify-content: space-between; 
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--card-shadow);
    min-height: 200px;
}

.widget-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

.widget-title { 
    font-weight: 800; 
    font-size: 0.9rem; 
    color: var(--text-primary); 
    letter-spacing: -0.2px;
}

.widget-value { 
    font-size: 2.25rem; 
    font-weight: 800; 
    color: var(--primary-color); 
    margin: 1.5rem 0; 
}

.widget-footer { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-top: 1rem; 
    padding-top: 1rem; 
    border-top: 1px solid var(--glass-border); 
    font-size: 0.75rem; 
    color: var(--text-muted); 
    font-weight: 500;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
}
.btn-secondary:hover {
    border-color: var(--text-muted);
    background: rgba(0,0,0,0.05);
}
[data-theme="dark"] .btn-secondary:hover {
    background: rgba(255,255,255,0.05);
}

.text-center { text-align: center; }




/* Responsive Media Queries */
@media (max-width: 1024px) {
    :root { --sidebar-width: 210px; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 20px 0 50px rgba(0,0,0,0.2);
    }
    .sidebar.active { transform: translateX(0); }
    
    main { margin-left: 0 !important; width: 100% !important; }
    
    .top-header { margin-left: 0; width: 100%; }
    .main-footer { margin-left: 0 !important; width: 100% !important; }
    #sidebarToggle { display: flex !important; align-items: center; }
    
    .sidebar .sidebar-header button { display: none !important; }
    .sidebar-compact .sidebar { width: var(--sidebar-width-full) !important; }
    .sidebar-compact .sidebar span { display: block !important; }
    
    .header-search { display: none; }
    
    .grid-container { grid-template-columns: 1fr !important; }
    .dashboard-container { padding: 1rem; margin-top: 80px; }
    
    .sidebar-backdrop {
        position: fixed; top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
        z-index: 999; display: none;
    }
    .sidebar-backdrop.active { display: block; }
}

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

/* Premium Landing Page Redesign */
.landing-page {
    min-height: 100vh;
    background: var(--bg-color);
    display: flex;
    overflow-x: hidden;
}

.landing-split {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.landing-side-hero {
    flex: 1.2;
    position: relative;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.8)), 
                url('../img/hero_display.png');
    background-size: cover;
    background-position: center;
    padding: 4rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: white;
    border-right: 1px solid var(--glass-border);
}

.landing-side-auth {
    flex: 0.8;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    z-index: 10;
}

.landing-feature-list {
    margin-top: 3rem;
    display: grid;
    gap: 1.5rem;
    max-width: 600px;
}

.landing-feature-item {
    display: flex;
    gap: 1.25rem;
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    backdrop-filter: blur(8px);
    transition: all 0.3s ease;
}

.landing-feature-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary-color);
    transform: translateX(10px);
}

.landing-feature-icon {
    width: 42px;
    height: 42px;
    background: var(--primary-soft);
    color: var(--primary-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.landing-contact-info {
    margin-top: auto;
    padding-top: 3rem;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    gap: 2rem;
}

.landing-contact-info i {
    margin-right: 0.5rem;
    color: var(--primary-color);
}

@media (max-width: 1024px) {
    .landing-split { flex-direction: column; }
    .landing-side-hero { padding: 3rem 2rem; min-height: 50vh; border-right: none; border-bottom: 1px solid var(--glass-border); }
    .landing-side-auth { padding: 4rem 1.5rem; min-height: 50vh; }
    .landing-contact-info { margin-top: 2rem; flex-wrap: wrap; gap: 1rem; }
}
