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

:root {
    --bg-primary: #0f1923;
    --bg-card: #1a2733;
    --text-primary: #e8edf2;
    --text-secondary: #8899a6;
    --accent-blue: #1da1f2;
    --accent-green: #17bf63;
    --accent-orange: #f5a623;
    --accent-red: #e0245e;
    --border-color: #2a3f4f;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 2rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

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

header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.dashboard {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.card h2 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Gauge (SVG-based) --- */
.gauge-container {
    position: relative;
    width: 200px;
    height: 200px;
}

.gauge-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.gauge-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 12;
}

.gauge-fill {
    fill: none;
    stroke-width: 12;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease, stroke 0.5s ease;
}

.gauge-fill--temperature {
    stroke: var(--accent-blue);
}

.gauge-fill--battery {
    stroke: var(--accent-green);
}

.gauge-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.gauge-value .value {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.gauge-value .unit {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* --- Status --- */
.status-bar {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* --- Chart Section --- */
.chart-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem 2.5rem;
    box-shadow: var(--shadow);
}

.chart-section h2 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.chart-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.chart-controls button {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.4rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.chart-controls button:hover,
.chart-controls button.active {
    background: var(--accent-blue);
    color: var(--text-primary);
    border-color: var(--accent-blue);
}

#history-chart {
    width: 100%;
    height: 100%;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 450px;
}

/* --- Loading State --- */
.loading {
    color: var(--text-secondary);
    font-style: italic;
}

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

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

    .gauge-container {
        width: 160px;
        height: 160px;
    }

    .gauge-value .value {
        font-size: 2rem;
    }
}

/* --- Battery Icon (top-left) --- */
.battery-icon {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    z-index: 100;
}

.battery-icon__body {
    display: flex;
    gap: 2px;
    border: 2px solid var(--text-secondary);
    border-radius: 3px;
    padding: 3px;
    width: 40px;
    height: 20px;
    align-items: stretch;
}

.battery-icon__bar {
    flex: 1;
    background: var(--border-color);
    border-radius: 1px;
    transition: background 0.5s ease;
}

.battery-icon__bar.active {
    background: var(--accent-green);
}

.battery-icon__bar.low {
    background: var(--accent-red);
}

.battery-icon__bar.medium {
    background: var(--accent-orange);
}

.battery-icon__tip {
    width: 3px;
    height: 10px;
    background: var(--text-secondary);
    border-radius: 0 2px 2px 0;
    margin-left: -2px;
}

.battery-icon__label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: 0.3rem;
}
