:root {
    /* Premium Color Palette (Dark Mode First) */
    --bg-app: #0f1115;
    --bg-card: rgba(24, 27, 33, 0.7);
    /* Translucent for glassmorphism */
    --bg-card-hover: rgba(31, 35, 43, 0.8);

    --text-main: #f0f2f5;
    --text-muted: #9ca3af;
    --text-accent: #38bdf8;

    --color-green: #10b981;
    --color-green-glow: rgba(16, 185, 129, 0.15);
    --color-yellow: #f59e0b;
    --color-yellow-glow: rgba(245, 158, 11, 0.15);
    --color-red: #ef4444;
    --color-red: #ef4444;
    --color-red-glow: rgba(239, 68, 68, 0.15);
    --color-h6: #d97706;
    /* Added for config button gradient */

    --accent-gradient: linear-gradient(135deg, #38bdf8 0%, #3b82f6 100%);

    --radius-lg: 20px;
    /* Modern rounded corners */
    --radius-md: 14px;
    --radius-sm: 8px;

    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    --glass-border: 1px solid rgba(255, 255, 255, 0.08);

    --ease-ios: cubic-bezier(0.25, 1, 0.5, 1);
    /* Super fluid interaction */
    --gap: 24px;
    /* Unified Bento Gap */
}

body {
    margin: 0;
    font-family: 'Roboto Flex', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-app);
    background-image: radial-gradient(circle at top center, rgba(56, 189, 248, 0.08) 0%, transparent 60%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Utilities */
.container {
    max-width: 1200px;
    /* Fluid Desktop Width */
    margin: 0 auto;
    padding: var(--gap);
    /* Consistent Padding */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Login/Config Center Wrapper */
.center-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    text-align: center;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
}

/* Dashboard Grids */
.dashboard-stats {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--gap);
    margin-bottom: var(--gap);
    /* Same spacing vertically */
}

.dashboard-devices {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--gap);
}

@media (min-width: 768px) {
    .dashboard-stats {
        /* Weather (1) + Solar (2) ratio */
        grid-template-columns: 1fr 1.5fr;
    }

    .dashboard-devices {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

/* Remove margins in grids so gap handles spacing */
.dashboard-stats .card,
.dashboard-devices .card {
    margin-bottom: 0;
}

.card {
    background-color: var(--bg-card);
    backdrop-filter: blur(12px);
    /* Glassmorphism */
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: var(--gap);
    /* Consistent spacing for non-grid views */
    box-shadow: var(--shadow-sm);
    border: var(--glass-border);
    transition: transform 0.3s var(--ease-ios), background-color 0.3s var(--ease-ios), box-shadow 0.3s var(--ease-ios);
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.card:hover {
    background-color: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(255, 255, 255, 0.12);
}

.btn {
    width: 100%;
    padding: 16px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--accent-gradient);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--ease-ios);
    font-size: 1rem;
    letter-spacing: 0.01em;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.btn:active {
    transform: scale(0.98) translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.03);
    border: var(--glass-border);
    color: var(--text-main);
    padding: 10px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
    transform: none;
    box-shadow: none;
}

.input {
    width: 100%;
    padding: 16px;
    margin-bottom: 16px;
    border-radius: var(--radius-md);
    border: var(--glass-border);
    background-color: rgba(0, 0, 0, 0.2);
    color: white;
    font-size: 1rem;
    box-sizing: border-box;
    outline: none;
    transition: all 0.2s var(--ease-ios);
}

.input:focus {
    border-color: var(--text-accent);
    background-color: rgba(0, 0, 0, 0.3);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

/* Typography & Layout */
h1,
h2,
h3 {
    margin: 0;
}

h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #fff, #cbd5e1);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    /* Gradient text for title */
}

/* Override for "SolarOpt" span to keep color */
h1 span {
    background: none;
    -webkit-text-fill-color: initial;
    color: var(--color-yellow);
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

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

/* Status Indicators */
.status-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-top: 16px;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.03);
    /* Fallback */
    border: 1px solid transparent;
}

/* Animations */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.98) translateY(10px);
    }

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

.animate-in {
    animation: fadeInScale 0.5s var(--ease-ios) forwards;
}

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

.spin {
    animation: spin 1s linear infinite;
}

/* Mobile Tweaks */
@media (max-width: 480px) {
    .container {
        padding: 16px;
    }

    .card {
        padding: 20px;
    }

    h1 {
        font-size: 1.75rem;
    }
}

/* Apple Button Override */
#appleid-signin {
    width: 100%;
    height: 50px;
}

/* Custom Range Slider */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    margin: 10px 0;
}

input[type=range]:focus {
    outline: none;
}

/* Webkit Track */
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    border: none;
}

/* Webkit Thumb */
input[type=range]::-webkit-slider-thumb {
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--text-accent);
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -7px;
    /* center thumb */
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* Firefox Track */
input[type=range]::-moz-range-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Firefox Thumb */
input[type=range]::-moz-range-thumb {
    height: 20px;
    width: 20px;
    border: none;
    border-radius: 50%;
    background: var(--text-accent);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.btn-glass {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    padding: 8px 20px;
    border-radius: 99px;
    /* Pill shape */
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    margin: 0 auto;
    width: fit-content;
}

.btn-glass:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-main);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}