* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #89dcff;
    --primary-dark: #0db7ef;
    --success: #9ece6a;
    --warning: #ff9e64;
    --danger: #f7768e;
    --bg-dark: #1e1e2e;
    --bg-light: #24283b;
    --text-primary: #c0caf5;
    --text-secondary: #7aa2f7;
    --border-color: #414868;
}

body {
    background: linear-gradient(135deg, #0f0e1e 0%, #1e1e2e 100%);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    min-height: 100vh;
    padding: 0;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 50% 50%, rgba(137, 220, 255, 0.05) 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(137, 220, 255, 0.1) 0%, rgba(13, 183, 239, 0.05) 100%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 5px;
    color: var(--primary);
    text-shadow: 0 0 20px rgba(137, 220, 255, 0.3);
}

.header .subtitle {
    color: var(--text-secondary);
    font-size: 0.95em;
}

/* Cards */
.card-base {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.card-base:hover {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(137, 220, 255, 0.1);
}

.status-card {
    display: flex;
    gap: 20px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.status-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-item .label {
    color: var(--text-secondary);
    font-weight: 600;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85em;
}

.status-idle {
    background: rgba(100, 100, 120, 0.3);
    color: #a0a0b0;
}

.status-active {
    background: rgba(158, 206, 106, 0.3);
    color: var(--success);
    animation: pulse 2s infinite;
}

.status-warning {
    background: rgba(255, 158, 100, 0.3);
    color: var(--warning);
    animation: pulse 1s infinite;
}

.status-error {
    background: rgba(247, 118, 142, 0.3);
    color: var(--danger);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Live Card */
.live-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    align-items: center;
}

.db-meter {
    display: flex;
    justify-content: center;
}

.db-meter canvas {
    width: 100%;
    max-width: 250px;
    height: auto;
    filter: drop-shadow(0 0 10px rgba(137, 220, 255, 0.2));
}

.db-display {
    text-align: center;
}

.db-value {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 5px;
    margin-bottom: 15px;
}

.db-value span:first-child {
    font-size: 3em;
    font-weight: 700;
    color: var(--primary);
    text-shadow: 0 0 20px rgba(137, 220, 255, 0.3);
}

.unit {
    font-size: 1.2em;
    color: var(--text-secondary);
}

.db-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.db-info small {
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Configuration Card */
.config-card {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.config-card h2 {
    font-size: 1.3em;
    margin-bottom: 20px;
    color: var(--primary);
}

.config-group {
    margin-bottom: 20px;
}

.config-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95em;
}

.config-group label span {
    color: var(--primary);
    font-weight: 700;
}

.config-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 0.85em;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    margin: 10px 0;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(137, 220, 255, 0.4);
    transition: all 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(137, 220, 255, 0.4);
    transition: all 0.2s ease;
}

.slider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 0.95em;
    transition: all 0.2s ease;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(137, 220, 255, 0.2);
}

/* Lamp Card */
.lamp-card {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.lamp-card h2 {
    font-size: 1.3em;
    margin-bottom: 20px;
    color: var(--primary);
}

.lamp-status {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-dark);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.lamp-indicator {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #444;
    transition: all 0.3s ease;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.lamp-indicator.on {
    background: #ffd700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6), inset 0 0 10px rgba(255, 215, 0, 0.3);
}

.lamp-info {
    flex: 1;
}

.lamp-info div:first-child {
    font-weight: 700;
    font-size: 1.1em;
    color: var(--text-primary);
}

.lamp-info small {
    color: var(--text-secondary);
    font-size: 0.9em;
}

.lamp-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

/* Buttons */
.btn {
    padding: 12px 16px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95em;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--bg-dark);
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(137, 220, 255, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--primary);
    color: var(--bg-dark);
}

.btn-small {
    padding: 8px 12px;
    font-size: 0.85em;
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Event Log */
.log-card {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.log-card h2 {
    font-size: 1.3em;
    margin-bottom: 15px;
    color: var(--primary);
}

.event-log {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 15px;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
}

.log-entry {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.success {
    color: var(--success);
}

.log-entry.warning {
    color: var(--warning);
}

.log-entry.error {
    color: var(--danger);
}

/* Help Card */
.help-card {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.help-card h2 {
    font-size: 1.3em;
    margin-bottom: 15px;
    color: var(--primary);
}

.help-list {
    list-style: none;
}

.help-list li {
    padding: 10px 0;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.help-list li:last-child {
    border-bottom: none;
}

.help-list strong {
    color: var(--primary);
}

/* Responsive */
@media (max-width: 500px) {
    .header h1 {
        font-size: 2em;
    }

    .live-card {
        grid-template-columns: 1fr;
    }

    .status-card {
        flex-direction: column;
        gap: 15px;
    }

    .db-value span:first-child {
        font-size: 2.5em;
    }

    .config-group {
        margin-bottom: 18px;
    }

    .lamp-controls {
        grid-template-columns: 1fr 1fr;
    }
}

/* Scrollbar Styling */
.event-log::-webkit-scrollbar {
    width: 6px;
}

.event-log::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-radius: 3px;
}

.event-log::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

.event-log::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
    }

    .container {
        max-width: 100%;
    }

    .card-base, .status-card, .live-card, .config-card, .lamp-card, .log-card, .help-card {
        page-break-inside: avoid;
        border: 1px solid #ccc;
        background: white;
    }
}
