:root {
    --bg-dark: #0f1115;
    /* Deep space charcoal */
    --panel-bg: rgba(22, 26, 33, 0.45);
    --panel-border: rgba(255, 255, 255, 0.06);
    --neon-cyan-main: #00f3ff;
    --neon-cyan-dim: rgba(0, 243, 255, 0.2);
    --neon-cyan-glow: rgba(0, 243, 255, 0.5);
    --amber-main: #ffb703;
    --amber-glow: rgba(255, 183, 3, 0.6);
    --green-main: #00e676;
    --green-glow: rgba(0, 230, 118, 0.6);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --glass-blur: blur(16px);

    --font-heading: 'Outfit', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --border-radius-lg: 24px;
    --border-radius-md: 16px;
    --border-radius-sm: 8px;
}

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

body {
    background-color: var(--bg-dark);
    /* Subtle neon gradient background for depth */
    background-image:
        radial-gradient(circle at 15% 20%, var(--neon-cyan-dim) 0%, transparent 35%),
        radial-gradient(circle at 85% 85%, var(--neon-cyan-dim) 0%, transparent 35%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Stack dashboard + footer vertically */
    align-items: center;
    /* Keep everything centred horizontally */
    justify-content: flex-start;
    padding: 2rem;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-heading);
    font-weight: 700;
}

h2 {
    font-size: 1.25rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 1.25rem;
}

/* Base Glass Panel Styles */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    padding: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.glass-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.1);
}

.neon-text {
    color: var(--neon-cyan-main);
    text-shadow: 0 0 10px var(--neon-cyan-glow);
    font-family: var(--font-heading);
    font-weight: 700;
}

/* Dashboard Layout */
.dashboard {
    width: 100%;
    max-width: 1280px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Header */
.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-radius: 100px;
    /* Pill shape */
}

.logo-text {
    font-size: 1.5rem;
    letter-spacing: 2px;
    background: linear-gradient(90deg, #fff, var(--neon-cyan-main));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text span {
    font-size: 0.8rem;
    color: var(--neon-cyan-main);
    background: none;
    -webkit-text-fill-color: initial;
    opacity: 0.8;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(0, 230, 118, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid rgba(0, 230, 118, 0.2);
}

.ip-config-panel {
    display: flex;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.35rem;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ip-config-panel input {
    background: transparent;
    border: none;
    color: var(--neon-cyan-main);
    padding: 0.2rem 1rem;
    font-family: var(--font-body);
    font-size: 0.85rem;
    width: 200px;
    outline: none;
}

.mini-action-btn {
    background: var(--neon-cyan-dim);
    border: 1px solid var(--neon-cyan-main);
    color: var(--neon-cyan-main);
    padding: 0.35rem 1rem;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.mini-action-btn:hover {
    background: var(--neon-cyan-main);
    color: var(--bg-dark);
}

.pulsing-dot {
    width: 12px;
    height: 12px;
    background-color: var(--green-main);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--green-glow);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(0, 230, 118, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(0, 230, 118, 0);
    }
}

.status-text {
    color: var(--green-main);
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

/* Grid Layout */
.grid-layout {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-gap: 1.5rem;
}

/* Central Card (Compass) */
.central-card {
    grid-column: span 6;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.compass-wrapper {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 1.5rem 0;
}

.compass-outer {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px dashed rgba(255, 255, 255, 0.2);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Add N/S/E/W labels */
.compass-outer::before {
    content: "N";
    position: absolute;
    top: -30px;
    color: var(--text-secondary);
    font-weight: bold;
}

.compass-outer::after {
    content: "S";
    position: absolute;
    bottom: -30px;
    color: var(--text-secondary);
    font-weight: bold;
}

.compass-inner {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 243, 255, 0.1) 0%, rgba(0, 0, 0, 0.4) 100%);
    border: 1px solid var(--neon-cyan-dim);
    box-shadow: inset 0 0 20px var(--neon-cyan-dim);
    position: relative;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.sun-icon {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    background: #ffb703;
    border-radius: 50%;
    box-shadow: 0 0 20px #ffb703, 0 0 40px #ffb703, inset 0 0 10px #fff;
}

.compass-center {
    width: 12px;
    height: 12px;
    background: var(--text-primary);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px #fff;
    z-index: 5;
}

.angle-readout {
    font-size: 3rem;
    line-height: 1;
    margin-top: 1rem;
}

.angle-readout .unit {
    font-size: 1.5rem;
    color: var(--text-secondary);
    vertical-align: top;
}

/* Gauges Card */
.gauges-card {
    grid-column: span 6;
    display: flex;
    flex-direction: column;
}

.gauges-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    flex-grow: 1;
    justify-content: center;
}

.gauge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.half-circle-gauge {
    position: relative;
    width: 160px;
    height: 80px;
    background: rgba(255, 255, 255, 0.05);
    border-top-left-radius: 160px;
    border-top-right-radius: 160px;
    overflow: hidden;
}

.gauge-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 160px;
    height: 160px;
    /* We make the bottom half solid, and rotate it into view */
    background: conic-gradient(from 270deg, transparent 0deg, transparent 180deg, var(--neon-cyan-main) 180deg, var(--neon-cyan-main) 360deg);
    border-radius: 50%;
    transform-origin: 50% 50%;
    transition: transform 0.5s ease;
}

.gauge-fill.alt-color {
    background: conic-gradient(from 270deg, transparent 0deg, transparent 180deg, var(--amber-main) 180deg, var(--amber-main) 360deg);
}

.gauge-mask {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 140px;
    height: 140px;
    background: var(--bg-dark);
    border-radius: 50%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 25px;
    box-shadow: inset 0 5px 10px rgba(0, 0, 0, 0.5);
}

.gauge-value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* LDR Section (Four Cards) */
.ldr-section {
    grid-column: span 4;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-gap: 1rem;
}

.ldr-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1.25rem;
}

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

.ldr-header h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.ldr-val {
    font-size: 1.25rem;
}

.progress-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #005f73, var(--neon-cyan-main));
    border-radius: 4px;
    box-shadow: 0 0 10px var(--neon-cyan-glow);
    transition: width 0.5s ease;
}

/* Direction Sidebar & Stats */
.sidebar-layout {
    grid-column: span 12;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-gap: 1.5rem;
}

.direction-card {
    grid-column: span 6;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.direction-display {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--amber-main);
    text-shadow: 0 0 15px var(--amber-glow);
    font-family: var(--font-heading);
    letter-spacing: 2px;
    margin: 1.5rem 0;
    background: rgba(255, 183, 3, 0.1);
    padding: 1rem 3rem;
    border-radius: var(--border-radius-md);
    border: 1px dashed rgba(255, 183, 3, 0.3);
    text-align: center;
}

.direction-controls {
    margin-top: auto;
}

.arrow-pad {
    display: grid;
    grid-template-columns: 40px 40px 40px;
    grid-template-rows: 40px 40px 40px;
    gap: 5px;
}

.arrow {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.arrow.up {
    grid-column: 2;
    grid-row: 1;
    border-bottom: 2px solid var(--neon-cyan-main);
}

.arrow.left {
    grid-column: 1;
    grid-row: 2;
    border-right: 2px solid var(--neon-cyan-main);
}

.arrow.right {
    grid-column: 3;
    grid-row: 2;
    border-left: 2px solid var(--neon-cyan-main);
}

.arrow.down {
    grid-column: 2;
    grid-row: 3;
    border-top: 2px solid var(--neon-cyan-main);
}

.arrow.active {
    background: rgba(0, 243, 255, 0.2);
    box-shadow: 0 0 10px var(--neon-cyan-main);
}

.stats-card {
    grid-column: span 6;
}

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 1rem;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-heading);
}

.text-connected {
    color: var(--green-main);
    font-size: 0.9rem;
    text-shadow: 0 0 5px var(--green-glow);
}

.text-disconnected {
    color: #ff3333;
    font-size: 0.9rem;
    text-shadow: 0 0 5px rgba(255, 51, 51, 0.6);
}

.status-indicator.offline {
    background: rgba(255, 51, 51, 0.1);
    border: 1px solid rgba(255, 51, 51, 0.2);
}

.status-indicator.offline .pulsing-dot {
    background-color: #ff3333;
    box-shadow: 0 0 12px rgba(255, 51, 51, 0.6);
    animation: pulse-offline 2s infinite;
}

.status-indicator.offline .status-text {
    color: #ff3333;
}

@keyframes pulse-offline {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(255, 51, 51, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(255, 51, 51, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(255, 51, 51, 0);
    }
}

/* Manual Control Card */
.manual-control-card {
    grid-column: span 12;
    margin-top: 1rem;
}

/* Mode Switcher Buttons */
.mode-switch-group {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
}

.mode-btn {
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: var(--neon-cyan-main);
    color: var(--bg-dark);
    box-shadow: 0 0 15px var(--neon-cyan-glow);
}

.mode-btn#btn-manual.active {
    background: var(--amber-main);
    box-shadow: 0 0 15px var(--amber-glow);
}

/* Manual Control Card */
.manual-control-card {
    grid-column: span 12;
    margin-top: 1rem;
}

.header-with-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

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

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

input:checked+.toggle-slider {
    background-color: var(--neon-cyan-dim);
    border-color: var(--neon-cyan-main);
}

input:checked+.toggle-slider:before {
    transform: translateX(28px);
    background-color: var(--neon-cyan-main);
    box-shadow: 0 0 10px var(--neon-cyan-main);
}

/* Slider Controls */
.slider-controls {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    transition: opacity 0.3s ease;
}

.disabled-ui {
    opacity: 0.3;
    pointer-events: none;
}

.slider-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--neon-cyan-main);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px var(--neon-cyan-main);
}

.action-btn {
    padding: 1rem;
    background: var(--neon-cyan-dim);
    border: 1px solid var(--neon-cyan-main);
    color: var(--neon-cyan-main);
    border-radius: var(--border-radius-sm);
    font-family: var(--font-heading);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.action-btn:hover {
    background: var(--neon-cyan-main);
    color: var(--bg-dark);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: var(--text-secondary);
    color: var(--text-secondary);
    background: transparent;
}

/* Weather Card */
.weather-card {
    grid-column: span 6;
    margin-top: 1rem;
}

.weather-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
}

.current-weather {
    flex: 1 1 200px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    padding-right: 1.5rem;
}

.weather-main {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.weather-temp {
    font-size: 3rem;
    font-weight: 800;
}

.weather-desc {
    display: flex;
    flex-direction: column;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

#weather-condition {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: capitalize;
}

.hourly-forecast {
    flex: 2 1 300px;
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--neon-cyan-dim) transparent;
}

.hourly-forecast::-webkit-scrollbar {
    height: 6px;
}

.hourly-forecast::-webkit-scrollbar-thumb {
    background-color: var(--neon-cyan-dim);
    border-radius: 4px;
}

.forecast-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-sm);
    min-width: 80px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.forecast-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.forecast-icon {
    width: 40px;
    height: 40px;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.2));
}

.forecast-temp {
    font-weight: 700;
    color: var(--neon-cyan-main);
    margin-top: 0.5rem;
}

/* Chart Card */
.chart-card {
    grid-column: span 12;
    margin-top: 1.5rem;
}

.chart-container {
    width: 100%;
    height: 400px;
    position: relative;
}

/* Power Card */
.power-card {
    grid-column: span 6;
    margin-top: 1rem;
}

.power-stats {
    display: flex;
    justify-content: center;
    align-items: center;
}

.power-highlight {
    background: rgba(255, 183, 3, 0.05);
    /* Slight amber background tint */
    border: 1px solid rgba(255, 183, 3, 0.15);
    /* Amber border */
    padding: 1.5rem 2rem;
    border-radius: var(--border-radius-md);
    width: 100%;
    text-align: center;
}

.power-highlight .stat-label {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.power-highlight .stat-value {
    font-size: 3rem;
    margin-top: 0.5rem;
}

/* Responsive Design */
@media (max-width: 1024px) {

    .weather-card,
    .power-card {
        grid-column: span 12;
    }

    .current-weather {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding-right: 0;
        padding-bottom: 1.5rem;
    }

    .central-card {
        grid-column: span 12;
    }

    .gauges-card {
        grid-column: span 6;
    }

    .ldr-section {
        grid-column: span 6;
    }
}

@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    .header-container {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
        border-radius: var(--border-radius-md);
    }

    .gauges-card {
        grid-column: span 12;
    }

    .ldr-section {
        grid-column: span 12;
    }

    .direction-card {
        grid-column: span 12;
    }

    .stats-card {
        grid-column: span 12;
    }

    .sidebar-layout {
        grid-column: span 12;
    }
}

/* Modal & History Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-content {
    width: 100%;
    max-width: 1100px;
    height: 80vh;
    display: flex !important;
    flex-direction: column;
}

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

.history-chart-container {
    flex-grow: 1;
    min-height: 0;
    width: 100%;
    position: relative;
}

.history-controls {
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
}

.modal.active {
    display: flex !important;
}

/* Side-by-side charts row — full grid width */
.charts-row {
    display: flex;
    gap: 1.5rem;
    width: 100%;
    grid-column: 1 / -1;
    /* span ALL 12 columns */
}

.charts-row .chart-card {
    flex: 1;
    min-width: 0;
    /* prevent flex children from overflowing */
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* ==============================
   FOOTER
   ============================== */
footer.site-footer {
    width: 100%;
    max-width: 1280px;
    /* matches .dashboard max-width */
    margin: 1rem auto 0;
    padding: 1.2rem 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.82rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

footer.site-footer a {
    color: var(--neon-cyan-main);
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.2s;
}

footer.site-footer a:hover {
    opacity: 0.75;
    text-decoration: underline;
}

footer.site-footer .footer-divider {
    color: rgba(255, 255, 255, 0.2);
}

footer.site-footer .github-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

footer.site-footer .github-icon:hover {
    color: var(--neon-cyan-main);
    text-decoration: none;
}