:root {
    --bg-dark: #f0f4f8;
    --bg-panel: #ffffff;
    --text-main: #000000;
    --text-muted: #1e293b;
    --accent-primary: #2563eb; /* Blue for RPM */
    --accent-secondary: #d97706; /* Orange for Torque */
    --accent-success: #059669; /* Green */
    --accent-danger: #dc2626; /* Red */
    --accent-ac: #7c3aed; /* Purple for AC */
    --accent-dc: #0891b2; /* Cyan for DC */
    --accent-temp: #e11d48; /* Rose for Temp */
    
    --panel-border: rgba(0, 0, 0, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 0.5rem;
    gap: 0.5rem;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

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

.logo i {
    font-size: 1.25rem;
    color: var(--accent-primary);
}

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

.status-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0,0,0,0.05);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--accent-success);
    box-shadow: 0 0 10px rgba(5, 150, 105, 0.5);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.time-display {
    font-family: monospace;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Main Layout: CSS Grid */
.main-content {
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    gap: 0.5rem;
    flex: 1;
    min-height: 500px;
}

/* Panels */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.panel h2 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding-bottom: 0.25rem;
}

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

.sub-header {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mt-4 { margin-top: 1.5rem; }

/* Cards & Displays */
.gauge-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.value-card {
    background: #f8fafc;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(0,0,0,0.03);
    transition: transform 0.2s;
}

.value-card:hover {
    transform: translateY(-2px);
    border-color: rgba(0,0,0,0.1);
}

.label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.value-display {
    font-family: monospace;
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.value-display.small {
    font-size: 1.25rem;
    margin-bottom: 0;
}

/* Colors for specific readings */
.primary:nth-child(1) .value-display { color: var(--accent-primary); text-shadow: 0 0 10px rgba(37, 99, 235, 0.15); }
.primary:nth-child(2) .value-display { color: var(--accent-secondary); text-shadow: 0 0 10px rgba(217, 119, 6, 0.15); }

.temp .value-display { color: var(--accent-temp); }
.ac .value-display { color: var(--accent-ac); }
.dc .value-display { color: var(--accent-dc); }

.progress-bar {
    height: 4px;
    background: rgba(0,0,0,0.05);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    transition: width 0.1s linear;
}

.primary:nth-child(1) .fill { background: var(--accent-primary); }
.primary:nth-child(2) .fill { background: var(--accent-secondary); }

/* Grids */
.temp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
}

.electrical-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
}

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

/* Chart Canvas */
.chart-container {
    flex: 1;
    position: relative;
    width: 100%;
}

.legend-item {
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-left: 1rem;
    color: var(--text-main);
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.dot.rpm { background: var(--accent-primary); }
.dot.torque { background: var(--accent-secondary); }
.dot.voltage { background: var(--accent-ac); }
.dot.current { background: var(--accent-dc); }

/* Footer Controls */
.controls-bar {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.03);
}

.control-group {
    display: flex;
    gap: 1rem;
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

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

.btn-success {
    background: var(--accent-success);
    color: #fff;
}
.btn-success:not(:disabled):hover { background: #047857; }

.btn-danger {
    background: var(--accent-danger);
    color: #fff;
}
.btn-danger:not(:disabled):hover { background: #b91c1c; }

.btn-primary {
    background: var(--accent-primary);
    color: #fff;
}
.btn-primary:not(:disabled):hover { background: #1d4ed8; }

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

.record-status i {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.record-status.active { color: var(--accent-danger); }
.record-status.active i {
    color: var(--accent-danger);
    animation: pulse 1s infinite;
}

/* Responsive */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 250px 1fr 250px;
    }
}

@media (max-width: 992px) {
    body {
        height: auto;
        overflow: auto;
    }
    .app-container {
        height: auto;
    }
    .main-content {
        grid-template-columns: 1fr;
    }
    .panel {
        min-height: 400px;
    }
}
