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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #fff;
}

.header {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.title {
    font-size: 1.25rem;
    font-weight: 600;
    background: linear-gradient(90deg, #00d4ff, #00ff88);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff4757;
    transition: background-color 0.3s;
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: #2ed573;
}

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

.device-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.device-tab {
    flex: 1;
    min-width: 80px;
    padding: 10px 16px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.device-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.device-tab.active {
    background: linear-gradient(90deg, #00d4ff, #00ff88);
    color: #1a1a2e;
    font-weight: 600;
}

.main-content {
    padding: 16px;
    max-width: 1200px;
    margin: 0 auto;
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.data-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.data-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 212, 255, 0.1);
}

.data-card.p-type {
    border-left: 3px solid #00d4ff;
}

.data-card.a-type {
    border-left: 3px solid #ff6b6b;
}

.data-card.s-type {
    border-left: 3px solid #ffd93d;
}

.data-card.t-type {
    border-left: 3px solid #6bcb77;
}

.data-id {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.data-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}

.data-value .value {
    background: linear-gradient(135deg, #fff 0%, rgba(255, 255, 255, 0.7) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    transition: color 1s ease, text-shadow 1s ease, background 1s ease;
}

.data-value .value.flashing {
    color: #ff4757;
    background: linear-gradient(135deg, #ff4757 0%, #ff6b6b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(255, 71, 87, 0.6);
}

.data-status {
    font-size: 0.7rem;
    color: #2ed573;
}

.data-status.error {
    color: #ff4757;
}

.unit {
    font-size: 0.75rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.6);
    margin-left: 4px;
}

.alarm-active {
    background: rgba(255, 71, 87, 0.2) !important;
    border-color: rgba(255, 71, 87, 0.5) !important;
}

.alarm-active .data-value {
    color: #ff4757;
}

.alarm-active .data-status {
    color: #ff4757 !important;
    font-weight: 600;
}

.category-section {
    margin-bottom: 24px;
}

.category-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-icon {
    width: 4px;
    height: 16px;
    border-radius: 2px;
}

.category-icon.p { background: #00d4ff; }
.category-icon.a { background: #ff6b6b; }
.category-icon.s { background: #ffd93d; }
.category-icon.t { background: #6bcb77; }

.last-update {
    text-align: center;
    padding: 16px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.75rem;
}

.connection-error {
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid rgba(255, 71, 87, 0.3);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    margin-bottom: 16px;
    color: #ff6b6b;
    font-size: 0.875rem;
}

.refresh-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.3s;
}

.refresh-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

@media (min-width: 768px) {
    .data-grid {
        gap: 16px;
    }

    .data-card {
        padding: 20px;
    }

    .data-value {
        font-size: 1.75rem;
    }
}
